Skip to main content

CSEPass

Struct CSEPass 

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

Common Subexpression Elimination pass.

Usage:

use oxilean_codegen::opt_cse::{CSEPass, CseConfig};
let mut pass = CSEPass::new(CseConfig::default());
// pass.run(&mut decls);

Implementations§

Source§

impl CSEPass

Source

pub fn new(config: CseConfig) -> Self

Create a new CSE pass with the given configuration.

Source

pub fn run(&mut self, decls: &mut [LcnfFunDecl])

Run CSE over all function declarations, modifying them in place.

Source

pub fn global_cse(&mut self, decl: &LcnfFunDecl) -> LcnfFunDecl

Perform CSE on a single function declaration.

Source

pub fn local_cse(&mut self, expr: &LcnfExpr) -> LcnfExpr

Perform local CSE on a single expression (no cross-branch sharing).

Source

pub fn hash_expr(&self, value: &LcnfLetValue) -> Option<ExprKey>

Compute the canonical hash key for a let-bound value.

Source

pub fn find_available( &self, avail: &AvailableSet, value: &LcnfLetValue, ) -> Option<LcnfVarId>

Look up expr in the available set.

Source

pub fn report(&self) -> CseReport

Return the accumulated CSE report.

Trait Implementations§

Source§

impl Default for CSEPass

Source§

fn default() -> Self

Returns the “default value” for a 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<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.