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/x86Props.sml
ViewVC logotype

Diff of /sml/trunk/src/MLRISC/x86/instructions/x86Props.sml

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

revision 499, Tue Dec 7 15:44:50 1999 UTC revision 545, Thu Feb 24 13:56:44 2000 UTC
# Line 7  Line 7 
7  struct  struct
8    structure I = X86Instr    structure I = X86Instr
9    structure C = I.C    structure C = I.C
10    structure LE = LabelExp    structure LE = I.LabelExp
11    
12    exception NegateConditional    exception NegateConditional
13    
14    fun error msg = MLRiscErrorMsg.error("X86Props",msg)    fun error msg = MLRiscErrorMsg.error("X86Props",msg)
15    
16    datatype kind = IK_JUMP | IK_NOP | IK_INSTR | IK_COPY | IK_CALL | IK_GROUP    datatype kind = IK_JUMP | IK_NOP | IK_INSTR | IK_COPY | IK_CALL
17                  | IK_PHI | IK_SOURCE | IK_SINK                  | IK_PHI | IK_SOURCE | IK_SINK
18    datatype target = LABELLED of Label.label | FALLTHROUGH | ESCAPES    datatype target = LABELLED of Label.label | FALLTHROUGH | ESCAPES
19   (*========================================================================   (*========================================================================
# Line 25  Line 25 
25      | instrKind (I.FCOPY _) = IK_COPY      | instrKind (I.FCOPY _) = IK_COPY
26      | instrKind (I.CALL _) = IK_CALL      | instrKind (I.CALL _) = IK_CALL
27      | instrKind (I.ANNOTATION{i,...}) = instrKind i      | instrKind (I.ANNOTATION{i,...}) = instrKind i
     | instrKind (I.GROUP _) = IK_GROUP  
28      | instrKind _ = IK_INSTR      | instrKind _ = IK_INSTR
29    
30    
# Line 86  Line 85 
85    *  Hashing and Equality on operands    *  Hashing and Equality on operands
86    *=====================================================================*)    *=====================================================================*)
87     fun hashOpn(I.Immed i) = Word.fromInt(Int32.toInt i)     fun hashOpn(I.Immed i) = Word.fromInt(Int32.toInt i)
88       | hashOpn(I.Const c) = I.Constant.hash c       | hashOpn(I.ImmedLabel le) = LE.hash le + 0w123
      | hashOpn(I.ImmedLabel le) = LabelExp.hash le + 0w123  
89       | hashOpn(I.Relative i) = Word.fromInt i + 0w1232       | hashOpn(I.Relative i) = Word.fromInt i + 0w1232
90       | hashOpn(I.LabelEA le) = LabelExp.hash le + 0w44444       | hashOpn(I.LabelEA le) = LE.hash le + 0w44444
91       | hashOpn(I.Direct r)  = Word.fromInt r       | hashOpn(I.Direct r)  = Word.fromInt r
92       | hashOpn(I.MemReg r)  = Word.fromInt r + 0w2123       | hashOpn(I.MemReg r)  = Word.fromInt r + 0w2123
93       | hashOpn(I.FDirect f) = Word.fromInt f + 0w8888       | hashOpn(I.FDirect f) = Word.fromInt f + 0w8888
94       | hashOpn(I.Displace {base, disp, ...}) = hashOpn disp + Word.fromInt base       | hashOpn(I.Displace {base, disp, ...}) =
95             hashOpn disp + Word.fromInt base
96       | hashOpn(I.Indexed {base, index, scale, disp, ...}) =       | hashOpn(I.Indexed {base, index, scale, disp, ...}) =
97           Word.fromInt index + Word.fromInt scale + hashOpn disp           Word.fromInt index + Word.fromInt scale + hashOpn disp
98     fun eqOpn(I.Immed a,I.Immed b) = a = b     fun eqOpn(I.Immed a,I.Immed b) = a = b
99       | eqOpn(I.Const a,I.Const b) = I.Constant.==(a,b)       | eqOpn(I.ImmedLabel a,I.ImmedLabel b) = LE.==(a,b)
      | eqOpn(I.ImmedLabel a,I.ImmedLabel b) = LabelExp.==(a,b)  
100       | eqOpn(I.Relative a,I.Relative b) = a = b       | eqOpn(I.Relative a,I.Relative b) = a = b
101       | eqOpn(I.LabelEA a,I.LabelEA b) = LabelExp.==(a,b)       | eqOpn(I.LabelEA a,I.LabelEA b) = LE.==(a,b)
102       | eqOpn(I.Direct a,I.Direct b) = a = b       | eqOpn(I.Direct a,I.Direct b) = a = b
103       | eqOpn(I.MemReg a,I.MemReg b) = a = b       | eqOpn(I.MemReg a,I.MemReg b) = a = b
104       | eqOpn(I.FDirect a,I.FDirect b) = a = b       | eqOpn(I.FDirect a,I.FDirect b) = a = b
# Line 138  Line 136 
136          | I.UMUL => (eaxPair, C.eax::uses)          | I.UMUL => (eaxPair, C.eax::uses)
137      end      end
138    
139      fun unary {unOp, opnd} = (operandDef opnd, operandUse opnd)      fun unary opnd = (operandDef opnd, operandUse opnd)
140        fun cmptest{lsrc, rsrc} = ([], operandAcc(lsrc, operandUse rsrc))
141        fun push arg = ([], operandUse arg)
142        fun float opnd = ([], operandUse opnd)
143    in    in
144      case instr      case instr
145       of I.JMP(opnd, _)        => ([], operandUse opnd)       of I.JMP(opnd, _)        => ([], operandUse opnd)
# Line 148  Line 149 
149        | I.MOVE{src, dst=I.MemReg r, ...} => ([r], operandUse src)        | I.MOVE{src, dst=I.MemReg r, ...} => ([r], operandUse src)
150        | I.MOVE{src, dst, ...} => ([], operandAcc(dst, operandUse src))        | I.MOVE{src, dst, ...} => ([], operandAcc(dst, operandUse src))
151        | I.LEA{r32, addr}      => ([r32], operandUse addr)        | I.LEA{r32, addr}      => ([r32], operandUse addr)
152        | I.CMP{lsrc, rsrc}     => ([], operandAcc(lsrc, operandUse rsrc))        | ( I.CMPL arg | I.CMPW arg | I.CMPB arg
153        | I.BINARY{src,dst,...} => (operandDef dst, operandAcc(src, operandUse dst))          | I.TESTL arg | I.TESTW arg | I.TESTB arg) => cmptest arg
154          | I.BINARY{binOp=I.XORL,src=I.Direct rs,dst=I.Direct rd,...} =>
155               if rs=rd then ([rd],[]) else ([rd],[rs,rd])
156          | I.BINARY{src,dst,...} =>
157               (operandDef dst, operandAcc(src, operandUse dst))
158          | I.LEAVE               => error "leave"
159        | I.MULTDIV arg         => multdiv arg        | I.MULTDIV arg         => multdiv arg
160        | I.MUL3{src1, src2=SOME _, dst}=> ([dst], operandUse src1)        | I.MUL3{src1, src2=SOME _, dst}=> ([dst], operandUse src1)
161        | I.MUL3{src1, dst, ...}=> ([dst], dst::operandUse src1)        | I.MUL3{src1, dst, ...}=> ([dst], dst::operandUse src1)
162    
163        | I.UNARY arg           => unary arg        | I.UNARY{opnd, ...}    => unary opnd
164        | I.PUSH arg            => ([], operandUse arg)        | I.SET{opnd, ...}      => unary opnd
165          | ( I.PUSHL arg | I.PUSHW arg | I.PUSHB arg ) => push arg
166        | I.POP arg             => (operandDef arg, [])        | I.POP arg             => (operandDef arg, [])
167        | I.CDQ                 => ([C.edx], [C.eax])        | I.CDQ                 => ([C.edx], [C.eax])
168    
169        | I.COPY{dst, src, tmp=SOME(I.Direct r), ...}   => (r::dst, src)        | I.COPY{dst, src, tmp=SOME(I.Direct r), ...}   => (r::dst, src)
170        | I.COPY{dst, src, ...} => (dst, src)        | I.COPY{dst, src, ...} => (dst, src)
171        | I.FSTP opnd           => ([], operandUse opnd)        | I.FSTPL opnd          => float opnd
172        | I.FLD opnd            => ([], operandUse opnd)        | I.FSTPS opnd          => float opnd
173        | I.FILD opnd           => ([], operandUse opnd)        | I.FLDL opnd           => float opnd
174          | I.FLDS opnd           => float opnd
175          | I.FILD opnd           => float opnd
176        | I.FBINARY{src, ...}   => ([], operandUse src)        | I.FBINARY{src, ...}   => ([], operandUse src)
177          | I.FENV{opnd, ...}     => ([], operandUse opnd)
178        | I.FNSTSW              => ([C.eax], [])        | I.FNSTSW              => ([C.eax], [])
179        | I.SAHF                => ([], [C.eax])        | I.SAHF                => ([], [C.eax])
180            (* This sets the low order byte,
181             * do potentially it may define *and* use
182             *)
183          | I.CMOV{src,dst,...} => ([dst], operandAcc(src, [dst]))
184        | I.ANNOTATION{a, i, ...} => defUseR i        | I.ANNOTATION{a, i, ...} => defUseR i
185        | _                     => ([], [])        | _                     => ([], [])
186    end (* defUseR *)    end (* defUseR *)
# Line 176  Line 190 
190        | operand _ = []        | operand _ = []
191    in    in
192      case instr      case instr
193       of I.FSTP opnd             => (operand opnd, [])       of I.FSTPL opnd            => (operand opnd, [])
194        | I.FLD opnd              => ([], operand opnd)        | I.FSTPS opnd            => (operand opnd, [])
195          | I.FLDL opnd             => ([], operand opnd)
196          | I.FLDS opnd             => ([], operand opnd)
197        | I.CALL(_, defs, uses,_) => (#2 defs, #2 uses)        | I.CALL(_, defs, uses,_) => (#2 defs, #2 uses)
198        | I.FBINARY{dst, src, ...}=> (operand dst, operand dst @ operand src)        | I.FBINARY{dst, src, ...}=> (operand dst, operand dst @ operand src)
199        | I.FCOPY{dst, src, tmp=SOME(I.FDirect f), ...}  => (f::dst, src)        | I.FCOPY{dst, src, tmp=SOME(I.FDirect f), ...}  => (f::dst, src)
# Line 197  Line 213 
213         let val (i,an) = getAnnotations i in (i,a::an) end         let val (i,an) = getAnnotations i in (i,a::an) end
214      | getAnnotations i = (i,[])      | getAnnotations i = (i,[])
215    fun annotate(i,a) = I.ANNOTATION{i=i,a=a}    fun annotate(i,a) = I.ANNOTATION{i=i,a=a}
   
   (*========================================================================  
    *  Groups  
    *========================================================================*)  
   fun getGroup(I.ANNOTATION{i,...}) = getGroup i  
     | getGroup(I.GROUP r) = r  
     | getGroup _ = error "getGroup"  
   
   val makeGroup = I.GROUP  
216  end  end
217    

Legend:
Removed from v.499  
changed lines
  Added in v.545

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