Skip to content

Commit

Permalink
boots: track free registers in InstTracker
Browse files Browse the repository at this point in the history
  • Loading branch information
dinfuehr committed Aug 30, 2023
1 parent ace0e66 commit 96396fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions dora-boots/assembler.dora
Original file line number Diff line number Diff line change
Expand Up @@ -290,4 +290,10 @@ impl RegSet {
pub fn equals(other: RegSet): Bool {
self.value == other.value
}

pub fn clone(): RegSet {
RegSet(
self.value,
)
}
}
4 changes: 3 additions & 1 deletion dora-boots/regalloc.dora
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ impl SimpleRegisterAllocator {
// pick a register
let register = self.tracker.allocateRegister(inst).getOrPanic();
loc.getOutput().setRegister(register);

}

for inst in block.instructionsIterator() {
Expand Down Expand Up @@ -132,6 +131,7 @@ fn ssaDestruction(graph: Graph, codegen: CodeGen) {

pub class InstTracker {
allocatable: RegSet,
free: RegSet,
data: RegMap[Inst],
locations: HashMap[Inst, Register],
}
Expand All @@ -140,6 +140,7 @@ impl InstTracker {
static fn new(allocatable: RegSet): InstTracker {
InstTracker(
allocatable,
allocatable.clone(),
RegMap[Inst]::new(allocatable),
HashMap[Inst, Register]::new(),
)
Expand Down Expand Up @@ -186,6 +187,7 @@ impl InstTracker {
fn clone(): InstTracker {
InstTracker(
self.allocatable,
self.free.clone(),
self.data.clone(),
self.locations.clone(),
)
Expand Down

0 comments on commit 96396fc

Please sign in to comment.