Replace inst_order with Layout in Function.

The Layout also handles EBB layout, so new append_ebb calls are necessary.

- Rewrite callers to use the public data member 'layout'.
- Implement Debug for Function in terms of the write module to avoid deriving
  it.
This commit is contained in:
Jakob Stoklund Olesen
2016-07-18 18:23:32 -07:00
parent 2f74efd5fc
commit e926674b4e
5 changed files with 58 additions and 105 deletions

View File

@@ -101,6 +101,7 @@ impl Context {
// Allocate a new EBB and add a mapping src_ebb -> Ebb.
fn add_ebb(&mut self, src_ebb: Ebb, loc: &Location) -> Result<Ebb> {
let ebb = self.function.make_ebb();
self.function.layout.append_ebb(ebb);
if self.ebbs.insert(src_ebb, ebb).is_some() {
err!(loc, "duplicate EBB: {}", src_ebb)
} else {
@@ -704,7 +705,7 @@ impl<'a> Parser<'a> {
let ctrl_typevar = try!(self.infer_typevar(ctx, opcode, explicit_ctrl_type, &inst_data));
let inst = ctx.function.make_inst(inst_data);
let num_results = ctx.function.make_inst_results(inst, ctrl_typevar);
ctx.function.append_inst(ebb, inst);
ctx.function.layout.append_inst(inst, ebb);
ctx.add_inst_loc(inst, &opcode_loc);
if results.len() != num_results {