Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/trunk/src/MLRISC/x86/instructions/x86Peephole.peep
ViewVC logotype

Diff of /sml/trunk/src/MLRISC/x86/instructions/x86Peephole.peep

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 898, Mon Aug 13 17:44:08 2001 UTC revision 899, Mon Aug 13 21:14:31 2001 UTC
# Line 21  Line 21 
21  struct  struct
22     structure I = X86Instr     structure I = X86Instr
23     structure C = I.C     structure C = I.C
24       structure CBase = CellsBasis
25    
26     (* IMPORTANT: instructions are given in forward order *)     (* IMPORTANT: instructions are given in forward order *)
27     fun peephole instrs =     fun peephole instrs =
28     let fun isStackPtr(I.Direct r) = C.sameColor(r, C.esp)     let fun isStackPtr(I.Direct r) = CBase.sameColor(r, C.esp)
29           | isStackPtr _ = false           | isStackPtr _ = false
30    
31         fun isZero(I.Immed n) = n = 0         fun isZero(I.Immed n) = n = 0
# Line 46  Line 47 
47                (* remove lea 0(r), r *)                (* remove lea 0(r), r *)
48             | I.LEA{r32, addr=I.Displace{base, disp=I.ImmedLabel le,...}}::rest             | I.LEA{r32, addr=I.Displace{base, disp=I.ImmedLabel le,...}}::rest
49                  where I.LabelExp.valueOf le = 0 andalso                  where I.LabelExp.valueOf le = 0 andalso
50                        C.sameColor(r32,base) => loop(rest, instrs)                        CBase.sameColor(r32,base) => loop(rest, instrs)
51    
52               (*   addl n, %esp; subl m, %esp               (*   addl n, %esp; subl m, %esp
53                * => addl (n-m), %esp     ;; when m < n                * => addl (n-m), %esp     ;; when m < n
# Line 56  Line 57 
57             | I.BINARY{binOp=I.ADDL, src=I.Immed n, dst=I.Direct d_i}::             | I.BINARY{binOp=I.ADDL, src=I.Immed n, dst=I.Direct d_i}::
58               I.BINARY{binOp=I.SUBL, src=I.Immed m, dst=I.Direct d_j}::               I.BINARY{binOp=I.SUBL, src=I.Immed m, dst=I.Direct d_j}::
59               rest               rest
60                  where C.sameColor(d_i, C.esp) andalso                  where CBase.sameColor(d_i, C.esp) andalso
61                        C.sameColor(d_j, C.esp) =>                        CBase.sameColor(d_j, C.esp) =>
62                    if (m = n) then loop (rest, instrs)                    if (m = n) then loop (rest, instrs)
63                    else if (m < n) then                    else if (m < n) then
64                      loop(rest,                      loop(rest,
# Line 77  Line 78 
78             | I.BINARY{binOp=I.SUBL, src=I.Immed 4, dst=I.Direct dst_i}::             | I.BINARY{binOp=I.SUBL, src=I.Immed 4, dst=I.Direct dst_i}::
79               I.MOVE{mvOp=I.MOVL,src,dst=I.Displace{base,disp=I.Immed 0,...}}               I.MOVE{mvOp=I.MOVL,src,dst=I.Displace{base,disp=I.Immed 0,...}}
80               ::rest               ::rest
81                 where C.sameColor(base, C.esp) andalso                 where CBase.sameColor(base, C.esp) andalso
82                       C.sameColor(dst_i, C.esp) andalso                       CBase.sameColor(dst_i, C.esp) andalso
83                       not(isStackPtr src) =>                       not(isStackPtr src) =>
84                 loop(rest, I.PUSHL src::instrs)                 loop(rest, I.PUSHL src::instrs)
85    
# Line 92  Line 93 
93                      src=I.Displace{base, disp=I.Immed 0, ...}, dst}::                      src=I.Displace{base, disp=I.Immed 0, ...}, dst}::
94               I.BINARY{binOp=I.ADDL, src=I.Immed 4, dst=I.Direct dst_i}::               I.BINARY{binOp=I.ADDL, src=I.Immed 4, dst=I.Direct dst_i}::
95               rest               rest
96                 where C.sameColor(base, C.esp) andalso                 where CBase.sameColor(base, C.esp) andalso
97                       C.sameColor(dst_i,C.esp) andalso                       CBase.sameColor(dst_i,C.esp) andalso
98                       not(isStackPtr dst) =>                       not(isStackPtr dst) =>
99                 loop(rest, I.POP dst::instrs)                 loop(rest, I.POP dst::instrs)
100    

Legend:
Removed from v.898  
changed lines
  Added in v.899

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0