Mercurial > repos > tabletprog
diff modules/il.tp @ 195:7856f0916549
Add save il instruction to save callee saved registers in function prolog
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 26 Aug 2013 21:04:44 -0700 |
parents | 30bed95cbb18 |
children | 49bca6487178 |
line wrap: on
line diff
--- a/modules/il.tp Mon Aug 26 20:42:20 2013 -0700 +++ b/modules/il.tp Mon Aug 26 21:04:44 2013 -0700 @@ -17,6 +17,7 @@ _call <- 13 _ret <- 14 _skipif <- 15 + _save <- 16 _names <- #[ "add" @@ -35,6 +36,7 @@ "call" "ret" "skipIf" + "save" ] op3:a:b:out:size <- :_opcode :_ina :_inb :_out :_size { @@ -394,6 +396,20 @@ } } } + save <- :regs :scope{ + #{ + opcode <- { _save } + numops <- { 0 } + name <- { _names get: _save } + string <- { + block <- scope join: "\n\t" + if: (scope length) > 0 { + block <- "\n\t" . block . "\n" + } + name . " " . (regs join: " ") . " {" . block . "}" + } + } + } allocRegs:withSource <- :instarr:regSrc { _regMap <- dict linear @@ -524,10 +540,15 @@ print: (string: reg) . " = " . assign . "\n" } - //TODO: Save callee saved regs - map: instarr :inst { + withassign <- map: instarr :inst { inst assignRegs: _assignments withSource: regSrc } + psave <- regSrc needSaveProlog + print: "Regs that need saving in prolog: " . (psave join: ",") . "\n" + if: (psave length) > 0 { + withassign <- #[save: psave withassign] + } + withassign } //used to convert IL to a format suitable for a 2-operand architecture