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 /MLRISC/trunk/amd64/mltree/amd64-gen.sml
ViewVC logotype

Diff of /MLRISC/trunk/amd64/mltree/amd64-gen.sml

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

revision 3048, Thu May 29 22:14:42 2008 UTC revision 3049, Fri May 30 00:58:55 2008 UTC
# Line 109  Line 109 
109            end handle _ => (i, NONE)            end handle _ => (i, NONE)
110        end        end
111    
     fun immedLabel lab = I.ImmedLabel(T.LABEL lab)  
   
112      (* translate MLTREE condition codes to amd64 condition codes *)      (* translate MLTREE condition codes to amd64 condition codes *)
113      fun cond T.LT = I.LT | cond T.LTU = I.B      fun cond T.LT = I.LT | cond T.LTU = I.B
114        | cond T.LE = I.LE | cond T.LEU = I.BE        | cond T.LE = I.LE | cond T.LEU = I.BE
# Line 352  Line 350 
350    
351          and address (ea, mem) = address' 64 (ea, mem)          and address (ea, mem) = address' 64 (ea, mem)
352    
353          (* load the label into a temp register. this operation is necessary, since most instructions
354           * can only handle 32-bit immediates *)
355            and loadLabel src = let
356                val tmp = newReg ()
357                val tmpR = I.Direct (64, tmp)
358                in
359                    emitInstr (move64 (src, tmpR));
360                    tmpR
361                end
362    
363          (* reduce an expression into an operand *)          (* reduce an expression into an operand *)
364          and operand ty (T.LI i) = if (fitsIn32Bits i)          and operand ty (T.LI i) = if (fitsIn32Bits i)
365              then I.Immed (toInt32 i)              then I.Immed (toInt32 i)
# Line 364  Line 372 
372                     move (ty, I.Immed64 (Int64.fromLarge i'), dst);                     move (ty, I.Immed64 (Int64.fromLarge i'), dst);
373                     dst                     dst
374                 end                 end
375            | operand _ (x as (T.CONST _ | T.LABEL _)) = I.ImmedLabel x            | operand _ (x as (T.CONST _ | T.LABEL _)) = loadLabel (I.ImmedLabel x)
376            | operand _ (T.LABEXP le) = I.ImmedLabel le            | operand _ (T.LABEXP le) = loadLabel (I.ImmedLabel le)
377            | operand _ (T.REG(ty,r)) = gpr (ty, r)            | operand _ (T.REG(ty,r)) = gpr (ty, r)
378            | operand _ (T.LOAD(ty,ea,mem)) = address (ea, mem)            | operand _ (T.LOAD(ty,ea,mem)) = address (ea, mem)
379            | operand ty t = I.Direct(ty, genExpr t)            | operand ty t = I.Direct(ty, genExpr t)
380    
381            and immedLabel lab = I.ImmedLabel(T.LABEL lab)
382    
383          (* ensure that the operand is either an immed or register *)          (* ensure that the operand is either an immed or register *)
384          and immedOrReg(ty, opnd as I.Displace _) = moveToReg (ty, opnd)          and immedOrReg(ty, opnd as I.Displace _) = moveToReg (ty, opnd)
385            | immedOrReg(ty, opnd as I.Indexed _)  = moveToReg (ty, opnd)            | immedOrReg(ty, opnd as I.Indexed _)  = moveToReg (ty, opnd)
386            | immedOrReg(ty, opnd as I.LabelEA _)  = moveToReg (ty, opnd)            | immedOrReg(ty, opnd as I.LabelEA _)  = moveToReg (ty, opnd)
387            | immedOrReg (ty, opnd)  = opnd            | immedOrReg (ty, opnd)  = opnd
388    
389          and regOrMem (ty, opnd) =          and regOrMem (ty, opnd as (I.Immed _ | I.ImmedLabel _)) = moveToReg (ty, opnd)
390              if isImmediate opnd then moveToReg (ty, opnd) else opnd            | regOrMem (ty, opnd) = opnd
391    
392          and getExpr (exp as T.REG(_, rd)) = rd          and getExpr (exp as T.REG(_, rd)) = rd
393            | getExpr exp = genExpr exp            | getExpr exp = genExpr exp
# Line 390  Line 400 
400              end              end
401    
402          and isImmediate(I.Immed _) = true          and isImmediate(I.Immed _) = true
403            | isImmediate(I.ImmedLabel _) = true  (*        | isImmediate(I.ImmedLabel _) = true *)
404            | isImmediate _ = false            | isImmediate _ = false
405    
406          and genExpr' e = let          and genExpr' e = let

Legend:
Removed from v.3048  
changed lines
  Added in v.3049

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