Skip to content

Commit 1e192c0

Browse files
authored
Revert "[MLIR] Remove CopyOpInterface (#157711)"
This reverts commit 6364707.
1 parent 30f9fb7 commit 1e192c0

File tree

13 files changed

+92
-3
lines changed

13 files changed

+92
-3
lines changed

mlir/include/mlir/Dialect/Bufferization/IR/Bufferization.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "mlir/Bytecode/BytecodeOpInterface.h"
1313
#include "mlir/Dialect/Bufferization/IR/AllocationOpInterface.h"
1414
#include "mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h"
15+
#include "mlir/Interfaces/CopyOpInterface.h"
1516
#include "mlir/Interfaces/DestinationStyleOpInterface.h"
1617
#include "mlir/Interfaces/InferTypeOpInterface.h"
1718
#include "mlir/Interfaces/SubsetOpInterface.h"

mlir/include/mlir/Dialect/Bufferization/IR/BufferizationOps.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ include "mlir/Interfaces/DestinationStyleOpInterface.td"
1818
include "mlir/Interfaces/InferTypeOpInterface.td"
1919
include "mlir/Interfaces/SideEffectInterfaces.td"
2020
include "mlir/Interfaces/SubsetOpInterface.td"
21+
include "mlir/Interfaces/CopyOpInterface.td"
2122

2223
class Bufferization_Op<string mnemonic, list<Trait> traits = []>
2324
: Op<Bufferization_Dialect, mnemonic, traits>;
@@ -170,6 +171,7 @@ def Bufferization_AllocTensorOp : Bufferization_Op<"alloc_tensor",
170171
//===----------------------------------------------------------------------===//
171172

172173
def Bufferization_CloneOp : Bufferization_Op<"clone", [
174+
CopyOpInterface,
173175
MemoryEffectsOpInterface,
174176
DeclareOpInterfaceMethods<AllocationOpInterface, ["buildDealloc", "buildClone"]>
175177
]> {

mlir/include/mlir/Dialect/Linalg/IR/Linalg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "mlir/IR/ImplicitLocOpBuilder.h"
2323
#include "mlir/IR/TypeUtilities.h"
2424
#include "mlir/Interfaces/ControlFlowInterfaces.h"
25+
#include "mlir/Interfaces/CopyOpInterface.h"
2526
#include "mlir/Interfaces/DestinationStyleOpInterface.h"
2627
#include "mlir/Interfaces/InferTypeOpInterface.h"
2728
#include "mlir/Interfaces/SideEffectInterfaces.h"

mlir/include/mlir/Dialect/MemRef/IR/MemRef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "mlir/Interfaces/CallInterfaces.h"
1717
#include "mlir/Interfaces/CastInterfaces.h"
1818
#include "mlir/Interfaces/ControlFlowInterfaces.h"
19+
#include "mlir/Interfaces/CopyOpInterface.h"
1920
#include "mlir/Interfaces/InferIntRangeInterface.h"
2021
#include "mlir/Interfaces/InferTypeOpInterface.h"
2122
#include "mlir/Interfaces/MemorySlotInterfaces.h"

mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ include "mlir/Dialect/Arith/IR/ArithBase.td"
1313
include "mlir/Dialect/MemRef/IR/MemRefBase.td"
1414
include "mlir/Interfaces/CastInterfaces.td"
1515
include "mlir/Interfaces/ControlFlowInterfaces.td"
16+
include "mlir/Interfaces/CopyOpInterface.td"
1617
include "mlir/Interfaces/InferIntRangeInterface.td"
1718
include "mlir/Interfaces/InferTypeOpInterface.td"
1819
include "mlir/Interfaces/MemorySlotInterfaces.td"
@@ -529,7 +530,7 @@ def MemRef_CastOp : MemRef_Op<"cast", [
529530
// CopyOp
530531
//===----------------------------------------------------------------------===//
531532

532-
def CopyOp : MemRef_Op<"copy", [SameOperandsElementType,
533+
def CopyOp : MemRef_Op<"copy", [CopyOpInterface, SameOperandsElementType,
533534
SameOperandsShape]> {
534535

535536
let description = [{

mlir/include/mlir/Interfaces/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
add_mlir_interface(CallInterfaces)
22
add_mlir_interface(CastInterfaces)
33
add_mlir_interface(ControlFlowInterfaces)
4+
add_mlir_interface(CopyOpInterface)
45
add_mlir_interface(DerivedAttributeOpInterface)
56
add_mlir_interface(DestinationStyleOpInterface)
67
add_mlir_interface(FunctionInterfaces)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//===- CopyOpInterface.h - copy operations interface ----------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file implements the operation interface for copy-like operations.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef MLIR_INTERFACES_COPYOPINTERFACE_H_
14+
#define MLIR_INTERFACES_COPYOPINTERFACE_H_
15+
16+
#include "mlir/IR/OpDefinition.h"
17+
18+
/// Include the generated interface declarations.
19+
#include "mlir/Interfaces/CopyOpInterface.h.inc"
20+
21+
#endif // MLIR_INTERFACES_COPYOPINTERFACE_H_
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//===- CopyOpInterface.td - Copy operation interface -------*- tablegen -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// Defines the interface for copy-like operations.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef MLIR_INTERFACES_COPYOPINTERFACE
14+
#define MLIR_INTERFACES_COPYOPINTERFACE
15+
16+
include "mlir/IR/OpBase.td"
17+
18+
def CopyOpInterface : OpInterface<"CopyOpInterface"> {
19+
let description = [{
20+
A copy-like operation is one that copies from source value to target value.
21+
}];
22+
let cppNamespace = "::mlir";
23+
24+
let methods = [
25+
InterfaceMethod<
26+
/*desc=*/"Returns the source value for this copy operation",
27+
/*retTy=*/"::mlir::Value",
28+
/*methodName=*/"getSource"
29+
>,
30+
InterfaceMethod<
31+
/*desc=*/"Returns the target value for this copy operation",
32+
/*retTy=*/"::mlir::Value",
33+
/*methodName=*/"getTarget"
34+
>
35+
];
36+
}
37+
38+
#endif // MLIR_INTERFACES_COPYOPINTERFACE

mlir/lib/Interfaces/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ set(LLVM_OPTIONAL_SOURCES
22
CallInterfaces.cpp
33
CastInterfaces.cpp
44
ControlFlowInterfaces.cpp
5+
CopyOpInterface.cpp
56
DataLayoutInterfaces.cpp
67
DerivedAttributeOpInterface.cpp
78
DestinationStyleOpInterface.cpp
@@ -42,6 +43,7 @@ endfunction(add_mlir_interface_library)
4243
add_mlir_interface_library(CallInterfaces)
4344
add_mlir_interface_library(CastInterfaces)
4445
add_mlir_interface_library(ControlFlowInterfaces)
46+
add_mlir_interface_library(CopyOpInterface)
4547
add_mlir_interface_library(DataLayoutInterfaces)
4648
add_mlir_interface_library(DerivedAttributeOpInterface)
4749
add_mlir_interface_library(DestinationStyleOpInterface)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//===- CopyOpInterface.cpp - Copy operations interface in MLIR ------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "mlir/Interfaces/CopyOpInterface.h"
10+
11+
using namespace mlir;
12+
13+
//===----------------------------------------------------------------------===//
14+
// CopyOp Interface
15+
//===----------------------------------------------------------------------===//
16+
17+
/// Include the definitions of the copy operation interface.
18+
#include "mlir/Interfaces/CopyOpInterface.cpp.inc"

0 commit comments

Comments
 (0)