12#include <mlir/IR/Visitors.h>
14#include <llvm/ADT/STLFunctionalExtras.h>
15#include <llvm/ADT/SmallVector.h>
21template <
typename MatchType,
typename R>
22inline static bool walkContainsMatch(R &root, llvm::function_ref<
bool(MatchType)> pred) {
24 .walk([&pred](MatchType t) {
25 return pred(t) ? mlir::WalkResult::interrupt() :
mlir::WalkResult::advance();
32template <
typename MatchType,
typename R>
inline static bool walkContains(R &root) {
33 return root.walk([](MatchType t) {
return mlir::WalkResult::interrupt(); }).wasInterrupted();
38template <
typename MatchType,
typename R>
39inline static llvm::SmallVector<MatchType> walkCollect(R &root) {
40 llvm::SmallVector<MatchType> collected;
41 root.walk([&collected](MatchType op) { collected.push_back(op); });