Lines Matching full:pattern

1 //===- PatternApplicator.cpp - Pattern Application Engine -------*- C++ -*-===//
9 // This file implements an applicator that applies pattern rewrites based upon a
18 #define DEBUG_TYPE "pattern-application"
34 /// Log a message for a pattern that is impossible to match.
35 static void logImpossibleToMatch(const Pattern &pattern) { in logImpossibleToMatch() argument
36 llvm::dbgs() << "Ignoring pattern '" << pattern.getRootKind() in logImpossibleToMatch()
41 /// Log IR after pattern application.
50 llvm::dbgs() << "// *** IR Dump After Pattern Application ***\n"; in logSucessfulPatternApplication()
68 for (const RewritePattern *pattern : it.second) { in applyCostModel() local
69 if (pattern->getBenefit().isImpossibleToMatch()) in applyCostModel()
70 LLVM_DEBUG(logImpossibleToMatch(*pattern)); in applyCostModel()
72 patterns[it.first].push_back(pattern); in applyCostModel()
76 for (const RewritePattern &pattern : in applyCostModel() local
78 if (pattern.getBenefit().isImpossibleToMatch()) in applyCostModel()
79 LLVM_DEBUG(logImpossibleToMatch(pattern)); in applyCostModel()
81 anyOpPatterns.push_back(&pattern); in applyCostModel()
85 llvm::SmallDenseMap<const Pattern *, PatternBenefit> benefits; in applyCostModel()
86 auto cmp = [&benefits](const Pattern *lhs, const Pattern *rhs) { in applyCostModel()
90 // Special case for one pattern in the list, which is the most common case. in applyCostModel()
99 // Collect the dynamic benefits for the current pattern list. in applyCostModel()
101 for (const Pattern *pat : list) in applyCostModel()
118 function_ref<void(const Pattern &)> walk) { in walkAllPatterns()
120 for (const auto &pattern : it.second) in walkAllPatterns() local
121 walk(*pattern); in walkAllPatterns()
122 for (const Pattern &it : frozenPatternList.getMatchAnyOpNativePatterns()) in walkAllPatterns()
125 for (const Pattern &it : bytecode->getPatterns()) in walkAllPatterns()
132 function_ref<bool(const Pattern &)> canApply, in matchAndRewrite()
133 function_ref<void(const Pattern &)> onFailure, in matchAndRewrite()
134 function_ref<LogicalResult(const Pattern &)> onSuccess) { in matchAndRewrite()
156 // Find the next pattern with the highest benefit. in matchAndRewrite()
157 const Pattern *bestPattern = nullptr; in matchAndRewrite()
177 bestPattern = pdlMatch->pattern; in matchAndRewrite()
183 // Update the pattern iterator on failure so that this pattern isn't in matchAndRewrite()
187 // Check that the pattern can be applied. in matchAndRewrite()
191 // Try to match and rewrite this pattern. The patterns are sorted by in matchAndRewrite()
200 // pattern. in matchAndRewrite()
210 const auto *pattern = in matchAndRewrite() local
212 result = pattern->matchAndRewrite(op, rewriter); in matchAndRewrite()
219 // Process the result of the pattern application. in matchAndRewrite()