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

Side by Side Diff: test/unittests/compiler/node-test-utils.cc

Issue 931623002: [turbofan] Optimize certain chains of Branch into a Switch. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addrssed comments. Created 5 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "test/unittests/compiler/node-test-utils.h" 5 #include "test/unittests/compiler/node-test-utils.h"
6 6
7 #include "src/assembler.h" 7 #include "src/assembler.h"
8 #include "src/compiler/node-properties.h" 8 #include "src/compiler/node-properties.h"
9 #include "src/compiler/simplified-operator.h" 9 #include "src/compiler/simplified-operator.h"
10 #include "src/unique.h" 10 #include "src/unique.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 PrintMatchAndExplain(NodeProperties::GetControlInput(node), 88 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
89 "control", control_matcher_, listener)); 89 "control", control_matcher_, listener));
90 } 90 }
91 91
92 private: 92 private:
93 const Matcher<Node*> value_matcher_; 93 const Matcher<Node*> value_matcher_;
94 const Matcher<Node*> control_matcher_; 94 const Matcher<Node*> control_matcher_;
95 }; 95 };
96 96
97 97
98 class IsSwitchMatcher FINAL : public NodeMatcher {
99 public:
100 IsSwitchMatcher(const Matcher<Node*>& value_matcher,
101 const Matcher<Node*>& control_matcher)
102 : NodeMatcher(IrOpcode::kSwitch),
103 value_matcher_(value_matcher),
104 control_matcher_(control_matcher) {}
105
106 void DescribeTo(std::ostream* os) const FINAL {
107 NodeMatcher::DescribeTo(os);
108 *os << " whose value (";
109 value_matcher_.DescribeTo(os);
110 *os << ") and control (";
111 control_matcher_.DescribeTo(os);
112 *os << ")";
113 }
114
115 bool MatchAndExplain(Node* node, MatchResultListener* listener) const FINAL {
116 return (NodeMatcher::MatchAndExplain(node, listener) &&
117 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
118 "value", value_matcher_, listener) &&
119 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
120 "control", control_matcher_, listener));
121 }
122
123 private:
124 const Matcher<Node*> value_matcher_;
125 const Matcher<Node*> control_matcher_;
126 };
127
128
129 class IsIfValueMatcher FINAL : public NodeMatcher {
130 public:
131 IsIfValueMatcher(const Matcher<int32_t>& value_matcher,
132 const Matcher<Node*>& control_matcher)
133 : NodeMatcher(IrOpcode::kIfValue),
134 value_matcher_(value_matcher),
135 control_matcher_(control_matcher) {}
136
137 void DescribeTo(std::ostream* os) const FINAL {
138 NodeMatcher::DescribeTo(os);
139 *os << " whose value (";
140 value_matcher_.DescribeTo(os);
141 *os << ") and control (";
142 control_matcher_.DescribeTo(os);
143 *os << ")";
144 }
145
146 bool MatchAndExplain(Node* node, MatchResultListener* listener) const FINAL {
147 return (NodeMatcher::MatchAndExplain(node, listener) &&
148 PrintMatchAndExplain(OpParameter<int32_t>(node->op()), "value",
149 value_matcher_, listener) &&
150 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
151 "control", control_matcher_, listener));
152 }
153
154 private:
155 const Matcher<int32_t> value_matcher_;
156 const Matcher<Node*> control_matcher_;
157 };
158
159
98 class IsControl1Matcher FINAL : public NodeMatcher { 160 class IsControl1Matcher FINAL : public NodeMatcher {
99 public: 161 public:
100 IsControl1Matcher(IrOpcode::Value opcode, 162 IsControl1Matcher(IrOpcode::Value opcode,
101 const Matcher<Node*>& control_matcher) 163 const Matcher<Node*>& control_matcher)
102 : NodeMatcher(opcode), control_matcher_(control_matcher) {} 164 : NodeMatcher(opcode), control_matcher_(control_matcher) {}
103 165
104 void DescribeTo(std::ostream* os) const FINAL { 166 void DescribeTo(std::ostream* os) const FINAL {
105 NodeMatcher::DescribeTo(os); 167 NodeMatcher::DescribeTo(os);
106 *os << " whose control ("; 168 *os << " whose control (";
107 control_matcher_.DescribeTo(os); 169 control_matcher_.DescribeTo(os);
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 } 1262 }
1201 1263
1202 1264
1203 Matcher<Node*> IsMerge(const Matcher<Node*>& control0_matcher, 1265 Matcher<Node*> IsMerge(const Matcher<Node*>& control0_matcher,
1204 const Matcher<Node*>& control1_matcher) { 1266 const Matcher<Node*>& control1_matcher) {
1205 return MakeMatcher(new IsControl2Matcher(IrOpcode::kMerge, control0_matcher, 1267 return MakeMatcher(new IsControl2Matcher(IrOpcode::kMerge, control0_matcher,
1206 control1_matcher)); 1268 control1_matcher));
1207 } 1269 }
1208 1270
1209 1271
1272 Matcher<Node*> IsMerge(const Matcher<Node*>& control0_matcher,
1273 const Matcher<Node*>& control1_matcher,
1274 const Matcher<Node*>& control2_matcher) {
1275 return MakeMatcher(new IsControl3Matcher(IrOpcode::kMerge, control0_matcher,
1276 control1_matcher, control2_matcher));
1277 }
1278
1279
1210 Matcher<Node*> IsLoop(const Matcher<Node*>& control0_matcher, 1280 Matcher<Node*> IsLoop(const Matcher<Node*>& control0_matcher,
1211 const Matcher<Node*>& control1_matcher) { 1281 const Matcher<Node*>& control1_matcher) {
1212 return MakeMatcher(new IsControl2Matcher(IrOpcode::kLoop, control0_matcher, 1282 return MakeMatcher(new IsControl2Matcher(IrOpcode::kLoop, control0_matcher,
1213 control1_matcher)); 1283 control1_matcher));
1214 } 1284 }
1215 1285
1216 1286
1217 Matcher<Node*> IsLoop(const Matcher<Node*>& control0_matcher, 1287 Matcher<Node*> IsLoop(const Matcher<Node*>& control0_matcher,
1218 const Matcher<Node*>& control1_matcher, 1288 const Matcher<Node*>& control1_matcher,
1219 const Matcher<Node*>& control2_matcher) { 1289 const Matcher<Node*>& control2_matcher) {
1220 return MakeMatcher(new IsControl3Matcher(IrOpcode::kLoop, control0_matcher, 1290 return MakeMatcher(new IsControl3Matcher(IrOpcode::kLoop, control0_matcher,
1221 control1_matcher, control2_matcher)); 1291 control1_matcher, control2_matcher));
1222 } 1292 }
1223 1293
1224 1294
1225 Matcher<Node*> IsIfTrue(const Matcher<Node*>& control_matcher) { 1295 Matcher<Node*> IsIfTrue(const Matcher<Node*>& control_matcher) {
1226 return MakeMatcher(new IsControl1Matcher(IrOpcode::kIfTrue, control_matcher)); 1296 return MakeMatcher(new IsControl1Matcher(IrOpcode::kIfTrue, control_matcher));
1227 } 1297 }
1228 1298
1229 1299
1230 Matcher<Node*> IsIfFalse(const Matcher<Node*>& control_matcher) { 1300 Matcher<Node*> IsIfFalse(const Matcher<Node*>& control_matcher) {
1231 return MakeMatcher( 1301 return MakeMatcher(
1232 new IsControl1Matcher(IrOpcode::kIfFalse, control_matcher)); 1302 new IsControl1Matcher(IrOpcode::kIfFalse, control_matcher));
1233 } 1303 }
1234 1304
1235 1305
1306 Matcher<Node*> IsSwitch(const Matcher<Node*>& value_matcher,
1307 const Matcher<Node*>& control_matcher) {
1308 return MakeMatcher(new IsSwitchMatcher(value_matcher, control_matcher));
1309 }
1310
1311
1312 Matcher<Node*> IsIfValue(const Matcher<int32_t>& value_matcher,
1313 const Matcher<Node*>& control_matcher) {
1314 return MakeMatcher(new IsIfValueMatcher(value_matcher, control_matcher));
1315 }
1316
1317
1318 Matcher<Node*> IsIfDefault(const Matcher<Node*>& control_matcher) {
1319 return MakeMatcher(
1320 new IsControl1Matcher(IrOpcode::kIfDefault, control_matcher));
1321 }
1322
1323
1236 Matcher<Node*> IsValueEffect(const Matcher<Node*>& value_matcher) { 1324 Matcher<Node*> IsValueEffect(const Matcher<Node*>& value_matcher) {
1237 return MakeMatcher(new IsUnopMatcher(IrOpcode::kValueEffect, value_matcher)); 1325 return MakeMatcher(new IsUnopMatcher(IrOpcode::kValueEffect, value_matcher));
1238 } 1326 }
1239 1327
1240 1328
1241 Matcher<Node*> IsFinish(const Matcher<Node*>& value_matcher, 1329 Matcher<Node*> IsFinish(const Matcher<Node*>& value_matcher,
1242 const Matcher<Node*>& effect_matcher) { 1330 const Matcher<Node*>& effect_matcher) {
1243 return MakeMatcher(new IsFinishMatcher(value_matcher, effect_matcher)); 1331 return MakeMatcher(new IsFinishMatcher(value_matcher, effect_matcher));
1244 } 1332 }
1245 1333
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
1522 IS_UNOP_MATCHER(Float64RoundTiesAway) 1610 IS_UNOP_MATCHER(Float64RoundTiesAway)
1523 IS_UNOP_MATCHER(NumberToInt32) 1611 IS_UNOP_MATCHER(NumberToInt32)
1524 IS_UNOP_MATCHER(NumberToUint32) 1612 IS_UNOP_MATCHER(NumberToUint32)
1525 IS_UNOP_MATCHER(ObjectIsSmi) 1613 IS_UNOP_MATCHER(ObjectIsSmi)
1526 IS_UNOP_MATCHER(ObjectIsNonNegativeSmi) 1614 IS_UNOP_MATCHER(ObjectIsNonNegativeSmi)
1527 #undef IS_UNOP_MATCHER 1615 #undef IS_UNOP_MATCHER
1528 1616
1529 } // namespace compiler 1617 } // namespace compiler
1530 } // namespace internal 1618 } // namespace internal
1531 } // namespace v8 1619 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/node-test-utils.h ('k') | test/unittests/compiler/scheduler-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698