[PATCH] D135158: [DataLayout] Introduce DataLayout::getPointerIntegralSize(AS)

Alexander Richardson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 4 07:32:09 PDT 2022


arichardson created this revision.
arichardson added reviewers: nikic, theraven, jrtc27, reames, mkazantsev.
Herald added subscribers: jdoerfert, hiraditya.
Herald added a project: All.
arichardson requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This function can be used to retried 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 (all?) 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. This could also benefit other
users of non-integral pointers but I am not familiar with any of those
backends. In the out-of-tree CHERI target, we use the index width of the
datalayout to identify the address range, but based on feedback on other
reviews (e.g. https://reviews.llvm.org/D99660), I decided to add an
explicit new field to the DataLayout that encodes the integral range.

I am not sure if getPointerIntegralSize() is the best name for this
accessor, I also considered names such as getPointerArithmenticRange or
getPointerAddressRange().

In the future it may also be possible to define isNonIntegralAddressSpace as `getPointerIntegralSize() != getPointerSize()`, but I am not sure if that would actually hold for all uses of non-integral pointers (I think in some cases all bits are arithmetically meaningful, but the representation can change at any time?)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135158

Files:
  llvm/docs/LangRef.rst
  llvm/include/llvm/IR/DataLayout.h
  llvm/lib/IR/DataLayout.cpp
  llvm/test/Assembler/invalid-datalayout25.ll
  llvm/test/Assembler/invalid-datalayout26.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135158.465008.patch
Type: text/x-patch
Size: 9642 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221004/4820a16d/attachment.bin>


More information about the llvm-commits mailing list