17 std::vector<Operation *> matchedOps)
18 : rootOp(rootOp), matchedOps(std::move(matchedOps)) {}
20 std::vector<MatchFinder::MatchResult>
22 std::vector<MatchResult> results;
25 if (matcher.
match(subOp)) {
28 match.matchedOps.push_back(subOp);
29 results.push_back(std::move(match));
30 }
else if (matcher.
match(subOp, tempStorage)) {
31 results.emplace_back(subOp, std::vector<Operation *>(tempStorage.begin(),
41 auto fileLoc = cast<FileLineColLoc>(op->
getLoc());
43 qs.
getBufferId(), fileLoc.getLine(), fileLoc.getColumn());
44 llvm::SMDiagnostic
diag =
46 diag.print(
"", os,
true,
false,
true);
50 Operation *op,
const std::string &binding)
const {
51 auto fileLoc = cast<FileLineColLoc>(op->
getLoc());
53 qs.
getBufferId(), fileLoc.getLine(), fileLoc.getColumn());
55 "\"" + binding +
"\" binds here");
58 std::vector<Operation *>
60 std::vector<Operation *> newVector;
61 for (
auto &result : matches) {
62 newVector.insert(newVector.end(), result.matchedOps.begin(),
63 result.matchedOps.end());
static std::string diag(const llvm::Value &value)
Operation is the basic unit of execution within MLIR.
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),...
Location getLoc()
The source location the operation was defined or derived from.
llvm::SourceMgr & getSourceManager() const
bool match(Operation *op) const
void printMatch(llvm::raw_ostream &os, QuerySession &qs, Operation *op) const
Prints the matched operation.
std::vector< MatchResult > collectMatches(Operation *root, DynMatcher matcher) const
Traverses the IR and returns a vector of MatchResult for each match of the matcher.
std::vector< Operation * > flattenMatchedOps(std::vector< MatchResult > &matches) const
Flattens a vector of MatchResult into a vector of operations.
A matcher encapsulating getBackwardSlice method from SliceAnalysis.h.