Skip to content

Commit abdc3d6

Browse files
elliotttfitzgen
andauthored
Remove the OperandConstraint::Stack variant (#185)
Following on from the removal of safepoints, remove the `OperandConstraint::Stack` and `Requirement::Stack` enum variants, as there's no longer any way to construct them. Co-authored-by: Nick Fitzgerald <[email protected]> --------- Co-authored-by: Nick Fitzgerald <[email protected]>
1 parent 76f120b commit abdc3d6

File tree

8 files changed

+11
-63
lines changed

8 files changed

+11
-63
lines changed

doc/DESIGN.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -648,14 +648,11 @@ other):
648648

649649
```plain
650650
651-
___Unknown_____
652-
| | |
653-
| | |
654-
| ____Any(rc) |
655-
|/ | |
656-
Stack(rc) FixedReg(reg)
657-
\ /
658-
Conflict
651+
Any(rc)
652+
/ \
653+
FixedReg(reg) FixedStack(reg)
654+
\ /
655+
Conflict
659656
```
660657

661658
Once we have the Requirement for a bundle, we can decide what to do.

src/checker.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -649,17 +649,6 @@ impl CheckerState {
649649
}
650650
return Err(CheckerError::AllocationIsNotReg { inst, op, alloc });
651651
}
652-
OperandConstraint::Stack => {
653-
if alloc.kind() != AllocationKind::Stack {
654-
// Accept pregs that represent a fixed stack slot.
655-
if let Some(preg) = alloc.as_reg() {
656-
if checker.machine_env.fixed_stack_slots.contains(&preg) {
657-
return Ok(());
658-
}
659-
}
660-
return Err(CheckerError::AllocationIsNotStack { inst, op, alloc });
661-
}
662-
}
663652
OperandConstraint::FixedReg(preg) => {
664653
if alloc != Allocation::reg(preg) {
665654
return Err(CheckerError::AllocationIsNotFixedReg { inst, op, alloc });

src/ion/data_structures.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ pub struct LiveBundle {
203203
pub spill_weight_and_props: u32,
204204
}
205205

206-
pub const BUNDLE_MAX_SPILL_WEIGHT: u32 = (1 << 28) - 1;
206+
pub const BUNDLE_MAX_SPILL_WEIGHT: u32 = (1 << 29) - 1;
207207
pub const MINIMAL_FIXED_BUNDLE_SPILL_WEIGHT: u32 = BUNDLE_MAX_SPILL_WEIGHT;
208208
pub const MINIMAL_BUNDLE_SPILL_WEIGHT: u32 = BUNDLE_MAX_SPILL_WEIGHT - 1;
209209
pub const BUNDLE_MAX_NORMAL_SPILL_WEIGHT: u32 = BUNDLE_MAX_SPILL_WEIGHT - 2;
@@ -216,14 +216,12 @@ impl LiveBundle {
216216
minimal: bool,
217217
fixed: bool,
218218
fixed_def: bool,
219-
stack: bool,
220219
) {
221220
debug_assert!(spill_weight <= BUNDLE_MAX_SPILL_WEIGHT);
222221
self.spill_weight_and_props = spill_weight
223222
| (if minimal { 1 << 31 } else { 0 })
224223
| (if fixed { 1 << 30 } else { 0 })
225-
| (if fixed_def { 1 << 29 } else { 0 })
226-
| (if stack { 1 << 28 } else { 0 });
224+
| (if fixed_def { 1 << 29 } else { 0 });
227225
}
228226

229227
#[inline(always)]

src/ion/liveranges.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -805,10 +805,6 @@ impl<'a, F: Function> Env<'a, F> {
805805
first_reg_slot.get_or_insert(u.slot);
806806
}
807807
}
808-
// Maybe this could be supported in this future...
809-
OperandConstraint::Stack => panic!(
810-
"multiple uses of vreg with a Stack constraint are not supported"
811-
),
812808
}
813809
}
814810

src/ion/merge.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ impl<'a, F: Function> Env<'a, F> {
263263

264264
let mut fixed = false;
265265
let mut fixed_def = false;
266-
let mut stack = false;
267266
for entry in &self.bundles[bundle].ranges {
268267
for u in &self.ranges[entry.index].uses {
269268
if let OperandConstraint::FixedReg(_) = u.operand.constraint() {
@@ -272,10 +271,7 @@ impl<'a, F: Function> Env<'a, F> {
272271
fixed_def = true;
273272
}
274273
}
275-
if let OperandConstraint::Stack = u.operand.constraint() {
276-
stack = true;
277-
}
278-
if fixed && stack && fixed_def {
274+
if fixed && fixed_def {
279275
break;
280276
}
281277
}
@@ -286,9 +282,6 @@ impl<'a, F: Function> Env<'a, F> {
286282
if fixed_def {
287283
self.bundles[bundle].set_cached_fixed_def();
288284
}
289-
if stack {
290-
self.bundles[bundle].set_cached_stack();
291-
}
292285

293286
// Create a spillslot for this bundle.
294287
let reg = self.vreg(vreg);

src/ion/process.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@ impl<'a, F: Function> Env<'a, F> {
265265
let minimal;
266266
let mut fixed = false;
267267
let mut fixed_def = false;
268-
let mut stack = false;
269268
let bundledata = &self.bundles[bundle];
270269
let first_range = bundledata.ranges[0].index;
271270
let first_range_data = &self.ranges[first_range];
@@ -286,12 +285,7 @@ impl<'a, F: Function> Env<'a, F> {
286285
trace!(" -> is fixed def");
287286
fixed_def = true;
288287
}
289-
}
290-
if let OperandConstraint::Stack = u.operand.constraint() {
291-
trace!(" -> stack operand at {:?}: {:?}", u.pos, u.operand);
292-
stack = true;
293-
}
294-
if stack && fixed {
288+
295289
break;
296290
}
297291
}
@@ -343,7 +337,6 @@ impl<'a, F: Function> Env<'a, F> {
343337
minimal,
344338
fixed,
345339
fixed_def,
346-
stack,
347340
);
348341
}
349342

@@ -1056,12 +1049,6 @@ impl<'a, F: Function> Env<'a, F> {
10561049
let fixed_preg = match req {
10571050
Requirement::FixedReg(preg) | Requirement::FixedStack(preg) => Some(preg),
10581051
Requirement::Register => None,
1059-
Requirement::Stack => {
1060-
// If we must be on the stack, mark our spillset
1061-
// as required immediately.
1062-
self.spillsets[self.bundles[bundle].spillset].required = true;
1063-
return Ok(());
1064-
}
10651052

10661053
Requirement::Any => {
10671054
self.spilled_bundles.push(bundle);

src/ion/requirement.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ pub enum Requirement {
6161
FixedReg(PReg),
6262
FixedStack(PReg),
6363
Register,
64-
Stack,
6564
Any,
6665
}
6766
impl Requirement {
@@ -70,15 +69,10 @@ impl Requirement {
7069
match (self, other) {
7170
(other, Requirement::Any) | (Requirement::Any, other) => Ok(other),
7271
(Requirement::Register, Requirement::Register) => Ok(self),
73-
(Requirement::Stack, Requirement::Stack) => Ok(self),
7472
(Requirement::Register, Requirement::FixedReg(preg))
7573
| (Requirement::FixedReg(preg), Requirement::Register) => {
7674
Ok(Requirement::FixedReg(preg))
7775
}
78-
(Requirement::Stack, Requirement::FixedStack(preg))
79-
| (Requirement::FixedStack(preg), Requirement::Stack) => {
80-
Ok(Requirement::FixedStack(preg))
81-
}
8276
(Requirement::FixedReg(a), Requirement::FixedReg(b)) if a == b => Ok(self),
8377
(Requirement::FixedStack(a), Requirement::FixedStack(b)) if a == b => Ok(self),
8478
_ => Err(RequirementConflict),
@@ -88,7 +82,7 @@ impl Requirement {
8882
#[inline(always)]
8983
pub fn is_stack(self) -> bool {
9084
match self {
91-
Requirement::Stack | Requirement::FixedStack(..) => true,
85+
Requirement::FixedStack(..) => true,
9286
Requirement::Register | Requirement::FixedReg(..) => false,
9387
Requirement::Any => false,
9488
}
@@ -98,7 +92,7 @@ impl Requirement {
9892
pub fn is_reg(self) -> bool {
9993
match self {
10094
Requirement::Register | Requirement::FixedReg(..) => true,
101-
Requirement::Stack | Requirement::FixedStack(..) => false,
95+
Requirement::FixedStack(..) => false,
10296
Requirement::Any => false,
10397
}
10498
}
@@ -116,7 +110,6 @@ impl<'a, F: Function> Env<'a, F> {
116110
}
117111
}
118112
OperandConstraint::Reg | OperandConstraint::Reuse(_) => Requirement::Register,
119-
OperandConstraint::Stack => Requirement::Stack,
120113
OperandConstraint::Any => Requirement::Any,
121114
}
122115
}

src/lib.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,6 @@ pub enum OperandConstraint {
447447
Any,
448448
/// Operand must be in a register. Register is read-only for Uses.
449449
Reg,
450-
/// Operand must be on the stack.
451-
Stack,
452450
/// Operand must be in a fixed register.
453451
FixedReg(PReg),
454452
/// On defs only: reuse a use's register.
@@ -460,7 +458,6 @@ impl core::fmt::Display for OperandConstraint {
460458
match self {
461459
Self::Any => write!(f, "any"),
462460
Self::Reg => write!(f, "reg"),
463-
Self::Stack => write!(f, "stack"),
464461
Self::FixedReg(preg) => write!(f, "fixed({})", preg),
465462
Self::Reuse(idx) => write!(f, "reuse({})", idx),
466463
}
@@ -556,7 +553,6 @@ impl Operand {
556553
let constraint_field = match constraint {
557554
OperandConstraint::Any => 0,
558555
OperandConstraint::Reg => 1,
559-
OperandConstraint::Stack => 2,
560556
OperandConstraint::FixedReg(preg) => {
561557
debug_assert_eq!(preg.class(), vreg.class());
562558
0b1000000 | preg.hw_enc() as u32
@@ -829,7 +825,6 @@ impl Operand {
829825
match constraint_field {
830826
0 => OperandConstraint::Any,
831827
1 => OperandConstraint::Reg,
832-
2 => OperandConstraint::Stack,
833828
_ => unreachable!(),
834829
}
835830
}

0 commit comments

Comments
 (0)