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

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

Issue 816053002: [turbofan] First version of loop peeling. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « test/unittests/compiler/node-test-utils.h ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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-inl.h" 8 #include "src/compiler/node-properties-inl.h"
9 #include "src/compiler/simplified-operator.h" 9 #include "src/compiler/simplified-operator.h"
10 10
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 PrintMatchAndExplain(NodeProperties::GetControlInput(node), 87 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
88 "control", control_matcher_, listener)); 88 "control", control_matcher_, listener));
89 } 89 }
90 90
91 private: 91 private:
92 const Matcher<Node*> value_matcher_; 92 const Matcher<Node*> value_matcher_;
93 const Matcher<Node*> control_matcher_; 93 const Matcher<Node*> control_matcher_;
94 }; 94 };
95 95
96 96
97 class IsMergeMatcher FINAL : public NodeMatcher { 97 class IsControl1Matcher FINAL : public NodeMatcher {
98 public: 98 public:
99 IsMergeMatcher(const Matcher<Node*>& control0_matcher, 99 IsControl1Matcher(IrOpcode::Value opcode,
100 const Matcher<Node*>& control1_matcher) 100 const Matcher<Node*>& control_matcher)
101 : NodeMatcher(IrOpcode::kMerge), 101 : NodeMatcher(opcode), control_matcher_(control_matcher) {}
102
103 void DescribeTo(std::ostream* os) const FINAL {
104 NodeMatcher::DescribeTo(os);
105 *os << " whose control (";
106 control_matcher_.DescribeTo(os);
107 *os << ")";
108 }
109
110 bool MatchAndExplain(Node* node, MatchResultListener* listener) const FINAL {
111 return (NodeMatcher::MatchAndExplain(node, listener) &&
112 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
113 "control", control_matcher_, listener));
114 }
115
116 private:
117 const Matcher<Node*> control_matcher_;
118 };
119
120
121 class IsControl2Matcher FINAL : public NodeMatcher {
122 public:
123 IsControl2Matcher(IrOpcode::Value opcode,
124 const Matcher<Node*>& control0_matcher,
125 const Matcher<Node*>& control1_matcher)
126 : NodeMatcher(opcode),
102 control0_matcher_(control0_matcher), 127 control0_matcher_(control0_matcher),
103 control1_matcher_(control1_matcher) {} 128 control1_matcher_(control1_matcher) {}
104 129
105 void DescribeTo(std::ostream* os) const FINAL { 130 void DescribeTo(std::ostream* os) const FINAL {
106 NodeMatcher::DescribeTo(os); 131 NodeMatcher::DescribeTo(os);
107 *os << " whose control0 ("; 132 *os << " whose control0 (";
108 control0_matcher_.DescribeTo(os); 133 control0_matcher_.DescribeTo(os);
109 *os << ") and control1 ("; 134 *os << ") and control1 (";
110 control1_matcher_.DescribeTo(os); 135 control1_matcher_.DescribeTo(os);
111 *os << ")"; 136 *os << ")";
112 } 137 }
113 138
114 bool MatchAndExplain(Node* node, MatchResultListener* listener) const FINAL { 139 bool MatchAndExplain(Node* node, MatchResultListener* listener) const FINAL {
115 return (NodeMatcher::MatchAndExplain(node, listener) && 140 return (NodeMatcher::MatchAndExplain(node, listener) &&
116 PrintMatchAndExplain(NodeProperties::GetControlInput(node, 0), 141 PrintMatchAndExplain(NodeProperties::GetControlInput(node, 0),
117 "control0", control0_matcher_, listener) && 142 "control0", control0_matcher_, listener) &&
118 PrintMatchAndExplain(NodeProperties::GetControlInput(node, 1), 143 PrintMatchAndExplain(NodeProperties::GetControlInput(node, 1),
119 "control1", control1_matcher_, listener)); 144 "control1", control1_matcher_, listener));
120 } 145 }
121 146
122 private: 147 private:
123 const Matcher<Node*> control0_matcher_; 148 const Matcher<Node*> control0_matcher_;
124 const Matcher<Node*> control1_matcher_; 149 const Matcher<Node*> control1_matcher_;
125 }; 150 };
126 151
127 152
128 class IsControl1Matcher FINAL : public NodeMatcher { 153 class IsControl3Matcher FINAL : public NodeMatcher {
129 public: 154 public:
130 IsControl1Matcher(IrOpcode::Value opcode, 155 IsControl3Matcher(IrOpcode::Value opcode,
131 const Matcher<Node*>& control_matcher) 156 const Matcher<Node*>& control0_matcher,
132 : NodeMatcher(opcode), control_matcher_(control_matcher) {} 157 const Matcher<Node*>& control1_matcher,
158 const Matcher<Node*>& control2_matcher)
159 : NodeMatcher(opcode),
160 control0_matcher_(control0_matcher),
161 control1_matcher_(control1_matcher),
162 control2_matcher_(control2_matcher) {}
133 163
134 void DescribeTo(std::ostream* os) const FINAL { 164 void DescribeTo(std::ostream* os) const FINAL {
135 NodeMatcher::DescribeTo(os); 165 NodeMatcher::DescribeTo(os);
136 *os << " whose control ("; 166 *os << " whose control0 (";
137 control_matcher_.DescribeTo(os); 167 control0_matcher_.DescribeTo(os);
168 *os << ") and control1 (";
169 control1_matcher_.DescribeTo(os);
170 *os << ") and control2 (";
171 control2_matcher_.DescribeTo(os);
138 *os << ")"; 172 *os << ")";
139 } 173 }
140 174
141 bool MatchAndExplain(Node* node, MatchResultListener* listener) const FINAL { 175 bool MatchAndExplain(Node* node, MatchResultListener* listener) const FINAL {
142 return (NodeMatcher::MatchAndExplain(node, listener) && 176 return (NodeMatcher::MatchAndExplain(node, listener) &&
143 PrintMatchAndExplain(NodeProperties::GetControlInput(node), 177 PrintMatchAndExplain(NodeProperties::GetControlInput(node, 0),
144 "control", control_matcher_, listener)); 178 "control0", control0_matcher_, listener) &&
179 PrintMatchAndExplain(NodeProperties::GetControlInput(node, 1),
180 "control1", control1_matcher_, listener) &&
181 PrintMatchAndExplain(NodeProperties::GetControlInput(node, 2),
182 "control2", control2_matcher_, listener));
145 } 183 }
146 184
147 private: 185 private:
148 const Matcher<Node*> control_matcher_; 186 const Matcher<Node*> control0_matcher_;
187 const Matcher<Node*> control1_matcher_;
188 const Matcher<Node*> control2_matcher_;
149 }; 189 };
150 190
151 191
152 class IsFinishMatcher FINAL : public NodeMatcher { 192 class IsFinishMatcher FINAL : public NodeMatcher {
153 public: 193 public:
154 IsFinishMatcher(const Matcher<Node*>& value_matcher, 194 IsFinishMatcher(const Matcher<Node*>& value_matcher,
155 const Matcher<Node*>& effect_matcher) 195 const Matcher<Node*>& effect_matcher)
156 : NodeMatcher(IrOpcode::kFinish), 196 : NodeMatcher(IrOpcode::kFinish),
157 value_matcher_(value_matcher), 197 value_matcher_(value_matcher),
158 effect_matcher_(effect_matcher) {} 198 effect_matcher_(effect_matcher) {}
(...skipping 14 matching lines...) Expand all
173 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", 213 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
174 effect_matcher_, listener)); 214 effect_matcher_, listener));
175 } 215 }
176 216
177 private: 217 private:
178 const Matcher<Node*> value_matcher_; 218 const Matcher<Node*> value_matcher_;
179 const Matcher<Node*> effect_matcher_; 219 const Matcher<Node*> effect_matcher_;
180 }; 220 };
181 221
182 222
223 class IsReturnMatcher FINAL : public NodeMatcher {
224 public:
225 IsReturnMatcher(const Matcher<Node*>& value_matcher,
226 const Matcher<Node*>& effect_matcher,
227 const Matcher<Node*>& control_matcher)
228 : NodeMatcher(IrOpcode::kReturn),
229 value_matcher_(value_matcher),
230 effect_matcher_(effect_matcher),
231 control_matcher_(control_matcher) {}
232
233 void DescribeTo(std::ostream* os) const FINAL {
234 NodeMatcher::DescribeTo(os);
235 *os << " whose value (";
236 value_matcher_.DescribeTo(os);
237 *os << ") and effect (";
238 effect_matcher_.DescribeTo(os);
239 *os << ") and control (";
240 control_matcher_.DescribeTo(os);
241 *os << ")";
242 }
243
244 bool MatchAndExplain(Node* node, MatchResultListener* listener) const FINAL {
245 return (NodeMatcher::MatchAndExplain(node, listener) &&
246 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
247 "value", value_matcher_, listener) &&
248 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
249 effect_matcher_, listener) &&
250 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
251 "control", control_matcher_, listener));
252 }
253
254 private:
255 const Matcher<Node*> value_matcher_;
256 const Matcher<Node*> effect_matcher_;
257 const Matcher<Node*> control_matcher_;
258 };
259
260
183 template <typename T> 261 template <typename T>
184 class IsConstantMatcher FINAL : public NodeMatcher { 262 class IsConstantMatcher FINAL : public NodeMatcher {
185 public: 263 public:
186 IsConstantMatcher(IrOpcode::Value opcode, const Matcher<T>& value_matcher) 264 IsConstantMatcher(IrOpcode::Value opcode, const Matcher<T>& value_matcher)
187 : NodeMatcher(opcode), value_matcher_(value_matcher) {} 265 : NodeMatcher(opcode), value_matcher_(value_matcher) {}
188 266
189 void DescribeTo(std::ostream* os) const FINAL { 267 void DescribeTo(std::ostream* os) const FINAL {
190 NodeMatcher::DescribeTo(os); 268 NodeMatcher::DescribeTo(os);
191 *os << " whose value ("; 269 *os << " whose value (";
192 value_matcher_.DescribeTo(os); 270 value_matcher_.DescribeTo(os);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 } 365 }
288 366
289 private: 367 private:
290 const Matcher<MachineType> type_matcher_; 368 const Matcher<MachineType> type_matcher_;
291 const Matcher<Node*> value0_matcher_; 369 const Matcher<Node*> value0_matcher_;
292 const Matcher<Node*> value1_matcher_; 370 const Matcher<Node*> value1_matcher_;
293 const Matcher<Node*> control_matcher_; 371 const Matcher<Node*> control_matcher_;
294 }; 372 };
295 373
296 374
375 class IsPhi2Matcher FINAL : public NodeMatcher {
376 public:
377 IsPhi2Matcher(const Matcher<MachineType>& type_matcher,
378 const Matcher<Node*>& value0_matcher,
379 const Matcher<Node*>& value1_matcher,
380 const Matcher<Node*>& value2_matcher,
381 const Matcher<Node*>& control_matcher)
382 : NodeMatcher(IrOpcode::kPhi),
383 type_matcher_(type_matcher),
384 value0_matcher_(value0_matcher),
385 value1_matcher_(value1_matcher),
386 value2_matcher_(value2_matcher),
387 control_matcher_(control_matcher) {}
388
389 void DescribeTo(std::ostream* os) const FINAL {
390 NodeMatcher::DescribeTo(os);
391 *os << " whose type (";
392 type_matcher_.DescribeTo(os);
393 *os << "), value0 (";
394 value0_matcher_.DescribeTo(os);
395 *os << "), value1 (";
396 value1_matcher_.DescribeTo(os);
397 *os << "), value2 (";
398 value2_matcher_.DescribeTo(os);
399 *os << ") and control (";
400 control_matcher_.DescribeTo(os);
401 *os << ")";
402 }
403
404 bool MatchAndExplain(Node* node, MatchResultListener* listener) const FINAL {
405 return (NodeMatcher::MatchAndExplain(node, listener) &&
406 PrintMatchAndExplain(OpParameter<MachineType>(node), "type",
407 type_matcher_, listener) &&
408 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
409 "value0", value0_matcher_, listener) &&
410 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
411 "value1", value1_matcher_, listener) &&
412 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2),
413 "value2", value2_matcher_, listener) &&
414 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
415 "control", control_matcher_, listener));
416 }
417
418 private:
419 const Matcher<MachineType> type_matcher_;
420 const Matcher<Node*> value0_matcher_;
421 const Matcher<Node*> value1_matcher_;
422 const Matcher<Node*> value2_matcher_;
423 const Matcher<Node*> control_matcher_;
424 };
425
426
297 class IsEffectPhiMatcher FINAL : public NodeMatcher { 427 class IsEffectPhiMatcher FINAL : public NodeMatcher {
298 public: 428 public:
299 IsEffectPhiMatcher(const Matcher<Node*>& effect0_matcher, 429 IsEffectPhiMatcher(const Matcher<Node*>& effect0_matcher,
300 const Matcher<Node*>& effect1_matcher, 430 const Matcher<Node*>& effect1_matcher,
301 const Matcher<Node*>& control_matcher) 431 const Matcher<Node*>& control_matcher)
302 : NodeMatcher(IrOpcode::kEffectPhi), 432 : NodeMatcher(IrOpcode::kEffectPhi),
303 effect0_matcher_(effect0_matcher), 433 effect0_matcher_(effect0_matcher),
304 effect1_matcher_(effect1_matcher), 434 effect1_matcher_(effect1_matcher),
305 control_matcher_(control_matcher) {} 435 control_matcher_(control_matcher) {}
306 436
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 1152
1023 1153
1024 Matcher<Node*> IsBranch(const Matcher<Node*>& value_matcher, 1154 Matcher<Node*> IsBranch(const Matcher<Node*>& value_matcher,
1025 const Matcher<Node*>& control_matcher) { 1155 const Matcher<Node*>& control_matcher) {
1026 return MakeMatcher(new IsBranchMatcher(value_matcher, control_matcher)); 1156 return MakeMatcher(new IsBranchMatcher(value_matcher, control_matcher));
1027 } 1157 }
1028 1158
1029 1159
1030 Matcher<Node*> IsMerge(const Matcher<Node*>& control0_matcher, 1160 Matcher<Node*> IsMerge(const Matcher<Node*>& control0_matcher,
1031 const Matcher<Node*>& control1_matcher) { 1161 const Matcher<Node*>& control1_matcher) {
1032 return MakeMatcher(new IsMergeMatcher(control0_matcher, control1_matcher)); 1162 return MakeMatcher(new IsControl2Matcher(IrOpcode::kMerge, control0_matcher,
1163 control1_matcher));
1033 } 1164 }
1034 1165
1035 1166
1167 Matcher<Node*> IsLoop(const Matcher<Node*>& control0_matcher,
1168 const Matcher<Node*>& control1_matcher) {
1169 return MakeMatcher(new IsControl2Matcher(IrOpcode::kLoop, control0_matcher,
1170 control1_matcher));
1171 }
1172
1173
1174 Matcher<Node*> IsLoop(const Matcher<Node*>& control0_matcher,
1175 const Matcher<Node*>& control1_matcher,
1176 const Matcher<Node*>& control2_matcher) {
1177 return MakeMatcher(new IsControl3Matcher(IrOpcode::kLoop, control0_matcher,
1178 control1_matcher, control2_matcher));
1179 }
1180
1181
1036 Matcher<Node*> IsIfTrue(const Matcher<Node*>& control_matcher) { 1182 Matcher<Node*> IsIfTrue(const Matcher<Node*>& control_matcher) {
1037 return MakeMatcher(new IsControl1Matcher(IrOpcode::kIfTrue, control_matcher)); 1183 return MakeMatcher(new IsControl1Matcher(IrOpcode::kIfTrue, control_matcher));
1038 } 1184 }
1039 1185
1040 1186
1041 Matcher<Node*> IsIfFalse(const Matcher<Node*>& control_matcher) { 1187 Matcher<Node*> IsIfFalse(const Matcher<Node*>& control_matcher) {
1042 return MakeMatcher( 1188 return MakeMatcher(
1043 new IsControl1Matcher(IrOpcode::kIfFalse, control_matcher)); 1189 new IsControl1Matcher(IrOpcode::kIfFalse, control_matcher));
1044 } 1190 }
1045 1191
1046 1192
1047 Matcher<Node*> IsValueEffect(const Matcher<Node*>& value_matcher) { 1193 Matcher<Node*> IsValueEffect(const Matcher<Node*>& value_matcher) {
1048 return MakeMatcher(new IsUnopMatcher(IrOpcode::kValueEffect, value_matcher)); 1194 return MakeMatcher(new IsUnopMatcher(IrOpcode::kValueEffect, value_matcher));
1049 } 1195 }
1050 1196
1051 1197
1052 Matcher<Node*> IsFinish(const Matcher<Node*>& value_matcher, 1198 Matcher<Node*> IsFinish(const Matcher<Node*>& value_matcher,
1053 const Matcher<Node*>& effect_matcher) { 1199 const Matcher<Node*>& effect_matcher) {
1054 return MakeMatcher(new IsFinishMatcher(value_matcher, effect_matcher)); 1200 return MakeMatcher(new IsFinishMatcher(value_matcher, effect_matcher));
1055 } 1201 }
1056 1202
1057 1203
1204 Matcher<Node*> IsReturn(const Matcher<Node*>& value_matcher,
1205 const Matcher<Node*>& effect_matcher,
1206 const Matcher<Node*>& control_matcher) {
1207 return MakeMatcher(
1208 new IsReturnMatcher(value_matcher, effect_matcher, control_matcher));
1209 }
1210
1211
1058 Matcher<Node*> IsExternalConstant( 1212 Matcher<Node*> IsExternalConstant(
1059 const Matcher<ExternalReference>& value_matcher) { 1213 const Matcher<ExternalReference>& value_matcher) {
1060 return MakeMatcher(new IsConstantMatcher<ExternalReference>( 1214 return MakeMatcher(new IsConstantMatcher<ExternalReference>(
1061 IrOpcode::kExternalConstant, value_matcher)); 1215 IrOpcode::kExternalConstant, value_matcher));
1062 } 1216 }
1063 1217
1064 1218
1065 Matcher<Node*> IsHeapConstant( 1219 Matcher<Node*> IsHeapConstant(
1066 const Matcher<Unique<HeapObject> >& value_matcher) { 1220 const Matcher<Unique<HeapObject> >& value_matcher) {
1067 return MakeMatcher(new IsConstantMatcher<Unique<HeapObject> >( 1221 return MakeMatcher(new IsConstantMatcher<Unique<HeapObject> >(
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 1264
1111 Matcher<Node*> IsPhi(const Matcher<MachineType>& type_matcher, 1265 Matcher<Node*> IsPhi(const Matcher<MachineType>& type_matcher,
1112 const Matcher<Node*>& value0_matcher, 1266 const Matcher<Node*>& value0_matcher,
1113 const Matcher<Node*>& value1_matcher, 1267 const Matcher<Node*>& value1_matcher,
1114 const Matcher<Node*>& merge_matcher) { 1268 const Matcher<Node*>& merge_matcher) {
1115 return MakeMatcher(new IsPhiMatcher(type_matcher, value0_matcher, 1269 return MakeMatcher(new IsPhiMatcher(type_matcher, value0_matcher,
1116 value1_matcher, merge_matcher)); 1270 value1_matcher, merge_matcher));
1117 } 1271 }
1118 1272
1119 1273
1274 Matcher<Node*> IsPhi(const Matcher<MachineType>& type_matcher,
1275 const Matcher<Node*>& value0_matcher,
1276 const Matcher<Node*>& value1_matcher,
1277 const Matcher<Node*>& value2_matcher,
1278 const Matcher<Node*>& merge_matcher) {
1279 return MakeMatcher(new IsPhi2Matcher(type_matcher, value0_matcher,
1280 value1_matcher, value2_matcher,
1281 merge_matcher));
1282 }
1283
1284
1120 Matcher<Node*> IsEffectPhi(const Matcher<Node*>& effect0_matcher, 1285 Matcher<Node*> IsEffectPhi(const Matcher<Node*>& effect0_matcher,
1121 const Matcher<Node*>& effect1_matcher, 1286 const Matcher<Node*>& effect1_matcher,
1122 const Matcher<Node*>& merge_matcher) { 1287 const Matcher<Node*>& merge_matcher) {
1123 return MakeMatcher( 1288 return MakeMatcher(
1124 new IsEffectPhiMatcher(effect0_matcher, effect1_matcher, merge_matcher)); 1289 new IsEffectPhiMatcher(effect0_matcher, effect1_matcher, merge_matcher));
1125 } 1290 }
1126 1291
1127 1292
1128 Matcher<Node*> IsProjection(const Matcher<size_t>& index_matcher, 1293 Matcher<Node*> IsProjection(const Matcher<size_t>& index_matcher,
1129 const Matcher<Node*>& base_matcher) { 1294 const Matcher<Node*>& base_matcher) {
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 IS_UNOP_MATCHER(Float64Ceil) 1471 IS_UNOP_MATCHER(Float64Ceil)
1307 IS_UNOP_MATCHER(Float64RoundTruncate) 1472 IS_UNOP_MATCHER(Float64RoundTruncate)
1308 IS_UNOP_MATCHER(Float64RoundTiesAway) 1473 IS_UNOP_MATCHER(Float64RoundTiesAway)
1309 IS_UNOP_MATCHER(NumberToInt32) 1474 IS_UNOP_MATCHER(NumberToInt32)
1310 IS_UNOP_MATCHER(NumberToUint32) 1475 IS_UNOP_MATCHER(NumberToUint32)
1311 #undef IS_UNOP_MATCHER 1476 #undef IS_UNOP_MATCHER
1312 1477
1313 } // namespace compiler 1478 } // namespace compiler
1314 } // namespace internal 1479 } // namespace internal
1315 } // namespace v8 1480 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/node-test-utils.h ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698