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*
This commit is contained in:
Maybe Waffle 2022-05-11 17:52:00 +04:00
parent ee65a1018f
commit 5b32aa0747

View File

@ -540,6 +540,13 @@ fn codegen_regular_intrinsic_call<'tcx>(
ret.write_cvalue(fx, CValue::by_val(res, base.layout()));
}
sym::ptr_mask => {
intrinsic_args!(fx, args => (ptr, mask); intrinsic);
let ptr_val = ptr.load_scalar(fx);
fx.bcx.ins().band(ptr_val, mask);
}
sym::transmute => {
intrinsic_args!(fx, args => (from); intrinsic);