[Mlir-commits] [mlir] [mlir][ptr] Add the `ptradd` and `type_offset` ops, and `int_space` attr (PR #136434)

Mehdi Amini llvmlistbot at llvm.org
Sun Apr 20 05:01:10 PDT 2025


================
@@ -20,6 +21,38 @@ class Ptr_Attr<string name, string attrMnemonic,
   let mnemonic = attrMnemonic;
 }
 
+//===----------------------------------------------------------------------===//
+// IAddressSpaceAttr
+//===----------------------------------------------------------------------===//
+
+def Ptr_IAddressSpaceAttr :
+    Ptr_Attr<"IAddressSpace", "int_space", [
+      DeclareAttrInterfaceMethods<MemorySpaceAttrInterface>
+    ]> {
+  let summary = "Int memory space";
+  let description = [{
+    The `int_as` attribute defines a memory space attribute with the following
+    properties:
+    - Load and store operations are always valid, regardless of the type.
+    - Atomic operations are always valid, regardless of the type.
+    - Cast operations are valid between pointers with `int_space` memory space,
+    or between non-scalable `vector` of pointers with `int_space` memory space.
+
+    The default address spaces is 0.
+
+    Example:
+
+    ```mlir
+    // Default address space: 0.
+    #ptr.int_space
+    // Address space 3.
+    #ptr.int_space<3>
+    ```
+  }];
+  let parameters = (ins DefaultValuedParameter<"int64_t", "0">:$value);
+  let assemblyFormat = "(`<` $value^ `>`)?";
+}
----------------
joker-eph wrote:

Why this "int memory space"? Could we avoid doing anything special about "integer" (and discourage these instead).
We introduced DeviceMappingAttrInterface to be able for it to be possible I believe.

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


More information about the Mlir-commits mailing list