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 731, Fri Nov 10 22:57:45 2000 UTC revision 796, Tue Mar 6 00:04:33 2001 UTC
# Line 8  Line 8 
8    structure I = X86Instr    structure I = X86Instr
9    structure C = I.C    structure C = I.C
10    structure LE = I.LabelExp    structure LE = I.LabelExp
11      structure T = I.T
12    
13    exception NegateConditional    exception NegateConditional
14    
15    fun error msg = MLRiscErrorMsg.error("X86Props",msg)    fun error msg = MLRiscErrorMsg.error("X86Props",msg)
16    
17    datatype kind = IK_JUMP | IK_NOP | IK_INSTR | IK_COPY | IK_CALL    datatype kind = IK_JUMP | IK_NOP | IK_INSTR | IK_COPY | IK_CALL
18                  | IK_PHI | IK_SOURCE | IK_SINK                  | IK_CALL_WITH_CUTS | IK_PHI | IK_SOURCE | IK_SINK
19    datatype target = LABELLED of Label.label | FALLTHROUGH | ESCAPES    datatype target = LABELLED of Label.label | FALLTHROUGH | ESCAPES
20   (*========================================================================   (*========================================================================
21    *  Instruction Kinds    *  Instruction Kinds
# Line 23  Line 24 
24      | instrKind (I.JCC _) = IK_JUMP      | instrKind (I.JCC _) = IK_JUMP
25      | instrKind (I.COPY _) = IK_COPY      | instrKind (I.COPY _) = IK_COPY
26      | instrKind (I.FCOPY _) = IK_COPY      | instrKind (I.FCOPY _) = IK_COPY
27        | instrKind (I.CALL{cutsTo=_::_,...}) = IK_CALL_WITH_CUTS
28      | instrKind (I.CALL _) = IK_CALL      | instrKind (I.CALL _) = IK_CALL
29      | instrKind (I.PHI _)    = IK_PHI      | instrKind (I.PHI _)    = IK_PHI
30      | instrKind (I.SOURCE _) = IK_SOURCE      | instrKind (I.SOURCE _) = IK_SOURCE
# Line 72  Line 74 
74    fun branchTargets(I.JMP(_, [])) = [ESCAPES]    fun branchTargets(I.JMP(_, [])) = [ESCAPES]
75      | branchTargets(I.JMP(_, labs)) = map LABELLED labs      | branchTargets(I.JMP(_, labs)) = map LABELLED labs
76      | branchTargets(I.RET _) = [ESCAPES]      | branchTargets(I.RET _) = [ESCAPES]
77      | branchTargets(I.JCC{opnd=I.ImmedLabel(LE.LABEL(lab)), ...}) =      | branchTargets(I.JCC{opnd=I.ImmedLabel(T.LABEL(lab)), ...}) =
78          [FALLTHROUGH, LABELLED lab]          [FALLTHROUGH, LABELLED lab]
79        | branchTargets(I.CALL{cutsTo, ...}) = FALLTHROUGH :: map LABELLED cutsTo
80      | branchTargets(I.ANNOTATION{i,...}) = branchTargets i      | branchTargets(I.ANNOTATION{i,...}) = branchTargets i
81      | branchTargets _ = error "branchTargets"      | branchTargets _ = error "branchTargets"
82    
83    fun jump label = I.JMP (I.ImmedLabel(LE.LABEL label), [label])    fun jump label = I.JMP (I.ImmedLabel(T.LABEL label), [label])
84    
85    exception NotImplemented    exception NotImplemented
86    fun setTargets(I.JMP(I.ImmedLabel _,_),[l]) = jump l    fun setTargets(I.JMP(I.ImmedLabel _,_),[l]) = jump l
87      | setTargets(I.JMP(opnd,_),_) = error "setTargets"      | setTargets(I.JMP(opnd,_),_) = error "setTargets"
88      | setTargets(I.JCC{cond,opnd=I.ImmedLabel _},[f,t]) =      | setTargets(I.JCC{cond,opnd=I.ImmedLabel _},[f,t]) =
89          I.JCC{cond=cond,opnd=I.ImmedLabel(LE.LABEL t)}          I.JCC{cond=cond,opnd=I.ImmedLabel(T.LABEL t)}
90      | setTargets(I.JCC _,_) = error "setTargets"      | setTargets(I.JCC _,_) = error "setTargets"
91      | setTargets(I.ANNOTATION{i,a},l) = I.ANNOTATION{i=setTargets(i,l),a=a}      | setTargets(I.ANNOTATION{i,a},l) = I.ANNOTATION{i=setTargets(i,l),a=a}
92      | setTargets(i,_) = i      | setTargets(i,_) = i
# Line 102  Line 105 
105       | hashOpn(I.ImmedLabel le) = LE.hash le + 0w123       | hashOpn(I.ImmedLabel le) = LE.hash le + 0w123
106       | hashOpn(I.Relative i) = Word.fromInt i + 0w1232       | hashOpn(I.Relative i) = Word.fromInt i + 0w1232
107       | hashOpn(I.LabelEA le) = LE.hash le + 0w44444       | hashOpn(I.LabelEA le) = LE.hash le + 0w44444
108       | hashOpn(I.Direct r)  = Word.fromInt r       | hashOpn(I.Direct r)  = C.hashCell r
109       | hashOpn(I.MemReg r)  = Word.fromInt r + 0w2123       | hashOpn(I.MemReg r)  = C.hashCell r + 0w2123
110       | hashOpn(I.ST f) = Word.fromInt f + 0w88       | hashOpn(I.ST f) = C.hashCell f + 0w88
111       | hashOpn(I.FPR f) = Word.fromInt f + 0w881       | hashOpn(I.FPR f) = C.hashCell f + 0w881
112       | hashOpn(I.FDirect f) = Word.fromInt f + 0w31245       | hashOpn(I.FDirect f) = C.hashCell f + 0w31245
113       | hashOpn(I.Displace {base, disp, ...}) =       | hashOpn(I.Displace {base, disp, ...}) =
114           hashOpn disp + Word.fromInt base           hashOpn disp + C.hashCell base
115       | hashOpn(I.Indexed {base, index, scale, disp, ...}) =       | hashOpn(I.Indexed {base, index, scale, disp, ...}) =
116           Word.fromInt index + Word.fromInt scale + hashOpn disp           C.hashCell index + Word.fromInt scale + hashOpn disp
117     fun eqOpn(I.Immed a,I.Immed b) = a = b     fun eqOpn(I.Immed a,I.Immed b) = a = b
118       | eqOpn(I.ImmedLabel a,I.ImmedLabel b) = LE.==(a,b)       | eqOpn(I.ImmedLabel a,I.ImmedLabel b) = LE.==(a,b)
119       | eqOpn(I.Relative a,I.Relative b) = a = b       | eqOpn(I.Relative a,I.Relative b) = a = b
120       | eqOpn(I.LabelEA a,I.LabelEA b) = LE.==(a,b)       | eqOpn(I.LabelEA a,I.LabelEA b) = LE.==(a,b)
121       | eqOpn(I.Direct a,I.Direct b) = a = b       | eqOpn(I.Direct a,I.Direct b) = C.sameColor(a,b)
122       | eqOpn(I.MemReg a,I.MemReg b) = a = b       | eqOpn(I.MemReg a,I.MemReg b) = C.sameColor(a,b)
123       | eqOpn(I.FDirect a,I.FDirect b) = a = b       | eqOpn(I.FDirect a,I.FDirect b) = C.sameColor(a,b)
124       | eqOpn(I.ST a,I.ST b) = a = b       | eqOpn(I.ST a,I.ST b) = C.sameColor(a,b)
125       | eqOpn(I.FPR a,I.FPR b) = a = b       | eqOpn(I.FPR a,I.FPR b) = C.sameColor(a,b)
126       | 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,...}) =
127            a = c andalso eqOpn(b,d)            C.sameColor(a,c) andalso eqOpn(b,d)
128       | eqOpn(I.Indexed{base=a,index=b,scale=c,disp=d,...},       | eqOpn(I.Indexed{base=a,index=b,scale=c,disp=d,...},
129               I.Indexed{base=e,index=f,scale=g,disp=h,...}) =               I.Indexed{base=e,index=f,scale=g,disp=h,...}) =
130            b = f andalso c = g andalso a = e andalso eqOpn(d,h)            C.sameColor(b,f) andalso c = g
131              andalso sameCellOption(a,e) andalso eqOpn(d,h)
132       | eqOpn _ = false       | eqOpn _ = false
133       and sameCellOption(NONE, NONE) = true
134         | sameCellOption(SOME x, SOME y) = C.sameColor(x,y)
135         | sameCellOption _ = false
136    
137   (*========================================================================   (*========================================================================
138    *  Definition and use (for register allocation mainly)    *  Definition and use (for register allocation mainly)
# Line 165  Line 172 
172      case instr      case instr
173       of I.JMP(opnd, _)        => ([], operandUse opnd)       of I.JMP(opnd, _)        => ([], operandUse opnd)
174        | I.JCC{opnd, ...}      => ([], operandUse opnd)        | I.JCC{opnd, ...}      => ([], operandUse opnd)
175        | I.CALL(opnd,defs,uses,_)=> (#1 defs, operandAcc(opnd, #1 uses))        | I.CALL{opnd,defs,uses,...} =>
176               (C.getReg defs, operandAcc(opnd, C.getReg uses))
177        | I.MOVE{src, dst=I.Direct r, ...} => ([r], operandUse src)        | I.MOVE{src, dst=I.Direct r, ...} => ([r], operandUse src)
178        | I.MOVE{src, dst=I.MemReg r, ...} => ([r], operandUse src)        | I.MOVE{src, dst=I.MemReg r, ...} => ([r], operandUse src)
179        | I.MOVE{src, dst, ...} => ([], operandAcc(dst, operandUse src))        | I.MOVE{src, dst, ...} => ([], operandAcc(dst, operandUse src))
# Line 174  Line 182 
182          | I.TESTL arg | I.TESTW arg | I.TESTB arg ) => cmptest arg          | I.TESTL arg | I.TESTW arg | I.TESTB arg ) => cmptest arg
183        | I.BITOP{lsrc, rsrc, ...} => cmptest{lsrc=lsrc,rsrc=rsrc}        | I.BITOP{lsrc, rsrc, ...} => cmptest{lsrc=lsrc,rsrc=rsrc}
184        | 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,...} =>
185             if rs=rd then ([rd],[]) else ([rd],[rs,rd])             if C.sameColor(rs,rd) then ([rd],[]) else ([rd],[rs,rd])
186        | I.BINARY{src,dst,...} =>        | I.BINARY{src,dst,...} =>
187             (operandDef dst, operandAcc(src, operandUse dst))             (operandDef dst, operandAcc(src, operandUse dst))
188        | I.ENTER _             => ([C.esp, C.ebp], [C.esp, C.ebp])        | I.ENTER _             => ([C.esp, C.ebp], [C.esp, C.ebp])
# Line 255  Line 263 
263        | I.FLDS opnd             => ([], operand opnd)        | I.FLDS opnd             => ([], operand opnd)
264        | I.FUCOM opnd            => ([], operand opnd)        | I.FUCOM opnd            => ([], operand opnd)
265        | I.FUCOMP opnd           => ([], operand opnd)        | I.FUCOMP opnd           => ([], operand opnd)
266        | I.CALL(_, defs, uses,_) => (#2 defs, #2 uses)        | I.CALL{defs, uses, ...} => (C.getFreg defs, C.getFreg uses)
267        | I.FBINARY{dst, src, ...}=> (operand dst, operand dst @ operand src)        | I.FBINARY{dst, src, ...}=> (operand dst, operand dst @ operand src)
268        | I.FCOPY{dst, src, tmp=SOME(I.FDirect f), ...}  => (f::dst, src)        | I.FCOPY{dst, src, tmp=SOME(I.FDirect f), ...}  => (f::dst, src)
269        | I.FCOPY{dst, src, tmp=SOME(I.FPR f), ...}  => (f::dst, src)        | I.FCOPY{dst, src, tmp=SOME(I.FPR f), ...}  => (f::dst, src)

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

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