21 #ifndef MLIR_TOOLS_MLIRQUERY_MATCHER_MATCHERSINTERNAL_H
22 #define MLIR_TOOLS_MLIRQUERY_MATCHER_MATCHERSINTERNAL_H
25 #include "llvm/ADT/IntrusiveRefCntPtr.h"
31 template <
typename T,
typename =
void>
38 std::declval<Operation *>()))>>
43 template <
typename T,
typename =
void>
50 std::declval<Operation *>(),
51 std::declval<SetVector<Operation *> &>()))>>
56 :
public llvm::ThreadSafeRefCountedBase<MatcherInterface> {
66 template <
typename MatcherFn>
73 return matcherFn.match(op);
79 return matcherFn.match(op, matchedOps);
93 : implementation(implementation) {}
95 template <
typename MatcherFn>
96 static std::unique_ptr<DynMatcher>
98 auto impl = std::make_unique<MatcherFnImpl<MatcherFn>>(matcherFn);
99 return std::make_unique<DynMatcher>(
impl.release());
104 return implementation->match(op, matchedOps);
112 llvm::IntrusiveRefCntPtr<MatcherInterface> implementation;
113 std::string functionName;
Operation is the basic unit of execution within MLIR.
DynMatcher(MatcherInterface *implementation)
bool match(Operation *op) const
static std::unique_ptr< DynMatcher > constructDynMatcherFromMatcherFn(MatcherFn &matcherFn)
StringRef getFunctionName() const
bool hasFunctionName() const
bool match(Operation *op, SetVector< Operation * > &matchedOps) const
void setFunctionName(StringRef name)
MatcherFnImpl(MatcherFn &matcherFn)
bool match(Operation *op, SetVector< Operation * > &matchedOps) override
bool match(Operation *op) override
virtual ~MatcherInterface()=default
virtual bool match(Operation *op, SetVector< Operation * > &matchedOps)=0
virtual bool match(Operation *op)=0
A matcher encapsulating getBackwardSlice method from SliceAnalysis.h.