/
AllocationOpInterface.td
61 lines (55 loc) · 2.53 KB
/
AllocationOpInterface.td
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//===-- AllocationOpInterface.td - Allocation op 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 with allocation-related methods. It is used by the
// buffer deallocation pass.
//
//===----------------------------------------------------------------------===//
#ifndef ALLOCATION_OP_INTERFACE
#define ALLOCATION_OP_INTERFACE
include "mlir/IR/OpBase.td"
//===----------------------------------------------------------------------===//
// AllocationOpInterface
//===----------------------------------------------------------------------===//
def AllocationOpInterface : OpInterface<"AllocationOpInterface"> {
let description = [{
This interface provides general allocation-related methods that are
designed for allocation operations. For example, it offers the ability to
construct associated deallocation and clone operations that are compatible
with the current allocation operation.
}];
let cppNamespace = "::mlir::bufferization";
let methods = [
StaticInterfaceMethod<[{
Builds a deallocation operation using the provided builder and the
current allocation value (which refers to the current Op implementing
this interface). The allocation value is a result of the current
operation implementing this interface. If there is no compatible
deallocation operation, this method can return ::llvm::None.
}],
"::mlir::Optional<::mlir::Operation*>", "buildDealloc",
(ins "::mlir::OpBuilder&":$builder, "::mlir::Value":$alloc), [{}],
/*defaultImplementation=*/[{ return llvm::None; }]
>,
StaticInterfaceMethod<[{
Builds a clone operation using the provided builder and the current
allocation value (which refers to the current Op implementing this
interface). The allocation value is a result of the current operation
implementing this interface. If there is no compatible clone operation,
this method can return ::llvm::None.
}],
"::mlir::Optional<::mlir::Value>", "buildClone",
(ins "::mlir::OpBuilder&":$builder, "::mlir::Value":$alloc), [{}],
/*defaultImplementation=*/[{
return builder.create<memref::CloneOp>(alloc.getLoc(), alloc)
.getResult();
}]
>
];
}
#endif // ALLOCATION_OP_INTERFACE