Skip to content

Commit 5b32aa0

Browse files
committed
Add pointer masking convenience functions
This commit adds the following functions all of which have a signature `pointer, usize -> pointer`: - `<*mut T>::mask` - `<*const T>::mask` - `intrinsics::ptr_mask` These functions are equivalent to `.map_addr(|a| a & mask)` but they utilize `llvm.ptrmask` llvm intrinsic. *masks your pointers*
1 parent ee65a10 commit 5b32aa0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Diff for: src/intrinsics/mod.rs

+7
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,13 @@ fn codegen_regular_intrinsic_call<'tcx>(
540540
ret.write_cvalue(fx, CValue::by_val(res, base.layout()));
541541
}
542542

543+
sym::ptr_mask => {
544+
intrinsic_args!(fx, args => (ptr, mask); intrinsic);
545+
let ptr_val = ptr.load_scalar(fx);
546+
547+
fx.bcx.ins().band(ptr_val, mask);
548+
}
549+
543550
sym::transmute => {
544551
intrinsic_args!(fx, args => (from); intrinsic);
545552

0 commit comments

Comments
 (0)