Skip to content

Commit 0edb11d

Browse files
authored
Remove mod operands. (#109)
* Remove Mod operands. * Typo fix.
1 parent e09f651 commit 0edb11d

File tree

4 files changed

+19
-34
lines changed

4 files changed

+19
-34
lines changed

src/ion/liveranges.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ impl<'a, F: Function> Env<'a, F> {
373373
let was_live = live.get(op.vreg().vreg());
374374
trace!("op {:?} was_live = {}", op, was_live);
375375
match op.kind() {
376-
OperandKind::Use | OperandKind::Mod => {
376+
OperandKind::Use => {
377377
live.set(op.vreg().vreg(), true);
378378
}
379379
OperandKind::Def => {
@@ -776,7 +776,6 @@ impl<'a, F: Function> Env<'a, F> {
776776
.cloned()
777777
.unwrap_or(self.func.inst_operands(inst)[i]);
778778
let pos = match (operand.kind(), operand.pos()) {
779-
(OperandKind::Mod, _) => ProgPoint::before(inst),
780779
(OperandKind::Def, OperandPos::Early) => ProgPoint::before(inst),
781780
(OperandKind::Def, OperandPos::Late) => ProgPoint::after(inst),
782781
(OperandKind::Use, OperandPos::Late) => ProgPoint::after(inst),
@@ -817,19 +816,15 @@ impl<'a, F: Function> Env<'a, F> {
817816
}
818817

819818
match operand.kind() {
820-
OperandKind::Def | OperandKind::Mod => {
819+
OperandKind::Def => {
821820
trace!("Def of {} at {:?}", operand.vreg(), pos);
822821

823822
// Get or create the LiveRange.
824823
let mut lr = vreg_ranges[operand.vreg().vreg()];
825824
trace!(" -> has existing LR {:?}", lr);
826825
// If there was no liverange (dead def), create a trivial one.
827826
if !live.get(operand.vreg().vreg()) {
828-
let from = match operand.kind() {
829-
OperandKind::Def => pos,
830-
OperandKind::Mod => self.cfginfo.block_entry[block.index()],
831-
_ => unreachable!(),
832-
};
827+
let from = pos;
833828
// We want to we want to span
834829
// until Before of the next
835830
// inst. This ensures that early

src/ion/moves.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ impl<'a, F: Function> Env<'a, F> {
906906
let inst = Inst::new(inst);
907907
for (i, op) in this.func.inst_operands(inst).iter().enumerate() {
908908
match op.kind() {
909-
OperandKind::Def | OperandKind::Mod => {
909+
OperandKind::Def => {
910910
let alloc = this.get_alloc(inst, i);
911911
redundant_moves.clear_alloc(alloc);
912912
}

src/lib.rs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -426,14 +426,13 @@ impl std::fmt::Display for OperandConstraint {
426426
}
427427
}
428428

429-
/// The "kind" of the operand: whether it reads a vreg (Use), writes a
430-
/// vreg (Def), or reads and then writes (Mod, for "modify").
429+
/// The "kind" of the operand: whether it reads a vreg (Use) or writes
430+
/// a vreg (Def).
431431
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
432432
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
433433
pub enum OperandKind {
434434
Def = 0,
435-
Mod = 1,
436-
Use = 2,
435+
Use = 1,
437436
}
438437

439438
/// The "position" of the operand: where it has its read/write
@@ -488,7 +487,7 @@ pub enum OperandPos {
488487
pub struct Operand {
489488
/// Bit-pack into 32 bits.
490489
///
491-
/// constraint:7 kind:2 pos:1 class:1 vreg:21
490+
/// constraint:7 kind:1 pos:1 class:2 vreg:21
492491
///
493492
/// where `constraint` is an `OperandConstraint`, `kind` is an
494493
/// `OperandKind`, `pos` is an `OperandPos`, `class` is a
@@ -532,8 +531,8 @@ impl Operand {
532531
Operand {
533532
bits: vreg.vreg() as u32
534533
| (class_field << 21)
535-
| (pos_field << 22)
536-
| (kind_field << 23)
534+
| (pos_field << 23)
535+
| (kind_field << 24)
537536
| (constraint_field << 25),
538537
}
539538
}
@@ -719,23 +718,22 @@ impl Operand {
719718
/// Get the register class used by this operand.
720719
#[inline(always)]
721720
pub fn class(self) -> RegClass {
722-
let class_field = (self.bits >> 21) & 1;
721+
let class_field = (self.bits >> 21) & 3;
723722
match class_field {
724723
0 => RegClass::Int,
725724
1 => RegClass::Float,
726725
_ => unreachable!(),
727726
}
728727
}
729728

730-
/// Get the "kind" of this operand: a definition (write), a use
731-
/// (read), or a "mod" / modify (a read followed by a write).
729+
/// Get the "kind" of this operand: a definition (write) or a use
730+
/// (read).
732731
#[inline(always)]
733732
pub fn kind(self) -> OperandKind {
734-
let kind_field = (self.bits >> 23) & 3;
733+
let kind_field = (self.bits >> 24) & 1;
735734
match kind_field {
736735
0 => OperandKind::Def,
737-
1 => OperandKind::Mod,
738-
2 => OperandKind::Use,
736+
1 => OperandKind::Use,
739737
_ => unreachable!(),
740738
}
741739
}
@@ -746,7 +744,7 @@ impl Operand {
746744
/// at "after", though there are cases where this is not true.
747745
#[inline(always)]
748746
pub fn pos(self) -> OperandPos {
749-
let pos_field = (self.bits >> 22) & 1;
747+
let pos_field = (self.bits >> 23) & 1;
750748
match pos_field {
751749
0 => OperandPos::Early,
752750
1 => OperandPos::Late,
@@ -808,8 +806,7 @@ impl std::fmt::Debug for Operand {
808806
impl std::fmt::Display for Operand {
809807
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
810808
match (self.kind(), self.pos()) {
811-
(OperandKind::Def, OperandPos::Late)
812-
| (OperandKind::Mod | OperandKind::Use, OperandPos::Early) => {
809+
(OperandKind::Def, OperandPos::Late) | (OperandKind::Use, OperandPos::Early) => {
813810
write!(f, "{:?}", self.kind())?;
814811
}
815812
_ => {
@@ -1058,8 +1055,8 @@ pub trait Function {
10581055
/// it in a given PReg chosen by the client prior to regalloc.
10591056
///
10601057
/// Every register written by an instruction must either
1061-
/// correspond to (be assigned to) an Operand of kind `Def` or
1062-
/// `Mod`, or else must be a "clobber".
1058+
/// correspond to (be assigned to) an Operand of kind `Def`, or
1059+
/// else must be a "clobber".
10631060
///
10641061
/// This can be used to, for example, describe ABI-specified
10651062
/// registers that are not preserved by a call instruction, or

src/ssa.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,6 @@ pub fn validate_ssa<F: Function>(f: &F, cfginfo: &CFGInfo) -> Result<(), RegAllo
7373
// Check all the uses in this instruction
7474
// first, before recording its defs below.
7575
}
76-
OperandKind::Mod => {
77-
// Mod (modify) operands are not used in SSA,
78-
// but can be used by non-SSA code (e.g. with
79-
// the regalloc.rs compatibility shim).
80-
trace!("Unexpected mod {:?}", operand.vreg());
81-
return Err(RegAllocError::SSA(operand.vreg(), iix));
82-
}
8376
}
8477
}
8578

0 commit comments

Comments
 (0)