Skip to main content

IrBuilder

Struct IrBuilder 

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

Builder for constructing IR modules.

Implementations§

Source§

impl IrBuilder

Source

pub fn new(name: impl Into<String>) -> Self

Create a new builder.

Source

pub fn build(self) -> IrModule

Build and return the IR module.

Source

pub fn module(&self) -> &IrModule

Get a reference to the module being built.

Source

pub fn set_config(&mut self, config: KernelConfig)

Set kernel configuration.

Source

pub fn set_block_size(&mut self, x: u32, y: u32, z: u32)

Set block size.

Source

pub fn set_persistent(&mut self, persistent: bool)

Mark as persistent kernel.

Source

pub fn parameter(&mut self, name: impl Into<String>, ty: IrType) -> ValueId

Add a parameter.

Source

pub fn create_block(&mut self, label: impl Into<String>) -> BlockId

Create a new block.

Source

pub fn switch_to_block(&mut self, block: BlockId)

Switch to a different block.

Source

pub fn current_block(&self) -> BlockId

Get current block ID.

Source

pub fn const_i32(&mut self, value: i32) -> ValueId

Create an i32 constant.

Source

pub fn const_i64(&mut self, value: i64) -> ValueId

Create an i64 constant.

Source

pub fn const_u32(&mut self, value: u32) -> ValueId

Create a u32 constant.

Source

pub fn const_u64(&mut self, value: u64) -> ValueId

Create a u64 constant.

Source

pub fn const_f32(&mut self, value: f32) -> ValueId

Create an f32 constant.

Source

pub fn const_f64(&mut self, value: f64) -> ValueId

Create an f64 constant.

Source

pub fn const_bool(&mut self, value: bool) -> ValueId

Create a boolean constant.

Source

pub fn add(&mut self, lhs: ValueId, rhs: ValueId) -> ValueId

Add two values.

Source

pub fn sub(&mut self, lhs: ValueId, rhs: ValueId) -> ValueId

Subtract two values.

Source

pub fn mul(&mut self, lhs: ValueId, rhs: ValueId) -> ValueId

Multiply two values.

Source

pub fn div(&mut self, lhs: ValueId, rhs: ValueId) -> ValueId

Divide two values.

Source

pub fn rem(&mut self, lhs: ValueId, rhs: ValueId) -> ValueId

Remainder.

Source

pub fn and(&mut self, lhs: ValueId, rhs: ValueId) -> ValueId

Bitwise AND.

Source

pub fn or(&mut self, lhs: ValueId, rhs: ValueId) -> ValueId

Bitwise OR.

Source

pub fn xor(&mut self, lhs: ValueId, rhs: ValueId) -> ValueId

Bitwise XOR.

Source

pub fn shl(&mut self, lhs: ValueId, rhs: ValueId) -> ValueId

Left shift.

Source

pub fn shr(&mut self, lhs: ValueId, rhs: ValueId) -> ValueId

Logical right shift.

Source

pub fn min(&mut self, lhs: ValueId, rhs: ValueId) -> ValueId

Minimum.

Source

pub fn max(&mut self, lhs: ValueId, rhs: ValueId) -> ValueId

Maximum.

Source

pub fn neg(&mut self, value: ValueId) -> ValueId

Negate.

Source

pub fn not(&mut self, value: ValueId) -> ValueId

Bitwise NOT.

Source

pub fn abs(&mut self, value: ValueId) -> ValueId

Absolute value.

Source

pub fn sqrt(&mut self, value: ValueId) -> ValueId

Square root.

Source

pub fn floor(&mut self, value: ValueId) -> ValueId

Floor.

Source

pub fn ceil(&mut self, value: ValueId) -> ValueId

Ceiling.

Source

pub fn eq(&mut self, lhs: ValueId, rhs: ValueId) -> ValueId

Equal comparison.

Source

pub fn ne(&mut self, lhs: ValueId, rhs: ValueId) -> ValueId

Not equal comparison.

Source

pub fn lt(&mut self, lhs: ValueId, rhs: ValueId) -> ValueId

Less than.

Source

pub fn le(&mut self, lhs: ValueId, rhs: ValueId) -> ValueId

Less than or equal.

Source

pub fn gt(&mut self, lhs: ValueId, rhs: ValueId) -> ValueId

Greater than.

Source

pub fn ge(&mut self, lhs: ValueId, rhs: ValueId) -> ValueId

Greater than or equal.

Source

pub fn load(&mut self, ptr: ValueId) -> ValueId

Load from pointer.

Source

pub fn store(&mut self, ptr: ValueId, value: ValueId)

Store to pointer.

Source

pub fn gep(&mut self, ptr: ValueId, indices: Vec<ValueId>) -> ValueId

Get element pointer.

Source

pub fn shared_alloc(&mut self, ty: IrType, count: usize) -> ValueId

Allocate shared memory.

Source

pub fn thread_id(&mut self, dim: Dimension) -> ValueId

Get thread ID.

Source

pub fn block_id(&mut self, dim: Dimension) -> ValueId

Get block ID.

Source

pub fn block_dim(&mut self, dim: Dimension) -> ValueId

Get block dimension.

Source

pub fn grid_dim(&mut self, dim: Dimension) -> ValueId

Get grid dimension.

Source

pub fn global_thread_id(&mut self, dim: Dimension) -> ValueId

Get global thread ID.

Source

pub fn barrier(&mut self)

Block/threadgroup barrier.

Source

pub fn fence(&mut self, scope: MemoryScope)

Memory fence.

Source

pub fn grid_sync(&mut self)

Grid sync (cooperative groups).

Source

pub fn atomic_add(&mut self, ptr: ValueId, value: ValueId) -> ValueId

Atomic add.

Source

pub fn atomic_exchange(&mut self, ptr: ValueId, value: ValueId) -> ValueId

Atomic exchange.

Source

pub fn atomic_cas( &mut self, ptr: ValueId, expected: ValueId, desired: ValueId, ) -> ValueId

Atomic compare-and-swap.

Source

pub fn select( &mut self, cond: ValueId, then_val: ValueId, else_val: ValueId, ) -> ValueId

Select (ternary).

Source

pub fn branch(&mut self, target: BlockId)

Branch to block.

Source

pub fn cond_branch( &mut self, cond: ValueId, then_block: BlockId, else_block: BlockId, )

Conditional branch.

Source

pub fn ret(&mut self)

Return from kernel.

Source

pub fn ret_value(&mut self, value: ValueId)

Return value from kernel.

Source

pub fn k2h_enqueue(&mut self, message: ValueId)

Enqueue to output (K2H).

Source

pub fn h2k_dequeue(&mut self, msg_ty: IrType) -> ValueId

Dequeue from input (H2K).

Source

pub fn h2k_is_empty(&mut self) -> ValueId

Check if input queue is empty.

Source

pub fn k2k_send(&mut self, dest: ValueId, message: ValueId)

Send K2K message.

Source

pub fn k2k_try_recv(&mut self, msg_ty: IrType) -> ValueId

Try receive K2K message.

Source

pub fn hlc_now(&mut self) -> ValueId

Get current HLC time.

Source

pub fn hlc_tick(&mut self) -> ValueId

Tick HLC.

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<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.