Struct cranelift_codegen::ir::MemFlags
source · pub struct MemFlags { /* private fields */ }
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.
Implementations§
source§impl MemFlags
impl MemFlags
sourcepub fn trusted() -> Self
pub fn trusted() -> Self
Create a set of flags representing an access from a “trusted” address, meaning it’s known to be aligned and non-trapping.
sourcepub fn set_by_name(&mut self, name: &str) -> bool
pub fn set_by_name(&mut self, name: &str) -> bool
Set a flag bit by name.
Returns true if the flag was found and set, false for an unknown flag name.
sourcepub fn notrap(self) -> bool
pub fn notrap(self) -> bool
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.
sourcepub fn set_notrap(&mut self)
pub fn set_notrap(&mut self)
Set the notrap
flag.
sourcepub fn aligned(self) -> bool
pub fn aligned(self) -> bool
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.
sourcepub fn set_aligned(&mut self)
pub fn set_aligned(&mut self)
Set the aligned
flag.
sourcepub fn readonly(self) -> bool
pub fn readonly(self) -> bool
Test if the readonly
flag is set.
Loads with this flag have no memory dependendies. This results in indefined behavior if the dereferenced memory is mutated at any time between when the function is called and when it is exited.
sourcepub fn set_readonly(&mut self)
pub fn set_readonly(&mut self)
Set the readonly
flag.