diff options
author | bd-912 <bdunahu@colostate.edu> | 2024-04-29 17:09:51 -0600 |
---|---|---|
committer | bd-912 <bdunahu@colostate.edu> | 2024-04-29 17:09:51 -0600 |
commit | ae4c925285a2f5d4d5c584168baafbabd0fe7971 (patch) | |
tree | 51cc017006eff54ef461667e2b88d3db5fe5d04c /vaporize/RegisterAlloc.java | |
parent | 3dfeff8e8e4c84929e35880bf0bbdea64c085fc0 (diff) |
Implement optimal spilling, fix minor issue with gaps in LRA
Diffstat (limited to 'vaporize/RegisterAlloc.java')
-rw-r--r-- | vaporize/RegisterAlloc.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/vaporize/RegisterAlloc.java b/vaporize/RegisterAlloc.java index 100d6c4..3afdb02 100644 --- a/vaporize/RegisterAlloc.java +++ b/vaporize/RegisterAlloc.java @@ -70,10 +70,16 @@ public class RegisterAlloc { } private void spillAtInterval(LIRVar interval) { - // You can make this spill optimally (the sarkar linearscan algorithm) + this.intervals.addSpilledNum(); + LIRVar spill = this.active.last(); + if (spill.getLastUse() > interval.getLastUse()) { + interval.assignRegister(spill.getAssignedRegister()); + this.active.add(interval); + this.active.remove(spill); + interval = spill; + } MinimalLogger.severe(String.format("Ran out of free registers, had to spill %s!", interval.toString())); - this.intervals.addSpilledNum(); interval.assignRegister(String.format("local[%d]", this.spill_start++)); } |