diff options
author | Alexander Richardson <alexrichardson@google.com> | 2025-05-16 10:04:00 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-16 10:04:00 -0700 |
commit | aec685ea77e97bcc6892b12e970857fb1b049528 (patch) | |
tree | 36fb9dc1dd61310f92f4010ccd30d03aabd65709 /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | e620f10f57bf698b7446f134528bb2585fdf1f28 (diff) | |
download | llvm-aec685ea77e97bcc6892b12e970857fb1b049528.zip llvm-aec685ea77e97bcc6892b12e970857fb1b049528.tar.gz llvm-aec685ea77e97bcc6892b12e970857fb1b049528.tar.bz2 |
[DataLayout] Introduce DataLayout::getAddressSize(AS)
This function can be used to retrieve the number of bits that can be used
for arithmetic in a given address space (i.e. the range of the address
space). For most in-tree targets this should not make any difference
but differentiating between the size of a pointer in bits and the address
range is extremely important e.g. for CHERI-enabled targets, where pointers
carry additional metadata such as bounds and permissions and only a subset
of the pointer bits is used as the address.
The address size is defined to be the same as the index size.
We considered adding a separate property since targets exist where indexing
and address range actually use different sizes (AMDGPU fat pointers with
160 representation, 48 bit address and 32 bit index), but for the purposes
of LLVM semantics, differentiating them does not add much value and it
introduces a lot of complexity in ensure the correct bits are used. See
the reasoning by @nikic on https://discourse.llvm.org/t/clarifiying-the-semantics-of-ptrtoint/83987/38https://discourse.llvm.org/t/clarifiying-the-semantics-of-ptrtoint/83987/49
Originally uploaded as https://reviews.llvm.org/D135158
Reviewed By: davidchisnall, krzysz00
Pull Request: https://github.com/llvm/llvm-project/pull/139347
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
0 files changed, 0 insertions, 0 deletions