13 #ifndef MLIR_IR_VISITORS_H 14 #define MLIR_IR_VISITORS_H 18 #include "llvm/ADT/STLExtras.h" 22 class InFlightDiagnostic;
28 enum ResultEnum { Interrupt, Advance } result;
35 : result(
failed(result) ? Interrupt : Advance) {}
53 template <
typename Ret,
typename F,
typename Arg>
55 template <
typename Ret,
typename F,
typename Arg>
85 typename RetT = decltype(std::declval<FuncTy>()(std::declval<ArgT>()))>
86 typename std::enable_if<std::is_same<ArgT,
Operation *>::value, RetT>::type
99 typename RetT = decltype(std::declval<FuncTy>()(std::declval<ArgT>()))>
100 typename std::enable_if<!std::is_same<ArgT, Operation *>::value &&
101 std::is_same<RetT, void>::value,
105 if (
auto derivedOp = dyn_cast<ArgT>(op))
123 typename RetT = decltype(std::declval<FuncTy>()(std::declval<ArgT>()))>
124 typename std::enable_if<!std::is_same<ArgT, Operation *>::value &&
125 std::is_same<RetT, WalkResult>::value,
129 if (
auto derivedOp = dyn_cast<ArgT>(op))
130 return callback(derivedOp);
137 template <
typename FnT>
Definition: InferTypeOpInterface.cpp:20
WalkResult(InFlightDiagnostic &&)
Definition: Visitors.h:39
Definition: Operation.h:27
Definition: Diagnostics.h:320
bool wasInterrupted() const
Returns if the walk was interrupted.
Definition: Visitors.h:47
bool failed(LogicalResult result)
Definition: LogicalResult.h:45
Definition: Diagnostics.h:173
Definition: LogicalResult.h:18
WalkResult(LogicalResult result)
Allow LogicalResult to interrupt the walk on failure.
Definition: Visitors.h:34
std::enable_if<!std::is_same< ArgT, Operation * >::value &&std::is_same< RetT, WalkResult >::value, RetT >::type walkOperations(Operation *op, FuncTy &&callback)
Definition: Visitors.h:127
static WalkResult advance()
Definition: Visitors.h:44
void walkOperations(Operation *op, function_ref< void(Operation *op)> callback)
Walk all of the operations nested under and including the given operation.
Definition: Visitors.cpp:15
static WalkResult interrupt()
Definition: Visitors.h:43
Definition: Visitors.h:27
decltype(first_argument_type(std::declval< T >())) first_argument
Type definition of the first argument to the given callable 'T'.
Definition: Visitors.h:62
bool operator==(const WalkResult &rhs) const
Definition: Visitors.h:41
Arg first_argument_type(Ret(F::*)(Arg))
WalkResult(ResultEnum result)
Definition: Visitors.h:31
decltype(walkOperations(nullptr, std::declval< FnT >())) walkResultType
Utility to provide the return type of a templated walk method.
Definition: Visitors.h:138
WalkResult(Diagnostic &&)
Allow diagnostics to interrupt the walk.
Definition: Visitors.h:38