[Mlir-commits] [mlir] [mlir][amdgpu] Add make_dma_base operation (PR #169086)

Erick Ochoa Lopez llvmlistbot at llvm.org
Fri Nov 21 11:51:35 PST 2025


================
@@ -79,6 +80,36 @@ def AMDGPU_AddressSpaceAttr : EnumAttr<AMDGPU_Dialect, AMDGPU_AddressSpace,
   let assemblyFormat = "`<` $value `>`";
 }
 
+class AMDGPU_Type<string name, string typeMnemonic, list<Trait> traits = []>
+    : TypeDef<AMDGPU_Dialect, name, traits> {
+  let mnemonic = typeMnemonic;
+}
+
+//===----------------------------------------------------------------------===//
+// AMDGPU Type definitions
+//===----------------------------------------------------------------------===//
+
+def AMDGPU_TDMBaseType : AMDGPU_Type<"TDMBase", "tdm_base"> {
+  // TODO:
+  // * Add verifiers such that one of the memrefs is from LDS and the other global.
+  // * Add verifiers to make sure that the type is in the correct direction.
+  // * Add verifiers to make sure that the number of indices do not exceed the number of dimensions.
+
+  let summary = "Pair of base addresses that move data between LDS and global storage.";
+  let description = [{
+    This type is opaque and it is used to represent a struct of two addresses.
+    One address is in LDS while the other is in global memory.
+  }];
+  let parameters = (ins "Type":$elementType);
+  let builders = [
+    TypeBuilderWithInferredContext<(ins "Type":$elementType), [{
+      return $_get(elementType.getContext(), elementType);
+    }]>
+  ];
+  let assemblyFormat = "`<` $elementType `>`";
----------------
amd-eochoalo wrote:

@krzysz00 

One suggestion I have that differs from your proposal is to encode in this type the direction of memory. If this type has `#gpu.address_space<workgroup>` then it is loading data to LDS. Without it is is storing data from LDS.

Without this, there is the possibility of a program compiling with logic errors where a value that was obtained from the `make_dma_base` operation for storing data from LDS could be used to load data to LDS.

With the type, we can make sure that only values that are properly constructed would flow to the appropriate operations.

```suggestion
  let assemblyFormat = "`<` $elementType `,` $memorySpace `>`";
```

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


More information about the Mlir-commits mailing list