66 :
impl(std::make_shared<Impl>()) {
68 disabledPatterns.insert_range(disabledPatternLabels);
69 enabledPatterns.insert_range(enabledPatternLabels);
74 std::vector<RegisteredOperationName> opInfos;
76 [&](std::unique_ptr<RewritePattern> &pattern,
79 opInfos = pattern->getContext()->getRegisteredOperations();
82 impl->nativeOpSpecificPatternMap[info].push_back(pattern.get());
83 impl->nativeOpSpecificPatternList.push_back(std::move(pattern));
86 for (std::unique_ptr<RewritePattern> &pat : patterns.getNativePatterns()) {
88 if (!enabledPatterns.empty()) {
89 auto isEnabledFn = [&](StringRef label) {
90 return enabledPatterns.count(label);
92 if (!isEnabledFn(pat->getDebugName()) &&
93 llvm::none_of(pat->getDebugLabels(), isEnabledFn))
97 if (!disabledPatterns.empty()) {
98 auto isDisabledFn = [&](StringRef label) {
99 return disabledPatterns.count(label);
101 if (isDisabledFn(pat->getDebugName()) ||
102 llvm::any_of(pat->getDebugLabels(), isDisabledFn))
106 if (std::optional<OperationName> rootName = pat->getRootKind()) {
107 impl->nativeOpSpecificPatternMap[*rootName].push_back(pat.get());
108 impl->nativeOpSpecificPatternList.push_back(std::move(pat));
111 if (std::optional<TypeID> interfaceID = pat->getRootInterfaceID()) {
112 addToOpsWhen(pat, [&](RegisteredOperationName info) {
113 return info.hasInterface(*interfaceID);
117 if (std::optional<TypeID> traitID = pat->getRootTraitID()) {
123 impl->nativeAnyOpPatterns.push_back(std::move(pat));
126#if MLIR_ENABLE_PDL_IN_PATTERNMATCH
128 PDLPatternModule &pdlPatterns = patterns.getPDLPatterns();
129 ModuleOp pdlModule = pdlPatterns.getModule();
133 pdlPatterns.takeConfigMap();
134 if (
failed(convertPDLToPDLInterp(pdlModule, configMap)))
135 llvm::report_fatal_error(
136 "failed to lower PDL pattern module to the PDL Interpreter");
143 if (!pdlModule.lookupSymbol(
144 pdl_interp::PDLInterpDialect::getMatcherFunctionName()))
148 impl->pdlByteCode = std::make_unique<detail::PDLByteCode>(
149 pdlModule, pdlPatterns.takeConfigs(), configMap,
150 pdlPatterns.takeConstraintFunctions(),
151 pdlPatterns.takeRewriteFunctions());