blob: 74afda974a15002ff02139f1350b8e7880da24fd [file] [log] [blame]
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001// 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 "src/assembler.h"
8#include "src/compiler/node-properties-inl.h"
9#include "src/compiler/simplified-operator.h"
10
11using testing::_;
12using testing::MakeMatcher;
13using testing::MatcherInterface;
14using testing::MatchResultListener;
15using testing::StringMatchResultListener;
16
17namespace v8 {
18namespace internal {
19namespace compiler {
20
21namespace {
22
23template <typename T>
24bool PrintMatchAndExplain(const T& value, const char* value_name,
25 const Matcher<T>& value_matcher,
26 MatchResultListener* listener) {
27 StringMatchResultListener value_listener;
28 if (!value_matcher.MatchAndExplain(value, &value_listener)) {
29 *listener << "whose " << value_name << " " << value << " doesn't match";
30 if (value_listener.str() != "") {
31 *listener << ", " << value_listener.str();
32 }
33 return false;
34 }
35 return true;
36}
37
38
39class NodeMatcher : public MatcherInterface<Node*> {
40 public:
41 explicit NodeMatcher(IrOpcode::Value opcode) : opcode_(opcode) {}
42
43 void DescribeTo(std::ostream* os) const OVERRIDE {
44 *os << "is a " << IrOpcode::Mnemonic(opcode_) << " node";
45 }
46
47 bool MatchAndExplain(Node* node,
48 MatchResultListener* listener) const OVERRIDE {
49 if (node == NULL) {
50 *listener << "which is NULL";
51 return false;
52 }
53 if (node->opcode() != opcode_) {
54 *listener << "whose opcode is " << IrOpcode::Mnemonic(node->opcode())
55 << " but should have been " << IrOpcode::Mnemonic(opcode_);
56 return false;
57 }
58 return true;
59 }
60
61 private:
62 const IrOpcode::Value opcode_;
63};
64
65
66class IsBranchMatcher FINAL : public NodeMatcher {
67 public:
68 IsBranchMatcher(const Matcher<Node*>& value_matcher,
69 const Matcher<Node*>& control_matcher)
70 : NodeMatcher(IrOpcode::kBranch),
71 value_matcher_(value_matcher),
72 control_matcher_(control_matcher) {}
73
74 void DescribeTo(std::ostream* os) const FINAL {
75 NodeMatcher::DescribeTo(os);
76 *os << " whose value (";
77 value_matcher_.DescribeTo(os);
78 *os << ") and control (";
79 control_matcher_.DescribeTo(os);
80 *os << ")";
81 }
82
83 bool MatchAndExplain(Node* node, MatchResultListener* listener) const FINAL {
84 return (NodeMatcher::MatchAndExplain(node, listener) &&
85 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
86 "value", value_matcher_, listener) &&
87 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
88 "control", control_matcher_, listener));
89 }
90
91 private:
92 const Matcher<Node*> value_matcher_;
93 const Matcher<Node*> control_matcher_;
94};
95
96
97class IsMergeMatcher FINAL : public NodeMatcher {
98 public:
99 IsMergeMatcher(const Matcher<Node*>& control0_matcher,
100 const Matcher<Node*>& control1_matcher)
101 : NodeMatcher(IrOpcode::kMerge),
102 control0_matcher_(control0_matcher),
103 control1_matcher_(control1_matcher) {}
104
105 void DescribeTo(std::ostream* os) const FINAL {
106 NodeMatcher::DescribeTo(os);
107 *os << " whose control0 (";
108 control0_matcher_.DescribeTo(os);
109 *os << ") and control1 (";
110 control1_matcher_.DescribeTo(os);
111 *os << ")";
112 }
113
114 bool MatchAndExplain(Node* node, MatchResultListener* listener) const FINAL {
115 return (NodeMatcher::MatchAndExplain(node, listener) &&
116 PrintMatchAndExplain(NodeProperties::GetControlInput(node, 0),
117 "control0", control0_matcher_, listener) &&
118 PrintMatchAndExplain(NodeProperties::GetControlInput(node, 1),
119 "control1", control1_matcher_, listener));
120 }
121
122 private:
123 const Matcher<Node*> control0_matcher_;
124 const Matcher<Node*> control1_matcher_;
125};
126
127
128class IsControl1Matcher FINAL : public NodeMatcher {
129 public:
130 IsControl1Matcher(IrOpcode::Value opcode,
131 const Matcher<Node*>& control_matcher)
132 : NodeMatcher(opcode), control_matcher_(control_matcher) {}
133
134 void DescribeTo(std::ostream* os) const FINAL {
135 NodeMatcher::DescribeTo(os);
136 *os << " whose control (";
137 control_matcher_.DescribeTo(os);
138 *os << ")";
139 }
140
141 bool MatchAndExplain(Node* node, MatchResultListener* listener) const FINAL {
142 return (NodeMatcher::MatchAndExplain(node, listener) &&
143 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
144 "control", control_matcher_, listener));
145 }
146
147 private:
148 const Matcher<Node*> control_matcher_;
149};
150
151
152class IsFinishMatcher FINAL : public NodeMatcher {
153 public:
154 IsFinishMatcher(const Matcher<Node*>& value_matcher,
155 const Matcher<Node*>& effect_matcher)
156 : NodeMatcher(IrOpcode::kFinish),
157 value_matcher_(value_matcher),
158 effect_matcher_(effect_matcher) {}
159
160 void DescribeTo(std::ostream* os) const FINAL {
161 NodeMatcher::DescribeTo(os);
162 *os << " whose value (";
163 value_matcher_.DescribeTo(os);
164 *os << ") and effect (";
165 effect_matcher_.DescribeTo(os);
166 *os << ")";
167 }
168
169 bool MatchAndExplain(Node* node, MatchResultListener* listener) const FINAL {
170 return (NodeMatcher::MatchAndExplain(node, listener) &&
171 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
172 "value", value_matcher_, listener) &&
173 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
174 effect_matcher_, listener));
175 }
176
177 private:
178 const Matcher<Node*> value_matcher_;
179 const Matcher<Node*> effect_matcher_;
180};
181
182
183template <typename T>
184class IsConstantMatcher FINAL : public NodeMatcher {
185 public:
186 IsConstantMatcher(IrOpcode::Value opcode, const Matcher<T>& value_matcher)
187 : NodeMatcher(opcode), value_matcher_(value_matcher) {}
188
189 void DescribeTo(std::ostream* os) const FINAL {
190 NodeMatcher::DescribeTo(os);
191 *os << " whose value (";
192 value_matcher_.DescribeTo(os);
193 *os << ")";
194 }
195
196 bool MatchAndExplain(Node* node, MatchResultListener* listener) const FINAL {
197 return (NodeMatcher::MatchAndExplain(node, listener) &&
198 PrintMatchAndExplain(OpParameter<T>(node), "value", value_matcher_,
199 listener));
200 }
201
202 private:
203 const Matcher<T> value_matcher_;
204};
205
206
207class IsSelectMatcher FINAL : public NodeMatcher {
208 public:
209 IsSelectMatcher(const Matcher<MachineType>& type_matcher,
210 const Matcher<Node*>& value0_matcher,
211 const Matcher<Node*>& value1_matcher,
212 const Matcher<Node*>& value2_matcher)
213 : NodeMatcher(IrOpcode::kSelect),
214 type_matcher_(type_matcher),
215 value0_matcher_(value0_matcher),
216 value1_matcher_(value1_matcher),
217 value2_matcher_(value2_matcher) {}
218
219 void DescribeTo(std::ostream* os) const FINAL {
220 NodeMatcher::DescribeTo(os);
221 *os << " whose type (";
222 type_matcher_.DescribeTo(os);
223 *os << "), value0 (";
224 value0_matcher_.DescribeTo(os);
225 *os << "), value1 (";
226 value1_matcher_.DescribeTo(os);
227 *os << ") and value2 (";
228 value2_matcher_.DescribeTo(os);
229 *os << ")";
230 }
231
232 bool MatchAndExplain(Node* node, MatchResultListener* listener) const FINAL {
233 return (NodeMatcher::MatchAndExplain(node, listener) &&
234 PrintMatchAndExplain(OpParameter<MachineType>(node), "type",
235 type_matcher_, listener) &&
236 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
237 "value0", value0_matcher_, listener) &&
238 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
239 "value1", value1_matcher_, listener) &&
240 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2),
241 "value2", value2_matcher_, listener));
242 }
243
244 private:
245 const Matcher<MachineType> type_matcher_;
246 const Matcher<Node*> value0_matcher_;
247 const Matcher<Node*> value1_matcher_;
248 const Matcher<Node*> value2_matcher_;
249};
250
251
252class IsPhiMatcher FINAL : public NodeMatcher {
253 public:
254 IsPhiMatcher(const Matcher<MachineType>& type_matcher,
255 const Matcher<Node*>& value0_matcher,
256 const Matcher<Node*>& value1_matcher,
257 const Matcher<Node*>& control_matcher)
258 : NodeMatcher(IrOpcode::kPhi),
259 type_matcher_(type_matcher),
260 value0_matcher_(value0_matcher),
261 value1_matcher_(value1_matcher),
262 control_matcher_(control_matcher) {}
263
264 void DescribeTo(std::ostream* os) const FINAL {
265 NodeMatcher::DescribeTo(os);
266 *os << " whose type (";
267 type_matcher_.DescribeTo(os);
268 *os << "), value0 (";
269 value0_matcher_.DescribeTo(os);
270 *os << "), value1 (";
271 value1_matcher_.DescribeTo(os);
272 *os << ") and control (";
273 control_matcher_.DescribeTo(os);
274 *os << ")";
275 }
276
277 bool MatchAndExplain(Node* node, MatchResultListener* listener) const FINAL {
278 return (NodeMatcher::MatchAndExplain(node, listener) &&
279 PrintMatchAndExplain(OpParameter<MachineType>(node), "type",
280 type_matcher_, listener) &&
281 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
282 "value0", value0_matcher_, listener) &&
283 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
284 "value1", value1_matcher_, listener) &&
285 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
286 "control", control_matcher_, listener));
287 }
288
289 private:
290 const Matcher<MachineType> type_matcher_;
291 const Matcher<Node*> value0_matcher_;
292 const Matcher<Node*> value1_matcher_;
293 const Matcher<Node*> control_matcher_;
294};
295
296
297class IsEffectPhiMatcher FINAL : public NodeMatcher {
298 public:
299 IsEffectPhiMatcher(const Matcher<Node*>& effect0_matcher,
300 const Matcher<Node*>& effect1_matcher,
301 const Matcher<Node*>& control_matcher)
302 : NodeMatcher(IrOpcode::kEffectPhi),
303 effect0_matcher_(effect0_matcher),
304 effect1_matcher_(effect1_matcher),
305 control_matcher_(control_matcher) {}
306
307 void DescribeTo(std::ostream* os) const FINAL {
308 NodeMatcher::DescribeTo(os);
309 *os << "), effect0 (";
310 effect0_matcher_.DescribeTo(os);
311 *os << "), effect1 (";
312 effect1_matcher_.DescribeTo(os);
313 *os << ") and control (";
314 control_matcher_.DescribeTo(os);
315 *os << ")";
316 }
317
318 bool MatchAndExplain(Node* node, MatchResultListener* listener) const FINAL {
319 return (NodeMatcher::MatchAndExplain(node, listener) &&
320 PrintMatchAndExplain(NodeProperties::GetEffectInput(node, 0),
321 "effect0", effect0_matcher_, listener) &&
322 PrintMatchAndExplain(NodeProperties::GetEffectInput(node, 1),
323 "effect1", effect1_matcher_, listener) &&
324 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
325 "control", control_matcher_, listener));
326 }
327
328 private:
329 const Matcher<Node*> effect0_matcher_;
330 const Matcher<Node*> effect1_matcher_;
331 const Matcher<Node*> control_matcher_;
332};
333
334
335class IsProjectionMatcher FINAL : public NodeMatcher {
336 public:
337 IsProjectionMatcher(const Matcher<size_t>& index_matcher,
338 const Matcher<Node*>& base_matcher)
339 : NodeMatcher(IrOpcode::kProjection),
340 index_matcher_(index_matcher),
341 base_matcher_(base_matcher) {}
342
343 void DescribeTo(std::ostream* os) const FINAL {
344 NodeMatcher::DescribeTo(os);
345 *os << " whose index (";
346 index_matcher_.DescribeTo(os);
347 *os << ") and base (";
348 base_matcher_.DescribeTo(os);
349 *os << ")";
350 }
351
352 bool MatchAndExplain(Node* node, MatchResultListener* listener) const FINAL {
353 return (NodeMatcher::MatchAndExplain(node, listener) &&
354 PrintMatchAndExplain(OpParameter<size_t>(node), "index",
355 index_matcher_, listener) &&
356 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
357 base_matcher_, listener));
358 }
359
360 private:
361 const Matcher<size_t> index_matcher_;
362 const Matcher<Node*> base_matcher_;
363};
364
365
366class IsCall2Matcher FINAL : public NodeMatcher {
367 public:
368 IsCall2Matcher(const Matcher<CallDescriptor*>& descriptor_matcher,
369 const Matcher<Node*>& value0_matcher,
370 const Matcher<Node*>& value1_matcher,
371 const Matcher<Node*>& effect_matcher,
372 const Matcher<Node*>& control_matcher)
373 : NodeMatcher(IrOpcode::kCall),
374 descriptor_matcher_(descriptor_matcher),
375 value0_matcher_(value0_matcher),
376 value1_matcher_(value1_matcher),
377 effect_matcher_(effect_matcher),
378 control_matcher_(control_matcher) {}
379
380 void DescribeTo(std::ostream* os) const FINAL {
381 NodeMatcher::DescribeTo(os);
382 *os << " whose value0 (";
383 value0_matcher_.DescribeTo(os);
384 *os << ") and value1 (";
385 value1_matcher_.DescribeTo(os);
386 *os << ") and effect (";
387 effect_matcher_.DescribeTo(os);
388 *os << ") and control (";
389 control_matcher_.DescribeTo(os);
390 *os << ")";
391 }
392
393 bool MatchAndExplain(Node* node, MatchResultListener* listener) const FINAL {
394 return (NodeMatcher::MatchAndExplain(node, listener) &&
395 PrintMatchAndExplain(OpParameter<CallDescriptor*>(node),
396 "descriptor", descriptor_matcher_, listener) &&
397 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
398 "value0", value0_matcher_, listener) &&
399 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
400 "value1", value1_matcher_, listener) &&
401 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
402 effect_matcher_, listener) &&
403 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
404 "control", control_matcher_, listener));
405 }
406
407 private:
408 const Matcher<CallDescriptor*> descriptor_matcher_;
409 const Matcher<Node*> value0_matcher_;
410 const Matcher<Node*> value1_matcher_;
411 const Matcher<Node*> effect_matcher_;
412 const Matcher<Node*> control_matcher_;
413};
414
415
416class IsCall4Matcher FINAL : public NodeMatcher {
417 public:
418 IsCall4Matcher(const Matcher<CallDescriptor*>& descriptor_matcher,
419 const Matcher<Node*>& value0_matcher,
420 const Matcher<Node*>& value1_matcher,
421 const Matcher<Node*>& value2_matcher,
422 const Matcher<Node*>& value3_matcher,
423 const Matcher<Node*>& effect_matcher,
424 const Matcher<Node*>& control_matcher)
425 : NodeMatcher(IrOpcode::kCall),
426 descriptor_matcher_(descriptor_matcher),
427 value0_matcher_(value0_matcher),
428 value1_matcher_(value1_matcher),
429 value2_matcher_(value2_matcher),
430 value3_matcher_(value3_matcher),
431 effect_matcher_(effect_matcher),
432 control_matcher_(control_matcher) {}
433
434 void DescribeTo(std::ostream* os) const FINAL {
435 NodeMatcher::DescribeTo(os);
436 *os << " whose value0 (";
437 value0_matcher_.DescribeTo(os);
438 *os << ") and value1 (";
439 value1_matcher_.DescribeTo(os);
440 *os << ") and value2 (";
441 value2_matcher_.DescribeTo(os);
442 *os << ") and value3 (";
443 value3_matcher_.DescribeTo(os);
444 *os << ") and effect (";
445 effect_matcher_.DescribeTo(os);
446 *os << ") and control (";
447 control_matcher_.DescribeTo(os);
448 *os << ")";
449 }
450
451 bool MatchAndExplain(Node* node, MatchResultListener* listener) const FINAL {
452 return (NodeMatcher::MatchAndExplain(node, listener) &&
453 PrintMatchAndExplain(OpParameter<CallDescriptor*>(node),
454 "descriptor", descriptor_matcher_, listener) &&
455 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
456 "value0", value0_matcher_, listener) &&
457 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
458 "value1", value1_matcher_, listener) &&
459 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2),
460 "value2", value2_matcher_, listener) &&
461 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 3),
462 "value3", value3_matcher_, listener) &&
463 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
464 effect_matcher_, listener) &&
465 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
466 "control", control_matcher_, listener));
467 }
468
469 private:
470 const Matcher<CallDescriptor*> descriptor_matcher_;
471 const Matcher<Node*> value0_matcher_;
472 const Matcher<Node*> value1_matcher_;
473 const Matcher<Node*> value2_matcher_;
474 const Matcher<Node*> value3_matcher_;
475 const Matcher<Node*> effect_matcher_;
476 const Matcher<Node*> control_matcher_;
477};
478
479
480class IsLoadFieldMatcher FINAL : public NodeMatcher {
481 public:
482 IsLoadFieldMatcher(const Matcher<FieldAccess>& access_matcher,
483 const Matcher<Node*>& base_matcher,
484 const Matcher<Node*>& effect_matcher,
485 const Matcher<Node*>& control_matcher)
486 : NodeMatcher(IrOpcode::kLoadField),
487 access_matcher_(access_matcher),
488 base_matcher_(base_matcher),
489 effect_matcher_(effect_matcher),
490 control_matcher_(control_matcher) {}
491
492 void DescribeTo(std::ostream* os) const FINAL {
493 NodeMatcher::DescribeTo(os);
494 *os << " whose access (";
495 access_matcher_.DescribeTo(os);
496 *os << "), base (";
497 base_matcher_.DescribeTo(os);
498 *os << "), effect (";
499 effect_matcher_.DescribeTo(os);
500 *os << ") and control (";
501 control_matcher_.DescribeTo(os);
502 *os << ")";
503 }
504
505 bool MatchAndExplain(Node* node, MatchResultListener* listener) const FINAL {
506 return (NodeMatcher::MatchAndExplain(node, listener) &&
507 PrintMatchAndExplain(OpParameter<FieldAccess>(node), "access",
508 access_matcher_, listener) &&
509 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
510 base_matcher_, listener) &&
511 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
512 effect_matcher_, listener) &&
513 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
514 "control", control_matcher_, listener));
515 }
516
517 private:
518 const Matcher<FieldAccess> access_matcher_;
519 const Matcher<Node*> base_matcher_;
520 const Matcher<Node*> effect_matcher_;
521 const Matcher<Node*> control_matcher_;
522};
523
524
525class IsStoreFieldMatcher FINAL : public NodeMatcher {
526 public:
527 IsStoreFieldMatcher(const Matcher<FieldAccess>& access_matcher,
528 const Matcher<Node*>& base_matcher,
529 const Matcher<Node*>& value_matcher,
530 const Matcher<Node*>& effect_matcher,
531 const Matcher<Node*>& control_matcher)
532 : NodeMatcher(IrOpcode::kStoreField),
533 access_matcher_(access_matcher),
534 base_matcher_(base_matcher),
535 value_matcher_(value_matcher),
536 effect_matcher_(effect_matcher),
537 control_matcher_(control_matcher) {}
538
539 void DescribeTo(std::ostream* os) const FINAL {
540 NodeMatcher::DescribeTo(os);
541 *os << " whose access (";
542 access_matcher_.DescribeTo(os);
543 *os << "), base (";
544 base_matcher_.DescribeTo(os);
545 *os << "), value (";
546 value_matcher_.DescribeTo(os);
547 *os << "), effect (";
548 effect_matcher_.DescribeTo(os);
549 *os << ") and control (";
550 control_matcher_.DescribeTo(os);
551 *os << ")";
552 }
553
554 bool MatchAndExplain(Node* node, MatchResultListener* listener) const FINAL {
555 return (NodeMatcher::MatchAndExplain(node, listener) &&
556 PrintMatchAndExplain(OpParameter<FieldAccess>(node), "access",
557 access_matcher_, listener) &&
558 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
559 base_matcher_, listener) &&
560 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
561 "value", value_matcher_, listener) &&
562 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
563 effect_matcher_, listener) &&
564 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
565 "control", control_matcher_, listener));
566 }
567
568 private:
569 const Matcher<FieldAccess> access_matcher_;
570 const Matcher<Node*> base_matcher_;
571 const Matcher<Node*> value_matcher_;
572 const Matcher<Node*> effect_matcher_;
573 const Matcher<Node*> control_matcher_;
574};
575
576
577class IsLoadBufferMatcher FINAL : public NodeMatcher {
578 public:
579 IsLoadBufferMatcher(const Matcher<BufferAccess>& access_matcher,
580 const Matcher<Node*>& buffer_matcher,
581 const Matcher<Node*>& offset_matcher,
582 const Matcher<Node*>& length_matcher,
583 const Matcher<Node*>& effect_matcher,
584 const Matcher<Node*>& control_matcher)
585 : NodeMatcher(IrOpcode::kLoadBuffer),
586 access_matcher_(access_matcher),
587 buffer_matcher_(buffer_matcher),
588 offset_matcher_(offset_matcher),
589 length_matcher_(length_matcher),
590 effect_matcher_(effect_matcher),
591 control_matcher_(control_matcher) {}
592
593 void DescribeTo(std::ostream* os) const FINAL {
594 NodeMatcher::DescribeTo(os);
595 *os << " whose access (";
596 access_matcher_.DescribeTo(os);
597 *os << "), buffer (";
598 buffer_matcher_.DescribeTo(os);
599 *os << "), offset (";
600 offset_matcher_.DescribeTo(os);
601 *os << "), length (";
602 length_matcher_.DescribeTo(os);
603 *os << "), effect (";
604 effect_matcher_.DescribeTo(os);
605 *os << ") and control (";
606 control_matcher_.DescribeTo(os);
607 *os << ")";
608 }
609
610 bool MatchAndExplain(Node* node, MatchResultListener* listener) const FINAL {
611 return (NodeMatcher::MatchAndExplain(node, listener) &&
612 PrintMatchAndExplain(BufferAccessOf(node->op()), "access",
613 access_matcher_, listener) &&
614 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
615 "buffer", buffer_matcher_, listener) &&
616 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
617 "offset", offset_matcher_, listener) &&
618 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2),
619 "length", length_matcher_, listener) &&
620 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
621 effect_matcher_, listener) &&
622 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
623 "control", control_matcher_, listener));
624 }
625
626 private:
627 const Matcher<BufferAccess> access_matcher_;
628 const Matcher<Node*> buffer_matcher_;
629 const Matcher<Node*> offset_matcher_;
630 const Matcher<Node*> length_matcher_;
631 const Matcher<Node*> effect_matcher_;
632 const Matcher<Node*> control_matcher_;
633};
634
635
636class IsStoreBufferMatcher FINAL : public NodeMatcher {
637 public:
638 IsStoreBufferMatcher(const Matcher<BufferAccess>& access_matcher,
639 const Matcher<Node*>& buffer_matcher,
640 const Matcher<Node*>& offset_matcher,
641 const Matcher<Node*>& length_matcher,
642 const Matcher<Node*>& value_matcher,
643 const Matcher<Node*>& effect_matcher,
644 const Matcher<Node*>& control_matcher)
645 : NodeMatcher(IrOpcode::kStoreBuffer),
646 access_matcher_(access_matcher),
647 buffer_matcher_(buffer_matcher),
648 offset_matcher_(offset_matcher),
649 length_matcher_(length_matcher),
650 value_matcher_(value_matcher),
651 effect_matcher_(effect_matcher),
652 control_matcher_(control_matcher) {}
653
654 void DescribeTo(std::ostream* os) const FINAL {
655 NodeMatcher::DescribeTo(os);
656 *os << " whose access (";
657 access_matcher_.DescribeTo(os);
658 *os << "), buffer (";
659 buffer_matcher_.DescribeTo(os);
660 *os << "), offset (";
661 offset_matcher_.DescribeTo(os);
662 *os << "), length (";
663 length_matcher_.DescribeTo(os);
664 *os << "), value (";
665 value_matcher_.DescribeTo(os);
666 *os << "), effect (";
667 effect_matcher_.DescribeTo(os);
668 *os << ") and control (";
669 control_matcher_.DescribeTo(os);
670 *os << ")";
671 }
672
673 bool MatchAndExplain(Node* node, MatchResultListener* listener) const FINAL {
674 return (NodeMatcher::MatchAndExplain(node, listener) &&
675 PrintMatchAndExplain(BufferAccessOf(node->op()), "access",
676 access_matcher_, listener) &&
677 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
678 "buffer", buffer_matcher_, listener) &&
679 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
680 "offset", offset_matcher_, listener) &&
681 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2),
682 "length", length_matcher_, listener) &&
683 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 3),
684 "value", value_matcher_, listener) &&
685 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
686 effect_matcher_, listener) &&
687 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
688 "control", control_matcher_, listener));
689 }
690
691 private:
692 const Matcher<BufferAccess> access_matcher_;
693 const Matcher<Node*> buffer_matcher_;
694 const Matcher<Node*> offset_matcher_;
695 const Matcher<Node*> length_matcher_;
696 const Matcher<Node*> value_matcher_;
697 const Matcher<Node*> effect_matcher_;
698 const Matcher<Node*> control_matcher_;
699};
700
701
702class IsLoadElementMatcher FINAL : public NodeMatcher {
703 public:
704 IsLoadElementMatcher(const Matcher<ElementAccess>& access_matcher,
705 const Matcher<Node*>& base_matcher,
706 const Matcher<Node*>& index_matcher,
707 const Matcher<Node*>& effect_matcher,
708 const Matcher<Node*>& control_matcher)
709 : NodeMatcher(IrOpcode::kLoadElement),
710 access_matcher_(access_matcher),
711 base_matcher_(base_matcher),
712 index_matcher_(index_matcher),
713 effect_matcher_(effect_matcher),
714 control_matcher_(control_matcher) {}
715
716 void DescribeTo(std::ostream* os) const FINAL {
717 NodeMatcher::DescribeTo(os);
718 *os << " whose access (";
719 access_matcher_.DescribeTo(os);
720 *os << "), base (";
721 base_matcher_.DescribeTo(os);
722 *os << "), index (";
723 index_matcher_.DescribeTo(os);
724 *os << "), effect (";
725 effect_matcher_.DescribeTo(os);
726 *os << ") and control (";
727 control_matcher_.DescribeTo(os);
728 *os << ")";
729 }
730
731 bool MatchAndExplain(Node* node, MatchResultListener* listener) const FINAL {
732 return (NodeMatcher::MatchAndExplain(node, listener) &&
733 PrintMatchAndExplain(OpParameter<ElementAccess>(node), "access",
734 access_matcher_, listener) &&
735 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
736 base_matcher_, listener) &&
737 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
738 "index", index_matcher_, listener) &&
739 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
740 effect_matcher_, listener) &&
741 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
742 "control", control_matcher_, listener));
743 }
744
745 private:
746 const Matcher<ElementAccess> access_matcher_;
747 const Matcher<Node*> base_matcher_;
748 const Matcher<Node*> index_matcher_;
749 const Matcher<Node*> effect_matcher_;
750 const Matcher<Node*> control_matcher_;
751};
752
753
754class IsStoreElementMatcher FINAL : public NodeMatcher {
755 public:
756 IsStoreElementMatcher(const Matcher<ElementAccess>& access_matcher,
757 const Matcher<Node*>& base_matcher,
758 const Matcher<Node*>& index_matcher,
759 const Matcher<Node*>& value_matcher,
760 const Matcher<Node*>& effect_matcher,
761 const Matcher<Node*>& control_matcher)
762 : NodeMatcher(IrOpcode::kStoreElement),
763 access_matcher_(access_matcher),
764 base_matcher_(base_matcher),
765 index_matcher_(index_matcher),
766 value_matcher_(value_matcher),
767 effect_matcher_(effect_matcher),
768 control_matcher_(control_matcher) {}
769
770 void DescribeTo(std::ostream* os) const FINAL {
771 NodeMatcher::DescribeTo(os);
772 *os << " whose access (";
773 access_matcher_.DescribeTo(os);
774 *os << "), base (";
775 base_matcher_.DescribeTo(os);
776 *os << "), index (";
777 index_matcher_.DescribeTo(os);
778 *os << "), value (";
779 value_matcher_.DescribeTo(os);
780 *os << "), effect (";
781 effect_matcher_.DescribeTo(os);
782 *os << ") and control (";
783 control_matcher_.DescribeTo(os);
784 *os << ")";
785 }
786
787 bool MatchAndExplain(Node* node, MatchResultListener* listener) const FINAL {
788 return (NodeMatcher::MatchAndExplain(node, listener) &&
789 PrintMatchAndExplain(OpParameter<ElementAccess>(node), "access",
790 access_matcher_, listener) &&
791 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
792 base_matcher_, listener) &&
793 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
794 "index", index_matcher_, listener) &&
795 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2),
796 "value", value_matcher_, listener) &&
797 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
798 effect_matcher_, listener) &&
799 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
800 "control", control_matcher_, listener));
801 }
802
803 private:
804 const Matcher<ElementAccess> access_matcher_;
805 const Matcher<Node*> base_matcher_;
806 const Matcher<Node*> index_matcher_;
807 const Matcher<Node*> value_matcher_;
808 const Matcher<Node*> effect_matcher_;
809 const Matcher<Node*> control_matcher_;
810};
811
812
813class IsLoadMatcher FINAL : public NodeMatcher {
814 public:
815 IsLoadMatcher(const Matcher<LoadRepresentation>& rep_matcher,
816 const Matcher<Node*>& base_matcher,
817 const Matcher<Node*>& index_matcher,
818 const Matcher<Node*>& effect_matcher,
819 const Matcher<Node*>& control_matcher)
820 : NodeMatcher(IrOpcode::kLoad),
821 rep_matcher_(rep_matcher),
822 base_matcher_(base_matcher),
823 index_matcher_(index_matcher),
824 effect_matcher_(effect_matcher),
825 control_matcher_(control_matcher) {}
826
827 void DescribeTo(std::ostream* os) const FINAL {
828 NodeMatcher::DescribeTo(os);
829 *os << " whose rep (";
830 rep_matcher_.DescribeTo(os);
831 *os << "), base (";
832 base_matcher_.DescribeTo(os);
833 *os << "), index (";
834 index_matcher_.DescribeTo(os);
835 *os << "), effect (";
836 effect_matcher_.DescribeTo(os);
837 *os << ") and control (";
838 control_matcher_.DescribeTo(os);
839 *os << ")";
840 }
841
842 bool MatchAndExplain(Node* node, MatchResultListener* listener) const FINAL {
843 return (NodeMatcher::MatchAndExplain(node, listener) &&
844 PrintMatchAndExplain(OpParameter<LoadRepresentation>(node), "rep",
845 rep_matcher_, listener) &&
846 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
847 base_matcher_, listener) &&
848 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
849 "index", index_matcher_, listener) &&
850 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
851 effect_matcher_, listener) &&
852 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
853 "control", control_matcher_, listener));
854 }
855
856 private:
857 const Matcher<LoadRepresentation> rep_matcher_;
858 const Matcher<Node*> base_matcher_;
859 const Matcher<Node*> index_matcher_;
860 const Matcher<Node*> effect_matcher_;
861 const Matcher<Node*> control_matcher_;
862};
863
864
865class IsToNumberMatcher FINAL : public NodeMatcher {
866 public:
867 IsToNumberMatcher(const Matcher<Node*>& base_matcher,
868 const Matcher<Node*>& context_matcher,
869 const Matcher<Node*>& effect_matcher,
870 const Matcher<Node*>& control_matcher)
871 : NodeMatcher(IrOpcode::kJSToNumber),
872 base_matcher_(base_matcher),
873 context_matcher_(context_matcher),
874 effect_matcher_(effect_matcher),
875 control_matcher_(control_matcher) {}
876
877 void DescribeTo(std::ostream* os) const FINAL {
878 NodeMatcher::DescribeTo(os);
879 *os << " whose base (";
880 base_matcher_.DescribeTo(os);
881 *os << "), context (";
882 context_matcher_.DescribeTo(os);
883 *os << "), effect (";
884 effect_matcher_.DescribeTo(os);
885 *os << ") and control (";
886 control_matcher_.DescribeTo(os);
887 *os << ")";
888 }
889
890 bool MatchAndExplain(Node* node, MatchResultListener* listener) const FINAL {
891 return (NodeMatcher::MatchAndExplain(node, listener) &&
892 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
893 base_matcher_, listener) &&
894 PrintMatchAndExplain(NodeProperties::GetContextInput(node),
895 "context", context_matcher_, listener) &&
896 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
897 effect_matcher_, listener) &&
898 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
899 "control", control_matcher_, listener));
900 }
901
902 private:
903 const Matcher<Node*> base_matcher_;
904 const Matcher<Node*> context_matcher_;
905 const Matcher<Node*> effect_matcher_;
906 const Matcher<Node*> control_matcher_;
907};
908
909
910class IsStoreMatcher FINAL : public NodeMatcher {
911 public:
912 IsStoreMatcher(const Matcher<StoreRepresentation>& rep_matcher,
913 const Matcher<Node*>& base_matcher,
914 const Matcher<Node*>& index_matcher,
915 const Matcher<Node*>& value_matcher,
916 const Matcher<Node*>& effect_matcher,
917 const Matcher<Node*>& control_matcher)
918 : NodeMatcher(IrOpcode::kStore),
919 rep_matcher_(rep_matcher),
920 base_matcher_(base_matcher),
921 index_matcher_(index_matcher),
922 value_matcher_(value_matcher),
923 effect_matcher_(effect_matcher),
924 control_matcher_(control_matcher) {}
925
926 void DescribeTo(std::ostream* os) const FINAL {
927 NodeMatcher::DescribeTo(os);
928 *os << " whose rep (";
929 rep_matcher_.DescribeTo(os);
930 *os << "), base (";
931 base_matcher_.DescribeTo(os);
932 *os << "), index (";
933 index_matcher_.DescribeTo(os);
934 *os << "), value (";
935 value_matcher_.DescribeTo(os);
936 *os << "), effect (";
937 effect_matcher_.DescribeTo(os);
938 *os << ") and control (";
939 control_matcher_.DescribeTo(os);
940 *os << ")";
941 }
942
943 bool MatchAndExplain(Node* node, MatchResultListener* listener) const FINAL {
944 return (NodeMatcher::MatchAndExplain(node, listener) &&
945 PrintMatchAndExplain(OpParameter<StoreRepresentation>(node), "rep",
946 rep_matcher_, listener) &&
947 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
948 base_matcher_, listener) &&
949 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
950 "index", index_matcher_, listener) &&
951 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2),
952 "value", value_matcher_, listener) &&
953 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
954 effect_matcher_, listener) &&
955 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
956 "control", control_matcher_, listener));
957 }
958
959 private:
960 const Matcher<StoreRepresentation> rep_matcher_;
961 const Matcher<Node*> base_matcher_;
962 const Matcher<Node*> index_matcher_;
963 const Matcher<Node*> value_matcher_;
964 const Matcher<Node*> effect_matcher_;
965 const Matcher<Node*> control_matcher_;
966};
967
968
969class IsBinopMatcher FINAL : public NodeMatcher {
970 public:
971 IsBinopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& lhs_matcher,
972 const Matcher<Node*>& rhs_matcher)
973 : NodeMatcher(opcode),
974 lhs_matcher_(lhs_matcher),
975 rhs_matcher_(rhs_matcher) {}
976
977 void DescribeTo(std::ostream* os) const FINAL {
978 NodeMatcher::DescribeTo(os);
979 *os << " whose lhs (";
980 lhs_matcher_.DescribeTo(os);
981 *os << ") and rhs (";
982 rhs_matcher_.DescribeTo(os);
983 *os << ")";
984 }
985
986 bool MatchAndExplain(Node* node, MatchResultListener* listener) const FINAL {
987 return (NodeMatcher::MatchAndExplain(node, listener) &&
988 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "lhs",
989 lhs_matcher_, listener) &&
990 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "rhs",
991 rhs_matcher_, listener));
992 }
993
994 private:
995 const Matcher<Node*> lhs_matcher_;
996 const Matcher<Node*> rhs_matcher_;
997};
998
999
1000class IsUnopMatcher FINAL : public NodeMatcher {
1001 public:
1002 IsUnopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& input_matcher)
1003 : NodeMatcher(opcode), input_matcher_(input_matcher) {}
1004
1005 void DescribeTo(std::ostream* os) const FINAL {
1006 NodeMatcher::DescribeTo(os);
1007 *os << " whose input (";
1008 input_matcher_.DescribeTo(os);
1009 *os << ")";
1010 }
1011
1012 bool MatchAndExplain(Node* node, MatchResultListener* listener) const FINAL {
1013 return (NodeMatcher::MatchAndExplain(node, listener) &&
1014 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
1015 "input", input_matcher_, listener));
1016 }
1017
1018 private:
1019 const Matcher<Node*> input_matcher_;
1020};
1021}
1022
1023
1024Matcher<Node*> IsBranch(const Matcher<Node*>& value_matcher,
1025 const Matcher<Node*>& control_matcher) {
1026 return MakeMatcher(new IsBranchMatcher(value_matcher, control_matcher));
1027}
1028
1029
1030Matcher<Node*> IsMerge(const Matcher<Node*>& control0_matcher,
1031 const Matcher<Node*>& control1_matcher) {
1032 return MakeMatcher(new IsMergeMatcher(control0_matcher, control1_matcher));
1033}
1034
1035
1036Matcher<Node*> IsIfTrue(const Matcher<Node*>& control_matcher) {
1037 return MakeMatcher(new IsControl1Matcher(IrOpcode::kIfTrue, control_matcher));
1038}
1039
1040
1041Matcher<Node*> IsIfFalse(const Matcher<Node*>& control_matcher) {
1042 return MakeMatcher(
1043 new IsControl1Matcher(IrOpcode::kIfFalse, control_matcher));
1044}
1045
1046
1047Matcher<Node*> IsValueEffect(const Matcher<Node*>& value_matcher) {
1048 return MakeMatcher(new IsUnopMatcher(IrOpcode::kValueEffect, value_matcher));
1049}
1050
1051
1052Matcher<Node*> IsFinish(const Matcher<Node*>& value_matcher,
1053 const Matcher<Node*>& effect_matcher) {
1054 return MakeMatcher(new IsFinishMatcher(value_matcher, effect_matcher));
1055}
1056
1057
1058Matcher<Node*> IsExternalConstant(
1059 const Matcher<ExternalReference>& value_matcher) {
1060 return MakeMatcher(new IsConstantMatcher<ExternalReference>(
1061 IrOpcode::kExternalConstant, value_matcher));
1062}
1063
1064
1065Matcher<Node*> IsHeapConstant(
1066 const Matcher<Unique<HeapObject> >& value_matcher) {
1067 return MakeMatcher(new IsConstantMatcher<Unique<HeapObject> >(
1068 IrOpcode::kHeapConstant, value_matcher));
1069}
1070
1071
1072Matcher<Node*> IsInt32Constant(const Matcher<int32_t>& value_matcher) {
1073 return MakeMatcher(
1074 new IsConstantMatcher<int32_t>(IrOpcode::kInt32Constant, value_matcher));
1075}
1076
1077
1078Matcher<Node*> IsInt64Constant(const Matcher<int64_t>& value_matcher) {
1079 return MakeMatcher(
1080 new IsConstantMatcher<int64_t>(IrOpcode::kInt64Constant, value_matcher));
1081}
1082
1083
1084Matcher<Node*> IsFloat32Constant(const Matcher<float>& value_matcher) {
1085 return MakeMatcher(
1086 new IsConstantMatcher<float>(IrOpcode::kFloat32Constant, value_matcher));
1087}
1088
1089
1090Matcher<Node*> IsFloat64Constant(const Matcher<double>& value_matcher) {
1091 return MakeMatcher(
1092 new IsConstantMatcher<double>(IrOpcode::kFloat64Constant, value_matcher));
1093}
1094
1095
1096Matcher<Node*> IsNumberConstant(const Matcher<double>& value_matcher) {
1097 return MakeMatcher(
1098 new IsConstantMatcher<double>(IrOpcode::kNumberConstant, value_matcher));
1099}
1100
1101
1102Matcher<Node*> IsSelect(const Matcher<MachineType>& type_matcher,
1103 const Matcher<Node*>& value0_matcher,
1104 const Matcher<Node*>& value1_matcher,
1105 const Matcher<Node*>& value2_matcher) {
1106 return MakeMatcher(new IsSelectMatcher(type_matcher, value0_matcher,
1107 value1_matcher, value2_matcher));
1108}
1109
1110
1111Matcher<Node*> IsPhi(const Matcher<MachineType>& type_matcher,
1112 const Matcher<Node*>& value0_matcher,
1113 const Matcher<Node*>& value1_matcher,
1114 const Matcher<Node*>& merge_matcher) {
1115 return MakeMatcher(new IsPhiMatcher(type_matcher, value0_matcher,
1116 value1_matcher, merge_matcher));
1117}
1118
1119
1120Matcher<Node*> IsEffectPhi(const Matcher<Node*>& effect0_matcher,
1121 const Matcher<Node*>& effect1_matcher,
1122 const Matcher<Node*>& merge_matcher) {
1123 return MakeMatcher(
1124 new IsEffectPhiMatcher(effect0_matcher, effect1_matcher, merge_matcher));
1125}
1126
1127
1128Matcher<Node*> IsProjection(const Matcher<size_t>& index_matcher,
1129 const Matcher<Node*>& base_matcher) {
1130 return MakeMatcher(new IsProjectionMatcher(index_matcher, base_matcher));
1131}
1132
1133
1134Matcher<Node*> IsCall(const Matcher<CallDescriptor*>& descriptor_matcher,
1135 const Matcher<Node*>& value0_matcher,
1136 const Matcher<Node*>& value1_matcher,
1137 const Matcher<Node*>& effect_matcher,
1138 const Matcher<Node*>& control_matcher) {
1139 return MakeMatcher(new IsCall2Matcher(descriptor_matcher, value0_matcher,
1140 value1_matcher, effect_matcher,
1141 control_matcher));
1142}
1143
1144
1145Matcher<Node*> IsCall(const Matcher<CallDescriptor*>& descriptor_matcher,
1146 const Matcher<Node*>& value0_matcher,
1147 const Matcher<Node*>& value1_matcher,
1148 const Matcher<Node*>& value2_matcher,
1149 const Matcher<Node*>& value3_matcher,
1150 const Matcher<Node*>& effect_matcher,
1151 const Matcher<Node*>& control_matcher) {
1152 return MakeMatcher(new IsCall4Matcher(
1153 descriptor_matcher, value0_matcher, value1_matcher, value2_matcher,
1154 value3_matcher, effect_matcher, control_matcher));
1155}
1156
1157
1158Matcher<Node*> IsLoadField(const Matcher<FieldAccess>& access_matcher,
1159 const Matcher<Node*>& base_matcher,
1160 const Matcher<Node*>& effect_matcher,
1161 const Matcher<Node*>& control_matcher) {
1162 return MakeMatcher(new IsLoadFieldMatcher(access_matcher, base_matcher,
1163 effect_matcher, control_matcher));
1164}
1165
1166
1167Matcher<Node*> IsStoreField(const Matcher<FieldAccess>& access_matcher,
1168 const Matcher<Node*>& base_matcher,
1169 const Matcher<Node*>& value_matcher,
1170 const Matcher<Node*>& effect_matcher,
1171 const Matcher<Node*>& control_matcher) {
1172 return MakeMatcher(new IsStoreFieldMatcher(access_matcher, base_matcher,
1173 value_matcher, effect_matcher,
1174 control_matcher));
1175}
1176
1177
1178Matcher<Node*> IsLoadBuffer(const Matcher<BufferAccess>& access_matcher,
1179 const Matcher<Node*>& buffer_matcher,
1180 const Matcher<Node*>& offset_matcher,
1181 const Matcher<Node*>& length_matcher,
1182 const Matcher<Node*>& effect_matcher,
1183 const Matcher<Node*>& control_matcher) {
1184 return MakeMatcher(new IsLoadBufferMatcher(access_matcher, buffer_matcher,
1185 offset_matcher, length_matcher,
1186 effect_matcher, control_matcher));
1187}
1188
1189
1190Matcher<Node*> IsStoreBuffer(const Matcher<BufferAccess>& access_matcher,
1191 const Matcher<Node*>& buffer_matcher,
1192 const Matcher<Node*>& offset_matcher,
1193 const Matcher<Node*>& length_matcher,
1194 const Matcher<Node*>& value_matcher,
1195 const Matcher<Node*>& effect_matcher,
1196 const Matcher<Node*>& control_matcher) {
1197 return MakeMatcher(new IsStoreBufferMatcher(
1198 access_matcher, buffer_matcher, offset_matcher, length_matcher,
1199 value_matcher, effect_matcher, control_matcher));
1200}
1201
1202
1203Matcher<Node*> IsLoadElement(const Matcher<ElementAccess>& access_matcher,
1204 const Matcher<Node*>& base_matcher,
1205 const Matcher<Node*>& index_matcher,
1206 const Matcher<Node*>& effect_matcher,
1207 const Matcher<Node*>& control_matcher) {
1208 return MakeMatcher(new IsLoadElementMatcher(access_matcher, base_matcher,
1209 index_matcher, effect_matcher,
1210 control_matcher));
1211}
1212
1213
1214Matcher<Node*> IsStoreElement(const Matcher<ElementAccess>& access_matcher,
1215 const Matcher<Node*>& base_matcher,
1216 const Matcher<Node*>& index_matcher,
1217 const Matcher<Node*>& value_matcher,
1218 const Matcher<Node*>& effect_matcher,
1219 const Matcher<Node*>& control_matcher) {
1220 return MakeMatcher(new IsStoreElementMatcher(
1221 access_matcher, base_matcher, index_matcher, value_matcher,
1222 effect_matcher, control_matcher));
1223}
1224
1225
1226Matcher<Node*> IsLoad(const Matcher<LoadRepresentation>& rep_matcher,
1227 const Matcher<Node*>& base_matcher,
1228 const Matcher<Node*>& index_matcher,
1229 const Matcher<Node*>& effect_matcher,
1230 const Matcher<Node*>& control_matcher) {
1231 return MakeMatcher(new IsLoadMatcher(rep_matcher, base_matcher, index_matcher,
1232 effect_matcher, control_matcher));
1233}
1234
1235
1236Matcher<Node*> IsToNumber(const Matcher<Node*>& base_matcher,
1237 const Matcher<Node*>& context_matcher,
1238 const Matcher<Node*>& effect_matcher,
1239 const Matcher<Node*>& control_matcher) {
1240 return MakeMatcher(new IsToNumberMatcher(base_matcher, context_matcher,
1241 effect_matcher, control_matcher));
1242}
1243
1244
1245Matcher<Node*> IsStore(const Matcher<StoreRepresentation>& rep_matcher,
1246 const Matcher<Node*>& base_matcher,
1247 const Matcher<Node*>& index_matcher,
1248 const Matcher<Node*>& value_matcher,
1249 const Matcher<Node*>& effect_matcher,
1250 const Matcher<Node*>& control_matcher) {
1251 return MakeMatcher(new IsStoreMatcher(rep_matcher, base_matcher,
1252 index_matcher, value_matcher,
1253 effect_matcher, control_matcher));
1254}
1255
1256
1257#define IS_BINOP_MATCHER(Name) \
1258 Matcher<Node*> Is##Name(const Matcher<Node*>& lhs_matcher, \
1259 const Matcher<Node*>& rhs_matcher) { \
1260 return MakeMatcher( \
1261 new IsBinopMatcher(IrOpcode::k##Name, lhs_matcher, rhs_matcher)); \
1262 }
1263IS_BINOP_MATCHER(NumberEqual)
1264IS_BINOP_MATCHER(NumberLessThan)
1265IS_BINOP_MATCHER(NumberSubtract)
1266IS_BINOP_MATCHER(NumberMultiply)
1267IS_BINOP_MATCHER(Word32And)
1268IS_BINOP_MATCHER(Word32Sar)
1269IS_BINOP_MATCHER(Word32Shl)
1270IS_BINOP_MATCHER(Word32Shr)
1271IS_BINOP_MATCHER(Word32Ror)
1272IS_BINOP_MATCHER(Word32Equal)
1273IS_BINOP_MATCHER(Word64And)
1274IS_BINOP_MATCHER(Word64Sar)
1275IS_BINOP_MATCHER(Word64Shl)
1276IS_BINOP_MATCHER(Word64Equal)
1277IS_BINOP_MATCHER(Int32AddWithOverflow)
1278IS_BINOP_MATCHER(Int32Add)
1279IS_BINOP_MATCHER(Int32Sub)
1280IS_BINOP_MATCHER(Int32Mul)
1281IS_BINOP_MATCHER(Int32MulHigh)
1282IS_BINOP_MATCHER(Int32LessThan)
1283IS_BINOP_MATCHER(Uint32LessThan)
1284IS_BINOP_MATCHER(Uint32LessThanOrEqual)
1285IS_BINOP_MATCHER(Float64Sub)
1286#undef IS_BINOP_MATCHER
1287
1288
1289#define IS_UNOP_MATCHER(Name) \
1290 Matcher<Node*> Is##Name(const Matcher<Node*>& input_matcher) { \
1291 return MakeMatcher(new IsUnopMatcher(IrOpcode::k##Name, input_matcher)); \
1292 }
1293IS_UNOP_MATCHER(AnyToBoolean)
1294IS_UNOP_MATCHER(BooleanNot)
1295IS_UNOP_MATCHER(ChangeFloat64ToInt32)
1296IS_UNOP_MATCHER(ChangeFloat64ToUint32)
1297IS_UNOP_MATCHER(ChangeInt32ToFloat64)
1298IS_UNOP_MATCHER(ChangeInt32ToInt64)
1299IS_UNOP_MATCHER(ChangeUint32ToFloat64)
1300IS_UNOP_MATCHER(ChangeUint32ToUint64)
1301IS_UNOP_MATCHER(TruncateFloat64ToFloat32)
1302IS_UNOP_MATCHER(TruncateFloat64ToInt32)
1303IS_UNOP_MATCHER(TruncateInt64ToInt32)
1304IS_UNOP_MATCHER(Float64Sqrt)
1305IS_UNOP_MATCHER(Float64Floor)
1306IS_UNOP_MATCHER(Float64Ceil)
1307IS_UNOP_MATCHER(Float64RoundTruncate)
1308IS_UNOP_MATCHER(Float64RoundTiesAway)
1309IS_UNOP_MATCHER(NumberToInt32)
1310IS_UNOP_MATCHER(NumberToUint32)
1311#undef IS_UNOP_MATCHER
1312
1313} // namespace compiler
1314} // namespace internal
1315} // namespace v8