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
 [smlnj] / sml / trunk / src / MLRISC / sparc / mltree / sparc.sml

# Diff of /sml/trunk/src/MLRISC/sparc/mltree/sparc.sml

revision 1008, Fri Dec 14 21:01:29 2001 UTC revision 1009, Wed Jan 9 19:44:22 2002 UTC
# Line 60  Line 60
60    fun LI i = T.LI(T.I.fromInt(32, i))    fun LI i = T.LI(T.I.fromInt(32, i))
61    fun LT (n,m) = T.I.LT(32, n, m)    fun LT (n,m) = T.I.LT(32, n, m)
62    fun LE (n,m) = T.I.LE(32, n, m)    fun LE (n,m) = T.I.LE(32, n, m)
63      fun COPY{dst, src, tmp} =
64          I.COPY{k=CB.GP, sz=32, dst=dst, src=src, tmp=tmp}
65      fun FCOPY{dst, src, tmp} =
66          I.COPY{k=CB.FP, sz=64, dst=dst, src=src, tmp=tmp}
67
68    val intTy = if V9 then 64 else 32    val intTy = if V9 then 64 else 32
69    structure Gen = MLTreeGen(structure T = T    structure Gen = MLTreeGen(structure T = T
# Line 77  Line 81
81       type argi = {r:CB.cell,i:int,d:CB.cell}       type argi = {r:CB.cell,i:int,d:CB.cell}
82
83       val intTy = 32       val intTy = 32
84       fun mov{r,d} = I.copy{dst=[d],src=[r],tmp=NONE,impl=ref NONE}       fun mov{r,d} = COPY{dst=[d],src=[r],tmp=NONE}
86       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}]
87       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}]
# Line 92  Line 96
96       type argi = {r:CB.cell,i:int,d:CB.cell}       type argi = {r:CB.cell,i:int,d:CB.cell}
97
98       val intTy = 64       val intTy = 64
99       fun mov{r,d} = I.copy{dst=[d],src=[r],tmp=NONE,impl=ref NONE}       fun mov{r,d} = COPY{dst=[d],src=[r],tmp=NONE}
101       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}]
102       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}]
# Line 229  Line 233
233          | fcond T.?=  = I.FBUE          | fcond T.?=  = I.FBUE
234          | fcond fc = error("fcond "^T.Basis.fcondToString fc)          | fcond fc = error("fcond "^T.Basis.fcondToString fc)
235
236        fun mark'(i,[]) = i        fun annotate(i,[]) = i
237          | mark'(i,a::an) = mark'(I.ANNOTATION{i=i,a=a},an)          | annotate(i,a::an) = annotate(I.ANNOTATION{i=i,a=a},an)
238          fun mark'(i,an) = emitInstruction(annotate(i,an))
239        fun mark(i,an) = emitInstruction(mark'(I.INSTR i,an))        fun mark(i,an) = emitInstruction(annotate(I.INSTR i,an))
240
241        (* convert an operand into a register *)        (* convert an operand into a register *)
242        fun reduceOpn(I.REG r) = r        fun reduceOpn(I.REG r) = r
# Line 243  Line 247
247
248        (* emit parallel copies *)        (* emit parallel copies *)
249        fun copy(dst,src,an) =        fun copy(dst,src,an) =
250           mark(I.COPY{dst=dst,src=src,impl=ref NONE,           mark'(COPY{dst=dst,src=src,
251                      tmp=case dst of [_] => NONE                      tmp=case dst of [_] => NONE
252                                 | _ => SOME(I.Direct(newReg()))},an)                                 | _ => SOME(I.Direct(newReg()))},an)
253        fun fcopy(dst,src,an) =        fun fcopy(dst,src,an) =
254           mark(I.FCOPY{dst=dst,src=src,impl=ref NONE,           mark'(FCOPY{dst=dst,src=src,
255                       tmp=case dst of [_] => NONE                       tmp=case dst of [_] => NONE
256                                   | _ => SOME(I.FDirect(newFreg()))},an)                                   | _ => SOME(I.FDirect(newFreg()))},an)
257
258        (* move register s to register d *)        (* move register s to register d *)
259        fun move(s,d,an) =        fun move(s,d,an) =
260            if CB.sameColor(s,d) orelse CB.registerId d = 0 then ()            if CB.sameColor(s,d) orelse CB.registerId d = 0 then ()
261            else mark(I.COPY{dst=[d],src=[s],tmp=NONE,impl=ref NONE},an)            else mark'(COPY{dst=[d],src=[s],tmp=NONE},an)
262
263        (* move floating point register s to register d *)        (* move floating point register s to register d *)
264        fun fmoved(s,d,an) =        fun fmoved(s,d,an) =
265            if CB.sameColor(s,d) then ()            if CB.sameColor(s,d) then ()
266            else mark(I.FCOPY{dst=[d],src=[s],tmp=NONE,impl=ref NONE},an)            else mark'(FCOPY{dst=[d],src=[s],tmp=NONE},an)
267        fun fmoves(s,d,an) = fmoved(s,d,an) (* error "fmoves" for now!!! XXX *)        fun fmoves(s,d,an) = fmoved(s,d,an) (* error "fmoves" for now!!! XXX *)
268        fun fmoveq(s,d,an) = error "fmoveq"        fun fmoveq(s,d,an) = error "fmoveq"
269
# Line 326  Line 330
330        (* emit 64-bit multiply or division operation (V9) *)        (* emit 64-bit multiply or division operation (V9) *)
331        and muldiv64(a,genConst,e1,e2,d,cc,comm,an) =        and muldiv64(a,genConst,e1,e2,d,cc,comm,an) =
332            let fun nonconst(e1,e2) =            let fun nonconst(e1,e2) =
333                   [mark'(                   [annotate(
334                    case (opn e1,opn e2,comm) of                    case (opn e1,opn e2,comm) of
335                      (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}
336                    | (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}
# Line 335  Line 339
339                fun const(e,i) =                fun const(e,i) =
340                    let val r = expr e                    let val r = expr e
341                    in  genConst{r=r,i=toInt i,d=d}                    in  genConst{r=r,i=toInt i,d=d}
342                        handle _ => [mark'(I.arith{a=a,r=r,i=opn(T.LI i),d=d},an)]                        handle _ => [annotate(I.arith{a=a,r=r,i=opn(T.LI i),d=d},an)]
343                    end                    end
344                val instrs =                val instrs =
345                   case (comm,e1,e2) of                   case (comm,e1,e2) of
# Line 729  Line 733
733                      operand       = opn,                      operand       = opn,
734                      reduceOperand = reduceOpn,                      reduceOperand = reduceOpn,