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

@@ -107,11 +107,11 @@ impl SubTest for TestBinEmit {
// Give an encoding to any instruction that doesn't already have one.
for ebb in func.layout.ebbs() {
for inst in func.layout.ebb_insts(ebb) {
if !func.encodings.get_or_default(inst).is_legal() {
if !func.encodings[inst].is_legal() {
if let Ok(enc) = isa.encode(&func.dfg,
&func.dfg[inst],
func.dfg.ctrl_typevar(inst)) {
*func.encodings.ensure(inst) = enc;
func.encodings[inst] = enc;
}
}
}
@@ -158,7 +158,7 @@ impl SubTest for TestBinEmit {
ebb);
for inst in func.layout.ebb_insts(ebb) {
sink.text.clear();
let enc = func.encodings.get_or_default(inst);
let enc = func.encodings[inst];
// Send legal encodings into the emitter.
if enc.is_legal() {