From aa994adee03b01d3427ba2f65646d77fcc30b35a Mon Sep 17 00:00:00 2001 From: Trevor Elliott Date: Fri, 30 Aug 2024 10:38:49 -0700 Subject: [PATCH 1/2] Remove the OperandConstraint::Stack variant Also remove the Requirement::Stack case, as there is no longer a constraint that can produce it. Co-authored-by: Nick Fitzgerald --- doc/DESIGN.md | 13 +++++-------- src/checker.rs | 11 ----------- src/ion/data_structures.rs | 4 +--- src/ion/liveranges.rs | 4 ---- src/ion/merge.rs | 9 +-------- src/ion/process.rs | 15 +-------------- src/ion/requirement.rs | 11 ++--------- src/lib.rs | 5 ----- 8 files changed, 10 insertions(+), 62 deletions(-) diff --git a/doc/DESIGN.md b/doc/DESIGN.md index cc3f771f..0c5f35ed 100644 --- a/doc/DESIGN.md +++ b/doc/DESIGN.md @@ -648,14 +648,11 @@ other): ```plain - ___Unknown_____ - | | | - | | | - | ____Any(rc) | - |/ | | - Stack(rc) FixedReg(reg) - \ / - Conflict + Any(rc) + / \ + FixedReg(reg) FixedStack(reg) + \ / + Conflict ``` Once we have the Requirement for a bundle, we can decide what to do. diff --git a/src/checker.rs b/src/checker.rs index 98e014f4..297a89ef 100644 --- a/src/checker.rs +++ b/src/checker.rs @@ -649,17 +649,6 @@ impl CheckerState { } return Err(CheckerError::AllocationIsNotReg { inst, op, alloc }); } - OperandConstraint::Stack => { - if alloc.kind() != AllocationKind::Stack { - // Accept pregs that represent a fixed stack slot. - if let Some(preg) = alloc.as_reg() { - if checker.machine_env.fixed_stack_slots.contains(&preg) { - return Ok(()); - } - } - return Err(CheckerError::AllocationIsNotStack { inst, op, alloc }); - } - } OperandConstraint::FixedReg(preg) => { if alloc != Allocation::reg(preg) { return Err(CheckerError::AllocationIsNotFixedReg { inst, op, alloc }); diff --git a/src/ion/data_structures.rs b/src/ion/data_structures.rs index f888862b..aa84c378 100644 --- a/src/ion/data_structures.rs +++ b/src/ion/data_structures.rs @@ -216,14 +216,12 @@ impl LiveBundle { minimal: bool, fixed: bool, fixed_def: bool, - stack: bool, ) { debug_assert!(spill_weight <= BUNDLE_MAX_SPILL_WEIGHT); self.spill_weight_and_props = spill_weight | (if minimal { 1 << 31 } else { 0 }) | (if fixed { 1 << 30 } else { 0 }) - | (if fixed_def { 1 << 29 } else { 0 }) - | (if stack { 1 << 28 } else { 0 }); + | (if fixed_def { 1 << 29 } else { 0 }); } #[inline(always)] diff --git a/src/ion/liveranges.rs b/src/ion/liveranges.rs index 1744bd74..d6d413dd 100644 --- a/src/ion/liveranges.rs +++ b/src/ion/liveranges.rs @@ -805,10 +805,6 @@ impl<'a, F: Function> Env<'a, F> { first_reg_slot.get_or_insert(u.slot); } } - // Maybe this could be supported in this future... - OperandConstraint::Stack => panic!( - "multiple uses of vreg with a Stack constraint are not supported" - ), } } diff --git a/src/ion/merge.rs b/src/ion/merge.rs index 09bd2906..04afaf2f 100644 --- a/src/ion/merge.rs +++ b/src/ion/merge.rs @@ -263,7 +263,6 @@ impl<'a, F: Function> Env<'a, F> { let mut fixed = false; let mut fixed_def = false; - let mut stack = false; for entry in &self.bundles[bundle].ranges { for u in &self.ranges[entry.index].uses { if let OperandConstraint::FixedReg(_) = u.operand.constraint() { @@ -272,10 +271,7 @@ impl<'a, F: Function> Env<'a, F> { fixed_def = true; } } - if let OperandConstraint::Stack = u.operand.constraint() { - stack = true; - } - if fixed && stack && fixed_def { + if fixed && fixed_def { break; } } @@ -286,9 +282,6 @@ impl<'a, F: Function> Env<'a, F> { if fixed_def { self.bundles[bundle].set_cached_fixed_def(); } - if stack { - self.bundles[bundle].set_cached_stack(); - } // Create a spillslot for this bundle. let reg = self.vreg(vreg); diff --git a/src/ion/process.rs b/src/ion/process.rs index 371ab84b..0e07340f 100644 --- a/src/ion/process.rs +++ b/src/ion/process.rs @@ -265,7 +265,6 @@ impl<'a, F: Function> Env<'a, F> { let minimal; let mut fixed = false; let mut fixed_def = false; - let mut stack = false; let bundledata = &self.bundles[bundle]; let first_range = bundledata.ranges[0].index; let first_range_data = &self.ranges[first_range]; @@ -286,12 +285,7 @@ impl<'a, F: Function> Env<'a, F> { trace!(" -> is fixed def"); fixed_def = true; } - } - if let OperandConstraint::Stack = u.operand.constraint() { - trace!(" -> stack operand at {:?}: {:?}", u.pos, u.operand); - stack = true; - } - if stack && fixed { + break; } } @@ -343,7 +337,6 @@ impl<'a, F: Function> Env<'a, F> { minimal, fixed, fixed_def, - stack, ); } @@ -1056,12 +1049,6 @@ impl<'a, F: Function> Env<'a, F> { let fixed_preg = match req { Requirement::FixedReg(preg) | Requirement::FixedStack(preg) => Some(preg), Requirement::Register => None, - Requirement::Stack => { - // If we must be on the stack, mark our spillset - // as required immediately. - self.spillsets[self.bundles[bundle].spillset].required = true; - return Ok(()); - } Requirement::Any => { self.spilled_bundles.push(bundle); diff --git a/src/ion/requirement.rs b/src/ion/requirement.rs index fc049e20..5e9af2a3 100644 --- a/src/ion/requirement.rs +++ b/src/ion/requirement.rs @@ -61,7 +61,6 @@ pub enum Requirement { FixedReg(PReg), FixedStack(PReg), Register, - Stack, Any, } impl Requirement { @@ -70,15 +69,10 @@ impl Requirement { match (self, other) { (other, Requirement::Any) | (Requirement::Any, other) => Ok(other), (Requirement::Register, Requirement::Register) => Ok(self), - (Requirement::Stack, Requirement::Stack) => Ok(self), (Requirement::Register, Requirement::FixedReg(preg)) | (Requirement::FixedReg(preg), Requirement::Register) => { Ok(Requirement::FixedReg(preg)) } - (Requirement::Stack, Requirement::FixedStack(preg)) - | (Requirement::FixedStack(preg), Requirement::Stack) => { - Ok(Requirement::FixedStack(preg)) - } (Requirement::FixedReg(a), Requirement::FixedReg(b)) if a == b => Ok(self), (Requirement::FixedStack(a), Requirement::FixedStack(b)) if a == b => Ok(self), _ => Err(RequirementConflict), @@ -88,7 +82,7 @@ impl Requirement { #[inline(always)] pub fn is_stack(self) -> bool { match self { - Requirement::Stack | Requirement::FixedStack(..) => true, + Requirement::FixedStack(..) => true, Requirement::Register | Requirement::FixedReg(..) => false, Requirement::Any => false, } @@ -98,7 +92,7 @@ impl Requirement { pub fn is_reg(self) -> bool { match self { Requirement::Register | Requirement::FixedReg(..) => true, - Requirement::Stack | Requirement::FixedStack(..) => false, + Requirement::FixedStack(..) => false, Requirement::Any => false, } } @@ -116,7 +110,6 @@ impl<'a, F: Function> Env<'a, F> { } } OperandConstraint::Reg | OperandConstraint::Reuse(_) => Requirement::Register, - OperandConstraint::Stack => Requirement::Stack, OperandConstraint::Any => Requirement::Any, } } diff --git a/src/lib.rs b/src/lib.rs index 0d068cac..a2e9597c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -447,8 +447,6 @@ pub enum OperandConstraint { Any, /// Operand must be in a register. Register is read-only for Uses. Reg, - /// Operand must be on the stack. - Stack, /// Operand must be in a fixed register. FixedReg(PReg), /// On defs only: reuse a use's register. @@ -460,7 +458,6 @@ impl core::fmt::Display for OperandConstraint { match self { Self::Any => write!(f, "any"), Self::Reg => write!(f, "reg"), - Self::Stack => write!(f, "stack"), Self::FixedReg(preg) => write!(f, "fixed({})", preg), Self::Reuse(idx) => write!(f, "reuse({})", idx), } @@ -556,7 +553,6 @@ impl Operand { let constraint_field = match constraint { OperandConstraint::Any => 0, OperandConstraint::Reg => 1, - OperandConstraint::Stack => 2, OperandConstraint::FixedReg(preg) => { debug_assert_eq!(preg.class(), vreg.class()); 0b1000000 | preg.hw_enc() as u32 @@ -829,7 +825,6 @@ impl Operand { match constraint_field { 0 => OperandConstraint::Any, 1 => OperandConstraint::Reg, - 2 => OperandConstraint::Stack, _ => unreachable!(), } } From 09f5c9c9e2bee127a0a1c2ad17d30dd1386d4b99 Mon Sep 17 00:00:00 2001 From: Trevor Elliott Date: Fri, 30 Aug 2024 14:18:01 -0700 Subject: [PATCH 2/2] Embiggen BUNDLE_MAX_SPILL_WEIGHT --- src/ion/data_structures.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ion/data_structures.rs b/src/ion/data_structures.rs index aa84c378..b62cb2c0 100644 --- a/src/ion/data_structures.rs +++ b/src/ion/data_structures.rs @@ -203,7 +203,7 @@ pub struct LiveBundle { pub spill_weight_and_props: u32, } -pub const BUNDLE_MAX_SPILL_WEIGHT: u32 = (1 << 28) - 1; +pub const BUNDLE_MAX_SPILL_WEIGHT: u32 = (1 << 29) - 1; pub const MINIMAL_FIXED_BUNDLE_SPILL_WEIGHT: u32 = BUNDLE_MAX_SPILL_WEIGHT; pub const MINIMAL_BUNDLE_SPILL_WEIGHT: u32 = BUNDLE_MAX_SPILL_WEIGHT - 1; pub const BUNDLE_MAX_NORMAL_SPILL_WEIGHT: u32 = BUNDLE_MAX_SPILL_WEIGHT - 2;