This is a POC patch implementing the low level abstractions described
in https://discourse.llvm.org/t/rfc-proper-low-level-abstractions-to-llvm-bits-bytes-addresses-and-masks/63081/13
I'm starting with primitives and tests.
I'll convert a few files to get a feel of the usability and tweak accordingly.
At this point feedback is welcome: naming, use cases, integration with other
LLVM concepts, etc...
Would it be possible to change this to masking off low bits instead of shifting? I'm not sure if this code is going to be used for actual pointers, but if it is, the current shifting pattern is incompatible with CHERI hosts such as Arm Morello. On CHERI systems, shifting a pointer will cause it to go so far out of bounds that it becomes invalidated (the bounds are encoded relative to the address and if the address goes too far out of bounds the can no longer be represented).
Also it looks like RISC-V already does this conversion from shift to mask: https://godbolt.org/z/15KfM78Tn