Split EntityMap into entity::PrimaryMap and entity::EntityMap.
The new PrimaryMap replaces the primary EntityMap and the PrimaryEntityData marker trait which was causing some confusion. We now have a clear division between the two types of maps: - PrimaryMap is used to assign entity numbers to the primary data for an entity. - EntityMap is a secondary mapping adding additional info. The split also means that the secondary EntityMap can now behave as if all keys have a default value. This means that we can get rid of the annoying ensure() and get_or_default() methods ther were used everywhere instead of indexing. Just use normal indexing now; non-existent keys will return the default value.
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
//! and parent in the loop tree.
|
||||
|
||||
use dominator_tree::DominatorTree;
|
||||
use entity_map::{EntityMap, PrimaryEntityData, Keys};
|
||||
use entity::{PrimaryMap, Keys};
|
||||
use entity::EntityMap;
|
||||
use flowgraph::ControlFlowGraph;
|
||||
use ir::{Function, Ebb, Layout};
|
||||
use packed_option::PackedOption;
|
||||
@@ -17,7 +18,7 @@ entity_impl!(Loop, "loop");
|
||||
/// Loops are referenced by the Loop object, and for each loop you can access its header EBB,
|
||||
/// its eventual parent in the loop tree and all the EBB belonging to the loop.
|
||||
pub struct LoopAnalysis {
|
||||
loops: EntityMap<Loop, LoopData>,
|
||||
loops: PrimaryMap<Loop, LoopData>,
|
||||
ebb_loop_map: EntityMap<Ebb, PackedOption<Loop>>,
|
||||
}
|
||||
|
||||
@@ -26,8 +27,6 @@ struct LoopData {
|
||||
parent: PackedOption<Loop>,
|
||||
}
|
||||
|
||||
impl PrimaryEntityData for LoopData {}
|
||||
|
||||
impl LoopData {
|
||||
/// Creates a `LoopData` object with the loop header and its eventual parent in the loop tree.
|
||||
pub fn new(header: Ebb, parent: Option<Loop>) -> LoopData {
|
||||
@@ -44,7 +43,7 @@ impl LoopAnalysis {
|
||||
/// a function.
|
||||
pub fn new() -> LoopAnalysis {
|
||||
LoopAnalysis {
|
||||
loops: EntityMap::new(),
|
||||
loops: PrimaryMap::new(),
|
||||
ebb_loop_map: EntityMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user