summaryrefslogtreecommitdiffstats
path: root/mlir/lib/IR/PatternMatch.cpp
diff options
context:
space:
mode:
authorChris Lattner <clattner@google.com>2018-11-28 15:09:39 -0800
committerjpienaar <jpienaar@google.com>2019-03-29 14:12:07 -0700
commit3f2530cdf598f6340020abb9199867594a0eb538 (patch)
tree7f1254763778bf7c3c26a67785f042189e00b52c /mlir/lib/IR/PatternMatch.cpp
parent1f5330ac9028b577ff5496b57a96757512ca8dda (diff)
downloadbcm5719-llvm-3f2530cdf598f6340020abb9199867594a0eb538.tar.gz
bcm5719-llvm-3f2530cdf598f6340020abb9199867594a0eb538.zip
Split "rewrite" functionality out of Pattern into a new RewritePattern derived
class. This change is NFC, but allows for new kinds of patterns, specifically LegalizationPatterns which will be allowed to change the types of things they rewrite. PiperOrigin-RevId: 223243783
Diffstat (limited to 'mlir/lib/IR/PatternMatch.cpp')
-rw-r--r--mlir/lib/IR/PatternMatch.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/mlir/lib/IR/PatternMatch.cpp b/mlir/lib/IR/PatternMatch.cpp
index 11e9b94901f..a8b6aa1e738 100644
--- a/mlir/lib/IR/PatternMatch.cpp
+++ b/mlir/lib/IR/PatternMatch.cpp
@@ -51,19 +51,22 @@ Pattern::Pattern(StringRef rootName, PatternBenefit benefit,
MLIRContext *context)
: rootKind(OperationName(rootName, context)), benefit(benefit) {}
-void Pattern::rewrite(Operation *op, std::unique_ptr<PatternState> state,
- PatternRewriter &rewriter) const {
+// Out-of-line vtable anchor.
+void Pattern::anchor() {}
+
+//===----------------------------------------------------------------------===//
+// RewritePattern and PatternRewriter implementation
+//===----------------------------------------------------------------------===//
+
+void RewritePattern::rewrite(Operation *op, std::unique_ptr<PatternState> state,
+ PatternRewriter &rewriter) const {
rewrite(op, rewriter);
}
-void Pattern::rewrite(Operation *op, PatternRewriter &rewriter) const {
+void RewritePattern::rewrite(Operation *op, PatternRewriter &rewriter) const {
llvm_unreachable("need to implement one of the rewrite functions!");
}
-//===----------------------------------------------------------------------===//
-// PatternRewriter implementation
-//===----------------------------------------------------------------------===//
-
PatternRewriter::~PatternRewriter() {
// Out of line to provide a vtable anchor for the class.
}
OpenPOWER on IntegriCloud