Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1 | // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "test/unittests/compiler/node-test-utils.h" |
| 6 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 7 | #include <vector> |
| 8 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 9 | #include "src/assembler.h" |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 10 | #include "src/compiler/common-operator.h" |
| 11 | #include "src/compiler/js-operator.h" |
| 12 | #include "src/compiler/node-properties.h" |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 13 | #include "src/compiler/simplified-operator.h" |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 14 | #include "src/handles-inl.h" |
| 15 | #include "src/objects.h" |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 16 | |
| 17 | using testing::_; |
| 18 | using testing::MakeMatcher; |
| 19 | using testing::MatcherInterface; |
| 20 | using testing::MatchResultListener; |
| 21 | using testing::StringMatchResultListener; |
| 22 | |
| 23 | namespace v8 { |
| 24 | namespace internal { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 25 | |
| 26 | bool operator==(Handle<HeapObject> const& lhs, Handle<HeapObject> const& rhs) { |
| 27 | return lhs.is_identical_to(rhs); |
| 28 | } |
| 29 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 30 | namespace compiler { |
| 31 | |
| 32 | namespace { |
| 33 | |
| 34 | template <typename T> |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 35 | bool PrintMatchAndExplain(const T& value, const std::string& value_name, |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 36 | 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 | |
| 50 | class NodeMatcher : public MatcherInterface<Node*> { |
| 51 | public: |
| 52 | explicit NodeMatcher(IrOpcode::Value opcode) : opcode_(opcode) {} |
| 53 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 54 | void DescribeTo(std::ostream* os) const override { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 55 | *os << "is a " << IrOpcode::Mnemonic(opcode_) << " node"; |
| 56 | } |
| 57 | |
| 58 | bool MatchAndExplain(Node* node, |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 59 | MatchResultListener* listener) const override { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 60 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 77 | class IsBranchMatcher final : public NodeMatcher { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 78 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 85 | void DescribeTo(std::ostream* os) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 86 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 94 | bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 95 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 108 | class IsSwitchMatcher final : public NodeMatcher { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 109 | public: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 110 | 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 | |
| 139 | class 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 | |
| 170 | class 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 | |
| 194 | class 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 Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 200 | control0_matcher_(control0_matcher), |
| 201 | control1_matcher_(control1_matcher) {} |
| 202 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 203 | void DescribeTo(std::ostream* os) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 204 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 212 | bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 213 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 226 | class IsControl3Matcher final : public NodeMatcher { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 227 | public: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 228 | 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 Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 236 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 237 | void DescribeTo(std::ostream* os) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 238 | NodeMatcher::DescribeTo(os); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 239 | *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 Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 245 | *os << ")"; |
| 246 | } |
| 247 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 248 | bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 249 | return (NodeMatcher::MatchAndExplain(node, listener) && |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 250 | 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 Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 256 | } |
| 257 | |
| 258 | private: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 259 | const Matcher<Node*> control0_matcher_; |
| 260 | const Matcher<Node*> control1_matcher_; |
| 261 | const Matcher<Node*> control2_matcher_; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 262 | }; |
| 263 | |
| 264 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 265 | class IsBeginRegionMatcher final : public NodeMatcher { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 266 | public: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 267 | 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 | |
| 288 | class IsFinishRegionMatcher final : public NodeMatcher { |
| 289 | public: |
| 290 | IsFinishRegionMatcher(const Matcher<Node*>& value_matcher, |
| 291 | const Matcher<Node*>& effect_matcher) |
| 292 | : NodeMatcher(IrOpcode::kFinishRegion), |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 293 | value_matcher_(value_matcher), |
| 294 | effect_matcher_(effect_matcher) {} |
| 295 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 296 | void DescribeTo(std::ostream* os) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 297 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 305 | bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 306 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 319 | class 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 Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 326 | value2_matcher_(_), |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 327 | effect_matcher_(effect_matcher), |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 328 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 341 | |
| 342 | void DescribeTo(std::ostream* os) const final { |
| 343 | NodeMatcher::DescribeTo(os); |
| 344 | *os << " whose value ("; |
| 345 | value_matcher_.DescribeTo(os); |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 346 | if (has_second_return_value_) { |
| 347 | *os << ") and second value ("; |
| 348 | value2_matcher_.DescribeTo(os); |
| 349 | } |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 350 | *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 Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 361 | (!has_second_return_value_ || |
| 362 | PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), |
| 363 | "value2", value2_matcher_, listener)) && |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 364 | 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 Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 372 | const Matcher<Node*> value2_matcher_; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 373 | const Matcher<Node*> effect_matcher_; |
| 374 | const Matcher<Node*> control_matcher_; |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 375 | bool has_second_return_value_; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 376 | }; |
| 377 | |
| 378 | |
| 379 | class 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 Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 410 | template <typename T> |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 411 | class IsConstantMatcher final : public NodeMatcher { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 412 | public: |
| 413 | IsConstantMatcher(IrOpcode::Value opcode, const Matcher<T>& value_matcher) |
| 414 | : NodeMatcher(opcode), value_matcher_(value_matcher) {} |
| 415 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 416 | void DescribeTo(std::ostream* os) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 417 | NodeMatcher::DescribeTo(os); |
| 418 | *os << " whose value ("; |
| 419 | value_matcher_.DescribeTo(os); |
| 420 | *os << ")"; |
| 421 | } |
| 422 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 423 | bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 424 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 434 | class IsSelectMatcher final : public NodeMatcher { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 435 | public: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 436 | IsSelectMatcher(const Matcher<MachineRepresentation>& type_matcher, |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 437 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 446 | void DescribeTo(std::ostream* os) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 447 | NodeMatcher::DescribeTo(os); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 448 | *os << " whose representation ("; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 449 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 459 | 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 Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 470 | } |
| 471 | |
| 472 | private: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 473 | const Matcher<MachineRepresentation> type_matcher_; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 474 | const Matcher<Node*> value0_matcher_; |
| 475 | const Matcher<Node*> value1_matcher_; |
| 476 | const Matcher<Node*> value2_matcher_; |
| 477 | }; |
| 478 | |
| 479 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 480 | class IsPhiMatcher final : public NodeMatcher { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 481 | public: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 482 | IsPhiMatcher(const Matcher<MachineRepresentation>& type_matcher, |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 483 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 492 | void DescribeTo(std::ostream* os) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 493 | NodeMatcher::DescribeTo(os); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 494 | *os << " whose representation ("; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 495 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 505 | bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 506 | return (NodeMatcher::MatchAndExplain(node, listener) && |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 507 | PrintMatchAndExplain(PhiRepresentationOf(node->op()), |
| 508 | "representation", type_matcher_, listener) && |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 509 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 518 | const Matcher<MachineRepresentation> type_matcher_; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 519 | const Matcher<Node*> value0_matcher_; |
| 520 | const Matcher<Node*> value1_matcher_; |
| 521 | const Matcher<Node*> control_matcher_; |
| 522 | }; |
| 523 | |
| 524 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 525 | class 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 | |
| 577 | class IsEffectPhiMatcher final : public NodeMatcher { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 578 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 587 | void DescribeTo(std::ostream* os) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 588 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 598 | bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 599 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 615 | class 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 | |
| 658 | class IsProjectionMatcher final : public NodeMatcher { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 659 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 666 | void DescribeTo(std::ostream* os) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 667 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 675 | bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 676 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 689 | class IsCallMatcher final : public NodeMatcher { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 690 | public: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 691 | 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 Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 695 | : NodeMatcher(IrOpcode::kCall), |
| 696 | descriptor_matcher_(descriptor_matcher), |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 697 | value_matchers_(value_matchers), |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 698 | effect_matcher_(effect_matcher), |
| 699 | control_matcher_(control_matcher) {} |
| 700 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 701 | void DescribeTo(std::ostream* os) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 702 | NodeMatcher::DescribeTo(os); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 703 | 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 Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 712 | effect_matcher_.DescribeTo(os); |
| 713 | *os << ") and control ("; |
| 714 | control_matcher_.DescribeTo(os); |
| 715 | *os << ")"; |
| 716 | } |
| 717 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 718 | 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 | |
| 755 | class 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 | |
| 821 | class 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 Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 832 | return (NodeMatcher::MatchAndExplain(node, listener) && |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 833 | // 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 | |
| 847 | class 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 Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 861 | PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", |
| 862 | effect_matcher_, listener) && |
| 863 | PrintMatchAndExplain(NodeProperties::GetControlInput(node), |
| 864 | "control", control_matcher_, listener)); |
| 865 | } |
| 866 | |
| 867 | private: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 868 | const Matcher<Node*> size_matcher_; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 869 | const Matcher<Node*> effect_matcher_; |
| 870 | const Matcher<Node*> control_matcher_; |
| 871 | }; |
| 872 | |
| 873 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 874 | class IsLoadFieldMatcher final : public NodeMatcher { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 875 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 886 | void DescribeTo(std::ostream* os) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 887 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 899 | bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 900 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 919 | class IsStoreFieldMatcher final : public NodeMatcher { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 920 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 933 | void DescribeTo(std::ostream* os) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 934 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 948 | bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 949 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 971 | class IsLoadBufferMatcher final : public NodeMatcher { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 972 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 987 | void DescribeTo(std::ostream* os) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 988 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1004 | bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1005 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1030 | class IsStoreBufferMatcher final : public NodeMatcher { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1031 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1048 | void DescribeTo(std::ostream* os) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1049 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1067 | bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1068 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1096 | class IsLoadElementMatcher final : public NodeMatcher { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1097 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1110 | void DescribeTo(std::ostream* os) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1111 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1125 | bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1126 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1148 | class IsStoreElementMatcher final : public NodeMatcher { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1149 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1164 | void DescribeTo(std::ostream* os) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1165 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1181 | bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1182 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1207 | class IsLoadMatcher final : public NodeMatcher { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1208 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1221 | void DescribeTo(std::ostream* os) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1222 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1236 | 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 Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1245 | 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1252 | PrintMatchAndExplain(effect_node, "effect", effect_matcher_, |
| 1253 | listener) && |
| 1254 | PrintMatchAndExplain(control_node, "control", control_matcher_, |
| 1255 | listener)); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1256 | } |
| 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 Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1267 | class 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 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 1333 | class IsStackSlotMatcher final : public NodeMatcher { |
| 1334 | public: |
| 1335 | explicit IsStackSlotMatcher(const Matcher<MachineRepresentation>& rep_matcher) |
| 1336 | : NodeMatcher(IrOpcode::kStackSlot), rep_matcher_(rep_matcher) {} |
| 1337 | |
| 1338 | void DescribeTo(std::ostream* os) const final { |
| 1339 | NodeMatcher::DescribeTo(os); |
| 1340 | *os << " whose rep ("; |
| 1341 | rep_matcher_.DescribeTo(os); |
| 1342 | *os << ")"; |
| 1343 | } |
| 1344 | |
| 1345 | bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
| 1346 | return (NodeMatcher::MatchAndExplain(node, listener) && |
| 1347 | PrintMatchAndExplain(OpParameter<MachineRepresentation>(node), |
| 1348 | "rep", rep_matcher_, listener)); |
| 1349 | } |
| 1350 | |
| 1351 | private: |
| 1352 | const Matcher<MachineRepresentation> rep_matcher_; |
| 1353 | }; |
| 1354 | |
| 1355 | class IsGuardMatcher final : public NodeMatcher { |
| 1356 | public: |
| 1357 | IsGuardMatcher(const Matcher<Type*>& type_matcher, |
| 1358 | const Matcher<Node*>& value_matcher, |
| 1359 | const Matcher<Node*>& control_matcher) |
| 1360 | : NodeMatcher(IrOpcode::kGuard), |
| 1361 | type_matcher_(type_matcher), |
| 1362 | value_matcher_(value_matcher), |
| 1363 | control_matcher_(control_matcher) {} |
| 1364 | |
| 1365 | bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
| 1366 | return (NodeMatcher::MatchAndExplain(node, listener) && |
| 1367 | PrintMatchAndExplain(OpParameter<Type*>(node->op()), "type", |
| 1368 | type_matcher_, listener) && |
| 1369 | PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), |
| 1370 | "value", value_matcher_, listener) && |
| 1371 | PrintMatchAndExplain(NodeProperties::GetControlInput(node, 0), |
| 1372 | "control", control_matcher_, listener)); |
| 1373 | } |
| 1374 | |
| 1375 | private: |
| 1376 | const Matcher<Type*> type_matcher_; |
| 1377 | const Matcher<Node*> value_matcher_; |
| 1378 | const Matcher<Node*> control_matcher_; |
| 1379 | }; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1380 | |
| 1381 | class IsToNumberMatcher final : public NodeMatcher { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1382 | public: |
| 1383 | IsToNumberMatcher(const Matcher<Node*>& base_matcher, |
| 1384 | const Matcher<Node*>& context_matcher, |
| 1385 | const Matcher<Node*>& effect_matcher, |
| 1386 | const Matcher<Node*>& control_matcher) |
| 1387 | : NodeMatcher(IrOpcode::kJSToNumber), |
| 1388 | base_matcher_(base_matcher), |
| 1389 | context_matcher_(context_matcher), |
| 1390 | effect_matcher_(effect_matcher), |
| 1391 | control_matcher_(control_matcher) {} |
| 1392 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1393 | void DescribeTo(std::ostream* os) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1394 | NodeMatcher::DescribeTo(os); |
| 1395 | *os << " whose base ("; |
| 1396 | base_matcher_.DescribeTo(os); |
| 1397 | *os << "), context ("; |
| 1398 | context_matcher_.DescribeTo(os); |
| 1399 | *os << "), effect ("; |
| 1400 | effect_matcher_.DescribeTo(os); |
| 1401 | *os << ") and control ("; |
| 1402 | control_matcher_.DescribeTo(os); |
| 1403 | *os << ")"; |
| 1404 | } |
| 1405 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1406 | bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1407 | return (NodeMatcher::MatchAndExplain(node, listener) && |
| 1408 | PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "base", |
| 1409 | base_matcher_, listener) && |
| 1410 | PrintMatchAndExplain(NodeProperties::GetContextInput(node), |
| 1411 | "context", context_matcher_, listener) && |
| 1412 | PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect", |
| 1413 | effect_matcher_, listener) && |
| 1414 | PrintMatchAndExplain(NodeProperties::GetControlInput(node), |
| 1415 | "control", control_matcher_, listener)); |
| 1416 | } |
| 1417 | |
| 1418 | private: |
| 1419 | const Matcher<Node*> base_matcher_; |
| 1420 | const Matcher<Node*> context_matcher_; |
| 1421 | const Matcher<Node*> effect_matcher_; |
| 1422 | const Matcher<Node*> control_matcher_; |
| 1423 | }; |
| 1424 | |
| 1425 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1426 | class IsLoadContextMatcher final : public NodeMatcher { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1427 | public: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1428 | IsLoadContextMatcher(const Matcher<ContextAccess>& access_matcher, |
| 1429 | const Matcher<Node*>& context_matcher) |
| 1430 | : NodeMatcher(IrOpcode::kJSLoadContext), |
| 1431 | access_matcher_(access_matcher), |
| 1432 | context_matcher_(context_matcher) {} |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1433 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1434 | void DescribeTo(std::ostream* os) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1435 | NodeMatcher::DescribeTo(os); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1436 | *os << " whose access ("; |
| 1437 | access_matcher_.DescribeTo(os); |
| 1438 | *os << ") and context ("; |
| 1439 | context_matcher_.DescribeTo(os); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1440 | *os << ")"; |
| 1441 | } |
| 1442 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1443 | bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1444 | return (NodeMatcher::MatchAndExplain(node, listener) && |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1445 | PrintMatchAndExplain(OpParameter<ContextAccess>(node), "access", |
| 1446 | access_matcher_, listener) && |
| 1447 | PrintMatchAndExplain(NodeProperties::GetContextInput(node), |
| 1448 | "context", context_matcher_, listener)); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1449 | } |
| 1450 | |
| 1451 | private: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1452 | const Matcher<ContextAccess> access_matcher_; |
| 1453 | const Matcher<Node*> context_matcher_; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1454 | }; |
| 1455 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 1456 | class IsQuadopMatcher final : public NodeMatcher { |
| 1457 | public: |
| 1458 | IsQuadopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& a_matcher, |
| 1459 | const Matcher<Node*>& b_matcher, |
| 1460 | const Matcher<Node*>& c_matcher, |
| 1461 | const Matcher<Node*>& d_matcher) |
| 1462 | : NodeMatcher(opcode), |
| 1463 | a_matcher_(a_matcher), |
| 1464 | b_matcher_(b_matcher), |
| 1465 | c_matcher_(c_matcher), |
| 1466 | d_matcher_(d_matcher) {} |
| 1467 | |
| 1468 | void DescribeTo(std::ostream* os) const final { |
| 1469 | NodeMatcher::DescribeTo(os); |
| 1470 | *os << " whose a ("; |
| 1471 | a_matcher_.DescribeTo(os); |
| 1472 | *os << ") and b ("; |
| 1473 | b_matcher_.DescribeTo(os); |
| 1474 | *os << ") and c ("; |
| 1475 | c_matcher_.DescribeTo(os); |
| 1476 | *os << ") and d ("; |
| 1477 | d_matcher_.DescribeTo(os); |
| 1478 | *os << ")"; |
| 1479 | } |
| 1480 | |
| 1481 | bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
| 1482 | return (NodeMatcher::MatchAndExplain(node, listener) && |
| 1483 | PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "a", |
| 1484 | a_matcher_, listener) && |
| 1485 | PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "b", |
| 1486 | b_matcher_, listener) && |
| 1487 | PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2), "c", |
| 1488 | c_matcher_, listener) && |
| 1489 | PrintMatchAndExplain(NodeProperties::GetValueInput(node, 3), "d", |
| 1490 | d_matcher_, listener)); |
| 1491 | } |
| 1492 | |
| 1493 | private: |
| 1494 | const Matcher<Node*> a_matcher_; |
| 1495 | const Matcher<Node*> b_matcher_; |
| 1496 | const Matcher<Node*> c_matcher_; |
| 1497 | const Matcher<Node*> d_matcher_; |
| 1498 | }; |
| 1499 | |
| 1500 | class IsTernopMatcher final : public NodeMatcher { |
| 1501 | public: |
| 1502 | IsTernopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& lhs_matcher, |
| 1503 | const Matcher<Node*>& mid_matcher, |
| 1504 | const Matcher<Node*>& rhs_matcher) |
| 1505 | : NodeMatcher(opcode), |
| 1506 | lhs_matcher_(lhs_matcher), |
| 1507 | mid_matcher_(mid_matcher), |
| 1508 | rhs_matcher_(rhs_matcher) {} |
| 1509 | |
| 1510 | void DescribeTo(std::ostream* os) const final { |
| 1511 | NodeMatcher::DescribeTo(os); |
| 1512 | *os << " whose lhs ("; |
| 1513 | lhs_matcher_.DescribeTo(os); |
| 1514 | *os << ") and mid ("; |
| 1515 | mid_matcher_.DescribeTo(os); |
| 1516 | *os << ") and rhs ("; |
| 1517 | rhs_matcher_.DescribeTo(os); |
| 1518 | *os << ")"; |
| 1519 | } |
| 1520 | |
| 1521 | bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
| 1522 | return (NodeMatcher::MatchAndExplain(node, listener) && |
| 1523 | PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "lhs", |
| 1524 | lhs_matcher_, listener) && |
| 1525 | PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "mid", |
| 1526 | mid_matcher_, listener) && |
| 1527 | PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2), "rhs", |
| 1528 | rhs_matcher_, listener)); |
| 1529 | } |
| 1530 | |
| 1531 | private: |
| 1532 | const Matcher<Node*> lhs_matcher_; |
| 1533 | const Matcher<Node*> mid_matcher_; |
| 1534 | const Matcher<Node*> rhs_matcher_; |
| 1535 | }; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1536 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1537 | class IsBinopMatcher final : public NodeMatcher { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1538 | public: |
| 1539 | IsBinopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& lhs_matcher, |
| 1540 | const Matcher<Node*>& rhs_matcher) |
| 1541 | : NodeMatcher(opcode), |
| 1542 | lhs_matcher_(lhs_matcher), |
| 1543 | rhs_matcher_(rhs_matcher) {} |
| 1544 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1545 | void DescribeTo(std::ostream* os) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1546 | NodeMatcher::DescribeTo(os); |
| 1547 | *os << " whose lhs ("; |
| 1548 | lhs_matcher_.DescribeTo(os); |
| 1549 | *os << ") and rhs ("; |
| 1550 | rhs_matcher_.DescribeTo(os); |
| 1551 | *os << ")"; |
| 1552 | } |
| 1553 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1554 | bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1555 | return (NodeMatcher::MatchAndExplain(node, listener) && |
| 1556 | PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), "lhs", |
| 1557 | lhs_matcher_, listener) && |
| 1558 | PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1), "rhs", |
| 1559 | rhs_matcher_, listener)); |
| 1560 | } |
| 1561 | |
| 1562 | private: |
| 1563 | const Matcher<Node*> lhs_matcher_; |
| 1564 | const Matcher<Node*> rhs_matcher_; |
| 1565 | }; |
| 1566 | |
| 1567 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1568 | class IsUnopMatcher final : public NodeMatcher { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1569 | public: |
| 1570 | IsUnopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& input_matcher) |
| 1571 | : NodeMatcher(opcode), input_matcher_(input_matcher) {} |
| 1572 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1573 | void DescribeTo(std::ostream* os) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1574 | NodeMatcher::DescribeTo(os); |
| 1575 | *os << " whose input ("; |
| 1576 | input_matcher_.DescribeTo(os); |
| 1577 | *os << ")"; |
| 1578 | } |
| 1579 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1580 | bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1581 | return (NodeMatcher::MatchAndExplain(node, listener) && |
| 1582 | PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0), |
| 1583 | "input", input_matcher_, listener)); |
| 1584 | } |
| 1585 | |
| 1586 | private: |
| 1587 | const Matcher<Node*> input_matcher_; |
| 1588 | }; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1589 | |
| 1590 | |
| 1591 | class IsParameterMatcher final : public NodeMatcher { |
| 1592 | public: |
| 1593 | explicit IsParameterMatcher(const Matcher<int>& index_matcher) |
| 1594 | : NodeMatcher(IrOpcode::kParameter), index_matcher_(index_matcher) {} |
| 1595 | |
| 1596 | void DescribeTo(std::ostream* os) const override { |
| 1597 | *os << "is a Parameter node with index("; |
| 1598 | index_matcher_.DescribeTo(os); |
| 1599 | *os << ")"; |
| 1600 | } |
| 1601 | |
| 1602 | bool MatchAndExplain(Node* node, MatchResultListener* listener) const final { |
| 1603 | return (NodeMatcher::MatchAndExplain(node, listener) && |
| 1604 | PrintMatchAndExplain(ParameterIndexOf(node->op()), "index", |
| 1605 | index_matcher_, listener)); |
| 1606 | } |
| 1607 | |
| 1608 | private: |
| 1609 | const Matcher<int> index_matcher_; |
| 1610 | }; |
| 1611 | |
| 1612 | } // namespace |
| 1613 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1614 | Matcher<Node*> IsDead() { |
| 1615 | return MakeMatcher(new NodeMatcher(IrOpcode::kDead)); |
| 1616 | } |
| 1617 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1618 | Matcher<Node*> IsEnd(const Matcher<Node*>& control0_matcher) { |
| 1619 | return MakeMatcher(new IsControl1Matcher(IrOpcode::kEnd, control0_matcher)); |
| 1620 | } |
| 1621 | |
| 1622 | |
| 1623 | Matcher<Node*> IsEnd(const Matcher<Node*>& control0_matcher, |
| 1624 | const Matcher<Node*>& control1_matcher) { |
| 1625 | return MakeMatcher(new IsControl2Matcher(IrOpcode::kEnd, control0_matcher, |
| 1626 | control1_matcher)); |
| 1627 | } |
| 1628 | |
| 1629 | |
| 1630 | Matcher<Node*> IsEnd(const Matcher<Node*>& control0_matcher, |
| 1631 | const Matcher<Node*>& control1_matcher, |
| 1632 | const Matcher<Node*>& control2_matcher) { |
| 1633 | return MakeMatcher(new IsControl3Matcher(IrOpcode::kEnd, control0_matcher, |
| 1634 | control1_matcher, control2_matcher)); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1635 | } |
| 1636 | |
| 1637 | |
| 1638 | Matcher<Node*> IsBranch(const Matcher<Node*>& value_matcher, |
| 1639 | const Matcher<Node*>& control_matcher) { |
| 1640 | return MakeMatcher(new IsBranchMatcher(value_matcher, control_matcher)); |
| 1641 | } |
| 1642 | |
| 1643 | |
| 1644 | Matcher<Node*> IsMerge(const Matcher<Node*>& control0_matcher, |
| 1645 | const Matcher<Node*>& control1_matcher) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1646 | return MakeMatcher(new IsControl2Matcher(IrOpcode::kMerge, control0_matcher, |
| 1647 | control1_matcher)); |
| 1648 | } |
| 1649 | |
| 1650 | |
| 1651 | Matcher<Node*> IsMerge(const Matcher<Node*>& control0_matcher, |
| 1652 | const Matcher<Node*>& control1_matcher, |
| 1653 | const Matcher<Node*>& control2_matcher) { |
| 1654 | return MakeMatcher(new IsControl3Matcher(IrOpcode::kMerge, control0_matcher, |
| 1655 | control1_matcher, control2_matcher)); |
| 1656 | } |
| 1657 | |
| 1658 | |
| 1659 | Matcher<Node*> IsLoop(const Matcher<Node*>& control0_matcher, |
| 1660 | const Matcher<Node*>& control1_matcher) { |
| 1661 | return MakeMatcher(new IsControl2Matcher(IrOpcode::kLoop, control0_matcher, |
| 1662 | control1_matcher)); |
| 1663 | } |
| 1664 | |
| 1665 | |
| 1666 | Matcher<Node*> IsLoop(const Matcher<Node*>& control0_matcher, |
| 1667 | const Matcher<Node*>& control1_matcher, |
| 1668 | const Matcher<Node*>& control2_matcher) { |
| 1669 | return MakeMatcher(new IsControl3Matcher(IrOpcode::kLoop, control0_matcher, |
| 1670 | control1_matcher, control2_matcher)); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1671 | } |
| 1672 | |
| 1673 | |
| 1674 | Matcher<Node*> IsIfTrue(const Matcher<Node*>& control_matcher) { |
| 1675 | return MakeMatcher(new IsControl1Matcher(IrOpcode::kIfTrue, control_matcher)); |
| 1676 | } |
| 1677 | |
| 1678 | |
| 1679 | Matcher<Node*> IsIfFalse(const Matcher<Node*>& control_matcher) { |
| 1680 | return MakeMatcher( |
| 1681 | new IsControl1Matcher(IrOpcode::kIfFalse, control_matcher)); |
| 1682 | } |
| 1683 | |
| 1684 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1685 | Matcher<Node*> IsIfSuccess(const Matcher<Node*>& control_matcher) { |
| 1686 | return MakeMatcher( |
| 1687 | new IsControl1Matcher(IrOpcode::kIfSuccess, control_matcher)); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1688 | } |
| 1689 | |
| 1690 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1691 | Matcher<Node*> IsSwitch(const Matcher<Node*>& value_matcher, |
| 1692 | const Matcher<Node*>& control_matcher) { |
| 1693 | return MakeMatcher(new IsSwitchMatcher(value_matcher, control_matcher)); |
| 1694 | } |
| 1695 | |
| 1696 | |
| 1697 | Matcher<Node*> IsIfValue(const Matcher<int32_t>& value_matcher, |
| 1698 | const Matcher<Node*>& control_matcher) { |
| 1699 | return MakeMatcher(new IsIfValueMatcher(value_matcher, control_matcher)); |
| 1700 | } |
| 1701 | |
| 1702 | |
| 1703 | Matcher<Node*> IsIfDefault(const Matcher<Node*>& control_matcher) { |
| 1704 | return MakeMatcher( |
| 1705 | new IsControl1Matcher(IrOpcode::kIfDefault, control_matcher)); |
| 1706 | } |
| 1707 | |
| 1708 | |
| 1709 | Matcher<Node*> IsBeginRegion(const Matcher<Node*>& effect_matcher) { |
| 1710 | return MakeMatcher(new IsBeginRegionMatcher(effect_matcher)); |
| 1711 | } |
| 1712 | |
| 1713 | |
| 1714 | Matcher<Node*> IsFinishRegion(const Matcher<Node*>& value_matcher, |
| 1715 | const Matcher<Node*>& effect_matcher) { |
| 1716 | return MakeMatcher(new IsFinishRegionMatcher(value_matcher, effect_matcher)); |
| 1717 | } |
| 1718 | |
| 1719 | |
| 1720 | Matcher<Node*> IsReturn(const Matcher<Node*>& value_matcher, |
| 1721 | const Matcher<Node*>& effect_matcher, |
| 1722 | const Matcher<Node*>& control_matcher) { |
| 1723 | return MakeMatcher( |
| 1724 | new IsReturnMatcher(value_matcher, effect_matcher, control_matcher)); |
| 1725 | } |
| 1726 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 1727 | Matcher<Node*> IsReturn2(const Matcher<Node*>& value_matcher, |
| 1728 | const Matcher<Node*>& value2_matcher, |
| 1729 | const Matcher<Node*>& effect_matcher, |
| 1730 | const Matcher<Node*>& control_matcher) { |
| 1731 | return MakeMatcher(new IsReturnMatcher(value_matcher, value2_matcher, |
| 1732 | effect_matcher, control_matcher)); |
| 1733 | } |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1734 | |
| 1735 | Matcher<Node*> IsTerminate(const Matcher<Node*>& effect_matcher, |
| 1736 | const Matcher<Node*>& control_matcher) { |
| 1737 | return MakeMatcher(new IsTerminateMatcher(effect_matcher, control_matcher)); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1738 | } |
| 1739 | |
| 1740 | |
| 1741 | Matcher<Node*> IsExternalConstant( |
| 1742 | const Matcher<ExternalReference>& value_matcher) { |
| 1743 | return MakeMatcher(new IsConstantMatcher<ExternalReference>( |
| 1744 | IrOpcode::kExternalConstant, value_matcher)); |
| 1745 | } |
| 1746 | |
| 1747 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1748 | Matcher<Node*> IsHeapConstant(Handle<HeapObject> value) { |
| 1749 | return MakeMatcher(new IsConstantMatcher<Handle<HeapObject>>( |
| 1750 | IrOpcode::kHeapConstant, value)); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1751 | } |
| 1752 | |
| 1753 | |
| 1754 | Matcher<Node*> IsInt32Constant(const Matcher<int32_t>& value_matcher) { |
| 1755 | return MakeMatcher( |
| 1756 | new IsConstantMatcher<int32_t>(IrOpcode::kInt32Constant, value_matcher)); |
| 1757 | } |
| 1758 | |
| 1759 | |
| 1760 | Matcher<Node*> IsInt64Constant(const Matcher<int64_t>& value_matcher) { |
| 1761 | return MakeMatcher( |
| 1762 | new IsConstantMatcher<int64_t>(IrOpcode::kInt64Constant, value_matcher)); |
| 1763 | } |
| 1764 | |
| 1765 | |
| 1766 | Matcher<Node*> IsFloat32Constant(const Matcher<float>& value_matcher) { |
| 1767 | return MakeMatcher( |
| 1768 | new IsConstantMatcher<float>(IrOpcode::kFloat32Constant, value_matcher)); |
| 1769 | } |
| 1770 | |
| 1771 | |
| 1772 | Matcher<Node*> IsFloat64Constant(const Matcher<double>& value_matcher) { |
| 1773 | return MakeMatcher( |
| 1774 | new IsConstantMatcher<double>(IrOpcode::kFloat64Constant, value_matcher)); |
| 1775 | } |
| 1776 | |
| 1777 | |
| 1778 | Matcher<Node*> IsNumberConstant(const Matcher<double>& value_matcher) { |
| 1779 | return MakeMatcher( |
| 1780 | new IsConstantMatcher<double>(IrOpcode::kNumberConstant, value_matcher)); |
| 1781 | } |
| 1782 | |
| 1783 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1784 | Matcher<Node*> IsSelect(const Matcher<MachineRepresentation>& type_matcher, |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1785 | const Matcher<Node*>& value0_matcher, |
| 1786 | const Matcher<Node*>& value1_matcher, |
| 1787 | const Matcher<Node*>& value2_matcher) { |
| 1788 | return MakeMatcher(new IsSelectMatcher(type_matcher, value0_matcher, |
| 1789 | value1_matcher, value2_matcher)); |
| 1790 | } |
| 1791 | |
| 1792 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1793 | Matcher<Node*> IsPhi(const Matcher<MachineRepresentation>& type_matcher, |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1794 | const Matcher<Node*>& value0_matcher, |
| 1795 | const Matcher<Node*>& value1_matcher, |
| 1796 | const Matcher<Node*>& merge_matcher) { |
| 1797 | return MakeMatcher(new IsPhiMatcher(type_matcher, value0_matcher, |
| 1798 | value1_matcher, merge_matcher)); |
| 1799 | } |
| 1800 | |
| 1801 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1802 | Matcher<Node*> IsPhi(const Matcher<MachineRepresentation>& type_matcher, |
| 1803 | const Matcher<Node*>& value0_matcher, |
| 1804 | const Matcher<Node*>& value1_matcher, |
| 1805 | const Matcher<Node*>& value2_matcher, |
| 1806 | const Matcher<Node*>& merge_matcher) { |
| 1807 | return MakeMatcher(new IsPhi2Matcher(type_matcher, value0_matcher, |
| 1808 | value1_matcher, value2_matcher, |
| 1809 | merge_matcher)); |
| 1810 | } |
| 1811 | |
| 1812 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1813 | Matcher<Node*> IsEffectPhi(const Matcher<Node*>& effect0_matcher, |
| 1814 | const Matcher<Node*>& effect1_matcher, |
| 1815 | const Matcher<Node*>& merge_matcher) { |
| 1816 | return MakeMatcher( |
| 1817 | new IsEffectPhiMatcher(effect0_matcher, effect1_matcher, merge_matcher)); |
| 1818 | } |
| 1819 | |
| 1820 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1821 | Matcher<Node*> IsEffectSet(const Matcher<Node*>& effect0_matcher, |
| 1822 | const Matcher<Node*>& effect1_matcher) { |
| 1823 | return MakeMatcher(new IsEffectSetMatcher(effect0_matcher, effect1_matcher)); |
| 1824 | } |
| 1825 | |
| 1826 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1827 | Matcher<Node*> IsProjection(const Matcher<size_t>& index_matcher, |
| 1828 | const Matcher<Node*>& base_matcher) { |
| 1829 | return MakeMatcher(new IsProjectionMatcher(index_matcher, base_matcher)); |
| 1830 | } |
| 1831 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 1832 | Matcher<Node*> IsCall(const Matcher<const CallDescriptor*>& descriptor_matcher, |
| 1833 | const Matcher<Node*>& value0_matcher, |
| 1834 | const Matcher<Node*>& effect_matcher, |
| 1835 | const Matcher<Node*>& control_matcher) { |
| 1836 | std::vector<Matcher<Node*>> value_matchers; |
| 1837 | value_matchers.push_back(value0_matcher); |
| 1838 | return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers, |
| 1839 | effect_matcher, control_matcher)); |
| 1840 | } |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1841 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1842 | Matcher<Node*> IsCall(const Matcher<const CallDescriptor*>& descriptor_matcher, |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1843 | const Matcher<Node*>& value0_matcher, |
| 1844 | const Matcher<Node*>& value1_matcher, |
| 1845 | const Matcher<Node*>& effect_matcher, |
| 1846 | const Matcher<Node*>& control_matcher) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1847 | std::vector<Matcher<Node*>> value_matchers; |
| 1848 | value_matchers.push_back(value0_matcher); |
| 1849 | value_matchers.push_back(value1_matcher); |
| 1850 | return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers, |
| 1851 | effect_matcher, control_matcher)); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1852 | } |
| 1853 | |
| 1854 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1855 | Matcher<Node*> IsCall(const Matcher<const CallDescriptor*>& descriptor_matcher, |
| 1856 | const Matcher<Node*>& value0_matcher, |
| 1857 | const Matcher<Node*>& value1_matcher, |
| 1858 | const Matcher<Node*>& value2_matcher, |
| 1859 | const Matcher<Node*>& effect_matcher, |
| 1860 | const Matcher<Node*>& control_matcher) { |
| 1861 | std::vector<Matcher<Node*>> value_matchers; |
| 1862 | value_matchers.push_back(value0_matcher); |
| 1863 | value_matchers.push_back(value1_matcher); |
| 1864 | value_matchers.push_back(value2_matcher); |
| 1865 | return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers, |
| 1866 | effect_matcher, control_matcher)); |
| 1867 | } |
| 1868 | |
| 1869 | |
| 1870 | Matcher<Node*> IsCall(const Matcher<const CallDescriptor*>& descriptor_matcher, |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 1871 | const Matcher<Node*>& value0_matcher, |
| 1872 | const Matcher<Node*>& value1_matcher, |
| 1873 | const Matcher<Node*>& value2_matcher, |
| 1874 | const Matcher<Node*>& value3_matcher, |
| 1875 | const Matcher<Node*>& effect_matcher, |
| 1876 | const Matcher<Node*>& control_matcher) { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1877 | std::vector<Matcher<Node*>> value_matchers; |
| 1878 | value_matchers.push_back(value0_matcher); |
| 1879 | value_matchers.push_back(value1_matcher); |
| 1880 | value_matchers.push_back(value2_matcher); |
| 1881 | value_matchers.push_back(value3_matcher); |
| 1882 | return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers, |
| 1883 | effect_matcher, control_matcher)); |
| 1884 | } |
| 1885 | |
| 1886 | |
| 1887 | Matcher<Node*> IsCall(const Matcher<const CallDescriptor*>& descriptor_matcher, |
| 1888 | const Matcher<Node*>& value0_matcher, |
| 1889 | const Matcher<Node*>& value1_matcher, |
| 1890 | const Matcher<Node*>& value2_matcher, |
| 1891 | const Matcher<Node*>& value3_matcher, |
| 1892 | const Matcher<Node*>& value4_matcher, |
| 1893 | const Matcher<Node*>& effect_matcher, |
| 1894 | const Matcher<Node*>& control_matcher) { |
| 1895 | std::vector<Matcher<Node*>> value_matchers; |
| 1896 | value_matchers.push_back(value0_matcher); |
| 1897 | value_matchers.push_back(value1_matcher); |
| 1898 | value_matchers.push_back(value2_matcher); |
| 1899 | value_matchers.push_back(value3_matcher); |
| 1900 | value_matchers.push_back(value4_matcher); |
| 1901 | return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers, |
| 1902 | effect_matcher, control_matcher)); |
| 1903 | } |
| 1904 | |
| 1905 | |
| 1906 | Matcher<Node*> IsCall(const Matcher<const CallDescriptor*>& descriptor_matcher, |
| 1907 | const Matcher<Node*>& value0_matcher, |
| 1908 | const Matcher<Node*>& value1_matcher, |
| 1909 | const Matcher<Node*>& value2_matcher, |
| 1910 | const Matcher<Node*>& value3_matcher, |
| 1911 | const Matcher<Node*>& value4_matcher, |
| 1912 | const Matcher<Node*>& value5_matcher, |
| 1913 | const Matcher<Node*>& effect_matcher, |
| 1914 | const Matcher<Node*>& control_matcher) { |
| 1915 | std::vector<Matcher<Node*>> value_matchers; |
| 1916 | value_matchers.push_back(value0_matcher); |
| 1917 | value_matchers.push_back(value1_matcher); |
| 1918 | value_matchers.push_back(value2_matcher); |
| 1919 | value_matchers.push_back(value3_matcher); |
| 1920 | value_matchers.push_back(value4_matcher); |
| 1921 | value_matchers.push_back(value5_matcher); |
| 1922 | return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers, |
| 1923 | effect_matcher, control_matcher)); |
| 1924 | } |
| 1925 | |
| 1926 | |
| 1927 | Matcher<Node*> IsCall( |
| 1928 | const Matcher<const CallDescriptor*>& descriptor_matcher, |
| 1929 | const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher, |
| 1930 | const Matcher<Node*>& value2_matcher, const Matcher<Node*>& value3_matcher, |
| 1931 | const Matcher<Node*>& value4_matcher, const Matcher<Node*>& value5_matcher, |
| 1932 | const Matcher<Node*>& value6_matcher, const Matcher<Node*>& effect_matcher, |
| 1933 | const Matcher<Node*>& control_matcher) { |
| 1934 | std::vector<Matcher<Node*>> value_matchers; |
| 1935 | value_matchers.push_back(value0_matcher); |
| 1936 | value_matchers.push_back(value1_matcher); |
| 1937 | value_matchers.push_back(value2_matcher); |
| 1938 | value_matchers.push_back(value3_matcher); |
| 1939 | value_matchers.push_back(value4_matcher); |
| 1940 | value_matchers.push_back(value5_matcher); |
| 1941 | value_matchers.push_back(value6_matcher); |
| 1942 | return MakeMatcher(new IsCallMatcher(descriptor_matcher, value_matchers, |
| 1943 | effect_matcher, control_matcher)); |
| 1944 | } |
| 1945 | |
| 1946 | |
| 1947 | Matcher<Node*> IsTailCall( |
| 1948 | const Matcher<CallDescriptor const*>& descriptor_matcher, |
| 1949 | const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher, |
| 1950 | const Matcher<Node*>& effect_matcher, |
| 1951 | const Matcher<Node*>& control_matcher) { |
| 1952 | std::vector<Matcher<Node*>> value_matchers; |
| 1953 | value_matchers.push_back(value0_matcher); |
| 1954 | value_matchers.push_back(value1_matcher); |
| 1955 | return MakeMatcher(new IsTailCallMatcher(descriptor_matcher, value_matchers, |
| 1956 | effect_matcher, control_matcher)); |
| 1957 | } |
| 1958 | |
| 1959 | |
| 1960 | Matcher<Node*> IsTailCall( |
| 1961 | const Matcher<CallDescriptor const*>& descriptor_matcher, |
| 1962 | const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher, |
| 1963 | const Matcher<Node*>& value2_matcher, const Matcher<Node*>& effect_matcher, |
| 1964 | const Matcher<Node*>& control_matcher) { |
| 1965 | std::vector<Matcher<Node*>> value_matchers; |
| 1966 | value_matchers.push_back(value0_matcher); |
| 1967 | value_matchers.push_back(value1_matcher); |
| 1968 | value_matchers.push_back(value2_matcher); |
| 1969 | return MakeMatcher(new IsTailCallMatcher(descriptor_matcher, value_matchers, |
| 1970 | effect_matcher, control_matcher)); |
| 1971 | } |
| 1972 | |
| 1973 | |
| 1974 | Matcher<Node*> IsTailCall( |
| 1975 | const Matcher<CallDescriptor const*>& descriptor_matcher, |
| 1976 | const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher, |
| 1977 | const Matcher<Node*>& value2_matcher, const Matcher<Node*>& value3_matcher, |
| 1978 | const Matcher<Node*>& effect_matcher, |
| 1979 | const Matcher<Node*>& control_matcher) { |
| 1980 | std::vector<Matcher<Node*>> value_matchers; |
| 1981 | value_matchers.push_back(value0_matcher); |
| 1982 | value_matchers.push_back(value1_matcher); |
| 1983 | value_matchers.push_back(value2_matcher); |
| 1984 | value_matchers.push_back(value3_matcher); |
| 1985 | return MakeMatcher(new IsTailCallMatcher(descriptor_matcher, value_matchers, |
| 1986 | effect_matcher, control_matcher)); |
| 1987 | } |
| 1988 | |
| 1989 | |
| 1990 | Matcher<Node*> IsTailCall( |
| 1991 | const Matcher<CallDescriptor const*>& descriptor_matcher, |
| 1992 | const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher, |
| 1993 | const Matcher<Node*>& value2_matcher, const Matcher<Node*>& value3_matcher, |
| 1994 | const Matcher<Node*>& value4_matcher, const Matcher<Node*>& effect_matcher, |
| 1995 | const Matcher<Node*>& control_matcher) { |
| 1996 | std::vector<Matcher<Node*>> value_matchers; |
| 1997 | value_matchers.push_back(value0_matcher); |
| 1998 | value_matchers.push_back(value1_matcher); |
| 1999 | value_matchers.push_back(value2_matcher); |
| 2000 | value_matchers.push_back(value3_matcher); |
| 2001 | value_matchers.push_back(value4_matcher); |
| 2002 | return MakeMatcher(new IsTailCallMatcher(descriptor_matcher, value_matchers, |
| 2003 | effect_matcher, control_matcher)); |
| 2004 | } |
| 2005 | |
| 2006 | |
| 2007 | Matcher<Node*> IsTailCall( |
| 2008 | const Matcher<CallDescriptor const*>& descriptor_matcher, |
| 2009 | const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher, |
| 2010 | const Matcher<Node*>& value2_matcher, const Matcher<Node*>& value3_matcher, |
| 2011 | const Matcher<Node*>& value4_matcher, const Matcher<Node*>& value5_matcher, |
| 2012 | const Matcher<Node*>& effect_matcher, |
| 2013 | const Matcher<Node*>& control_matcher) { |
| 2014 | std::vector<Matcher<Node*>> value_matchers; |
| 2015 | value_matchers.push_back(value0_matcher); |
| 2016 | value_matchers.push_back(value1_matcher); |
| 2017 | value_matchers.push_back(value2_matcher); |
| 2018 | value_matchers.push_back(value3_matcher); |
| 2019 | value_matchers.push_back(value4_matcher); |
| 2020 | value_matchers.push_back(value5_matcher); |
| 2021 | return MakeMatcher(new IsTailCallMatcher(descriptor_matcher, value_matchers, |
| 2022 | effect_matcher, control_matcher)); |
| 2023 | } |
| 2024 | |
| 2025 | |
| 2026 | Matcher<Node*> IsTailCall( |
| 2027 | const Matcher<CallDescriptor const*>& descriptor_matcher, |
| 2028 | const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher, |
| 2029 | const Matcher<Node*>& value2_matcher, const Matcher<Node*>& value3_matcher, |
| 2030 | const Matcher<Node*>& value4_matcher, const Matcher<Node*>& value5_matcher, |
| 2031 | const Matcher<Node*>& value6_matcher, const Matcher<Node*>& effect_matcher, |
| 2032 | const Matcher<Node*>& control_matcher) { |
| 2033 | std::vector<Matcher<Node*>> value_matchers; |
| 2034 | value_matchers.push_back(value0_matcher); |
| 2035 | value_matchers.push_back(value1_matcher); |
| 2036 | value_matchers.push_back(value2_matcher); |
| 2037 | value_matchers.push_back(value3_matcher); |
| 2038 | value_matchers.push_back(value4_matcher); |
| 2039 | value_matchers.push_back(value5_matcher); |
| 2040 | value_matchers.push_back(value6_matcher); |
| 2041 | return MakeMatcher(new IsTailCallMatcher(descriptor_matcher, value_matchers, |
| 2042 | effect_matcher, control_matcher)); |
| 2043 | } |
| 2044 | |
| 2045 | |
| 2046 | Matcher<Node*> IsTailCall( |
| 2047 | const Matcher<CallDescriptor const*>& descriptor_matcher, |
| 2048 | const Matcher<Node*>& value0_matcher, const Matcher<Node*>& value1_matcher, |
| 2049 | const Matcher<Node*>& value2_matcher, const Matcher<Node*>& value3_matcher, |
| 2050 | const Matcher<Node*>& value4_matcher, const Matcher<Node*>& value5_matcher, |
| 2051 | const Matcher<Node*>& value6_matcher, const Matcher<Node*>& value7_matcher, |
| 2052 | const Matcher<Node*>& effect_matcher, |
| 2053 | const Matcher<Node*>& control_matcher) { |
| 2054 | std::vector<Matcher<Node*>> value_matchers; |
| 2055 | value_matchers.push_back(value0_matcher); |
| 2056 | value_matchers.push_back(value1_matcher); |
| 2057 | value_matchers.push_back(value2_matcher); |
| 2058 | value_matchers.push_back(value3_matcher); |
| 2059 | value_matchers.push_back(value4_matcher); |
| 2060 | value_matchers.push_back(value5_matcher); |
| 2061 | value_matchers.push_back(value6_matcher); |
| 2062 | value_matchers.push_back(value7_matcher); |
| 2063 | return MakeMatcher(new IsTailCallMatcher(descriptor_matcher, value_matchers, |
| 2064 | effect_matcher, control_matcher)); |
| 2065 | } |
| 2066 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 2067 | Matcher<Node*> IsGuard(const Matcher<Type*>& type_matcher, |
| 2068 | const Matcher<Node*>& value_matcher, |
| 2069 | const Matcher<Node*>& control_matcher) { |
| 2070 | return MakeMatcher( |
| 2071 | new IsGuardMatcher(type_matcher, value_matcher, control_matcher)); |
| 2072 | } |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2073 | |
| 2074 | Matcher<Node*> IsReferenceEqual(const Matcher<Type*>& type_matcher, |
| 2075 | const Matcher<Node*>& lhs_matcher, |
| 2076 | const Matcher<Node*>& rhs_matcher) { |
| 2077 | return MakeMatcher( |
| 2078 | new IsReferenceEqualMatcher(type_matcher, lhs_matcher, rhs_matcher)); |
| 2079 | } |
| 2080 | |
| 2081 | |
| 2082 | Matcher<Node*> IsAllocate(const Matcher<Node*>& size_matcher, |
| 2083 | const Matcher<Node*>& effect_matcher, |
| 2084 | const Matcher<Node*>& control_matcher) { |
| 2085 | return MakeMatcher( |
| 2086 | new IsAllocateMatcher(size_matcher, effect_matcher, control_matcher)); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 2087 | } |
| 2088 | |
| 2089 | |
| 2090 | Matcher<Node*> IsLoadField(const Matcher<FieldAccess>& access_matcher, |
| 2091 | const Matcher<Node*>& base_matcher, |
| 2092 | const Matcher<Node*>& effect_matcher, |
| 2093 | const Matcher<Node*>& control_matcher) { |
| 2094 | return MakeMatcher(new IsLoadFieldMatcher(access_matcher, base_matcher, |
| 2095 | effect_matcher, control_matcher)); |
| 2096 | } |
| 2097 | |
| 2098 | |
| 2099 | Matcher<Node*> IsStoreField(const Matcher<FieldAccess>& access_matcher, |
| 2100 | const Matcher<Node*>& base_matcher, |
| 2101 | const Matcher<Node*>& value_matcher, |
| 2102 | const Matcher<Node*>& effect_matcher, |
| 2103 | const Matcher<Node*>& control_matcher) { |
| 2104 | return MakeMatcher(new IsStoreFieldMatcher(access_matcher, base_matcher, |
| 2105 | value_matcher, effect_matcher, |
| 2106 | control_matcher)); |
| 2107 | } |
| 2108 | |
| 2109 | |
| 2110 | Matcher<Node*> IsLoadBuffer(const Matcher<BufferAccess>& access_matcher, |
| 2111 | const Matcher<Node*>& buffer_matcher, |
| 2112 | const Matcher<Node*>& offset_matcher, |
| 2113 | const Matcher<Node*>& length_matcher, |
| 2114 | const Matcher<Node*>& effect_matcher, |
| 2115 | const Matcher<Node*>& control_matcher) { |
| 2116 | return MakeMatcher(new IsLoadBufferMatcher(access_matcher, buffer_matcher, |
| 2117 | offset_matcher, length_matcher, |
| 2118 | effect_matcher, control_matcher)); |
| 2119 | } |
| 2120 | |
| 2121 | |
| 2122 | Matcher<Node*> IsStoreBuffer(const Matcher<BufferAccess>& access_matcher, |
| 2123 | const Matcher<Node*>& buffer_matcher, |
| 2124 | const Matcher<Node*>& offset_matcher, |
| 2125 | const Matcher<Node*>& length_matcher, |
| 2126 | const Matcher<Node*>& value_matcher, |
| 2127 | const Matcher<Node*>& effect_matcher, |
| 2128 | const Matcher<Node*>& control_matcher) { |
| 2129 | return MakeMatcher(new IsStoreBufferMatcher( |
| 2130 | access_matcher, buffer_matcher, offset_matcher, length_matcher, |
| 2131 | value_matcher, effect_matcher, control_matcher)); |
| 2132 | } |
| 2133 | |
| 2134 | |
| 2135 | Matcher<Node*> IsLoadElement(const Matcher<ElementAccess>& access_matcher, |
| 2136 | const Matcher<Node*>& base_matcher, |
| 2137 | const Matcher<Node*>& index_matcher, |
| 2138 | const Matcher<Node*>& effect_matcher, |
| 2139 | const Matcher<Node*>& control_matcher) { |
| 2140 | return MakeMatcher(new IsLoadElementMatcher(access_matcher, base_matcher, |
| 2141 | index_matcher, effect_matcher, |
| 2142 | control_matcher)); |
| 2143 | } |
| 2144 | |
| 2145 | |
| 2146 | Matcher<Node*> IsStoreElement(const Matcher<ElementAccess>& access_matcher, |
| 2147 | const Matcher<Node*>& base_matcher, |
| 2148 | const Matcher<Node*>& index_matcher, |
| 2149 | const Matcher<Node*>& value_matcher, |
| 2150 | const Matcher<Node*>& effect_matcher, |
| 2151 | const Matcher<Node*>& control_matcher) { |
| 2152 | return MakeMatcher(new IsStoreElementMatcher( |
| 2153 | access_matcher, base_matcher, index_matcher, value_matcher, |
| 2154 | effect_matcher, control_matcher)); |
| 2155 | } |
| 2156 | |
| 2157 | |
| 2158 | Matcher<Node*> IsLoad(const Matcher<LoadRepresentation>& rep_matcher, |
| 2159 | const Matcher<Node*>& base_matcher, |
| 2160 | const Matcher<Node*>& index_matcher, |
| 2161 | const Matcher<Node*>& effect_matcher, |
| 2162 | const Matcher<Node*>& control_matcher) { |
| 2163 | return MakeMatcher(new IsLoadMatcher(rep_matcher, base_matcher, index_matcher, |
| 2164 | effect_matcher, control_matcher)); |
| 2165 | } |
| 2166 | |
| 2167 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 2168 | Matcher<Node*> IsStore(const Matcher<StoreRepresentation>& rep_matcher, |
| 2169 | const Matcher<Node*>& base_matcher, |
| 2170 | const Matcher<Node*>& index_matcher, |
| 2171 | const Matcher<Node*>& value_matcher, |
| 2172 | const Matcher<Node*>& effect_matcher, |
| 2173 | const Matcher<Node*>& control_matcher) { |
| 2174 | return MakeMatcher(new IsStoreMatcher(rep_matcher, base_matcher, |
| 2175 | index_matcher, value_matcher, |
| 2176 | effect_matcher, control_matcher)); |
| 2177 | } |
| 2178 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 2179 | Matcher<Node*> IsStackSlot(const Matcher<MachineRepresentation>& rep_matcher) { |
| 2180 | return MakeMatcher(new IsStackSlotMatcher(rep_matcher)); |
| 2181 | } |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 2182 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2183 | Matcher<Node*> IsToNumber(const Matcher<Node*>& base_matcher, |
| 2184 | const Matcher<Node*>& context_matcher, |
| 2185 | const Matcher<Node*>& effect_matcher, |
| 2186 | const Matcher<Node*>& control_matcher) { |
| 2187 | return MakeMatcher(new IsToNumberMatcher(base_matcher, context_matcher, |
| 2188 | effect_matcher, control_matcher)); |
| 2189 | } |
| 2190 | |
| 2191 | |
| 2192 | Matcher<Node*> IsLoadContext(const Matcher<ContextAccess>& access_matcher, |
| 2193 | const Matcher<Node*>& context_matcher) { |
| 2194 | return MakeMatcher(new IsLoadContextMatcher(access_matcher, context_matcher)); |
| 2195 | } |
| 2196 | |
| 2197 | |
| 2198 | Matcher<Node*> IsParameter(const Matcher<int> index_matcher) { |
| 2199 | return MakeMatcher(new IsParameterMatcher(index_matcher)); |
| 2200 | } |
| 2201 | |
| 2202 | |
| 2203 | Matcher<Node*> IsLoadFramePointer() { |
| 2204 | return MakeMatcher(new NodeMatcher(IrOpcode::kLoadFramePointer)); |
| 2205 | } |
| 2206 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 2207 | #define IS_QUADOP_MATCHER(Name) \ |
| 2208 | Matcher<Node*> Is##Name( \ |
| 2209 | const Matcher<Node*>& a_matcher, const Matcher<Node*>& b_matcher, \ |
| 2210 | const Matcher<Node*>& c_matcher, const Matcher<Node*>& d_matcher) { \ |
| 2211 | return MakeMatcher(new IsQuadopMatcher(IrOpcode::k##Name, a_matcher, \ |
| 2212 | b_matcher, c_matcher, d_matcher)); \ |
| 2213 | } |
| 2214 | |
| 2215 | IS_QUADOP_MATCHER(Int32PairAdd) |
| 2216 | IS_QUADOP_MATCHER(Int32PairSub) |
| 2217 | IS_QUADOP_MATCHER(Int32PairMul) |
| 2218 | |
| 2219 | #define IS_TERNOP_MATCHER(Name) \ |
| 2220 | Matcher<Node*> Is##Name(const Matcher<Node*>& lhs_matcher, \ |
| 2221 | const Matcher<Node*>& mid_matcher, \ |
| 2222 | const Matcher<Node*>& rhs_matcher) { \ |
| 2223 | return MakeMatcher(new IsTernopMatcher(IrOpcode::k##Name, lhs_matcher, \ |
| 2224 | mid_matcher, rhs_matcher)); \ |
| 2225 | } |
| 2226 | |
| 2227 | IS_TERNOP_MATCHER(Word32PairShl) |
| 2228 | IS_TERNOP_MATCHER(Word32PairShr) |
| 2229 | IS_TERNOP_MATCHER(Word32PairSar) |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2230 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 2231 | #define IS_BINOP_MATCHER(Name) \ |
| 2232 | Matcher<Node*> Is##Name(const Matcher<Node*>& lhs_matcher, \ |
| 2233 | const Matcher<Node*>& rhs_matcher) { \ |
| 2234 | return MakeMatcher( \ |
| 2235 | new IsBinopMatcher(IrOpcode::k##Name, lhs_matcher, rhs_matcher)); \ |
| 2236 | } |
| 2237 | IS_BINOP_MATCHER(NumberEqual) |
| 2238 | IS_BINOP_MATCHER(NumberLessThan) |
| 2239 | IS_BINOP_MATCHER(NumberSubtract) |
| 2240 | IS_BINOP_MATCHER(NumberMultiply) |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2241 | IS_BINOP_MATCHER(NumberShiftLeft) |
| 2242 | IS_BINOP_MATCHER(NumberShiftRight) |
| 2243 | IS_BINOP_MATCHER(NumberShiftRightLogical) |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 2244 | IS_BINOP_MATCHER(NumberImul) |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 2245 | IS_BINOP_MATCHER(Word32And) |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2246 | IS_BINOP_MATCHER(Word32Or) |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 2247 | IS_BINOP_MATCHER(Word32Xor) |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 2248 | IS_BINOP_MATCHER(Word32Sar) |
| 2249 | IS_BINOP_MATCHER(Word32Shl) |
| 2250 | IS_BINOP_MATCHER(Word32Shr) |
| 2251 | IS_BINOP_MATCHER(Word32Ror) |
| 2252 | IS_BINOP_MATCHER(Word32Equal) |
| 2253 | IS_BINOP_MATCHER(Word64And) |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2254 | IS_BINOP_MATCHER(Word64Or) |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 2255 | IS_BINOP_MATCHER(Word64Sar) |
| 2256 | IS_BINOP_MATCHER(Word64Shl) |
| 2257 | IS_BINOP_MATCHER(Word64Equal) |
| 2258 | IS_BINOP_MATCHER(Int32AddWithOverflow) |
| 2259 | IS_BINOP_MATCHER(Int32Add) |
| 2260 | IS_BINOP_MATCHER(Int32Sub) |
| 2261 | IS_BINOP_MATCHER(Int32Mul) |
| 2262 | IS_BINOP_MATCHER(Int32MulHigh) |
| 2263 | IS_BINOP_MATCHER(Int32LessThan) |
| 2264 | IS_BINOP_MATCHER(Uint32LessThan) |
| 2265 | IS_BINOP_MATCHER(Uint32LessThanOrEqual) |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2266 | IS_BINOP_MATCHER(Int64Add) |
| 2267 | IS_BINOP_MATCHER(Int64Sub) |
| 2268 | IS_BINOP_MATCHER(JSAdd) |
| 2269 | IS_BINOP_MATCHER(Float32Max) |
| 2270 | IS_BINOP_MATCHER(Float32Min) |
| 2271 | IS_BINOP_MATCHER(Float32Equal) |
| 2272 | IS_BINOP_MATCHER(Float32LessThan) |
| 2273 | IS_BINOP_MATCHER(Float32LessThanOrEqual) |
| 2274 | IS_BINOP_MATCHER(Float64Max) |
| 2275 | IS_BINOP_MATCHER(Float64Min) |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 2276 | IS_BINOP_MATCHER(Float64Sub) |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2277 | IS_BINOP_MATCHER(Float64InsertLowWord32) |
| 2278 | IS_BINOP_MATCHER(Float64InsertHighWord32) |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 2279 | #undef IS_BINOP_MATCHER |
| 2280 | |
| 2281 | |
| 2282 | #define IS_UNOP_MATCHER(Name) \ |
| 2283 | Matcher<Node*> Is##Name(const Matcher<Node*>& input_matcher) { \ |
| 2284 | return MakeMatcher(new IsUnopMatcher(IrOpcode::k##Name, input_matcher)); \ |
| 2285 | } |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 2286 | IS_UNOP_MATCHER(BooleanNot) |
| 2287 | IS_UNOP_MATCHER(ChangeFloat64ToInt32) |
| 2288 | IS_UNOP_MATCHER(ChangeFloat64ToUint32) |
| 2289 | IS_UNOP_MATCHER(ChangeInt32ToFloat64) |
| 2290 | IS_UNOP_MATCHER(ChangeInt32ToInt64) |
| 2291 | IS_UNOP_MATCHER(ChangeUint32ToFloat64) |
| 2292 | IS_UNOP_MATCHER(ChangeUint32ToUint64) |
| 2293 | IS_UNOP_MATCHER(TruncateFloat64ToFloat32) |
| 2294 | IS_UNOP_MATCHER(TruncateFloat64ToInt32) |
| 2295 | IS_UNOP_MATCHER(TruncateInt64ToInt32) |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2296 | IS_UNOP_MATCHER(Float32Abs) |
| 2297 | IS_UNOP_MATCHER(Float64Abs) |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 2298 | IS_UNOP_MATCHER(Float64Sqrt) |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2299 | IS_UNOP_MATCHER(Float64RoundDown) |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 2300 | IS_UNOP_MATCHER(Float64RoundTruncate) |
| 2301 | IS_UNOP_MATCHER(Float64RoundTiesAway) |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2302 | IS_UNOP_MATCHER(Float64ExtractLowWord32) |
| 2303 | IS_UNOP_MATCHER(Float64ExtractHighWord32) |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 2304 | IS_UNOP_MATCHER(NumberToInt32) |
| 2305 | IS_UNOP_MATCHER(NumberToUint32) |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 2306 | IS_UNOP_MATCHER(ObjectIsReceiver) |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 2307 | IS_UNOP_MATCHER(ObjectIsSmi) |
| 2308 | IS_UNOP_MATCHER(Word32Clz) |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 2309 | IS_UNOP_MATCHER(Word32Ctz) |
| 2310 | IS_UNOP_MATCHER(Word32Popcnt) |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 2311 | #undef IS_UNOP_MATCHER |
| 2312 | |
| 2313 | } // namespace compiler |
| 2314 | } // namespace internal |
| 2315 | } // namespace v8 |