s390x: use constraints for call arguments and return values (#5092)
Use the regalloc constraint-based CallArgList / CallRetList mechanism instead of directly using physregs in instructions.
This commit is contained in:
@@ -624,77 +624,6 @@ impl SigData {
|
||||
})
|
||||
}
|
||||
|
||||
/// Return all uses (i.e, function args), defs (i.e., return values
|
||||
/// and caller-saved registers), and clobbers for the callsite.
|
||||
///
|
||||
/// FIXME: used only by s390x; remove once that backend moves to
|
||||
/// `call_clobbers` and constraint-based calls.
|
||||
pub fn call_uses_defs_clobbers<M: ABIMachineSpec>(
|
||||
&self,
|
||||
) -> (SmallVec<[Reg; 8]>, SmallVec<[Writable<Reg>; 8]>, PRegSet) {
|
||||
// Compute uses: all arg regs.
|
||||
let mut uses = smallvec![];
|
||||
for arg in &self.args {
|
||||
match arg {
|
||||
&ABIArg::Slots { ref slots, .. } => {
|
||||
for slot in slots {
|
||||
match slot {
|
||||
&ABIArgSlot::Reg { reg, .. } => {
|
||||
uses.push(Reg::from(reg));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
&ABIArg::StructArg { ref pointer, .. } => {
|
||||
if let Some(slot) = pointer {
|
||||
match slot {
|
||||
&ABIArgSlot::Reg { reg, .. } => {
|
||||
uses.push(Reg::from(reg));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
&ABIArg::ImplicitPtrArg { ref pointer, .. } => match pointer {
|
||||
&ABIArgSlot::Reg { reg, .. } => {
|
||||
uses.push(Reg::from(reg));
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Get clobbers: all caller-saves. These may include return value
|
||||
// regs, which we will remove from the clobber set below.
|
||||
let mut clobbers = M::get_regs_clobbered_by_call(self.call_conv);
|
||||
|
||||
// Compute defs: all retval regs, and all caller-save
|
||||
// (clobbered) regs, except for StructRet args.
|
||||
let mut defs = smallvec![];
|
||||
for ret in &self.rets {
|
||||
if let &ABIArg::Slots {
|
||||
ref slots, purpose, ..
|
||||
} = ret
|
||||
{
|
||||
if purpose == ir::ArgumentPurpose::StructReturn {
|
||||
continue;
|
||||
}
|
||||
for slot in slots {
|
||||
match slot {
|
||||
&ABIArgSlot::Reg { reg, .. } => {
|
||||
defs.push(Writable::from_reg(Reg::from(reg)));
|
||||
clobbers.remove(PReg::from(reg));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(uses, defs, clobbers)
|
||||
}
|
||||
|
||||
/// Return all clobbers for the callsite.
|
||||
pub fn call_clobbers<M: ABIMachineSpec>(&self) -> PRegSet {
|
||||
// Get clobbers: all caller-saves. These may include return value
|
||||
|
||||
Reference in New Issue
Block a user