[llvm] [CHERI] Add a Support utility for determining alignment requirements of CHERI capabilities. (PR #197402)

Jessica Clarke via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 6 12:03:36 PDT 2026


================

----------------
jrtc27 wrote:

Would something like:
```
unsigned E;
if (Length > 511ULL << 14) {
  E = 24;
} else {
  E = 64 - countLeadingZeros64(Length);
  if (Length > 511ULL << E)
    ++E;

  assert(E <= 14 && "...");
}
return CHERIoTCapabilityFormat::AddressMask << E;
```
not be equivalent and avoid the need to loop 14 times?
(also ...ULL should probably be using UINT64_C(...))

https://github.com/llvm/llvm-project/pull/197402


More information about the llvm-commits mailing list