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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user