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

Diff of /sml/trunk/src/MLRISC/alpha/mltree/alpha.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 788, Wed Feb 28 04:09:48 2001 UTC revision 933, Wed Sep 19 19:31:19 2001 UTC
# Line 11  Line 11 
11  functor Alpha  functor Alpha
12     (structure AlphaInstr : ALPHAINSTR     (structure AlphaInstr : ALPHAINSTR
13      structure PseudoInstrs : ALPHA_PSEUDO_INSTR      structure PseudoInstrs : ALPHA_PSEUDO_INSTR
14                            where I = AlphaInstr
15      structure ExtensionComp : MLTREE_EXTENSION_COMP      structure ExtensionComp : MLTREE_EXTENSION_COMP
16         where I = AlphaInstr         where I = AlphaInstr
17         sharing PseudoInstrs.I = AlphaInstr                            and T = AlphaInstr.T
18    
19        (* Cost of multiplication in cycles *)        (* Cost of multiplication in cycles *)
20      val multCost : int ref      val multCost : int ref
# Line 41  Line 42 
42    structure W32 = Word32    structure W32 = Word32
43    structure P   = PseudoInstrs    structure P   = PseudoInstrs
44    structure A   = MLRiscAnnotations    structure A   = MLRiscAnnotations
45      structure CB  = CellsBasis
46      structure CFG = ExtensionComp.CFG
47    
48   (*********************************************************   (*********************************************************
49    
# Line 141  Line 144 
144    
145    fun error msg = MLRiscErrorMsg.error("Alpha",msg)    fun error msg = MLRiscErrorMsg.error("Alpha",msg)
146    
147    type instrStream = (I.instruction,C.cellset) T.stream    type instrStream = (I.instruction, C.cellset, CFG.cfg) T.stream
148    type mltreeStream = (T.stm,T.mlrisc list) T.stream    type mltreeStream = (T.stm, T.mlrisc list, CFG.cfg) T.stream
149    
150    (*    (*
151     * This module is used to simulate operations of non-standard widths.     * This module is used to simulate operations of non-standard widths.
# Line 169  Line 172 
172    functor Multiply32 = MLTreeMult    functor Multiply32 = MLTreeMult
173      (structure I = I      (structure I = I
174       structure T = T       structure T = T
175         structure CB = CellsBasis
176    
177       val intTy = 32       val intTy = 32
178    
179       type arg  = {r1:C.cell,r2:C.cell,d:C.cell}       type arg  = {r1:CB.cell,r2:CB.cell,d:CB.cell}
180       type argi = {r:C.cell,i:int,d:C.cell}       type argi = {r:CB.cell,i:int,d:CB.cell}
181    
182       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}
183       fun add{r1,r2,d} = I.OPERATE{oper=I.ADDL,ra=r1,rb=I.REGop r2,rc=d}       fun add{r1,r2,d} = I.OPERATE{oper=I.ADDL,ra=r1,rb=I.REGop r2,rc=d}
# Line 211  Line 215 
215    functor Multiply64 = MLTreeMult    functor Multiply64 = MLTreeMult
216      (structure I = I      (structure I = I
217       structure T = T       structure T = T
218         structure CB = CellsBasis
219    
220       val intTy = 64       val intTy = 64
221    
222       type arg  = {r1:C.cell,r2:C.cell,d:C.cell}       type arg  = {r1:CB.cell, r2:CB.cell, d:CB.cell}
223       type argi = {r:C.cell,i:int,d:C.cell}       type argi = {r:CB.cell, i:int, d:CB.cell}
224    
225       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}
226       fun add{r1,r2,d}= I.OPERATE{oper=I.ADDQ,ra=r1,rb=I.REGop r2,rc=d}       fun add{r1,r2,d}= I.OPERATE{oper=I.ADDQ,ra=r1,rb=I.REGop r2,rc=d}
# Line 294  Line 299 
299    
300    fun selectInstructions    fun selectInstructions
301          (instrStream as          (instrStream as
302           S.STREAM{emit,beginCluster,endCluster,           S.STREAM{emit,beginCluster,endCluster,getAnnotations,
303                    defineLabel,entryLabel,pseudoOp,annotation,                    defineLabel,entryLabel,pseudoOp,annotation,
304                    exitBlock,comment,...}) =                    exitBlock,comment,...}) =
305    let    let
# Line 413  Line 418 
418                             [_] => NONE | _ => SOME(I.FDirect(newFreg()))},an)                             [_] => NONE | _ => SOME(I.FDirect(newFreg()))},an)
419    
420        and move(s,d,an) =        and move(s,d,an) =
421            if C.sameCell(s,d) orelse C.sameCell(d,zeroR) then () else            if CB.sameCell(s,d) orelse CB.sameCell(d,zeroR) then () else
422            mark(I.COPY{dst=[d],src=[s],impl=ref NONE,tmp=NONE},an)            mark(I.COPY{dst=[d],src=[s],impl=ref NONE,tmp=NONE},an)
423    
424        and fmove(s,d,an) =        and fmove(s,d,an) =
425            if C.sameCell(s,d) orelse C.sameCell(d,zeroFR) then () else            if CB.sameCell(s,d) orelse CB.sameCell(d,zeroFR) then () else
426            mark(I.FCOPY{dst=[d],src=[s],impl=ref NONE,tmp=NONE},an)            mark(I.FCOPY{dst=[d],src=[s],impl=ref NONE,tmp=NONE},an)
427    
428         (* emit an sign extension op *)         (* emit an sign extension op *)
# Line 468  Line 473 
473                I.IMMop(toInt(n))                I.IMMop(toInt(n))
474              else let val tmpR = newReg()              else let val tmpR = newReg()
475                   in  loadImmed(n,zeroR,tmpR,[]); I.REGop tmpR end                   in  loadImmed(n,zeroR,tmpR,[]); I.REGop tmpR end
476          | opn(e as (T.CONST _ | T.LABEL _)) = I.LABop e          | opn(e as T.CONST _) = I.LABop e
477          | opn(T.LABEXP x) = I.LABop x          | opn(T.LABEXP x) = I.LABop x
478          | opn e = I.REGop(expr e)          | opn e = I.REGop(expr e)
479    
# Line 661  Line 666 
666            | SOME 0w3 => arith(I.S8ADDQ,a,zeroT,d,an)            | SOME 0w3 => arith(I.S8ADDQ,a,zeroT,d,an)
667            | _        => arith(I.SLL,a,b,d,an)            | _        => arith(I.SLL,a,b,d,an)
668    
669        and sra32(a,b,d,an) =         (* On the alpha, all 32 bit values are already sign extended.
670            let val ra = expr a          * So no sign extension is necessary.  We do the same for
671                val rb = opn b          * sra32 and sra64
               val t  = newReg()  
           in  (* On the alpha, all 32 bit values are already sign extended.  
                * So no sign extension is necessary.  
                * signExt32(ra,t);  
                * mark(I.OPERATE{oper=I.SRA,ra=t,rb=rb,rc=d},an)  
672                 *)                 *)
673                mark(I.OPERATE{oper=I.SRA,ra=ra,rb=rb,rc=d},an)        and sra(a,b,d,an) =
           end  
   
       and sra64(a,b,d,an) =  
674            mark(I.OPERATE{oper=I.SRA,ra=expr a,rb=opn b,rc=d},an)            mark(I.OPERATE{oper=I.SRA,ra=expr a,rb=opn b,rc=d},an)
675    
676        and srl32(a,b,d,an) =        and srl32(a,b,d,an) =
# Line 966  Line 963 
963            | T.REMS(32,a,b) => pseudo(P.reml,a,b,d)            | T.REMS(32,a,b) => pseudo(P.reml,a,b,d)
964    
965            | T.SLL(32,a,b) => sll32(a,b,d,an)            | T.SLL(32,a,b) => sll32(a,b,d,an)
966            | T.SRA(32,a,b) => sra32(a,b,d,an)            | T.SRA(32,a,b) => sra(a,b,d,an)
967            | T.SRL(32,a,b) => srl32(a,b,d,an)            | T.SRL(32,a,b) => srl32(a,b,d,an)
968    
969              (* 64 bit support *)              (* 64 bit support *)
# Line 994  Line 991 
991            | T.REMS(64,a,b) => pseudo(P.remq,a,b,d)            | T.REMS(64,a,b) => pseudo(P.remq,a,b,d)
992    
993            | T.SLL(64,a,b) => sll64(a,b,d,an)            | T.SLL(64,a,b) => sll64(a,b,d,an)
994            | T.SRA(64,a,b) => sra64(a,b,d,an)            | T.SRA(64,a,b) => sra(a,b,d,an)
995            | T.SRL(64,a,b) => srl64(a,b,d,an)            | T.SRL(64,a,b) => srl64(a,b,d,an)
996    
997              (* special bit operations with complement *)              (* special bit operations with complement *)
# Line 1202  Line 1199 
1199                  fun fall(cmp1, br1, cmp2, br2) =                  fun fall(cmp1, br1, cmp2, br2) =
1200                  let val tmpR1 = newFreg()                  let val tmpR1 = newFreg()
1201                      val tmpR2 = newFreg()                      val tmpR2 = newFreg()
1202                      val fallLab = Label.newLabel ""                      val fallLab = Label.anon()
1203                  in  emit(I.DEFFREG(tmpR1));                  in  emit(I.DEFFREG(tmpR1));
1204                      emit(I.FOPERATE{oper=cmp1, fa=f1, fb=f2, fc=tmpR1});                      emit(I.FOPERATE{oper=cmp1, fa=f1, fb=f2, fc=tmpR1});
1205                      emit(I.TRAPB);                      emit(I.TRAPB);
# Line 1416  Line 1413 
1413        and goto(lab,an) = mark(I.BRANCH{b=I.BR,r=zeroR,lab=lab},an)        and goto(lab,an) = mark(I.BRANCH{b=I.BR,r=zeroR,lab=lab},an)
1414    
1415           (* generate an call instruction *)           (* generate an call instruction *)
1416        and call(ea,flow,defs,uses,mem,an) =        and call(ea,flow,defs,uses,mem,cutTo,an,0) =
1417         let val defs=cellset defs         let val defs=cellset defs
1418             val uses=cellset uses             val uses=cellset uses
1419             val instr =             val instr =
1420                 case (ea, flow) of                 case (ea, flow) of
1421                   (T.LABEL lab, [_]) =>                   (T.LABEL lab, [_]) =>
1422                     I.BSR{lab=lab,r=C.returnAddr,defs=defs,uses=uses,mem=mem}                        I.BSR{lab=lab,r=C.returnAddr,defs=defs,uses=uses,
1423                                cutsTo=cutTo,mem=mem}
1424                 | _ => I.JSR{r=C.returnAddr,b=expr ea,                 | _ => I.JSR{r=C.returnAddr,b=expr ea,
1425                              d=0,defs=defs,uses=uses,mem=mem}                                   d=0,defs=defs,uses=uses,cutsTo=cutTo,mem=mem}
1426         in  mark(instr,an)         in  mark(instr,an)
1427         end         end
1428            | call _ = error "pops<>0 not implemented"
1429    
1430        and doCCexpr(T.CC(_,r),d,an) = move(r,d,an)        and doCCexpr(T.CC(_,r),d,an) = move(r,d,an)
1431          | doCCexpr(T.FCC(_,r),d,an) = fmove(r,d,an)          | doCCexpr(T.FCC(_,r),d,an) = fmove(r,d,an)
# Line 1454  Line 1453 
1453            | T.JMP(T.LABEL lab,_) => goto(lab,an)            | T.JMP(T.LABEL lab,_) => goto(lab,an)
1454            | T.JMP(e,labs) => mark(I.JMPL({r=zeroR,b=expr e,d=0},labs),an)            | T.JMP(e,labs) => mark(I.JMPL({r=zeroR,b=expr e,d=0},labs),an)
1455            | T.BCC(cc,lab) => branch(cc,lab,an)            | T.BCC(cc,lab) => branch(cc,lab,an)
1456            | T.CALL{funct,targets,defs,uses,region,...} =>            | T.CALL{funct,targets,defs,uses,region,pops,...} =>
1457                call(funct,targets,defs,uses,region,an)                call(funct,targets,defs,uses,region,[],an,pops)
1458              | T.FLOW_TO(T.CALL{funct,targets,defs,uses,region,pops,...},cutTo) =>
1459                  call(funct,targets,defs,uses,region,cutTo,an,pops)
1460            | T.RET _ => mark(I.RET{r=zeroR,b=C.returnAddr,d=0},an)            | T.RET _ => mark(I.RET{r=zeroR,b=C.returnAddr,d=0},an)
1461            | T.STORE(8,ea,data,mem) => store8(ea,data,mem,an)            | T.STORE(8,ea,data,mem) => store8(ea,data,mem,an)
1462            | T.STORE(16,ea,data,mem) => store16(ea,data,mem,an)            | T.STORE(16,ea,data,mem) => store16(ea,data,mem,an)
# Line 1506  Line 1507 
1507             entryLabel  = entryLabel,             entryLabel  = entryLabel,
1508             comment     = comment,             comment     = comment,
1509             annotation  = annotation,             annotation  = annotation,
1510               getAnnotations = getAnnotations,
1511             exitBlock   = fn regs => exitBlock(cellset regs)             exitBlock   = fn regs => exitBlock(cellset regs)
1512           }           }
1513     in  self()     in  self()

Legend:
Removed from v.788  
changed lines
  Added in v.933

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