Line data Source code
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
3 : // found in the LICENSE file.
4 :
5 : #include "test/unittests/compiler/node-test-utils.h"
6 :
7 : #include <vector>
8 :
9 : #include "src/assembler.h"
10 : #include "src/compiler/common-operator.h"
11 : #include "src/compiler/js-operator.h"
12 : #include "src/compiler/node-properties.h"
13 : #include "src/compiler/simplified-operator.h"
14 : #include "src/handles-inl.h"
15 : #include "src/objects-inl.h"
16 : #include "src/objects.h"
17 :
18 : using testing::_;
19 : using testing::MakeMatcher;
20 : using testing::MatcherInterface;
21 : using testing::MatchResultListener;
22 : using testing::StringMatchResultListener;
23 :
24 : namespace v8 {
25 : namespace internal {
26 :
27 0 : bool operator==(Handle<HeapObject> const& lhs, Handle<HeapObject> const& rhs) {
28 0 : return lhs.is_identical_to(rhs);
29 : }
30 :
31 : namespace compiler {
32 :
33 : namespace {
34 :
35 : template <typename T>
36 358683 : bool PrintMatchAndExplain(const T& value, const std::string& value_name,
37 : const Matcher<T>& value_matcher,
38 : MatchResultListener* listener) {
39 : StringMatchResultListener value_listener;
40 714187 : if (!value_matcher.MatchAndExplain(value, &value_listener)) {
41 : *listener << "whose " << value_name << " " << value << " doesn't match";
42 0 : if (value_listener.str() != "") {
43 0 : *listener << ", " << value_listener.str();
44 : }
45 : return false;
46 : }
47 : return true;
48 : }
49 :
50 284620 : class TestNodeMatcher : public MatcherInterface<Node*> {
51 : public:
52 283516 : explicit TestNodeMatcher(IrOpcode::Value opcode) : opcode_(opcode) {}
53 :
54 0 : void DescribeTo(std::ostream* os) const override {
55 0 : *os << "is a " << IrOpcode::Mnemonic(opcode_) << " node";
56 0 : }
57 :
58 567278 : bool MatchAndExplain(Node* node,
59 : MatchResultListener* listener) const override {
60 283639 : if (node == NULL) {
61 : *listener << "which is NULL";
62 : return false;
63 : }
64 283639 : if (node->opcode() != opcode_) {
65 0 : *listener << "whose opcode is " << IrOpcode::Mnemonic(node->opcode())
66 0 : << " but should have been " << IrOpcode::Mnemonic(opcode_);
67 : return false;
68 : }
69 : return true;
70 : }
71 :
72 : private:
73 : const IrOpcode::Value opcode_;
74 : };
75 :
76 504 : class IsBranchMatcher final : public TestNodeMatcher {
77 : public:
78 168 : IsBranchMatcher(const Matcher<Node*>& value_matcher,
79 : const Matcher<Node*>& control_matcher)
80 : : TestNodeMatcher(IrOpcode::kBranch),
81 : value_matcher_(value_matcher),
82 336 : control_matcher_(control_matcher) {}
83 :
84 0 : void DescribeTo(std::ostream* os) const final {
85 0 : TestNodeMatcher::DescribeTo(os);
86 0 : *os << " whose value (";
87 : value_matcher_.DescribeTo(os);
88 0 : *os << ") and control (";
89 : control_matcher_.DescribeTo(os);
90 0 : *os << ")";
91 0 : }
92 :
93 177 : bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
94 354 : return (TestNodeMatcher::MatchAndExplain(node, listener) &&
95 177 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
96 1062 : "value", value_matcher_, listener) &&
97 177 : PrintMatchAndExplain(NodeProperties::GetControlInput(node),
98 885 : "control", control_matcher_, listener));
99 : }
100 :
101 : private:
102 : const Matcher<Node*> value_matcher_;
103 : const Matcher<Node*> control_matcher_;
104 : };
105 :
106 6 : class IsSwitchMatcher final : public TestNodeMatcher {
107 : public:
108 2 : IsSwitchMatcher(const Matcher<Node*>& value_matcher,
109 : const Matcher<Node*>& control_matcher)
110 : : TestNodeMatcher(IrOpcode::kSwitch),
111 : value_matcher_(value_matcher),
112 4 : control_matcher_(control_matcher) {}
113 :
114 0 : void DescribeTo(std::ostream* os) const final {
115 0 : TestNodeMatcher::DescribeTo(os);
116 0 : *os << " whose value (";
117 : value_matcher_.DescribeTo(os);
118 0 : *os << ") and control (";
119 : control_matcher_.DescribeTo(os);
120 0 : *os << ")";
121 0 : }
122 :
123 2 : bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
124 4 : return (TestNodeMatcher::MatchAndExplain(node, listener) &&
125 2 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
126 12 : "value", value_matcher_, listener) &&
127 2 : PrintMatchAndExplain(NodeProperties::GetControlInput(node),
128 10 : "control", control_matcher_, listener));
129 : }
130 :
131 : private:
132 : const Matcher<Node*> value_matcher_;
133 : const Matcher<Node*> control_matcher_;
134 : };
135 :
136 12 : class IsIfValueMatcher final : public TestNodeMatcher {
137 : public:
138 4 : IsIfValueMatcher(const Matcher<int32_t>& value_matcher,
139 : const Matcher<Node*>& control_matcher)
140 : : TestNodeMatcher(IrOpcode::kIfValue),
141 : value_matcher_(value_matcher),
142 8 : control_matcher_(control_matcher) {}
143 :
144 0 : void DescribeTo(std::ostream* os) const final {
145 0 : TestNodeMatcher::DescribeTo(os);
146 0 : *os << " whose value (";
147 : value_matcher_.DescribeTo(os);
148 0 : *os << ") and control (";
149 : control_matcher_.DescribeTo(os);
150 0 : *os << ")";
151 0 : }
152 :
153 8 : bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
154 8 : return (TestNodeMatcher::MatchAndExplain(node, listener) &&
155 4 : PrintMatchAndExplain(OpParameter<int32_t>(node->op()), "value",
156 24 : value_matcher_, listener) &&
157 4 : PrintMatchAndExplain(NodeProperties::GetControlInput(node),
158 20 : "control", control_matcher_, listener));
159 : }
160 :
161 : private:
162 : const Matcher<int32_t> value_matcher_;
163 : const Matcher<Node*> control_matcher_;
164 : };
165 :
166 398 : class IsControl1Matcher final : public TestNodeMatcher {
167 : public:
168 199 : IsControl1Matcher(IrOpcode::Value opcode,
169 : const Matcher<Node*>& control_matcher)
170 398 : : TestNodeMatcher(opcode), control_matcher_(control_matcher) {}
171 :
172 0 : void DescribeTo(std::ostream* os) const final {
173 0 : TestNodeMatcher::DescribeTo(os);
174 0 : *os << " whose control (";
175 : control_matcher_.DescribeTo(os);
176 0 : *os << ")";
177 0 : }
178 :
179 203 : bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
180 406 : return (TestNodeMatcher::MatchAndExplain(node, listener) &&
181 203 : PrintMatchAndExplain(NodeProperties::GetControlInput(node),
182 812 : "control", control_matcher_, listener));
183 : }
184 :
185 : private:
186 : const Matcher<Node*> control_matcher_;
187 : };
188 :
189 306 : class IsControl2Matcher final : public TestNodeMatcher {
190 : public:
191 102 : IsControl2Matcher(IrOpcode::Value opcode,
192 : const Matcher<Node*>& control0_matcher,
193 : const Matcher<Node*>& control1_matcher)
194 : : TestNodeMatcher(opcode),
195 : control0_matcher_(control0_matcher),
196 204 : control1_matcher_(control1_matcher) {}
197 :
198 0 : void DescribeTo(std::ostream* os) const final {
199 0 : TestNodeMatcher::DescribeTo(os);
200 0 : *os << " whose control0 (";
201 : control0_matcher_.DescribeTo(os);
202 0 : *os << ") and control1 (";
203 : control1_matcher_.DescribeTo(os);
204 0 : *os << ")";
205 0 : }
206 :
207 104 : bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
208 208 : return (TestNodeMatcher::MatchAndExplain(node, listener) &&
209 104 : PrintMatchAndExplain(NodeProperties::GetControlInput(node, 0),
210 624 : "control0", control0_matcher_, listener) &&
211 104 : PrintMatchAndExplain(NodeProperties::GetControlInput(node, 1),
212 520 : "control1", control1_matcher_, listener));
213 : }
214 :
215 : private:
216 : const Matcher<Node*> control0_matcher_;
217 : const Matcher<Node*> control1_matcher_;
218 : };
219 :
220 18 : class IsControl3Matcher final : public TestNodeMatcher {
221 : public:
222 6 : IsControl3Matcher(IrOpcode::Value opcode,
223 : const Matcher<Node*>& control0_matcher,
224 : const Matcher<Node*>& control1_matcher,
225 : const Matcher<Node*>& control2_matcher)
226 : : TestNodeMatcher(opcode),
227 : control0_matcher_(control0_matcher),
228 : control1_matcher_(control1_matcher),
229 12 : control2_matcher_(control2_matcher) {}
230 :
231 0 : void DescribeTo(std::ostream* os) const final {
232 0 : TestNodeMatcher::DescribeTo(os);
233 0 : *os << " whose control0 (";
234 : control0_matcher_.DescribeTo(os);
235 0 : *os << ") and control1 (";
236 : control1_matcher_.DescribeTo(os);
237 0 : *os << ") and control2 (";
238 : control2_matcher_.DescribeTo(os);
239 0 : *os << ")";
240 0 : }
241 :
242 6 : bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
243 12 : return (TestNodeMatcher::MatchAndExplain(node, listener) &&
244 6 : PrintMatchAndExplain(NodeProperties::GetControlInput(node, 0),
245 36 : "control0", control0_matcher_, listener) &&
246 6 : PrintMatchAndExplain(NodeProperties::GetControlInput(node, 1),
247 36 : "control1", control1_matcher_, listener) &&
248 6 : PrintMatchAndExplain(NodeProperties::GetControlInput(node, 2),
249 30 : "control2", control2_matcher_, listener));
250 : }
251 :
252 : private:
253 : const Matcher<Node*> control0_matcher_;
254 : const Matcher<Node*> control1_matcher_;
255 : const Matcher<Node*> control2_matcher_;
256 : };
257 :
258 8 : class IsBeginRegionMatcher final : public TestNodeMatcher {
259 : public:
260 4 : explicit IsBeginRegionMatcher(const Matcher<Node*>& effect_matcher)
261 : : TestNodeMatcher(IrOpcode::kBeginRegion),
262 8 : effect_matcher_(effect_matcher) {}
263 :
264 0 : void DescribeTo(std::ostream* os) const final {
265 0 : TestNodeMatcher::DescribeTo(os);
266 0 : *os << " whose effect (";
267 : effect_matcher_.DescribeTo(os);
268 0 : *os << ")";
269 0 : }
270 :
271 4 : bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
272 8 : return (TestNodeMatcher::MatchAndExplain(node, listener) &&
273 4 : PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
274 16 : effect_matcher_, listener));
275 : }
276 :
277 : private:
278 : const Matcher<Node*> effect_matcher_;
279 : };
280 :
281 21 : class IsFinishRegionMatcher final : public TestNodeMatcher {
282 : public:
283 7 : IsFinishRegionMatcher(const Matcher<Node*>& value_matcher,
284 : const Matcher<Node*>& effect_matcher)
285 : : TestNodeMatcher(IrOpcode::kFinishRegion),
286 : value_matcher_(value_matcher),
287 14 : effect_matcher_(effect_matcher) {}
288 :
289 0 : void DescribeTo(std::ostream* os) const final {
290 0 : TestNodeMatcher::DescribeTo(os);
291 0 : *os << " whose value (";
292 : value_matcher_.DescribeTo(os);
293 0 : *os << ") and effect (";
294 : effect_matcher_.DescribeTo(os);
295 0 : *os << ")";
296 0 : }
297 :
298 7 : bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
299 14 : return (TestNodeMatcher::MatchAndExplain(node, listener) &&
300 7 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
301 42 : "value", value_matcher_, listener) &&
302 7 : PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
303 35 : effect_matcher_, listener));
304 : }
305 :
306 : private:
307 : const Matcher<Node*> value_matcher_;
308 : const Matcher<Node*> effect_matcher_;
309 : };
310 :
311 174 : class IsReturnMatcher final : public TestNodeMatcher {
312 : public:
313 30 : IsReturnMatcher(const Matcher<Node*>& value_matcher,
314 : const Matcher<Node*>& effect_matcher,
315 : const Matcher<Node*>& control_matcher)
316 : : TestNodeMatcher(IrOpcode::kReturn),
317 : value_matcher_(value_matcher),
318 : value2_matcher_(_),
319 : effect_matcher_(effect_matcher),
320 : control_matcher_(control_matcher),
321 60 : has_second_return_value_(false) {}
322 :
323 28 : IsReturnMatcher(const Matcher<Node*>& value_matcher,
324 : const Matcher<Node*>& value2_matcher,
325 : const Matcher<Node*>& effect_matcher,
326 : const Matcher<Node*>& control_matcher)
327 : : TestNodeMatcher(IrOpcode::kReturn),
328 : value_matcher_(value_matcher),
329 : value2_matcher_(value2_matcher),
330 : effect_matcher_(effect_matcher),
331 : control_matcher_(control_matcher),
332 56 : has_second_return_value_(true) {}
333 :
334 0 : void DescribeTo(std::ostream* os) const final {
335 0 : TestNodeMatcher::DescribeTo(os);
336 0 : *os << " whose value (";
337 : value_matcher_.DescribeTo(os);
338 0 : if (has_second_return_value_) {
339 0 : *os << ") and second value (";
340 : value2_matcher_.DescribeTo(os);
341 : }
342 0 : *os << ") and effect (";
343 : effect_matcher_.DescribeTo(os);
344 0 : *os << ") and control (";
345 : control_matcher_.DescribeTo(os);
346 0 : *os << ")";
347 0 : }
348 :
349 58 : bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
350 116 : return (TestNodeMatcher::MatchAndExplain(node, listener) &&
351 58 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
352 348 : "value", value_matcher_, listener) &&
353 86 : (!has_second_return_value_ ||
354 28 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2),
355 200 : "value2", value2_matcher_, listener)) &&
356 58 : PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
357 348 : effect_matcher_, listener) &&
358 58 : PrintMatchAndExplain(NodeProperties::GetControlInput(node),
359 290 : "control", control_matcher_, listener));
360 : }
361 :
362 : private:
363 : const Matcher<Node*> value_matcher_;
364 : const Matcher<Node*> value2_matcher_;
365 : const Matcher<Node*> effect_matcher_;
366 : const Matcher<Node*> control_matcher_;
367 : bool has_second_return_value_;
368 : };
369 :
370 0 : class IsTerminateMatcher final : public TestNodeMatcher {
371 : public:
372 0 : IsTerminateMatcher(const Matcher<Node*>& effect_matcher,
373 : const Matcher<Node*>& control_matcher)
374 : : TestNodeMatcher(IrOpcode::kTerminate),
375 : effect_matcher_(effect_matcher),
376 0 : control_matcher_(control_matcher) {}
377 :
378 0 : void DescribeTo(std::ostream* os) const final {
379 0 : TestNodeMatcher::DescribeTo(os);
380 0 : *os << " whose effect (";
381 : effect_matcher_.DescribeTo(os);
382 0 : *os << ") and control (";
383 : control_matcher_.DescribeTo(os);
384 0 : *os << ")";
385 0 : }
386 :
387 0 : bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
388 0 : return (TestNodeMatcher::MatchAndExplain(node, listener) &&
389 0 : PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
390 0 : effect_matcher_, listener) &&
391 0 : PrintMatchAndExplain(NodeProperties::GetControlInput(node),
392 0 : "control", control_matcher_, listener));
393 : }
394 :
395 : private:
396 : const Matcher<Node*> effect_matcher_;
397 : const Matcher<Node*> control_matcher_;
398 : };
399 :
400 0 : class IsTypeGuardMatcher final : public TestNodeMatcher {
401 : public:
402 0 : IsTypeGuardMatcher(const Matcher<Node*>& value_matcher,
403 : const Matcher<Node*>& control_matcher)
404 : : TestNodeMatcher(IrOpcode::kTypeGuard),
405 : value_matcher_(value_matcher),
406 0 : control_matcher_(control_matcher) {}
407 :
408 0 : void DescribeTo(std::ostream* os) const final {
409 0 : TestNodeMatcher::DescribeTo(os);
410 0 : *os << " whose value (";
411 : value_matcher_.DescribeTo(os);
412 0 : *os << ") and control (";
413 : control_matcher_.DescribeTo(os);
414 0 : *os << ")";
415 0 : }
416 :
417 0 : bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
418 0 : return (TestNodeMatcher::MatchAndExplain(node, listener) &&
419 0 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
420 0 : "value", value_matcher_, listener) &&
421 0 : PrintMatchAndExplain(NodeProperties::GetControlInput(node),
422 0 : "control", control_matcher_, listener));
423 : }
424 :
425 : private:
426 : const Matcher<Node*> value_matcher_;
427 : const Matcher<Node*> control_matcher_;
428 : };
429 :
430 : template <typename T>
431 427694 : class IsConstantMatcher final : public TestNodeMatcher {
432 : public:
433 213847 : IsConstantMatcher(IrOpcode::Value opcode, const Matcher<T>& value_matcher)
434 427694 : : TestNodeMatcher(opcode), value_matcher_(value_matcher) {}
435 :
436 0 : void DescribeTo(std::ostream* os) const final {
437 0 : TestNodeMatcher::DescribeTo(os);
438 0 : *os << " whose value (";
439 : value_matcher_.DescribeTo(os);
440 0 : *os << ")";
441 0 : }
442 :
443 213901 : bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
444 213901 : return (TestNodeMatcher::MatchAndExplain(node, listener) &&
445 213901 : PrintMatchAndExplain(OpParameter<T>(node), "value", value_matcher_,
446 641703 : listener));
447 : }
448 :
449 : private:
450 : const Matcher<T> value_matcher_;
451 : };
452 :
453 3 : class IsSelectMatcher final : public TestNodeMatcher {
454 : public:
455 1 : IsSelectMatcher(const Matcher<MachineRepresentation>& type_matcher,
456 : const Matcher<Node*>& value0_matcher,
457 : const Matcher<Node*>& value1_matcher,
458 : const Matcher<Node*>& value2_matcher)
459 : : TestNodeMatcher(IrOpcode::kSelect),
460 : type_matcher_(type_matcher),
461 : value0_matcher_(value0_matcher),
462 : value1_matcher_(value1_matcher),
463 2 : value2_matcher_(value2_matcher) {}
464 :
465 0 : void DescribeTo(std::ostream* os) const final {
466 0 : TestNodeMatcher::DescribeTo(os);
467 0 : *os << " whose representation (";
468 : type_matcher_.DescribeTo(os);
469 0 : *os << "), value0 (";
470 : value0_matcher_.DescribeTo(os);
471 0 : *os << "), value1 (";
472 : value1_matcher_.DescribeTo(os);
473 0 : *os << ") and value2 (";
474 : value2_matcher_.DescribeTo(os);
475 0 : *os << ")";
476 0 : }
477 :
478 2 : bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
479 : return (
480 2 : TestNodeMatcher::MatchAndExplain(node, listener) &&
481 1 : PrintMatchAndExplain(SelectParametersOf(node->op()).representation(),
482 6 : "representation", type_matcher_, listener) &&
483 1 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "value0",
484 5 : value0_matcher_, listener) &&
485 1 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "value1",
486 6 : value1_matcher_, listener) &&
487 1 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2), "value2",
488 5 : value2_matcher_, listener));
489 : }
490 :
491 : private:
492 : const Matcher<MachineRepresentation> type_matcher_;
493 : const Matcher<Node*> value0_matcher_;
494 : const Matcher<Node*> value1_matcher_;
495 : const Matcher<Node*> value2_matcher_;
496 : };
497 :
498 261 : class IsPhiMatcher final : public TestNodeMatcher {
499 : public:
500 87 : IsPhiMatcher(const Matcher<MachineRepresentation>& type_matcher,
501 : const Matcher<Node*>& value0_matcher,
502 : const Matcher<Node*>& value1_matcher,
503 : const Matcher<Node*>& control_matcher)
504 : : TestNodeMatcher(IrOpcode::kPhi),
505 : type_matcher_(type_matcher),
506 : value0_matcher_(value0_matcher),
507 : value1_matcher_(value1_matcher),
508 174 : control_matcher_(control_matcher) {}
509 :
510 0 : void DescribeTo(std::ostream* os) const final {
511 0 : TestNodeMatcher::DescribeTo(os);
512 0 : *os << " whose representation (";
513 : type_matcher_.DescribeTo(os);
514 0 : *os << "), value0 (";
515 : value0_matcher_.DescribeTo(os);
516 0 : *os << "), value1 (";
517 : value1_matcher_.DescribeTo(os);
518 0 : *os << ") and control (";
519 : control_matcher_.DescribeTo(os);
520 0 : *os << ")";
521 0 : }
522 :
523 178 : bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
524 178 : return (TestNodeMatcher::MatchAndExplain(node, listener) &&
525 89 : PrintMatchAndExplain(PhiRepresentationOf(node->op()),
526 534 : "representation", type_matcher_, listener) &&
527 89 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
528 445 : "value0", value0_matcher_, listener) &&
529 89 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
530 534 : "value1", value1_matcher_, listener) &&
531 89 : PrintMatchAndExplain(NodeProperties::GetControlInput(node),
532 445 : "control", control_matcher_, listener));
533 : }
534 :
535 : private:
536 : const Matcher<MachineRepresentation> type_matcher_;
537 : const Matcher<Node*> value0_matcher_;
538 : const Matcher<Node*> value1_matcher_;
539 : const Matcher<Node*> control_matcher_;
540 : };
541 :
542 6 : class IsPhi2Matcher final : public TestNodeMatcher {
543 : public:
544 2 : IsPhi2Matcher(const Matcher<MachineRepresentation>& type_matcher,
545 : const Matcher<Node*>& value0_matcher,
546 : const Matcher<Node*>& value1_matcher,
547 : const Matcher<Node*>& value2_matcher,
548 : const Matcher<Node*>& control_matcher)
549 : : TestNodeMatcher(IrOpcode::kPhi),
550 : type_matcher_(type_matcher),
551 : value0_matcher_(value0_matcher),
552 : value1_matcher_(value1_matcher),
553 : value2_matcher_(value2_matcher),
554 4 : control_matcher_(control_matcher) {}
555 :
556 0 : void DescribeTo(std::ostream* os) const final {
557 0 : TestNodeMatcher::DescribeTo(os);
558 0 : *os << " whose representation (";
559 : type_matcher_.DescribeTo(os);
560 0 : *os << "), value0 (";
561 : value0_matcher_.DescribeTo(os);
562 0 : *os << "), value1 (";
563 : value1_matcher_.DescribeTo(os);
564 0 : *os << "), value2 (";
565 : value2_matcher_.DescribeTo(os);
566 0 : *os << ") and control (";
567 : control_matcher_.DescribeTo(os);
568 0 : *os << ")";
569 0 : }
570 :
571 4 : bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
572 4 : return (TestNodeMatcher::MatchAndExplain(node, listener) &&
573 2 : PrintMatchAndExplain(PhiRepresentationOf(node->op()),
574 12 : "representation", type_matcher_, listener) &&
575 2 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
576 10 : "value0", value0_matcher_, listener) &&
577 2 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
578 10 : "value1", value1_matcher_, listener) &&
579 2 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2),
580 12 : "value2", value2_matcher_, listener) &&
581 2 : PrintMatchAndExplain(NodeProperties::GetControlInput(node),
582 10 : "control", control_matcher_, listener));
583 : }
584 :
585 : private:
586 : const Matcher<MachineRepresentation> type_matcher_;
587 : const Matcher<Node*> value0_matcher_;
588 : const Matcher<Node*> value1_matcher_;
589 : const Matcher<Node*> value2_matcher_;
590 : const Matcher<Node*> control_matcher_;
591 : };
592 :
593 9 : class IsEffectPhiMatcher final : public TestNodeMatcher {
594 : public:
595 3 : IsEffectPhiMatcher(const Matcher<Node*>& effect0_matcher,
596 : const Matcher<Node*>& effect1_matcher,
597 : const Matcher<Node*>& control_matcher)
598 : : TestNodeMatcher(IrOpcode::kEffectPhi),
599 : effect0_matcher_(effect0_matcher),
600 : effect1_matcher_(effect1_matcher),
601 6 : control_matcher_(control_matcher) {}
602 :
603 0 : void DescribeTo(std::ostream* os) const final {
604 0 : TestNodeMatcher::DescribeTo(os);
605 0 : *os << "), effect0 (";
606 : effect0_matcher_.DescribeTo(os);
607 0 : *os << "), effect1 (";
608 : effect1_matcher_.DescribeTo(os);
609 0 : *os << ") and control (";
610 : control_matcher_.DescribeTo(os);
611 0 : *os << ")";
612 0 : }
613 :
614 3 : bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
615 6 : return (TestNodeMatcher::MatchAndExplain(node, listener) &&
616 3 : PrintMatchAndExplain(NodeProperties::GetEffectInput(node, 0),
617 18 : "effect0", effect0_matcher_, listener) &&
618 3 : PrintMatchAndExplain(NodeProperties::GetEffectInput(node, 1),
619 18 : "effect1", effect1_matcher_, listener) &&
620 3 : PrintMatchAndExplain(NodeProperties::GetControlInput(node),
621 15 : "control", control_matcher_, listener));
622 : }
623 :
624 : private:
625 : const Matcher<Node*> effect0_matcher_;
626 : const Matcher<Node*> effect1_matcher_;
627 : const Matcher<Node*> control_matcher_;
628 : };
629 :
630 30 : class IsProjectionMatcher final : public TestNodeMatcher {
631 : public:
632 10 : IsProjectionMatcher(const Matcher<size_t>& index_matcher,
633 : const Matcher<Node*>& base_matcher)
634 : : TestNodeMatcher(IrOpcode::kProjection),
635 : index_matcher_(index_matcher),
636 20 : base_matcher_(base_matcher) {}
637 :
638 0 : void DescribeTo(std::ostream* os) const final {
639 0 : TestNodeMatcher::DescribeTo(os);
640 0 : *os << " whose index (";
641 : index_matcher_.DescribeTo(os);
642 0 : *os << ") and base (";
643 : base_matcher_.DescribeTo(os);
644 0 : *os << ")";
645 0 : }
646 :
647 10 : bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
648 20 : return (TestNodeMatcher::MatchAndExplain(node, listener) &&
649 10 : PrintMatchAndExplain(OpParameter<size_t>(node), "index",
650 60 : index_matcher_, listener) &&
651 10 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
652 50 : base_matcher_, listener));
653 : }
654 :
655 : private:
656 : const Matcher<size_t> index_matcher_;
657 : const Matcher<Node*> base_matcher_;
658 : };
659 :
660 716 : class IsCallMatcher final : public TestNodeMatcher {
661 : public:
662 179 : IsCallMatcher(const Matcher<const CallDescriptor*>& descriptor_matcher,
663 : const std::vector<Matcher<Node*>>& value_matchers,
664 : const Matcher<Node*>& effect_matcher,
665 : const Matcher<Node*>& control_matcher)
666 : : TestNodeMatcher(IrOpcode::kCall),
667 : descriptor_matcher_(descriptor_matcher),
668 : value_matchers_(value_matchers),
669 : effect_matcher_(effect_matcher),
670 537 : control_matcher_(control_matcher) {}
671 :
672 0 : void DescribeTo(std::ostream* os) const final {
673 0 : TestNodeMatcher::DescribeTo(os);
674 0 : for (size_t i = 0; i < value_matchers_.size(); ++i) {
675 0 : if (i == 0) {
676 0 : *os << " whose value0 (";
677 : } else {
678 0 : *os << "), value" << i << " (";
679 : }
680 0 : value_matchers_[i].DescribeTo(os);
681 : }
682 0 : *os << "), effect (";
683 : effect_matcher_.DescribeTo(os);
684 0 : *os << ") and control (";
685 : control_matcher_.DescribeTo(os);
686 0 : *os << ")";
687 0 : }
688 :
689 179 : bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
690 537 : if (!TestNodeMatcher::MatchAndExplain(node, listener) ||
691 179 : !PrintMatchAndExplain(OpParameter<const CallDescriptor*>(node),
692 895 : "descriptor", descriptor_matcher_, listener)) {
693 : return false;
694 : }
695 2313 : for (size_t i = 0; i < value_matchers_.size(); ++i) {
696 1067 : std::ostringstream ost;
697 1067 : ost << "value" << i;
698 1067 : if (!PrintMatchAndExplain(
699 1067 : NodeProperties::GetValueInput(node, static_cast<int>(i)),
700 4447 : ost.str(), value_matchers_[i], listener)) {
701 0 : return false;
702 : }
703 1067 : }
704 179 : Node* effect_node = nullptr;
705 179 : Node* control_node = nullptr;
706 179 : if (NodeProperties::FirstEffectIndex(node) < node->InputCount()) {
707 1 : effect_node = NodeProperties::GetEffectInput(node);
708 : }
709 179 : if (NodeProperties::FirstControlIndex(node) < node->InputCount()) {
710 1 : control_node = NodeProperties::GetControlInput(node);
711 : }
712 : return (PrintMatchAndExplain(effect_node, "effect", effect_matcher_,
713 537 : listener) &&
714 : PrintMatchAndExplain(control_node, "control", control_matcher_,
715 537 : listener));
716 : }
717 :
718 : private:
719 : const Matcher<const CallDescriptor*> descriptor_matcher_;
720 : const std::vector<Matcher<Node*>> value_matchers_;
721 : const Matcher<Node*> effect_matcher_;
722 : const Matcher<Node*> control_matcher_;
723 : };
724 :
725 0 : class IsTailCallMatcher final : public TestNodeMatcher {
726 : public:
727 0 : IsTailCallMatcher(const Matcher<CallDescriptor const*>& descriptor_matcher,
728 : const std::vector<Matcher<Node*>>& value_matchers,
729 : const Matcher<Node*>& effect_matcher,
730 : const Matcher<Node*>& control_matcher)
731 : : TestNodeMatcher(IrOpcode::kTailCall),
732 : descriptor_matcher_(descriptor_matcher),
733 : value_matchers_(value_matchers),
734 : effect_matcher_(effect_matcher),
735 0 : control_matcher_(control_matcher) {}
736 :
737 0 : void DescribeTo(std::ostream* os) const final {
738 0 : TestNodeMatcher::DescribeTo(os);
739 0 : for (size_t i = 0; i < value_matchers_.size(); ++i) {
740 0 : if (i == 0) {
741 0 : *os << " whose value0 (";
742 : } else {
743 0 : *os << "), value" << i << " (";
744 : }
745 0 : value_matchers_[i].DescribeTo(os);
746 : }
747 0 : *os << "), effect (";
748 : effect_matcher_.DescribeTo(os);
749 0 : *os << ") and control (";
750 : control_matcher_.DescribeTo(os);
751 0 : *os << ")";
752 0 : }
753 :
754 0 : bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
755 0 : if (!TestNodeMatcher::MatchAndExplain(node, listener) ||
756 0 : !PrintMatchAndExplain(OpParameter<CallDescriptor const*>(node),
757 0 : "descriptor", descriptor_matcher_, listener)) {
758 : return false;
759 : }
760 0 : for (size_t i = 0; i < value_matchers_.size(); ++i) {
761 0 : std::ostringstream ost;
762 0 : ost << "value" << i;
763 0 : if (!PrintMatchAndExplain(
764 0 : NodeProperties::GetValueInput(node, static_cast<int>(i)),
765 0 : ost.str(), value_matchers_[i], listener)) {
766 0 : return false;
767 : }
768 0 : }
769 0 : Node* effect_node = nullptr;
770 0 : Node* control_node = nullptr;
771 0 : if (NodeProperties::FirstEffectIndex(node) < node->InputCount()) {
772 0 : effect_node = NodeProperties::GetEffectInput(node);
773 : }
774 0 : if (NodeProperties::FirstControlIndex(node) < node->InputCount()) {
775 0 : control_node = NodeProperties::GetControlInput(node);
776 : }
777 : return (PrintMatchAndExplain(effect_node, "effect", effect_matcher_,
778 0 : listener) &&
779 : PrintMatchAndExplain(control_node, "control", control_matcher_,
780 0 : listener));
781 : }
782 :
783 : private:
784 : const Matcher<CallDescriptor const*> descriptor_matcher_;
785 : const std::vector<Matcher<Node*>> value_matchers_;
786 : const Matcher<Node*> effect_matcher_;
787 : const Matcher<Node*> control_matcher_;
788 : };
789 :
790 0 : class IsSpeculativeBinopMatcher final : public TestNodeMatcher {
791 : public:
792 0 : IsSpeculativeBinopMatcher(IrOpcode::Value opcode,
793 : const Matcher<NumberOperationHint>& hint_matcher,
794 : const Matcher<Node*>& lhs_matcher,
795 : const Matcher<Node*>& rhs_matcher,
796 : const Matcher<Node*>& effect_matcher,
797 : const Matcher<Node*>& control_matcher)
798 : : TestNodeMatcher(opcode),
799 : hint_matcher_(hint_matcher),
800 : lhs_matcher_(lhs_matcher),
801 : rhs_matcher_(rhs_matcher),
802 : effect_matcher_(effect_matcher),
803 0 : control_matcher_(control_matcher) {}
804 :
805 0 : bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
806 0 : return (TestNodeMatcher::MatchAndExplain(node, listener) &&
807 : // TODO(bmeurer): The type parameter is currently ignored.
808 0 : PrintMatchAndExplain(OpParameter<NumberOperationHint>(node->op()),
809 0 : "hints", hint_matcher_, listener) &&
810 0 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "lhs",
811 0 : lhs_matcher_, listener) &&
812 0 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "rhs",
813 0 : rhs_matcher_, listener) &&
814 0 : PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
815 0 : effect_matcher_, listener) &&
816 0 : PrintMatchAndExplain(NodeProperties::GetControlInput(node),
817 0 : "control", control_matcher_, listener));
818 : }
819 :
820 : private:
821 : const Matcher<NumberOperationHint> hint_matcher_;
822 : const Matcher<Type*> type_matcher_;
823 : const Matcher<Node*> lhs_matcher_;
824 : const Matcher<Node*> rhs_matcher_;
825 : const Matcher<Node*> effect_matcher_;
826 : const Matcher<Node*> control_matcher_;
827 : };
828 :
829 21 : class IsAllocateMatcher final : public TestNodeMatcher {
830 : public:
831 7 : IsAllocateMatcher(const Matcher<Node*>& size_matcher,
832 : const Matcher<Node*>& effect_matcher,
833 : const Matcher<Node*>& control_matcher)
834 : : TestNodeMatcher(IrOpcode::kAllocate),
835 : size_matcher_(size_matcher),
836 : effect_matcher_(effect_matcher),
837 14 : control_matcher_(control_matcher) {}
838 :
839 7 : bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
840 14 : return (TestNodeMatcher::MatchAndExplain(node, listener) &&
841 7 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "size",
842 42 : size_matcher_, listener) &&
843 7 : PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
844 42 : effect_matcher_, listener) &&
845 7 : PrintMatchAndExplain(NodeProperties::GetControlInput(node),
846 35 : "control", control_matcher_, listener));
847 : }
848 :
849 : private:
850 : const Matcher<Node*> size_matcher_;
851 : const Matcher<Node*> effect_matcher_;
852 : const Matcher<Node*> control_matcher_;
853 : };
854 :
855 201 : class IsLoadFieldMatcher final : public TestNodeMatcher {
856 : public:
857 67 : IsLoadFieldMatcher(const Matcher<FieldAccess>& access_matcher,
858 : const Matcher<Node*>& base_matcher,
859 : const Matcher<Node*>& effect_matcher,
860 : const Matcher<Node*>& control_matcher)
861 : : TestNodeMatcher(IrOpcode::kLoadField),
862 : access_matcher_(access_matcher),
863 : base_matcher_(base_matcher),
864 : effect_matcher_(effect_matcher),
865 134 : control_matcher_(control_matcher) {}
866 :
867 0 : void DescribeTo(std::ostream* os) const final {
868 0 : TestNodeMatcher::DescribeTo(os);
869 0 : *os << " whose access (";
870 : access_matcher_.DescribeTo(os);
871 0 : *os << "), base (";
872 : base_matcher_.DescribeTo(os);
873 0 : *os << "), effect (";
874 : effect_matcher_.DescribeTo(os);
875 0 : *os << ") and control (";
876 : control_matcher_.DescribeTo(os);
877 0 : *os << ")";
878 0 : }
879 :
880 67 : bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
881 134 : return (TestNodeMatcher::MatchAndExplain(node, listener) &&
882 67 : PrintMatchAndExplain(OpParameter<FieldAccess>(node), "access",
883 402 : access_matcher_, listener) &&
884 67 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
885 335 : base_matcher_, listener) &&
886 67 : PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
887 402 : effect_matcher_, listener) &&
888 67 : PrintMatchAndExplain(NodeProperties::GetControlInput(node),
889 335 : "control", control_matcher_, listener));
890 : }
891 :
892 : private:
893 : const Matcher<FieldAccess> access_matcher_;
894 : const Matcher<Node*> base_matcher_;
895 : const Matcher<Node*> effect_matcher_;
896 : const Matcher<Node*> control_matcher_;
897 : };
898 :
899 180 : class IsStoreFieldMatcher final : public TestNodeMatcher {
900 : public:
901 60 : IsStoreFieldMatcher(const Matcher<FieldAccess>& access_matcher,
902 : const Matcher<Node*>& base_matcher,
903 : const Matcher<Node*>& value_matcher,
904 : const Matcher<Node*>& effect_matcher,
905 : const Matcher<Node*>& control_matcher)
906 : : TestNodeMatcher(IrOpcode::kStoreField),
907 : access_matcher_(access_matcher),
908 : base_matcher_(base_matcher),
909 : value_matcher_(value_matcher),
910 : effect_matcher_(effect_matcher),
911 120 : control_matcher_(control_matcher) {}
912 :
913 0 : void DescribeTo(std::ostream* os) const final {
914 0 : TestNodeMatcher::DescribeTo(os);
915 0 : *os << " whose access (";
916 : access_matcher_.DescribeTo(os);
917 0 : *os << "), base (";
918 : base_matcher_.DescribeTo(os);
919 0 : *os << "), value (";
920 : value_matcher_.DescribeTo(os);
921 0 : *os << "), effect (";
922 : effect_matcher_.DescribeTo(os);
923 0 : *os << ") and control (";
924 : control_matcher_.DescribeTo(os);
925 0 : *os << ")";
926 0 : }
927 :
928 60 : bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
929 120 : return (TestNodeMatcher::MatchAndExplain(node, listener) &&
930 60 : PrintMatchAndExplain(OpParameter<FieldAccess>(node), "access",
931 360 : access_matcher_, listener) &&
932 60 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
933 300 : base_matcher_, listener) &&
934 60 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
935 300 : "value", value_matcher_, listener) &&
936 60 : PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
937 360 : effect_matcher_, listener) &&
938 60 : PrintMatchAndExplain(NodeProperties::GetControlInput(node),
939 300 : "control", control_matcher_, listener));
940 : }
941 :
942 : private:
943 : const Matcher<FieldAccess> access_matcher_;
944 : const Matcher<Node*> base_matcher_;
945 : const Matcher<Node*> value_matcher_;
946 : const Matcher<Node*> effect_matcher_;
947 : const Matcher<Node*> control_matcher_;
948 : };
949 :
950 0 : class IsLoadElementMatcher final : public TestNodeMatcher {
951 : public:
952 0 : IsLoadElementMatcher(const Matcher<ElementAccess>& access_matcher,
953 : const Matcher<Node*>& base_matcher,
954 : const Matcher<Node*>& index_matcher,
955 : const Matcher<Node*>& effect_matcher,
956 : const Matcher<Node*>& control_matcher)
957 : : TestNodeMatcher(IrOpcode::kLoadElement),
958 : access_matcher_(access_matcher),
959 : base_matcher_(base_matcher),
960 : index_matcher_(index_matcher),
961 : effect_matcher_(effect_matcher),
962 0 : control_matcher_(control_matcher) {}
963 :
964 0 : void DescribeTo(std::ostream* os) const final {
965 0 : TestNodeMatcher::DescribeTo(os);
966 0 : *os << " whose access (";
967 : access_matcher_.DescribeTo(os);
968 0 : *os << "), base (";
969 : base_matcher_.DescribeTo(os);
970 0 : *os << "), index (";
971 : index_matcher_.DescribeTo(os);
972 0 : *os << "), effect (";
973 : effect_matcher_.DescribeTo(os);
974 0 : *os << ") and control (";
975 : control_matcher_.DescribeTo(os);
976 0 : *os << ")";
977 0 : }
978 :
979 0 : bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
980 0 : return (TestNodeMatcher::MatchAndExplain(node, listener) &&
981 0 : PrintMatchAndExplain(OpParameter<ElementAccess>(node), "access",
982 0 : access_matcher_, listener) &&
983 0 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
984 0 : base_matcher_, listener) &&
985 0 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
986 0 : "index", index_matcher_, listener) &&
987 0 : PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
988 0 : effect_matcher_, listener) &&
989 0 : PrintMatchAndExplain(NodeProperties::GetControlInput(node),
990 0 : "control", control_matcher_, listener));
991 : }
992 :
993 : private:
994 : const Matcher<ElementAccess> access_matcher_;
995 : const Matcher<Node*> base_matcher_;
996 : const Matcher<Node*> index_matcher_;
997 : const Matcher<Node*> effect_matcher_;
998 : const Matcher<Node*> control_matcher_;
999 : };
1000 :
1001 0 : class IsStoreElementMatcher final : public TestNodeMatcher {
1002 : public:
1003 0 : IsStoreElementMatcher(const Matcher<ElementAccess>& access_matcher,
1004 : const Matcher<Node*>& base_matcher,
1005 : const Matcher<Node*>& index_matcher,
1006 : const Matcher<Node*>& value_matcher,
1007 : const Matcher<Node*>& effect_matcher,
1008 : const Matcher<Node*>& control_matcher)
1009 : : TestNodeMatcher(IrOpcode::kStoreElement),
1010 : access_matcher_(access_matcher),
1011 : base_matcher_(base_matcher),
1012 : index_matcher_(index_matcher),
1013 : value_matcher_(value_matcher),
1014 : effect_matcher_(effect_matcher),
1015 0 : control_matcher_(control_matcher) {}
1016 :
1017 0 : void DescribeTo(std::ostream* os) const final {
1018 0 : TestNodeMatcher::DescribeTo(os);
1019 0 : *os << " whose access (";
1020 : access_matcher_.DescribeTo(os);
1021 0 : *os << "), base (";
1022 : base_matcher_.DescribeTo(os);
1023 0 : *os << "), index (";
1024 : index_matcher_.DescribeTo(os);
1025 0 : *os << "), value (";
1026 : value_matcher_.DescribeTo(os);
1027 0 : *os << "), effect (";
1028 : effect_matcher_.DescribeTo(os);
1029 0 : *os << ") and control (";
1030 : control_matcher_.DescribeTo(os);
1031 0 : *os << ")";
1032 0 : }
1033 :
1034 0 : bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
1035 0 : return (TestNodeMatcher::MatchAndExplain(node, listener) &&
1036 0 : PrintMatchAndExplain(OpParameter<ElementAccess>(node), "access",
1037 0 : access_matcher_, listener) &&
1038 0 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
1039 0 : base_matcher_, listener) &&
1040 0 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
1041 0 : "index", index_matcher_, listener) &&
1042 0 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2),
1043 0 : "value", value_matcher_, listener) &&
1044 0 : PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
1045 0 : effect_matcher_, listener) &&
1046 0 : PrintMatchAndExplain(NodeProperties::GetControlInput(node),
1047 0 : "control", control_matcher_, listener));
1048 : }
1049 :
1050 : private:
1051 : const Matcher<ElementAccess> access_matcher_;
1052 : const Matcher<Node*> base_matcher_;
1053 : const Matcher<Node*> index_matcher_;
1054 : const Matcher<Node*> value_matcher_;
1055 : const Matcher<Node*> effect_matcher_;
1056 : const Matcher<Node*> control_matcher_;
1057 : };
1058 :
1059 : #define LOAD_MATCHER(kLoad) \
1060 : class Is##kLoad##Matcher final : public TestNodeMatcher { \
1061 : public: \
1062 : Is##kLoad##Matcher(const Matcher<kLoad##Representation>& rep_matcher, \
1063 : const Matcher<Node*>& base_matcher, \
1064 : const Matcher<Node*>& index_matcher, \
1065 : const Matcher<Node*>& effect_matcher, \
1066 : const Matcher<Node*>& control_matcher) \
1067 : : TestNodeMatcher(IrOpcode::k##kLoad), \
1068 : rep_matcher_(rep_matcher), \
1069 : base_matcher_(base_matcher), \
1070 : index_matcher_(index_matcher), \
1071 : effect_matcher_(effect_matcher), \
1072 : control_matcher_(control_matcher) {} \
1073 : \
1074 : void DescribeTo(std::ostream* os) const final { \
1075 : TestNodeMatcher::DescribeTo(os); \
1076 : *os << " whose rep ("; \
1077 : rep_matcher_.DescribeTo(os); \
1078 : *os << "), base ("; \
1079 : base_matcher_.DescribeTo(os); \
1080 : *os << "), index ("; \
1081 : index_matcher_.DescribeTo(os); \
1082 : *os << "), effect ("; \
1083 : effect_matcher_.DescribeTo(os); \
1084 : *os << ") and control ("; \
1085 : control_matcher_.DescribeTo(os); \
1086 : *os << ")"; \
1087 : } \
1088 : \
1089 : bool MatchAndExplain(Node* node, \
1090 : MatchResultListener* listener) const final { \
1091 : Node* effect_node = nullptr; \
1092 : Node* control_node = nullptr; \
1093 : if (NodeProperties::FirstEffectIndex(node) < node->InputCount()) { \
1094 : effect_node = NodeProperties::GetEffectInput(node); \
1095 : } \
1096 : if (NodeProperties::FirstControlIndex(node) < node->InputCount()) { \
1097 : control_node = NodeProperties::GetControlInput(node); \
1098 : } \
1099 : return (TestNodeMatcher::MatchAndExplain(node, listener) && \
1100 : PrintMatchAndExplain(OpParameter<kLoad##Representation>(node), \
1101 : "rep", rep_matcher_, listener) && \
1102 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), \
1103 : "base", base_matcher_, listener) && \
1104 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), \
1105 : "index", index_matcher_, listener) && \
1106 : PrintMatchAndExplain(effect_node, "effect", effect_matcher_, \
1107 : listener) && \
1108 : PrintMatchAndExplain(control_node, "control", control_matcher_, \
1109 : listener)); \
1110 : } \
1111 : \
1112 : private: \
1113 : const Matcher<kLoad##Representation> rep_matcher_; \
1114 : const Matcher<Node*> base_matcher_; \
1115 : const Matcher<Node*> index_matcher_; \
1116 : const Matcher<Node*> effect_matcher_; \
1117 : const Matcher<Node*> control_matcher_; \
1118 : };
1119 :
1120 38664 : LOAD_MATCHER(Load)
1121 39 : LOAD_MATCHER(UnalignedLoad)
1122 :
1123 : #define STORE_MATCHER(kStore) \
1124 : class Is##kStore##Matcher final : public TestNodeMatcher { \
1125 : public: \
1126 : Is##kStore##Matcher(const Matcher<kStore##Representation>& rep_matcher, \
1127 : const Matcher<Node*>& base_matcher, \
1128 : const Matcher<Node*>& index_matcher, \
1129 : const Matcher<Node*>& value_matcher, \
1130 : const Matcher<Node*>& effect_matcher, \
1131 : const Matcher<Node*>& control_matcher) \
1132 : : TestNodeMatcher(IrOpcode::k##kStore), \
1133 : rep_matcher_(rep_matcher), \
1134 : base_matcher_(base_matcher), \
1135 : index_matcher_(index_matcher), \
1136 : value_matcher_(value_matcher), \
1137 : effect_matcher_(effect_matcher), \
1138 : control_matcher_(control_matcher) {} \
1139 : \
1140 : void DescribeTo(std::ostream* os) const final { \
1141 : TestNodeMatcher::DescribeTo(os); \
1142 : *os << " whose rep ("; \
1143 : rep_matcher_.DescribeTo(os); \
1144 : *os << "), base ("; \
1145 : base_matcher_.DescribeTo(os); \
1146 : *os << "), index ("; \
1147 : index_matcher_.DescribeTo(os); \
1148 : *os << "), value ("; \
1149 : value_matcher_.DescribeTo(os); \
1150 : *os << "), effect ("; \
1151 : effect_matcher_.DescribeTo(os); \
1152 : *os << ") and control ("; \
1153 : control_matcher_.DescribeTo(os); \
1154 : *os << ")"; \
1155 : } \
1156 : \
1157 : bool MatchAndExplain(Node* node, \
1158 : MatchResultListener* listener) const final { \
1159 : Node* effect_node = nullptr; \
1160 : Node* control_node = nullptr; \
1161 : if (NodeProperties::FirstEffectIndex(node) < node->InputCount()) { \
1162 : effect_node = NodeProperties::GetEffectInput(node); \
1163 : } \
1164 : if (NodeProperties::FirstControlIndex(node) < node->InputCount()) { \
1165 : control_node = NodeProperties::GetControlInput(node); \
1166 : } \
1167 : return (TestNodeMatcher::MatchAndExplain(node, listener) && \
1168 : PrintMatchAndExplain(OpParameter<kStore##Representation>(node), \
1169 : "rep", rep_matcher_, listener) && \
1170 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), \
1171 : "base", base_matcher_, listener) && \
1172 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), \
1173 : "index", index_matcher_, listener) && \
1174 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2), \
1175 : "value", value_matcher_, listener) && \
1176 : PrintMatchAndExplain(effect_node, "effect", effect_matcher_, \
1177 : listener) && \
1178 : PrintMatchAndExplain(control_node, "control", control_matcher_, \
1179 : listener)); \
1180 : } \
1181 : \
1182 : private: \
1183 : const Matcher<kStore##Representation> rep_matcher_; \
1184 : const Matcher<Node*> base_matcher_; \
1185 : const Matcher<Node*> index_matcher_; \
1186 : const Matcher<Node*> value_matcher_; \
1187 : const Matcher<Node*> effect_matcher_; \
1188 : const Matcher<Node*> control_matcher_; \
1189 : };
1190 :
1191 5034 : STORE_MATCHER(Store)
1192 32 : STORE_MATCHER(UnalignedStore)
1193 :
1194 4 : class IsStackSlotMatcher final : public TestNodeMatcher {
1195 : public:
1196 2 : explicit IsStackSlotMatcher(
1197 : const Matcher<StackSlotRepresentation>& rep_matcher)
1198 4 : : TestNodeMatcher(IrOpcode::kStackSlot), rep_matcher_(rep_matcher) {}
1199 :
1200 0 : void DescribeTo(std::ostream* os) const final {
1201 0 : TestNodeMatcher::DescribeTo(os);
1202 0 : *os << " whose rep (";
1203 : rep_matcher_.DescribeTo(os);
1204 0 : *os << ")";
1205 0 : }
1206 :
1207 7 : bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
1208 14 : return (TestNodeMatcher::MatchAndExplain(node, listener) &&
1209 7 : PrintMatchAndExplain(OpParameter<StackSlotRepresentation>(node),
1210 28 : "rep", rep_matcher_, listener));
1211 : }
1212 :
1213 : private:
1214 : const Matcher<StackSlotRepresentation> rep_matcher_;
1215 : };
1216 :
1217 0 : class IsToNumberMatcher final : public TestNodeMatcher {
1218 : public:
1219 0 : IsToNumberMatcher(const Matcher<Node*>& base_matcher,
1220 : const Matcher<Node*>& context_matcher,
1221 : const Matcher<Node*>& effect_matcher,
1222 : const Matcher<Node*>& control_matcher)
1223 : : TestNodeMatcher(IrOpcode::kJSToNumber),
1224 : base_matcher_(base_matcher),
1225 : context_matcher_(context_matcher),
1226 : effect_matcher_(effect_matcher),
1227 0 : control_matcher_(control_matcher) {}
1228 :
1229 0 : void DescribeTo(std::ostream* os) const final {
1230 0 : TestNodeMatcher::DescribeTo(os);
1231 0 : *os << " whose base (";
1232 : base_matcher_.DescribeTo(os);
1233 0 : *os << "), context (";
1234 : context_matcher_.DescribeTo(os);
1235 0 : *os << "), effect (";
1236 : effect_matcher_.DescribeTo(os);
1237 0 : *os << ") and control (";
1238 : control_matcher_.DescribeTo(os);
1239 0 : *os << ")";
1240 0 : }
1241 :
1242 0 : bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
1243 0 : return (TestNodeMatcher::MatchAndExplain(node, listener) &&
1244 0 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
1245 0 : base_matcher_, listener) &&
1246 0 : PrintMatchAndExplain(NodeProperties::GetContextInput(node),
1247 0 : "context", context_matcher_, listener) &&
1248 0 : PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
1249 0 : effect_matcher_, listener) &&
1250 0 : PrintMatchAndExplain(NodeProperties::GetControlInput(node),
1251 0 : "control", control_matcher_, listener));
1252 : }
1253 :
1254 : private:
1255 : const Matcher<Node*> base_matcher_;
1256 : const Matcher<Node*> context_matcher_;
1257 : const Matcher<Node*> effect_matcher_;
1258 : const Matcher<Node*> control_matcher_;
1259 : };
1260 :
1261 0 : class IsLoadContextMatcher final : public TestNodeMatcher {
1262 : public:
1263 0 : IsLoadContextMatcher(const Matcher<ContextAccess>& access_matcher,
1264 : const Matcher<Node*>& context_matcher)
1265 : : TestNodeMatcher(IrOpcode::kJSLoadContext),
1266 : access_matcher_(access_matcher),
1267 0 : context_matcher_(context_matcher) {}
1268 :
1269 0 : void DescribeTo(std::ostream* os) const final {
1270 0 : TestNodeMatcher::DescribeTo(os);
1271 0 : *os << " whose access (";
1272 : access_matcher_.DescribeTo(os);
1273 0 : *os << ") and context (";
1274 : context_matcher_.DescribeTo(os);
1275 0 : *os << ")";
1276 0 : }
1277 :
1278 0 : bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
1279 0 : return (TestNodeMatcher::MatchAndExplain(node, listener) &&
1280 0 : PrintMatchAndExplain(OpParameter<ContextAccess>(node), "access",
1281 0 : access_matcher_, listener) &&
1282 0 : PrintMatchAndExplain(NodeProperties::GetContextInput(node),
1283 0 : "context", context_matcher_, listener));
1284 : }
1285 :
1286 : private:
1287 : const Matcher<ContextAccess> access_matcher_;
1288 : const Matcher<Node*> context_matcher_;
1289 : };
1290 :
1291 6 : class IsQuadopMatcher final : public TestNodeMatcher {
1292 : public:
1293 2 : IsQuadopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& a_matcher,
1294 : const Matcher<Node*>& b_matcher,
1295 : const Matcher<Node*>& c_matcher,
1296 : const Matcher<Node*>& d_matcher)
1297 : : TestNodeMatcher(opcode),
1298 : a_matcher_(a_matcher),
1299 : b_matcher_(b_matcher),
1300 : c_matcher_(c_matcher),
1301 4 : d_matcher_(d_matcher) {}
1302 :
1303 0 : void DescribeTo(std::ostream* os) const final {
1304 0 : TestNodeMatcher::DescribeTo(os);
1305 0 : *os << " whose a (";
1306 : a_matcher_.DescribeTo(os);
1307 0 : *os << ") and b (";
1308 : b_matcher_.DescribeTo(os);
1309 0 : *os << ") and c (";
1310 : c_matcher_.DescribeTo(os);
1311 0 : *os << ") and d (";
1312 : d_matcher_.DescribeTo(os);
1313 0 : *os << ")";
1314 0 : }
1315 :
1316 4 : bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
1317 8 : return (TestNodeMatcher::MatchAndExplain(node, listener) &&
1318 4 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "a",
1319 24 : a_matcher_, listener) &&
1320 4 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "b",
1321 20 : b_matcher_, listener) &&
1322 4 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2), "c",
1323 24 : c_matcher_, listener) &&
1324 4 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 3), "d",
1325 20 : d_matcher_, listener));
1326 : }
1327 :
1328 : private:
1329 : const Matcher<Node*> a_matcher_;
1330 : const Matcher<Node*> b_matcher_;
1331 : const Matcher<Node*> c_matcher_;
1332 : const Matcher<Node*> d_matcher_;
1333 : };
1334 :
1335 9 : class IsTernopMatcher final : public TestNodeMatcher {
1336 : public:
1337 3 : IsTernopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& lhs_matcher,
1338 : const Matcher<Node*>& mid_matcher,
1339 : const Matcher<Node*>& rhs_matcher)
1340 : : TestNodeMatcher(opcode),
1341 : lhs_matcher_(lhs_matcher),
1342 : mid_matcher_(mid_matcher),
1343 6 : rhs_matcher_(rhs_matcher) {}
1344 :
1345 0 : void DescribeTo(std::ostream* os) const final {
1346 0 : TestNodeMatcher::DescribeTo(os);
1347 0 : *os << " whose lhs (";
1348 : lhs_matcher_.DescribeTo(os);
1349 0 : *os << ") and mid (";
1350 : mid_matcher_.DescribeTo(os);
1351 0 : *os << ") and rhs (";
1352 : rhs_matcher_.DescribeTo(os);
1353 0 : *os << ")";
1354 0 : }
1355 :
1356 6 : bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
1357 12 : return (TestNodeMatcher::MatchAndExplain(node, listener) &&
1358 6 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "lhs",
1359 36 : lhs_matcher_, listener) &&
1360 6 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "mid",
1361 36 : mid_matcher_, listener) &&
1362 6 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2), "rhs",
1363 30 : rhs_matcher_, listener));
1364 : }
1365 :
1366 : private:
1367 : const Matcher<Node*> lhs_matcher_;
1368 : const Matcher<Node*> mid_matcher_;
1369 : const Matcher<Node*> rhs_matcher_;
1370 : };
1371 :
1372 184698 : class IsBinopMatcher final : public TestNodeMatcher {
1373 : public:
1374 61566 : IsBinopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& lhs_matcher,
1375 : const Matcher<Node*>& rhs_matcher)
1376 : : TestNodeMatcher(opcode),
1377 : lhs_matcher_(lhs_matcher),
1378 123132 : rhs_matcher_(rhs_matcher) {}
1379 :
1380 0 : void DescribeTo(std::ostream* os) const final {
1381 0 : TestNodeMatcher::DescribeTo(os);
1382 0 : *os << " whose lhs (";
1383 : lhs_matcher_.DescribeTo(os);
1384 0 : *os << ") and rhs (";
1385 : rhs_matcher_.DescribeTo(os);
1386 0 : *os << ")";
1387 0 : }
1388 :
1389 61591 : bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
1390 123182 : return (TestNodeMatcher::MatchAndExplain(node, listener) &&
1391 61591 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "lhs",
1392 369546 : lhs_matcher_, listener) &&
1393 61591 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "rhs",
1394 307955 : rhs_matcher_, listener));
1395 : }
1396 :
1397 : private:
1398 : const Matcher<Node*> lhs_matcher_;
1399 : const Matcher<Node*> rhs_matcher_;
1400 : };
1401 :
1402 2180 : class IsUnopMatcher final : public TestNodeMatcher {
1403 : public:
1404 1090 : IsUnopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& input_matcher)
1405 2180 : : TestNodeMatcher(opcode), input_matcher_(input_matcher) {}
1406 :
1407 0 : void DescribeTo(std::ostream* os) const final {
1408 0 : TestNodeMatcher::DescribeTo(os);
1409 0 : *os << " whose input (";
1410 : input_matcher_.DescribeTo(os);
1411 0 : *os << ")";
1412 0 : }
1413 :
1414 1090 : bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
1415 2180 : return (TestNodeMatcher::MatchAndExplain(node, listener) &&
1416 1090 : PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
1417 4360 : "input", input_matcher_, listener));
1418 : }
1419 :
1420 : private:
1421 : const Matcher<Node*> input_matcher_;
1422 : };
1423 :
1424 4082 : class IsParameterMatcher final : public TestNodeMatcher {
1425 : public:
1426 2041 : explicit IsParameterMatcher(const Matcher<int>& index_matcher)
1427 4082 : : TestNodeMatcher(IrOpcode::kParameter), index_matcher_(index_matcher) {}
1428 :
1429 0 : void DescribeTo(std::ostream* os) const override {
1430 0 : *os << "is a Parameter node with index(";
1431 : index_matcher_.DescribeTo(os);
1432 0 : *os << ")";
1433 0 : }
1434 :
1435 4110 : bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
1436 4110 : return (TestNodeMatcher::MatchAndExplain(node, listener) &&
1437 2055 : PrintMatchAndExplain(ParameterIndexOf(node->op()), "index",
1438 8220 : index_matcher_, listener));
1439 : }
1440 :
1441 : private:
1442 : const Matcher<int> index_matcher_;
1443 : };
1444 :
1445 : } // namespace
1446 :
1447 244 : Matcher<Node*> IsDead() {
1448 488 : return MakeMatcher(new TestNodeMatcher(IrOpcode::kDead));
1449 : }
1450 :
1451 4 : Matcher<Node*> IsEnd(const Matcher<Node*>& control0_matcher) {
1452 8 : return MakeMatcher(new IsControl1Matcher(IrOpcode::kEnd, control0_matcher));
1453 : }
1454 :
1455 :
1456 0 : Matcher<Node*> IsEnd(const Matcher<Node*>& control0_matcher,
1457 : const Matcher<Node*>& control1_matcher) {
1458 : return MakeMatcher(new IsControl2Matcher(IrOpcode::kEnd, control0_matcher,
1459 0 : control1_matcher));
1460 : }
1461 :
1462 :
1463 1 : Matcher<Node*> IsEnd(const Matcher<Node*>& control0_matcher,
1464 : const Matcher<Node*>& control1_matcher,
1465 : const Matcher<Node*>& control2_matcher) {
1466 : return MakeMatcher(new IsControl3Matcher(IrOpcode::kEnd, control0_matcher,
1467 2 : control1_matcher, control2_matcher));
1468 : }
1469 :
1470 :
1471 168 : Matcher<Node*> IsBranch(const Matcher<Node*>& value_matcher,
1472 : const Matcher<Node*>& control_matcher) {
1473 336 : return MakeMatcher(new IsBranchMatcher(value_matcher, control_matcher));
1474 : }
1475 :
1476 :
1477 95 : Matcher<Node*> IsMerge(const Matcher<Node*>& control0_matcher,
1478 : const Matcher<Node*>& control1_matcher) {
1479 : return MakeMatcher(new IsControl2Matcher(IrOpcode::kMerge, control0_matcher,
1480 190 : control1_matcher));
1481 : }
1482 :
1483 :
1484 2 : Matcher<Node*> IsMerge(const Matcher<Node*>& control0_matcher,
1485 : const Matcher<Node*>& control1_matcher,
1486 : const Matcher<Node*>& control2_matcher) {
1487 : return MakeMatcher(new IsControl3Matcher(IrOpcode::kMerge, control0_matcher,
1488 4 : control1_matcher, control2_matcher));
1489 : }
1490 :
1491 :
1492 7 : Matcher<Node*> IsLoop(const Matcher<Node*>& control0_matcher,
1493 : const Matcher<Node*>& control1_matcher) {
1494 : return MakeMatcher(new IsControl2Matcher(IrOpcode::kLoop, control0_matcher,
1495 14 : control1_matcher));
1496 : }
1497 :
1498 :
1499 3 : Matcher<Node*> IsLoop(const Matcher<Node*>& control0_matcher,
1500 : const Matcher<Node*>& control1_matcher,
1501 : const Matcher<Node*>& control2_matcher) {
1502 : return MakeMatcher(new IsControl3Matcher(IrOpcode::kLoop, control0_matcher,
1503 6 : control1_matcher, control2_matcher));
1504 : }
1505 :
1506 :
1507 96 : Matcher<Node*> IsIfTrue(const Matcher<Node*>& control_matcher) {
1508 192 : return MakeMatcher(new IsControl1Matcher(IrOpcode::kIfTrue, control_matcher));
1509 : }
1510 :
1511 :
1512 96 : Matcher<Node*> IsIfFalse(const Matcher<Node*>& control_matcher) {
1513 : return MakeMatcher(
1514 192 : new IsControl1Matcher(IrOpcode::kIfFalse, control_matcher));
1515 : }
1516 :
1517 :
1518 1 : Matcher<Node*> IsIfSuccess(const Matcher<Node*>& control_matcher) {
1519 : return MakeMatcher(
1520 2 : new IsControl1Matcher(IrOpcode::kIfSuccess, control_matcher));
1521 : }
1522 :
1523 :
1524 2 : Matcher<Node*> IsSwitch(const Matcher<Node*>& value_matcher,
1525 : const Matcher<Node*>& control_matcher) {
1526 4 : return MakeMatcher(new IsSwitchMatcher(value_matcher, control_matcher));
1527 : }
1528 :
1529 :
1530 4 : Matcher<Node*> IsIfValue(const Matcher<int32_t>& value_matcher,
1531 : const Matcher<Node*>& control_matcher) {
1532 8 : return MakeMatcher(new IsIfValueMatcher(value_matcher, control_matcher));
1533 : }
1534 :
1535 :
1536 2 : Matcher<Node*> IsIfDefault(const Matcher<Node*>& control_matcher) {
1537 : return MakeMatcher(
1538 4 : new IsControl1Matcher(IrOpcode::kIfDefault, control_matcher));
1539 : }
1540 :
1541 :
1542 4 : Matcher<Node*> IsBeginRegion(const Matcher<Node*>& effect_matcher) {
1543 8 : return MakeMatcher(new IsBeginRegionMatcher(effect_matcher));
1544 : }
1545 :
1546 :
1547 7 : Matcher<Node*> IsFinishRegion(const Matcher<Node*>& value_matcher,
1548 : const Matcher<Node*>& effect_matcher) {
1549 14 : return MakeMatcher(new IsFinishRegionMatcher(value_matcher, effect_matcher));
1550 : }
1551 :
1552 :
1553 30 : Matcher<Node*> IsReturn(const Matcher<Node*>& value_matcher,
1554 : const Matcher<Node*>& effect_matcher,
1555 : const Matcher<Node*>& control_matcher) {
1556 : return MakeMatcher(
1557 60 : new IsReturnMatcher(value_matcher, effect_matcher, control_matcher));
1558 : }
1559 :
1560 28 : Matcher<Node*> IsReturn2(const Matcher<Node*>& value_matcher,
1561 : const Matcher<Node*>& value2_matcher,
1562 : const Matcher<Node*>& effect_matcher,
1563 : const Matcher<Node*>& control_matcher) {
1564 : return MakeMatcher(new IsReturnMatcher(value_matcher, value2_matcher,
1565 56 : effect_matcher, control_matcher));
1566 : }
1567 :
1568 0 : Matcher<Node*> IsTerminate(const Matcher<Node*>& effect_matcher,
1569 : const Matcher<Node*>& control_matcher) {
1570 0 : return MakeMatcher(new IsTerminateMatcher(effect_matcher, control_matcher));
1571 : }
1572 :
1573 0 : Matcher<Node*> IsTypeGuard(const Matcher<Node*>& value_matcher,
1574 : const Matcher<Node*>& control_matcher) {
1575 0 : return MakeMatcher(new IsTypeGuardMatcher(value_matcher, control_matcher));
1576 : }
1577 :
1578 6 : Matcher<Node*> IsExternalConstant(
1579 : const Matcher<ExternalReference>& value_matcher) {
1580 : return MakeMatcher(new IsConstantMatcher<ExternalReference>(
1581 12 : IrOpcode::kExternalConstant, value_matcher));
1582 : }
1583 :
1584 :
1585 143 : Matcher<Node*> IsHeapConstant(Handle<HeapObject> value) {
1586 : return MakeMatcher(new IsConstantMatcher<Handle<HeapObject>>(
1587 286 : IrOpcode::kHeapConstant, value));
1588 : }
1589 :
1590 :
1591 175600 : Matcher<Node*> IsInt32Constant(const Matcher<int32_t>& value_matcher) {
1592 : return MakeMatcher(
1593 351200 : new IsConstantMatcher<int32_t>(IrOpcode::kInt32Constant, value_matcher));
1594 : }
1595 :
1596 :
1597 3257 : Matcher<Node*> IsInt64Constant(const Matcher<int64_t>& value_matcher) {
1598 : return MakeMatcher(
1599 6514 : new IsConstantMatcher<int64_t>(IrOpcode::kInt64Constant, value_matcher));
1600 : }
1601 :
1602 :
1603 600 : Matcher<Node*> IsFloat32Constant(const Matcher<float>& value_matcher) {
1604 : return MakeMatcher(
1605 1200 : new IsConstantMatcher<float>(IrOpcode::kFloat32Constant, value_matcher));
1606 : }
1607 :
1608 :
1609 33602 : Matcher<Node*> IsFloat64Constant(const Matcher<double>& value_matcher) {
1610 : return MakeMatcher(
1611 67204 : new IsConstantMatcher<double>(IrOpcode::kFloat64Constant, value_matcher));
1612 : }
1613 :
1614 :
1615 639 : Matcher<Node*> IsNumberConstant(const Matcher<double>& value_matcher) {
1616 : return MakeMatcher(
1617 1278 : new IsConstantMatcher<double>(IrOpcode::kNumberConstant, value_matcher));
1618 : }
1619 :
1620 0 : Matcher<Node*> IsPointerConstant(const Matcher<intptr_t>& value_matcher) {
1621 : return MakeMatcher(new IsConstantMatcher<intptr_t>(IrOpcode::kPointerConstant,
1622 0 : value_matcher));
1623 : }
1624 :
1625 1 : Matcher<Node*> IsSelect(const Matcher<MachineRepresentation>& type_matcher,
1626 : const Matcher<Node*>& value0_matcher,
1627 : const Matcher<Node*>& value1_matcher,
1628 : const Matcher<Node*>& value2_matcher) {
1629 : return MakeMatcher(new IsSelectMatcher(type_matcher, value0_matcher,
1630 2 : value1_matcher, value2_matcher));
1631 : }
1632 :
1633 :
1634 87 : Matcher<Node*> IsPhi(const Matcher<MachineRepresentation>& type_matcher,
1635 : const Matcher<Node*>& value0_matcher,
1636 : const Matcher<Node*>& value1_matcher,
1637 : const Matcher<Node*>& merge_matcher) {
1638 : return MakeMatcher(new IsPhiMatcher(type_matcher, value0_matcher,
1639 174 : value1_matcher, merge_matcher));
1640 : }
1641 :
1642 :
1643 2 : Matcher<Node*> IsPhi(const Matcher<MachineRepresentation>& type_matcher,
1644 : const Matcher<Node*>& value0_matcher,
1645 : const Matcher<Node*>& value1_matcher,
1646 : const Matcher<Node*>& value2_matcher,
1647 : const Matcher<Node*>& merge_matcher) {
1648 : return MakeMatcher(new IsPhi2Matcher(type_matcher, value0_matcher,
1649 : value1_matcher, value2_matcher,
1650 4 : merge_matcher));
1651 : }
1652 :
1653 :
1654 3 : Matcher<Node*> IsEffectPhi(const Matcher<Node*>& effect0_matcher,
1655 : const Matcher<Node*>& effect1_matcher,
1656 : const Matcher<Node*>& merge_matcher) {
1657 : return MakeMatcher(
1658 6 : new IsEffectPhiMatcher(effect0_matcher, effect1_matcher, merge_matcher));
1659 : }
1660 :
1661 :
1662 10 : Matcher<Node*> IsProjection(const Matcher<size_t>& index_matcher,
1663 : const Matcher<Node*>& base_matcher) {
1664 20 : return MakeMatcher(new IsProjectionMatcher(index_matcher, base_matcher));
1665 : }
1666 :
1667 0 : Matcher<Node*> IsCall(const Matcher<const CallDescriptor*>& descriptor_matcher,
1668 : const Matcher<Node*>& value0_matcher,
1669 : const Matcher<Node*>& effect_matcher,
1670 : const Matcher<Node*>& control_matcher) {
1671 : std::vector<Matcher<Node*>> value_matchers;
1672 0 : value_matchers.push_back(value0_matcher);
1673 : return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers,
1674 0 : effect_matcher, control_matcher));
1675 : }
1676 :
1677 0 : Matcher<Node*> IsCall(const Matcher<const CallDescriptor*>& descriptor_matcher,
1678 : const Matcher<Node*>& value0_matcher,
1679 : const Matcher<Node*>& value1_matcher,
1680 : const Matcher<Node*>& effect_matcher,
1681 : const Matcher<Node*>& control_matcher) {
1682 : std::vector<Matcher<Node*>> value_matchers;
1683 0 : value_matchers.push_back(value0_matcher);
1684 0 : value_matchers.push_back(value1_matcher);
1685 : return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers,
1686 0 : effect_matcher, control_matcher));
1687 : }
1688 :
1689 :
1690 0 : Matcher<Node*> IsCall(const Matcher<const CallDescriptor*>& descriptor_matcher,
1691 : const Matcher<Node*>& value0_matcher,
1692 : const Matcher<Node*>& value1_matcher,
1693 : const Matcher<Node*>& value2_matcher,
1694 : const Matcher<Node*>& effect_matcher,
1695 : const Matcher<Node*>& control_matcher) {
1696 : std::vector<Matcher<Node*>> value_matchers;
1697 0 : value_matchers.push_back(value0_matcher);
1698 0 : value_matchers.push_back(value1_matcher);
1699 0 : value_matchers.push_back(value2_matcher);
1700 : return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers,
1701 0 : effect_matcher, control_matcher));
1702 : }
1703 :
1704 :
1705 0 : Matcher<Node*> IsCall(const Matcher<const CallDescriptor*>& descriptor_matcher,
1706 : const Matcher<Node*>& value0_matcher,
1707 : const Matcher<Node*>& value1_matcher,
1708 : const Matcher<Node*>& value2_matcher,
1709 : const Matcher<Node*>& value3_matcher,
1710 : const Matcher<Node*>& effect_matcher,
1711 : const Matcher<Node*>& control_matcher) {
1712 : std::vector<Matcher<Node*>> value_matchers;
1713 0 : value_matchers.push_back(value0_matcher);
1714 0 : value_matchers.push_back(value1_matcher);
1715 0 : value_matchers.push_back(value2_matcher);
1716 0 : value_matchers.push_back(value3_matcher);
1717 : return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers,
1718 0 : effect_matcher, control_matcher));
1719 : }
1720 :
1721 :
1722 7 : Matcher<Node*> IsCall(const Matcher<const CallDescriptor*>& descriptor_matcher,
1723 : const Matcher<Node*>& value0_matcher,
1724 : const Matcher<Node*>& value1_matcher,
1725 : const Matcher<Node*>& value2_matcher,
1726 : const Matcher<Node*>& value3_matcher,
1727 : const Matcher<Node*>& value4_matcher,
1728 : const Matcher<Node*>& effect_matcher,
1729 : const Matcher<Node*>& control_matcher) {
1730 : std::vector<Matcher<Node*>> value_matchers;
1731 7 : value_matchers.push_back(value0_matcher);
1732 7 : value_matchers.push_back(value1_matcher);
1733 7 : value_matchers.push_back(value2_matcher);
1734 7 : value_matchers.push_back(value3_matcher);
1735 7 : value_matchers.push_back(value4_matcher);
1736 : return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers,
1737 14 : effect_matcher, control_matcher));
1738 : }
1739 :
1740 :
1741 172 : Matcher<Node*> IsCall(const Matcher<const CallDescriptor*>& descriptor_matcher,
1742 : const Matcher<Node*>& value0_matcher,
1743 : const Matcher<Node*>& value1_matcher,
1744 : const Matcher<Node*>& value2_matcher,
1745 : const Matcher<Node*>& value3_matcher,
1746 : const Matcher<Node*>& value4_matcher,
1747 : const Matcher<Node*>& value5_matcher,
1748 : const Matcher<Node*>& effect_matcher,
1749 : const Matcher<Node*>& control_matcher) {
1750 : std::vector<Matcher<Node*>> value_matchers;
1751 172 : value_matchers.push_back(value0_matcher);
1752 172 : value_matchers.push_back(value1_matcher);
1753 172 : value_matchers.push_back(value2_matcher);
1754 172 : value_matchers.push_back(value3_matcher);
1755 172 : value_matchers.push_back(value4_matcher);
1756 172 : value_matchers.push_back(value5_matcher);
1757 : return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers,
1758 344 : effect_matcher, control_matcher));
1759 : }
1760 :
1761 :
1762 0 : Matcher<Node*> IsCall(
1763 : const Matcher<const CallDescriptor*>& descriptor_matcher,
1764 : const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher,
1765 : const Matcher<Node*>& value2_matcher, const Matcher<Node*>& value3_matcher,
1766 : const Matcher<Node*>& value4_matcher, const Matcher<Node*>& value5_matcher,
1767 : const Matcher<Node*>& value6_matcher, const Matcher<Node*>& effect_matcher,
1768 : const Matcher<Node*>& control_matcher) {
1769 : std::vector<Matcher<Node*>> value_matchers;
1770 0 : value_matchers.push_back(value0_matcher);
1771 0 : value_matchers.push_back(value1_matcher);
1772 0 : value_matchers.push_back(value2_matcher);
1773 0 : value_matchers.push_back(value3_matcher);
1774 0 : value_matchers.push_back(value4_matcher);
1775 0 : value_matchers.push_back(value5_matcher);
1776 0 : value_matchers.push_back(value6_matcher);
1777 : return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers,
1778 0 : effect_matcher, control_matcher));
1779 : }
1780 :
1781 :
1782 0 : Matcher<Node*> IsTailCall(
1783 : const Matcher<CallDescriptor const*>& descriptor_matcher,
1784 : const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher,
1785 : const Matcher<Node*>& effect_matcher,
1786 : const Matcher<Node*>& control_matcher) {
1787 : std::vector<Matcher<Node*>> value_matchers;
1788 0 : value_matchers.push_back(value0_matcher);
1789 0 : value_matchers.push_back(value1_matcher);
1790 : return MakeMatcher(new IsTailCallMatcher(descriptor_matcher, value_matchers,
1791 0 : effect_matcher, control_matcher));
1792 : }
1793 :
1794 :
1795 0 : Matcher<Node*> IsTailCall(
1796 : const Matcher<CallDescriptor const*>& descriptor_matcher,
1797 : const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher,
1798 : const Matcher<Node*>& value2_matcher, const Matcher<Node*>& effect_matcher,
1799 : const Matcher<Node*>& control_matcher) {
1800 : std::vector<Matcher<Node*>> value_matchers;
1801 0 : value_matchers.push_back(value0_matcher);
1802 0 : value_matchers.push_back(value1_matcher);
1803 0 : value_matchers.push_back(value2_matcher);
1804 : return MakeMatcher(new IsTailCallMatcher(descriptor_matcher, value_matchers,
1805 0 : effect_matcher, control_matcher));
1806 : }
1807 :
1808 :
1809 0 : Matcher<Node*> IsTailCall(
1810 : const Matcher<CallDescriptor const*>& descriptor_matcher,
1811 : const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher,
1812 : const Matcher<Node*>& value2_matcher, const Matcher<Node*>& value3_matcher,
1813 : const Matcher<Node*>& effect_matcher,
1814 : const Matcher<Node*>& control_matcher) {
1815 : std::vector<Matcher<Node*>> value_matchers;
1816 0 : value_matchers.push_back(value0_matcher);
1817 0 : value_matchers.push_back(value1_matcher);
1818 0 : value_matchers.push_back(value2_matcher);
1819 0 : value_matchers.push_back(value3_matcher);
1820 : return MakeMatcher(new IsTailCallMatcher(descriptor_matcher, value_matchers,
1821 0 : effect_matcher, control_matcher));
1822 : }
1823 :
1824 :
1825 0 : Matcher<Node*> IsTailCall(
1826 : const Matcher<CallDescriptor const*>& descriptor_matcher,
1827 : const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher,
1828 : const Matcher<Node*>& value2_matcher, const Matcher<Node*>& value3_matcher,
1829 : const Matcher<Node*>& value4_matcher, const Matcher<Node*>& effect_matcher,
1830 : const Matcher<Node*>& control_matcher) {
1831 : std::vector<Matcher<Node*>> value_matchers;
1832 0 : value_matchers.push_back(value0_matcher);
1833 0 : value_matchers.push_back(value1_matcher);
1834 0 : value_matchers.push_back(value2_matcher);
1835 0 : value_matchers.push_back(value3_matcher);
1836 0 : value_matchers.push_back(value4_matcher);
1837 : return MakeMatcher(new IsTailCallMatcher(descriptor_matcher, value_matchers,
1838 0 : effect_matcher, control_matcher));
1839 : }
1840 :
1841 :
1842 0 : Matcher<Node*> IsTailCall(
1843 : const Matcher<CallDescriptor const*>& descriptor_matcher,
1844 : const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher,
1845 : const Matcher<Node*>& value2_matcher, const Matcher<Node*>& value3_matcher,
1846 : const Matcher<Node*>& value4_matcher, const Matcher<Node*>& value5_matcher,
1847 : const Matcher<Node*>& effect_matcher,
1848 : const Matcher<Node*>& control_matcher) {
1849 : std::vector<Matcher<Node*>> value_matchers;
1850 0 : value_matchers.push_back(value0_matcher);
1851 0 : value_matchers.push_back(value1_matcher);
1852 0 : value_matchers.push_back(value2_matcher);
1853 0 : value_matchers.push_back(value3_matcher);
1854 0 : value_matchers.push_back(value4_matcher);
1855 0 : value_matchers.push_back(value5_matcher);
1856 : return MakeMatcher(new IsTailCallMatcher(descriptor_matcher, value_matchers,
1857 0 : effect_matcher, control_matcher));
1858 : }
1859 :
1860 :
1861 0 : Matcher<Node*> IsTailCall(
1862 : const Matcher<CallDescriptor const*>& descriptor_matcher,
1863 : const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher,
1864 : const Matcher<Node*>& value2_matcher, const Matcher<Node*>& value3_matcher,
1865 : const Matcher<Node*>& value4_matcher, const Matcher<Node*>& value5_matcher,
1866 : const Matcher<Node*>& value6_matcher, const Matcher<Node*>& effect_matcher,
1867 : const Matcher<Node*>& control_matcher) {
1868 : std::vector<Matcher<Node*>> value_matchers;
1869 0 : value_matchers.push_back(value0_matcher);
1870 0 : value_matchers.push_back(value1_matcher);
1871 0 : value_matchers.push_back(value2_matcher);
1872 0 : value_matchers.push_back(value3_matcher);
1873 0 : value_matchers.push_back(value4_matcher);
1874 0 : value_matchers.push_back(value5_matcher);
1875 0 : value_matchers.push_back(value6_matcher);
1876 : return MakeMatcher(new IsTailCallMatcher(descriptor_matcher, value_matchers,
1877 0 : effect_matcher, control_matcher));
1878 : }
1879 :
1880 :
1881 0 : Matcher<Node*> IsTailCall(
1882 : const Matcher<CallDescriptor const*>& descriptor_matcher,
1883 : const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher,
1884 : const Matcher<Node*>& value2_matcher, const Matcher<Node*>& value3_matcher,
1885 : const Matcher<Node*>& value4_matcher, const Matcher<Node*>& value5_matcher,
1886 : const Matcher<Node*>& value6_matcher, const Matcher<Node*>& value7_matcher,
1887 : const Matcher<Node*>& effect_matcher,
1888 : const Matcher<Node*>& control_matcher) {
1889 : std::vector<Matcher<Node*>> value_matchers;
1890 0 : value_matchers.push_back(value0_matcher);
1891 0 : value_matchers.push_back(value1_matcher);
1892 0 : value_matchers.push_back(value2_matcher);
1893 0 : value_matchers.push_back(value3_matcher);
1894 0 : value_matchers.push_back(value4_matcher);
1895 0 : value_matchers.push_back(value5_matcher);
1896 0 : value_matchers.push_back(value6_matcher);
1897 0 : value_matchers.push_back(value7_matcher);
1898 : return MakeMatcher(new IsTailCallMatcher(descriptor_matcher, value_matchers,
1899 0 : effect_matcher, control_matcher));
1900 : }
1901 :
1902 : #define DEFINE_SPECULATIVE_BINOP_MATCHER(opcode) \
1903 : Matcher<Node*> Is##opcode(const Matcher<NumberOperationHint>& hint_matcher, \
1904 : const Matcher<Node*>& lhs_matcher, \
1905 : const Matcher<Node*>& rhs_matcher, \
1906 : const Matcher<Node*>& effect_matcher, \
1907 : const Matcher<Node*>& control_matcher) { \
1908 : return MakeMatcher(new IsSpeculativeBinopMatcher( \
1909 : IrOpcode::k##opcode, hint_matcher, lhs_matcher, rhs_matcher, \
1910 : effect_matcher, control_matcher)); \
1911 : }
1912 0 : SPECULATIVE_BINOPS(DEFINE_SPECULATIVE_BINOP_MATCHER);
1913 : #undef DEFINE_SPECULATIVE_BINOP_MATCHER
1914 :
1915 7 : Matcher<Node*> IsAllocate(const Matcher<Node*>& size_matcher,
1916 : const Matcher<Node*>& effect_matcher,
1917 : const Matcher<Node*>& control_matcher) {
1918 : return MakeMatcher(
1919 14 : new IsAllocateMatcher(size_matcher, effect_matcher, control_matcher));
1920 : }
1921 :
1922 :
1923 67 : Matcher<Node*> IsLoadField(const Matcher<FieldAccess>& access_matcher,
1924 : const Matcher<Node*>& base_matcher,
1925 : const Matcher<Node*>& effect_matcher,
1926 : const Matcher<Node*>& control_matcher) {
1927 : return MakeMatcher(new IsLoadFieldMatcher(access_matcher, base_matcher,
1928 134 : effect_matcher, control_matcher));
1929 : }
1930 :
1931 :
1932 60 : Matcher<Node*> IsStoreField(const Matcher<FieldAccess>& access_matcher,
1933 : const Matcher<Node*>& base_matcher,
1934 : const Matcher<Node*>& value_matcher,
1935 : const Matcher<Node*>& effect_matcher,
1936 : const Matcher<Node*>& control_matcher) {
1937 : return MakeMatcher(new IsStoreFieldMatcher(access_matcher, base_matcher,
1938 : value_matcher, effect_matcher,
1939 120 : control_matcher));
1940 : }
1941 :
1942 0 : Matcher<Node*> IsLoadElement(const Matcher<ElementAccess>& access_matcher,
1943 : const Matcher<Node*>& base_matcher,
1944 : const Matcher<Node*>& index_matcher,
1945 : const Matcher<Node*>& effect_matcher,
1946 : const Matcher<Node*>& control_matcher) {
1947 : return MakeMatcher(new IsLoadElementMatcher(access_matcher, base_matcher,
1948 : index_matcher, effect_matcher,
1949 0 : control_matcher));
1950 : }
1951 :
1952 :
1953 0 : Matcher<Node*> IsStoreElement(const Matcher<ElementAccess>& access_matcher,
1954 : const Matcher<Node*>& base_matcher,
1955 : const Matcher<Node*>& index_matcher,
1956 : const Matcher<Node*>& value_matcher,
1957 : const Matcher<Node*>& effect_matcher,
1958 : const Matcher<Node*>& control_matcher) {
1959 : return MakeMatcher(new IsStoreElementMatcher(
1960 : access_matcher, base_matcher, index_matcher, value_matcher,
1961 0 : effect_matcher, control_matcher));
1962 : }
1963 :
1964 2577 : Matcher<Node*> IsLoad(const Matcher<LoadRepresentation>& rep_matcher,
1965 : const Matcher<Node*>& base_matcher,
1966 : const Matcher<Node*>& index_matcher,
1967 : const Matcher<Node*>& effect_matcher,
1968 : const Matcher<Node*>& control_matcher) {
1969 : return MakeMatcher(new IsLoadMatcher(rep_matcher, base_matcher, index_matcher,
1970 5154 : effect_matcher, control_matcher));
1971 : }
1972 :
1973 2 : Matcher<Node*> IsUnalignedLoad(
1974 : const Matcher<UnalignedLoadRepresentation>& rep_matcher,
1975 : const Matcher<Node*>& base_matcher, const Matcher<Node*>& index_matcher,
1976 : const Matcher<Node*>& effect_matcher,
1977 : const Matcher<Node*>& control_matcher) {
1978 : return MakeMatcher(new IsUnalignedLoadMatcher(rep_matcher, base_matcher,
1979 : index_matcher, effect_matcher,
1980 4 : control_matcher));
1981 : }
1982 :
1983 314 : Matcher<Node*> IsStore(const Matcher<StoreRepresentation>& rep_matcher,
1984 : const Matcher<Node*>& base_matcher,
1985 : const Matcher<Node*>& index_matcher,
1986 : const Matcher<Node*>& value_matcher,
1987 : const Matcher<Node*>& effect_matcher,
1988 : const Matcher<Node*>& control_matcher) {
1989 : return MakeMatcher(new IsStoreMatcher(rep_matcher, base_matcher,
1990 : index_matcher, value_matcher,
1991 628 : effect_matcher, control_matcher));
1992 : }
1993 :
1994 2 : Matcher<Node*> IsUnalignedStore(
1995 : const Matcher<UnalignedStoreRepresentation>& rep_matcher,
1996 : const Matcher<Node*>& base_matcher, const Matcher<Node*>& index_matcher,
1997 : const Matcher<Node*>& value_matcher, const Matcher<Node*>& effect_matcher,
1998 : const Matcher<Node*>& control_matcher) {
1999 : return MakeMatcher(new IsUnalignedStoreMatcher(
2000 : rep_matcher, base_matcher, index_matcher, value_matcher, effect_matcher,
2001 4 : control_matcher));
2002 : }
2003 :
2004 2 : Matcher<Node*> IsStackSlot(
2005 : const Matcher<StackSlotRepresentation>& rep_matcher) {
2006 4 : return MakeMatcher(new IsStackSlotMatcher(rep_matcher));
2007 : }
2008 :
2009 0 : Matcher<Node*> IsToNumber(const Matcher<Node*>& base_matcher,
2010 : const Matcher<Node*>& context_matcher,
2011 : const Matcher<Node*>& effect_matcher,
2012 : const Matcher<Node*>& control_matcher) {
2013 : return MakeMatcher(new IsToNumberMatcher(base_matcher, context_matcher,
2014 0 : effect_matcher, control_matcher));
2015 : }
2016 :
2017 :
2018 0 : Matcher<Node*> IsLoadContext(const Matcher<ContextAccess>& access_matcher,
2019 : const Matcher<Node*>& context_matcher) {
2020 0 : return MakeMatcher(new IsLoadContextMatcher(access_matcher, context_matcher));
2021 : }
2022 :
2023 :
2024 2041 : Matcher<Node*> IsParameter(const Matcher<int> index_matcher) {
2025 4082 : return MakeMatcher(new IsParameterMatcher(index_matcher));
2026 : }
2027 :
2028 :
2029 0 : Matcher<Node*> IsLoadFramePointer() {
2030 0 : return MakeMatcher(new TestNodeMatcher(IrOpcode::kLoadFramePointer));
2031 : }
2032 :
2033 860 : Matcher<Node*> IsLoadParentFramePointer() {
2034 1720 : return MakeMatcher(new TestNodeMatcher(IrOpcode::kLoadParentFramePointer));
2035 : }
2036 :
2037 : #define IS_QUADOP_MATCHER(Name) \
2038 : Matcher<Node*> Is##Name( \
2039 : const Matcher<Node*>& a_matcher, const Matcher<Node*>& b_matcher, \
2040 : const Matcher<Node*>& c_matcher, const Matcher<Node*>& d_matcher) { \
2041 : return MakeMatcher(new IsQuadopMatcher(IrOpcode::k##Name, a_matcher, \
2042 : b_matcher, c_matcher, d_matcher)); \
2043 : }
2044 :
2045 0 : IS_QUADOP_MATCHER(Int32PairAdd)
2046 2 : IS_QUADOP_MATCHER(Int32PairSub)
2047 2 : IS_QUADOP_MATCHER(Int32PairMul)
2048 :
2049 : #define IS_TERNOP_MATCHER(Name) \
2050 : Matcher<Node*> Is##Name(const Matcher<Node*>& lhs_matcher, \
2051 : const Matcher<Node*>& mid_matcher, \
2052 : const Matcher<Node*>& rhs_matcher) { \
2053 : return MakeMatcher(new IsTernopMatcher(IrOpcode::k##Name, lhs_matcher, \
2054 : mid_matcher, rhs_matcher)); \
2055 : }
2056 :
2057 2 : IS_TERNOP_MATCHER(Word32PairShl)
2058 2 : IS_TERNOP_MATCHER(Word32PairShr)
2059 2 : IS_TERNOP_MATCHER(Word32PairSar)
2060 :
2061 : #define IS_BINOP_MATCHER(Name) \
2062 : Matcher<Node*> Is##Name(const Matcher<Node*>& lhs_matcher, \
2063 : const Matcher<Node*>& rhs_matcher) { \
2064 : return MakeMatcher( \
2065 : new IsBinopMatcher(IrOpcode::k##Name, lhs_matcher, rhs_matcher)); \
2066 : }
2067 106 : IS_BINOP_MATCHER(NumberEqual)
2068 0 : IS_BINOP_MATCHER(NumberLessThan)
2069 124 : IS_BINOP_MATCHER(NumberSubtract)
2070 0 : IS_BINOP_MATCHER(NumberMultiply)
2071 66 : IS_BINOP_MATCHER(NumberShiftLeft)
2072 66 : IS_BINOP_MATCHER(NumberShiftRight)
2073 66 : IS_BINOP_MATCHER(NumberShiftRightLogical)
2074 6 : IS_BINOP_MATCHER(NumberImul)
2075 290 : IS_BINOP_MATCHER(NumberAtan2)
2076 2 : IS_BINOP_MATCHER(NumberMax)
2077 2 : IS_BINOP_MATCHER(NumberMin)
2078 290 : IS_BINOP_MATCHER(NumberPow)
2079 6 : IS_BINOP_MATCHER(ReferenceEqual)
2080 60532 : IS_BINOP_MATCHER(Word32And)
2081 26 : IS_BINOP_MATCHER(Word32Or)
2082 10 : IS_BINOP_MATCHER(Word32Xor)
2083 634 : IS_BINOP_MATCHER(Word32Sar)
2084 1994 : IS_BINOP_MATCHER(Word32Shl)
2085 580 : IS_BINOP_MATCHER(Word32Shr)
2086 152 : IS_BINOP_MATCHER(Word32Ror)
2087 22 : IS_BINOP_MATCHER(Word32Equal)
2088 2 : IS_BINOP_MATCHER(Word64And)
2089 2 : IS_BINOP_MATCHER(Word64Or)
2090 2 : IS_BINOP_MATCHER(Word64Xor)
2091 2 : IS_BINOP_MATCHER(Word64Sar)
2092 1378 : IS_BINOP_MATCHER(Word64Shl)
2093 2 : IS_BINOP_MATCHER(Word64Shr)
2094 0 : IS_BINOP_MATCHER(Word64Equal)
2095 4 : IS_BINOP_MATCHER(Int32AddWithOverflow)
2096 4 : IS_BINOP_MATCHER(Int32SubWithOverflow)
2097 24380 : IS_BINOP_MATCHER(Int32Add)
2098 634 : IS_BINOP_MATCHER(Int32Sub)
2099 23590 : IS_BINOP_MATCHER(Int32Mul)
2100 388 : IS_BINOP_MATCHER(Int32MulHigh)
2101 250 : IS_BINOP_MATCHER(Int32LessThan)
2102 14 : IS_BINOP_MATCHER(Uint32LessThan)
2103 4 : IS_BINOP_MATCHER(Uint32LessThanOrEqual)
2104 2394 : IS_BINOP_MATCHER(Int64Add)
2105 2 : IS_BINOP_MATCHER(Int64Sub)
2106 2 : IS_BINOP_MATCHER(Int64Mul)
2107 0 : IS_BINOP_MATCHER(JSAdd)
2108 202 : IS_BINOP_MATCHER(Float32Equal)
2109 402 : IS_BINOP_MATCHER(Float32LessThan)
2110 402 : IS_BINOP_MATCHER(Float32LessThanOrEqual)
2111 0 : IS_BINOP_MATCHER(Float64Max)
2112 0 : IS_BINOP_MATCHER(Float64Min)
2113 4 : IS_BINOP_MATCHER(Float64Add)
2114 4 : IS_BINOP_MATCHER(Float64Sub)
2115 4090 : IS_BINOP_MATCHER(Float64Mul)
2116 0 : IS_BINOP_MATCHER(Float64InsertLowWord32)
2117 0 : IS_BINOP_MATCHER(Float64InsertHighWord32)
2118 : #undef IS_BINOP_MATCHER
2119 :
2120 :
2121 : #define IS_UNOP_MATCHER(Name) \
2122 : Matcher<Node*> Is##Name(const Matcher<Node*>& input_matcher) { \
2123 : return MakeMatcher(new IsUnopMatcher(IrOpcode::k##Name, input_matcher)); \
2124 : }
2125 34 : IS_UNOP_MATCHER(BooleanNot)
2126 0 : IS_UNOP_MATCHER(BitcastTaggedToWord)
2127 0 : IS_UNOP_MATCHER(BitcastWordToTagged)
2128 0 : IS_UNOP_MATCHER(BitcastWordToTaggedSigned)
2129 4 : IS_UNOP_MATCHER(TruncateFloat64ToWord32)
2130 4 : IS_UNOP_MATCHER(ChangeFloat64ToInt32)
2131 4 : IS_UNOP_MATCHER(ChangeFloat64ToUint32)
2132 2 : IS_UNOP_MATCHER(ChangeInt32ToFloat64)
2133 630 : IS_UNOP_MATCHER(ChangeInt32ToInt64)
2134 2 : IS_UNOP_MATCHER(ChangeUint32ToFloat64)
2135 684 : IS_UNOP_MATCHER(ChangeUint32ToUint64)
2136 0 : IS_UNOP_MATCHER(TruncateFloat64ToFloat32)
2137 0 : IS_UNOP_MATCHER(TruncateInt64ToInt32)
2138 4 : IS_UNOP_MATCHER(Float32Abs)
2139 2 : IS_UNOP_MATCHER(Float32Neg)
2140 4 : IS_UNOP_MATCHER(Float64Abs)
2141 4 : IS_UNOP_MATCHER(Float64Neg)
2142 0 : IS_UNOP_MATCHER(Float64Sqrt)
2143 0 : IS_UNOP_MATCHER(Float64RoundDown)
2144 0 : IS_UNOP_MATCHER(Float64RoundTruncate)
2145 0 : IS_UNOP_MATCHER(Float64RoundTiesAway)
2146 0 : IS_UNOP_MATCHER(Float64ExtractLowWord32)
2147 0 : IS_UNOP_MATCHER(Float64ExtractHighWord32)
2148 26 : IS_UNOP_MATCHER(NumberAbs)
2149 26 : IS_UNOP_MATCHER(NumberAcos)
2150 26 : IS_UNOP_MATCHER(NumberAcosh)
2151 26 : IS_UNOP_MATCHER(NumberAsin)
2152 26 : IS_UNOP_MATCHER(NumberAsinh)
2153 26 : IS_UNOP_MATCHER(NumberAtan)
2154 26 : IS_UNOP_MATCHER(NumberAtanh)
2155 26 : IS_UNOP_MATCHER(NumberCeil)
2156 6 : IS_UNOP_MATCHER(NumberClz32)
2157 0 : IS_UNOP_MATCHER(NumberCbrt)
2158 26 : IS_UNOP_MATCHER(NumberCos)
2159 26 : IS_UNOP_MATCHER(NumberCosh)
2160 26 : IS_UNOP_MATCHER(NumberExp)
2161 0 : IS_UNOP_MATCHER(NumberExpm1)
2162 26 : IS_UNOP_MATCHER(NumberFloor)
2163 26 : IS_UNOP_MATCHER(NumberFround)
2164 26 : IS_UNOP_MATCHER(NumberLog)
2165 26 : IS_UNOP_MATCHER(NumberLog1p)
2166 0 : IS_UNOP_MATCHER(NumberLog10)
2167 0 : IS_UNOP_MATCHER(NumberLog2)
2168 26 : IS_UNOP_MATCHER(NumberRound)
2169 26 : IS_UNOP_MATCHER(NumberSign)
2170 26 : IS_UNOP_MATCHER(NumberSin)
2171 26 : IS_UNOP_MATCHER(NumberSinh)
2172 26 : IS_UNOP_MATCHER(NumberSqrt)
2173 26 : IS_UNOP_MATCHER(NumberTan)
2174 26 : IS_UNOP_MATCHER(NumberTanh)
2175 50 : IS_UNOP_MATCHER(NumberTrunc)
2176 2 : IS_UNOP_MATCHER(NumberToBoolean)
2177 0 : IS_UNOP_MATCHER(NumberToInt32)
2178 12 : IS_UNOP_MATCHER(NumberToUint32)
2179 84 : IS_UNOP_MATCHER(PlainPrimitiveToNumber)
2180 24 : IS_UNOP_MATCHER(ObjectIsNaN)
2181 2 : IS_UNOP_MATCHER(ObjectIsReceiver)
2182 6 : IS_UNOP_MATCHER(ObjectIsSmi)
2183 2 : IS_UNOP_MATCHER(ObjectIsUndetectable)
2184 26 : IS_UNOP_MATCHER(StringFromCharCode)
2185 4 : IS_UNOP_MATCHER(Word32Clz)
2186 4 : IS_UNOP_MATCHER(Word32Ctz)
2187 4 : IS_UNOP_MATCHER(Word32Popcnt)
2188 4 : IS_UNOP_MATCHER(Word32ReverseBytes)
2189 : #undef IS_UNOP_MATCHER
2190 :
2191 : } // namespace compiler
2192 : } // namespace internal
2193 7893 : } // namespace v8
|