#include "mlir/Rewrite/PatternApplicator.h"
#include "ByteCode.h"
#include "llvm/Support/Debug.h"
#define DEBUG_TYPE …
usingnamespacemlir;
usingnamespacemlir::detail;
PatternApplicator::PatternApplicator(
const FrozenRewritePatternSet &frozenPatternList)
: … { … }
PatternApplicator::~PatternApplicator() = default;
#ifndef NDEBUG
static void logImpossibleToMatch(const Pattern &pattern) {
llvm::dbgs() << "Ignoring pattern '" << pattern.getRootKind()
<< "' because it is impossible to match or cannot lead "
"to legal IR (by cost model)\n";
}
static Operation *getDumpRootOp(Operation *op) {
Operation *isolatedParent =
op->getParentWithTrait<mlir::OpTrait::IsIsolatedFromAbove>();
if (isolatedParent)
return isolatedParent;
return op;
}
static void logSucessfulPatternApplication(Operation *op) {
llvm::dbgs() << "// *** IR Dump After Pattern Application ***\n";
op->dump();
llvm::dbgs() << "\n\n";
}
#endif
void PatternApplicator::applyCostModel(CostModel model) { … }
void PatternApplicator::walkAllPatterns(
function_ref<void(const Pattern &)> walk) { … }
LogicalResult PatternApplicator::matchAndRewrite(
Operation *op, PatternRewriter &rewriter,
function_ref<bool(const Pattern &)> canApply,
function_ref<void(const Pattern &)> onFailure,
function_ref<LogicalResult(const Pattern &)> onSuccess) { … }