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 428, Wed Sep 8 09:47:00 1999 UTC revision 429, Wed Sep 8 09:47:00 1999 UTC
# Line 17  Line 17 
17          and type cond = MLTreeBasis.cond          and type cond = MLTreeBasis.cond
18          and type fcond = MLTreeBasis.fcond          and type fcond = MLTreeBasis.fcond
19          and type rounding_mode = MLTreeBasis.rounding_mode          and type rounding_mode = MLTreeBasis.rounding_mode
    structure Stream : INSTRUCTION_STREAM  
       where B = SparcMLTree.BNames  
         and P = SparcMLTree.PseudoOp  
20     structure PseudoInstrs : SPARC_PSEUDO_INSTR     structure PseudoInstrs : SPARC_PSEUDO_INSTR
21        where I = SparcInstr        where I = SparcInstr
22     (*     (*
# Line 45  Line 42 
42           *)           *)
43    ) : MLTREECOMP =    ) : MLTREECOMP =
44  struct  struct
   structure S  = Stream  
45    structure T  = SparcMLTree    structure T  = SparcMLTree
46      structure S  = T.Stream
47    structure R  = SparcMLTree.Region    structure R  = SparcMLTree.Region
48    structure I  = SparcInstr    structure I  = SparcInstr
49    structure C  = I.C    structure C  = I.C
# Line 57  Line 54 
54    structure Gen = MLTreeGen(structure T = T    structure Gen = MLTreeGen(structure T = T
55                              val intTy = if V9 then 64 else 32                              val intTy = if V9 then 64 else 32
56                              val naturalWidths = if V9 then [32,64] else [32]                              val naturalWidths = if V9 then [32,64] else [32]
57                                datatype rep = SE | ZE | NEITHER
58                                val rep = NEITHER
59                             )                             )
60    
61    functor Multiply32 = MLTreeMult    functor Multiply32 = MLTreeMult
62      (structure I = I      (structure I = I
63       structure T = T       structure T = T
64       type arg  = {r1:C.register,r2:C.register,d:C.register}       type arg  = {r1:C.cell,r2:C.cell,d:C.cell}
65       type argi = {r:C.register,i:int,d:C.register}       type argi = {r:C.cell,i:int,d:C.cell}
66    
67       val intTy = 32       val intTy = 32
68       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}
# Line 76  Line 75 
75    functor Multiply64 = MLTreeMult    functor Multiply64 = MLTreeMult
76      (structure I = I      (structure I = I
77       structure T = T       structure T = T
78       type arg  = {r1:C.register,r2:C.register,d:C.register}       type arg  = {r1:C.cell,r2:C.cell,d:C.cell}
79       type argi = {r:C.register,i:int,d:C.register}       type argi = {r:C.cell,i:int,d:C.cell}
80    
81       val intTy = 64       val intTy = 64
82       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}
# Line 90  Line 89 
89    (* signed, trapping version of multiply and divide *)    (* signed, trapping version of multiply and divide *)
90    structure Mult32 = Multiply32    structure Mult32 = Multiply32
91      (val trapping = true      (val trapping = true
      val signed = true  
92       val multCost = multCost       val multCost = multCost
93       fun addv{r1,r2,d} =       fun addv{r1,r2,d} =
94           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
# Line 100  Line 98 
98       val sh2addv = NONE       val sh2addv = NONE
99       val sh3addv = NONE       val sh3addv = NONE
100      )      )
101        (val signed = true)
102    
103    (* unsigned, non-trapping version of multiply and divide *)    (* unsigned, non-trapping version of multiply and divide *)
104    structure Mulu32 = Multiply32    structure Mulu32 = Multiply32
105      (val trapping = false      (val trapping = false
      val signed = false  
106       val multCost = muluCost       val multCost = muluCost
107       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}]
108       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}]
# Line 112  Line 110 
110       val sh2addv = NONE       val sh2addv = NONE
111       val sh3addv = NONE       val sh3addv = NONE
112      )      )
113        (val signed = false)
114    
115    (* signed, trapping version of multiply and divide *)    (* signed, trapping version of multiply and divide *)
116    structure Mult64 = Multiply64    structure Mult64 = Multiply64
117      (val trapping = true      (val trapping = true
      val signed = true  
118       val multCost = multCost       val multCost = multCost
119       fun addv{r1,r2,d} =       fun addv{r1,r2,d} =
120           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
# Line 126  Line 124 
124       val sh2addv = NONE       val sh2addv = NONE
125       val sh3addv = NONE       val sh3addv = NONE
126      )      )
127        (val signed = true)
128    
129    (* unsigned, non-trapping version of multiply and divide *)    (* unsigned, non-trapping version of multiply and divide *)
130    structure Mulu64 = Multiply64    structure Mulu64 = Multiply64
131      (val trapping = false      (val trapping = false
      val signed = false  
132       val multCost = muluCost       val multCost = muluCost
133       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}]
134       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}]
# Line 138  Line 136 
136       val sh2addv = NONE       val sh2addv = NONE
137       val sh3addv = NONE       val sh3addv = NONE
138      )      )
139        (val signed = false)
140    
141    datatype commutative = COMMUTE | NOCOMMUTE    datatype commutative = COMMUTE | NOCOMMUTE
142    datatype cc = REG    (* write to register *)    datatype cc = REG    (* write to register *)
# Line 148  Line 147 
147    
148    fun selectInstructions    fun selectInstructions
149         (S.STREAM{emit,defineLabel,entryLabel,blockName,pseudoOp,annotation,         (S.STREAM{emit,defineLabel,entryLabel,blockName,pseudoOp,annotation,
150                   init,finish,exitBlock,...}) =                   beginCluster,endCluster,exitBlock,alias,phi,comment,...}) =
151    let    let
152        (* Flags *)        (* Flags *)
153        val useBR          = !useBR        val useBR          = !useBR
# Line 156  Line 155 
155    
156        val trap32 = PseudoInstrs.overflowtrap32        val trap32 = PseudoInstrs.overflowtrap32
157        val trap64 = PseudoInstrs.overflowtrap64        val trap64 = PseudoInstrs.overflowtrap64
       val emit = emit(fn _ => 0)  
158        val newReg = C.newReg        val newReg = C.newReg
159        val newFreg = C.newFreg        val newFreg = C.newFreg
160        fun immed13 n = ~4096 <= n andalso n < 4096        fun immed13 n = ~4096 <= n andalso n < 4096
# Line 703  Line 701 
701          | opn e              = I.REG(expr e)          | opn e              = I.REG(expr e)
702    
703    
704        fun mltreeComp mltree =        fun cc((r as T.CCR(T.CC 65))::l) = r::cc l
       let fun cc((r as T.CCR(T.CC 65))::l) = r::cc l  
705              | cc(T.CCR(T.CC r)::l) = T.GPR(T.REG(32,r))::cc l              | cc(T.CCR(T.CC r)::l) = T.GPR(T.REG(32,r))::cc l
706              | cc(r::l) = r::cc l              | cc(r::l) = r::cc l
707              | cc []    = []              | cc []    = []
708            fun comp(T.BEGINCLUSTER)      = init 0    in  S.STREAM
709              | comp(T.PSEUDO_OP p)       = pseudoOp p        { beginCluster= beginCluster,
710              | comp(T.DEFINELABEL l)     = defineLabel l          endCluster  = endCluster,
711              | comp(T.ENTRYLABEL l)      = entryLabel l          emit        = doStmt,
712              | comp(T.CODE stmts)        = app doStmt stmts          pseudoOp    = pseudoOp,
713              | comp(T.BLOCK_NAME n)      = blockName n          defineLabel = defineLabel,
714              | comp(T.BLOCK_ANNOTATION a)= annotation a          entryLabel  = entryLabel,
715              | comp(T.ESCAPEBLOCK regs)  = exitBlock(cc regs)          blockName   = blockName,
716              | comp(T.ENDCLUSTER regmap) = finish regmap          comment     = comment,
717              | comp _                    = error "mltreeComp"          annotation  = annotation,
718        in  comp mltree end          exitBlock   = fn regs => exitBlock(cc regs),
719            alias       = alias,
720    in  { mltreeComp = mltreeComp,          phi         = phi
         mlriscComp = doStmt,  
         emitInstr  = emit  
721        }        }
722    end    end
723    

Legend:
Removed from v.428  
changed lines
  Added in v.429

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