blob: ee4cf5446ee29fac52db2cf7885bf8bc213b2936 [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
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00007#include <vector>
8
Emily Bernierd0a1eb72015-03-24 16:35:39 -04009#include "src/assembler.h"
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000010#include "src/compiler/common-operator.h"
11#include "src/compiler/js-operator.h"
12#include "src/compiler/node-properties.h"
Emily Bernierd0a1eb72015-03-24 16:35:39 -040013#include "src/compiler/simplified-operator.h"
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000014#include "src/handles-inl.h"
15#include "src/objects.h"
Emily Bernierd0a1eb72015-03-24 16:35:39 -040016
17using testing::_;
18using testing::MakeMatcher;
19using testing::MatcherInterface;
20using testing::MatchResultListener;
21using testing::StringMatchResultListener;
22
23namespace v8 {
24namespace internal {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000025
26bool operator==(Handle<HeapObject> const& lhs, Handle<HeapObject> const& rhs) {
27 return lhs.is_identical_to(rhs);
28}
29
Emily Bernierd0a1eb72015-03-24 16:35:39 -040030namespace compiler {
31
32namespace {
33
34template <typename T>
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000035bool PrintMatchAndExplain(const T& value, const std::string& value_name,
Emily Bernierd0a1eb72015-03-24 16:35:39 -040036 const Matcher<T>& value_matcher,
37 MatchResultListener* listener) {
38 StringMatchResultListener value_listener;
39 if (!value_matcher.MatchAndExplain(value, &value_listener)) {
40 *listener << "whose " << value_name << " " << value << " doesn't match";
41 if (value_listener.str() != "") {
42 *listener << ", " << value_listener.str();
43 }
44 return false;
45 }
46 return true;
47}
48
49
50class NodeMatcher : public MatcherInterface<Node*> {
51 public:
52 explicit NodeMatcher(IrOpcode::Value opcode) : opcode_(opcode) {}
53
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000054 void DescribeTo(std::ostream* os) const override {
Emily Bernierd0a1eb72015-03-24 16:35:39 -040055 *os << "is a " << IrOpcode::Mnemonic(opcode_) << " node";
56 }
57
58 bool MatchAndExplain(Node* node,
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000059 MatchResultListener* listener) const override {
Emily Bernierd0a1eb72015-03-24 16:35:39 -040060 if (node == NULL) {
61 *listener << "which is NULL";
62 return false;
63 }
64 if (node->opcode() != opcode_) {
65 *listener << "whose opcode is " << IrOpcode::Mnemonic(node->opcode())
66 << " 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
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000077class IsBranchMatcher final : public NodeMatcher {
Emily Bernierd0a1eb72015-03-24 16:35:39 -040078 public:
79 IsBranchMatcher(const Matcher<Node*>& value_matcher,
80 const Matcher<Node*>& control_matcher)
81 : NodeMatcher(IrOpcode::kBranch),
82 value_matcher_(value_matcher),
83 control_matcher_(control_matcher) {}
84
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000085 void DescribeTo(std::ostream* os) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -040086 NodeMatcher::DescribeTo(os);
87 *os << " whose value (";
88 value_matcher_.DescribeTo(os);
89 *os << ") and control (";
90 control_matcher_.DescribeTo(os);
91 *os << ")";
92 }
93
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000094 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -040095 return (NodeMatcher::MatchAndExplain(node, listener) &&
96 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
97 "value", value_matcher_, listener) &&
98 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
99 "control", control_matcher_, listener));
100 }
101
102 private:
103 const Matcher<Node*> value_matcher_;
104 const Matcher<Node*> control_matcher_;
105};
106
107
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000108class IsSwitchMatcher final : public NodeMatcher {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400109 public:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000110 IsSwitchMatcher(const Matcher<Node*>& value_matcher,
111 const Matcher<Node*>& control_matcher)
112 : NodeMatcher(IrOpcode::kSwitch),
113 value_matcher_(value_matcher),
114 control_matcher_(control_matcher) {}
115
116 void DescribeTo(std::ostream* os) const final {
117 NodeMatcher::DescribeTo(os);
118 *os << " whose value (";
119 value_matcher_.DescribeTo(os);
120 *os << ") and control (";
121 control_matcher_.DescribeTo(os);
122 *os << ")";
123 }
124
125 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
126 return (NodeMatcher::MatchAndExplain(node, listener) &&
127 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
128 "value", value_matcher_, listener) &&
129 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
130 "control", control_matcher_, listener));
131 }
132
133 private:
134 const Matcher<Node*> value_matcher_;
135 const Matcher<Node*> control_matcher_;
136};
137
138
139class IsIfValueMatcher final : public NodeMatcher {
140 public:
141 IsIfValueMatcher(const Matcher<int32_t>& value_matcher,
142 const Matcher<Node*>& control_matcher)
143 : NodeMatcher(IrOpcode::kIfValue),
144 value_matcher_(value_matcher),
145 control_matcher_(control_matcher) {}
146
147 void DescribeTo(std::ostream* os) const final {
148 NodeMatcher::DescribeTo(os);
149 *os << " whose value (";
150 value_matcher_.DescribeTo(os);
151 *os << ") and control (";
152 control_matcher_.DescribeTo(os);
153 *os << ")";
154 }
155
156 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
157 return (NodeMatcher::MatchAndExplain(node, listener) &&
158 PrintMatchAndExplain(OpParameter<int32_t>(node->op()), "value",
159 value_matcher_, listener) &&
160 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
161 "control", control_matcher_, listener));
162 }
163
164 private:
165 const Matcher<int32_t> value_matcher_;
166 const Matcher<Node*> control_matcher_;
167};
168
169
170class IsControl1Matcher final : public NodeMatcher {
171 public:
172 IsControl1Matcher(IrOpcode::Value opcode,
173 const Matcher<Node*>& control_matcher)
174 : NodeMatcher(opcode), control_matcher_(control_matcher) {}
175
176 void DescribeTo(std::ostream* os) const final {
177 NodeMatcher::DescribeTo(os);
178 *os << " whose control (";
179 control_matcher_.DescribeTo(os);
180 *os << ")";
181 }
182
183 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
184 return (NodeMatcher::MatchAndExplain(node, listener) &&
185 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
186 "control", control_matcher_, listener));
187 }
188
189 private:
190 const Matcher<Node*> control_matcher_;
191};
192
193
194class IsControl2Matcher final : public NodeMatcher {
195 public:
196 IsControl2Matcher(IrOpcode::Value opcode,
197 const Matcher<Node*>& control0_matcher,
198 const Matcher<Node*>& control1_matcher)
199 : NodeMatcher(opcode),
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400200 control0_matcher_(control0_matcher),
201 control1_matcher_(control1_matcher) {}
202
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000203 void DescribeTo(std::ostream* os) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400204 NodeMatcher::DescribeTo(os);
205 *os << " whose control0 (";
206 control0_matcher_.DescribeTo(os);
207 *os << ") and control1 (";
208 control1_matcher_.DescribeTo(os);
209 *os << ")";
210 }
211
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000212 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400213 return (NodeMatcher::MatchAndExplain(node, listener) &&
214 PrintMatchAndExplain(NodeProperties::GetControlInput(node, 0),
215 "control0", control0_matcher_, listener) &&
216 PrintMatchAndExplain(NodeProperties::GetControlInput(node, 1),
217 "control1", control1_matcher_, listener));
218 }
219
220 private:
221 const Matcher<Node*> control0_matcher_;
222 const Matcher<Node*> control1_matcher_;
223};
224
225
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000226class IsControl3Matcher final : public NodeMatcher {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400227 public:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000228 IsControl3Matcher(IrOpcode::Value opcode,
229 const Matcher<Node*>& control0_matcher,
230 const Matcher<Node*>& control1_matcher,
231 const Matcher<Node*>& control2_matcher)
232 : NodeMatcher(opcode),
233 control0_matcher_(control0_matcher),
234 control1_matcher_(control1_matcher),
235 control2_matcher_(control2_matcher) {}
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400236
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000237 void DescribeTo(std::ostream* os) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400238 NodeMatcher::DescribeTo(os);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000239 *os << " whose control0 (";
240 control0_matcher_.DescribeTo(os);
241 *os << ") and control1 (";
242 control1_matcher_.DescribeTo(os);
243 *os << ") and control2 (";
244 control2_matcher_.DescribeTo(os);
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400245 *os << ")";
246 }
247
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000248 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400249 return (NodeMatcher::MatchAndExplain(node, listener) &&
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000250 PrintMatchAndExplain(NodeProperties::GetControlInput(node, 0),
251 "control0", control0_matcher_, listener) &&
252 PrintMatchAndExplain(NodeProperties::GetControlInput(node, 1),
253 "control1", control1_matcher_, listener) &&
254 PrintMatchAndExplain(NodeProperties::GetControlInput(node, 2),
255 "control2", control2_matcher_, listener));
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400256 }
257
258 private:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000259 const Matcher<Node*> control0_matcher_;
260 const Matcher<Node*> control1_matcher_;
261 const Matcher<Node*> control2_matcher_;
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400262};
263
264
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000265class IsBeginRegionMatcher final : public NodeMatcher {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400266 public:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000267 explicit IsBeginRegionMatcher(const Matcher<Node*>& effect_matcher)
268 : NodeMatcher(IrOpcode::kBeginRegion), effect_matcher_(effect_matcher) {}
269
270 void DescribeTo(std::ostream* os) const final {
271 NodeMatcher::DescribeTo(os);
272 *os << " whose effect (";
273 effect_matcher_.DescribeTo(os);
274 *os << ")";
275 }
276
277 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
278 return (NodeMatcher::MatchAndExplain(node, listener) &&
279 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
280 effect_matcher_, listener));
281 }
282
283 private:
284 const Matcher<Node*> effect_matcher_;
285};
286
287
288class IsFinishRegionMatcher final : public NodeMatcher {
289 public:
290 IsFinishRegionMatcher(const Matcher<Node*>& value_matcher,
291 const Matcher<Node*>& effect_matcher)
292 : NodeMatcher(IrOpcode::kFinishRegion),
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400293 value_matcher_(value_matcher),
294 effect_matcher_(effect_matcher) {}
295
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000296 void DescribeTo(std::ostream* os) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400297 NodeMatcher::DescribeTo(os);
298 *os << " whose value (";
299 value_matcher_.DescribeTo(os);
300 *os << ") and effect (";
301 effect_matcher_.DescribeTo(os);
302 *os << ")";
303 }
304
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000305 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400306 return (NodeMatcher::MatchAndExplain(node, listener) &&
307 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
308 "value", value_matcher_, listener) &&
309 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
310 effect_matcher_, listener));
311 }
312
313 private:
314 const Matcher<Node*> value_matcher_;
315 const Matcher<Node*> effect_matcher_;
316};
317
318
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000319class IsReturnMatcher final : public NodeMatcher {
320 public:
321 IsReturnMatcher(const Matcher<Node*>& value_matcher,
322 const Matcher<Node*>& effect_matcher,
323 const Matcher<Node*>& control_matcher)
324 : NodeMatcher(IrOpcode::kReturn),
325 value_matcher_(value_matcher),
Ben Murdoch097c5b22016-05-18 11:27:45 +0100326 value2_matcher_(_),
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000327 effect_matcher_(effect_matcher),
Ben Murdoch097c5b22016-05-18 11:27:45 +0100328 control_matcher_(control_matcher),
329 has_second_return_value_(false) {}
330
331 IsReturnMatcher(const Matcher<Node*>& value_matcher,
332 const Matcher<Node*>& value2_matcher,
333 const Matcher<Node*>& effect_matcher,
334 const Matcher<Node*>& control_matcher)
335 : NodeMatcher(IrOpcode::kReturn),
336 value_matcher_(value_matcher),
337 value2_matcher_(value2_matcher),
338 effect_matcher_(effect_matcher),
339 control_matcher_(control_matcher),
340 has_second_return_value_(true) {}
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000341
342 void DescribeTo(std::ostream* os) const final {
343 NodeMatcher::DescribeTo(os);
344 *os << " whose value (";
345 value_matcher_.DescribeTo(os);
Ben Murdoch097c5b22016-05-18 11:27:45 +0100346 if (has_second_return_value_) {
347 *os << ") and second value (";
348 value2_matcher_.DescribeTo(os);
349 }
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000350 *os << ") and effect (";
351 effect_matcher_.DescribeTo(os);
352 *os << ") and control (";
353 control_matcher_.DescribeTo(os);
354 *os << ")";
355 }
356
357 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
358 return (NodeMatcher::MatchAndExplain(node, listener) &&
359 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
360 "value", value_matcher_, listener) &&
Ben Murdoch097c5b22016-05-18 11:27:45 +0100361 (!has_second_return_value_ ||
362 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
363 "value2", value2_matcher_, listener)) &&
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000364 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
365 effect_matcher_, listener) &&
366 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
367 "control", control_matcher_, listener));
368 }
369
370 private:
371 const Matcher<Node*> value_matcher_;
Ben Murdoch097c5b22016-05-18 11:27:45 +0100372 const Matcher<Node*> value2_matcher_;
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000373 const Matcher<Node*> effect_matcher_;
374 const Matcher<Node*> control_matcher_;
Ben Murdoch097c5b22016-05-18 11:27:45 +0100375 bool has_second_return_value_;
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000376};
377
378
379class IsTerminateMatcher final : public NodeMatcher {
380 public:
381 IsTerminateMatcher(const Matcher<Node*>& effect_matcher,
382 const Matcher<Node*>& control_matcher)
383 : NodeMatcher(IrOpcode::kTerminate),
384 effect_matcher_(effect_matcher),
385 control_matcher_(control_matcher) {}
386
387 void DescribeTo(std::ostream* os) const final {
388 NodeMatcher::DescribeTo(os);
389 *os << " whose effect (";
390 effect_matcher_.DescribeTo(os);
391 *os << ") and control (";
392 control_matcher_.DescribeTo(os);
393 *os << ")";
394 }
395
396 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
397 return (NodeMatcher::MatchAndExplain(node, listener) &&
398 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
399 effect_matcher_, listener) &&
400 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
401 "control", control_matcher_, listener));
402 }
403
404 private:
405 const Matcher<Node*> effect_matcher_;
406 const Matcher<Node*> control_matcher_;
407};
408
409
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400410template <typename T>
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000411class IsConstantMatcher final : public NodeMatcher {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400412 public:
413 IsConstantMatcher(IrOpcode::Value opcode, const Matcher<T>& value_matcher)
414 : NodeMatcher(opcode), value_matcher_(value_matcher) {}
415
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000416 void DescribeTo(std::ostream* os) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400417 NodeMatcher::DescribeTo(os);
418 *os << " whose value (";
419 value_matcher_.DescribeTo(os);
420 *os << ")";
421 }
422
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000423 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400424 return (NodeMatcher::MatchAndExplain(node, listener) &&
425 PrintMatchAndExplain(OpParameter<T>(node), "value", value_matcher_,
426 listener));
427 }
428
429 private:
430 const Matcher<T> value_matcher_;
431};
432
433
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000434class IsSelectMatcher final : public NodeMatcher {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400435 public:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000436 IsSelectMatcher(const Matcher<MachineRepresentation>& type_matcher,
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400437 const Matcher<Node*>& value0_matcher,
438 const Matcher<Node*>& value1_matcher,
439 const Matcher<Node*>& value2_matcher)
440 : NodeMatcher(IrOpcode::kSelect),
441 type_matcher_(type_matcher),
442 value0_matcher_(value0_matcher),
443 value1_matcher_(value1_matcher),
444 value2_matcher_(value2_matcher) {}
445
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000446 void DescribeTo(std::ostream* os) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400447 NodeMatcher::DescribeTo(os);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000448 *os << " whose representation (";
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400449 type_matcher_.DescribeTo(os);
450 *os << "), value0 (";
451 value0_matcher_.DescribeTo(os);
452 *os << "), value1 (";
453 value1_matcher_.DescribeTo(os);
454 *os << ") and value2 (";
455 value2_matcher_.DescribeTo(os);
456 *os << ")";
457 }
458
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000459 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
460 return (
461 NodeMatcher::MatchAndExplain(node, listener) &&
462 PrintMatchAndExplain(SelectParametersOf(node->op()).representation(),
463 "representation", type_matcher_, listener) &&
464 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "value0",
465 value0_matcher_, listener) &&
466 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "value1",
467 value1_matcher_, listener) &&
468 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2), "value2",
469 value2_matcher_, listener));
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400470 }
471
472 private:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000473 const Matcher<MachineRepresentation> type_matcher_;
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400474 const Matcher<Node*> value0_matcher_;
475 const Matcher<Node*> value1_matcher_;
476 const Matcher<Node*> value2_matcher_;
477};
478
479
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000480class IsPhiMatcher final : public NodeMatcher {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400481 public:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000482 IsPhiMatcher(const Matcher<MachineRepresentation>& type_matcher,
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400483 const Matcher<Node*>& value0_matcher,
484 const Matcher<Node*>& value1_matcher,
485 const Matcher<Node*>& control_matcher)
486 : NodeMatcher(IrOpcode::kPhi),
487 type_matcher_(type_matcher),
488 value0_matcher_(value0_matcher),
489 value1_matcher_(value1_matcher),
490 control_matcher_(control_matcher) {}
491
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000492 void DescribeTo(std::ostream* os) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400493 NodeMatcher::DescribeTo(os);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000494 *os << " whose representation (";
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400495 type_matcher_.DescribeTo(os);
496 *os << "), value0 (";
497 value0_matcher_.DescribeTo(os);
498 *os << "), value1 (";
499 value1_matcher_.DescribeTo(os);
500 *os << ") and control (";
501 control_matcher_.DescribeTo(os);
502 *os << ")";
503 }
504
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000505 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400506 return (NodeMatcher::MatchAndExplain(node, listener) &&
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000507 PrintMatchAndExplain(PhiRepresentationOf(node->op()),
508 "representation", type_matcher_, listener) &&
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400509 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
510 "value0", value0_matcher_, listener) &&
511 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
512 "value1", value1_matcher_, listener) &&
513 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
514 "control", control_matcher_, listener));
515 }
516
517 private:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000518 const Matcher<MachineRepresentation> type_matcher_;
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400519 const Matcher<Node*> value0_matcher_;
520 const Matcher<Node*> value1_matcher_;
521 const Matcher<Node*> control_matcher_;
522};
523
524
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000525class IsPhi2Matcher final : public NodeMatcher {
526 public:
527 IsPhi2Matcher(const Matcher<MachineRepresentation>& type_matcher,
528 const Matcher<Node*>& value0_matcher,
529 const Matcher<Node*>& value1_matcher,
530 const Matcher<Node*>& value2_matcher,
531 const Matcher<Node*>& control_matcher)
532 : NodeMatcher(IrOpcode::kPhi),
533 type_matcher_(type_matcher),
534 value0_matcher_(value0_matcher),
535 value1_matcher_(value1_matcher),
536 value2_matcher_(value2_matcher),
537 control_matcher_(control_matcher) {}
538
539 void DescribeTo(std::ostream* os) const final {
540 NodeMatcher::DescribeTo(os);
541 *os << " whose representation (";
542 type_matcher_.DescribeTo(os);
543 *os << "), value0 (";
544 value0_matcher_.DescribeTo(os);
545 *os << "), value1 (";
546 value1_matcher_.DescribeTo(os);
547 *os << "), value2 (";
548 value2_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(PhiRepresentationOf(node->op()),
557 "representation", type_matcher_, listener) &&
558 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
559 "value0", value0_matcher_, listener) &&
560 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
561 "value1", value1_matcher_, listener) &&
562 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2),
563 "value2", value2_matcher_, listener) &&
564 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
565 "control", control_matcher_, listener));
566 }
567
568 private:
569 const Matcher<MachineRepresentation> type_matcher_;
570 const Matcher<Node*> value0_matcher_;
571 const Matcher<Node*> value1_matcher_;
572 const Matcher<Node*> value2_matcher_;
573 const Matcher<Node*> control_matcher_;
574};
575
576
577class IsEffectPhiMatcher final : public NodeMatcher {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400578 public:
579 IsEffectPhiMatcher(const Matcher<Node*>& effect0_matcher,
580 const Matcher<Node*>& effect1_matcher,
581 const Matcher<Node*>& control_matcher)
582 : NodeMatcher(IrOpcode::kEffectPhi),
583 effect0_matcher_(effect0_matcher),
584 effect1_matcher_(effect1_matcher),
585 control_matcher_(control_matcher) {}
586
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000587 void DescribeTo(std::ostream* os) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400588 NodeMatcher::DescribeTo(os);
589 *os << "), effect0 (";
590 effect0_matcher_.DescribeTo(os);
591 *os << "), effect1 (";
592 effect1_matcher_.DescribeTo(os);
593 *os << ") and control (";
594 control_matcher_.DescribeTo(os);
595 *os << ")";
596 }
597
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000598 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400599 return (NodeMatcher::MatchAndExplain(node, listener) &&
600 PrintMatchAndExplain(NodeProperties::GetEffectInput(node, 0),
601 "effect0", effect0_matcher_, listener) &&
602 PrintMatchAndExplain(NodeProperties::GetEffectInput(node, 1),
603 "effect1", effect1_matcher_, listener) &&
604 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
605 "control", control_matcher_, listener));
606 }
607
608 private:
609 const Matcher<Node*> effect0_matcher_;
610 const Matcher<Node*> effect1_matcher_;
611 const Matcher<Node*> control_matcher_;
612};
613
614
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000615class IsEffectSetMatcher final : public NodeMatcher {
616 public:
617 IsEffectSetMatcher(const Matcher<Node*>& effect0_matcher,
618 const Matcher<Node*>& effect1_matcher)
619 : NodeMatcher(IrOpcode::kEffectSet),
620 effect0_matcher_(effect0_matcher),
621 effect1_matcher_(effect1_matcher) {}
622
623 void DescribeTo(std::ostream* os) const final {
624 NodeMatcher::DescribeTo(os);
625 *os << "), effect0 (";
626 effect0_matcher_.DescribeTo(os);
627 *os << ") and effect1 (";
628 effect1_matcher_.DescribeTo(os);
629 *os << ")";
630 }
631
632 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
633 if (!NodeMatcher::MatchAndExplain(node, listener)) return false;
634
635 Node* effect0 = NodeProperties::GetEffectInput(node, 0);
636 Node* effect1 = NodeProperties::GetEffectInput(node, 1);
637
638 {
639 // Try matching in the reverse order first.
640 StringMatchResultListener value_listener;
641 if (effect0_matcher_.MatchAndExplain(effect1, &value_listener) &&
642 effect1_matcher_.MatchAndExplain(effect0, &value_listener)) {
643 return true;
644 }
645 }
646
647 return PrintMatchAndExplain(effect0, "effect0", effect0_matcher_,
648 listener) &&
649 PrintMatchAndExplain(effect1, "effect1", effect1_matcher_, listener);
650 }
651
652 private:
653 const Matcher<Node*> effect0_matcher_;
654 const Matcher<Node*> effect1_matcher_;
655};
656
657
658class IsProjectionMatcher final : public NodeMatcher {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400659 public:
660 IsProjectionMatcher(const Matcher<size_t>& index_matcher,
661 const Matcher<Node*>& base_matcher)
662 : NodeMatcher(IrOpcode::kProjection),
663 index_matcher_(index_matcher),
664 base_matcher_(base_matcher) {}
665
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000666 void DescribeTo(std::ostream* os) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400667 NodeMatcher::DescribeTo(os);
668 *os << " whose index (";
669 index_matcher_.DescribeTo(os);
670 *os << ") and base (";
671 base_matcher_.DescribeTo(os);
672 *os << ")";
673 }
674
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000675 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400676 return (NodeMatcher::MatchAndExplain(node, listener) &&
677 PrintMatchAndExplain(OpParameter<size_t>(node), "index",
678 index_matcher_, listener) &&
679 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
680 base_matcher_, listener));
681 }
682
683 private:
684 const Matcher<size_t> index_matcher_;
685 const Matcher<Node*> base_matcher_;
686};
687
688
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000689class IsCallMatcher final : public NodeMatcher {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400690 public:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000691 IsCallMatcher(const Matcher<const CallDescriptor*>& descriptor_matcher,
692 const std::vector<Matcher<Node*>>& value_matchers,
693 const Matcher<Node*>& effect_matcher,
694 const Matcher<Node*>& control_matcher)
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400695 : NodeMatcher(IrOpcode::kCall),
696 descriptor_matcher_(descriptor_matcher),
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000697 value_matchers_(value_matchers),
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400698 effect_matcher_(effect_matcher),
699 control_matcher_(control_matcher) {}
700
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000701 void DescribeTo(std::ostream* os) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400702 NodeMatcher::DescribeTo(os);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000703 for (size_t i = 0; i < value_matchers_.size(); ++i) {
704 if (i == 0) {
705 *os << " whose value0 (";
706 } else {
707 *os << "), value" << i << " (";
708 }
709 value_matchers_[i].DescribeTo(os);
710 }
711 *os << "), effect (";
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400712 effect_matcher_.DescribeTo(os);
713 *os << ") and control (";
714 control_matcher_.DescribeTo(os);
715 *os << ")";
716 }
717
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000718 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
719 if (!NodeMatcher::MatchAndExplain(node, listener) ||
720 !PrintMatchAndExplain(OpParameter<const CallDescriptor*>(node),
721 "descriptor", descriptor_matcher_, listener)) {
722 return false;
723 }
724 for (size_t i = 0; i < value_matchers_.size(); ++i) {
725 std::ostringstream ost;
726 ost << "value" << i;
727 if (!PrintMatchAndExplain(
728 NodeProperties::GetValueInput(node, static_cast<int>(i)),
729 ost.str(), value_matchers_[i], listener)) {
730 return false;
731 }
732 }
733 Node* effect_node = nullptr;
734 Node* control_node = nullptr;
735 if (NodeProperties::FirstEffectIndex(node) < node->InputCount()) {
736 effect_node = NodeProperties::GetEffectInput(node);
737 }
738 if (NodeProperties::FirstControlIndex(node) < node->InputCount()) {
739 control_node = NodeProperties::GetControlInput(node);
740 }
741 return (PrintMatchAndExplain(effect_node, "effect", effect_matcher_,
742 listener) &&
743 PrintMatchAndExplain(control_node, "control", control_matcher_,
744 listener));
745 }
746
747 private:
748 const Matcher<const CallDescriptor*> descriptor_matcher_;
749 const std::vector<Matcher<Node*>> value_matchers_;
750 const Matcher<Node*> effect_matcher_;
751 const Matcher<Node*> control_matcher_;
752};
753
754
755class IsTailCallMatcher final : public NodeMatcher {
756 public:
757 IsTailCallMatcher(const Matcher<CallDescriptor const*>& descriptor_matcher,
758 const std::vector<Matcher<Node*>>& value_matchers,
759 const Matcher<Node*>& effect_matcher,
760 const Matcher<Node*>& control_matcher)
761 : NodeMatcher(IrOpcode::kTailCall),
762 descriptor_matcher_(descriptor_matcher),
763 value_matchers_(value_matchers),
764 effect_matcher_(effect_matcher),
765 control_matcher_(control_matcher) {}
766
767 void DescribeTo(std::ostream* os) const final {
768 NodeMatcher::DescribeTo(os);
769 for (size_t i = 0; i < value_matchers_.size(); ++i) {
770 if (i == 0) {
771 *os << " whose value0 (";
772 } else {
773 *os << "), value" << i << " (";
774 }
775 value_matchers_[i].DescribeTo(os);
776 }
777 *os << "), effect (";
778 effect_matcher_.DescribeTo(os);
779 *os << ") and control (";
780 control_matcher_.DescribeTo(os);
781 *os << ")";
782 }
783
784 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
785 if (!NodeMatcher::MatchAndExplain(node, listener) ||
786 !PrintMatchAndExplain(OpParameter<CallDescriptor const*>(node),
787 "descriptor", descriptor_matcher_, listener)) {
788 return false;
789 }
790 for (size_t i = 0; i < value_matchers_.size(); ++i) {
791 std::ostringstream ost;
792 ost << "value" << i;
793 if (!PrintMatchAndExplain(
794 NodeProperties::GetValueInput(node, static_cast<int>(i)),
795 ost.str(), value_matchers_[i], listener)) {
796 return false;
797 }
798 }
799 Node* effect_node = nullptr;
800 Node* control_node = nullptr;
801 if (NodeProperties::FirstEffectIndex(node) < node->InputCount()) {
802 effect_node = NodeProperties::GetEffectInput(node);
803 }
804 if (NodeProperties::FirstControlIndex(node) < node->InputCount()) {
805 control_node = NodeProperties::GetControlInput(node);
806 }
807 return (PrintMatchAndExplain(effect_node, "effect", effect_matcher_,
808 listener) &&
809 PrintMatchAndExplain(control_node, "control", control_matcher_,
810 listener));
811 }
812
813 private:
814 const Matcher<CallDescriptor const*> descriptor_matcher_;
815 const std::vector<Matcher<Node*>> value_matchers_;
816 const Matcher<Node*> effect_matcher_;
817 const Matcher<Node*> control_matcher_;
818};
819
820
821class IsReferenceEqualMatcher final : public NodeMatcher {
822 public:
823 IsReferenceEqualMatcher(const Matcher<Type*>& type_matcher,
824 const Matcher<Node*>& lhs_matcher,
825 const Matcher<Node*>& rhs_matcher)
826 : NodeMatcher(IrOpcode::kReferenceEqual),
827 type_matcher_(type_matcher),
828 lhs_matcher_(lhs_matcher),
829 rhs_matcher_(rhs_matcher) {}
830
831 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400832 return (NodeMatcher::MatchAndExplain(node, listener) &&
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000833 // TODO(bmeurer): The type parameter is currently ignored.
834 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "lhs",
835 lhs_matcher_, listener) &&
836 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "rhs",
837 rhs_matcher_, listener));
838 }
839
840 private:
841 const Matcher<Type*> type_matcher_;
842 const Matcher<Node*> lhs_matcher_;
843 const Matcher<Node*> rhs_matcher_;
844};
845
846
847class IsAllocateMatcher final : public NodeMatcher {
848 public:
849 IsAllocateMatcher(const Matcher<Node*>& size_matcher,
850 const Matcher<Node*>& effect_matcher,
851 const Matcher<Node*>& control_matcher)
852 : NodeMatcher(IrOpcode::kAllocate),
853 size_matcher_(size_matcher),
854 effect_matcher_(effect_matcher),
855 control_matcher_(control_matcher) {}
856
857 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
858 return (NodeMatcher::MatchAndExplain(node, listener) &&
859 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "size",
860 size_matcher_, listener) &&
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400861 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
862 effect_matcher_, listener) &&
863 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
864 "control", control_matcher_, listener));
865 }
866
867 private:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000868 const Matcher<Node*> size_matcher_;
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400869 const Matcher<Node*> effect_matcher_;
870 const Matcher<Node*> control_matcher_;
871};
872
873
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000874class IsLoadFieldMatcher final : public NodeMatcher {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400875 public:
876 IsLoadFieldMatcher(const Matcher<FieldAccess>& access_matcher,
877 const Matcher<Node*>& base_matcher,
878 const Matcher<Node*>& effect_matcher,
879 const Matcher<Node*>& control_matcher)
880 : NodeMatcher(IrOpcode::kLoadField),
881 access_matcher_(access_matcher),
882 base_matcher_(base_matcher),
883 effect_matcher_(effect_matcher),
884 control_matcher_(control_matcher) {}
885
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000886 void DescribeTo(std::ostream* os) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400887 NodeMatcher::DescribeTo(os);
888 *os << " whose access (";
889 access_matcher_.DescribeTo(os);
890 *os << "), base (";
891 base_matcher_.DescribeTo(os);
892 *os << "), effect (";
893 effect_matcher_.DescribeTo(os);
894 *os << ") and control (";
895 control_matcher_.DescribeTo(os);
896 *os << ")";
897 }
898
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000899 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400900 return (NodeMatcher::MatchAndExplain(node, listener) &&
901 PrintMatchAndExplain(OpParameter<FieldAccess>(node), "access",
902 access_matcher_, listener) &&
903 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
904 base_matcher_, listener) &&
905 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
906 effect_matcher_, listener) &&
907 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
908 "control", control_matcher_, listener));
909 }
910
911 private:
912 const Matcher<FieldAccess> access_matcher_;
913 const Matcher<Node*> base_matcher_;
914 const Matcher<Node*> effect_matcher_;
915 const Matcher<Node*> control_matcher_;
916};
917
918
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000919class IsStoreFieldMatcher final : public NodeMatcher {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400920 public:
921 IsStoreFieldMatcher(const Matcher<FieldAccess>& access_matcher,
922 const Matcher<Node*>& base_matcher,
923 const Matcher<Node*>& value_matcher,
924 const Matcher<Node*>& effect_matcher,
925 const Matcher<Node*>& control_matcher)
926 : NodeMatcher(IrOpcode::kStoreField),
927 access_matcher_(access_matcher),
928 base_matcher_(base_matcher),
929 value_matcher_(value_matcher),
930 effect_matcher_(effect_matcher),
931 control_matcher_(control_matcher) {}
932
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000933 void DescribeTo(std::ostream* os) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400934 NodeMatcher::DescribeTo(os);
935 *os << " whose access (";
936 access_matcher_.DescribeTo(os);
937 *os << "), base (";
938 base_matcher_.DescribeTo(os);
939 *os << "), value (";
940 value_matcher_.DescribeTo(os);
941 *os << "), effect (";
942 effect_matcher_.DescribeTo(os);
943 *os << ") and control (";
944 control_matcher_.DescribeTo(os);
945 *os << ")";
946 }
947
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000948 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400949 return (NodeMatcher::MatchAndExplain(node, listener) &&
950 PrintMatchAndExplain(OpParameter<FieldAccess>(node), "access",
951 access_matcher_, listener) &&
952 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
953 base_matcher_, listener) &&
954 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
955 "value", value_matcher_, listener) &&
956 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
957 effect_matcher_, listener) &&
958 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
959 "control", control_matcher_, listener));
960 }
961
962 private:
963 const Matcher<FieldAccess> access_matcher_;
964 const Matcher<Node*> base_matcher_;
965 const Matcher<Node*> value_matcher_;
966 const Matcher<Node*> effect_matcher_;
967 const Matcher<Node*> control_matcher_;
968};
969
970
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000971class IsLoadBufferMatcher final : public NodeMatcher {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400972 public:
973 IsLoadBufferMatcher(const Matcher<BufferAccess>& access_matcher,
974 const Matcher<Node*>& buffer_matcher,
975 const Matcher<Node*>& offset_matcher,
976 const Matcher<Node*>& length_matcher,
977 const Matcher<Node*>& effect_matcher,
978 const Matcher<Node*>& control_matcher)
979 : NodeMatcher(IrOpcode::kLoadBuffer),
980 access_matcher_(access_matcher),
981 buffer_matcher_(buffer_matcher),
982 offset_matcher_(offset_matcher),
983 length_matcher_(length_matcher),
984 effect_matcher_(effect_matcher),
985 control_matcher_(control_matcher) {}
986
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000987 void DescribeTo(std::ostream* os) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400988 NodeMatcher::DescribeTo(os);
989 *os << " whose access (";
990 access_matcher_.DescribeTo(os);
991 *os << "), buffer (";
992 buffer_matcher_.DescribeTo(os);
993 *os << "), offset (";
994 offset_matcher_.DescribeTo(os);
995 *os << "), length (";
996 length_matcher_.DescribeTo(os);
997 *os << "), effect (";
998 effect_matcher_.DescribeTo(os);
999 *os << ") and control (";
1000 control_matcher_.DescribeTo(os);
1001 *os << ")";
1002 }
1003
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001004 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001005 return (NodeMatcher::MatchAndExplain(node, listener) &&
1006 PrintMatchAndExplain(BufferAccessOf(node->op()), "access",
1007 access_matcher_, listener) &&
1008 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
1009 "buffer", buffer_matcher_, listener) &&
1010 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
1011 "offset", offset_matcher_, listener) &&
1012 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2),
1013 "length", length_matcher_, listener) &&
1014 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
1015 effect_matcher_, listener) &&
1016 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
1017 "control", control_matcher_, listener));
1018 }
1019
1020 private:
1021 const Matcher<BufferAccess> access_matcher_;
1022 const Matcher<Node*> buffer_matcher_;
1023 const Matcher<Node*> offset_matcher_;
1024 const Matcher<Node*> length_matcher_;
1025 const Matcher<Node*> effect_matcher_;
1026 const Matcher<Node*> control_matcher_;
1027};
1028
1029
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001030class IsStoreBufferMatcher final : public NodeMatcher {
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001031 public:
1032 IsStoreBufferMatcher(const Matcher<BufferAccess>& access_matcher,
1033 const Matcher<Node*>& buffer_matcher,
1034 const Matcher<Node*>& offset_matcher,
1035 const Matcher<Node*>& length_matcher,
1036 const Matcher<Node*>& value_matcher,
1037 const Matcher<Node*>& effect_matcher,
1038 const Matcher<Node*>& control_matcher)
1039 : NodeMatcher(IrOpcode::kStoreBuffer),
1040 access_matcher_(access_matcher),
1041 buffer_matcher_(buffer_matcher),
1042 offset_matcher_(offset_matcher),
1043 length_matcher_(length_matcher),
1044 value_matcher_(value_matcher),
1045 effect_matcher_(effect_matcher),
1046 control_matcher_(control_matcher) {}
1047
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001048 void DescribeTo(std::ostream* os) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001049 NodeMatcher::DescribeTo(os);
1050 *os << " whose access (";
1051 access_matcher_.DescribeTo(os);
1052 *os << "), buffer (";
1053 buffer_matcher_.DescribeTo(os);
1054 *os << "), offset (";
1055 offset_matcher_.DescribeTo(os);
1056 *os << "), length (";
1057 length_matcher_.DescribeTo(os);
1058 *os << "), value (";
1059 value_matcher_.DescribeTo(os);
1060 *os << "), effect (";
1061 effect_matcher_.DescribeTo(os);
1062 *os << ") and control (";
1063 control_matcher_.DescribeTo(os);
1064 *os << ")";
1065 }
1066
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001067 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001068 return (NodeMatcher::MatchAndExplain(node, listener) &&
1069 PrintMatchAndExplain(BufferAccessOf(node->op()), "access",
1070 access_matcher_, listener) &&
1071 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
1072 "buffer", buffer_matcher_, listener) &&
1073 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
1074 "offset", offset_matcher_, listener) &&
1075 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2),
1076 "length", length_matcher_, listener) &&
1077 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 3),
1078 "value", value_matcher_, listener) &&
1079 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
1080 effect_matcher_, listener) &&
1081 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
1082 "control", control_matcher_, listener));
1083 }
1084
1085 private:
1086 const Matcher<BufferAccess> access_matcher_;
1087 const Matcher<Node*> buffer_matcher_;
1088 const Matcher<Node*> offset_matcher_;
1089 const Matcher<Node*> length_matcher_;
1090 const Matcher<Node*> value_matcher_;
1091 const Matcher<Node*> effect_matcher_;
1092 const Matcher<Node*> control_matcher_;
1093};
1094
1095
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001096class IsLoadElementMatcher final : public NodeMatcher {
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001097 public:
1098 IsLoadElementMatcher(const Matcher<ElementAccess>& access_matcher,
1099 const Matcher<Node*>& base_matcher,
1100 const Matcher<Node*>& index_matcher,
1101 const Matcher<Node*>& effect_matcher,
1102 const Matcher<Node*>& control_matcher)
1103 : NodeMatcher(IrOpcode::kLoadElement),
1104 access_matcher_(access_matcher),
1105 base_matcher_(base_matcher),
1106 index_matcher_(index_matcher),
1107 effect_matcher_(effect_matcher),
1108 control_matcher_(control_matcher) {}
1109
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001110 void DescribeTo(std::ostream* os) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001111 NodeMatcher::DescribeTo(os);
1112 *os << " whose access (";
1113 access_matcher_.DescribeTo(os);
1114 *os << "), base (";
1115 base_matcher_.DescribeTo(os);
1116 *os << "), index (";
1117 index_matcher_.DescribeTo(os);
1118 *os << "), effect (";
1119 effect_matcher_.DescribeTo(os);
1120 *os << ") and control (";
1121 control_matcher_.DescribeTo(os);
1122 *os << ")";
1123 }
1124
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001125 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001126 return (NodeMatcher::MatchAndExplain(node, listener) &&
1127 PrintMatchAndExplain(OpParameter<ElementAccess>(node), "access",
1128 access_matcher_, listener) &&
1129 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
1130 base_matcher_, listener) &&
1131 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
1132 "index", index_matcher_, listener) &&
1133 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
1134 effect_matcher_, listener) &&
1135 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
1136 "control", control_matcher_, listener));
1137 }
1138
1139 private:
1140 const Matcher<ElementAccess> access_matcher_;
1141 const Matcher<Node*> base_matcher_;
1142 const Matcher<Node*> index_matcher_;
1143 const Matcher<Node*> effect_matcher_;
1144 const Matcher<Node*> control_matcher_;
1145};
1146
1147
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001148class IsStoreElementMatcher final : public NodeMatcher {
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001149 public:
1150 IsStoreElementMatcher(const Matcher<ElementAccess>& access_matcher,
1151 const Matcher<Node*>& base_matcher,
1152 const Matcher<Node*>& index_matcher,
1153 const Matcher<Node*>& value_matcher,
1154 const Matcher<Node*>& effect_matcher,
1155 const Matcher<Node*>& control_matcher)
1156 : NodeMatcher(IrOpcode::kStoreElement),
1157 access_matcher_(access_matcher),
1158 base_matcher_(base_matcher),
1159 index_matcher_(index_matcher),
1160 value_matcher_(value_matcher),
1161 effect_matcher_(effect_matcher),
1162 control_matcher_(control_matcher) {}
1163
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001164 void DescribeTo(std::ostream* os) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001165 NodeMatcher::DescribeTo(os);
1166 *os << " whose access (";
1167 access_matcher_.DescribeTo(os);
1168 *os << "), base (";
1169 base_matcher_.DescribeTo(os);
1170 *os << "), index (";
1171 index_matcher_.DescribeTo(os);
1172 *os << "), value (";
1173 value_matcher_.DescribeTo(os);
1174 *os << "), effect (";
1175 effect_matcher_.DescribeTo(os);
1176 *os << ") and control (";
1177 control_matcher_.DescribeTo(os);
1178 *os << ")";
1179 }
1180
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001181 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001182 return (NodeMatcher::MatchAndExplain(node, listener) &&
1183 PrintMatchAndExplain(OpParameter<ElementAccess>(node), "access",
1184 access_matcher_, listener) &&
1185 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
1186 base_matcher_, listener) &&
1187 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
1188 "index", index_matcher_, listener) &&
1189 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2),
1190 "value", value_matcher_, listener) &&
1191 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
1192 effect_matcher_, listener) &&
1193 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
1194 "control", control_matcher_, listener));
1195 }
1196
1197 private:
1198 const Matcher<ElementAccess> access_matcher_;
1199 const Matcher<Node*> base_matcher_;
1200 const Matcher<Node*> index_matcher_;
1201 const Matcher<Node*> value_matcher_;
1202 const Matcher<Node*> effect_matcher_;
1203 const Matcher<Node*> control_matcher_;
1204};
1205
1206
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001207class IsLoadMatcher final : public NodeMatcher {
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001208 public:
1209 IsLoadMatcher(const Matcher<LoadRepresentation>& rep_matcher,
1210 const Matcher<Node*>& base_matcher,
1211 const Matcher<Node*>& index_matcher,
1212 const Matcher<Node*>& effect_matcher,
1213 const Matcher<Node*>& control_matcher)
1214 : NodeMatcher(IrOpcode::kLoad),
1215 rep_matcher_(rep_matcher),
1216 base_matcher_(base_matcher),
1217 index_matcher_(index_matcher),
1218 effect_matcher_(effect_matcher),
1219 control_matcher_(control_matcher) {}
1220
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001221 void DescribeTo(std::ostream* os) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001222 NodeMatcher::DescribeTo(os);
1223 *os << " whose rep (";
1224 rep_matcher_.DescribeTo(os);
1225 *os << "), base (";
1226 base_matcher_.DescribeTo(os);
1227 *os << "), index (";
1228 index_matcher_.DescribeTo(os);
1229 *os << "), effect (";
1230 effect_matcher_.DescribeTo(os);
1231 *os << ") and control (";
1232 control_matcher_.DescribeTo(os);
1233 *os << ")";
1234 }
1235
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001236 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
1237 Node* effect_node = nullptr;
1238 Node* control_node = nullptr;
1239 if (NodeProperties::FirstEffectIndex(node) < node->InputCount()) {
1240 effect_node = NodeProperties::GetEffectInput(node);
1241 }
1242 if (NodeProperties::FirstControlIndex(node) < node->InputCount()) {
1243 control_node = NodeProperties::GetControlInput(node);
1244 }
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001245 return (NodeMatcher::MatchAndExplain(node, listener) &&
1246 PrintMatchAndExplain(OpParameter<LoadRepresentation>(node), "rep",
1247 rep_matcher_, listener) &&
1248 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
1249 base_matcher_, listener) &&
1250 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
1251 "index", index_matcher_, listener) &&
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001252 PrintMatchAndExplain(effect_node, "effect", effect_matcher_,
1253 listener) &&
1254 PrintMatchAndExplain(control_node, "control", control_matcher_,
1255 listener));
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001256 }
1257
1258 private:
1259 const Matcher<LoadRepresentation> rep_matcher_;
1260 const Matcher<Node*> base_matcher_;
1261 const Matcher<Node*> index_matcher_;
1262 const Matcher<Node*> effect_matcher_;
1263 const Matcher<Node*> control_matcher_;
1264};
1265
1266
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001267class IsStoreMatcher final : public NodeMatcher {
1268 public:
1269 IsStoreMatcher(const Matcher<StoreRepresentation>& rep_matcher,
1270 const Matcher<Node*>& base_matcher,
1271 const Matcher<Node*>& index_matcher,
1272 const Matcher<Node*>& value_matcher,
1273 const Matcher<Node*>& effect_matcher,
1274 const Matcher<Node*>& control_matcher)
1275 : NodeMatcher(IrOpcode::kStore),
1276 rep_matcher_(rep_matcher),
1277 base_matcher_(base_matcher),
1278 index_matcher_(index_matcher),
1279 value_matcher_(value_matcher),
1280 effect_matcher_(effect_matcher),
1281 control_matcher_(control_matcher) {}
1282
1283 void DescribeTo(std::ostream* os) const final {
1284 NodeMatcher::DescribeTo(os);
1285 *os << " whose rep (";
1286 rep_matcher_.DescribeTo(os);
1287 *os << "), base (";
1288 base_matcher_.DescribeTo(os);
1289 *os << "), index (";
1290 index_matcher_.DescribeTo(os);
1291 *os << "), value (";
1292 value_matcher_.DescribeTo(os);
1293 *os << "), effect (";
1294 effect_matcher_.DescribeTo(os);
1295 *os << ") and control (";
1296 control_matcher_.DescribeTo(os);
1297 *os << ")";
1298 }
1299
1300 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
1301 Node* effect_node = nullptr;
1302 Node* control_node = nullptr;
1303 if (NodeProperties::FirstEffectIndex(node) < node->InputCount()) {
1304 effect_node = NodeProperties::GetEffectInput(node);
1305 }
1306 if (NodeProperties::FirstControlIndex(node) < node->InputCount()) {
1307 control_node = NodeProperties::GetControlInput(node);
1308 }
1309 return (NodeMatcher::MatchAndExplain(node, listener) &&
1310 PrintMatchAndExplain(OpParameter<StoreRepresentation>(node), "rep",
1311 rep_matcher_, listener) &&
1312 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
1313 base_matcher_, listener) &&
1314 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
1315 "index", index_matcher_, listener) &&
1316 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2),
1317 "value", value_matcher_, listener) &&
1318 PrintMatchAndExplain(effect_node, "effect", effect_matcher_,
1319 listener) &&
1320 PrintMatchAndExplain(control_node, "control", control_matcher_,
1321 listener));
1322 }
1323
1324 private:
1325 const Matcher<StoreRepresentation> rep_matcher_;
1326 const Matcher<Node*> base_matcher_;
1327 const Matcher<Node*> index_matcher_;
1328 const Matcher<Node*> value_matcher_;
1329 const Matcher<Node*> effect_matcher_;
1330 const Matcher<Node*> control_matcher_;
1331};
1332
1333
1334class IsToNumberMatcher final : public NodeMatcher {
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001335 public:
1336 IsToNumberMatcher(const Matcher<Node*>& base_matcher,
1337 const Matcher<Node*>& context_matcher,
1338 const Matcher<Node*>& effect_matcher,
1339 const Matcher<Node*>& control_matcher)
1340 : NodeMatcher(IrOpcode::kJSToNumber),
1341 base_matcher_(base_matcher),
1342 context_matcher_(context_matcher),
1343 effect_matcher_(effect_matcher),
1344 control_matcher_(control_matcher) {}
1345
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001346 void DescribeTo(std::ostream* os) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001347 NodeMatcher::DescribeTo(os);
1348 *os << " whose base (";
1349 base_matcher_.DescribeTo(os);
1350 *os << "), context (";
1351 context_matcher_.DescribeTo(os);
1352 *os << "), effect (";
1353 effect_matcher_.DescribeTo(os);
1354 *os << ") and control (";
1355 control_matcher_.DescribeTo(os);
1356 *os << ")";
1357 }
1358
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001359 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001360 return (NodeMatcher::MatchAndExplain(node, listener) &&
1361 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base",
1362 base_matcher_, listener) &&
1363 PrintMatchAndExplain(NodeProperties::GetContextInput(node),
1364 "context", context_matcher_, listener) &&
1365 PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
1366 effect_matcher_, listener) &&
1367 PrintMatchAndExplain(NodeProperties::GetControlInput(node),
1368 "control", control_matcher_, listener));
1369 }
1370
1371 private:
1372 const Matcher<Node*> base_matcher_;
1373 const Matcher<Node*> context_matcher_;
1374 const Matcher<Node*> effect_matcher_;
1375 const Matcher<Node*> control_matcher_;
1376};
1377
1378
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001379class IsLoadContextMatcher final : public NodeMatcher {
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001380 public:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001381 IsLoadContextMatcher(const Matcher<ContextAccess>& access_matcher,
1382 const Matcher<Node*>& context_matcher)
1383 : NodeMatcher(IrOpcode::kJSLoadContext),
1384 access_matcher_(access_matcher),
1385 context_matcher_(context_matcher) {}
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001386
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001387 void DescribeTo(std::ostream* os) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001388 NodeMatcher::DescribeTo(os);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001389 *os << " whose access (";
1390 access_matcher_.DescribeTo(os);
1391 *os << ") and context (";
1392 context_matcher_.DescribeTo(os);
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001393 *os << ")";
1394 }
1395
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001396 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001397 return (NodeMatcher::MatchAndExplain(node, listener) &&
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001398 PrintMatchAndExplain(OpParameter<ContextAccess>(node), "access",
1399 access_matcher_, listener) &&
1400 PrintMatchAndExplain(NodeProperties::GetContextInput(node),
1401 "context", context_matcher_, listener));
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001402 }
1403
1404 private:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001405 const Matcher<ContextAccess> access_matcher_;
1406 const Matcher<Node*> context_matcher_;
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001407};
1408
1409
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001410class IsBinopMatcher final : public NodeMatcher {
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001411 public:
1412 IsBinopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& lhs_matcher,
1413 const Matcher<Node*>& rhs_matcher)
1414 : NodeMatcher(opcode),
1415 lhs_matcher_(lhs_matcher),
1416 rhs_matcher_(rhs_matcher) {}
1417
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001418 void DescribeTo(std::ostream* os) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001419 NodeMatcher::DescribeTo(os);
1420 *os << " whose lhs (";
1421 lhs_matcher_.DescribeTo(os);
1422 *os << ") and rhs (";
1423 rhs_matcher_.DescribeTo(os);
1424 *os << ")";
1425 }
1426
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001427 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001428 return (NodeMatcher::MatchAndExplain(node, listener) &&
1429 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "lhs",
1430 lhs_matcher_, listener) &&
1431 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "rhs",
1432 rhs_matcher_, listener));
1433 }
1434
1435 private:
1436 const Matcher<Node*> lhs_matcher_;
1437 const Matcher<Node*> rhs_matcher_;
1438};
1439
1440
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001441class IsUnopMatcher final : public NodeMatcher {
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001442 public:
1443 IsUnopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& input_matcher)
1444 : NodeMatcher(opcode), input_matcher_(input_matcher) {}
1445
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001446 void DescribeTo(std::ostream* os) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001447 NodeMatcher::DescribeTo(os);
1448 *os << " whose input (";
1449 input_matcher_.DescribeTo(os);
1450 *os << ")";
1451 }
1452
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001453 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001454 return (NodeMatcher::MatchAndExplain(node, listener) &&
1455 PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
1456 "input", input_matcher_, listener));
1457 }
1458
1459 private:
1460 const Matcher<Node*> input_matcher_;
1461};
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001462
1463
1464class IsParameterMatcher final : public NodeMatcher {
1465 public:
1466 explicit IsParameterMatcher(const Matcher<int>& index_matcher)
1467 : NodeMatcher(IrOpcode::kParameter), index_matcher_(index_matcher) {}
1468
1469 void DescribeTo(std::ostream* os) const override {
1470 *os << "is a Parameter node with index(";
1471 index_matcher_.DescribeTo(os);
1472 *os << ")";
1473 }
1474
1475 bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
1476 return (NodeMatcher::MatchAndExplain(node, listener) &&
1477 PrintMatchAndExplain(ParameterIndexOf(node->op()), "index",
1478 index_matcher_, listener));
1479 }
1480
1481 private:
1482 const Matcher<int> index_matcher_;
1483};
1484
1485} // namespace
1486
1487
1488Matcher<Node*> IsDead() {
1489 return MakeMatcher(new NodeMatcher(IrOpcode::kDead));
1490}
1491
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001492Matcher<Node*> IsEnd(const Matcher<Node*>& control0_matcher) {
1493 return MakeMatcher(new IsControl1Matcher(IrOpcode::kEnd, control0_matcher));
1494}
1495
1496
1497Matcher<Node*> IsEnd(const Matcher<Node*>& control0_matcher,
1498 const Matcher<Node*>& control1_matcher) {
1499 return MakeMatcher(new IsControl2Matcher(IrOpcode::kEnd, control0_matcher,
1500 control1_matcher));
1501}
1502
1503
1504Matcher<Node*> IsEnd(const Matcher<Node*>& control0_matcher,
1505 const Matcher<Node*>& control1_matcher,
1506 const Matcher<Node*>& control2_matcher) {
1507 return MakeMatcher(new IsControl3Matcher(IrOpcode::kEnd, control0_matcher,
1508 control1_matcher, control2_matcher));
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001509}
1510
1511
1512Matcher<Node*> IsBranch(const Matcher<Node*>& value_matcher,
1513 const Matcher<Node*>& control_matcher) {
1514 return MakeMatcher(new IsBranchMatcher(value_matcher, control_matcher));
1515}
1516
1517
1518Matcher<Node*> IsMerge(const Matcher<Node*>& control0_matcher,
1519 const Matcher<Node*>& control1_matcher) {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001520 return MakeMatcher(new IsControl2Matcher(IrOpcode::kMerge, control0_matcher,
1521 control1_matcher));
1522}
1523
1524
1525Matcher<Node*> IsMerge(const Matcher<Node*>& control0_matcher,
1526 const Matcher<Node*>& control1_matcher,
1527 const Matcher<Node*>& control2_matcher) {
1528 return MakeMatcher(new IsControl3Matcher(IrOpcode::kMerge, control0_matcher,
1529 control1_matcher, control2_matcher));
1530}
1531
1532
1533Matcher<Node*> IsLoop(const Matcher<Node*>& control0_matcher,
1534 const Matcher<Node*>& control1_matcher) {
1535 return MakeMatcher(new IsControl2Matcher(IrOpcode::kLoop, control0_matcher,
1536 control1_matcher));
1537}
1538
1539
1540Matcher<Node*> IsLoop(const Matcher<Node*>& control0_matcher,
1541 const Matcher<Node*>& control1_matcher,
1542 const Matcher<Node*>& control2_matcher) {
1543 return MakeMatcher(new IsControl3Matcher(IrOpcode::kLoop, control0_matcher,
1544 control1_matcher, control2_matcher));
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001545}
1546
1547
1548Matcher<Node*> IsIfTrue(const Matcher<Node*>& control_matcher) {
1549 return MakeMatcher(new IsControl1Matcher(IrOpcode::kIfTrue, control_matcher));
1550}
1551
1552
1553Matcher<Node*> IsIfFalse(const Matcher<Node*>& control_matcher) {
1554 return MakeMatcher(
1555 new IsControl1Matcher(IrOpcode::kIfFalse, control_matcher));
1556}
1557
1558
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001559Matcher<Node*> IsIfSuccess(const Matcher<Node*>& control_matcher) {
1560 return MakeMatcher(
1561 new IsControl1Matcher(IrOpcode::kIfSuccess, control_matcher));
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001562}
1563
1564
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001565Matcher<Node*> IsSwitch(const Matcher<Node*>& value_matcher,
1566 const Matcher<Node*>& control_matcher) {
1567 return MakeMatcher(new IsSwitchMatcher(value_matcher, control_matcher));
1568}
1569
1570
1571Matcher<Node*> IsIfValue(const Matcher<int32_t>& value_matcher,
1572 const Matcher<Node*>& control_matcher) {
1573 return MakeMatcher(new IsIfValueMatcher(value_matcher, control_matcher));
1574}
1575
1576
1577Matcher<Node*> IsIfDefault(const Matcher<Node*>& control_matcher) {
1578 return MakeMatcher(
1579 new IsControl1Matcher(IrOpcode::kIfDefault, control_matcher));
1580}
1581
1582
1583Matcher<Node*> IsBeginRegion(const Matcher<Node*>& effect_matcher) {
1584 return MakeMatcher(new IsBeginRegionMatcher(effect_matcher));
1585}
1586
1587
1588Matcher<Node*> IsFinishRegion(const Matcher<Node*>& value_matcher,
1589 const Matcher<Node*>& effect_matcher) {
1590 return MakeMatcher(new IsFinishRegionMatcher(value_matcher, effect_matcher));
1591}
1592
1593
1594Matcher<Node*> IsReturn(const Matcher<Node*>& value_matcher,
1595 const Matcher<Node*>& effect_matcher,
1596 const Matcher<Node*>& control_matcher) {
1597 return MakeMatcher(
1598 new IsReturnMatcher(value_matcher, effect_matcher, control_matcher));
1599}
1600
Ben Murdoch097c5b22016-05-18 11:27:45 +01001601Matcher<Node*> IsReturn2(const Matcher<Node*>& value_matcher,
1602 const Matcher<Node*>& value2_matcher,
1603 const Matcher<Node*>& effect_matcher,
1604 const Matcher<Node*>& control_matcher) {
1605 return MakeMatcher(new IsReturnMatcher(value_matcher, value2_matcher,
1606 effect_matcher, control_matcher));
1607}
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001608
1609Matcher<Node*> IsTerminate(const Matcher<Node*>& effect_matcher,
1610 const Matcher<Node*>& control_matcher) {
1611 return MakeMatcher(new IsTerminateMatcher(effect_matcher, control_matcher));
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001612}
1613
1614
1615Matcher<Node*> IsExternalConstant(
1616 const Matcher<ExternalReference>& value_matcher) {
1617 return MakeMatcher(new IsConstantMatcher<ExternalReference>(
1618 IrOpcode::kExternalConstant, value_matcher));
1619}
1620
1621
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001622Matcher<Node*> IsHeapConstant(Handle<HeapObject> value) {
1623 return MakeMatcher(new IsConstantMatcher<Handle<HeapObject>>(
1624 IrOpcode::kHeapConstant, value));
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001625}
1626
1627
1628Matcher<Node*> IsInt32Constant(const Matcher<int32_t>& value_matcher) {
1629 return MakeMatcher(
1630 new IsConstantMatcher<int32_t>(IrOpcode::kInt32Constant, value_matcher));
1631}
1632
1633
1634Matcher<Node*> IsInt64Constant(const Matcher<int64_t>& value_matcher) {
1635 return MakeMatcher(
1636 new IsConstantMatcher<int64_t>(IrOpcode::kInt64Constant, value_matcher));
1637}
1638
1639
1640Matcher<Node*> IsFloat32Constant(const Matcher<float>& value_matcher) {
1641 return MakeMatcher(
1642 new IsConstantMatcher<float>(IrOpcode::kFloat32Constant, value_matcher));
1643}
1644
1645
1646Matcher<Node*> IsFloat64Constant(const Matcher<double>& value_matcher) {
1647 return MakeMatcher(
1648 new IsConstantMatcher<double>(IrOpcode::kFloat64Constant, value_matcher));
1649}
1650
1651
1652Matcher<Node*> IsNumberConstant(const Matcher<double>& value_matcher) {
1653 return MakeMatcher(
1654 new IsConstantMatcher<double>(IrOpcode::kNumberConstant, value_matcher));
1655}
1656
1657
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001658Matcher<Node*> IsSelect(const Matcher<MachineRepresentation>& type_matcher,
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001659 const Matcher<Node*>& value0_matcher,
1660 const Matcher<Node*>& value1_matcher,
1661 const Matcher<Node*>& value2_matcher) {
1662 return MakeMatcher(new IsSelectMatcher(type_matcher, value0_matcher,
1663 value1_matcher, value2_matcher));
1664}
1665
1666
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001667Matcher<Node*> IsPhi(const Matcher<MachineRepresentation>& type_matcher,
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001668 const Matcher<Node*>& value0_matcher,
1669 const Matcher<Node*>& value1_matcher,
1670 const Matcher<Node*>& merge_matcher) {
1671 return MakeMatcher(new IsPhiMatcher(type_matcher, value0_matcher,
1672 value1_matcher, merge_matcher));
1673}
1674
1675
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001676Matcher<Node*> IsPhi(const Matcher<MachineRepresentation>& type_matcher,
1677 const Matcher<Node*>& value0_matcher,
1678 const Matcher<Node*>& value1_matcher,
1679 const Matcher<Node*>& value2_matcher,
1680 const Matcher<Node*>& merge_matcher) {
1681 return MakeMatcher(new IsPhi2Matcher(type_matcher, value0_matcher,
1682 value1_matcher, value2_matcher,
1683 merge_matcher));
1684}
1685
1686
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001687Matcher<Node*> IsEffectPhi(const Matcher<Node*>& effect0_matcher,
1688 const Matcher<Node*>& effect1_matcher,
1689 const Matcher<Node*>& merge_matcher) {
1690 return MakeMatcher(
1691 new IsEffectPhiMatcher(effect0_matcher, effect1_matcher, merge_matcher));
1692}
1693
1694
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001695Matcher<Node*> IsEffectSet(const Matcher<Node*>& effect0_matcher,
1696 const Matcher<Node*>& effect1_matcher) {
1697 return MakeMatcher(new IsEffectSetMatcher(effect0_matcher, effect1_matcher));
1698}
1699
1700
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001701Matcher<Node*> IsProjection(const Matcher<size_t>& index_matcher,
1702 const Matcher<Node*>& base_matcher) {
1703 return MakeMatcher(new IsProjectionMatcher(index_matcher, base_matcher));
1704}
1705
Ben Murdoch097c5b22016-05-18 11:27:45 +01001706Matcher<Node*> IsCall(const Matcher<const CallDescriptor*>& descriptor_matcher,
1707 const Matcher<Node*>& value0_matcher,
1708 const Matcher<Node*>& effect_matcher,
1709 const Matcher<Node*>& control_matcher) {
1710 std::vector<Matcher<Node*>> value_matchers;
1711 value_matchers.push_back(value0_matcher);
1712 return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers,
1713 effect_matcher, control_matcher));
1714}
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001715
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001716Matcher<Node*> IsCall(const Matcher<const CallDescriptor*>& descriptor_matcher,
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001717 const Matcher<Node*>& value0_matcher,
1718 const Matcher<Node*>& value1_matcher,
1719 const Matcher<Node*>& effect_matcher,
1720 const Matcher<Node*>& control_matcher) {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001721 std::vector<Matcher<Node*>> value_matchers;
1722 value_matchers.push_back(value0_matcher);
1723 value_matchers.push_back(value1_matcher);
1724 return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers,
1725 effect_matcher, control_matcher));
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001726}
1727
1728
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001729Matcher<Node*> IsCall(const Matcher<const CallDescriptor*>& descriptor_matcher,
1730 const Matcher<Node*>& value0_matcher,
1731 const Matcher<Node*>& value1_matcher,
1732 const Matcher<Node*>& value2_matcher,
1733 const Matcher<Node*>& effect_matcher,
1734 const Matcher<Node*>& control_matcher) {
1735 std::vector<Matcher<Node*>> value_matchers;
1736 value_matchers.push_back(value0_matcher);
1737 value_matchers.push_back(value1_matcher);
1738 value_matchers.push_back(value2_matcher);
1739 return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers,
1740 effect_matcher, control_matcher));
1741}
1742
1743
1744Matcher<Node*> IsCall(const Matcher<const CallDescriptor*>& descriptor_matcher,
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001745 const Matcher<Node*>& value0_matcher,
1746 const Matcher<Node*>& value1_matcher,
1747 const Matcher<Node*>& value2_matcher,
1748 const Matcher<Node*>& value3_matcher,
1749 const Matcher<Node*>& effect_matcher,
1750 const Matcher<Node*>& control_matcher) {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001751 std::vector<Matcher<Node*>> value_matchers;
1752 value_matchers.push_back(value0_matcher);
1753 value_matchers.push_back(value1_matcher);
1754 value_matchers.push_back(value2_matcher);
1755 value_matchers.push_back(value3_matcher);
1756 return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers,
1757 effect_matcher, control_matcher));
1758}
1759
1760
1761Matcher<Node*> IsCall(const Matcher<const CallDescriptor*>& descriptor_matcher,
1762 const Matcher<Node*>& value0_matcher,
1763 const Matcher<Node*>& value1_matcher,
1764 const Matcher<Node*>& value2_matcher,
1765 const Matcher<Node*>& value3_matcher,
1766 const Matcher<Node*>& value4_matcher,
1767 const Matcher<Node*>& effect_matcher,
1768 const Matcher<Node*>& control_matcher) {
1769 std::vector<Matcher<Node*>> value_matchers;
1770 value_matchers.push_back(value0_matcher);
1771 value_matchers.push_back(value1_matcher);
1772 value_matchers.push_back(value2_matcher);
1773 value_matchers.push_back(value3_matcher);
1774 value_matchers.push_back(value4_matcher);
1775 return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers,
1776 effect_matcher, control_matcher));
1777}
1778
1779
1780Matcher<Node*> IsCall(const Matcher<const CallDescriptor*>& descriptor_matcher,
1781 const Matcher<Node*>& value0_matcher,
1782 const Matcher<Node*>& value1_matcher,
1783 const Matcher<Node*>& value2_matcher,
1784 const Matcher<Node*>& value3_matcher,
1785 const Matcher<Node*>& value4_matcher,
1786 const Matcher<Node*>& value5_matcher,
1787 const Matcher<Node*>& effect_matcher,
1788 const Matcher<Node*>& control_matcher) {
1789 std::vector<Matcher<Node*>> value_matchers;
1790 value_matchers.push_back(value0_matcher);
1791 value_matchers.push_back(value1_matcher);
1792 value_matchers.push_back(value2_matcher);
1793 value_matchers.push_back(value3_matcher);
1794 value_matchers.push_back(value4_matcher);
1795 value_matchers.push_back(value5_matcher);
1796 return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers,
1797 effect_matcher, control_matcher));
1798}
1799
1800
1801Matcher<Node*> IsCall(
1802 const Matcher<const CallDescriptor*>& descriptor_matcher,
1803 const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher,
1804 const Matcher<Node*>& value2_matcher, const Matcher<Node*>& value3_matcher,
1805 const Matcher<Node*>& value4_matcher, const Matcher<Node*>& value5_matcher,
1806 const Matcher<Node*>& value6_matcher, const Matcher<Node*>& effect_matcher,
1807 const Matcher<Node*>& control_matcher) {
1808 std::vector<Matcher<Node*>> value_matchers;
1809 value_matchers.push_back(value0_matcher);
1810 value_matchers.push_back(value1_matcher);
1811 value_matchers.push_back(value2_matcher);
1812 value_matchers.push_back(value3_matcher);
1813 value_matchers.push_back(value4_matcher);
1814 value_matchers.push_back(value5_matcher);
1815 value_matchers.push_back(value6_matcher);
1816 return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers,
1817 effect_matcher, control_matcher));
1818}
1819
1820
1821Matcher<Node*> IsTailCall(
1822 const Matcher<CallDescriptor const*>& descriptor_matcher,
1823 const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher,
1824 const Matcher<Node*>& effect_matcher,
1825 const Matcher<Node*>& control_matcher) {
1826 std::vector<Matcher<Node*>> value_matchers;
1827 value_matchers.push_back(value0_matcher);
1828 value_matchers.push_back(value1_matcher);
1829 return MakeMatcher(new IsTailCallMatcher(descriptor_matcher, value_matchers,
1830 effect_matcher, control_matcher));
1831}
1832
1833
1834Matcher<Node*> IsTailCall(
1835 const Matcher<CallDescriptor const*>& descriptor_matcher,
1836 const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher,
1837 const Matcher<Node*>& value2_matcher, const Matcher<Node*>& effect_matcher,
1838 const Matcher<Node*>& control_matcher) {
1839 std::vector<Matcher<Node*>> value_matchers;
1840 value_matchers.push_back(value0_matcher);
1841 value_matchers.push_back(value1_matcher);
1842 value_matchers.push_back(value2_matcher);
1843 return MakeMatcher(new IsTailCallMatcher(descriptor_matcher, value_matchers,
1844 effect_matcher, control_matcher));
1845}
1846
1847
1848Matcher<Node*> IsTailCall(
1849 const Matcher<CallDescriptor const*>& descriptor_matcher,
1850 const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher,
1851 const Matcher<Node*>& value2_matcher, const Matcher<Node*>& value3_matcher,
1852 const Matcher<Node*>& effect_matcher,
1853 const Matcher<Node*>& control_matcher) {
1854 std::vector<Matcher<Node*>> value_matchers;
1855 value_matchers.push_back(value0_matcher);
1856 value_matchers.push_back(value1_matcher);
1857 value_matchers.push_back(value2_matcher);
1858 value_matchers.push_back(value3_matcher);
1859 return MakeMatcher(new IsTailCallMatcher(descriptor_matcher, value_matchers,
1860 effect_matcher, control_matcher));
1861}
1862
1863
1864Matcher<Node*> IsTailCall(
1865 const Matcher<CallDescriptor const*>& descriptor_matcher,
1866 const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher,
1867 const Matcher<Node*>& value2_matcher, const Matcher<Node*>& value3_matcher,
1868 const Matcher<Node*>& value4_matcher, const Matcher<Node*>& effect_matcher,
1869 const Matcher<Node*>& control_matcher) {
1870 std::vector<Matcher<Node*>> value_matchers;
1871 value_matchers.push_back(value0_matcher);
1872 value_matchers.push_back(value1_matcher);
1873 value_matchers.push_back(value2_matcher);
1874 value_matchers.push_back(value3_matcher);
1875 value_matchers.push_back(value4_matcher);
1876 return MakeMatcher(new IsTailCallMatcher(descriptor_matcher, value_matchers,
1877 effect_matcher, control_matcher));
1878}
1879
1880
1881Matcher<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*>& effect_matcher,
1887 const Matcher<Node*>& control_matcher) {
1888 std::vector<Matcher<Node*>> value_matchers;
1889 value_matchers.push_back(value0_matcher);
1890 value_matchers.push_back(value1_matcher);
1891 value_matchers.push_back(value2_matcher);
1892 value_matchers.push_back(value3_matcher);
1893 value_matchers.push_back(value4_matcher);
1894 value_matchers.push_back(value5_matcher);
1895 return MakeMatcher(new IsTailCallMatcher(descriptor_matcher, value_matchers,
1896 effect_matcher, control_matcher));
1897}
1898
1899
1900Matcher<Node*> IsTailCall(
1901 const Matcher<CallDescriptor const*>& descriptor_matcher,
1902 const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher,
1903 const Matcher<Node*>& value2_matcher, const Matcher<Node*>& value3_matcher,
1904 const Matcher<Node*>& value4_matcher, const Matcher<Node*>& value5_matcher,
1905 const Matcher<Node*>& value6_matcher, const Matcher<Node*>& effect_matcher,
1906 const Matcher<Node*>& control_matcher) {
1907 std::vector<Matcher<Node*>> value_matchers;
1908 value_matchers.push_back(value0_matcher);
1909 value_matchers.push_back(value1_matcher);
1910 value_matchers.push_back(value2_matcher);
1911 value_matchers.push_back(value3_matcher);
1912 value_matchers.push_back(value4_matcher);
1913 value_matchers.push_back(value5_matcher);
1914 value_matchers.push_back(value6_matcher);
1915 return MakeMatcher(new IsTailCallMatcher(descriptor_matcher, value_matchers,
1916 effect_matcher, control_matcher));
1917}
1918
1919
1920Matcher<Node*> IsTailCall(
1921 const Matcher<CallDescriptor const*>& descriptor_matcher,
1922 const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher,
1923 const Matcher<Node*>& value2_matcher, const Matcher<Node*>& value3_matcher,
1924 const Matcher<Node*>& value4_matcher, const Matcher<Node*>& value5_matcher,
1925 const Matcher<Node*>& value6_matcher, const Matcher<Node*>& value7_matcher,
1926 const Matcher<Node*>& effect_matcher,
1927 const Matcher<Node*>& control_matcher) {
1928 std::vector<Matcher<Node*>> value_matchers;
1929 value_matchers.push_back(value0_matcher);
1930 value_matchers.push_back(value1_matcher);
1931 value_matchers.push_back(value2_matcher);
1932 value_matchers.push_back(value3_matcher);
1933 value_matchers.push_back(value4_matcher);
1934 value_matchers.push_back(value5_matcher);
1935 value_matchers.push_back(value6_matcher);
1936 value_matchers.push_back(value7_matcher);
1937 return MakeMatcher(new IsTailCallMatcher(descriptor_matcher, value_matchers,
1938 effect_matcher, control_matcher));
1939}
1940
1941
1942Matcher<Node*> IsReferenceEqual(const Matcher<Type*>& type_matcher,
1943 const Matcher<Node*>& lhs_matcher,
1944 const Matcher<Node*>& rhs_matcher) {
1945 return MakeMatcher(
1946 new IsReferenceEqualMatcher(type_matcher, lhs_matcher, rhs_matcher));
1947}
1948
1949
1950Matcher<Node*> IsAllocate(const Matcher<Node*>& size_matcher,
1951 const Matcher<Node*>& effect_matcher,
1952 const Matcher<Node*>& control_matcher) {
1953 return MakeMatcher(
1954 new IsAllocateMatcher(size_matcher, effect_matcher, control_matcher));
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001955}
1956
1957
1958Matcher<Node*> IsLoadField(const Matcher<FieldAccess>& access_matcher,
1959 const Matcher<Node*>& base_matcher,
1960 const Matcher<Node*>& effect_matcher,
1961 const Matcher<Node*>& control_matcher) {
1962 return MakeMatcher(new IsLoadFieldMatcher(access_matcher, base_matcher,
1963 effect_matcher, control_matcher));
1964}
1965
1966
1967Matcher<Node*> IsStoreField(const Matcher<FieldAccess>& access_matcher,
1968 const Matcher<Node*>& base_matcher,
1969 const Matcher<Node*>& value_matcher,
1970 const Matcher<Node*>& effect_matcher,
1971 const Matcher<Node*>& control_matcher) {
1972 return MakeMatcher(new IsStoreFieldMatcher(access_matcher, base_matcher,
1973 value_matcher, effect_matcher,
1974 control_matcher));
1975}
1976
1977
1978Matcher<Node*> IsLoadBuffer(const Matcher<BufferAccess>& access_matcher,
1979 const Matcher<Node*>& buffer_matcher,
1980 const Matcher<Node*>& offset_matcher,
1981 const Matcher<Node*>& length_matcher,
1982 const Matcher<Node*>& effect_matcher,
1983 const Matcher<Node*>& control_matcher) {
1984 return MakeMatcher(new IsLoadBufferMatcher(access_matcher, buffer_matcher,
1985 offset_matcher, length_matcher,
1986 effect_matcher, control_matcher));
1987}
1988
1989
1990Matcher<Node*> IsStoreBuffer(const Matcher<BufferAccess>& access_matcher,
1991 const Matcher<Node*>& buffer_matcher,
1992 const Matcher<Node*>& offset_matcher,
1993 const Matcher<Node*>& length_matcher,
1994 const Matcher<Node*>& value_matcher,
1995 const Matcher<Node*>& effect_matcher,
1996 const Matcher<Node*>& control_matcher) {
1997 return MakeMatcher(new IsStoreBufferMatcher(
1998 access_matcher, buffer_matcher, offset_matcher, length_matcher,
1999 value_matcher, effect_matcher, control_matcher));
2000}
2001
2002
2003Matcher<Node*> IsLoadElement(const Matcher<ElementAccess>& access_matcher,
2004 const Matcher<Node*>& base_matcher,
2005 const Matcher<Node*>& index_matcher,
2006 const Matcher<Node*>& effect_matcher,
2007 const Matcher<Node*>& control_matcher) {
2008 return MakeMatcher(new IsLoadElementMatcher(access_matcher, base_matcher,
2009 index_matcher, effect_matcher,
2010 control_matcher));
2011}
2012
2013
2014Matcher<Node*> IsStoreElement(const Matcher<ElementAccess>& access_matcher,
2015 const Matcher<Node*>& base_matcher,
2016 const Matcher<Node*>& index_matcher,
2017 const Matcher<Node*>& value_matcher,
2018 const Matcher<Node*>& effect_matcher,
2019 const Matcher<Node*>& control_matcher) {
2020 return MakeMatcher(new IsStoreElementMatcher(
2021 access_matcher, base_matcher, index_matcher, value_matcher,
2022 effect_matcher, control_matcher));
2023}
2024
2025
2026Matcher<Node*> IsLoad(const Matcher<LoadRepresentation>& rep_matcher,
2027 const Matcher<Node*>& base_matcher,
2028 const Matcher<Node*>& index_matcher,
2029 const Matcher<Node*>& effect_matcher,
2030 const Matcher<Node*>& control_matcher) {
2031 return MakeMatcher(new IsLoadMatcher(rep_matcher, base_matcher, index_matcher,
2032 effect_matcher, control_matcher));
2033}
2034
2035
Emily Bernierd0a1eb72015-03-24 16:35:39 -04002036Matcher<Node*> IsStore(const Matcher<StoreRepresentation>& rep_matcher,
2037 const Matcher<Node*>& base_matcher,
2038 const Matcher<Node*>& index_matcher,
2039 const Matcher<Node*>& value_matcher,
2040 const Matcher<Node*>& effect_matcher,
2041 const Matcher<Node*>& control_matcher) {
2042 return MakeMatcher(new IsStoreMatcher(rep_matcher, base_matcher,
2043 index_matcher, value_matcher,
2044 effect_matcher, control_matcher));
2045}
2046
2047
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00002048Matcher<Node*> IsToNumber(const Matcher<Node*>& base_matcher,
2049 const Matcher<Node*>& context_matcher,
2050 const Matcher<Node*>& effect_matcher,
2051 const Matcher<Node*>& control_matcher) {
2052 return MakeMatcher(new IsToNumberMatcher(base_matcher, context_matcher,
2053 effect_matcher, control_matcher));
2054}
2055
2056
2057Matcher<Node*> IsLoadContext(const Matcher<ContextAccess>& access_matcher,
2058 const Matcher<Node*>& context_matcher) {
2059 return MakeMatcher(new IsLoadContextMatcher(access_matcher, context_matcher));
2060}
2061
2062
2063Matcher<Node*> IsParameter(const Matcher<int> index_matcher) {
2064 return MakeMatcher(new IsParameterMatcher(index_matcher));
2065}
2066
2067
2068Matcher<Node*> IsLoadFramePointer() {
2069 return MakeMatcher(new NodeMatcher(IrOpcode::kLoadFramePointer));
2070}
2071
2072
Emily Bernierd0a1eb72015-03-24 16:35:39 -04002073#define IS_BINOP_MATCHER(Name) \
2074 Matcher<Node*> Is##Name(const Matcher<Node*>& lhs_matcher, \
2075 const Matcher<Node*>& rhs_matcher) { \
2076 return MakeMatcher( \
2077 new IsBinopMatcher(IrOpcode::k##Name, lhs_matcher, rhs_matcher)); \
2078 }
2079IS_BINOP_MATCHER(NumberEqual)
2080IS_BINOP_MATCHER(NumberLessThan)
2081IS_BINOP_MATCHER(NumberSubtract)
2082IS_BINOP_MATCHER(NumberMultiply)
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00002083IS_BINOP_MATCHER(NumberShiftLeft)
2084IS_BINOP_MATCHER(NumberShiftRight)
2085IS_BINOP_MATCHER(NumberShiftRightLogical)
Emily Bernierd0a1eb72015-03-24 16:35:39 -04002086IS_BINOP_MATCHER(Word32And)
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00002087IS_BINOP_MATCHER(Word32Or)
Emily Bernierd0a1eb72015-03-24 16:35:39 -04002088IS_BINOP_MATCHER(Word32Sar)
2089IS_BINOP_MATCHER(Word32Shl)
2090IS_BINOP_MATCHER(Word32Shr)
2091IS_BINOP_MATCHER(Word32Ror)
2092IS_BINOP_MATCHER(Word32Equal)
2093IS_BINOP_MATCHER(Word64And)
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00002094IS_BINOP_MATCHER(Word64Or)
Emily Bernierd0a1eb72015-03-24 16:35:39 -04002095IS_BINOP_MATCHER(Word64Sar)
2096IS_BINOP_MATCHER(Word64Shl)
2097IS_BINOP_MATCHER(Word64Equal)
2098IS_BINOP_MATCHER(Int32AddWithOverflow)
2099IS_BINOP_MATCHER(Int32Add)
2100IS_BINOP_MATCHER(Int32Sub)
2101IS_BINOP_MATCHER(Int32Mul)
2102IS_BINOP_MATCHER(Int32MulHigh)
2103IS_BINOP_MATCHER(Int32LessThan)
2104IS_BINOP_MATCHER(Uint32LessThan)
2105IS_BINOP_MATCHER(Uint32LessThanOrEqual)
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00002106IS_BINOP_MATCHER(Int64Add)
2107IS_BINOP_MATCHER(Int64Sub)
2108IS_BINOP_MATCHER(JSAdd)
2109IS_BINOP_MATCHER(Float32Max)
2110IS_BINOP_MATCHER(Float32Min)
2111IS_BINOP_MATCHER(Float32Equal)
2112IS_BINOP_MATCHER(Float32LessThan)
2113IS_BINOP_MATCHER(Float32LessThanOrEqual)
2114IS_BINOP_MATCHER(Float64Max)
2115IS_BINOP_MATCHER(Float64Min)
Emily Bernierd0a1eb72015-03-24 16:35:39 -04002116IS_BINOP_MATCHER(Float64Sub)
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00002117IS_BINOP_MATCHER(Float64InsertLowWord32)
2118IS_BINOP_MATCHER(Float64InsertHighWord32)
Emily Bernierd0a1eb72015-03-24 16:35:39 -04002119#undef IS_BINOP_MATCHER
2120
2121
2122#define IS_UNOP_MATCHER(Name) \
2123 Matcher<Node*> Is##Name(const Matcher<Node*>& input_matcher) { \
2124 return MakeMatcher(new IsUnopMatcher(IrOpcode::k##Name, input_matcher)); \
2125 }
Emily Bernierd0a1eb72015-03-24 16:35:39 -04002126IS_UNOP_MATCHER(BooleanNot)
2127IS_UNOP_MATCHER(ChangeFloat64ToInt32)
2128IS_UNOP_MATCHER(ChangeFloat64ToUint32)
2129IS_UNOP_MATCHER(ChangeInt32ToFloat64)
2130IS_UNOP_MATCHER(ChangeInt32ToInt64)
2131IS_UNOP_MATCHER(ChangeUint32ToFloat64)
2132IS_UNOP_MATCHER(ChangeUint32ToUint64)
2133IS_UNOP_MATCHER(TruncateFloat64ToFloat32)
2134IS_UNOP_MATCHER(TruncateFloat64ToInt32)
2135IS_UNOP_MATCHER(TruncateInt64ToInt32)
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00002136IS_UNOP_MATCHER(Float32Abs)
2137IS_UNOP_MATCHER(Float64Abs)
Emily Bernierd0a1eb72015-03-24 16:35:39 -04002138IS_UNOP_MATCHER(Float64Sqrt)
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00002139IS_UNOP_MATCHER(Float64RoundDown)
Emily Bernierd0a1eb72015-03-24 16:35:39 -04002140IS_UNOP_MATCHER(Float64RoundTruncate)
2141IS_UNOP_MATCHER(Float64RoundTiesAway)
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00002142IS_UNOP_MATCHER(Float64ExtractLowWord32)
2143IS_UNOP_MATCHER(Float64ExtractHighWord32)
Emily Bernierd0a1eb72015-03-24 16:35:39 -04002144IS_UNOP_MATCHER(NumberToInt32)
2145IS_UNOP_MATCHER(NumberToUint32)
Ben Murdoch097c5b22016-05-18 11:27:45 +01002146IS_UNOP_MATCHER(ObjectIsReceiver)
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00002147IS_UNOP_MATCHER(ObjectIsSmi)
2148IS_UNOP_MATCHER(Word32Clz)
Emily Bernierd0a1eb72015-03-24 16:35:39 -04002149#undef IS_UNOP_MATCHER
2150
2151} // namespace compiler
2152} // namespace internal
2153} // namespace v8