Struct Builder

Source
pub struct Builder { /* private fields */ }
Expand description

A wrapper around a LLVMBuilderRef for a specific context

Implementations§

Source§

impl Builder

Source

pub fn build_alloca(&self, ty: Type) -> Value

Build a stack allocation

Source

pub fn build_malloc(&self, ty: Type) -> Value

Build a heap allocation

Source

pub fn build_array_alloca(&self, ty: Type, count: u32) -> Value

Build a stack allocation for an array

Source

pub fn build_array_malloc(&self, ty: Type, count: u32) -> Value

Build a heap allocation for an array

Source

pub fn build_free(&self, ptr: Value) -> Value

Build a heap free

Source

pub fn build_call(&self, func: Value, args: Vec<Value>) -> Value

Build a call to a function

Source

pub fn build_struct_init(&self, ty: Type, elements: Vec<Value>) -> Value

Build a struct initialization for the given type and elements

Source

pub fn build_struct_alloca_init(&self, ty: Type, elements: Vec<Value>) -> Value

Build a struct initialization that stores it into memory with alloca

Source

pub fn build_struct_malloc_init(&self, ty: Type, elements: Vec<Value>) -> Value

Build a struct initialization that stores it into memory with malloc

Source

pub fn build_insert_value(&self, agg: Value, elt: Value, index: u32) -> Value

Build an insert value instruction

Source

pub fn build_extract_value(&self, agg: Value, index: u32) -> Value

Build an extract value instruction

Source

pub fn build_gep(&self, ptr: Value, indices: Vec<Value>) -> Value

Build a get element pointer instruction

Source

pub fn build_struct_gep(&self, ptr: Value, index: u32) -> Value

Build a struct get element pointer instruction

Source

pub fn build_inbounds_gep(&self, ptr: Value, indices: Vec<Value>) -> Value

Build an inbounds get element pointer instruction

Source

pub fn build_global_string<S>(&self, string: S) -> Value
where S: AsRef<str>,

Build a global string with the given value

Source

pub fn build_global_string_ptr<S>(&self, string: S) -> Value
where S: AsRef<str>,

Build a global string pointer with the given value

Source

pub fn build_store(&self, val: Value, ptr: Value)

Build a store instruction

Source

pub fn build_load(&self, ptr: Value) -> Value

Build a load instruction

Source

pub fn build_array_alloca_store(&self, ty: Type, elements: Vec<Value>) -> Value

Alloca some memory for an array and then store values in it

Source

pub fn build_array_malloc_store(&self, ty: Type, elements: Vec<Value>) -> Value

Malloc some memory for an array and then store values in it

Source

pub fn build_alloca_store(&self, val: Value) -> Value

Alloca some memory and then store a value in it

Source

pub fn build_malloc_store(&self, val: Value) -> Value

Malloc some memory and then store a value in it

Source

pub fn build_load_free(&self, ptr: Value) -> Value

Load a value and then free the memory

Source

pub fn build_int_to_ptr(&self, val: Value, ptr_ty: Type) -> Value

Build a cast from integer to pointer

Source

pub fn build_ptr_to_int(&self, ptr: Value, val_ty: Type) -> Value

Build a cast from pointer to integer

Source

pub fn build_pointer_cast(&self, ptr: Value, ty: Type) -> Value

Build a pointer cast

Source

pub fn build_int_cast(&self, val: Value, ty: Type) -> Value

Build an integer cast

Source

pub fn build_bit_cast(&self, val: Value, ty: Type) -> Value

Build a bit cast

Source

pub fn build_float_cast(&self, val: Value, ty: Type) -> Value

Build a floating point cast

Source

pub fn build_ret_void(&self) -> Value

Build a ret void statement

Source

pub fn build_ret(&self, val: Value) -> Value

Build a ret statement

Source

pub fn build_unreachable(&self)

Build an unreachable instruction

Source

pub fn build_br(&self, block: BasicBlock)

Build a branch instruction to the given block

Source

pub fn build_if( &self, condition: Value, then_block: BasicBlock, else_block: BasicBlock, )

Build an if statement that branches to the given blocks

Source

pub fn build_switch( &self, val: Value, cases: Vec<(Value, BasicBlock)>, default: BasicBlock, )

Build a switch statement that branches to the given blocks

Source

pub fn build_phi(&self, incoming: Vec<(Value, BasicBlock)>) -> Value

Build a phi instruction that takes ceratin values from certain blocks

Source

pub fn position_in_block(&self, bb: BasicBlock, val: Value)

Position the builder at a given value in a basic block

Source

pub fn position_at_end(&self, bb: BasicBlock)

Position the builder at the end of the basic block

Source

pub fn position_before(&self, val: Value)

Position the builder before a value

Source

pub fn inner(&self) -> LLVMBuilderRef

Returns the internal builder reference

Source

pub unsafe fn into_inner(self) -> LLVMBuilderRef

Destroys the wrapper, returning the internal builder reference

Source

pub fn build_is_null(&self, val: Value) -> Value

Builds a null check

Source

pub fn build_is_not_null(&self, val: Value) -> Value

Builds a null check

Source

pub fn build_int_add(&self, a: Value, b: Value) -> Value

Builds an integer add instruction

Source

pub fn build_int_sub(&self, a: Value, b: Value) -> Value

Builds an integer sub instruction

Source

pub fn build_int_mul(&self, a: Value, b: Value) -> Value

Builds an integer mul instruction

Source

pub fn build_int_udiv(&self, a: Value, b: Value) -> Value

Builds an integer udiv instruction

Source

pub fn build_int_sdiv(&self, a: Value, b: Value) -> Value

Builds an integer sdiv instruction

Source

pub fn build_int_urem(&self, a: Value, b: Value) -> Value

Builds an integer urem instruction

Source

pub fn build_int_srem(&self, a: Value, b: Value) -> Value

Builds an integer srem instruction

Source

pub fn build_shl(&self, a: Value, b: Value) -> Value

Builds a shl instruction

Source

pub fn build_lshr(&self, a: Value, b: Value) -> Value

Builds a lshr instruction

Source

pub fn build_ashr(&self, a: Value, b: Value) -> Value

Builds an ashr instruction

Source

pub fn build_and(&self, a: Value, b: Value) -> Value

Builds an and instruction

Source

pub fn build_or(&self, a: Value, b: Value) -> Value

Builds an or instruction

Source

pub fn build_xor(&self, a: Value, b: Value) -> Value

Builds an xor instruction

Source

pub fn build_int_eq(&self, a: Value, b: Value) -> Value

Builds an integer eq check

Source

pub fn build_int_ne(&self, a: Value, b: Value) -> Value

Builds an integer ne check

Source

pub fn build_int_ule(&self, a: Value, b: Value) -> Value

Builds an integer ule check

Source

pub fn build_int_ult(&self, a: Value, b: Value) -> Value

Builds an integer ult check

Source

pub fn build_int_uge(&self, a: Value, b: Value) -> Value

Builds an integer uge check

Source

pub fn build_int_ugt(&self, a: Value, b: Value) -> Value

Builds an integer ugt check

Source

pub fn build_int_sle(&self, a: Value, b: Value) -> Value

Builds an integer sle check

Source

pub fn build_int_slt(&self, a: Value, b: Value) -> Value

Builds an integer slt check

Source

pub fn build_int_sge(&self, a: Value, b: Value) -> Value

Builds an integer sge check

Source

pub fn build_int_sgt(&self, a: Value, b: Value) -> Value

Builds an integer sgt check

Source

pub fn build_float_add(&self, a: Value, b: Value) -> Value

Builds a float add instruction

Source

pub fn build_float_sub(&self, a: Value, b: Value) -> Value

Builds a float sub instruction

Source

pub fn build_float_mul(&self, a: Value, b: Value) -> Value

Builds a float mul instruction

Source

pub fn build_float_div(&self, a: Value, b: Value) -> Value

Builds a float div instruction

Source

pub fn build_float_rem(&self, a: Value, b: Value) -> Value

Builds a float rem instruction

Source

pub fn build_float_eq(&self, a: Value, b: Value) -> Value

Builds a float eq check

Source

pub fn build_float_ne(&self, a: Value, b: Value) -> Value

Builds a float ne check

Source

pub fn build_float_le(&self, a: Value, b: Value) -> Value

Builds a float le check

Source

pub fn build_float_lt(&self, a: Value, b: Value) -> Value

Builds a float lt check

Source

pub fn build_float_ge(&self, a: Value, b: Value) -> Value

Builds a float ge check

Source

pub fn build_float_gt(&self, a: Value, b: Value) -> Value

Builds a float gt check

Source

pub fn build_float_ord_eq(&self, a: Value, b: Value) -> Value

Builds an ordered float eq check

Source

pub fn build_float_ord_ne(&self, a: Value, b: Value) -> Value

Builds an ordered float ne check

Source

pub fn build_float_ord_le(&self, a: Value, b: Value) -> Value

Builds an ordered float le check

Source

pub fn build_float_ord_lt(&self, a: Value, b: Value) -> Value

Builds an ordered float lt check

Source

pub fn build_float_ord_ge(&self, a: Value, b: Value) -> Value

Builds an ordered float ge check

Source

pub fn build_float_ord_gt(&self, a: Value, b: Value) -> Value

Builds an ordered float gt check

Source

pub fn build_float_is_ord(&self, a: Value, b: Value) -> Value

Builds a check for an ordered float

Source

pub fn build_float_non_ord(&self, a: Value, b: Value) -> Value

Builds a check for an unordered float

Trait Implementations§

Source§

impl Debug for Builder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for Builder

Source§

type Target = *mut LLVMBuilder

The resulting type after dereferencing.
Source§

fn deref(&self) -> &LLVMBuilderRef

Dereferences the value.
Source§

impl Drop for Builder

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.