Skip to main content

CCPState

Struct CCPState 

Source
pub struct CCPState {
    pub known: HashMap<LcnfVarId, KnownConstant>,
    pub folded: usize,
    pub dead_branches: usize,
}
Expand description

State for Conditional Constant Propagation integrated with GVN.

CCP tracks which variables have statically-known values and uses this information to fold conditions and eliminate dead branches.

Fields§

§known: HashMap<LcnfVarId, KnownConstant>

Map from variable to its known constant value.

§folded: usize

Number of constants folded.

§dead_branches: usize

Number of dead branches eliminated.

Implementations§

Source§

impl CCPState

Source

pub fn new() -> Self

Source

pub fn set_known(&mut self, var: LcnfVarId, val: KnownConstant)

Source

pub fn get_known(&self, var: &LcnfVarId) -> &KnownConstant

Source

pub fn run(&mut self, decl: &mut LcnfFunDecl)

Run CCP on a function declaration, folding constants and removing dead branches.

Trait Implementations§

Source§

impl Debug for CCPState

Source§

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

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

impl Default for CCPState

Source§

fn default() -> CCPState

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.