Add EntityMap::with_capacity.

Create a secondary entity map with space reserved for a known range of entity
references.

Add dfg.num_ebbs() and dfg.num_insts() methods to provide capacities.
This commit is contained in:
Jakob Stoklund Olesen
2016-07-29 15:59:09 -07:00
parent 0ef28f5bde
commit dae349371f
2 changed files with 31 additions and 0 deletions

View File

@@ -42,6 +42,22 @@ impl DataFlowGraph {
extended_values: Vec::new(),
}
}
/// 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`.
pub fn num_insts(&self) -> usize {
self.insts.len()
}
/// 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`.
pub fn num_ebbs(&self) -> usize {
self.ebbs.len()
}
}
/// Handling values.