Struct cranelift_codegen::ir::MemFlags[][src]

pub struct MemFlags { /* fields omitted */ }
Expand description

Flags for memory operations like load/store.

Each of these flags introduce a limited form of undefined behavior. The flags each enable certain optimizations that need to make additional assumptions. Generally, the semantics of a program does not change when a flag is removed, but adding a flag will.

In addition, the flags determine the endianness of the memory access. By default, any memory access uses the native endianness determined by the target ISA. This can be overridden for individual accesses by explicitly specifying little- or big-endian semantics via the flags.

Implementations

impl MemFlags[src]

pub fn new() -> Self[src]

Create a new empty set of flags.

pub fn trusted() -> Self[src]

Create a set of flags representing an access from a “trusted” address, meaning it’s known to be aligned and non-trapping.

pub fn set_by_name(&mut self, name: &str) -> bool[src]

Set a flag bit by name.

Returns true if the flag was found and set, false for an unknown flag name. Will also return false when trying to set inconsistent endianness flags.

pub fn endianness(self, native_endianness: Endianness) -> Endianness[src]

Return endianness of the memory access. This will return the endianness explicitly specified by the flags if any, and will default to the native endianness otherwise. The native endianness has to be provided by the caller since it is not explicitly encoded in CLIF IR – this allows a front end to create IR without having to know the target endianness.

pub fn set_endianness(&mut self, endianness: Endianness)[src]

Set endianness of the memory access.

pub fn notrap(self) -> bool[src]

Test if the notrap flag is set.

Normally, trapping is part of the semantics of a load/store operation. If the platform would cause a trap when accessing the effective address, the Cranelift memory operation is also required to trap.

The notrap flag tells Cranelift that the memory is accessible, which means that accesses will not trap. This makes it possible to delete an unused load or a dead store instruction.

pub fn set_notrap(&mut self)[src]

Set the notrap flag.

pub fn aligned(self) -> bool[src]

Test if the aligned flag is set.

By default, Cranelift memory instructions work with any unaligned effective address. If the aligned flag is set, the instruction is permitted to trap or return a wrong result if the effective address is misaligned.

pub fn set_aligned(&mut self)[src]

Set the aligned flag.

pub fn readonly(self) -> bool[src]

Test if the readonly flag is set.

Loads with this flag have no memory dependencies. This results in undefined behavior if the dereferenced memory is mutated at any time between when the function is called and when it is exited.

pub fn set_readonly(&mut self)[src]

Set the readonly flag.

Trait Implementations

impl Clone for MemFlags[src]

fn clone(&self) -> MemFlags[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for MemFlags[src]

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

Formats the value using the given formatter. Read more

impl Display for MemFlags[src]

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

Formats the value using the given formatter. Read more

impl Hash for MemFlags[src]

fn hash<__H: Hasher>(&self, state: &mut __H)[src]

Feeds this value into the given Hasher. Read more

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given Hasher. Read more

impl PartialEq<MemFlags> for MemFlags[src]

fn eq(&self, other: &MemFlags) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &MemFlags) -> bool[src]

This method tests for !=.

impl Copy for MemFlags[src]

impl Eq for MemFlags[src]

impl StructuralEq for MemFlags[src]

impl StructuralPartialEq for MemFlags[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

pub fn equivalent(&self, key: &K) -> bool[src]

Compare self to key and return true if they are equal.

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T> ToString for T where
    T: Display + ?Sized
[src]

pub default fn to_string(&self) -> String[src]

Converts the given value to a String. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.