diff options
Diffstat (limited to 'emit.fun')
-rw-r--r-- | emit.fun | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -847,6 +847,36 @@ functor Emit(I: IL) = struct List.app (printAllocVar rinfo) toAlloc end + fun getUsedRegs rinfo = + let + val regs = Array.array (usedRegNum, false) + + fun loop idx = + if idx = Array.length rinfo then + () + else + let + val (_, vt) = Array.sub (rinfo, idx) + in + case vt of + VtReg reg => Array.update (regs, reg2idx reg - firstUsedReg, true) + | _ => (); + loop (idx + 1) + end + val () = loop 0 + + fun collect idx acc = + if idx = usedRegNum then + acc + else + if Array.sub (regs, idx) then + collect (idx + 1) (idx2reg (idx + firstUsedReg) :: acc) + else + collect (idx + 1) acc + in + collect 0 [] + end + fun regAlloc (F as I.Fi { vregs, ops, paramNum, ... }) = let val (toAlloc, regInfo) = prepareRegInfo paramNum ops vregs @@ -858,6 +888,10 @@ functor Emit(I: IL) = struct val () = linearscan regInfo intervals val () = printAlloced regInfo toAlloc + + val usedRegs = getUsedRegs regInfo + val () = printfn + `"used registers: " Plist preg usedRegs (", ", true, 0) % in raise Unimplemented end |