Rename EntityMap to SecondaryMap (#528)

* Rename `EntityMap` to `SecondaryMap`
This commit is contained in:
Muhammad Mominul Huque
2018-09-27 01:03:44 +06:00
committed by Dan Gohman
parent 7ff71fcfd9
commit d266b1a42d
18 changed files with 91 additions and 91 deletions

View File

@@ -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<Ebb, DomNode>,
nodes: SecondaryMap<Ebb, DomNode>,
/// CFG post-order of all reachable EBBs.
postorder: Vec<Ebb>,
@@ -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<Ebb, ExtraNode>,
nodes: SecondaryMap<Ebb, ExtraNode>,
// Scratch memory used by `compute_postorder()`.
stack: Vec<Ebb>,
@@ -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(),
}
}

View File

@@ -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<Ebb, CFGNode>,
data: SecondaryMap<Ebb, CFGNode>,
pred_forest: bforest::MapForest<Inst, Ebb>,
succ_forest: bforest::SetForest<Ebb>,
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(),

View File

@@ -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<Inst, ValueList>,
results: SecondaryMap<Inst, ValueList>,
/// 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()
}

View File

@@ -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(),
}
}

View File

@@ -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<Ebb, EbbNode>,
ebbs: SecondaryMap<Ebb, EbbNode>,
/// Linked list nodes for the layout order of instructions. Forms a double linked list per EBB,
/// terminated in both ends by `None`.
insts: EntityMap<Inst, InstNode>,
insts: SecondaryMap<Inst, InstNode>,
/// First EBB in the layout order, or `None` when no EBBs have been laid out.
first_ebb: Option<Ebb>,
@@ -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,
}

View File

@@ -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<Value, ValueLoc>;
pub type ValueLocations = SecondaryMap<Value, ValueLoc>;
/// Map of jump tables.
pub type JumpTables = PrimaryMap<JumpTable, JumpTableData>;
/// Map of instruction encodings.
pub type InstEncodings = EntityMap<Inst, isa::Encoding>;
pub type InstEncodings = SecondaryMap<Inst, isa::Encoding>;
/// Code offsets for EBBs.
pub type EbbOffsets = EntityMap<Ebb, binemit::CodeOffset>;
pub type EbbOffsets = SecondaryMap<Ebb, binemit::CodeOffset>;
/// Source locations for instructions.
pub type SourceLocs = EntityMap<Inst, SourceLoc>;
pub type SourceLocs = SecondaryMap<Inst, SourceLoc>;

View File

@@ -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<Loop, LoopData>,
ebb_loop_map: EntityMap<Ebb, PackedOption<Loop>>,
ebb_loop_map: SecondaryMap<Ebb, PackedOption<Loop>>,
valid: bool,
}
@@ -48,7 +48,7 @@ impl LoopAnalysis {
Self {
valid: false,
loops: PrimaryMap::new(),
ebb_loop_map: EntityMap::new(),
ebb_loop_map: SecondaryMap::new(),
}
}

View File

@@ -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<Value, Vec<Value>>,
aliases: &SecondaryMap<Value, Vec<Value>>,
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<Value, Vec<Value>>,
aliases: &SecondaryMap<Value, Vec<Value>>,
isa: Option<&TargetIsa>,
cur_inst: Inst,
indent: usize,

View File

@@ -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<VirtReg>,
/// Each value belongs to at most one virtual register.
value_vregs: EntityMap<Value, PackedOption<VirtReg>>,
value_vregs: SecondaryMap<Value, PackedOption<VirtReg>>,
/// Table used during the union-find phase while `vregs` is empty.
union_find: EntityMap<Value, i32>,
union_find: SecondaryMap<Value, i32>,
/// 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(),
}
}

View File

@@ -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<isa::EncInfo>,
/// The single live-in flags value (if any) for each EBB.
livein: EntityMap<ir::Ebb, PackedOption<ir::Value>>,
livein: SecondaryMap<ir::Ebb, PackedOption<ir::Value>>,
}
impl<'a> FlagsVerifier<'a> {

View File

@@ -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<Value, Vec<Value>>,
aliases: &SecondaryMap<Value, Vec<Value>>,
isa: Option<&TargetIsa>,
inst: Inst,
ident: usize,
@@ -101,7 +101,7 @@ impl FuncWriter for PlainWriter {
&mut self,
w: &mut Write,
func: &Function,
aliases: &EntityMap<Value, Vec<Value>>,
aliases: &SecondaryMap<Value, Vec<Value>>,
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<Value, Vec<Value>> {
let mut aliases = EntityMap::<_, Vec<_>>::new();
fn alias_map(func: &Function) -> SecondaryMap<Value, Vec<Value>> {
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<FW: FuncWriter>(
func_w: &mut FW,
w: &mut Write,
func: &Function,
aliases: &EntityMap<Value, Vec<Value>>,
aliases: &SecondaryMap<Value, Vec<Value>>,
isa: Option<&TargetIsa>,
ebb: Ebb,
) -> fmt::Result {
@@ -279,7 +279,7 @@ fn type_suffix(func: &Function, inst: Inst) -> Option<Type> {
/// Write out any aliases to the given target, including indirect aliases
fn write_value_aliases(
w: &mut Write,
aliases: &EntityMap<Value, Vec<Value>>,
aliases: &SecondaryMap<Value, Vec<Value>>,
target: Value,
indent: usize,
) -> fmt::Result {
@@ -293,7 +293,7 @@ fn write_value_aliases(
fn write_instruction(
w: &mut Write,
func: &Function,
aliases: &EntityMap<Value, Vec<Value>>,
aliases: &SecondaryMap<Value, Vec<Value>>,
isa: Option<&TargetIsa>,
inst: Inst,
indent: usize,