pub struct Builder<'a> { /* private fields */ }Expand description
A cursor that appends to the end of one block.
This is the shape lowering wants: it works on one block at a time, it appends, and it wants
the value back so it can use it in the next instruction. Everything here is a thin wrapper
over Func::create_inst and Func::append_inst, and anything the wrappers do not
cover is done with those two directly.
Implementations§
Source§impl<'a> Builder<'a>
impl<'a> Builder<'a>
Sourcepub fn new(func: &'a mut Func, block: Block) -> Self
pub fn new(func: &'a mut Func, block: Block) -> Self
A cursor appending to that block, with every instruction taking that source location.
Sourcepub fn at(self, span: Span) -> Self
pub fn at(self, span: Span) -> Self
The same cursor, with a source location for the instructions after this.
Sourcepub fn set_span(&mut self, span: Span)
pub fn set_span(&mut self, span: Span)
Sets the source location for the instructions after this.
Sourcepub fn inst(&mut self, data: InstData, results: &[Type]) -> Inst
pub fn inst(&mut self, data: InstData, results: &[Type]) -> Inst
Appends an instruction as it is, and gives back its results.
Sourcepub fn fconst(&mut self, ty: Type, bits: u128) -> Value
pub fn fconst(&mut self, ty: Type, bits: u128) -> Value
A floating point constant, given as the bits of its format.
Sourcepub fn binary(
&mut self,
opcode: Opcode,
lhs: Value,
rhs: Value,
flags: Flags,
) -> Value
pub fn binary( &mut self, opcode: Opcode, lhs: Value, rhs: Value, flags: Flags, ) -> Value
A two-operand instruction whose result has the type of its operands.
Sourcepub fn unary(&mut self, opcode: Opcode, arg: Value, ty: Type) -> Value
pub fn unary(&mut self, opcode: Opcode, arg: Value, ty: Type) -> Value
A one-operand instruction whose result has the type given.
Sourcepub fn icmp(&mut self, pred: IntPred, lhs: Value, rhs: Value) -> Value
pub fn icmp(&mut self, pred: IntPred, lhs: Value, rhs: Value) -> Value
An integer comparison, which produces one i1 per lane.
Sourcepub fn fcmp(
&mut self,
pred: FloatPred,
lhs: Value,
rhs: Value,
flags: Flags,
) -> Value
pub fn fcmp( &mut self, pred: FloatPred, lhs: Value, rhs: Value, flags: Flags, ) -> Value
A floating point comparison, which produces one i1 per lane.
Sourcepub fn load(
&mut self,
ty: Type,
addr: Value,
info: MemInfo,
flags: Flags,
) -> Value
pub fn load( &mut self, ty: Type, addr: Value, info: MemInfo, flags: Flags, ) -> Value
A read of that type from that address.
Sourcepub fn store(
&mut self,
value: Value,
addr: Value,
info: MemInfo,
flags: Flags,
) -> Inst
pub fn store( &mut self, value: Value, addr: Value, info: MemInfo, flags: Flags, ) -> Inst
A write of a value to an address.
Sourcepub fn br_if(
&mut self,
cond: Value,
then_block: Block,
then_args: &[Value],
else_block: Block,
else_args: &[Value],
) -> Inst
pub fn br_if( &mut self, cond: Value, then_block: Block, then_args: &[Value], else_block: Block, else_args: &[Value], ) -> Inst
A two-way branch, taking the first target when the condition is one.
Sourcepub fn switch(
&mut self,
value: Value,
default: Block,
cases: &[(i128, Block)],
) -> Inst
pub fn switch( &mut self, value: Value, default: Block, cases: &[(i128, Block)], ) -> Inst
A branch on an integer, taking the target its value selects and the default when it selects none.
The cases are values and blocks rather than a table with the default in it, because the
order the side table wants, which is the default first, is not an order anybody building
a switch has their cases in.
Sourcepub fn unreachable(&mut self) -> Inst
pub fn unreachable(&mut self) -> Inst
A place control does not reach.