Skip to main content

Flags

Struct Flags 

Source
pub struct Flags(/* private fields */);
Expand description

The flags on one instruction.

A bitset rather than a struct of bools, because it rides along in the instruction table and two bytes there is two bytes per instruction in every function in the program.

Implementations§

Source§

impl Flags

Source

pub const NONE: Self

No flags, which is what -O0 and -fwrapv and a plain unsigned addition all produce.

Source

pub const NSW: Self

No signed wrap. Signed overflow is undefined, so the optimizer may assume it does not happen. -fwrapv stops the frontend setting this and nothing else changes.

Source

pub const NUW: Self

No unsigned wrap. Set only where the frontend knows it from the source, since C’s unsigned arithmetic wraps by definition and most unsigned arithmetic does not get this.

Source

pub const EXACT: Self

The shift or division is exact, so no bits are discarded and no remainder is dropped.

Source

pub const NNAN: Self

No NaN operands or results.

Source

pub const NINF: Self

No infinite operands or results.

Source

pub const NSZ: Self

The sign of a zero does not matter.

Source

pub const ARCP: Self

A division may become a multiplication by the reciprocal.

Source

pub const CONTRACT: Self

A multiplication and an addition may be contracted into one rounding.

Source

pub const REASSOC: Self

The operation may be reassociated, which is the one that changes results the most.

Source

pub const VOLATILE: Self

The access is volatile, so it happens exactly once and is never moved or merged.

Source

pub const NOALIAS: Self

The result does not alias anything else reachable, which is what restrict gives.

Source

pub const FAST: Self

Every fast-math flag, which is what -ffast-math sets on an expression.

Source

pub const fn bits(self) -> u16

The underlying bits, for the printer and for hashing an instruction.

Source

pub const fn is_empty(self) -> bool

Whether nothing is set.

Source

pub const fn contains(self, other: Self) -> bool

Whether every flag in other is set here.

Source

pub const fn union(self, other: Self) -> Self

Both sets.

Source

pub const fn intersection(self, other: Self) -> Self

The flags in both sets.

This is what a rewrite does when it replaces two instructions with one: a licence granted on one of them and not the other is not a licence over the result.

Source

pub const fn without(self, other: Self) -> Self

This set without the flags in other.

Source

pub const fn legal_on(opcode: Opcode) -> Self

The flags that mean anything on that opcode.

Anything outside this is a verifier failure rather than something ignored, because a flag on an instruction that does not read it is a flag somebody meant to put somewhere else.

Source

pub fn iter(self) -> impl Iterator<Item = (Self, &'static str)>

Every flag that is set, with its name, in the order the printer writes them.

Source

pub fn from_name(name: &str) -> Option<Self>

The flag with that name, if there is one.

Trait Implementations§

Source§

impl BitOr for Flags

Source§

type Output = Flags

The resulting type after applying the | operator.
Source§

fn bitor(self, other: Self) -> Self

Performs the | operation. Read more
Source§

impl BitOrAssign for Flags

Source§

fn bitor_assign(&mut self, other: Self)

Performs the |= operation. Read more
Source§

impl Clone for Flags

Source§

fn clone(&self) -> Flags

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Flags

Source§

impl Debug for Flags

Source§

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

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

impl Default for Flags

Source§

fn default() -> Flags

Returns the “default value” for a type. Read more
Source§

impl Display for Flags

Source§

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

The suffix form the textual IR uses, add.nsw, with a leading dot on each flag and nothing at all when the set is empty.

Source§

impl Eq for Flags

Source§

impl Hash for Flags

Source§

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

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

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

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

impl PartialEq for Flags

Source§

fn eq(&self, other: &Flags) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Flags

Auto Trait Implementations§

§

impl Freeze for Flags

§

impl RefUnwindSafe for Flags

§

impl Send for Flags

§

impl Sync for Flags

§

impl Unpin for Flags

§

impl UnsafeUnpin for Flags

§

impl UnwindSafe for Flags

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = !

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.