Rename "local variables" to "explicit stack slots".
The term "local variables" predated the SSA builder in the front-end crate, which also provides a way to implement source-language local variables. The name "explicit stack slot" makes it clear what this construct is.
This commit is contained in:
@@ -40,9 +40,9 @@ pub enum StackSlotKind {
|
||||
/// A spill slot. This is a stack slot created by the register allocator.
|
||||
SpillSlot,
|
||||
|
||||
/// A local variable. This is a chunk of local stack memory for use by the `stack_load` and
|
||||
/// `stack_store` instructions.
|
||||
Local,
|
||||
/// An explicit stack slot. This is a chunk of stack memory for use by the `stack_load`
|
||||
/// and `stack_store` instructions.
|
||||
ExplicitSlot,
|
||||
|
||||
/// An incoming function argument.
|
||||
///
|
||||
@@ -71,7 +71,7 @@ impl FromStr for StackSlotKind {
|
||||
fn from_str(s: &str) -> Result<StackSlotKind, ()> {
|
||||
use self::StackSlotKind::*;
|
||||
match s {
|
||||
"local" => Ok(Local),
|
||||
"explicit_slot" => Ok(ExplicitSlot),
|
||||
"spill_slot" => Ok(SpillSlot),
|
||||
"incoming_arg" => Ok(IncomingArg),
|
||||
"outgoing_arg" => Ok(OutgoingArg),
|
||||
@@ -85,7 +85,7 @@ impl fmt::Display for StackSlotKind {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
use self::StackSlotKind::*;
|
||||
f.write_str(match *self {
|
||||
Local => "local",
|
||||
ExplicitSlot => "explicit_slot",
|
||||
SpillSlot => "spill_slot",
|
||||
IncomingArg => "incoming_arg",
|
||||
OutgoingArg => "outgoing_arg",
|
||||
@@ -366,7 +366,7 @@ mod tests {
|
||||
assert_eq!(slot.alignment(8), 8);
|
||||
assert_eq!(slot.alignment(16), 8);
|
||||
|
||||
let slot2 = StackSlotData::new(StackSlotKind::Local, 24);
|
||||
let slot2 = StackSlotData::new(StackSlotKind::ExplicitSlot, 24);
|
||||
|
||||
assert_eq!(slot2.alignment(4), 4);
|
||||
assert_eq!(slot2.alignment(8), 8);
|
||||
|
||||
@@ -7,8 +7,8 @@ use std::cmp::{min, max};
|
||||
|
||||
/// Compute the stack frame layout.
|
||||
///
|
||||
/// Determine the total size of this stack frame and assign offsets to all `Spill` and `Local`
|
||||
/// stack slots.
|
||||
/// Determine the total size of this stack frame and assign offsets to all `Spill` and
|
||||
/// `Explicit` stack slots.
|
||||
///
|
||||
/// The total frame size will be a multiple of `alignment` which must be a power of two.
|
||||
///
|
||||
@@ -25,7 +25,7 @@ pub fn layout_stack(frame: &mut StackSlots, alignment: StackSize) -> Result<Stac
|
||||
// stack layout from high to low addresses will be:
|
||||
//
|
||||
// 1. incoming arguments.
|
||||
// 2. spills + locals.
|
||||
// 2. spills + explicits.
|
||||
// 3. outgoing arguments.
|
||||
//
|
||||
// The incoming arguments can have both positive and negative offsets. A negative offset
|
||||
@@ -57,15 +57,15 @@ pub fn layout_stack(frame: &mut StackSlots, alignment: StackSize) -> Result<Stac
|
||||
outgoing_max = max(outgoing_max, offset);
|
||||
}
|
||||
StackSlotKind::SpillSlot |
|
||||
StackSlotKind::Local |
|
||||
StackSlotKind::ExplicitSlot |
|
||||
StackSlotKind::EmergencySlot => {
|
||||
// Determine the smallest alignment of any local or spill slot.
|
||||
// Determine the smallest alignment of any explicit or spill slot.
|
||||
min_align = slot.alignment(min_align);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Lay out spill slots and locals below the incoming arguments.
|
||||
// Lay out spill slots and explicit slots below the incoming arguments.
|
||||
// The offset is negative, growing downwards.
|
||||
// Start with the smallest alignments for better packing.
|
||||
let mut offset = incoming_min;
|
||||
@@ -74,9 +74,10 @@ pub fn layout_stack(frame: &mut StackSlots, alignment: StackSize) -> Result<Stac
|
||||
for ss in frame.keys() {
|
||||
let slot = frame[ss].clone();
|
||||
|
||||
// Pick out locals and spill slots with exact alignment `min_align`.
|
||||
// Pick out explicit and spill slots with exact alignment `min_align`.
|
||||
match slot.kind {
|
||||
StackSlotKind::SpillSlot | StackSlotKind::Local => {
|
||||
StackSlotKind::SpillSlot |
|
||||
StackSlotKind::ExplicitSlot => {
|
||||
if slot.alignment(alignment) != min_align {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -475,29 +475,29 @@ mod tests {
|
||||
f.name = ExternalName::testcase("foo");
|
||||
assert_eq!(f.to_string(), "function %foo() native {\n}\n");
|
||||
|
||||
f.create_stack_slot(StackSlotData::new(StackSlotKind::Local, 4));
|
||||
f.create_stack_slot(StackSlotData::new(StackSlotKind::ExplicitSlot, 4));
|
||||
assert_eq!(
|
||||
f.to_string(),
|
||||
"function %foo() native {\n ss0 = local 4\n}\n"
|
||||
"function %foo() native {\n ss0 = explicit_slot 4\n}\n"
|
||||
);
|
||||
|
||||
let ebb = f.dfg.make_ebb();
|
||||
f.layout.append_ebb(ebb);
|
||||
assert_eq!(
|
||||
f.to_string(),
|
||||
"function %foo() native {\n ss0 = local 4\n\nebb0:\n}\n"
|
||||
"function %foo() native {\n ss0 = explicit_slot 4\n\nebb0:\n}\n"
|
||||
);
|
||||
|
||||
f.dfg.append_ebb_param(ebb, types::I8);
|
||||
assert_eq!(
|
||||
f.to_string(),
|
||||
"function %foo() native {\n ss0 = local 4\n\nebb0(v0: i8):\n}\n"
|
||||
"function %foo() native {\n ss0 = explicit_slot 4\n\nebb0(v0: i8):\n}\n"
|
||||
);
|
||||
|
||||
f.dfg.append_ebb_param(ebb, types::F32.by(4).unwrap());
|
||||
assert_eq!(
|
||||
f.to_string(),
|
||||
"function %foo() native {\n ss0 = local 4\n\nebb0(v0: i8, v1: f32x4):\n}\n"
|
||||
"function %foo() native {\n ss0 = explicit_slot 4\n\nebb0(v0: i8, v1: f32x4):\n}\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1044,7 +1044,7 @@ impl<'a> Parser<'a> {
|
||||
// Parse a stack slot decl.
|
||||
//
|
||||
// stack-slot-decl ::= * StackSlot(ss) "=" stack-slot-kind Bytes {"," stack-slot-flag}
|
||||
// stack-slot-kind ::= "local"
|
||||
// stack-slot-kind ::= "explicit_slot"
|
||||
// | "spill_slot"
|
||||
// | "incoming_arg"
|
||||
// | "outgoing_arg"
|
||||
|
||||
Reference in New Issue
Block a user