Use more helper functions on CursorBase to reduce cursor repositioning.

This commit is contained in:
Dan Gohman
2017-09-20 11:19:35 -07:00
parent 482439c94b
commit 74845fed6c
6 changed files with 139 additions and 79 deletions

View File

@@ -62,8 +62,7 @@ fn legalize_entry_arguments(func: &mut Function, entry: Ebb) {
// Insert position for argument conversion code.
// We want to insert instructions before the first instruction in the entry block.
// If the entry block is empty, append instructions to it instead.
let mut pos = Cursor::new(&mut func.layout);
pos.goto_first_inst(entry);
let mut pos = Cursor::new(&mut func.layout).at_first_inst(entry);
// Keep track of the argument types in the ABI-legalized signature.
let abi_types = &func.signature.argument_types;

View File

@@ -137,8 +137,7 @@ fn expand_cond_trap(inst: ir::Inst, func: &mut ir::Function, cfg: &mut ControlFl
func.dfg.replace(inst).brz(arg, new_ebb, &[]);
}
let mut pos = FuncCursor::new(func).at_inst(inst);
pos.next_inst();
let mut pos = FuncCursor::new(func).after_inst(inst);
pos.ins().trap();
pos.insert_ebb(new_ebb);