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:
@@ -368,20 +368,16 @@ impl<'a, F: Function> Env<'a, F> {
|
|||||||
self.liveins[block.index()] = live;
|
self.liveins[block.index()] = live;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that there are no liveins to the entry block. (The
|
// Check that there are no liveins to the entry block, except
|
||||||
// client should create a virtual intsruction that defines any
|
// for pinned vregs. (The client should create a virtual
|
||||||
// PReg liveins if necessary.)
|
// instruction that defines any other liveins if necessary.)
|
||||||
if self.liveins[self.func.entry_block().index()]
|
for livein in self.liveins[self.func.entry_block().index()].iter() {
|
||||||
.iter()
|
let livein = self.vreg_regs[livein];
|
||||||
.next()
|
if self.func.is_pinned_vreg(livein).is_none() {
|
||||||
.is_some()
|
trace!("non-pinned-vreg livein to entry block: {}", livein);
|
||||||
{
|
|
||||||
trace!(
|
|
||||||
"non-empty liveins to entry block: {:?}",
|
|
||||||
self.liveins[self.func.entry_block().index()]
|
|
||||||
);
|
|
||||||
return Err(RegAllocError::EntryLivein);
|
return Err(RegAllocError::EntryLivein);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -977,6 +977,11 @@ pub trait Function {
|
|||||||
/// liverange computation will check that this is the case (that
|
/// liverange computation will check that this is the case (that
|
||||||
/// there are enough remaining allocatable pregs of every class to
|
/// there are enough remaining allocatable pregs of every class to
|
||||||
/// hold all Reg-constrained operands).
|
/// hold all Reg-constrained operands).
|
||||||
|
///
|
||||||
|
/// Pinned vregs are implicitly live-in to the function: that is,
|
||||||
|
/// one can use a pinned vreg without having first defined it, and
|
||||||
|
/// this will take the value that that physical register (to which
|
||||||
|
/// the vreg is pinned) had at function entry.
|
||||||
fn is_pinned_vreg(&self, _: VReg) -> Option<PReg> {
|
fn is_pinned_vreg(&self, _: VReg) -> Option<PReg> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user