diff --git a/lib/codegen/src/dominator_tree.rs b/lib/codegen/src/dominator_tree.rs index a246f671bc..2198fbf2bf 100644 --- a/lib/codegen/src/dominator_tree.rs +++ b/lib/codegen/src/dominator_tree.rs @@ -1,6 +1,6 @@ //! A Dominator Tree represented as mappings of Ebbs to their immediate dominator. -use entity::EntityMap; +use entity::SecondaryMap; use flowgraph::{BasicBlock, ControlFlowGraph}; use ir::instructions::BranchInfo; use ir::{Ebb, ExpandedProgramPoint, Function, Inst, Layout, ProgramOrder, Value}; @@ -38,7 +38,7 @@ struct DomNode { /// The dominator tree for a single function. pub struct DominatorTree { - nodes: EntityMap, + nodes: SecondaryMap, /// CFG post-order of all reachable EBBs. postorder: Vec, @@ -217,7 +217,7 @@ impl DominatorTree { /// function. pub fn new() -> Self { Self { - nodes: EntityMap::new(), + nodes: SecondaryMap::new(), postorder: Vec::new(), stack: Vec::new(), valid: false, @@ -505,7 +505,7 @@ impl DominatorTree { /// The information in this auxillary data structure is not easy to update when the control flow /// graph changes, which is why it is kept separate. pub struct DominatorTreePreorder { - nodes: EntityMap, + nodes: SecondaryMap, // Scratch memory used by `compute_postorder()`. stack: Vec, @@ -533,7 +533,7 @@ impl DominatorTreePreorder { /// Create a new blank `DominatorTreePreorder`. pub fn new() -> Self { Self { - nodes: EntityMap::new(), + nodes: SecondaryMap::new(), stack: Vec::new(), } } diff --git a/lib/codegen/src/flowgraph.rs b/lib/codegen/src/flowgraph.rs index b84da7cd0b..97c3f932f5 100644 --- a/lib/codegen/src/flowgraph.rs +++ b/lib/codegen/src/flowgraph.rs @@ -24,7 +24,7 @@ //! and `(Ebb0, jmp Ebb2)` respectively. use bforest; -use entity::EntityMap; +use entity::SecondaryMap; use ir::instructions::BranchInfo; use ir::{Ebb, Function, Inst}; use std::mem; @@ -72,7 +72,7 @@ struct CFGNode { /// and successors where predecessors are basic blocks and successors are /// extended basic blocks. pub struct ControlFlowGraph { - data: EntityMap, + data: SecondaryMap, pred_forest: bforest::MapForest, succ_forest: bforest::SetForest, valid: bool, @@ -82,7 +82,7 @@ impl ControlFlowGraph { /// Allocate a new blank control flow graph. pub fn new() -> Self { Self { - data: EntityMap::new(), + data: SecondaryMap::new(), valid: false, pred_forest: bforest::MapForest::new(), succ_forest: bforest::SetForest::new(), diff --git a/lib/codegen/src/ir/dfg.rs b/lib/codegen/src/ir/dfg.rs index bb8ddbe9c4..7bcf17e949 100644 --- a/lib/codegen/src/ir/dfg.rs +++ b/lib/codegen/src/ir/dfg.rs @@ -1,6 +1,6 @@ //! Data flow graph tracking Instructions, Values, and EBBs. -use entity::{self, EntityMap, PrimaryMap}; +use entity::{self, PrimaryMap, SecondaryMap}; use ir; use ir::builder::ReplaceBuilder; use ir::extfunc::ExtFuncData; @@ -34,7 +34,7 @@ pub struct DataFlowGraph { /// /// This map gets resized automatically by `make_inst()` so it is always in sync with the /// primary `insts` map. - results: EntityMap, + results: SecondaryMap, /// Extended basic blocks in the function and their parameters. /// @@ -67,7 +67,7 @@ impl DataFlowGraph { pub fn new() -> Self { Self { insts: PrimaryMap::new(), - results: EntityMap::new(), + results: SecondaryMap::new(), ebbs: PrimaryMap::new(), value_lists: ValueListPool::new(), values: PrimaryMap::new(), @@ -90,7 +90,7 @@ impl DataFlowGraph { /// Get the total number of instructions created in this function, whether they are currently /// inserted in the layout or not. /// - /// This is intended for use with `EntityMap::with_capacity`. + /// This is intended for use with `SecondaryMap::with_capacity`. pub fn num_insts(&self) -> usize { self.insts.len() } @@ -103,7 +103,7 @@ impl DataFlowGraph { /// Get the total number of extended basic blocks created in this function, whether they are /// currently inserted in the layout or not. /// - /// This is intended for use with `EntityMap::with_capacity`. + /// This is intended for use with `SecondaryMap::with_capacity`. pub fn num_ebbs(&self) -> usize { self.ebbs.len() } diff --git a/lib/codegen/src/ir/function.rs b/lib/codegen/src/ir/function.rs index cf9cbdbe29..d15de64c3a 100644 --- a/lib/codegen/src/ir/function.rs +++ b/lib/codegen/src/ir/function.rs @@ -4,7 +4,7 @@ //! instructions. use binemit::CodeOffset; -use entity::{EntityMap, PrimaryMap}; +use entity::{PrimaryMap, SecondaryMap}; use ir; use ir::{DataFlowGraph, ExternalName, Layout, Signature}; use ir::{ @@ -84,10 +84,10 @@ impl Function { jump_tables: PrimaryMap::new(), dfg: DataFlowGraph::new(), layout: Layout::new(), - encodings: EntityMap::new(), - locations: EntityMap::new(), - offsets: EntityMap::new(), - srclocs: EntityMap::new(), + encodings: SecondaryMap::new(), + locations: SecondaryMap::new(), + offsets: SecondaryMap::new(), + srclocs: SecondaryMap::new(), } } diff --git a/lib/codegen/src/ir/layout.rs b/lib/codegen/src/ir/layout.rs index a9dc08d786..a251822847 100644 --- a/lib/codegen/src/ir/layout.rs +++ b/lib/codegen/src/ir/layout.rs @@ -3,7 +3,7 @@ //! The order of extended basic blocks in a function and the order of instructions in an EBB is //! determined by the `Layout` data structure defined in this module. -use entity::EntityMap; +use entity::SecondaryMap; use ir::progpoint::{ExpandedProgramPoint, ProgramOrder}; use ir::{Ebb, Inst}; use packed_option::PackedOption; @@ -28,11 +28,11 @@ use timing; pub struct Layout { /// Linked list nodes for the layout order of EBBs Forms a doubly linked list, terminated in /// both ends by `None`. - ebbs: EntityMap, + ebbs: SecondaryMap, /// Linked list nodes for the layout order of instructions. Forms a double linked list per EBB, /// terminated in both ends by `None`. - insts: EntityMap, + insts: SecondaryMap, /// First EBB in the layout order, or `None` when no EBBs have been laid out. first_ebb: Option, @@ -45,8 +45,8 @@ impl Layout { /// Create a new empty `Layout`. pub fn new() -> Self { Self { - ebbs: EntityMap::new(), - insts: EntityMap::new(), + ebbs: SecondaryMap::new(), + insts: SecondaryMap::new(), first_ebb: None, last_ebb: None, } diff --git a/lib/codegen/src/ir/mod.rs b/lib/codegen/src/ir/mod.rs index 5421911886..a9c035703e 100644 --- a/lib/codegen/src/ir/mod.rs +++ b/lib/codegen/src/ir/mod.rs @@ -47,20 +47,20 @@ pub use ir::types::Type; pub use ir::valueloc::{ArgumentLoc, ValueLoc}; use binemit; -use entity::{EntityMap, PrimaryMap}; +use entity::{PrimaryMap, SecondaryMap}; use isa; /// Map of value locations. -pub type ValueLocations = EntityMap; +pub type ValueLocations = SecondaryMap; /// Map of jump tables. pub type JumpTables = PrimaryMap; /// Map of instruction encodings. -pub type InstEncodings = EntityMap; +pub type InstEncodings = SecondaryMap; /// Code offsets for EBBs. -pub type EbbOffsets = EntityMap; +pub type EbbOffsets = SecondaryMap; /// Source locations for instructions. -pub type SourceLocs = EntityMap; +pub type SourceLocs = SecondaryMap; diff --git a/lib/codegen/src/loop_analysis.rs b/lib/codegen/src/loop_analysis.rs index fc1591b0cf..ded382f3f7 100644 --- a/lib/codegen/src/loop_analysis.rs +++ b/lib/codegen/src/loop_analysis.rs @@ -2,7 +2,7 @@ //! and parent in the loop tree. use dominator_tree::DominatorTree; -use entity::EntityMap; +use entity::SecondaryMap; use entity::{Keys, PrimaryMap}; use flowgraph::{BasicBlock, ControlFlowGraph}; use ir::{Ebb, Function, Layout}; @@ -21,7 +21,7 @@ entity_impl!(Loop, "loop"); /// its eventual parent in the loop tree and all the EBB belonging to the loop. pub struct LoopAnalysis { loops: PrimaryMap, - ebb_loop_map: EntityMap>, + ebb_loop_map: SecondaryMap>, valid: bool, } @@ -48,7 +48,7 @@ impl LoopAnalysis { Self { valid: false, loops: PrimaryMap::new(), - ebb_loop_map: EntityMap::new(), + ebb_loop_map: SecondaryMap::new(), } } diff --git a/lib/codegen/src/print_errors.rs b/lib/codegen/src/print_errors.rs index db557c865e..217d09f902 100644 --- a/lib/codegen/src/print_errors.rs +++ b/lib/codegen/src/print_errors.rs @@ -1,6 +1,6 @@ //! Utility routines for pretty-printing error messages. -use entity::EntityMap; +use entity::SecondaryMap; use ir; use ir::entities::{AnyEntity, Inst, Value}; use ir::function::Function; @@ -40,7 +40,7 @@ impl<'a> FuncWriter for PrettyVerifierError<'a> { &mut self, w: &mut Write, func: &Function, - aliases: &EntityMap>, + aliases: &SecondaryMap>, isa: Option<&TargetIsa>, inst: Inst, indent: usize, @@ -63,7 +63,7 @@ impl<'a> FuncWriter for PrettyVerifierError<'a> { fn pretty_instruction_error( w: &mut Write, func: &Function, - aliases: &EntityMap>, + aliases: &SecondaryMap>, isa: Option<&TargetIsa>, cur_inst: Inst, indent: usize, diff --git a/lib/codegen/src/regalloc/virtregs.rs b/lib/codegen/src/regalloc/virtregs.rs index 0e4bcdf5d0..7d2b87153b 100644 --- a/lib/codegen/src/regalloc/virtregs.rs +++ b/lib/codegen/src/regalloc/virtregs.rs @@ -15,7 +15,7 @@ use dbg::DisplayList; use dominator_tree::DominatorTreePreorder; use entity::EntityRef; use entity::{EntityList, ListPool}; -use entity::{EntityMap, Keys, PrimaryMap}; +use entity::{Keys, PrimaryMap, SecondaryMap}; use ir::{Function, Value}; use packed_option::PackedOption; use ref_slice::ref_slice; @@ -45,10 +45,10 @@ pub struct VirtRegs { unused_vregs: Vec, /// Each value belongs to at most one virtual register. - value_vregs: EntityMap>, + value_vregs: SecondaryMap>, /// Table used during the union-find phase while `vregs` is empty. - union_find: EntityMap, + union_find: SecondaryMap, /// Values that have been activated in the `union_find` table, but not yet added to any virtual /// registers by the `finish_union_find()` function. @@ -62,8 +62,8 @@ impl VirtRegs { pool: ListPool::new(), vregs: PrimaryMap::new(), unused_vregs: Vec::new(), - value_vregs: EntityMap::new(), - union_find: EntityMap::new(), + value_vregs: SecondaryMap::new(), + union_find: SecondaryMap::new(), pending_values: Vec::new(), } } diff --git a/lib/codegen/src/verifier/flags.rs b/lib/codegen/src/verifier/flags.rs index d3fda7555f..cf9c924244 100644 --- a/lib/codegen/src/verifier/flags.rs +++ b/lib/codegen/src/verifier/flags.rs @@ -1,6 +1,6 @@ //! Verify CPU flags values. -use entity::{EntityMap, SparseSet}; +use entity::{SecondaryMap, SparseSet}; use flowgraph::{BasicBlock, ControlFlowGraph}; use ir; use ir::instructions::BranchInfo; @@ -32,7 +32,7 @@ pub fn verify_flags( func, cfg, encinfo: isa.map(|isa| isa.encoding_info()), - livein: EntityMap::new(), + livein: SecondaryMap::new(), }; verifier.check(errors) } @@ -43,7 +43,7 @@ struct FlagsVerifier<'a> { encinfo: Option, /// The single live-in flags value (if any) for each EBB. - livein: EntityMap>, + livein: SecondaryMap>, } impl<'a> FlagsVerifier<'a> { diff --git a/lib/codegen/src/write.rs b/lib/codegen/src/write.rs index 0c3b7cbae9..743540bf67 100644 --- a/lib/codegen/src/write.rs +++ b/lib/codegen/src/write.rs @@ -3,7 +3,7 @@ //! The `write` module provides the `write_function` function which converts an IR `Function` to an //! equivalent textual form. This textual form can be read back by the `cranelift-reader` crate. -use entity::EntityMap; +use entity::SecondaryMap; use ir::entities::AnyEntity; use ir::{DataFlowGraph, Ebb, Function, Inst, SigRef, Type, Value, ValueDef}; use isa::{RegInfo, TargetIsa}; @@ -19,7 +19,7 @@ pub trait FuncWriter { &mut self, w: &mut Write, func: &Function, - aliases: &EntityMap>, + aliases: &SecondaryMap>, isa: Option<&TargetIsa>, inst: Inst, ident: usize, @@ -101,7 +101,7 @@ impl FuncWriter for PlainWriter { &mut self, w: &mut Write, func: &Function, - aliases: &EntityMap>, + aliases: &SecondaryMap>, isa: Option<&TargetIsa>, inst: Inst, indent: usize, @@ -117,8 +117,8 @@ pub fn write_function(w: &mut Write, func: &Function, isa: Option<&TargetIsa>) - } /// Create a reverse-alias map from a value to all aliases having that value as a direct target -fn alias_map(func: &Function) -> EntityMap> { - let mut aliases = EntityMap::<_, Vec<_>>::new(); +fn alias_map(func: &Function) -> SecondaryMap> { + let mut aliases = SecondaryMap::<_, Vec<_>>::new(); for v in func.dfg.values() { // VADFS returns the immediate target of an alias if let Some(k) = func.dfg.value_alias_dest_for_serialization(v) { @@ -216,7 +216,7 @@ fn decorate_ebb( func_w: &mut FW, w: &mut Write, func: &Function, - aliases: &EntityMap>, + aliases: &SecondaryMap>, isa: Option<&TargetIsa>, ebb: Ebb, ) -> fmt::Result { @@ -279,7 +279,7 @@ fn type_suffix(func: &Function, inst: Inst) -> Option { /// Write out any aliases to the given target, including indirect aliases fn write_value_aliases( w: &mut Write, - aliases: &EntityMap>, + aliases: &SecondaryMap>, target: Value, indent: usize, ) -> fmt::Result { @@ -293,7 +293,7 @@ fn write_value_aliases( fn write_instruction( w: &mut Write, func: &Function, - aliases: &EntityMap>, + aliases: &SecondaryMap>, isa: Option<&TargetIsa>, inst: Inst, indent: usize, diff --git a/lib/entity/README.md b/lib/entity/README.md index 2b9ff7e042..f840b142e6 100644 --- a/lib/entity/README.md +++ b/lib/entity/README.md @@ -17,11 +17,11 @@ easy to declare new unique types for use as keys. Any attempt to use a key in a map it's not intended for is diagnosed with a type error. Another is that this crate has two core map types, `PrimaryMap` and -`EntityMap`, which serve complementary purposes. A `PrimaryMap` creates its -own keys when elements are inserted, while an `EntityMap` reuses the keys +`SecondaryMap`, which serve complementary purposes. A `PrimaryMap` creates its +own keys when elements are inserted, while an `SecondaryMap` reuses the keys values of a `PrimaryMap`, conceptually storing additional data in the same -index space. `EntityMap`'s values must implement `Default` and all elements -in an `EntityMap` initially have the value of `default()`. +index space. `SecondaryMap`'s values must implement `Default` and all elements +in an `SecondaryMap` initially have the value of `default()`. A common way to implement `Default` is to wrap a type in `Option`, however this crate also provides the `PackedOption` utility which can use less memory @@ -30,9 +30,9 @@ in some cases. Additional utilities provided by this crate include: - `EntityList`, for allocating many small arrays (such as instruction operand lists in a compiler code generator). - - `SparseMap`: an alternative to `EntityMap` which can use less memory + - `SparseMap`: an alternative to `SecondaryMap` which can use less memory in some situations. - - `EntitySet`: a specialized form of `EntityMap` using a bitvector to + - `EntitySet`: a specialized form of `SecondaryMap` using a bitvector to record which entities are members of the set. [slotmap]: https://crates.io/crates/slotmap diff --git a/lib/entity/src/lib.rs b/lib/entity/src/lib.rs index a1d07db442..d8e4fcac18 100644 --- a/lib/entity/src/lib.rs +++ b/lib/entity/src/lib.rs @@ -15,7 +15,7 @@ //! //! - [`PrimaryMap`](struct.PrimaryMap.html) is used to keep track of a vector of entities, //! assigning a unique entity reference to each. -//! - [`EntityMap`](struct.EntityMap.html) is used to associate secondary information to an entity. +//! - [`SecondaryMap`](struct.SecondaryMap.html) is used to associate secondary information to an entity. //! The map is implemented as a simple vector, so it does not keep track of which entities have //! been inserted. Instead, any unknown entities map to the default value. //! - [`SparseMap`](struct.SparseMap.html) is used to associate secondary information to a small @@ -70,7 +70,7 @@ mod std { pub extern crate core as __core; /// A type wrapping a small integer index should implement `EntityRef` so it can be used as the key -/// of an `EntityMap` or `SparseMap`. +/// of an `SecondaryMap` or `SparseMap`. pub trait EntityRef: Copy + Eq { /// Create a new entity reference from a small integer. /// This should crash if the requested index is not representable. @@ -135,7 +135,7 @@ mod sparse; pub use self::iter::{Iter, IterMut}; pub use self::keys::Keys; pub use self::list::{EntityList, ListPool}; -pub use self::map::EntityMap; +pub use self::map::SecondaryMap; pub use self::primary::PrimaryMap; pub use self::set::EntitySet; pub use self::sparse::{SparseMap, SparseMapValue, SparseSet}; diff --git a/lib/entity/src/map.rs b/lib/entity/src/map.rs index 285e61e4c6..87a478e570 100644 --- a/lib/entity/src/map.rs +++ b/lib/entity/src/map.rs @@ -8,14 +8,14 @@ use {EntityRef, Iter, IterMut, Keys}; /// A mapping `K -> V` for densely indexed entity references. /// -/// The `EntityMap` data structure uses the dense index space to implement a map with a vector. -/// Unlike `PrimaryMap`, an `EntityMap` can't be used to allocate entity references. It is used to +/// The `SecondaryMap` data structure uses the dense index space to implement a map with a vector. +/// Unlike `PrimaryMap`, an `SecondaryMap` can't be used to allocate entity references. It is used to /// associate secondary information with entities. /// /// The map does not track if an entry for a key has been inserted or not. Instead it behaves as if /// all keys have a default entry from the beginning. #[derive(Debug, Clone)] -pub struct EntityMap +pub struct SecondaryMap where K: EntityRef, V: Clone, @@ -25,8 +25,8 @@ where unused: PhantomData, } -/// Shared `EntityMap` implementation for all value types. -impl EntityMap +/// Shared `SecondaryMap` implementation for all value types. +impl SecondaryMap where K: EntityRef, V: Clone, @@ -100,10 +100,10 @@ where } } -/// Immutable indexing into an `EntityMap`. +/// Immutable indexing into an `SecondaryMap`. /// /// All keys are permitted. Untouched entries have the default value. -impl Index for EntityMap +impl Index for SecondaryMap where K: EntityRef, V: Clone, @@ -115,10 +115,10 @@ where } } -/// Mutable indexing into an `EntityMap`. +/// Mutable indexing into an `SecondaryMap`. /// /// The map grows as needed to accommodate new keys. -impl IndexMut for EntityMap +impl IndexMut for SecondaryMap where K: EntityRef, V: Clone, @@ -154,7 +154,7 @@ mod tests { let r0 = E(0); let r1 = E(1); let r2 = E(2); - let mut m = EntityMap::new(); + let mut m = SecondaryMap::new(); let v: Vec = m.keys().collect(); assert_eq!(v, []); diff --git a/lib/entity/src/set.rs b/lib/entity/src/set.rs index 7644db49ad..4f7b631c93 100644 --- a/lib/entity/src/set.rs +++ b/lib/entity/src/set.rs @@ -7,7 +7,7 @@ use {EntityRef, Keys}; /// A set of `K` for densely indexed entity references. /// /// The `EntitySet` data structure uses the dense index space to implement a set with a bitvector. -/// Like `EntityMap`, an `EntitySet` is used to associate secondary information with entities. +/// Like `SecondaryMap`, an `EntitySet` is used to associate secondary information with entities. #[derive(Debug, Clone)] pub struct EntitySet where diff --git a/lib/entity/src/sparse.rs b/lib/entity/src/sparse.rs index 28cbd80ad8..1a6de3e39d 100644 --- a/lib/entity/src/sparse.rs +++ b/lib/entity/src/sparse.rs @@ -11,7 +11,7 @@ use std::mem; use std::slice; use std::u32; use std::vec::Vec; -use {EntityMap, EntityRef}; +use {EntityRef, SecondaryMap}; /// Trait for extracting keys from values stored in a `SparseMap`. /// @@ -27,16 +27,16 @@ pub trait SparseMapValue { /// /// A `SparseMap` map provides: /// -/// - Memory usage equivalent to `EntityMap` + `Vec`, so much smaller than -/// `EntityMap` for sparse mappings of larger `V` types. -/// - Constant time lookup, slightly slower than `EntityMap`. +/// - Memory usage equivalent to `SecondaryMap` + `Vec`, so much smaller than +/// `SecondaryMap` for sparse mappings of larger `V` types. +/// - Constant time lookup, slightly slower than `SecondaryMap`. /// - A very fast, constant time `clear()` operation. /// - Fast insert and erase operations. /// - Stable iteration that is as fast as a `Vec`. /// -/// # Compared to `EntityMap` +/// # Compared to `SecondaryMap` /// -/// When should we use a `SparseMap` instead of a secondary `EntityMap`? First of all, `SparseMap` +/// When should we use a `SparseMap` instead of a secondary `SecondaryMap`? First of all, `SparseMap` /// does not provide the functionality of a `PrimaryMap` which can allocate and assign entity /// references to objects as they are pushed onto the map. It is only the secondary entity maps /// that can be replaced with a `SparseMap`. @@ -44,10 +44,10 @@ pub trait SparseMapValue { /// - A secondary entity map assigns a default mapping to all keys. It doesn't distinguish between /// an unmapped key and one that maps to the default value. `SparseMap` does not require /// `Default` values, and it tracks accurately if a key has been mapped or not. -/// - Iterating over the contents of an `EntityMap` is linear in the size of the *key space*, while +/// - Iterating over the contents of an `SecondaryMap` is linear in the size of the *key space*, while /// iterating over a `SparseMap` is linear in the number of elements in the mapping. This is an /// advantage precisely when the mapping is sparse. -/// - `SparseMap::clear()` is constant time and super-fast. `EntityMap::clear()` is linear in the +/// - `SparseMap::clear()` is constant time and super-fast. `SecondaryMap::clear()` is linear in the /// size of the key space. (Or, rather the required `resize()` call following the `clear()` is). /// - `SparseMap` requires the values to implement `SparseMapValue` which means that they must /// contain their own key. @@ -56,7 +56,7 @@ where K: EntityRef, V: SparseMapValue, { - sparse: EntityMap, + sparse: SecondaryMap, dense: Vec, } @@ -68,7 +68,7 @@ where /// Create a new empty mapping. pub fn new() -> Self { Self { - sparse: EntityMap::new(), + sparse: SecondaryMap::new(), dense: Vec::new(), } } diff --git a/lib/frontend/src/frontend.rs b/lib/frontend/src/frontend.rs index d32e1892e7..98cdc1c753 100644 --- a/lib/frontend/src/frontend.rs +++ b/lib/frontend/src/frontend.rs @@ -1,6 +1,6 @@ //! A frontend for building Cranelift IR from other languages. use cranelift_codegen::cursor::{Cursor, FuncCursor}; -use cranelift_codegen::entity::{EntityMap, EntitySet}; +use cranelift_codegen::entity::{EntitySet, SecondaryMap}; use cranelift_codegen::ir; use cranelift_codegen::ir::function::DisplayFunction; use cranelift_codegen::ir::{ @@ -24,8 +24,8 @@ use variable::Variable; /// use here, `variable::Variable` can be used. pub struct FunctionBuilderContext { ssa: SSABuilder, - ebbs: EntityMap, - types: EntityMap, + ebbs: SecondaryMap, + types: SecondaryMap, } /// Temporary object used to build a single Cranelift IR `Function`. @@ -79,8 +79,8 @@ impl FunctionBuilderContext { pub fn new() -> Self { Self { ssa: SSABuilder::new(), - ebbs: EntityMap::new(), - types: EntityMap::new(), + ebbs: SecondaryMap::new(), + types: SecondaryMap::new(), } } diff --git a/lib/frontend/src/ssa.rs b/lib/frontend/src/ssa.rs index 3474b5104e..2cb6839b76 100644 --- a/lib/frontend/src/ssa.rs +++ b/lib/frontend/src/ssa.rs @@ -6,7 +6,7 @@ //! Lecture Notes in Computer Science, vol 7791. Springer, Berlin, Heidelberg use cranelift_codegen::cursor::{Cursor, FuncCursor}; -use cranelift_codegen::entity::{EntityMap, EntityRef, PrimaryMap}; +use cranelift_codegen::entity::{EntityRef, PrimaryMap, SecondaryMap}; use cranelift_codegen::ir::immediates::{Ieee32, Ieee64}; use cranelift_codegen::ir::instructions::BranchInfo; use cranelift_codegen::ir::types::{F32, F64}; @@ -36,13 +36,13 @@ use Variable; pub struct SSABuilder { // Records for every variable and for every relevant block, the last definition of // the variable in the block. - // TODO: Consider a sparse representation rather than EntityMap-of-EntityMap. - variables: EntityMap>>, + // TODO: Consider a sparse representation rather than SecondaryMap-of-SecondaryMap. + variables: SecondaryMap>>, // Records the position of the basic blocks and the list of values used but not defined in the // block. blocks: PrimaryMap, // Records the basic blocks at the beginning of the `Ebb`s. - ebb_headers: EntityMap>, + ebb_headers: SecondaryMap>, // Call and result stacks for use in the `use_var`/`predecessors_lookup` state machine. calls: Vec, @@ -158,9 +158,9 @@ impl SSABuilder { /// Allocate a new blank SSA builder struct. Use the API function to interact with the struct. pub fn new() -> Self { Self { - variables: EntityMap::with_default(EntityMap::new()), + variables: SecondaryMap::with_default(SecondaryMap::new()), blocks: PrimaryMap::new(), - ebb_headers: EntityMap::new(), + ebb_headers: SecondaryMap::new(), calls: Vec::new(), results: Vec::new(), side_effects: SideEffects::new(),