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/hppa/instructions/hppaProps.sml
ViewVC logotype

Diff of /sml/trunk/src/MLRISC/hppa/instructions/hppaProps.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 29  Line 29 
29      *  Instruction Kinds      *  Instruction Kinds
30      *========================================================================*)      *========================================================================*)
31    (* Note: BLE and BL used to implement calls are not view as branches *)    (* Note: BLE and BL used to implement calls are not view as branches *)
32    fun instrKind(I.BCOND _)  = IK_JUMP    fun instrKind(I.ANNOTATION{i, ...}) = instrKind i
33      | instrKind(I.BCONDI _) = IK_JUMP      | instrKind(I.INSTR instr) =
34      | instrKind(I.BB _)     = IK_JUMP        (case instr
35      | instrKind(I.B _)      = IK_JUMP          of (I.BCOND _) => IK_JUMP
36      | instrKind(I.BE _)     = IK_JUMP           | (I.BCONDI _) => IK_JUMP
37      | instrKind(I.FBRANCH _)= IK_JUMP           | (I.BB _)     => IK_JUMP
38      | instrKind(I.BV _)     = IK_JUMP           | (I.B _)      => IK_JUMP
39      | instrKind(I.BLR _)    = IK_JUMP           | (I.BE _)     => IK_JUMP
40      | instrKind(I.NOP)      = IK_NOP           | (I.FBRANCH _)=> IK_JUMP
41      | instrKind(I.COPY _)   = IK_COPY           | (I.BV _)     => IK_JUMP
42      | instrKind(I.FCOPY _)  = IK_COPY           | (I.BLR _)    => IK_JUMP
43      | instrKind(I.BL{cutsTo=_::_,...}) = IK_CALL_WITH_CUTS           | (I.NOP)      => IK_NOP
44      | instrKind(I.BL  _)    = IK_CALL           | (I.COPY _)   => IK_COPY
45      | instrKind(I.BLE{cutsTo=_::_,...}) = IK_CALL_WITH_CUTS           | (I.FCOPY _)  => IK_COPY
46      | instrKind(I.BLE _)    = IK_CALL           | (I.BL{cutsTo=_::_,...}) => IK_CALL_WITH_CUTS
47      | instrKind(I.PHI _)    = IK_PHI           | (I.BL  _)    => IK_CALL
48      | instrKind(I.SOURCE _) = IK_SOURCE           | (I.BLE{cutsTo=_::_,...}) => IK_CALL_WITH_CUTS
49      | instrKind(I.SINK _)   = IK_SINK           | (I.BLE _)    => IK_CALL
50      | instrKind(I.ANNOTATION{i,...}) = instrKind i           | (I.PHI _)    => IK_PHI
51      | instrKind _           = IK_INSTR           | (I.SOURCE _) => IK_SOURCE
52             | (I.SINK _)   => IK_SINK
53    fun moveInstr(I.COPY _)   = true           |  _          => IK_INSTR)
54      | moveInstr(I.FCOPY _)  = true      | instrKind _ = error "instrKind"
55    
56      fun moveInstr(I.INSTR(I.COPY _))   = true
57        | moveInstr(I.INSTR(I.FCOPY _))  = true
58        | moveInstr(I.LIVE _)            = false
59        | moveInstr(I.KILL _)            = false
60      | moveInstr(I.ANNOTATION{i,...}) = moveInstr i      | moveInstr(I.ANNOTATION{i,...}) = moveInstr i
61      | moveInstr _ = false      | moveInstr _ = false
62    
63    fun nop() = I.NOP    fun nop() = I.nop
64    
65     (*========================================================================     (*========================================================================
66      *  Parallel Move      *  Parallel Move
67      *========================================================================*)      *========================================================================*)
68    fun moveTmpR(I.COPY{tmp=SOME(I.Direct r), ...}) = SOME r    fun moveTmpR(I.INSTR(I.COPY{tmp=SOME(I.Direct r), ...})) = SOME r
69      | moveTmpR(I.FCOPY{tmp=SOME(I.FDirect f), ...}) = SOME f      | moveTmpR(I.INSTR(I.FCOPY{tmp=SOME(I.FDirect f), ...})) = SOME f
70      | moveTmpR(I.ANNOTATION{i,...}) = moveTmpR i      | moveTmpR(I.ANNOTATION{i,...}) = moveTmpR i
71      | moveTmpR _ = NONE      | moveTmpR _ = NONE
72    
73    fun moveDstSrc(I.COPY{dst, src, ...}) = (dst, src)    fun moveDstSrc(I.INSTR(I.COPY{dst, src, ...})) = (dst, src)
74      | moveDstSrc(I.FCOPY{dst, src, ...}) = (dst, src)      | moveDstSrc(I.INSTR(I.FCOPY{dst, src, ...})) = (dst, src)
75      | moveDstSrc(I.ANNOTATION{i,...}) = moveDstSrc i      | moveDstSrc(I.ANNOTATION{i,...}) = moveDstSrc i
76      | moveDstSrc _ = error "moveDstSrc"      | moveDstSrc _ = error "moveDstSrc"
77    
78     (*========================================================================     (*========================================================================
79      *  Branches and Calls/Returns      *  Branches and Calls/Returns
80      *========================================================================*)      *========================================================================*)
81    fun branchTargets(I.BCOND{t, ...})    = [LABELLED t, FALLTHROUGH]    fun branchTargets(I.ANNOTATION{i,...}) = branchTargets i
82      | branchTargets(I.BCONDI{t, ...})   = [LABELLED t, FALLTHROUGH]      | branchTargets(I.INSTR instr) =
83      | branchTargets(I.BB{t, ...})       = [LABELLED t, FALLTHROUGH]        (case instr
84      | branchTargets(I.B{lab, ...})      = [LABELLED lab]         of (I.BCOND{t, ...})    => [LABELLED t, FALLTHROUGH]
85      | branchTargets(I.FBRANCH{t,...})   = [LABELLED t, FALLTHROUGH]          | (I.BCONDI{t, ...})   => [LABELLED t, FALLTHROUGH]
86      | branchTargets(I.BE{labs=[],...})  = [ESCAPES]          | (I.BB{t, ...})       => [LABELLED t, FALLTHROUGH]
87      | branchTargets(I.BE{labs,...})     = map LABELLED labs          | (I.B{lab, ...})      => [LABELLED lab]
88      | branchTargets(I.BV{labs=[],...})  = [ESCAPES]          | (I.FBRANCH{t,...})   => [LABELLED t, FALLTHROUGH]
89      | branchTargets(I.BV{labs,...})     = map LABELLED labs          | (I.BE{labs=[],...})  => [ESCAPES]
90      | branchTargets(I.BLR{labs,...})    = map LABELLED labs          | (I.BE{labs,...})     => map LABELLED labs
91      | branchTargets(I.BL{cutsTo,...})   = FALLTHROUGH::map LABELLED cutsTo          | (I.BV{labs=[],...})  => [ESCAPES]
92      | branchTargets(I.BLE{cutsTo,...})  = FALLTHROUGH::map LABELLED cutsTo          | (I.BV{labs,...})     => map LABELLED labs
93      | branchTargets(I.ANNOTATION{i,...}) = branchTargets i          | (I.BLR{labs,...})    => map LABELLED labs
94            | (I.BL{cutsTo,...})   => FALLTHROUGH::map LABELLED cutsTo
95            | (I.BLE{cutsTo,...})  => FALLTHROUGH::map LABELLED cutsTo
96            | _ => error "branchTargets"
97          (*easc*))
98      | branchTargets _ = error "branchTargets"      | branchTargets _ = error "branchTargets"
99    
100    fun jump label = I.B{lab=label,n=true}    fun jump label = I.b{lab=label,n=true}
101    
102    val immedRange = {lo= ~8192, hi=8191}    val immedRange = {lo= ~8192, hi=8191}
103    fun loadImmed{immed,t} =    fun loadImmed{immed,t} =
104        I.LDO{i=if #lo immedRange <= immed andalso immed <= #hi immedRange        I.ldo{i=if #lo immedRange <= immed andalso immed <= #hi immedRange
105                then I.IMMED immed                then I.IMMED immed
106                else I.LabExp(I.T.LI(I.T.I.fromInt(32,immed)),I.F),b=zeroR,t=t}                else I.LabExp(I.T.LI(I.T.I.fromInt(32,immed)),I.F),b=zeroR,t=t}
107    fun loadOperand{opn,t} = I.LDO{i=opn,b=zeroR,t=t}    fun loadOperand{opn,t} = I.ldo{i=opn,b=zeroR,t=t}
108    
109    fun setTargets(I.BCOND{cmp,bc,r1,r2,t,f,n,nop},[F,T]) =    fun setTargets(I.INSTR(I.BCOND{cmp,bc,r1,r2,t,f,n,nop}), [F,T]) =
110            I.BCOND{cmp=cmp,bc=bc,r1=r1,r2=r2,t=T,f=F,n=n,nop=nop}            I.bcond{cmp=cmp,bc=bc,r1=r1,r2=r2,t=T,f=F,n=n,nop=nop}
111      | setTargets(I.BCONDI{cmpi,bc,i,r2,t,f,n,nop=nop},[F,T]) =      | setTargets(I.INSTR(I.BCONDI{cmpi,bc,i,r2,t,f,n,nop=nop}), [F,T]) =
112            I.BCONDI{cmpi=cmpi,bc=bc,i=i,r2=r2,t=T,f=F,n=n,nop=nop}            I.bcondi{cmpi=cmpi,bc=bc,i=i,r2=r2,t=T,f=F,n=n,nop=nop}
113      | setTargets(I.BB{bc,r,p,t,f,n,nop},[F,T]) =      | setTargets(I.INSTR(I.BB{bc,r,p,t,f,n,nop}), [F,T]) =
114            I.BB{bc=bc,r=r,p=p,t=T,f=F,n=n,nop=nop}            I.bb{bc=bc,r=r,p=p,t=T,f=F,n=n,nop=nop}
115      | setTargets(I.B{n,...},[L]) = I.B{lab=L,n=n}      | setTargets(I.INSTR(I.B{n,...}), [L]) = I.b{lab=L,n=n}
116      | setTargets(I.FBRANCH{cc,fmt,n,long,f1,f2,...},[F,T]) =      | setTargets(I.INSTR(I.FBRANCH{cc,fmt,n,long,f1,f2,...}), [F,T]) =
117            I.FBRANCH{cc=cc,fmt=fmt,t=T,f=F,n=n,long=long,f1=f1,f2=f2}            I.fbranch{cc=cc,fmt=fmt,t=T,f=F,n=n,long=long,f1=f1,f2=f2}
118      | setTargets(I.BV{x,b,n,...},labels) = I.BV{x=x,b=b,labs=labels,n=n}      | setTargets(I.INSTR(I.BV{x,b,n,...}),labels) = I.bv{x=x,b=b,labs=labels,n=n}
119      | setTargets(I.BE{b,d,n,sr,...},labs) = I.BE{b=b,d=d,n=n,sr=sr,labs=labs}      | setTargets(I.INSTR(I.BE{b,d,n,sr,...}),labs) = I.be{b=b,d=d,n=n,sr=sr,labs=labs}
120      | setTargets(I.BLR{x,t,n,...},labels) = I.BLR{x=x,t=t,labs=labels,n=n}      | setTargets(I.INSTR(I.BLR{x,t,n,...}),labels) = I.blr{x=x,t=t,labs=labels,n=n}
121      | setTargets(I.ANNOTATION{i,a},labels) =      | setTargets(I.ANNOTATION{i,a},labels) =
122            I.ANNOTATION{i=setTargets(i,labels),a=a}            I.ANNOTATION{i=setTargets(i,labels),a=a}
123      | setTargets(i,_) = i      | setTargets(i,_) = i
# Line 143  Line 152 
152        | revFcond _      = error "revFcond"        | revFcond _      = error "revFcond"
153    in    in
154      case br of      case br of
155        I.BCOND{cmp,bc,r1,r2,t,f,n,nop} =>        I.INSTR(I.BCOND{cmp,bc,r1,r2,t,f,n,nop}) =>
156           I.BCOND{bc=bc, r1=r1, r2=r2, t=t, f=f, n=n, nop=nop,           I.bcond{bc=bc, r1=r1, r2=r2, t=t, f=f, n=n, nop=nop,
157                   cmp=case cmp of I.COMBT => I.COMBF | I.COMBF => I.COMBT}                   cmp=case cmp of I.COMBT => I.COMBF | I.COMBF => I.COMBT}
158      | I.BCONDI{cmpi,bc,i,r2,t,f,n,nop} =>      | I.INSTR(I.BCONDI{cmpi,bc,i,r2,t,f,n,nop}) =>
159          I.BCONDI{bc=bc, i=i, r2=r2, t=t, f=f, n=n, nop=nop,          I.bcondi{bc=bc, i=i, r2=r2, t=t, f=f, n=n, nop=nop,
160                   cmpi=case cmpi of I.COMIBT => I.COMIBF | I.COMIBF => I.COMIBT}                   cmpi=case cmpi of I.COMIBT => I.COMIBF | I.COMIBF => I.COMIBT}
161      | I.BB{bc,r,p,t,f,n,nop} =>      | I.INSTR(I.BB{bc,r,p,t,f,n,nop}) =>
162           I.BB{bc=case bc of I.BSET => I.BCLR | I.BCLR => I.BSET,           I.bb{bc=case bc of I.BSET => I.BCLR | I.BCLR => I.BSET,
163                r=r,p=p,t=t,f=f,n=n,nop=nop}                r=r,p=p,t=t,f=f,n=n,nop=nop}
164      | I.FBRANCH{cc,fmt,f1,f2,t,f,n,long} =>      | I.INSTR(I.FBRANCH{cc,fmt,f1,f2,t,f,n,long}) =>
165          I.FBRANCH{cc=revFcond cc,fmt=fmt,f1=f1,f2=f2,t=t,f=f,n=n,long=long}          I.fbranch{cc=revFcond cc,fmt=fmt,f1=f1,f2=f2,t=t,f=f,n=n,long=long}
166      | I.ANNOTATION{i,a} => I.ANNOTATION{i=negateConditional i,a=a}      | I.ANNOTATION{i,a} => I.ANNOTATION{i=negateConditional i,a=a}
167      | _ => raise NegateConditional      | _ => raise NegateConditional
168    end    end
# Line 187  Line 196 
196     *  Definition and use (for register allocation mainly)     *  Definition and use (for register allocation mainly)
197     *========================================================================*)     *========================================================================*)
198    fun defUseR instr = let    fun defUseR instr = let
199        fun hppaDU instr = let
200      fun trap((I.ADDO | I.SUBO | I.SH1ADDO), d, u) = (d, u)      fun trap((I.ADDO | I.SUBO | I.SH1ADDO), d, u) = (d, u)
201        | trap(_, d, u) = (d, u)        | trap(_, d, u) = (d, u)
202      fun trapi((I.ADDIO | I.SUBIO), d, u) = (d, u)      fun trapi((I.ADDIO | I.SUBIO), d, u) = (d, u)
# Line 224  Line 234 
234        | I.FSTOREX {b, x, ...}       => ([],  [b,x])        | I.FSTOREX {b, x, ...}       => ([],  [b,x])
235        | I.FLOAD {b, ...}            => ([],  [b])        | I.FLOAD {b, ...}            => ([],  [b])
236        | I.FLOADX{b, x, ...}         => ([],  [b,x])        | I.FLOADX{b, x, ...}         => ([],  [b,x])
       | 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  
237        | _   => ([],[])        | _   => ([],[])
238    end    end
239      in
240          case instr
241           of I.ANNOTATION{i, ...} => defUseR i
242            | I.LIVE{regs, ...} => ([], C.getReg regs)
243            | I.KILL{regs, ...} => (C.getReg regs, [])
244            | I.INSTR(i) => hppaDU(i)
245            | _ => error "defUseR"
246      end
247    
248    fun defUseF instr =    fun defUseF instr = let
249        fun hppaDU instr =
250      case instr      case instr
251        of I.FSTORE {r, ...}         => ([],  [r])        of I.FSTORE {r, ...}         => ([],  [r])
252         | I.FSTOREX{r, ...}         => ([],  [r])         | I.FSTOREX{r, ...}         => ([],  [r])
# Line 244  Line 260 
260         | I.BLE{defs, uses, ...}    => (C.getFreg defs, C.getFreg uses)         | I.BLE{defs, uses, ...}    => (C.getFreg defs, C.getFreg uses)
261         | I.FCOPY{dst, src, tmp=SOME(I.FDirect f), ...} => (f::dst, src)         | I.FCOPY{dst, src, tmp=SOME(I.FDirect f), ...} => (f::dst, src)
262         | I.FCOPY{dst, src, ...}    => (dst, src)         | I.FCOPY{dst, src, ...}    => (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  
263         | _ => ([],[])         | _ => ([],[])
264      in
265          case instr
266           of I.ANNOTATION{i, ...} => defUseF i
267            | I.INSTR(i) => hppaDU(i)
268            | I.LIVE{regs, ...} => ([], C.getFreg regs)
269            | I.KILL{regs, ...} => (C.getFreg regs, [])
270            | _ => error "defUseR"
271      end
272    
273    fun defUse CB.GP = defUseR    fun defUse CB.GP = defUseR
274      | defUse CB.FP = defUseF      | defUse CB.FP = defUseF
# Line 265  Line 286 
286     *  Replicate an instruction     *  Replicate an instruction
287     *========================================================================*)     *========================================================================*)
288    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}
289      | replicate(I.COPY{tmp=SOME _, dst, src, impl}) =      | replicate(I.INSTR(I.COPY{tmp=SOME _, dst, src, impl})) =
290          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}
291      | replicate(I.FCOPY{tmp=SOME _, dst, src, impl}) =      | replicate(I.INSTR(I.FCOPY{tmp=SOME _, dst, src, impl})) =
292          I.FCOPY{tmp=SOME(I.FDirect(C.newFreg())),          I.fcopy{tmp=SOME(I.FDirect(C.newFreg())),
293                  dst=dst, src=src, impl=ref NONE}                  dst=dst, src=src, impl=ref NONE}
294      | replicate i = i      | replicate i = i
295  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