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

Diff of /sml/trunk/src/MLRISC/sparc/mltree/sparc.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 77  Line 77 
77       type argi = {r:CB.cell,i:int,d:CB.cell}       type argi = {r:CB.cell,i:int,d:CB.cell}
78    
79       val intTy = 32       val intTy = 32
80       fun mov{r,d} = I.COPY{dst=[d],src=[r],tmp=NONE,impl=ref NONE}       fun mov{r,d} = I.copy{dst=[d],src=[r],tmp=NONE,impl=ref NONE}
81       fun add{r1,r2,d} = I.ARITH{a=I.ADD,r=r1,i=I.REG r2,d=d}       fun add{r1,r2,d} = I.arith{a=I.ADD,r=r1,i=I.REG r2,d=d}
82       fun slli{r,i,d} = [I.SHIFT{s=I.SLL,r=r,i=I.IMMED i,d=d}]       fun slli{r,i,d} = [I.shift{s=I.SLL,r=r,i=I.IMMED i,d=d}]
83       fun srli{r,i,d} = [I.SHIFT{s=I.SRL,r=r,i=I.IMMED i,d=d}]       fun srli{r,i,d} = [I.shift{s=I.SRL,r=r,i=I.IMMED i,d=d}]
84       fun srai{r,i,d} = [I.SHIFT{s=I.SRA,r=r,i=I.IMMED i,d=d}]       fun srai{r,i,d} = [I.shift{s=I.SRA,r=r,i=I.IMMED i,d=d}]
85      )      )
86    
87    functor Multiply64 = MLTreeMult    functor Multiply64 = MLTreeMult
# Line 92  Line 92 
92       type argi = {r:CB.cell,i:int,d:CB.cell}       type argi = {r:CB.cell,i:int,d:CB.cell}
93    
94       val intTy = 64       val intTy = 64
95       fun mov{r,d} = I.COPY{dst=[d],src=[r],tmp=NONE,impl=ref NONE}       fun mov{r,d} = I.copy{dst=[d],src=[r],tmp=NONE,impl=ref NONE}
96       fun add{r1,r2,d} = I.ARITH{a=I.ADD,r=r1,i=I.REG r2,d=d}       fun add{r1,r2,d} = I.arith{a=I.ADD,r=r1,i=I.REG r2,d=d}
97       fun slli{r,i,d} = [I.SHIFT{s=I.SLLX,r=r,i=I.IMMED i,d=d}]       fun slli{r,i,d} = [I.shift{s=I.SLLX,r=r,i=I.IMMED i,d=d}]
98       fun srli{r,i,d} = [I.SHIFT{s=I.SRLX,r=r,i=I.IMMED i,d=d}]       fun srli{r,i,d} = [I.shift{s=I.SRLX,r=r,i=I.IMMED i,d=d}]
99       fun srai{r,i,d} = [I.SHIFT{s=I.SRAX,r=r,i=I.IMMED i,d=d}]       fun srai{r,i,d} = [I.shift{s=I.SRAX,r=r,i=I.IMMED i,d=d}]
100      )      )
101    
102    (* signed, trapping version of multiply and divide *)    (* signed, trapping version of multiply and divide *)
# Line 104  Line 104 
104      (val trapping = true      (val trapping = true
105       val multCost = multCost       val multCost = multCost
106       fun addv{r1,r2,d} =       fun addv{r1,r2,d} =
107           I.ARITH{a=I.ADDCC,r=r1,i=I.REG r2,d=d}::PseudoInstrs.overflowtrap32           I.arith{a=I.ADDCC,r=r1,i=I.REG r2,d=d}::PseudoInstrs.overflowtrap32
108       fun subv{r1,r2,d} =       fun subv{r1,r2,d} =
109           I.ARITH{a=I.SUBCC,r=r1,i=I.REG r2,d=d}::PseudoInstrs.overflowtrap32           I.arith{a=I.SUBCC,r=r1,i=I.REG r2,d=d}::PseudoInstrs.overflowtrap32
110       val sh1addv = NONE       val sh1addv = NONE
111       val sh2addv = NONE       val sh2addv = NONE
112       val sh3addv = NONE       val sh3addv = NONE
# Line 117  Line 117 
117    functor Mul32 = Multiply32    functor Mul32 = Multiply32
118      (val trapping = false      (val trapping = false
119       val multCost = muluCost       val multCost = muluCost
120       fun addv{r1,r2,d} = [I.ARITH{a=I.ADD,r=r1,i=I.REG r2,d=d}]       fun addv{r1,r2,d} = [I.arith{a=I.ADD,r=r1,i=I.REG r2,d=d}]
121       fun subv{r1,r2,d} = [I.ARITH{a=I.SUB,r=r1,i=I.REG r2,d=d}]       fun subv{r1,r2,d} = [I.arith{a=I.SUB,r=r1,i=I.REG r2,d=d}]
122       val sh1addv = NONE       val sh1addv = NONE
123       val sh2addv = NONE       val sh2addv = NONE
124       val sh3addv = NONE       val sh3addv = NONE
# Line 132  Line 132 
132      (val trapping = true      (val trapping = true
133       val multCost = multCost       val multCost = multCost
134       fun addv{r1,r2,d} =       fun addv{r1,r2,d} =
135           I.ARITH{a=I.ADDCC,r=r1,i=I.REG r2,d=d}::PseudoInstrs.overflowtrap64           I.arith{a=I.ADDCC,r=r1,i=I.REG r2,d=d}::PseudoInstrs.overflowtrap64
136       fun subv{r1,r2,d} =       fun subv{r1,r2,d} =
137           I.ARITH{a=I.SUBCC,r=r1,i=I.REG r2,d=d}::PseudoInstrs.overflowtrap64           I.arith{a=I.SUBCC,r=r1,i=I.REG r2,d=d}::PseudoInstrs.overflowtrap64
138       val sh1addv = NONE       val sh1addv = NONE
139       val sh2addv = NONE       val sh2addv = NONE
140       val sh3addv = NONE       val sh3addv = NONE
# Line 145  Line 145 
145    functor Mul64 = Multiply64    functor Mul64 = Multiply64
146      (val trapping = false      (val trapping = false
147       val multCost = muluCost       val multCost = muluCost
148       fun addv{r1,r2,d} = [I.ARITH{a=I.ADD,r=r1,i=I.REG r2,d=d}]       fun addv{r1,r2,d} = [I.arith{a=I.ADD,r=r1,i=I.REG r2,d=d}]
149       fun subv{r1,r2,d} = [I.ARITH{a=I.SUB,r=r1,i=I.REG r2,d=d}]       fun subv{r1,r2,d} = [I.arith{a=I.SUB,r=r1,i=I.REG r2,d=d}]
150       val sh1addv = NONE       val sh1addv = NONE
151       val sh2addv = NONE       val sh2addv = NONE
152       val sh3addv = NONE       val sh3addv = NONE
# Line 166  Line 166 
166    
167    fun selectInstructions    fun selectInstructions
168         (instrStream as         (instrStream as
169          TS.S.STREAM{emit,defineLabel,entryLabel,pseudoOp,annotation,getAnnotations,          TS.S.STREAM{emit=emitInstruction,defineLabel,entryLabel,pseudoOp,annotation,getAnnotations,
170                   beginCluster,endCluster,exitBlock,comment,...}) =                   beginCluster,endCluster,exitBlock,comment,...}) =
171    let    let
172          val emit           = emitInstruction o I.INSTR
173        (* Flags *)        (* Flags *)
174        val useBR          = !useBR        val useBR          = !useBR
175        val registerwindow = !registerwindow        val registerwindow = !registerwindow
# Line 231  Line 232 
232        fun mark'(i,[]) = i        fun mark'(i,[]) = i
233          | mark'(i,a::an) = mark'(I.ANNOTATION{i=i,a=a},an)          | mark'(i,a::an) = mark'(I.ANNOTATION{i=i,a=a},an)
234    
235        fun mark(i,an) = emit(mark'(i,an))        fun mark(i,an) = emitInstruction(mark'(I.INSTR i,an))
236    
237        (* convert an operand into a register *)        (* convert an operand into a register *)
238        fun reduceOpn(I.REG r) = r        fun reduceOpn(I.REG r) = r
# Line 292  Line 293 
293            | (I.REG r,i,_)      => mark(I.ARITH{a=a,r=r,i=i,d=d},an)            | (I.REG r,i,_)      => mark(I.ARITH{a=a,r=r,i=i,d=d},an)
294            | (r,i,_)            => mark(I.ARITH{a=a,r=reduceOpn r,i=i,d=d},an)            | (r,i,_)            => mark(I.ARITH{a=a,r=reduceOpn r,i=i,d=d},an)
295            ;            ;
296            case trap of [] => () | _ => app emit trap            case trap of [] => () | _ => app emitInstruction trap
297        end        end
298    
299        (* emit a shift op *)        (* emit a shift op *)
# Line 318  Line 319 
319                     (_,e1,T.LI i) => const(e1,i)                     (_,e1,T.LI i) => const(e1,i)
320                   | (COMMUTE,T.LI i,e2) => const(e2,i)                   | (COMMUTE,T.LI i,e2) => const(e2,i)
321                   |  _ => nonconst(e1,e2)                   |  _ => nonconst(e1,e2)
322            in  app emit instrs;            in  app emitInstruction instrs;
323                genCmp0(cc,d)                genCmp0(cc,d)
324            end            end
325    
# Line 327  Line 328 
328            let fun nonconst(e1,e2) =            let fun nonconst(e1,e2) =
329                   [mark'(                   [mark'(
330                    case (opn e1,opn e2,comm) of                    case (opn e1,opn e2,comm) of
331                      (i,I.REG r,COMMUTE) => I.ARITH{a=a,r=r,i=i,d=d}                      (i,I.REG r,COMMUTE) => I.arith{a=a,r=r,i=i,d=d}
332                    | (I.REG r,i,_) => I.ARITH{a=a,r=r,i=i,d=d}                    | (I.REG r,i,_) => I.arith{a=a,r=r,i=i,d=d}
333                    | (r,i,_) => I.ARITH{a=a,r=reduceOpn r,i=i,d=d},an)                    | (r,i,_) => I.arith{a=a,r=reduceOpn r,i=i,d=d},an)
334                   ]                   ]
335                fun const(e,i) =                fun const(e,i) =
336                    let val r = expr e                    let val r = expr e
337                    in  genConst{r=r,i=toInt i,d=d}                    in  genConst{r=r,i=toInt i,d=d}
338                        handle _ => [mark'(I.ARITH{a=a,r=r,i=opn(T.LI i),d=d},an)]                        handle _ => [mark'(I.arith{a=a,r=r,i=opn(T.LI i),d=d},an)]
339                    end                    end
340                val instrs =                val instrs =
341                   case (comm,e1,e2) of                   case (comm,e1,e2) of
342                     (_,e1,T.LI i) => const(e1,i)                     (_,e1,T.LI i) => const(e1,i)
343                   | (COMMUTE,T.LI i,e2) => const(e2,i)                   | (COMMUTE,T.LI i,e2) => const(e2,i)
344                   |  _ => nonconst(e1,e2)                   |  _ => nonconst(e1,e2)
345            in  app emit instrs;            in  app emitInstruction instrs;
346                genCmp0(cc,d)                genCmp0(cc,d)
347            end            end
348    
# Line 601  Line 602 
602                muldiv64(I.MULX,Muls64.multiply,a,b,d,cc,COMMUTE,an)                muldiv64(I.MULX,Muls64.multiply,a,b,d,cc,COMMUTE,an)
603            | T.MULT(64,a,b) =>            | T.MULT(64,a,b) =>
604                (muldiv64(I.MULX,Mult64.multiply,a,b,d,CC_REG,COMMUTE,an);                (muldiv64(I.MULX,Mult64.multiply,a,b,d,CC_REG,COMMUTE,an);
605                 app emit trap64)                 app emitInstruction trap64)
606            | T.DIVU(64,a,b) => muldiv64(I.UDIVX,divu64,a,b,d,cc,NOCOMMUTE,an)            | T.DIVU(64,a,b) => muldiv64(I.UDIVX,divu64,a,b,d,cc,NOCOMMUTE,an)
607            | T.DIVS(64,a,b) => muldiv64(I.SDIVX,divs64,a,b,d,cc,NOCOMMUTE,an)            | T.DIVS(64,a,b) => muldiv64(I.SDIVX,divs64,a,b,d,cc,NOCOMMUTE,an)
608            | T.DIVT(64,a,b) => muldiv64(I.SDIVX,divt64,a,b,d,cc,NOCOMMUTE,an)            | T.DIVT(64,a,b) => muldiv64(I.SDIVX,divt64,a,b,d,cc,NOCOMMUTE,an)
# Line 685  Line 686 
686                )                )
687    
688              (* integer to floating point *)              (* integer to floating point *)
689            | T.CVTI2F(32,32,e) => app emit (P.cvti2s({i=opn e,d=d},reduceOpn))            | T.CVTI2F(32,32,e) => app emitInstruction (P.cvti2s({i=opn e,d=d},reduceOpn))
690            | T.CVTI2F(64,32,e) => app emit (P.cvti2d({i=opn e,d=d},reduceOpn))            | T.CVTI2F(64,32,e) => app emitInstruction (P.cvti2d({i=opn e,d=d},reduceOpn))
691            | T.CVTI2F(128,32,e) => app emit (P.cvti2q({i=opn e,d=d},reduceOpn))            | T.CVTI2F(128,32,e) => app emitInstruction (P.cvti2q({i=opn e,d=d},reduceOpn))
692    
693            | T.FMARK(e,A.MARKREG f) => (f d; doFexpr(e,d,an))            | T.FMARK(e,A.MARKREG f) => (f d; doFexpr(e,d,an))
694            | T.FMARK(e,a) => doFexpr(e,d,a::an)            | T.FMARK(e,a) => doFexpr(e,d,a::an)
# Line 728  Line 729 
729                      operand       = opn,                      operand       = opn,
730                      reduceOperand = reduceOpn,                      reduceOperand = reduceOpn,
731                      addressOf     = addr,                      addressOf     = addr,
732                      emit          = mark,                      emit          = emitInstruction o mark',
733                      instrStream   = instrStream,                      instrStream   = instrStream,
734                      mltreeStream  = self()                      mltreeStream  = self()
735                     }                     }

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