Struct cranelift_codegen::ir::pcc::FactContext

source ·
pub struct FactContext<'a> { /* private fields */ }
Expand description

A “context” in which we can evaluate and derive facts. This context carries environment/global properties, such as the machine pointer width.

Implementations§

source§

impl<'a> FactContext<'a>

source

pub fn new(function: &'a Function, pointer_width: u16) -> Self

Create a new “fact context” in which to evaluate facts.

source

pub fn subsumes(&self, lhs: &Fact, rhs: &Fact) -> bool

Computes whether lhs “subsumes” (implies) rhs.

source

pub fn subsumes_fact_optionals( &self, lhs: Option<&Fact>, rhs: Option<&Fact> ) -> bool

Computes whether the optional fact lhs subsumes (implies) the optional fact lhs. A None never subsumes any fact, and is always subsumed by any fact at all (or no fact).

source

pub fn add(&self, lhs: &Fact, rhs: &Fact, add_width: u16) -> Option<Fact>

Computes whatever fact can be known about the sum of two values with attached facts. The add is performed to the given bit-width. Note that this is distinct from the machine or pointer width: e.g., many 64-bit machines can still do 32-bit adds that wrap at 2^32.

source

pub fn uextend( &self, fact: &Fact, from_width: u16, to_width: u16 ) -> Option<Fact>

Computes the uextend of a value with the given facts.

source

pub fn sextend( &self, fact: &Fact, from_width: u16, to_width: u16 ) -> Option<Fact>

Computes the sextend of a value with the given facts.

source

pub fn truncate( &self, fact: &Fact, from_width: u16, to_width: u16 ) -> Option<Fact>

Computes the bit-truncation of a value with the given fact.

source

pub fn scale(&self, fact: &Fact, width: u16, factor: u32) -> Option<Fact>

Scales a value with a fact by a known constant.

source

pub fn shl(&self, fact: &Fact, width: u16, amount: u16) -> Option<Fact>

Left-shifts a value with a fact by a known constant.

source

pub fn offset(&self, fact: &Fact, width: u16, offset: i64) -> Option<Fact>

Offsets a value with a fact by a known amount.

source

pub fn struct_field<'b>( &'b self, fact: &Fact, access_ty: Type ) -> PccResult<Option<&'b MemoryTypeField>>

Get the access struct field, if any, by a pointer with the given fact and an access of the given type.

source

pub fn load<'b>( &'b self, fact: &Fact, access_ty: Type ) -> PccResult<Option<&'b Fact>>

Check a load, and determine what fact, if any, the result of the load might have.

source

pub fn store( &self, fact: &Fact, access_ty: Type, data_fact: Option<&Fact> ) -> PccResult<()>

Check a store.

source

pub fn apply_inequality( &self, fact: &Fact, lhs: &Fact, rhs: &Fact, kind: InequalityKind ) -> Fact

Apply a known inequality to rewrite dynamic bounds using transitivity, if possible.

Given that lhs >= rhs (if not strict) or lhs > rhs (if strict), update fact.

source

pub fn union(&self, lhs: &Fact, rhs: &Fact) -> Option<Fact>

Compute the union of two facts, if possible.

Auto Trait Implementations§

§

impl<'a> Freeze for FactContext<'a>

§

impl<'a> RefUnwindSafe for FactContext<'a>

§

impl<'a> Send for FactContext<'a>

§

impl<'a> Sync for FactContext<'a>

§

impl<'a> Unpin for FactContext<'a>

§

impl<'a> UnwindSafe for FactContext<'a>

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> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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.