Track stack slot kinds.

Add a StackSlotKind enumeration to help keep track of the different
kinds of stack slots supported:

- Incoming and outgoing function arguments on the stack.
- Spill slots and locals.

Change the text format syntax for declaring a stack slot to use a kind
keyword rather than just 'stack_slot'.
This commit is contained in:
Jakob Stoklund Olesen
2017-06-16 10:35:01 -07:00
parent 66bc0a9c8b
commit 91d919c11a
9 changed files with 110 additions and 38 deletions

View File

@@ -359,7 +359,7 @@ impl<'a> fmt::Display for DisplayValues<'a> {
#[cfg(test)]
mod tests {
use ir::{Function, FunctionName, StackSlotData};
use ir::{Function, FunctionName, StackSlotData, StackSlotKind};
use ir::types;
#[test]
@@ -370,21 +370,21 @@ mod tests {
f.name = FunctionName::new("foo");
assert_eq!(f.to_string(), "function %foo() {\n}\n");
f.stack_slots.push(StackSlotData::new(4));
assert_eq!(f.to_string(),
"function %foo() {\n ss0 = stack_slot 4\n}\n");
f.stack_slots
.push(StackSlotData::new(StackSlotKind::Local, 4));
assert_eq!(f.to_string(), "function %foo() {\n ss0 = local 4\n}\n");
let ebb = f.dfg.make_ebb();
f.layout.append_ebb(ebb);
assert_eq!(f.to_string(),
"function %foo() {\n ss0 = stack_slot 4\n\nebb0:\n}\n");
"function %foo() {\n ss0 = local 4\n\nebb0:\n}\n");
f.dfg.append_ebb_arg(ebb, types::I8);
assert_eq!(f.to_string(),
"function %foo() {\n ss0 = stack_slot 4\n\nebb0(v0: i8):\n}\n");
"function %foo() {\n ss0 = local 4\n\nebb0(v0: i8):\n}\n");
f.dfg.append_ebb_arg(ebb, types::F32.by(4).unwrap());
assert_eq!(f.to_string(),
"function %foo() {\n ss0 = stack_slot 4\n\nebb0(v0: i8, v1: f32x4):\n}\n");
"function %foo() {\n ss0 = local 4\n\nebb0(v0: i8, v1: f32x4):\n}\n");
}
}