Reorganize the instruction builder traits.
Leave the primary InstBuilderBase trait alone, but add an alternative InstInserterBase trait that can be implemented instead by builders that always allocate new instructions with dfg.make_inst(). Any implementation of InstInserterBase can be used as an instruction builder by wrapping it in an InsertBuilder. The InsertBuilder type adds additional functionality via the with_results() method which makes it possible to override the result values on the instruction that is built. The motivation for this shuffle is that the with_result() functionality can now be reused by different kinds of instruction builders, as long as they insert new instructions. So ReplaceBuilder doesn't get with_results().
This commit is contained in:
@@ -5,7 +5,7 @@ use isa::TargetIsa;
|
||||
use ir::builder::{InsertBuilder, ReplaceBuilder};
|
||||
use ir::extfunc::ExtFuncData;
|
||||
use ir::instructions::{Opcode, InstructionData, CallInfo};
|
||||
use ir::layout::Cursor;
|
||||
use ir::layout::{Cursor, LayoutCursorInserter};
|
||||
use ir::types;
|
||||
use ir::{Ebb, Inst, Value, Type, SigRef, Signature, FuncRef, ValueList, ValueListPool};
|
||||
use write::write_operands;
|
||||
@@ -486,8 +486,8 @@ impl DataFlowGraph {
|
||||
/// 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)
|
||||
-> InsertBuilder<'fd, LayoutCursorInserter<'c, 'fc, 'fd>> {
|
||||
InsertBuilder::new(LayoutCursorInserter::new(at, self))
|
||||
}
|
||||
|
||||
/// Create a `ReplaceBuilder` that will replace `inst` with a new instruction in place.
|
||||
|
||||
Reference in New Issue
Block a user