diff options
Diffstat (limited to 'il.fun')
-rw-r--r-- | il.fun | 35 |
1 files changed, 23 insertions, 12 deletions
@@ -53,7 +53,7 @@ functor IL(P: PARSER) = struct | IrJmp of label | IrRet of vreg option - | IrAlloc of vreg * word + | IrAlloc of vreg * word * int option | IrCopy of vreg * label * word | IrFcall of vreg * vreg * vreg list @@ -240,7 +240,7 @@ functor IL(P: PARSER) = struct | IrJnz (r, _) => { defs = [], use = [r] } | IrNopLabel _ | IrNop _ => { defs = [], use = [] } | IrRet v => { defs = [], use = case v of SOME r => [r] | _ => [] } - | IrAlloc (r, _) => { defs = [r], use = [] } + | IrAlloc (r, _, _) => { defs = [r], use = [] } | IrCopy (r, _, _) => { defs = [], use = [r] } | IrFcall (rd, f, args) => { defs = if rd = ~1 then [] else [rd], use = f :: args } @@ -1024,7 +1024,7 @@ functor IL(P: PARSER) = struct let val size = P.sizeOfType $ #t $ Vector.sub (localVars, id) in - ctxPutOp C (IrAlloc (id, size)) + ctxPutOp C (IrAlloc (id, size, NONE)) end | convIni (C as Lctx { localVars, ... }) (id, SOME (P.CiniExpr ea)) = let @@ -1041,6 +1041,7 @@ functor IL(P: PARSER) = struct let val size = P.getLayoutSize lid in + ctxPutOp ctx (IrAlloc (id, size, NONE)); ctxPutOp ctx (IrCopy (id, lid, size)) end @@ -1236,7 +1237,7 @@ functor IL(P: PARSER) = struct bind A2 f end z - fun printConst class w = + fun pwc class w out = let val (sign, w) = case class of @@ -1251,9 +1252,11 @@ functor IL(P: PARSER) = struct else ("-", Word.~ w) in - printf `sign W w % + Printf out `sign W w % end + val Pwc = fn z => bind A2 pwc z + fun preg (C as Lctx { vregs, ... }) id out = let val rt = getRegType vregs id @@ -1261,8 +1264,8 @@ functor IL(P: PARSER) = struct case rt of RtReg => Printf out `"%" I id % | RtRem => raise Unreachable - | RtConst w => printConst (getClass C id) w - | RtAddrConst (id, w) => (printf `"$" PP.? id %; printConst VR8 w) + | RtConst w => printf Pwc (getClass C id) w % + | RtAddrConst (id, w) => printf `"$" PP.? id Pwc VR8 w % end val Preg = fn z => bind A2 preg z @@ -1272,8 +1275,8 @@ functor IL(P: PARSER) = struct in case arg of SaVReg reg => printf Preg ctx reg % - | SaConst w => printConst (getClass ctx reg) w - | SaAddr (id, w) => (printf PP.? id %; printConst VR8 w) + | SaConst w => printf Pwc (getClass ctx reg) w % + | SaAddr (id, w) => printf PP.? id Pwc VR8 w % end fun printOp ctx (idx, (SOME op', li)) = @@ -1304,7 +1307,15 @@ functor IL(P: PARSER) = struct | printRet (SOME reg) = printf `"\tret " Pt ctx reg `" " Preg ctx reg % - fun printAlloc (r, size) = printf `"\t" Preg ctx r `" = alloc " W size % + fun printAlloc (r, size, off) = + let + val () = printf `"\t" Preg ctx r `" = alloc " W size % + in + case off of + SOME off => printf `" [rbp-" I off `"]" % + | NONE => () + end + fun printCopy (to, from, size) = printf `"\tcopy " Preg ctx to `", .I" I from `", " W size % @@ -1389,9 +1400,9 @@ functor IL(P: PARSER) = struct case t of RtReg => printf `" regular" % | RtRem => printf `" removed" % - | RtConst w => (printf `" const "; printConst class w) + | RtConst w => printf `" const " Pwc class w % | RtAddrConst (id, w) => - (printf `" addr const " PP.? id; printConst class w) + printf `" addr const " PP.? id Pwc class w % ; printf `"\n" % end |