[clang] [lld] [llvm] [mlir] [IR] Introduce `T<address space>` to `DataLayout` to represent flat address space if a target supports it (PR #108786)

Nikita Popov via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 16 00:44:07 PDT 2024


================
@@ -3050,6 +3050,19 @@ as follows:
     address space 0, this property only affects the default value to be used
     when creating globals without additional contextual information (e.g. in
     LLVM passes).
+``T<address space>``
+    Specifies the address space for a target's 'flat' address space. Note this
+    is not necessarily the same as addrspace 0, which LLVM sometimes refers to
+    as the generic address space. The flat address space is a generic address
+    space that can be used access multiple segments of memory with different
+    address spaces. Access of a memory location through a pointer with this
+    address space is expected to be legal but slower compared to the same memory
+    location accessed through a pointer with a different address space. This is
+    for targets with different pointer representations which can be converted
+    with the addrspacecast instruction. If a pointer is converted to this
+    address space, optimizations should attempt to replace the access with the
+    source address space. The absence of this specification indicates the target
+    does not have such a flat address space to optimize away.
----------------
nikic wrote:

>From this description, I don't really understand what flat address space means in terms of operational semantics. To put it differently: If you had to implement support for the flat address space concept in alive2, what would you do?

Some additional questions: Can there be more than one flat address space? If you specify a flat address space, does that mean that all other address spaces are not flat, and thus cannot alias with other address spaces? (If I understand the concept correctly at all.)

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


More information about the cfe-commits mailing list