pub struct Builder(_);Expand description
This provides a uniform API for creating instructions and inserting them into a basic block.
Implementations§
source§impl Builder
impl Builder
sourcepub fn new(context: &Context) -> CSemiBox<'_, Builder>
pub fn new(context: &Context) -> CSemiBox<'_, Builder>
Create a new builder in the context given.
sourcepub fn position_at_end(&self, block: &BasicBlock)
pub fn position_at_end(&self, block: &BasicBlock)
Position the builder at the end of block.
sourcepub fn build_ret_void(&self) -> &Value
pub fn build_ret_void(&self) -> &Value
Build an instruction that returns from the function with void.
sourcepub fn build_ret(&self, value: &Value) -> &Value
pub fn build_ret(&self, value: &Value) -> &Value
Build an instruction that returns from the function with value.
sourcepub fn build_array_alloca(&self, elem: &Type, size: &Value) -> &Value
pub fn build_array_alloca(&self, elem: &Type, size: &Value) -> &Value
Build an instruction that allocates an array with the element type elem and the size size.
The size of this array will be the size of elem times size.
sourcepub fn build_alloca(&self, ty: &Type) -> &Value
pub fn build_alloca(&self, ty: &Type) -> &Value
Build an instruction that allocates a pointer to fit the size of ty then returns this pointer.
Make sure to call build_free with the pointer value when you’re done with it, or you’re
gonna have a bad time.
sourcepub fn build_free(&self, val: &Value) -> &Value
pub fn build_free(&self, val: &Value) -> &Value
Build an instruction that frees the val, which MUST be a pointer that was returned
from build_alloca.
sourcepub fn build_store(&self, val: &Value, ptr: &Value) -> &Value
pub fn build_store(&self, val: &Value, ptr: &Value) -> &Value
Build an instruction that store the value val in the pointer ptr.
sourcepub fn build_br(&self, dest: &BasicBlock) -> &Value
pub fn build_br(&self, dest: &BasicBlock) -> &Value
Build an instruction that branches to the block dest.
pub fn get_insert_block<'a>(&self) -> &'a BasicBlock
sourcepub fn build_cond_br(
&self,
cond: &Value,
if_block: &BasicBlock,
else_block: &BasicBlock
) -> &Value
pub fn build_cond_br(
&self,
cond: &Value,
if_block: &BasicBlock,
else_block: &BasicBlock
) -> &Value
Build an instruction that branches to if_block if cond evaluates to true, and else_block otherwise.
sourcepub fn build_call(&self, func: &Function, args: &[&Value]) -> &Value
pub fn build_call(&self, func: &Function, args: &[&Value]) -> &Value
Build an instruction that calls the function func with the arguments args.
This will return the return value of the function.
sourcepub fn build_tail_call(&self, func: &Function, args: &[&Value]) -> &Value
pub fn build_tail_call(&self, func: &Function, args: &[&Value]) -> &Value
Build an instruction that calls the function func with the arguments args.
This will return the return value of the function.
sourcepub fn build_fp_to_si(&self, val: &Value, dest: &Type) -> &Value
pub fn build_fp_to_si(&self, val: &Value, dest: &Type) -> &Value
Build an instruction that converts val to a floating point dest.
sourcepub fn build_si_to_fp(&self, val: &Value, dest: &Type) -> &Value
pub fn build_si_to_fp(&self, val: &Value, dest: &Type) -> &Value
Build an instruction that converts val to an integer dest.
sourcepub fn build_select(
&self,
cond: &Value,
true_val: &Value,
false_val: &Value
) -> &Value
pub fn build_select(
&self,
cond: &Value,
true_val: &Value,
false_val: &Value
) -> &Value
Build an instruction that yields to true_val if cond is equal to 1, and false_val otherwise.
sourcepub fn build_bit_cast(&self, value: &Value, dest: &Type) -> &Value
pub fn build_bit_cast(&self, value: &Value, dest: &Type) -> &Value
Build an instruction that casts a value into a certain type.
sourcepub fn build_int_to_ptr(&self, val: &Value, dest: &Type) -> &Value
pub fn build_int_to_ptr(&self, val: &Value, dest: &Type) -> &Value
Build an instruction that casts an integer to a pointer.
sourcepub fn build_ptr_to_int(&self, val: &Value, dest: &Type) -> &Value
pub fn build_ptr_to_int(&self, val: &Value, dest: &Type) -> &Value
Build an instruction that casts a pointer to an integer.
sourcepub fn build_zext(&self, value: &Value, dest: &Type) -> &Value
pub fn build_zext(&self, value: &Value, dest: &Type) -> &Value
Build an instruction that zero extends its operand to the type dest.
sourcepub fn build_trunc(&self, value: &Value, dest: &Type) -> &Value
pub fn build_trunc(&self, value: &Value, dest: &Type) -> &Value
Build an instruction that truncates the high-order bits of value to fit into a certain type.
sourcepub fn build_insert_value(&self, agg: &Value, elem: &Value, index: usize) -> &Value
pub fn build_insert_value(&self, agg: &Value, elem: &Value, index: usize) -> &Value
Build an instruction that inserts a value into an aggregate data value.
sourcepub fn build_gep(&self, pointer: &Value, indices: &[&Value]) -> &Value
pub fn build_gep(&self, pointer: &Value, indices: &[&Value]) -> &Value
Build an instruction that computes the address of a subelement of an aggregate data structure.
Basically type-safe pointer arithmetic.
sourcepub fn build_switch(
&self,
value: &Value,
default: &BasicBlock,
cases: &[(&Value, &BasicBlock)]
) -> &Value
pub fn build_switch(
&self,
value: &Value,
default: &BasicBlock,
cases: &[(&Value, &BasicBlock)]
) -> &Value
Build an instruction that runs whichever block matches the value, or default if none of them matched it.
sourcepub fn build_phi<'ctx>(
&self,
ty: &'ctx Type,
entries: &[(&'ctx Value, &'ctx BasicBlock)]
) -> &'ctx Value
pub fn build_phi<'ctx>(
&self,
ty: &'ctx Type,
entries: &[(&'ctx Value, &'ctx BasicBlock)]
) -> &'ctx Value
Build a phi node which is used together with branching to select a value depending on the predecessor of the current block