Move the 'ins' method to DataFlowGraph.

This given us better symmetry between the replace and insert builder operations:

    dfg.replace(inst).iadd(x, y)
    dfg.ins(cursor).imul(x, y)
This commit is contained in:
Jakob Stoklund Olesen
2016-10-21 09:44:24 -07:00
parent 0acabc80d0
commit 1305283ed8
4 changed files with 19 additions and 18 deletions

View File

@@ -5,7 +5,8 @@ use ir::entities::{NO_VALUE, ExpandedValue};
use ir::instructions::{InstructionData, CallInfo};
use ir::extfunc::ExtFuncData;
use entity_map::{EntityMap, PrimaryEntityData};
use ir::builder::ReplaceBuilder;
use ir::builder::{InsertBuilder, ReplaceBuilder};
use ir::layout::Cursor;
use std::mem;
use std::ops::{Index, IndexMut};
@@ -271,6 +272,13 @@ impl DataFlowGraph {
total_results
}
/// Create an `InsertBuilder` that will insert an instruction at the cursor's current position.
pub fn ins<'c, 'fc: 'c, 'fd>(&'fd mut self,
at: &'c mut Cursor<'fc>)
-> InsertBuilder<'c, 'fc, 'fd> {
InsertBuilder::new(self, at)
}
/// Create a `ReplaceBuilder` that will replace `inst` with a new instruction in place.
pub fn replace(&mut self, inst: Inst) -> ReplaceBuilder {
ReplaceBuilder::new(self, inst)