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
impl Flags
Sourcepub const NONE: Self
pub const NONE: Self
No flags, which is what -O0 and -fwrapv and a plain unsigned addition all produce.
Sourcepub const NSW: Self
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.
Sourcepub const NUW: Self
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.
Sourcepub const EXACT: Self
pub const EXACT: Self
The shift or division is exact, so no bits are discarded and no remainder is dropped.
Sourcepub const REASSOC: Self
pub const REASSOC: Self
The operation may be reassociated, which is the one that changes results the most.
Sourcepub const VOLATILE: Self
pub const VOLATILE: Self
The access is volatile, so it happens exactly once and is never moved or merged.
Sourcepub const NOALIAS: Self
pub const NOALIAS: Self
The result does not alias anything else reachable, which is what restrict gives.
Sourcepub const NOFREE: Self
pub const NOFREE: Self
Nothing this call reaches ends the lifetime of any storage.
The nofree summary of spec/safe-memory/07-check-elimination.md section 7.5, written onto
the call site by a module-level analysis rather than by the frontend. A pass carrying what
an earlier safety check established keeps it across a call that has this and gives it up
across a call that does not.
Sourcepub const STATIC: Self
pub const STATIC: Self
The bytes this safety check is about lie inside one object of static storage duration whose extent this module knows.
Section 7.2 of spec/safe-memory/07-check-elimination.md puts the frontend first of the
four sources of a discharge, because most accesses in real C are to a local or a global at a
constant offset and how big either one is is not something anybody has to work out. The
local half is read straight off the alloca by the pass that removes the check. The global
half is this flag, because a global’s size lives on the module and a pass is given one
function, so a module-level analysis works it out before the pipeline starts and writes it
onto the check.
A fact rather than a licence, like Flags::NOFREE and unlike everything above it. It
says what is true of the bytes, and whether that is enough for the check to go is a rule.
Sourcepub const fn bits(self) -> u16
pub const fn bits(self) -> u16
The underlying bits, for the printer and for hashing an instruction.
Sourcepub const fn intersection(self, other: Self) -> Self
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.
Sourcepub const fn legal_on(opcode: Opcode) -> Self
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.
Trait Implementations§
Source§impl BitOrAssign for Flags
impl BitOrAssign for Flags
Source§fn bitor_assign(&mut self, other: Self)
fn bitor_assign(&mut self, other: Self)
|= operation. Read more