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:
Jakob Stoklund Olesen
2017-08-18 15:04:10 -07:00
parent 8599372098
commit 7e08b14cf6
30 changed files with 413 additions and 363 deletions

View File

@@ -585,7 +585,7 @@ fn spill_entry_arguments(func: &mut Function, entry: Ebb) {
.zip(func.dfg.ebb_args(entry)) {
if let ArgumentLoc::Stack(offset) = abi.location {
let ss = func.stack_slots.make_incoming_arg(abi.value_type, offset);
*func.locations.ensure(arg) = ValueLoc::Stack(ss);
func.locations[arg] = ValueLoc::Stack(ss);
}
}
}
@@ -646,7 +646,7 @@ fn spill_call_arguments(dfg: &mut DataFlowGraph,
// Insert the spill instructions and rewrite call arguments.
for (idx, arg, ss) in arglist {
let stack_val = dfg.ins(pos).spill(arg);
*locations.ensure(stack_val) = ValueLoc::Stack(ss);
locations[stack_val] = ValueLoc::Stack(ss);
dfg.inst_variable_args_mut(inst)[idx] = stack_val;
}

View File

@@ -73,7 +73,7 @@ pub fn legalize_function(func: &mut ir::Function,
match isa.encode(&pos.func.dfg,
&pos.func.dfg[inst],
pos.func.dfg.ctrl_typevar(inst)) {
Ok(encoding) => *pos.func.encodings.ensure(inst) = encoding,
Ok(encoding) => pos.func.encodings[inst] = encoding,
Err(action) => {
// We should transform the instruction into legal equivalents.
let changed = action(inst, pos.func, cfg);