Add a Cursor::ins() method which constructs a Builder.
Rewrite Builder uses in test cases to use this method and construct a new builder for each instruction. This pattern allows us to change the InstBuilder trait to a one-shot implementation that can only create a single instruction. Don't re-export the Builder struct, it is less important than the InstBuilder trait, and we may get more implementations.
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
use std::iter::{Iterator, IntoIterator};
|
||||
use entity_map::{EntityMap, EntityRef};
|
||||
use ir::entities::{Ebb, NO_EBB, Inst, NO_INST};
|
||||
use ir::dfg::DataFlowGraph;
|
||||
use ir::builder::Builder;
|
||||
|
||||
/// The `Layout` struct determines the layout of EBBs and instructions in a function. It does not
|
||||
/// contain definitions of instructions or EBBs, but depends on `Inst` and `Ebb` entity references
|
||||
@@ -615,6 +617,11 @@ impl<'f> Cursor<'f> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a builder for inserting an instruction at the current position.
|
||||
pub fn ins<'c, 'fd>(&'c mut self, dfg: &'fd mut DataFlowGraph) -> Builder<'c, 'f, 'fd> {
|
||||
Builder::new(dfg, self)
|
||||
}
|
||||
|
||||
/// Insert an EBB at the current position and switch to it.
|
||||
///
|
||||
/// As far as possible, this method behaves as if the EBB header were an instruction inserted
|
||||
|
||||
@@ -24,4 +24,4 @@ pub use ir::jumptable::JumpTableData;
|
||||
pub use ir::dfg::{DataFlowGraph, ValueDef};
|
||||
pub use ir::layout::{Layout, Cursor};
|
||||
pub use ir::function::Function;
|
||||
pub use ir::builder::{Builder, InstBuilder};
|
||||
pub use ir::builder::InstBuilder;
|
||||
|
||||
Reference in New Issue
Block a user