pub struct Optimizer {
pub allocator: Allocator,
pub ret: NodeIndex,
/* private fields */
}Expand description
An optimizer that applies various analyses and optimization passes to the IR.
Fields§
§allocator: AllocatorAllocator for kernel
ret: NodeIndexThe single return block
Implementations§
Source§impl Optimizer
impl Optimizer
Sourcepub fn analysis<A: Analysis + Any>(&mut self) -> Rc<A>
pub fn analysis<A: Analysis + Any>(&mut self) -> Rc<A>
Fetch an analysis if cached, or run it if not.
Sourcepub fn invalidate_analysis<A: Analysis + Any>(&self)
pub fn invalidate_analysis<A: Analysis + Any>(&self)
Invalidate an analysis by removing it from the cache. The analysis is rerun when requested again.
Sourcepub fn invalidate_structure(&self)
pub fn invalidate_structure(&self)
Invalidate all analyses that rely on the structure of the control flow graph.
Source§impl Optimizer
impl Optimizer
pub fn visit_out( &mut self, var: &mut Option<Variable>, visit_write: impl FnMut(&mut Self, &mut Variable), )
Sourcepub fn visit_instruction(
&mut self,
inst: &mut Instruction,
visit_read: impl FnMut(&mut Self, &mut Variable),
visit_write: impl FnMut(&mut Self, &mut Variable),
)
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.
Sourcepub fn visit_operation(
&mut self,
op: &mut Operation,
visit_read: impl FnMut(&mut Self, &mut Variable),
)
pub fn visit_operation( &mut self, op: &mut Operation, 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.
Sourcepub fn visit_operator(
&mut self,
op: &mut Operator,
visit_read: impl FnMut(&mut Self, &mut Variable),
)
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
impl Optimizer
Sourcepub fn place_phi_nodes(&mut self)
pub fn place_phi_nodes(&mut self)
Places a phi node for each live variable at each frontier
Sourcepub fn insert_phi(&mut self, block: NodeIndex, id: Id, item: Item)
pub fn insert_phi(&mut self, block: NodeIndex, id: Id, item: Item)
Insert a phi node for variable id at block
Source§impl Optimizer
impl Optimizer
Sourcepub fn new(expand: Scope, cube_dim: CubeDim, mode: ExecutionMode) -> Self
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.
Sourcepub fn predecessors(&self, block: NodeIndex) -> Vec<NodeIndex>
pub fn predecessors(&self, block: NodeIndex) -> Vec<NodeIndex>
List of predecessor IDs of the block
Sourcepub fn successors(&self, block: NodeIndex) -> Vec<NodeIndex>
pub fn successors(&self, block: NodeIndex) -> Vec<NodeIndex>
List of successor IDs of the block
Sourcepub fn block(&self, block: NodeIndex) -> &BasicBlock
pub fn block(&self, block: NodeIndex) -> &BasicBlock
Reference to the BasicBlock with ID block
Sourcepub fn block_mut(&mut self, block: NodeIndex) -> &mut BasicBlock
pub fn block_mut(&mut self, block: NodeIndex) -> &mut BasicBlock
Reference to the BasicBlock with ID block
Sourcepub fn parse_scope(&mut self, scope: Scope) -> bool
pub fn parse_scope(&mut self, scope: Scope) -> bool
Recursively parse a scope into the graph
Sourcepub fn local_variable_id(&mut self, variable: &Variable) -> Option<Id>
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.