[Mlir-commits] [mlir] [mlir] MLIR-QUERY slice-matchers implementation (PR #115670)
Denzel-Brian Budii
llvmlistbot at llvm.org
Sat Mar 29 08:41:19 PDT 2025
================
@@ -7,32 +7,93 @@
//===----------------------------------------------------------------------===//
//
// This file contains the MatchFinder class, which is used to find operations
-// that match a given matcher.
+// that match a given matcher and print them.
//
//===----------------------------------------------------------------------===//
#ifndef MLIR_TOOLS_MLIRQUERY_MATCHER_MATCHERFINDER_H
#define MLIR_TOOLS_MLIRQUERY_MATCHER_MATCHERFINDER_H
#include "MatchersInternal.h"
+#include "mlir/Query/QuerySession.h"
+#include "llvm/ADT/SetVector.h"
+#include "llvm/Support/SourceMgr.h"
+#include "llvm/Support/raw_ostream.h"
namespace mlir::query::matcher {
-// MatchFinder is used to find all operations that match a given matcher.
class MatchFinder {
-public:
- // Returns all operations that match the given matcher.
- static std::vector<Operation *> getMatches(Operation *root,
- DynMatcher matcher) {
- std::vector<Operation *> matches;
- // Simple match finding with walk.
+public:
+ //
+ // getMatches walks the IR and prints operations as soon as it matches them
+ // if a matcher is to be further extracted into the function, then it does not
+ // print operations
----------------
chios202 wrote:
It now follows a similar design to clang-query's MatchFinder class
https://github.com/llvm/llvm-project/pull/115670
More information about the Mlir-commits
mailing list