cubecl_opt

Struct Optimizer

Source
pub struct Optimizer {
    pub ret: NodeIndex,
    /* private fields */
}
Expand description

An optimizer that applies various analyses and optimization passes to the IR.

Fields§

§ret: NodeIndex

The single return block

Implementations§

Source§

impl Optimizer

Source

pub fn visit_all( &mut self, visit_read: impl FnMut(&mut Self, &mut Variable) + Clone, visit_write: impl FnMut(&mut Self, &mut Variable) + Clone, )

Visit all operations in the program with the specified read and write visitors.

Source§

impl Optimizer

Source

pub fn visit_operation( &mut self, op: &mut Operation, visit_read: impl FnMut(&mut Self, &mut Variable), visit_write: impl FnMut(&mut Self, &mut Variable), )

Visit an operation with a set of read and write visitors. Each visitor will be called with each read or written to variable.

Source

pub fn visit_operator( &mut self, op: &mut Operator, visit_read: impl FnMut(&mut Self, &mut Variable), visit_write: impl FnMut(&mut Self, &mut Variable), )

Visit an operator with a set of read and write visitors. Each visitor will be called with each read or written to variable.

Source

pub fn write_var(&mut self, var: &mut Variable)

Source

pub fn find_writes_select(&mut self, select: &mut Select)

Source§

impl Optimizer

Source

pub fn analyze_liveness(&mut self)

Do a conservative block level liveness analysis

Source§

impl Optimizer

Source

pub fn new(expand: Scope, cube_dim: CubeDim, mode: ExecutionMode) -> Self

Create a new optimizer with the scope, CubeDim and execution mode passed into the compiler. Parses the scope and runs several optimization and analysis loops.

Source

pub fn entry(&self) -> NodeIndex

The entry block of the program

Source

pub fn post_order(&self) -> Vec<NodeIndex>

Source

pub fn reverse_post_order(&self) -> Vec<NodeIndex>

Source

pub fn predecessors(&self, block: NodeIndex) -> Vec<NodeIndex>

List of predecessor IDs of the block

Source

pub fn successors(&self, block: NodeIndex) -> Vec<NodeIndex>

List of successor IDs of the block

Source

pub fn block(&self, block: NodeIndex) -> &BasicBlock

Reference to the BasicBlock with ID block

Source

pub fn block_mut(&mut self, block: NodeIndex) -> &mut BasicBlock

Reference to the BasicBlock with ID block

Source

pub fn parse_scope(&mut self, scope: Scope) -> bool

Recursively parse a scope into the graph

Source

pub fn local_variable_id(&mut self, variable: &Variable) -> Option<(u16, u8)>

Gets the id and depth of the variable if it’s a Local and not atomic, None otherwise.

Source

pub fn create_temporary(&self, item: Item) -> Variable

Create a temporary variable for use in the compiler. Counts backwards from u16::MAX to avoid Collisions with existing locals, since binding counter is no longer available.

Trait Implementations§

Source§

impl Clone for Optimizer

Source§

fn clone(&self) -> Optimizer

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Optimizer

Source§

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

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

impl Default for Optimizer

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for Optimizer

Debug display for the program state.

Source§

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

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V