Optimizer

Struct Optimizer 

Source
pub struct Optimizer {
    pub program: Program,
    pub allocator: Allocator,
    pub ret: NodeIndex,
    pub root_scope: Scope,
    /* private fields */
}
Expand description

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

Fields§

§program: Program

The overall program state

§allocator: Allocator

Allocator for kernel

§ret: NodeIndex

The single return block

§root_scope: Scope

Root scope to allocate variables on

Implementations§

Source§

impl Optimizer

Source

pub fn analysis<A: Analysis + Any>(&mut self) -> Rc<A>

Fetch an analysis if cached, or run it if not.

Source

pub fn invalidate_analysis<A: Analysis + Any>(&self)

Invalidate an analysis by removing it from the cache. The analysis is rerun when requested again.

Source

pub fn invalidate_structure(&self)

Invalidate all analyses that rely on the structure of the control flow graph.

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_out( &mut self, var: &mut Option<Variable>, visit_write: impl FnMut(&mut Self, &mut Variable), )

Source

pub fn visit_instruction( &mut self, inst: &mut Instruction, 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_operation( &mut self, op: &mut Operation, out: &mut Option<Variable>, visit_read: 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_arithmetic( &mut self, op: &mut Arithmetic, visit_read: 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 visit_compare( &mut self, op: &mut Comparison, visit_read: 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 visit_bitwise( &mut self, op: &mut Bitwise, visit_read: 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 visit_operator( &mut self, op: &mut Operator, visit_read: 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§

impl Optimizer

Source

pub fn place_phi_nodes(&mut self)

Places a phi node for each live variable at each frontier

Source

pub fn insert_phi(&mut self, block: NodeIndex, id: Id, item: Type)

Insert a phi node for variable id at block

Source§

impl Optimizer

Source

pub fn new( expand: Scope, cube_dim: CubeDim, transformers: Vec<Rc<dyn IrTransformer>>, processors: Vec<Box<dyn Processor>>, ) -> 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 shared_only(expand: Scope, cube_dim: CubeDim) -> 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 node_ids(&self) -> Vec<NodeIndex>

A set of node indices for all blocks in the program

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

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

Source

pub fn const_arrays(&self) -> Vec<ConstArray>

Source

pub fn dot_viz(&self) -> Dot<'_, &StableDiGraph<BasicBlock, u32>>

Trait Implementations§

Source§

impl Clone for Optimizer

Source§

fn clone(&self) -> Optimizer

Returns a duplicate 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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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§

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