Assign stack slots to incoming function arguments.

Function arguments that don't fit in registers are passed on the stack.

Create "incoming_arg" stack slots representing the stack arguments, and
assign them to the value arguments during spilling.
This commit is contained in:
Jakob Stoklund Olesen
2017-06-28 14:59:59 -07:00
parent 05cf44a156
commit b2fda76c5f
5 changed files with 53 additions and 17 deletions

View File

@@ -155,10 +155,10 @@ impl StackSlots {
}
/// Create a stack slot representing an incoming function argument.
pub fn make_incoming_arg(&mut self, ty: Type, offset: u32) -> StackSlot {
pub fn make_incoming_arg(&mut self, ty: Type, offset: i32) -> StackSlot {
let mut data = StackSlotData::new(StackSlotKind::IncomingArg, ty.bytes());
assert!(offset <= i32::max_value() as u32 - data.size);
data.offset = offset as i32;
assert!(offset <= i32::max_value() - data.size as i32);
data.offset = offset;
self.push(data)
}
}

View File

@@ -112,6 +112,14 @@ impl ArgumentLoc {
}
}
/// Is this a stack location?
pub fn is_stack(&self) -> bool {
match *self {
ArgumentLoc::Stack(_) => true,
_ => false,
}
}
/// Return an object that can display this argument location, using the register info from the
/// target ISA.
pub fn display<'a, R: Into<Option<&'a RegInfo>>>(self, regs: R) -> DisplayArgumentLoc<'a> {