From 59f5f12c60b070445bb31c7fb79867ea13ea3783 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Thu, 12 Sep 2019 14:23:12 +0200 Subject: [PATCH] [codegen] Rename GenLiveRange to GenericLiveRange; (to avoid confuson with Gen interpreted as Generator) --- cranelift/codegen/src/ir/layout.rs | 2 +- cranelift/codegen/src/regalloc/liverange.rs | 32 ++++++++++++--------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/cranelift/codegen/src/ir/layout.rs b/cranelift/codegen/src/ir/layout.rs index 78a4628576..632c03dc59 100644 --- a/cranelift/codegen/src/ir/layout.rs +++ b/cranelift/codegen/src/ir/layout.rs @@ -698,7 +698,7 @@ impl Layout { #[derive(Clone, Debug, Default)] struct InstNode { - // The Ebb containing this instruction, or `None` if the instruction is not yet inserted. + /// The Ebb containing this instruction, or `None` if the instruction is not yet inserted. ebb: PackedOption, prev: PackedOption, next: PackedOption, diff --git a/cranelift/codegen/src/regalloc/liverange.rs b/cranelift/codegen/src/regalloc/liverange.rs index b0d3c6fed6..49d7f23cb2 100644 --- a/cranelift/codegen/src/regalloc/liverange.rs +++ b/cranelift/codegen/src/regalloc/liverange.rs @@ -142,13 +142,13 @@ use core::marker::PhantomData; /// Inserting new instructions in the layout is safe, but removing instructions is not. Besides the /// instructions using or defining their value, `LiveRange` structs can contain references to /// branch and jump instructions. -pub type LiveRange = GenLiveRange; +pub type LiveRange = GenericLiveRange; /// Generic live range implementation. /// /// The intended generic parameter is `PO=Layout`, but tests are simpler with a mock order. /// Use `LiveRange` instead of using this generic directly. -pub struct GenLiveRange { +pub struct GenericLiveRange { /// The value described by this live range. /// This member can't be modified in case the live range is stored in a `SparseMap`. value: Value, @@ -216,7 +216,7 @@ impl<'a, PO: ProgramOrder> bforest::Comparator for Cmp<'a, PO> { } } -impl GenLiveRange { +impl GenericLiveRange { /// Create a new live range for `value` defined at `def`. /// /// The live range will be created as dead, but it can be extended with `extend_in_ebb()`. @@ -307,7 +307,7 @@ impl GenLiveRange { c.insert(ebb, to); } - // Now `c` to left pointing at an interval that ends in `to`. + // Now `c` is left pointing at an interval that ends in `to`. debug_assert_eq!(c.value(), Some(to)); // See if it can be coalesced with the following interval. @@ -449,7 +449,7 @@ impl GenLiveRange { } /// Allow a `LiveRange` to be stored in a `SparseMap` indexed by values. -impl SparseMapValue for GenLiveRange { +impl SparseMapValue for GenericLiveRange { fn key(&self) -> Value { self.value } @@ -457,7 +457,7 @@ impl SparseMapValue for GenLiveRange { #[cfg(test)] mod tests { - use super::{GenLiveRange, LiveRangeContext}; + use super::{GenericLiveRange, LiveRangeContext}; use crate::bforest; use crate::entity::EntityRef; use crate::ir::{Ebb, Inst, Value}; @@ -510,7 +510,11 @@ mod tests { } // Validate the live range invariants. - fn validate(&self, lr: &GenLiveRange, forest: &bforest::MapForest) { + fn validate( + &self, + lr: &GenericLiveRange, + forest: &bforest::MapForest, + ) { // The def interval must cover a single EBB. let def_ebb = self.pp_ebb(lr.def_begin); assert_eq!(def_ebb, self.pp_ebb(lr.def_end)); @@ -554,7 +558,7 @@ mod tests { let i1 = Inst::new(1); let i2 = Inst::new(2); let e2 = Ebb::new(2); - let lr = GenLiveRange::new(v0, i1.into(), Default::default()); + let lr = GenericLiveRange::new(v0, i1.into(), Default::default()); let forest = &bforest::MapForest::new(); let ctx = LiveRangeContext::new(PO, forest); assert!(lr.is_dead()); @@ -574,7 +578,7 @@ mod tests { fn dead_arg_range() { let v0 = Value::new(0); let e2 = Ebb::new(2); - let lr = GenLiveRange::new(v0, e2.into(), Default::default()); + let lr = GenericLiveRange::new(v0, e2.into(), Default::default()); let forest = &bforest::MapForest::new(); let ctx = LiveRangeContext::new(PO, forest); assert!(lr.is_dead()); @@ -593,7 +597,7 @@ mod tests { let i11 = Inst::new(11); let i12 = Inst::new(12); let i13 = Inst::new(13); - let mut lr = GenLiveRange::new(v0, i11.into(), Default::default()); + let mut lr = GenericLiveRange::new(v0, i11.into(), Default::default()); let forest = &mut bforest::MapForest::new(); assert_eq!(lr.extend_in_ebb(e10, i13, PO, forest), false); @@ -617,7 +621,7 @@ mod tests { let i11 = Inst::new(11); let i12 = Inst::new(12); let i13 = Inst::new(13); - let mut lr = GenLiveRange::new(v0, e10.into(), Default::default()); + let mut lr = GenericLiveRange::new(v0, e10.into(), Default::default()); let forest = &mut bforest::MapForest::new(); // Extending a dead EBB argument in its own block should not indicate that a live-in @@ -652,7 +656,7 @@ mod tests { let i21 = Inst::new(21); let i22 = Inst::new(22); let i23 = Inst::new(23); - let mut lr = GenLiveRange::new(v0, i11.into(), Default::default()); + let mut lr = GenericLiveRange::new(v0, i11.into(), Default::default()); let forest = &mut bforest::MapForest::new(); assert_eq!(lr.extend_in_ebb(e10, i12, PO, forest), false); @@ -691,7 +695,7 @@ mod tests { let i31 = Inst::new(31); let e40 = Ebb::new(40); let i41 = Inst::new(41); - let mut lr = GenLiveRange::new(v0, i11.into(), Default::default()); + let mut lr = GenericLiveRange::new(v0, i11.into(), Default::default()); let forest = &mut bforest::MapForest::new(); assert_eq!(lr.extend_in_ebb(e30, i31, PO, forest), true); @@ -717,7 +721,7 @@ mod tests { [(e20, i41)] ); - let mut lr = GenLiveRange::new(v0, i11.into(), Default::default()); + let mut lr = GenericLiveRange::new(v0, i11.into(), Default::default()); assert_eq!(lr.extend_in_ebb(e40, i41, PO, forest), true); assert_eq!(