65 :
impl(std::make_shared<Impl>()) {
67 disabledPatterns.insert_range(disabledPatternLabels);
68 enabledPatterns.insert_range(enabledPatternLabels);
73 std::vector<RegisteredOperationName> opInfos;
75 [&](std::unique_ptr<RewritePattern> &pattern,
78 opInfos = pattern->getContext()->getRegisteredOperations();
81 impl->nativeOpSpecificPatternMap[info].push_back(pattern.get());
82 impl->nativeOpSpecificPatternList.push_back(std::move(pattern));
85 for (std::unique_ptr<RewritePattern> &pat :
patterns.getNativePatterns()) {
87 if (!enabledPatterns.empty()) {
88 auto isEnabledFn = [&](StringRef label) {
89 return enabledPatterns.count(label);
91 if (!isEnabledFn(pat->getDebugName()) &&
92 llvm::none_of(pat->getDebugLabels(), isEnabledFn))
96 if (!disabledPatterns.empty()) {
97 auto isDisabledFn = [&](StringRef label) {
98 return disabledPatterns.count(label);
100 if (isDisabledFn(pat->getDebugName()) ||
101 llvm::any_of(pat->getDebugLabels(), isDisabledFn))
105 if (std::optional<OperationName> rootName = pat->getRootKind()) {
106 impl->nativeOpSpecificPatternMap[*rootName].push_back(pat.get());
107 impl->nativeOpSpecificPatternList.push_back(std::move(pat));
110 if (std::optional<TypeID> interfaceID = pat->getRootInterfaceID()) {
111 addToOpsWhen(pat, [&](RegisteredOperationName info) {
112 return info.hasInterface(*interfaceID);
116 if (std::optional<TypeID> traitID = pat->getRootTraitID()) {
122 impl->nativeAnyOpPatterns.push_back(std::move(pat));
125#if MLIR_ENABLE_PDL_IN_PATTERNMATCH
127 PDLPatternModule &pdlPatterns =
patterns.getPDLPatterns();
128 ModuleOp pdlModule = pdlPatterns.getModule();
132 pdlPatterns.takeConfigMap();
133 if (
failed(convertPDLToPDLInterp(pdlModule, configMap)))
134 llvm::report_fatal_error(
135 "failed to lower PDL pattern module to the PDL Interpreter");
138 impl->pdlByteCode = std::make_unique<detail::PDLByteCode>(
139 pdlModule, pdlPatterns.takeConfigs(), configMap,
140 pdlPatterns.takeConstraintFunctions(),
141 pdlPatterns.takeRewriteFunctions());