MLIR
20.0.0git
include
mlir
Query
Matcher
MatchFinder.h
Go to the documentation of this file.
1
//===- MatchFinder.h - ------------------------------------------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This file contains the MatchFinder class, which is used to find operations
10
// that match a given matcher.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef MLIR_TOOLS_MLIRQUERY_MATCHER_MATCHERFINDER_H
15
#define MLIR_TOOLS_MLIRQUERY_MATCHER_MATCHERFINDER_H
16
17
#include "
MatchersInternal.h
"
18
19
namespace
mlir::query::matcher
{
20
21
// MatchFinder is used to find all operations that match a given matcher.
22
class
MatchFinder
{
23
public
:
24
// Returns all operations that match the given matcher.
25
static
std::vector<Operation *>
getMatches
(
Operation
*root,
26
DynMatcher
matcher) {
27
std::vector<Operation *> matches;
28
29
// Simple match finding with walk.
30
root->
walk
([&](
Operation
*subOp) {
31
if
(matcher.
match
(subOp))
32
matches.push_back(subOp);
33
});
34
35
return
matches;
36
}
37
};
38
39
}
// namespace mlir::query::matcher
40
41
#endif
// MLIR_TOOLS_MLIRQUERY_MATCHER_MATCHERFINDER_H
MatchersInternal.h
mlir::Operation
Operation is the basic unit of execution within MLIR.
Definition:
Operation.h:88
mlir::Operation::walk
std::enable_if_t< llvm::function_traits< std::decay_t< FnT > >::num_args==1, RetT > walk(FnT &&callback)
Walk the operation by calling the callback for each nested operation (including this one),...
Definition:
Operation.h:793
mlir::query::matcher::DynMatcher
Definition:
MatchersInternal.h:51
mlir::query::matcher::DynMatcher::match
bool match(Operation *op) const
Definition:
MatchersInternal.h:64
mlir::query::matcher::MatchFinder
Definition:
MatchFinder.h:22
mlir::query::matcher::MatchFinder::getMatches
static std::vector< Operation * > getMatches(Operation *root, DynMatcher matcher)
Definition:
MatchFinder.h:25
mlir::query::matcher
Definition:
ErrorBuilder.h:20
Generated on Wed Nov 27 2024 08:32:56 for MLIR by
1.9.1