[Mlir-commits] [mlir] [mlir] Implement a memory-space cast bubbling-down transform (PR #159454)
    Fabian Mora 
    llvmlistbot at llvm.org
       
    Mon Sep 22 04:26:43 PDT 2025
    
    
  
================
@@ -0,0 +1,117 @@
+//===- MemOpInterfaces.td - Memory operation interfaces -----*- tablegen -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file contains interfaces for operations that interact with memory.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef MLIR_INTERFACES_MEMOPINTERFACES_TD
+#define MLIR_INTERFACES_MEMOPINTERFACES_TD
+
+include "mlir/IR/OpBase.td"
+include "mlir/Interfaces/SideEffectInterfaces.td"
+
+def MemorySpaceCastConsumerOpInterface :
+    OpInterface<"MemorySpaceCastConsumerOpInterface"> {
+  let description = [{
+    An interface for operations that can consume memory-space cast-like
+    operations.
+  }];
+  let cppNamespace = "::mlir";
+  let methods = [
+    InterfaceMethod<[{
+        Attempt to bubble-down the incoming cast-like operands. On success
+        returns any new results, and whether the operation was modified in
+        place, otherwise it returns failure.
+        If new results are produced, these must be compatible with the original
+        operation results.
+
+        If the operation was not modified in place, then the interface
+        guarantees it is valid to erase the original operation.
+        If the operation was modified in place, then the interface must
+        guarantee no operations were created by the method, and that no further
+        IR modification is necessary.
+
+        Any implementations of this method must not erase/replace the original
+        operation, instead it is the caller responsibility to erase or replace
+        the op with the results provided by the method.
+
+        Finally, any implementations of this method have to guarantee that the
+        IR remains valid at all times.
+      }],
+      "::llvm::FailureOr<std::pair<::llvm::SmallVector<::mlir::Value>, bool>>",
----------------
fabianmcg wrote:
The semantics of the return value is not of optional value. 
And yes, `modifiedInplace` is valuable because there's a large body of ops (load/store) where in place modification saves from creating and erasing ops.
https://github.com/llvm/llvm-project/pull/159454
    
    
More information about the Mlir-commits
mailing list