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/sparc/instructions/sparcProps.sml
ViewVC logotype

Diff of /sml/trunk/src/MLRISC/sparc/instructions/sparcProps.sml

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

revision 1002, Fri Nov 30 17:11:33 2001 UTC revision 1003, Fri Dec 7 02:45:32 2001 UTC
# Line 24  Line 24 
24    (*========================================================================    (*========================================================================
25     *  Instruction Kinds     *  Instruction Kinds
26     *========================================================================*)     *========================================================================*)
27    fun instrKind(I.Bicc _)  = IK_JUMP    fun instrKind(I.ANNOTATION{i, ...}) = instrKind i
28      | instrKind(I.FBfcc _) = IK_JUMP      | instrKind(I.INSTR instr) =
29      | instrKind(I.JMP _)   = IK_JUMP        (case instr
30      | instrKind(I.RET _)   = IK_JUMP         of (I.Bicc _)  => IK_JUMP
31      | instrKind(I.BR _)    = IK_JUMP          | (I.FBfcc _) => IK_JUMP
32      | instrKind(I.BP _)    = IK_JUMP          | (I.JMP _)   => IK_JUMP
33      | instrKind(I.COPY _)  = IK_COPY          | (I.RET _)   => IK_JUMP
34      | instrKind(I.FCOPY _) = IK_COPY          | (I.BR _)    => IK_JUMP
35      | instrKind(I.CALL{cutsTo=_::_,...})  = IK_CALL_WITH_CUTS          | (I.BP _)    => IK_JUMP
36      | instrKind(I.CALL _)  = IK_CALL          | (I.COPY _)  => IK_COPY
37      | instrKind(I.JMPL{cutsTo=_::_,...})  = IK_CALL_WITH_CUTS          | (I.FCOPY _) => IK_COPY
38      | instrKind(I.JMPL _)  = IK_CALL          | (I.CALL{cutsTo=_::_,...})  => IK_CALL_WITH_CUTS
39      | instrKind(I.PHI _)    = IK_PHI          | (I.CALL _)  => IK_CALL
40      | instrKind(I.SOURCE _) = IK_SOURCE          | (I.JMPL{cutsTo=_::_,...})  => IK_CALL_WITH_CUTS
41      | instrKind(I.SINK _)   = IK_SINK          | (I.JMPL _)  => IK_CALL
42      | instrKind(I.ANNOTATION{i,...}) = instrKind i          | (I.PHI _)    => IK_PHI
43      | instrKind _          = IK_INSTR          | (I.SOURCE _) => IK_SOURCE
44            | (I.SINK _)   => IK_SINK
45    fun branchTargets(I.Bicc{b=I.BA,label,...}) = [LABELLED label]          |  _          => IK_INSTR
46      | branchTargets(I.Bicc{label,...}) = [LABELLED label, FALLTHROUGH]        (*esac*))
47      | branchTargets(I.FBfcc{b=I.FBA,label,...}) = [LABELLED label]      | instrKind _ = error "instrKind"
48      | branchTargets(I.FBfcc{label,...}) = [LABELLED label, FALLTHROUGH]  
49      | branchTargets(I.BR{label,...}) = [LABELLED label, FALLTHROUGH]    fun branchTargets(I.ANNOTATION{i,...}) = branchTargets i
50      | branchTargets(I.BP{label,...}) = [LABELLED label, FALLTHROUGH]      | branchTargets(I.INSTR(instr)) =
51      | branchTargets(I.JMP{labs=[],...}) = [ESCAPES]        (case instr
52      | branchTargets(I.RET _)   = [ESCAPES]          of (I.Bicc{b=I.BA,label,...}) => [LABELLED label]
53      | branchTargets(I.JMP{labs,...})    = map LABELLED labs           | (I.Bicc{label,...}) => [LABELLED label, FALLTHROUGH]
54      | branchTargets(I.CALL{cutsTo,...}) = FALLTHROUGH::map LABELLED cutsTo           | (I.FBfcc{b=I.FBA,label,...}) => [LABELLED label]
55      | branchTargets(I.JMPL{cutsTo,...}) = FALLTHROUGH::map LABELLED cutsTo           | (I.FBfcc{label,...}) => [LABELLED label, FALLTHROUGH]
56      | branchTargets(I.ANNOTATION{i,...}) = branchTargets i           | (I.BR{label,...}) => [LABELLED label, FALLTHROUGH]
57             | (I.BP{label,...}) => [LABELLED label, FALLTHROUGH]
58             | (I.JMP{labs=[],...}) => [ESCAPES]
59             | (I.RET _)   => [ESCAPES]
60             | (I.JMP{labs,...})    => map LABELLED labs
61             | (I.CALL{cutsTo,...}) => FALLTHROUGH::map LABELLED cutsTo
62             | (I.JMPL{cutsTo,...}) => FALLTHROUGH::map LABELLED cutsTo
63             |  _ => error "branchTargets"
64          (*esac*))
65      | branchTargets _ = error "branchTargets"      | branchTargets _ = error "branchTargets"
66    
67    fun setTargets(I.Bicc{b=I.BA,a,nop,...},[L]) =    fun setTargets(I.INSTR(I.Bicc{b=I.BA,a,nop,...}),[L]) =
68            I.Bicc{b=I.BA,a=a,label=L,nop=nop}            I.bicc{b=I.BA,a=a,label=L,nop=nop}
69      | setTargets(I.Bicc{b,a,nop,...},[F,T]) =      | setTargets(I.INSTR(I.Bicc{b,a,nop,...}),[F,T]) =
70            I.Bicc{b=b,a=a,label=T,nop=nop}            I.bicc{b=b,a=a,label=T,nop=nop}
71      | setTargets(I.FBfcc{b,a,nop,...},[F,T]) =      | setTargets(I.INSTR(I.FBfcc{b,a,nop,...}),[F,T]) =
72            I.FBfcc{b=b,a=a,label=T,nop=nop}            I.fbfcc{b=b,a=a,label=T,nop=nop}
73      | setTargets(I.BR{rcond,p,r,a,nop,...},[F,T]) =      | setTargets(I.INSTR(I.BR{rcond,p,r,a,nop,...}),[F,T]) =
74            I.BR{rcond=rcond,p=p,r=r,a=a,label=T,nop=nop}            I.br{rcond=rcond,p=p,r=r,a=a,label=T,nop=nop}
75      | setTargets(I.BP{b,cc,p,a,nop,...},[F,T]) =      | setTargets(I.INSTR(I.BP{b,cc,p,a,nop,...}),[F,T]) =
76            I.BP{b=b,cc=cc,p=p,a=a,label=T,nop=nop}            I.bp{b=b,cc=cc,p=p,a=a,label=T,nop=nop}
77      | setTargets(I.JMP{r,i,nop,...},labels) =      | setTargets(I.INSTR(I.JMP{r,i,nop,...}),labels) =
78            I.JMP{r=r,i=i,labs=labels,nop=nop}            I.jmp{r=r,i=i,labs=labels,nop=nop}
79      | setTargets(I.ANNOTATION{i,a},labs) =      | setTargets(I.ANNOTATION{i,a},labs) =
80            I.ANNOTATION{i=setTargets(i,labs),a=a}            I.ANNOTATION{i=setTargets(i,labs),a=a}
81      | setTargets(i,_) = i      | setTargets(i,_) = i
# Line 116  Line 124 
124    fun revP I.PT = I.PN    fun revP I.PT = I.PN
125      | revP I.PN = I.PT      | revP I.PN = I.PT
126    
127    fun negateConditional(I.Bicc{b,a,label,nop}) =    fun negateConditional(I.INSTR(I.Bicc{b,a,label,nop})) =
128           I.Bicc{b=revCond b,a=a,label=label,nop=nop}           I.bicc{b=revCond b,a=a,label=label,nop=nop}
129      | negateConditional(I.FBfcc{b,a,label,nop}) =      | negateConditional(I.INSTR(I.FBfcc{b,a,label,nop})) =
130           I.FBfcc{b=revFcond b,a=a,label=label,nop=nop}           I.fbfcc{b=revFcond b,a=a,label=label,nop=nop}
131      | negateConditional(I.BR{p,r,rcond,a,label,nop}) =      | negateConditional(I.INSTR(I.BR{p,r,rcond,a,label,nop})) =
132           I.BR{p=revP p,a=a,r=r,rcond=revRcond rcond,label=label,nop=nop}           I.br{p=revP p,a=a,r=r,rcond=revRcond rcond,label=label,nop=nop}
133      | negateConditional(I.BP{b,cc,p,a,label,nop}) =      | negateConditional(I.INSTR(I.BP{b,cc,p,a,label,nop})) =
134           I.BP{p=revP p,a=a,b=revCond b,cc=cc,label=label,nop=nop}           I.bp{p=revP p,a=a,b=revCond b,cc=cc,label=label,nop=nop}
135      | negateConditional(I.ANNOTATION{i,a}) =      | negateConditional(I.ANNOTATION{i,a}) =
136           I.ANNOTATION{i=negateConditional i,a=a}           I.ANNOTATION{i=negateConditional i,a=a}
137      | negateConditional _ = raise NegateConditional      | negateConditional _ = raise NegateConditional
138    
139    fun jump label = I.Bicc{b=I.BA,a=true,label=label,nop=true}    fun jump label = I.bicc{b=I.BA,a=true,label=label,nop=true}
140    
141    val immedRange = {lo= ~4096, hi = 4095}    val immedRange = {lo= ~4096, hi = 4095}
142    
143    fun loadImmed{immed,t} =    fun loadImmed{immed,t} =
144        I.ARITH{a=I.OR,r=zeroR,i=        I.arith{a=I.OR,r=zeroR,i=
145                if #lo immedRange <= immed andalso immed <= #hi immedRange                if #lo immedRange <= immed andalso immed <= #hi immedRange
146                then I.IMMED immed else I.LAB(T.LI(IntInf.fromInt immed)),d=t}                then I.IMMED immed else I.LAB(T.LI(IntInf.fromInt immed)),d=t}
147    fun loadOperand{opn, t} = I.ARITH{a=I.OR,r=zeroR,i=opn, d=t}    fun loadOperand{opn, t} = I.arith{a=I.OR,r=zeroR,i=opn, d=t}
148    
149    fun moveInstr(I.COPY _)  = true    fun moveInstr(I.ANNOTATION{i,...}) = moveInstr i
150      | moveInstr(I.FCOPY _) = true      | moveInstr(I.INSTR(I.COPY _))  = true
151      | moveInstr(I.ANNOTATION{i,...}) = moveInstr i      | moveInstr(I.INSTR(I.FCOPY _)) = true
152        | moveInstr(I.LIVE _)           = false
153        | moveInstr(I.KILL _)           = false
154      | moveInstr _          = false      | moveInstr _          = false
155    
156    fun nop() = I.SETHI{d=zeroR, i=0}    fun nop() = I.sethi{d=zeroR, i=0}
157    
158    (*========================================================================    (*========================================================================
159     *  Parallel Move     *  Parallel Move
160     *========================================================================*)     *========================================================================*)
161    fun moveTmpR(I.COPY{tmp=SOME(I.Direct r),...}) = SOME r    fun moveTmpR(I.INSTR(I.COPY{tmp=SOME(I.Direct r),...})) = SOME r
162      | moveTmpR(I.FCOPY{tmp=SOME(I.FDirect f),...}) = SOME f      | moveTmpR(I.INSTR(I.FCOPY{tmp=SOME(I.FDirect f),...})) = SOME f
163      | moveTmpR(I.ANNOTATION{i,...}) = moveTmpR i      | moveTmpR(I.ANNOTATION{i,...}) = moveTmpR i
164      | moveTmpR _ = NONE      | moveTmpR _ = NONE
165    
166    fun moveDstSrc(I.COPY{dst,src,...}) = (dst,src)    fun moveDstSrc(I.INSTR(I.COPY{dst,src,...})) = (dst,src)
167      | moveDstSrc(I.FCOPY{dst,src,...}) = (dst,src)      | moveDstSrc(I.INSTR(I.FCOPY{dst,src,...})) = (dst,src)
168      | moveDstSrc(I.ANNOTATION{i,...}) = moveDstSrc i      | moveDstSrc(I.ANNOTATION{i,...}) = moveDstSrc i
169      | moveDstSrc _ = error "moveDstSrc"      | moveDstSrc _ = error "moveDstSrc"
170    
# Line 173  Line 183 
183       | eqOpn(I.HI a,I.HI b) = MLTreeEval.==(a,b)       | eqOpn(I.HI a,I.HI b) = MLTreeEval.==(a,b)
184       | eqOpn _ = false       | eqOpn _ = false
185    
186    fun defUseR instr =    fun defUseR instr = let
187        fun sparcDU instr =
188      let      let
189         fun oper (I.REG r,def,use) = (def,r::use)         fun oper (I.REG r,def,use) = (def,r::use)
190           | oper (_,def,use)       = (def,use)           | oper (_,def,use)       = (def,use)
# Line 204  Line 215 
215          | I.Ticc{r,i,...} => oper(i,[],[r])          | I.Ticc{r,i,...} => oper(i,[],[r])
216          | I.RDY{d,...} => ([d],[])          | I.RDY{d,...} => ([d],[])
217          | I.WRY{r,i,...} => oper(i,[],[r])          | I.WRY{r,i,...} => oper(i,[],[r])
         | I.ANNOTATION{a=CB.DEF_USE{cellkind=CB.GP,defs,uses}, i, ...} =>  
           let val (d,u) = defUseR i in (defs@d, u@uses) end  
         | I.ANNOTATION{a, i, ...} => defUseR i  
218          | _ => ([],[])          | _ => ([],[])
219      end      end
220      in
221          case instr
222           of I.ANNOTATION{i, ...} => defUseR i
223            | I.LIVE{regs, ...} => ([], C.getReg regs)
224            | I.KILL{regs, ...} => (C.getReg regs, [])
225            | I.INSTR(i) => sparcDU(i)
226            | _ => error "defUseR"
227      end
228    
229    (* Use of FP registers *)    (* Use of FP registers *)
230    fun defUseF instr =    fun defUseF instr = let
231        case instr of      fun sparcDU instr =
232         (case instr of
233          I.FLOAD{r,d,i,...} => ([d],[])          I.FLOAD{r,d,i,...} => ([d],[])
234        | I.FSTORE{r,d,i,...} => ([],[d])        | I.FSTORE{r,d,i,...} => ([],[d])
235        | I.FPop1{r,d,...} => ([d],[r])        | I.FPop1{r,d,...} => ([d],[r])
# Line 224  Line 241 
241        | I.FMOVfcc{r,d,...} => ([d],[r,d])        | I.FMOVfcc{r,d,...} => ([d],[r,d])
242        | I.FCOPY{src,dst,tmp=SOME(I.FDirect r),...} => (r::dst,src)        | I.FCOPY{src,dst,tmp=SOME(I.FDirect r),...} => (r::dst,src)
243        | I.FCOPY{src,dst,...} => (dst,src)        | I.FCOPY{src,dst,...} => (dst,src)
       | I.ANNOTATION{a=CB.DEF_USE{cellkind=CB.FP,defs,uses}, i, ...} =>  
         let val (d,u) = defUseF i in (defs@d, u@uses) end  
       | I.ANNOTATION{a, i, ...} => defUseF i  
244        | _ => ([],[])        | _ => ([],[])
245         (*esac*))
246      in
247         case instr
248          of I.ANNOTATION{i, ...} => defUseF i
249           | I.LIVE{regs, ...} => ([], C.getFreg regs)
250           | I.KILL{regs, ...} => (C.getFreg regs, [])
251           | I.INSTR(i) => sparcDU(i)
252           | _ => error "defUseF"
253      end
254    
255    fun defUse CB.GP = defUseR    fun defUse CB.GP = defUseR
256      | defUse CB.FP = defUseF      | defUse CB.FP = defUseF
# Line 245  Line 268 
268     *  Replicate an instruction     *  Replicate an instruction
269     *========================================================================*)     *========================================================================*)
270    fun replicate(I.ANNOTATION{i,a}) = I.ANNOTATION{i=replicate i,a=a}    fun replicate(I.ANNOTATION{i,a}) = I.ANNOTATION{i=replicate i,a=a}
271      | replicate(I.COPY{tmp=SOME _, dst, src, impl}) =      | replicate(I.INSTR(I.COPY{tmp=SOME _, dst, src, impl})) =
272          I.COPY{tmp=SOME(I.Direct(C.newReg())), dst=dst, src=src, impl=ref NONE}          I.copy{tmp=SOME(I.Direct(C.newReg())), dst=dst, src=src, impl=ref NONE}
273      | replicate(I.FCOPY{tmp=SOME _, dst, src, impl}) =      | replicate(I.INSTR(I.FCOPY{tmp=SOME _, dst, src, impl})) =
274          I.FCOPY{tmp=SOME(I.FDirect(C.newFreg())),          I.fcopy{tmp=SOME(I.FDirect(C.newFreg())),
275                  dst=dst, src=src, impl=ref NONE}                  dst=dst, src=src, impl=ref NONE}
276      | replicate i = i      | replicate i = i
277  end  end

Legend:
Removed from v.1002  
changed lines
  Added in v.1003

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