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:
@@ -6,8 +6,7 @@ use cretonne::ir::instructions::BranchInfo;
|
||||
use cretonne::ir::function::DisplayFunction;
|
||||
use cretonne::isa::TargetIsa;
|
||||
use ssa::{SSABuilder, SideEffects, Block};
|
||||
use cretonne::entity_map::{EntityMap, PrimaryEntityData};
|
||||
use cretonne::entity::EntityRef;
|
||||
use cretonne::entity::{EntityRef, EntityMap};
|
||||
use std::hash::Hash;
|
||||
|
||||
/// Permanent structure used for translating into Cretonne IL.
|
||||
@@ -38,8 +37,6 @@ struct EbbData {
|
||||
user_arg_count: usize,
|
||||
}
|
||||
|
||||
impl PrimaryEntityData for EbbData {}
|
||||
|
||||
struct Position {
|
||||
ebb: Ebb,
|
||||
basic_block: Block,
|
||||
@@ -231,7 +228,7 @@ impl<'a, Variable> FunctionBuilder<'a, Variable>
|
||||
pub fn create_ebb(&mut self) -> Ebb {
|
||||
let ebb = self.func.dfg.make_ebb();
|
||||
self.builder.ssa.declare_ebb_header_block(ebb);
|
||||
*self.builder.ebbs.ensure(ebb) = EbbData {
|
||||
self.builder.ebbs[ebb] = EbbData {
|
||||
filled: false,
|
||||
pristine: true,
|
||||
user_arg_count: 0,
|
||||
@@ -286,7 +283,7 @@ impl<'a, Variable> FunctionBuilder<'a, Variable>
|
||||
|
||||
/// In order to use a variable in a `use_var`, you need to declare its type with this method.
|
||||
pub fn declare_var(&mut self, var: Variable, ty: Type) {
|
||||
*self.builder.types.ensure(var) = ty;
|
||||
self.builder.types[var] = ty;
|
||||
}
|
||||
|
||||
/// Returns the Cretonne IL value corresponding to the utilization at the current program
|
||||
@@ -560,7 +557,7 @@ impl<'a, Variable> FunctionBuilder<'a, Variable>
|
||||
|
||||
fn handle_ssa_side_effects(&mut self, side_effects: SideEffects) {
|
||||
for split_ebb in side_effects.split_ebbs_created {
|
||||
self.builder.ebbs.ensure(split_ebb).filled = true
|
||||
self.builder.ebbs[split_ebb].filled = true
|
||||
}
|
||||
for modified_ebb in side_effects.instructions_added_to_ebbs {
|
||||
self.builder.ebbs[modified_ebb].pristine = false
|
||||
|
||||
Reference in New Issue
Block a user