Cranelift: use regalloc2 constraints on caller side of ABI code. (#4892)
* Cranelift: use regalloc2 constraints on caller side of ABI code. This PR updates the shared ABI code and backends to use register-operand constraints rather than explicit pinned-vreg moves for register arguments and return values. The s390x backend was not updated, because it has its own implementation of ABI code. Ideally we could converge back to the code shared by x64 and aarch64 (which didn't exist when s390x ported calls to ISLE, so the current situation is underestandable, to be clear!). I'll leave this for future work. This PR exposed several places where regalloc2 needed to be a bit more flexible with constraints; it requires regalloc2#74 to be merged and pulled in. * Update to regalloc2 0.3.3. In addition to version bump, this required removing two asserts as `SpillSlot`s no longer carry their class (so we can't assert that they have the correct class). * Review comments. * Filetest updates. * Add cargo-vet audit for regalloc2 0.3.2 -> 0.3.3 upgrade. * Update to regalloc2 0.4.0.
This commit is contained in:
@@ -919,8 +919,8 @@ impl ABIMachineSpec for AArch64MachineDeps {
|
||||
|
||||
fn gen_call(
|
||||
dest: &CallDest,
|
||||
uses: SmallVec<[Reg; 8]>,
|
||||
defs: SmallVec<[Writable<Reg>; 8]>,
|
||||
uses: CallArgList,
|
||||
defs: CallRetList,
|
||||
clobbers: PRegSet,
|
||||
opcode: ir::Opcode,
|
||||
tmp: Writable<Reg>,
|
||||
@@ -978,19 +978,32 @@ impl ABIMachineSpec for AArch64MachineDeps {
|
||||
call_conv: isa::CallConv,
|
||||
dst: Reg,
|
||||
src: Reg,
|
||||
tmp: Writable<Reg>,
|
||||
_tmp2: Writable<Reg>,
|
||||
size: usize,
|
||||
) -> SmallVec<[Self::I; 8]> {
|
||||
let mut insts = SmallVec::new();
|
||||
let arg0 = writable_xreg(0);
|
||||
let arg1 = writable_xreg(1);
|
||||
let arg2 = writable_xreg(2);
|
||||
insts.push(Inst::gen_move(arg0, dst, I64));
|
||||
insts.push(Inst::gen_move(arg1, src, I64));
|
||||
insts.extend(Inst::load_constant(arg2, size as u64).into_iter());
|
||||
insts.extend(Inst::load_constant(tmp, size as u64).into_iter());
|
||||
insts.push(Inst::Call {
|
||||
info: Box::new(CallInfo {
|
||||
dest: ExternalName::LibCall(LibCall::Memcpy),
|
||||
uses: smallvec![arg0.to_reg(), arg1.to_reg(), arg2.to_reg()],
|
||||
uses: smallvec![
|
||||
CallArgPair {
|
||||
vreg: dst,
|
||||
preg: arg0.to_reg()
|
||||
},
|
||||
CallArgPair {
|
||||
vreg: src,
|
||||
preg: arg1.to_reg()
|
||||
},
|
||||
CallArgPair {
|
||||
vreg: tmp.to_reg(),
|
||||
preg: arg2.to_reg()
|
||||
}
|
||||
],
|
||||
defs: smallvec![],
|
||||
clobbers: Self::get_regs_clobbered_by_call(call_conv),
|
||||
opcode: Opcode::Call,
|
||||
|
||||
@@ -78,8 +78,8 @@ impl BitOp {
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct CallInfo {
|
||||
pub dest: ExternalName,
|
||||
pub uses: SmallVec<[Reg; 8]>,
|
||||
pub defs: SmallVec<[Writable<Reg>; 8]>,
|
||||
pub uses: CallArgList,
|
||||
pub defs: CallRetList,
|
||||
pub clobbers: PRegSet,
|
||||
pub opcode: Opcode,
|
||||
pub caller_callconv: CallConv,
|
||||
@@ -91,8 +91,8 @@ pub struct CallInfo {
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct CallIndInfo {
|
||||
pub rn: Reg,
|
||||
pub uses: SmallVec<[Reg; 8]>,
|
||||
pub defs: SmallVec<[Writable<Reg>; 8]>,
|
||||
pub uses: SmallVec<[CallArgPair; 8]>,
|
||||
pub defs: SmallVec<[CallRetPair; 8]>,
|
||||
pub clobbers: PRegSet,
|
||||
pub opcode: Opcode,
|
||||
pub caller_callconv: CallConv,
|
||||
@@ -1027,14 +1027,22 @@ fn aarch64_get_operands<F: Fn(VReg) -> VReg>(inst: &Inst, collector: &mut Operan
|
||||
}
|
||||
&Inst::Jump { .. } => {}
|
||||
&Inst::Call { ref info, .. } => {
|
||||
collector.reg_uses(&info.uses[..]);
|
||||
collector.reg_defs(&info.defs[..]);
|
||||
for u in &info.uses {
|
||||
collector.reg_fixed_use(u.vreg, u.preg);
|
||||
}
|
||||
for d in &info.defs {
|
||||
collector.reg_fixed_def(d.vreg, d.preg);
|
||||
}
|
||||
collector.reg_clobbers(info.clobbers);
|
||||
}
|
||||
&Inst::CallInd { ref info, .. } => {
|
||||
collector.reg_use(info.rn);
|
||||
collector.reg_uses(&info.uses[..]);
|
||||
collector.reg_defs(&info.defs[..]);
|
||||
for u in &info.uses {
|
||||
collector.reg_fixed_use(u.vreg, u.preg);
|
||||
}
|
||||
for d in &info.defs {
|
||||
collector.reg_fixed_def(d.vreg, d.preg);
|
||||
}
|
||||
collector.reg_clobbers(info.clobbers);
|
||||
}
|
||||
&Inst::CondBr { ref kind, .. } => match kind {
|
||||
|
||||
Reference in New Issue
Block a user