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

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

Issue 615483003: [turbofan] x64 lea multiplication matching (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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
Index: src/compiler/node-matchers.h
diff --git a/src/compiler/node-matchers.h b/src/compiler/node-matchers.h
index 6019cba3a593fa9a64a9bc2cbf7cd4a37719ecbb..c69401c6f6996447594b9c1c9e37d2279b83d172 100644
--- a/src/compiler/node-matchers.h
+++ b/src/compiler/node-matchers.h
@@ -145,6 +145,8 @@ typedef BinopMatcher<Float64Matcher, Float64Matcher> Float64BinopMatcher;
// Matches nodes of form [x * N] for N in {1,2,4,8}
class ScaleFactorMatcher : public NodeMatcher {
public:
+ static const int kMatchedFactors[4];
+
explicit ScaleFactorMatcher(Node* node)
: NodeMatcher(node), left_(NULL), power_(0) {
Match();
@@ -161,25 +163,7 @@ class ScaleFactorMatcher : public NodeMatcher {
}
private:
- void Match() {
- if (opcode() != IrOpcode::kInt32Mul) return;
- Int32BinopMatcher m(node());
- if (!m.right().HasValue()) return;
- int32_t value = m.right().Value();
- switch (value) {
- case 8:
- power_++; // Fall through.
- case 4:
- power_++; // Fall through.
- case 2:
- power_++; // Fall through.
- case 1:
- break;
- default:
- return;
- }
- left_ = m.left().node();
- }
+ void Match();
Node* left_;
int power_;
@@ -206,22 +190,7 @@ class IndexAndDisplacementMatcher : public NodeMatcher {
int power() { return power_; }
private:
- void Match() {
- if (opcode() == IrOpcode::kInt32Add) {
- // Assume reduction has put constant on the right.
- Int32BinopMatcher m(node());
- if (m.right().HasValue()) {
- displacement_ = m.right().Value();
- index_node_ = m.left().node();
- }
- }
- // Test scale factor.
- ScaleFactorMatcher scale_matcher(index_node_);
- if (scale_matcher.Matches()) {
- index_node_ = scale_matcher.Left();
- power_ = scale_matcher.Power();
- }
- }
+ void Match();
Node* index_node_;
int displacement_;
@@ -229,6 +198,44 @@ class IndexAndDisplacementMatcher : public NodeMatcher {
};
+// Fairly intel-specify node matcher used for matching multiplies that can be
+// transformed to lea instructions.
+// Matches nodes of form:
+// [x * N]
+// for N in {1,2,3,4,5,8,9}
+class LeaMultiplyMatcher : public NodeMatcher {
+ public:
+ static const int kMatchedFactors[7];
+
+ explicit LeaMultiplyMatcher(Node* node)
+ : NodeMatcher(node), left_(NULL), power_(0), displacement_(0) {
+ Match();
+ }
+
+ bool Matches() { return left_ != NULL; }
Benedikt Meurer 2014/09/30 04:55:04 Nit: const
dcarney 2014/09/30 08:03:22 Done.
+ int Power() {
Benedikt Meurer 2014/09/30 04:55:04 Nit: const
dcarney 2014/09/30 08:03:22 Done.
+ DCHECK(Matches());
+ return power_;
+ }
+ Node* Left() {
Benedikt Meurer 2014/09/30 04:55:04 Nit: const
dcarney 2014/09/30 08:03:22 Done.
+ DCHECK(Matches());
+ return left_;
+ }
+ // Displacement will be either 0 or 1.
+ int32_t Displacement() {
Benedikt Meurer 2014/09/30 04:55:04 Nit: const
dcarney 2014/09/30 08:03:22 Done.
+ DCHECK(Matches());
+ return displacement_;
+ }
+
+ private:
+ void Match();
Benedikt Meurer 2014/09/30 04:55:04 Hm, those Match method(s) could be inlined into th
dcarney 2014/09/30 08:03:22 Done.
+
+ Node* left_;
+ int power_;
+ int displacement_;
+};
+
+
} // namespace compiler
} // namespace internal
} // namespace v8

Powered by Google App Engine
This is Rietveld 408576698