Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Unified Diff: src/compiler/node-matchers.h

Issue 2239813002: [compiler] Allow matcher to work on arch without scaling capability (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Use Flags Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/ia32/instruction-selector-ia32.cc ('k') | src/compiler/ppc/instruction-selector-ppc.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/node-matchers.h
diff --git a/src/compiler/node-matchers.h b/src/compiler/node-matchers.h
index 19089c5d6c4219fc085e37547f7fd69980f73273..6cd52aeb3e75c59d207ca9bc6ebd086f3e29a580 100644
--- a/src/compiler/node-matchers.h
+++ b/src/compiler/node-matchers.h
@@ -396,14 +396,22 @@ enum DisplacementMode { kPositiveDisplacement, kNegativeDisplacement };
template <class AddMatcher>
Benedikt Meurer 2016/08/15 06:29:20 You need to move this enum out of the template cla
struct BaseWithIndexAndDisplacementMatcher {
- BaseWithIndexAndDisplacementMatcher(Node* node, bool allow_input_swap)
+ enum Flag {
+ kAllowNone = 0u,
+ kAllowInputSwap = 1u << 0,
+ kAllowScale = 1u << 1,
+ kAllowAll = kAllowInputSwap | kAllowScale
+ };
+
+ typedef base::Flags<Flag, uint8_t> Flags;
+ BaseWithIndexAndDisplacementMatcher(Node* node, Flags flags)
: matches_(false),
index_(nullptr),
scale_(0),
base_(nullptr),
displacement_(nullptr),
displacement_mode_(kPositiveDisplacement) {
- Initialize(node, allow_input_swap);
+ Initialize(node, flags);
}
explicit BaseWithIndexAndDisplacementMatcher(Node* node)
@@ -413,7 +421,10 @@ struct BaseWithIndexAndDisplacementMatcher {
base_(nullptr),
displacement_(nullptr),
displacement_mode_(kPositiveDisplacement) {
- Initialize(node, node->op()->HasProperty(Operator::kCommutative));
+ Initialize(node, Flags(kAllowScale) |
+ (node->op()->HasProperty(Operator::kCommutative)
+ ? kAllowInputSwap
+ : kAllowNone));
}
bool matches() const { return matches_; }
@@ -431,7 +442,7 @@ struct BaseWithIndexAndDisplacementMatcher {
Node* displacement_;
DisplacementMode displacement_mode_;
- void Initialize(Node* node, bool allow_input_swap) {
+ void Initialize(Node* node, Flags flags) {
// The BaseWithIndexAndDisplacementMatcher canonicalizes the order of
// displacements and scale factors that are used as inputs, so instead of
// enumerating all possible patterns by brute force, checking for node
@@ -449,7 +460,7 @@ struct BaseWithIndexAndDisplacementMatcher {
// (B + D)
// (B + B)
if (node->InputCount() < 2) return;
- AddMatcher m(node, allow_input_swap);
+ AddMatcher m(node, flags & kAllowInputSwap);
Node* left = m.left().node();
Node* right = m.right().node();
Node* displacement = nullptr;
@@ -608,6 +619,10 @@ struct BaseWithIndexAndDisplacementMatcher {
base = index;
}
}
+ if (!(flags & kAllowScale) && scale != 0) {
+ index = scale_expression;
+ scale = 0;
+ }
base_ = base;
displacement_ = displacement;
displacement_mode_ = displacement_mode;
« no previous file with comments | « src/compiler/ia32/instruction-selector-ia32.cc ('k') | src/compiler/ppc/instruction-selector-ppc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698