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

Diff of /sml/trunk/src/MLRISC/hppa/mltree/hppa.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 56  Line 56 
56       type arg  = {r1:CB.cell,r2:CB.cell,d:CB.cell}       type arg  = {r1:CB.cell,r2:CB.cell,d:CB.cell}
57       type argi = {r:CB.cell,i:int,d:CB.cell}       type argi = {r:CB.cell,i:int,d:CB.cell}
58    
59       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}
60       fun add{r1,r2,d} = I.ARITH{a=I.ADD,r1=r1,r2=r2,t=d}       fun add{r1,r2,d} = I.arith{a=I.ADD,r1=r1,r2=r2,t=d}
61       fun slli{r,i,d} = [I.SHIFT{s=I.ZDEP,r=r,p=31-i,len=32-i,t=d}]       fun slli{r,i,d} = [I.shift{s=I.ZDEP,r=r,p=31-i,len=32-i,t=d}]
62       fun srli{r,i,d} = [I.SHIFT{s=I.EXTRU,r=r,p=31-i,len=32-i,t=d}]       fun srli{r,i,d} = [I.shift{s=I.EXTRU,r=r,p=31-i,len=32-i,t=d}]
63       fun srai{r,i,d} = [I.SHIFT{s=I.EXTRS,r=r,p=31-i,len=32-i,t=d}]       fun srai{r,i,d} = [I.shift{s=I.EXTRS,r=r,p=31-i,len=32-i,t=d}]
64      )      )
65    
66     (* signed, trapping version of multiply and divide *)     (* signed, trapping version of multiply and divide *)
# Line 68  Line 68 
68      (val trapping = true      (val trapping = true
69       val multCost = costOfMultiply       val multCost = costOfMultiply
70       val divCost  = costOfDivision       val divCost  = costOfDivision
71       fun addv{r1,r2,d} = [I.ARITH{a=I.ADDO,r1=r1,r2=r2,t=d}]       fun addv{r1,r2,d} = [I.arith{a=I.ADDO,r1=r1,r2=r2,t=d}]
72       fun subv{r1,r2,d} = [I.ARITH{a=I.SUBO,r1=r1,r2=r2,t=d}]       fun subv{r1,r2,d} = [I.arith{a=I.SUBO,r1=r1,r2=r2,t=d}]
73       val sh1addv = SOME(fn{r1,r2,d} => [I.ARITH{a=I.SH1ADDO,r1=r1,r2=r2,t=d}])       val sh1addv = SOME(fn{r1,r2,d} => [I.arith{a=I.SH1ADDO,r1=r1,r2=r2,t=d}])
74       val sh2addv = SOME(fn{r1,r2,d} => [I.ARITH{a=I.SH2ADDO,r1=r1,r2=r2,t=d}])       val sh2addv = SOME(fn{r1,r2,d} => [I.arith{a=I.SH2ADDO,r1=r1,r2=r2,t=d}])
75       val sh3addv = SOME(fn{r1,r2,d} => [I.ARITH{a=I.SH3ADDO,r1=r1,r2=r2,t=d}])       val sh3addv = SOME(fn{r1,r2,d} => [I.arith{a=I.SH3ADDO,r1=r1,r2=r2,t=d}])
76      )      )
77      (val signed = true)      (val signed = true)
78    
# Line 82  Line 82 
82       val signed   = false       val signed   = false
83       val multCost = costOfMultiply       val multCost = costOfMultiply
84       val divCost  = costOfDivision       val divCost  = costOfDivision
85       fun addv{r1,r2,d} = [I.ARITH{a=I.ADD,r1=r1,r2=r2,t=d}]       fun addv{r1,r2,d} = [I.arith{a=I.ADD,r1=r1,r2=r2,t=d}]
86       fun subv{r1,r2,d} = [I.ARITH{a=I.SUB,r1=r1,r2=r2,t=d}]       fun subv{r1,r2,d} = [I.arith{a=I.SUB,r1=r1,r2=r2,t=d}]
87       val sh1addv = SOME(fn{r1,r2,d} => [I.ARITH{a=I.SH1ADDL,r1=r1,r2=r2,t=d}])       val sh1addv = SOME(fn{r1,r2,d} => [I.arith{a=I.SH1ADDL,r1=r1,r2=r2,t=d}])
88       val sh2addv = SOME(fn{r1,r2,d} => [I.ARITH{a=I.SH2ADDL,r1=r1,r2=r2,t=d}])       val sh2addv = SOME(fn{r1,r2,d} => [I.arith{a=I.SH2ADDL,r1=r1,r2=r2,t=d}])
89       val sh3addv = SOME(fn{r1,r2,d} => [I.ARITH{a=I.SH3ADDL,r1=r1,r2=r2,t=d}])       val sh3addv = SOME(fn{r1,r2,d} => [I.arith{a=I.SH3ADDL,r1=r1,r2=r2,t=d}])
90      )      )
91      (val signed   = false)      (val signed   = false)
92    
# Line 121  Line 121 
121    
122     fun selectInstructions     fun selectInstructions
123          (instrStream as          (instrStream as
124           TS.S.STREAM{emit, defineLabel, entryLabel, getAnnotations,           TS.S.STREAM{emit=emitInstruction, defineLabel, entryLabel, getAnnotations,
125                    beginCluster, endCluster, annotation,                    beginCluster, endCluster, annotation,
126                    exitBlock, pseudoOp, comment, ...}) =                    exitBlock, pseudoOp, comment, ...}) =
127     let     let
# Line 137  Line 137 
137         val zeroImmed = I.IMMED 0         val zeroImmed = I.IMMED 0
138         val zeroOpn = zeroImmed         val zeroOpn = zeroImmed
139    
140         fun mark(i,an) =         val emit = emitInstruction o I.INSTR
141         let fun f(i,[]) = i  
142           local
143               fun f(i,[]) = i
144               | f(i,a::an) = f(I.ANNOTATION{i=i,a=a},an)               | f(i,a::an) = f(I.ANNOTATION{i=i,a=a},an)
145         in  emit(f(i,an)) end         in
146             fun mark(i, an) = emitInstruction(f(I.INSTR i, an))
147             fun mark'(i, an) = emitInstruction(f(i, an))
148           end
149    
150         val ldLabelEA = LC.ldLabelEA emit         val ldLabelEA = LC.ldLabelEA emitInstruction
151         val ldLabelOpnd = LC.ldLabelOpnd emit         val ldLabelOpnd = LC.ldLabelOpnd emitInstruction
152    
153         (* Check whether an expression is being multiplied by 2, 4, or 8 *)         (* Check whether an expression is being multiplied by 2, 4, or 8 *)
154         local         local
# Line 230  Line 235 
235         fun milliCall(milliFn, e1, e2, rd) =         fun milliCall(milliFn, e1, e2, rd) =
236         let val rs = expr e1         let val rs = expr e1
237             val rt = expr e2             val rt = expr e2
238         in  app emit (milliFn{rs=rs,rt=rt,rd=rd}) end         in  app emitInstruction (milliFn{rs=rs,rt=rt,rd=rd}) end
239    
240         (* emit an arithmetic op with possible immediate mode         (* emit an arithmetic op with possible immediate mode
241          * The immed operand is the first operand on the HPPA! Arrrrggggghhhh!          * The immed operand is the first operand on the HPPA! Arrrrggggghhhh!
# Line 565  Line 570 
570                 | AMode(INDXSCALEDea(b,x)) => (b,x)                 | AMode(INDXSCALEDea(b,x)) => (b,x)
571             in mark(I.BV{b=b,x=x,n=true,labs=labs},an) end             in mark(I.BV{b=b,x=x,n=true,labs=labs},an) end
572    
573         and call(s,an) = let val reduce = {stm=doStmt, rexp=expr, emit=emit}         and call(s,an) = let val reduce = {stm=doStmt, rexp=expr, emit=emitInstruction}
574                          in  LC.doCall(reduce,s) end                          in  LC.doCall(reduce,s) end
575    
576             (* Optimize addition *)             (* Optimize addition *)
# Line 591  Line 596 
596         and muldiv(ty,genConst,milliFn,a,b,t,commute,an) =         and muldiv(ty,genConst,milliFn,a,b,t,commute,an) =
597             let fun const(a,i) =             let fun const(a,i) =
598                 let val r = expr a                 let val r = expr a
599                 in  app emit (genConst{r=r,i=toInt i,d=t})                 in  app emitInstruction (genConst{r=r,i=toInt i,d=t})
600                        handle _ => milliCall(milliFn,T.REG(ty,r),T.LI i,t)                        handle _ => milliCall(milliFn,T.REG(ty,r),T.LI i,t)
601                 end                 end
602             in  case (commute,a,b) of             in  case (commute,a,b) of
# Line 788  Line 793 
793                  | (64,64) => doFexpr(e,t,an)                  | (64,64) => doFexpr(e,t,an)
794                  | _ => error "CVTF2F"                  | _ => error "CVTF2F"
795                 )                 )
796             | T.CVTI2F(32,_,e) => app emit(MilliCode.cvti2s{rs=expr e,fd=t})             | T.CVTI2F(32,_,e) => app emitInstruction (MilliCode.cvti2s{rs=expr e,fd=t})
797             | T.CVTI2F(64,_,e) => app emit(MilliCode.cvti2d{rs=expr e,fd=t})             | T.CVTI2F(64,_,e) => app emitInstruction (MilliCode.cvti2d{rs=expr e,fd=t})
798    
799               (* negation is implemented as subtraction *)               (* negation is implemented as subtraction *)
800             | T.FNEG(ty,a)    => doFexpr(T.FSUB(ty,T.FREG(ty,zeroF),a),t,an)             | T.FNEG(ty,a)    => doFexpr(T.FSUB(ty,T.FREG(ty,zeroF),a),t,an)
# Line 835  Line 840 
840                       operand       = opn,                       operand       = opn,
841                       reduceOperand = reduceOpn,                       reduceOperand = reduceOpn,
842                       addressOf     = addrOf,                       addressOf     = addrOf,
843                       emit          = mark,                       emit          = mark',
844                       instrStream   = instrStream,                       instrStream   = instrStream,
845                       mltreeStream  = self()                       mltreeStream  = self()
846                     }                     }

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