ABI: implement register arguments with constraints. (#4858)
* ABI: implement register arguments with constraints. Currently, Cranelift's ABI code emits a sequence of moves from physical registers into vregs at the top of the function body, one for every register-carried argument. For a number of reasons, we want to move to operand constraints instead, and remove the use of explicitly-named "pinned vregs"; this allows for better regalloc in theory, as it removes the need to "reverse-engineer" the sequence of moves. This PR alters the ABI code so that it generates a single "args" pseudo-instruction as the first instruction in the function body. This pseudo-inst defs all register arguments, and constrains them to the appropriate registers at the def-point. Subsequently the regalloc can move them wherever it needs to. Some care was taken not to have this pseudo-inst show up in post-regalloc disassemblies, but the change did cause a general regalloc "shift" in many tests, so the precise-output updates are a bit noisy. Sorry about that! A subsequent PR will handle the other half of the ABI code, namely, the callsite case, with a similar preg-to-constraint conversion. * Update based on review feedback. * Review feedback.
This commit is contained in:
@@ -158,7 +158,7 @@ pub struct VCode<I: VCodeInst> {
|
||||
block_order: BlockLoweringOrder,
|
||||
|
||||
/// ABI object.
|
||||
abi: Callee<I::ABIMachineSpec>,
|
||||
pub(crate) abi: Callee<I::ABIMachineSpec>,
|
||||
|
||||
/// Constant information used during code emission. This should be
|
||||
/// immutable across function compilations within the same module.
|
||||
@@ -179,7 +179,7 @@ pub struct VCode<I: VCodeInst> {
|
||||
/// Value labels for debuginfo attached to vregs.
|
||||
debug_value_labels: Vec<(VReg, InsnIndex, InsnIndex, u32)>,
|
||||
|
||||
sigs: SigSet,
|
||||
pub(crate) sigs: SigSet,
|
||||
}
|
||||
|
||||
/// The result of `VCode::emit`. Contains all information computed
|
||||
@@ -244,7 +244,7 @@ pub struct EmitResult<I: VCodeInst> {
|
||||
/// terminator instructions with successor blocks.)
|
||||
pub struct VCodeBuilder<I: VCodeInst> {
|
||||
/// In-progress VCode.
|
||||
vcode: VCode<I>,
|
||||
pub(crate) vcode: VCode<I>,
|
||||
|
||||
/// In what direction is the build occuring?
|
||||
direction: VCodeBuildDirection,
|
||||
@@ -862,7 +862,7 @@ impl<I: VCodeInst> VCode<I> {
|
||||
disasm: &mut String,
|
||||
buffer: &mut MachBuffer<I>,
|
||||
state: &mut I::State| {
|
||||
if want_disasm {
|
||||
if want_disasm && !inst.is_args() {
|
||||
let mut s = state.clone();
|
||||
writeln!(disasm, " {}", inst.pretty_print_inst(allocs, &mut s)).unwrap();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user