Struct cranelift_codegen::ir::InsertBuilder
source · pub struct InsertBuilder<'f, IIB: InstInserterBase<'f>> { /* private fields */ }
Expand description
Builder that inserts an instruction at the current position.
An InsertBuilder
is a wrapper for an InstInserterBase
that turns it into an instruction
builder with some additional facilities for creating instructions that reuse existing values as
their results.
Implementations§
source§impl<'f, IIB: InstInserterBase<'f>> InsertBuilder<'f, IIB>
impl<'f, IIB: InstInserterBase<'f>> InsertBuilder<'f, IIB>
sourcepub fn new(inserter: IIB) -> Self
pub fn new(inserter: IIB) -> Self
Create a new builder which inserts instructions at pos
.
The dfg
and pos.layout
references should be from the same Function
.
sourcepub fn with_results<Array>(
self,
reuse: Array
) -> InsertReuseBuilder<'f, IIB, Array>where
Array: AsRef<[Option<Value>]>,
pub fn with_results<Array>( self, reuse: Array ) -> InsertReuseBuilder<'f, IIB, Array>where Array: AsRef<[Option<Value>]>,
Reuse result values in reuse
.
Convert this builder into one that will reuse the provided result values instead of allocating new ones. The provided values for reuse must not be attached to anything. Any missing result values will be allocated as normal.
The reuse
argument is expected to be an array of Option<Value>
.
sourcepub fn with_result(
self,
v: Value
) -> InsertReuseBuilder<'f, IIB, [Option<Value>; 1]>
pub fn with_result( self, v: Value ) -> InsertReuseBuilder<'f, IIB, [Option<Value>; 1]>
Reuse a single result value.
Convert this into a builder that will reuse v
as the single result value. The reused
result value v
must not be attached to anything.
This method should only be used when building an instruction with exactly one result. Use
with_results()
for the more general case.