From bc7af8fdf0e2f6560c7d7fa6c17f893409c4830c Mon Sep 17 00:00:00 2001 From: bd-912 Date: Sat, 27 Apr 2024 22:42:35 -0600 Subject: Implement variable spilling --- vaporize/RegisterAlloc.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'vaporize/RegisterAlloc.java') diff --git a/vaporize/RegisterAlloc.java b/vaporize/RegisterAlloc.java index ae5826b..100d6c4 100644 --- a/vaporize/RegisterAlloc.java +++ b/vaporize/RegisterAlloc.java @@ -9,8 +9,10 @@ public class RegisterAlloc { private String[] all_registers; private Stack free_registers; private TreeSet active; + private int spill_start; public RegisterAlloc(LIRDict intervals, String[] all_registers) { + this.spill_start = 14; this.intervals = intervals; this.all_registers = all_registers; this.free_registers = new Stack(); @@ -68,13 +70,11 @@ public class RegisterAlloc { } private void spillAtInterval(LIRVar interval) { - MinimalLogger.severe(String.format("Ran out of free registers, but a spill for %s was not performed!", + // You can make this spill optimally (the sarkar linearscan algorithm) + MinimalLogger.severe(String.format("Ran out of free registers, had to spill %s!", interval.toString())); this.intervals.addSpilledNum(); - // LIRVar spill = this.active.get(this.active.length()-1); - // if (spill.getLastUse() > interval.getLastUse()) { - // ; - // } + interval.assignRegister(String.format("local[%d]", this.spill_start++)); } } -- cgit v1.2.3