-
Notifications
You must be signed in to change notification settings - Fork 10.8k
/
TransformInterfaces.td
138 lines (121 loc) · 5.63 KB
/
TransformInterfaces.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
//===- TransformInterfaces.td - Transform Op 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 declares the interfaces for transformation-related-ops.
//
//===----------------------------------------------------------------------===//
#ifndef MLIR_DIALECT_TRANSFORM_IR_TRANSFORM_INTERFACES_TD
#define MLIR_DIALECT_TRANSFORM_IR_TRANSFORM_INTERFACES_TD
include "mlir/IR/OpBase.td"
def TransformOpInterface : OpInterface<"TransformOpInterface"> {
let description = [{
This interface is to be implemented by operations that identify
transformations to be performed on other operations. The former are referred
to as transform IR operations. The latter are referred to as payload IR
operations. Such transform IR operations provide a fine-grain control
mechanism over how transformations are applied by using and defining
transform IR values, referred to as handles, that correspond to sets of
operations in the payload IR. Transformations are applied starting from the
operations identified by handles, but may affect other operations as well.
Further restrictions may be imposed by flows that rely on transform IR
operations to control transformations.
}];
let cppNamespace = "::mlir::transform";
let methods = [
InterfaceMethod<
/*desc=*/[{
Applies the transformation represented by the current operation. This
accepts as arguments the object that must be populated with results of
the current transformation and a transformation state object that can be
used for queries, e.g., to obtain the list of operations on which the
transformation represented by the current op is targeted. Returns a
special status object indicating whether the transformation succeeded
or failed, and, if it failed, whether the failure is recoverable or not.
}],
/*returnType=*/"::mlir::DiagnosedSilenceableFailure",
/*name=*/"apply",
/*arguments=*/(ins
"::mlir::transform::TransformResults &":$transformResults,
"::mlir::transform::TransformState &":$state
)>,
];
let extraSharedClassDeclaration = [{
/// Creates the silenceable failure object with a diagnostic located at the
/// current operation. Silenceable failure must be suppressed or reported
/// explicitly at some later time.
DiagnosedSilenceableFailure
emitSilenceableError(const ::llvm::Twine &message = {}) {
return ::mlir::emitSilenceableFailure($_op, message);
}
/// Creates the definite failure object with a diagnostic located at the
/// current operation. Definite failure will be reported when the object
/// is destroyed or converted.
DiagnosedDefiniteFailure
emitDefiniteFailure(const ::llvm::Twine &message = {}) {
return ::mlir::emitDefiniteFailure($_op, message);
}
/// Emits a generic definite failure for the current transform operation
/// targeting the given Payload IR operation and returns failure. Should
/// be only used as a last resort when the transformation itself provides
/// no further indication as to the reason of the failure.
DiagnosedDefiniteFailure emitDefaultDefiniteFailure(
::mlir::Operation *target) {
auto diag = ::mlir::emitDefiniteFailure($_op, "failed to apply");
diag.attachNote(target->getLoc()) << "attempted to apply to this op";
return diag;
}
/// Creates the default silenceable failure for a transform op that failed
/// to properly apply to a target.
DiagnosedSilenceableFailure emitDefaultSilenceableFailure(
Operation *target) {
DiagnosedSilenceableFailure diag = emitSilenceableFailure($_op->getLoc());
diag << $_op->getName() << " failed to apply";
diag.attachNote(target->getLoc()) << "when applied to this op";
return diag;
}
}];
}
def TransformTypeInterface : TypeInterface<"TransformTypeInterface"> {
let description = [{
Types that can be used for Transform dialect handle values. Such types
define the properties of Payload IR operations associated with the handle.
A user of such a handle can assume that these properties have been verified
for any Payload IR operation associated with it.
}];
let cppNamespace = "::mlir::transform";
let methods = [
InterfaceMethod<
/*desc=*/[{
Checks if the given list of associated Payload IR operations satisfy
the conditions defined by this type. If not, produces a silenceable
error at the specified location.
}],
/*returnType=*/"::mlir::DiagnosedSilenceableFailure",
/*name=*/"checkPayload",
/*arguments=*/(ins "::mlir::Location":$loc,
"::mlir::ArrayRef<::mlir::Operation *>":$payload)
>
];
let extraSharedClassDeclaration = [{
DiagnosedSilenceableFailure emitSilenceableError(Location loc) const {
Diagnostic diag(loc, DiagnosticSeverity::Error);
return DiagnosedSilenceableFailure::silenceableFailure(std::move(diag));
}
}];
}
def FunctionalStyleTransformOpTrait
: NativeOpTrait<"FunctionalStyleTransformOpTrait"> {
let cppNamespace = "::mlir::transform";
}
def TransformEachOpTrait : NativeOpTrait<"TransformEachOpTrait"> {
let cppNamespace = "::mlir::transform";
}
def NavigationTransformOpTrait : NativeOpTrait<"NavigationTransformOpTrait"> {
let cppNamespace = "::mlir::transform";
}
#endif // MLIR_DIALECT_TRANSFORM_IR_TRANSFORM_INTERFACES_TD