24 if (pdlModule.getOps<pdl::PatternOp>().empty())
34 pdlModule.getBody()->walk(simplifyFn);
48 pdlModule.getBody()->walk(simplifyFn);
57 :
impl(std::make_shared<Impl>()) {}
62 :
impl(std::make_shared<Impl>()) {
64 disabledPatterns.insert(disabledPatternLabels.begin(),
65 disabledPatternLabels.end());
66 enabledPatterns.insert(enabledPatternLabels.begin(),
67 enabledPatternLabels.end());
72 std::vector<RegisteredOperationName> opInfos;
74 [&](std::unique_ptr<RewritePattern> &pattern,
77 opInfos = pattern->getContext()->getRegisteredOperations();
80 impl->nativeOpSpecificPatternMap[info].push_back(pattern.get());
81 impl->nativeOpSpecificPatternList.push_back(std::move(pattern));
84 for (std::unique_ptr<RewritePattern> &pat : patterns.getNativePatterns()) {
86 if (!enabledPatterns.empty()) {
87 auto isEnabledFn = [&](StringRef label) {
88 return enabledPatterns.count(label);
90 if (!isEnabledFn(pat->getDebugName()) &&
91 llvm::none_of(pat->getDebugLabels(), isEnabledFn))
95 if (!disabledPatterns.empty()) {
96 auto isDisabledFn = [&](StringRef label) {
97 return disabledPatterns.count(label);
99 if (isDisabledFn(pat->getDebugName()) ||
100 llvm::any_of(pat->getDebugLabels(), isDisabledFn))
104 if (std::optional<OperationName> rootName = pat->getRootKind()) {
105 impl->nativeOpSpecificPatternMap[*rootName].push_back(pat.get());
106 impl->nativeOpSpecificPatternList.push_back(std::move(pat));
109 if (std::optional<TypeID> interfaceID = pat->getRootInterfaceID()) {
115 if (std::optional<TypeID> traitID = pat->getRootTraitID()) {
121 impl->nativeAnyOpPatterns.push_back(std::move(pat));
126 ModuleOp pdlModule = pdlPatterns.
getModule();
132 llvm::report_fatal_error(
133 "failed to lower PDL pattern module to the PDL Interpreter");
136 impl->pdlByteCode = std::make_unique<detail::PDLByteCode>(
static LogicalResult convertPDLToPDLInterp(ModuleOp pdlModule, DenseMap< Operation *, PDLPatternConfigSet * > &configMap)
FrozenRewritePatternSet()
~FrozenRewritePatternSet()
void addPass(std::unique_ptr< Pass > pass)
Add the given pass to this pass manager.
bool hasTrait() const
Returns true if the operation was registered with a particular trait, e.g.
bool hasInterface() const
Returns true if this operation has the given interface registered to it.
Operation is the basic unit of execution within MLIR.
void erase()
Remove this operation from its parent block and delete it.
This class contains all of the necessary data for a set of PDL patterns, or pattern rewrites specifie...
llvm::StringMap< PDLConstraintFunction > takeConstraintFunctions()
ModuleOp getModule()
Return the internal PDL module of this pattern.
SmallVector< std::unique_ptr< PDLPatternConfigSet > > takeConfigs()
Return the set of the registered pattern configs.
llvm::StringMap< PDLRewriteFunction > takeRewriteFunctions()
DenseMap< Operation *, PDLPatternConfigSet * > takeConfigMap()
The main pass manager and pipeline builder.
LogicalResult run(Operation *op)
Run the passes within this manager on the provided operation.
void enableVerifier(bool enabled=true)
Runs the verifier after each individual pass.
This is a "type erased" representation of a registered operation.
Include the generated interface declarations.
LogicalResult failure(bool isFailure=true)
Utility function to generate a LogicalResult.
LogicalResult success(bool isSuccess=true)
Utility function to generate a LogicalResult.
bool isOpTriviallyDead(Operation *op)
Return true if the given operation is unused, and has no side effects on memory that prevent erasing.
bool failed(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a failure value.
std::unique_ptr< OperationPass< ModuleOp > > createPDLToPDLInterpPass()
Creates and returns a pass to convert PDL ops to PDL interpreter ops.
This class represents an efficient way to signal success or failure.