34 llvm_unreachable(
"Unhandled ArgKind");
39 void Registry::registerMatcherDescriptor(
40 llvm::StringRef matcherName,
41 std::unique_ptr<internal::MatcherDescriptor> callback) {
42 assert(!constructorMap.contains(matcherName));
43 constructorMap[matcherName] = std::move(callback);
46 std::optional<MatcherCtor>
49 auto it = matcherRegistry.
constructors().find(matcherName);
51 ? std::optional<MatcherCtor>()
59 std::set<ArgKind> typeSet;
62 for (
const auto &ctxEntry : context) {
64 unsigned argNumber = ctxEntry.second;
65 std::vector<ArgKind> nextTypeSet;
67 if (argNumber < ctor->getNumArgs())
70 typeSet.insert(nextTypeSet.begin(), nextTypeSet.end());
73 return std::vector<ArgKind>(typeSet.begin(), typeSet.end());
76 std::vector<MatcherCompletion>
79 std::vector<MatcherCompletion> completions;
84 llvm::StringRef name = m.getKey();
87 std::vector<std::vector<ArgKind>> argKinds(numArgs);
93 for (
unsigned arg = 0; arg != numArgs; ++arg)
98 llvm::raw_string_ostream os(decl);
100 std::string typedText = std::string(name);
101 os <<
"Matcher: " << name <<
"(";
103 for (
const std::vector<ArgKind> &arg : argKinds) {
104 if (&arg != &argKinds[0])
107 bool firstArgKind =
true;
109 for (
const ArgKind &argKind : arg) {
113 firstArgKind =
false;
114 os << asArgString(argKind);
121 if (argKinds.empty())
126 completions.emplace_back(typedText, decl);
137 if (functionName.empty() || out.
isNull())
140 if (std::optional<DynMatcher> result = out.
getDynMatcher()) {
141 result->setFunctionName(functionName);
union mlir::linalg::@1203::ArityGroupAndKind::Kind kind
static std::vector< MatcherCompletion > getMatcherCompletions(ArrayRef< ArgKind > acceptedTypes, const Registry &matcherRegistry)
static std::vector< ArgKind > getAcceptedCompletionTypes(llvm::ArrayRef< std::pair< MatcherCtor, unsigned >> context)
static std::optional< MatcherCtor > lookupMatcherCtor(llvm::StringRef matcherName, const Registry &matcherRegistry)
static VariantMatcher constructMatcher(MatcherCtor ctor, internal::SourceRange nameRange, llvm::StringRef functionName, ArrayRef< ParserValue > args, internal::Diagnostics *error)
const ConstructorMap & constructors() const
static VariantMatcher SingleMatcher(DynMatcher matcher)
std::optional< DynMatcher > getDynMatcher() const
ArgStream addError(SourceRange range, ErrorType error)
virtual VariantMatcher create(SourceRange nameRange, const llvm::ArrayRef< ParserValue > args, Diagnostics *error) const =0
virtual void getArgKinds(unsigned argNo, std::vector< ArgKind > &argKinds) const =0
virtual unsigned getNumArgs() const =0
A matcher encapsulating getBackwardSlice method from SliceAnalysis.h.