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 468, Wed Nov 10 22:42:52 1999 UTC revision 469, Wed Nov 10 22:42:52 1999 UTC
# Line 280  Line 280 
280    fun selectInstructions    fun selectInstructions
281          (S.STREAM{emit,beginCluster,endCluster,          (S.STREAM{emit,beginCluster,endCluster,
282                    defineLabel,entryLabel,pseudoOp,annotation,                    defineLabel,entryLabel,pseudoOp,annotation,
283                    blockName,exitBlock,phi,alias,comment,...}) =                    exitBlock,phi,alias,comment,...}) =
284    let    let
285        infix || && << >> ~>>        infix || && << >> ~>>
286    
# Line 340  Line 340 
340    
341        (* emit load immed *)        (* emit load immed *)
342        fun loadImmed(n, base, rd, an) =        fun loadImmed(n, base, rd, an) =
343        if ~32768 <= n andalso n < 32768 then        if n =0 then
344             move(base, rd, an)
345          else if ~32768 <= n andalso n < 32768 then
346           mark(I.LDA{r=rd, b=base, d=I.IMMop n},an)           mark(I.LDA{r=rd, b=base, d=I.IMMop n},an)
347        else        else
348        let val w = itow n        let val w = itow n
# Line 356  Line 358 
358         * In either case we sign extend the 32-bit value. This is compatible         * In either case we sign extend the 32-bit value. This is compatible
359         * with LDL which sign extends a 32-bit valued memory location.         * with LDL which sign extends a 32-bit valued memory location.
360         *)         *)
361        fun loadImmed32(0w0, base, rd, an) =        and loadImmed32(0w0, base, rd, an) =
362             mark(I.OPERATE{oper=I.ADDL, ra=base, rb=zeroOpn, rc=rd},an)             move(base, rd, an)
363          | loadImmed32(n, base, rd, an) = let          | loadImmed32(n, base, rd, an) = let
364              val low = W32.andb(n, 0w65535)  (* unsigned (0 .. 65535) *)              val low = W32.andb(n, 0w65535)  (* unsigned (0 .. 65535) *)
365              val high = W32.~>>(n, 0w16)     (* signed (~32768 .. 32768] *)              val high = W32.~>>(n, 0w16)     (* signed (~32768 .. 32768] *)
# Line 381  Line 383 
383                 else                 else
384                 let val tmpR1 = newReg()                 let val tmpR1 = newReg()
385                     val tmpR2 = newReg()                     val tmpR2 = newReg()
386                       val tmpR3 = newReg()
387                 in                 in
388                   (* you gotta do what you gotta do! *)                   (* you gotta do what you gotta do! *)
389                   emit(I.LDA{r=rd, b=base, d=I.IMMop(ilow)});                   emit(I.LDA{r=tmpR3, b=base, d=I.IMMop(ilow)});
390                   emit(I.OPERATE{oper=I.ADDL, ra=zeroR, rb=I.IMMop 1, rc=tmpR1});                   emit(I.OPERATE{oper=I.ADDQ, ra=zeroR, rb=I.IMMop 1, rc=tmpR1});
391                   emit(I.OPERATE{oper=I.SLL, ra=tmpR1, rb=I.IMMop 31, rc=tmpR2});                   emit(I.OPERATE{oper=I.SLL, ra=tmpR1, rb=I.IMMop 31, rc=tmpR2});
392                   mark(I.OPERATE{oper=I.ADDL, ra=tmpR2, rb=I.REGop rd, rc=rd},an)                   mark(I.OPERATE{oper=I.ADDQ, ra=tmpR2, rb=I.REGop tmpR3,
393                                    rc=rd},an)
394                 end                 end
395               end               end
396             end             end
397    
398        (* emit load immed *)        (* emit load immed *)
399        fun loadConst(c,d,an) = mark(I.LDA{r=d,b=zeroR,d=I.CONSTop c},an)        and loadConst(c,d,an) = mark(I.LDA{r=d,b=zeroR,d=I.CONSTop c},an)
400    
401        (* emit load label *)        (* emit load label *)
402        fun loadLabel(l,d,an) = mark(I.LDA{r=d,b=zeroR,d=I.LABop l},an)        and loadLabel(l,d,an) = mark(I.LDA{r=d,b=zeroR,d=I.LABop l},an)
403    
404        (* emit a copy *)        (* emit a copy *)
405        fun copy(dst,src,an) =        and copy(dst,src,an) =
406            mark(I.COPY{dst=dst,src=src,impl=ref NONE,            mark(I.COPY{dst=dst,src=src,impl=ref NONE,
407                        tmp=case dst of                        tmp=case dst of
408                             [_] => NONE | _ => SOME(I.Direct(newReg()))},an)                             [_] => NONE | _ => SOME(I.Direct(newReg()))},an)
409    
410        (* emit a floating point copy *)        (* emit a floating point copy *)
411        fun fcopy(dst,src,an) =        and fcopy(dst,src,an) =
412            mark(I.FCOPY{dst=dst,src=src,impl=ref NONE,            mark(I.FCOPY{dst=dst,src=src,impl=ref NONE,
413                        tmp=case dst of                        tmp=case dst of
414                             [_] => NONE | _ => SOME(I.FDirect(newFreg()))},an)                             [_] => NONE | _ => SOME(I.FDirect(newFreg()))},an)
415    
416        fun move(s,d,an) =        and move(s,d,an) =
417            if s = d orelse d = zeroR then () else            if s = d orelse d = zeroR then () else
418            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)
419    
420        fun fmove(s,d,an) =        and fmove(s,d,an) =
421            if s = d orelse d = zeroFR then () else            if s = d orelse d = zeroFR then () else
422            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)
423    
424         (* emit an sign extension op *)         (* emit an sign extension op *)
425        fun signExt32(r,d) =        and signExt32(r,d) =
426            emit(I.OPERATE{oper=I.SGNXL,ra=r,rb=zeroOpn,rc=d})            emit(I.OPERATE{oper=I.SGNXL,ra=r,rb=zeroOpn,rc=d})
427    
428        (* emit an commutative arithmetic op *)        (* emit an commutative arithmetic op *)
429        fun commArith(opcode,a,b,d,an) =        and commArith(opcode,a,b,d,an) =
430            case (opn a,opn b) of            case (opn a,opn b) of
431              (I.REGop r,i) => mark(I.OPERATE{oper=opcode,ra=r,rb=i,rc=d},an)              (I.REGop r,i) => mark(I.OPERATE{oper=opcode,ra=r,rb=i,rc=d},an)
432            | (i,I.REGop r) => mark(I.OPERATE{oper=opcode,ra=r,rb=i,rc=d},an)            | (i,I.REGop r) => mark(I.OPERATE{oper=opcode,ra=r,rb=i,rc=d},an)
# Line 1382  Line 1386 
1386          pseudoOp    = pseudoOp,          pseudoOp    = pseudoOp,
1387          defineLabel = defineLabel,          defineLabel = defineLabel,
1388          entryLabel  = entryLabel,          entryLabel  = entryLabel,
         blockName   = blockName,  
1389          comment     = comment,          comment     = comment,
1390          annotation  = annotation,          annotation  = annotation,
1391          exitBlock   = fn regs => exitBlock(map cc regs),          exitBlock   = fn regs => exitBlock(map cc regs),

Legend:
Removed from v.468  
changed lines
  Added in v.469

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