Author: Mehdi Amini Date: 2025-09-11T10:25:36+01:00 New Revision: 1e192c006bf978fad12dbc4bba8c6213b6b9c907
URL: https://github.com/llvm/llvm-project/commit/1e192c006bf978fad12dbc4bba8c6213b6b9c907 DIFF: https://github.com/llvm/llvm-project/commit/1e192c006bf978fad12dbc4bba8c6213b6b9c907.diff LOG: Revert "[MLIR] Remove CopyOpInterface (#157711)" This reverts commit 63647074ba97dc606c7ba48c3800ec08ca501d92. Added: mlir/include/mlir/Interfaces/CopyOpInterface.h mlir/include/mlir/Interfaces/CopyOpInterface.td mlir/lib/Interfaces/CopyOpInterface.cpp Modified: mlir/include/mlir/Dialect/Bufferization/IR/Bufferization.h mlir/include/mlir/Dialect/Bufferization/IR/BufferizationOps.td mlir/include/mlir/Dialect/Linalg/IR/Linalg.h mlir/include/mlir/Dialect/MemRef/IR/MemRef.h mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td mlir/include/mlir/Interfaces/CMakeLists.txt mlir/lib/Interfaces/CMakeLists.txt mlir/test/lib/Dialect/Test/TestDialect.h mlir/test/lib/Dialect/Test/TestOps.h mlir/test/lib/Dialect/Test/TestOps.td Removed: ################################################################################ diff --git a/mlir/include/mlir/Dialect/Bufferization/IR/Bufferization.h b/mlir/include/mlir/Dialect/Bufferization/IR/Bufferization.h index e735651d5366d..1ef5370802953 100644 --- a/mlir/include/mlir/Dialect/Bufferization/IR/Bufferization.h +++ b/mlir/include/mlir/Dialect/Bufferization/IR/Bufferization.h @@ -12,6 +12,7 @@ #include "mlir/Bytecode/BytecodeOpInterface.h" #include "mlir/Dialect/Bufferization/IR/AllocationOpInterface.h" #include "mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h" +#include "mlir/Interfaces/CopyOpInterface.h" #include "mlir/Interfaces/DestinationStyleOpInterface.h" #include "mlir/Interfaces/InferTypeOpInterface.h" #include "mlir/Interfaces/SubsetOpInterface.h" diff --git a/mlir/include/mlir/Dialect/Bufferization/IR/BufferizationOps.td b/mlir/include/mlir/Dialect/Bufferization/IR/BufferizationOps.td index 6724d4c483101..271b42025e0af 100644 --- a/mlir/include/mlir/Dialect/Bufferization/IR/BufferizationOps.td +++ b/mlir/include/mlir/Dialect/Bufferization/IR/BufferizationOps.td @@ -18,6 +18,7 @@ include "mlir/Interfaces/DestinationStyleOpInterface.td" include "mlir/Interfaces/InferTypeOpInterface.td" include "mlir/Interfaces/SideEffectInterfaces.td" include "mlir/Interfaces/SubsetOpInterface.td" +include "mlir/Interfaces/CopyOpInterface.td" class Bufferization_Op<string mnemonic, list<Trait> traits = []> : Op<Bufferization_Dialect, mnemonic, traits>; @@ -170,6 +171,7 @@ def Bufferization_AllocTensorOp : Bufferization_Op<"alloc_tensor", //===----------------------------------------------------------------------===// def Bufferization_CloneOp : Bufferization_Op<"clone", [ + CopyOpInterface, MemoryEffectsOpInterface, DeclareOpInterfaceMethods<AllocationOpInterface, ["buildDealloc", "buildClone"]> ]> { diff --git a/mlir/include/mlir/Dialect/Linalg/IR/Linalg.h b/mlir/include/mlir/Dialect/Linalg/IR/Linalg.h index 9de6d8fd50983..eb4e3810f0d07 100644 --- a/mlir/include/mlir/Dialect/Linalg/IR/Linalg.h +++ b/mlir/include/mlir/Dialect/Linalg/IR/Linalg.h @@ -22,6 +22,7 @@ #include "mlir/IR/ImplicitLocOpBuilder.h" #include "mlir/IR/TypeUtilities.h" #include "mlir/Interfaces/ControlFlowInterfaces.h" +#include "mlir/Interfaces/CopyOpInterface.h" #include "mlir/Interfaces/DestinationStyleOpInterface.h" #include "mlir/Interfaces/InferTypeOpInterface.h" #include "mlir/Interfaces/SideEffectInterfaces.h" diff --git a/mlir/include/mlir/Dialect/MemRef/IR/MemRef.h b/mlir/include/mlir/Dialect/MemRef/IR/MemRef.h index bdec699eb4ce4..ac383ab46e7a5 100644 --- a/mlir/include/mlir/Dialect/MemRef/IR/MemRef.h +++ b/mlir/include/mlir/Dialect/MemRef/IR/MemRef.h @@ -16,6 +16,7 @@ #include "mlir/Interfaces/CallInterfaces.h" #include "mlir/Interfaces/CastInterfaces.h" #include "mlir/Interfaces/ControlFlowInterfaces.h" +#include "mlir/Interfaces/CopyOpInterface.h" #include "mlir/Interfaces/InferIntRangeInterface.h" #include "mlir/Interfaces/InferTypeOpInterface.h" #include "mlir/Interfaces/MemorySlotInterfaces.h" diff --git a/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td b/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td index 513a9a18198a3..d6b7a97179b71 100644 --- a/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td +++ b/mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td @@ -13,6 +13,7 @@ include "mlir/Dialect/Arith/IR/ArithBase.td" include "mlir/Dialect/MemRef/IR/MemRefBase.td" include "mlir/Interfaces/CastInterfaces.td" include "mlir/Interfaces/ControlFlowInterfaces.td" +include "mlir/Interfaces/CopyOpInterface.td" include "mlir/Interfaces/InferIntRangeInterface.td" include "mlir/Interfaces/InferTypeOpInterface.td" include "mlir/Interfaces/MemorySlotInterfaces.td" @@ -529,7 +530,7 @@ def MemRef_CastOp : MemRef_Op<"cast", [ // CopyOp //===----------------------------------------------------------------------===// -def CopyOp : MemRef_Op<"copy", [SameOperandsElementType, +def CopyOp : MemRef_Op<"copy", [CopyOpInterface, SameOperandsElementType, SameOperandsShape]> { let description = [{ diff --git a/mlir/include/mlir/Interfaces/CMakeLists.txt b/mlir/include/mlir/Interfaces/CMakeLists.txt index 2add220fdfb7c..20cc2674d6fbc 100644 --- a/mlir/include/mlir/Interfaces/CMakeLists.txt +++ b/mlir/include/mlir/Interfaces/CMakeLists.txt @@ -1,6 +1,7 @@ add_mlir_interface(CallInterfaces) add_mlir_interface(CastInterfaces) add_mlir_interface(ControlFlowInterfaces) +add_mlir_interface(CopyOpInterface) add_mlir_interface(DerivedAttributeOpInterface) add_mlir_interface(DestinationStyleOpInterface) add_mlir_interface(FunctionInterfaces) diff --git a/mlir/include/mlir/Interfaces/CopyOpInterface.h b/mlir/include/mlir/Interfaces/CopyOpInterface.h new file mode 100644 index 0000000000000..2f38eb326b53e --- /dev/null +++ b/mlir/include/mlir/Interfaces/CopyOpInterface.h @@ -0,0 +1,21 @@ +//===- CopyOpInterface.h - copy operations interface ----------------------===// +// +// 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 implements the operation interface for copy-like operations. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_INTERFACES_COPYOPINTERFACE_H_ +#define MLIR_INTERFACES_COPYOPINTERFACE_H_ + +#include "mlir/IR/OpDefinition.h" + +/// Include the generated interface declarations. +#include "mlir/Interfaces/CopyOpInterface.h.inc" + +#endif // MLIR_INTERFACES_COPYOPINTERFACE_H_ diff --git a/mlir/include/mlir/Interfaces/CopyOpInterface.td b/mlir/include/mlir/Interfaces/CopyOpInterface.td new file mode 100644 index 0000000000000..f6c5a6f8bb810 --- /dev/null +++ b/mlir/include/mlir/Interfaces/CopyOpInterface.td @@ -0,0 +1,38 @@ +//===- CopyOpInterface.td - Copy operation interface -------*- 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 +// +//===----------------------------------------------------------------------===// +// +// Defines the interface for copy-like operations. +// +//===----------------------------------------------------------------------===// + +#ifndef MLIR_INTERFACES_COPYOPINTERFACE +#define MLIR_INTERFACES_COPYOPINTERFACE + +include "mlir/IR/OpBase.td" + +def CopyOpInterface : OpInterface<"CopyOpInterface"> { + let description = [{ + A copy-like operation is one that copies from source value to target value. + }]; + let cppNamespace = "::mlir"; + + let methods = [ + InterfaceMethod< + /*desc=*/"Returns the source value for this copy operation", + /*retTy=*/"::mlir::Value", + /*methodName=*/"getSource" + >, + InterfaceMethod< + /*desc=*/"Returns the target value for this copy operation", + /*retTy=*/"::mlir::Value", + /*methodName=*/"getTarget" + > + ]; +} + +#endif // MLIR_INTERFACES_COPYOPINTERFACE diff --git a/mlir/lib/Interfaces/CMakeLists.txt b/mlir/lib/Interfaces/CMakeLists.txt index fdc19844702bc..af923d98c76ff 100644 --- a/mlir/lib/Interfaces/CMakeLists.txt +++ b/mlir/lib/Interfaces/CMakeLists.txt @@ -2,6 +2,7 @@ set(LLVM_OPTIONAL_SOURCES CallInterfaces.cpp CastInterfaces.cpp ControlFlowInterfaces.cpp + CopyOpInterface.cpp DataLayoutInterfaces.cpp DerivedAttributeOpInterface.cpp DestinationStyleOpInterface.cpp @@ -42,6 +43,7 @@ endfunction(add_mlir_interface_library) add_mlir_interface_library(CallInterfaces) add_mlir_interface_library(CastInterfaces) add_mlir_interface_library(ControlFlowInterfaces) +add_mlir_interface_library(CopyOpInterface) add_mlir_interface_library(DataLayoutInterfaces) add_mlir_interface_library(DerivedAttributeOpInterface) add_mlir_interface_library(DestinationStyleOpInterface) diff --git a/mlir/lib/Interfaces/CopyOpInterface.cpp b/mlir/lib/Interfaces/CopyOpInterface.cpp new file mode 100644 index 0000000000000..8e6132ca14e91 --- /dev/null +++ b/mlir/lib/Interfaces/CopyOpInterface.cpp @@ -0,0 +1,18 @@ +//===- CopyOpInterface.cpp - Copy operations interface in MLIR ------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "mlir/Interfaces/CopyOpInterface.h" + +using namespace mlir; + +//===----------------------------------------------------------------------===// +// CopyOp Interface +//===----------------------------------------------------------------------===// + +/// Include the definitions of the copy operation interface. +#include "mlir/Interfaces/CopyOpInterface.cpp.inc" diff --git a/mlir/test/lib/Dialect/Test/TestDialect.h b/mlir/test/lib/Dialect/Test/TestDialect.h index f2adca6310d78..c05e15fc642a2 100644 --- a/mlir/test/lib/Dialect/Test/TestDialect.h +++ b/mlir/test/lib/Dialect/Test/TestDialect.h @@ -35,6 +35,7 @@ #include "mlir/IR/SymbolTable.h" #include "mlir/Interfaces/CallInterfaces.h" #include "mlir/Interfaces/ControlFlowInterfaces.h" +#include "mlir/Interfaces/CopyOpInterface.h" #include "mlir/Interfaces/DerivedAttributeOpInterface.h" #include "mlir/Interfaces/InferIntRangeInterface.h" #include "mlir/Interfaces/InferTypeOpInterface.h" diff --git a/mlir/test/lib/Dialect/Test/TestOps.h b/mlir/test/lib/Dialect/Test/TestOps.h index 4201ade9795e7..b414b47c87425 100644 --- a/mlir/test/lib/Dialect/Test/TestOps.h +++ b/mlir/test/lib/Dialect/Test/TestOps.h @@ -33,6 +33,7 @@ #include "mlir/IR/SymbolTable.h" #include "mlir/Interfaces/CallInterfaces.h" #include "mlir/Interfaces/ControlFlowInterfaces.h" +#include "mlir/Interfaces/CopyOpInterface.h" #include "mlir/Interfaces/DerivedAttributeOpInterface.h" #include "mlir/Interfaces/InferIntRangeInterface.h" #include "mlir/Interfaces/InferTypeOpInterface.h" diff --git a/mlir/test/lib/Dialect/Test/TestOps.td b/mlir/test/lib/Dialect/Test/TestOps.td index 5564264ed8b0b..231400ec9cd29 100644 --- a/mlir/test/lib/Dialect/Test/TestOps.td +++ b/mlir/test/lib/Dialect/Test/TestOps.td @@ -23,6 +23,7 @@ include "mlir/IR/RegionKindInterface.td" include "mlir/IR/SymbolInterfaces.td" include "mlir/Interfaces/CallInterfaces.td" include "mlir/Interfaces/ControlFlowInterfaces.td" +include "mlir/Interfaces/CopyOpInterface.td" include "mlir/Interfaces/DataLayoutInterfaces.td" include "mlir/Interfaces/DestinationStyleOpInterface.td" include "mlir/Interfaces/InferIntRangeInterface.td" @@ -2321,10 +2322,10 @@ def SideEffectWithRegionOp : TEST_Op<"side_effect_with_region_op", } //===----------------------------------------------------------------------===// -// Copy Operation Test +// Test CopyOpInterface //===----------------------------------------------------------------------===// -def CopyOp : TEST_Op<"copy", []> { +def CopyOp : TEST_Op<"copy", [CopyOpInterface]> { let description = [{ Represents a copy operation. }]; _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits