[all-commits] [llvm/llvm-project] aec685: [DataLayout] Introduce DataLayout::getAddressSize(AS)

Alexander Richardson via All-commits all-commits at lists.llvm.org
Fri May 16 10:04:22 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: aec685ea77e97bcc6892b12e970857fb1b049528
      https://github.com/llvm/llvm-project/commit/aec685ea77e97bcc6892b12e970857fb1b049528
  Author: Alexander Richardson <alexrichardson at google.com>
  Date:   2025-05-16 (Fri, 16 May 2025)

  Changed paths:
    M llvm/docs/LangRef.rst
    M llvm/include/llvm/IR/DataLayout.h

  Log Message:
  -----------
  [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



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list