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 796, Tue Mar 6 00:04:33 2001 UTC revision 984, Wed Nov 21 19:00:08 2001 UTC
# Line 3  Line 3 
3   * COPYRIGHT (c) 1997 Bell Laboratories.   * COPYRIGHT (c) 1997 Bell Laboratories.
4   *)   *)
5    
6  functor X86Props(X86Instr : X86INSTR) : INSN_PROPERTIES =  functor X86Props
7      (structure Instr : X86INSTR
8       structure MLTreeHash : MLTREE_HASH where T = Instr.T
9       structure MLTreeEval : MLTREE_EVAL where T = Instr.T
10      ) : INSN_PROPERTIES =
11  struct  struct
12    structure I = X86Instr    structure I = Instr
13    structure C = I.C    structure C = I.C
   structure LE = I.LabelExp  
14    structure T = I.T    structure T = I.T
15      structure CB = CellsBasis
16    
17    exception NegateConditional    exception NegateConditional
18    
# Line 102  Line 106 
106    *  Hashing and Equality on operands    *  Hashing and Equality on operands
107    *=====================================================================*)    *=====================================================================*)
108     fun hashOpn(I.Immed i) = Word.fromInt(Int32.toInt i)     fun hashOpn(I.Immed i) = Word.fromInt(Int32.toInt i)
109       | hashOpn(I.ImmedLabel le) = LE.hash le + 0w123       | hashOpn(I.ImmedLabel le) = MLTreeHash.hash le + 0w123
110       | hashOpn(I.Relative i) = Word.fromInt i + 0w1232       | hashOpn(I.Relative i) = Word.fromInt i + 0w1232
111       | hashOpn(I.LabelEA le) = LE.hash le + 0w44444       | hashOpn(I.LabelEA le) = MLTreeHash.hash le + 0w44444
112       | hashOpn(I.Direct r)  = C.hashCell r       | hashOpn(I.Direct r)  = CB.hashCell r
113       | hashOpn(I.MemReg r)  = C.hashCell r + 0w2123       | hashOpn(I.MemReg r)  = CB.hashCell r + 0w2123
114       | hashOpn(I.ST f) = C.hashCell f + 0w88       | hashOpn(I.ST f) = CB.hashCell f + 0w88
115       | hashOpn(I.FPR f) = C.hashCell f + 0w881       | hashOpn(I.FPR f) = CB.hashCell f + 0w881
116       | hashOpn(I.FDirect f) = C.hashCell f + 0w31245       | hashOpn(I.FDirect f) = CB.hashCell f + 0w31245
117       | hashOpn(I.Displace {base, disp, ...}) =       | hashOpn(I.Displace {base, disp, ...}) =
118           hashOpn disp + C.hashCell base           hashOpn disp + CB.hashCell base
119       | hashOpn(I.Indexed {base, index, scale, disp, ...}) =       | hashOpn(I.Indexed {base, index, scale, disp, ...}) =
120           C.hashCell index + Word.fromInt scale + hashOpn disp           CB.hashCell index + Word.fromInt scale + hashOpn disp
121     fun eqOpn(I.Immed a,I.Immed b) = a = b     fun eqOpn(I.Immed a,I.Immed b) = a = b
122       | eqOpn(I.ImmedLabel a,I.ImmedLabel b) = LE.==(a,b)       | eqOpn(I.ImmedLabel a,I.ImmedLabel b) = MLTreeEval.==(a,b)
123       | eqOpn(I.Relative a,I.Relative b) = a = b       | eqOpn(I.Relative a,I.Relative b) = a = b
124       | eqOpn(I.LabelEA a,I.LabelEA b) = LE.==(a,b)       | eqOpn(I.LabelEA a,I.LabelEA b) = MLTreeEval.==(a,b)
125       | eqOpn(I.Direct a,I.Direct b) = C.sameColor(a,b)       | eqOpn(I.Direct a,I.Direct b) = CB.sameColor(a,b)
126       | eqOpn(I.MemReg a,I.MemReg b) = C.sameColor(a,b)       | eqOpn(I.MemReg a,I.MemReg b) = CB.sameColor(a,b)
127       | eqOpn(I.FDirect a,I.FDirect b) = C.sameColor(a,b)       | eqOpn(I.FDirect a,I.FDirect b) = CB.sameColor(a,b)
128       | eqOpn(I.ST a,I.ST b) = C.sameColor(a,b)       | eqOpn(I.ST a,I.ST b) = CB.sameColor(a,b)
129       | eqOpn(I.FPR a,I.FPR b) = C.sameColor(a,b)       | eqOpn(I.FPR a,I.FPR b) = CB.sameColor(a,b)
130       | eqOpn(I.Displace{base=a,disp=b,...},I.Displace{base=c,disp=d,...}) =       | eqOpn(I.Displace{base=a,disp=b,...},I.Displace{base=c,disp=d,...}) =
131            C.sameColor(a,c) andalso eqOpn(b,d)            CB.sameColor(a,c) andalso eqOpn(b,d)
132       | eqOpn(I.Indexed{base=a,index=b,scale=c,disp=d,...},       | eqOpn(I.Indexed{base=a,index=b,scale=c,disp=d,...},
133               I.Indexed{base=e,index=f,scale=g,disp=h,...}) =               I.Indexed{base=e,index=f,scale=g,disp=h,...}) =
134            C.sameColor(b,f) andalso c = g            CB.sameColor(b,f) andalso c = g
135            andalso sameCellOption(a,e) andalso eqOpn(d,h)            andalso sameCellOption(a,e) andalso eqOpn(d,h)
136       | eqOpn _ = false       | eqOpn _ = false
137     and sameCellOption(NONE, NONE) = true     and sameCellOption(NONE, NONE) = true
138       | sameCellOption(SOME x, SOME y) = C.sameColor(x,y)       | sameCellOption(SOME x, SOME y) = CB.sameColor(x,y)
139       | sameCellOption _ = false       | sameCellOption _ = false
140    
141   (*========================================================================   (*========================================================================
# Line 160  Line 164 
164        val uses = operandUse src        val uses = operandUse src
165      in      in
166        case multDivOp        case multDivOp
167         of (I.IDIVL | I.DIVL) => (eaxPair, C.edx::C.eax::uses)         of (I.IDIVL1 | I.DIVL1) => (eaxPair, C.edx::C.eax::uses)
168          | I.MULL => (eaxPair, C.eax::uses)          | I.MULL1 => (eaxPair, C.eax::uses)
169      end      end
170    
171      fun unary opnd = (operandDef opnd, operandUse opnd)      fun unary opnd = (operandDef opnd, operandUse opnd)
172      fun cmptest{lsrc, rsrc} = ([], operandAcc(lsrc, operandUse rsrc))      fun cmptest{lsrc, rsrc} = ([], operandAcc(lsrc, operandUse rsrc))
173        fun espOnly()  = let val sp = [C.stackptrR] in (sp, sp) end
174      fun push arg = ([C.stackptrR], operandAcc(arg, [C.stackptrR]))      fun push arg = ([C.stackptrR], operandAcc(arg, [C.stackptrR]))
175      fun float opnd = ([], operandUse opnd)      fun float opnd = ([], operandUse opnd)
176    in    in
# Line 182  Line 187 
187          | I.TESTL arg | I.TESTW arg | I.TESTB arg ) => cmptest arg          | I.TESTL arg | I.TESTW arg | I.TESTB arg ) => cmptest arg
188        | I.BITOP{lsrc, rsrc, ...} => cmptest{lsrc=lsrc,rsrc=rsrc}        | I.BITOP{lsrc, rsrc, ...} => cmptest{lsrc=lsrc,rsrc=rsrc}
189        | I.BINARY{binOp=I.XORL,src=I.Direct rs,dst=I.Direct rd,...} =>        | I.BINARY{binOp=I.XORL,src=I.Direct rs,dst=I.Direct rd,...} =>
190             if C.sameColor(rs,rd) then ([rd],[]) else ([rd],[rs,rd])             if CB.sameColor(rs,rd) then ([rd],[]) else ([rd],[rs,rd])
191        | I.BINARY{src,dst,...} =>        | I.BINARY{src,dst,...} =>
192             (operandDef dst, operandAcc(src, operandUse dst))             (operandDef dst, operandAcc(src, operandUse dst))
193          | I.CMPXCHG{src, dst, ...} =>
194               (C.eax::operandDef dst, C.eax::operandAcc(src, operandUse dst))
195        | I.ENTER _             => ([C.esp, C.ebp], [C.esp, C.ebp])        | I.ENTER _             => ([C.esp, C.ebp], [C.esp, C.ebp])
196        | I.LEAVE               => ([C.esp, C.ebp], [C.esp, C.ebp])        | I.LEAVE               => ([C.esp, C.ebp], [C.esp, C.ebp])
197        | I.MULTDIV arg         => multdiv arg        | I.MULTDIV arg         => multdiv arg
198        | I.MUL3{src1, src2=SOME _, dst}=> ([dst], operandUse src1)        | I.MUL3{src1, dst, ...}=> ([dst], operandUse src1)
       | I.MUL3{src1, dst, ...}=> ([dst], dst::operandUse src1)  
199    
200        | I.UNARY{opnd, ...}    => unary opnd        | I.UNARY{opnd, ...}    => unary opnd
201        | I.SET{opnd, ...}      => unary opnd        | I.SET{opnd, ...}      => unary opnd
202        | ( I.PUSHL arg | I.PUSHW arg | I.PUSHB arg ) => push arg        | ( I.PUSHL arg | I.PUSHW arg | I.PUSHB arg ) => push arg
203        | I.POP arg             => (C.stackptrR::operandDef arg, [C.stackptrR])        | I.POP arg             => (C.stackptrR::operandDef arg, [C.stackptrR])
204          | I.PUSHFD              => espOnly()
205          | I.POPFD               => espOnly()
206        | I.CDQ                 => ([C.edx], [C.eax])        | I.CDQ                 => ([C.edx], [C.eax])
207    
208        | I.COPY{dst, src, tmp=SOME(I.Direct r), ...}   => (r::dst, src)        | I.COPY{dst, src, tmp=SOME(I.Direct r), ...}   => (r::dst, src)
# Line 224  Line 232 
232        | I.FUNOP{src, dst, ...} => operandUse2(src, dst)        | I.FUNOP{src, dst, ...} => operandUse2(src, dst)
233    
234        | I.SAHF                => ([], [C.eax])        | I.SAHF                => ([], [C.eax])
235          | I.LAHF                => ([C.eax], [])
236          (* This sets the low order byte,          (* This sets the low order byte,
237           * do potentially it may define *and* use           * do potentially it may define *and* use
238           *)           *)
239        | I.CMOV{src,dst,...} => ([dst], operandAcc(src, [dst]))        | I.CMOV{src,dst,...} => ([dst], operandAcc(src, [dst]))
240        | I.ANNOTATION{a=C.DEF_USE{cellkind=C.GP,defs,uses}, i, ...} =>        | I.ANNOTATION{a=CB.DEF_USE{cellkind=CB.GP,defs,uses}, i, ...} =>
241          let val (d,u) = defUseR i in (defs@d, u@uses) end          let val (d,u) = defUseR i in (defs@d, u@uses) end
242        | I.ANNOTATION{a, i, ...} => defUseR i        | I.ANNOTATION{a, i, ...} => defUseR i
243        | _                     => ([], [])        | _                     => ([], [])
# Line 276  Line 285 
285        | I.FIBINOP{lsrc, rsrc, dst, ...} => fbinop(lsrc, rsrc, dst)        | I.FIBINOP{lsrc, rsrc, dst, ...} => fbinop(lsrc, rsrc, dst)
286        | I.FUNOP{src, dst, ...} => (operand dst, operand src)        | I.FUNOP{src, dst, ...} => (operand dst, operand src)
287    
288        | I.ANNOTATION{a=C.DEF_USE{cellkind=C.FP,defs,uses}, i, ...} =>        | I.ANNOTATION{a=CB.DEF_USE{cellkind=CB.FP,defs,uses}, i, ...} =>
289          let val (d,u) = defUseF i in (defs@d, u@uses) end          let val (d,u) = defUseF i in (defs@d, u@uses) end
290        | I.ANNOTATION{a, i, ...} => defUseF i        | I.ANNOTATION{a, i, ...} => defUseF i
291        | _  => ([], [])        | _  => ([], [])
292    end    end
293    
294    fun defUse C.GP = defUseR    fun defUse CB.GP = defUseR
295      | defUse C.FP = defUseF      | defUse CB.FP = defUseF
296      | defUse _ = error "defUse"      | defUse _ = error "defUse"
297    
298    (*========================================================================    (*========================================================================

Legend:
Removed from v.796  
changed lines
  Added in v.984

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