cranelift_codegen::ir::pcc

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