[Mlir-commits] [mlir] [mlir] Implement a memory-space cast bubbling-down transform (PR #159454)
Krzysztof Drewniak
llvmlistbot at llvm.org
Fri Sep 19 13:02:42 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>>",
----------------
krzysz00 wrote:
`pair(X, bool)` feels suspicious?
Are we sure this isn't `optional<value_range>`?
Or ... heck, FailureOr<ValueRange> with the semantics that, if the returned range is empty, you just erase?
Wouldn't that be a lot simpler?
https://github.com/llvm/llvm-project/pull/159454
More information about the Mlir-commits
mailing list