SCM Repository
[smlnj] Diff of /sml/trunk/src/MLRISC/x86/instructions/x86Peephole.sml
Diff of /sml/trunk/src/MLRISC/x86/instructions/x86Peephole.sml
Parent Directory
|
Revision Log
|
Patch
11 |
| isZero(I.ImmedLabel le) = I.LabelExp.valueOf le = 0 |
| isZero(I.ImmedLabel le) = I.LabelExp.valueOf le = 0 |
12 |
| isZero _ = false |
| isZero _ = false |
13 |
|
|
14 |
|
fun isZeroOpt NONE = true |
15 |
|
| isZeroOpt (SOME opn) = isZero opn |
16 |
|
|
17 |
fun loop(code, instrs) = |
fun loop(code, instrs) = |
18 |
(case code of |
(case code of |
19 |
[] => rev instrs |
[] => rev instrs |
30 |
loop(rest, instrs) |
loop(rest, instrs) |
31 |
else loop(rest, i::instrs) |
else loop(rest, i::instrs) |
32 |
|
|
33 |
(* subl 4, %esp |
(* push folding: |
34 |
|
* subl 4, %esp |
35 |
* movl src, 0(%esp) (where src <> %esp !!! ) |
* movl src, 0(%esp) (where src <> %esp !!! ) |
36 |
* => |
* => |
37 |
* pushl src |
* pushl src |
62 |
else |
else |
63 |
loop(rest, i::instrs) |
loop(rest, i::instrs) |
64 |
|
|
65 |
|
(* |
66 |
|
* addl N, %esp |
67 |
|
* ret |
68 |
|
* => |
69 |
|
* ret N |
70 |
|
*) |
71 |
|
| (i as I.RET operand)::(j as I.BINARY{binOp=I.ADDL, src, dst}):: |
72 |
|
rest => if isStackPtr dst andalso isZeroOpt operand |
73 |
|
then loop(rest, I.RET (SOME src)::instrs) |
74 |
|
else loop(rest, j::i::instrs) |
75 |
|
|
76 |
| i::rest => loop(rest, i::instrs) |
| i::rest => loop(rest, i::instrs) |
77 |
) |
) |
78 |
in loop(instrs, []) |
in loop(instrs, []) |
|
Legend:
Removed from v.659 |
|
changed lines |
|
Added in v.660 |
|
|