Factor out a MemFlags constructor for trusted notrap/aligned accesses.
This commit is contained in:
@@ -26,6 +26,15 @@ impl MemFlags {
|
||||
Self { bits: 0 }
|
||||
}
|
||||
|
||||
/// Create a set of flags representing an access from a "trusted" address, meaning it's
|
||||
/// known to be aligned and non-trapping.
|
||||
pub fn trusted() -> Self {
|
||||
let mut result = Self::new();
|
||||
result.set_notrap();
|
||||
result.set_aligned();
|
||||
result
|
||||
}
|
||||
|
||||
/// Read a flag bit.
|
||||
fn read(self, bit: FlagBit) -> bool {
|
||||
self.bits & (1 << bit as usize) != 0
|
||||
|
||||
@@ -110,9 +110,7 @@ fn load_addr(
|
||||
};
|
||||
|
||||
// Global-value loads are always notrap and aligned. They may be readonly.
|
||||
let mut mflags = ir::MemFlags::new();
|
||||
mflags.set_notrap();
|
||||
mflags.set_aligned();
|
||||
let mut mflags = ir::MemFlags::trusted();
|
||||
if readonly {
|
||||
mflags.set_readonly();
|
||||
}
|
||||
|
||||
@@ -400,10 +400,8 @@ fn expand_stack_load(
|
||||
|
||||
let addr = pos.ins().stack_addr(addr_ty, stack_slot, offset);
|
||||
|
||||
let mut mflags = MemFlags::new();
|
||||
// Stack slots are required to be accessible and aligned.
|
||||
mflags.set_notrap();
|
||||
mflags.set_aligned();
|
||||
let mflags = MemFlags::trusted();
|
||||
pos.func.dfg.replace(inst).load(ty, mflags, addr, 0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user