Allow pinned-vregs to be implicit liveins. (#30)

Previously, the regalloc required all liveins to be defined by a
pseudoinstruction at the start of the function body. The regalloc.rs
compatibility shim did this, but it's slightly inconvenient when using
the API directly. This change allows pinned vregs to be implicit liveins
to the function body instead.
This commit is contained in:
Chris Fallin
2022-03-18 10:13:56 -07:00
committed by GitHub
parent b1a512dbf6
commit bf92e7c02f
2 changed files with 14 additions and 13 deletions

View File

@@ -368,19 +368,15 @@ impl<'a, F: Function> Env<'a, F> {
self.liveins[block.index()] = live;
}
// Check that there are no liveins to the entry block. (The
// client should create a virtual intsruction that defines any
// PReg liveins if necessary.)
if self.liveins[self.func.entry_block().index()]
.iter()
.next()
.is_some()
{
trace!(
"non-empty liveins to entry block: {:?}",
self.liveins[self.func.entry_block().index()]
);
return Err(RegAllocError::EntryLivein);
// Check that there are no liveins to the entry block, except
// for pinned vregs. (The client should create a virtual
// instruction that defines any other liveins if necessary.)
for livein in self.liveins[self.func.entry_block().index()].iter() {
let livein = self.vreg_regs[livein];
if self.func.is_pinned_vreg(livein).is_none() {
trace!("non-pinned-vreg livein to entry block: {}", livein);
return Err(RegAllocError::EntryLivein);
}
}
Ok(())