Revision: 24729
Author: [email protected]
Date: Mon Oct 20 11:26:23 2014 UTC
Log: [turbofan] Move node matchers to separate file.
TEST=unittests
[email protected]
Review URL: https://codereview.chromium.org/639293006
https://code.google.com/p/v8/source/detail?r=24729
Added:
/branches/bleeding_edge/test/unittests/compiler/node-test-utils.cc
/branches/bleeding_edge/test/unittests/compiler/node-test-utils.h
Modified:
/branches/bleeding_edge/test/unittests/compiler/change-lowering-unittest.cc
/branches/bleeding_edge/test/unittests/compiler/graph-unittest.cc
/branches/bleeding_edge/test/unittests/compiler/graph-unittest.h
/branches/bleeding_edge/test/unittests/compiler/js-builtin-reducer-unittest.cc
/branches/bleeding_edge/test/unittests/compiler/js-typed-lowering-unittest.cc
/branches/bleeding_edge/test/unittests/compiler/machine-operator-reducer-unittest.cc
/branches/bleeding_edge/test/unittests/compiler/simplified-operator-reducer-unittest.cc
/branches/bleeding_edge/test/unittests/unittests.gyp
=======================================
--- /dev/null
+++ /branches/bleeding_edge/test/unittests/compiler/node-test-utils.cc Mon
Oct 20 11:26:23 2014 UTC
@@ -0,0 +1,898 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "test/unittests/compiler/node-test-utils.h"
+
+#include "src/compiler/node-properties-inl.h"
+#include "src/compiler/simplified-operator.h"
+
+using testing::_;
+using testing::MakeMatcher;
+using testing::MatcherInterface;
+using testing::MatchResultListener;
+using testing::StringMatchResultListener;
+
+namespace v8 {
+namespace internal {
+namespace compiler {
+
+namespace {
+
+template <typename T>
+bool PrintMatchAndExplain(const T& value, const char* value_name,
+ const Matcher<T>& value_matcher,
+ MatchResultListener* listener) {
+ StringMatchResultListener value_listener;
+ if (!value_matcher.MatchAndExplain(value, &value_listener)) {
+ *listener << "whose " << value_name << " " << value << " doesn't
match";
+ if (value_listener.str() != "") {
+ *listener << ", " << value_listener.str();
+ }
+ return false;
+ }
+ return true;
+}
+
+
+class NodeMatcher : public MatcherInterface<Node*> {
+ public:
+ explicit NodeMatcher(IrOpcode::Value opcode) : opcode_(opcode) {}
+
+ virtual void DescribeTo(std::ostream* os) const OVERRIDE {
+ *os << "is a " << IrOpcode::Mnemonic(opcode_) << " node";
+ }
+
+ virtual bool MatchAndExplain(Node* node,
+ MatchResultListener* listener) const
OVERRIDE {
+ if (node == NULL) {
+ *listener << "which is NULL";
+ return false;
+ }
+ if (node->opcode() != opcode_) {
+ *listener << "whose opcode is " << IrOpcode::Mnemonic(node->opcode())
+ << " but should have been " << IrOpcode::Mnemonic(opcode_);
+ return false;
+ }
+ return true;
+ }
+
+ private:
+ const IrOpcode::Value opcode_;
+};
+
+
+class IsBranchMatcher FINAL : public NodeMatcher {
+ public:
+ IsBranchMatcher(const Matcher<Node*>& value_matcher,
+ const Matcher<Node*>& control_matcher)
+ : NodeMatcher(IrOpcode::kBranch),
+ value_matcher_(value_matcher),
+ control_matcher_(control_matcher) {}
+
+ virtual void DescribeTo(std::ostream* os) const OVERRIDE {
+ NodeMatcher::DescribeTo(os);
+ *os << " whose value (";
+ value_matcher_.DescribeTo(os);
+ *os << ") and control (";
+ control_matcher_.DescribeTo(os);
+ *os << ")";
+ }
+
+ virtual bool MatchAndExplain(Node* node,
+ MatchResultListener* listener) const
OVERRIDE {
+ return (NodeMatcher::MatchAndExplain(node, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
+ "value", value_matcher_, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetControlInput(node),
+ "control", control_matcher_, listener));
+ }
+
+ private:
+ const Matcher<Node*> value_matcher_;
+ const Matcher<Node*> control_matcher_;
+};
+
+
+class IsMergeMatcher FINAL : public NodeMatcher {
+ public:
+ IsMergeMatcher(const Matcher<Node*>& control0_matcher,
+ const Matcher<Node*>& control1_matcher)
+ : NodeMatcher(IrOpcode::kMerge),
+ control0_matcher_(control0_matcher),
+ control1_matcher_(control1_matcher) {}
+
+ virtual void DescribeTo(std::ostream* os) const OVERRIDE {
+ NodeMatcher::DescribeTo(os);
+ *os << " whose control0 (";
+ control0_matcher_.DescribeTo(os);
+ *os << ") and control1 (";
+ control1_matcher_.DescribeTo(os);
+ *os << ")";
+ }
+
+ virtual bool MatchAndExplain(Node* node,
+ MatchResultListener* listener) const
OVERRIDE {
+ return (NodeMatcher::MatchAndExplain(node, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetControlInput(node, 0),
+ "control0", control0_matcher_, listener)
&&
+ PrintMatchAndExplain(NodeProperties::GetControlInput(node, 1),
+ "control1", control1_matcher_, listener));
+ }
+
+ private:
+ const Matcher<Node*> control0_matcher_;
+ const Matcher<Node*> control1_matcher_;
+};
+
+
+class IsControl1Matcher FINAL : public NodeMatcher {
+ public:
+ IsControl1Matcher(IrOpcode::Value opcode,
+ const Matcher<Node*>& control_matcher)
+ : NodeMatcher(opcode), control_matcher_(control_matcher) {}
+
+ virtual void DescribeTo(std::ostream* os) const OVERRIDE {
+ NodeMatcher::DescribeTo(os);
+ *os << " whose control (";
+ control_matcher_.DescribeTo(os);
+ *os << ")";
+ }
+
+ virtual bool MatchAndExplain(Node* node,
+ MatchResultListener* listener) const
OVERRIDE {
+ return (NodeMatcher::MatchAndExplain(node, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetControlInput(node),
+ "control", control_matcher_, listener));
+ }
+
+ private:
+ const Matcher<Node*> control_matcher_;
+};
+
+
+class IsFinishMatcher FINAL : public NodeMatcher {
+ public:
+ IsFinishMatcher(const Matcher<Node*>& value_matcher,
+ const Matcher<Node*>& effect_matcher)
+ : NodeMatcher(IrOpcode::kFinish),
+ value_matcher_(value_matcher),
+ effect_matcher_(effect_matcher) {}
+
+ virtual void DescribeTo(std::ostream* os) const OVERRIDE {
+ NodeMatcher::DescribeTo(os);
+ *os << " whose value (";
+ value_matcher_.DescribeTo(os);
+ *os << ") and effect (";
+ effect_matcher_.DescribeTo(os);
+ *os << ")";
+ }
+
+ virtual bool MatchAndExplain(Node* node,
+ MatchResultListener* listener) const
OVERRIDE {
+ return (NodeMatcher::MatchAndExplain(node, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
+ "value", value_matcher_, listener) &&
+
PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
+ effect_matcher_, listener));
+ }
+
+ private:
+ const Matcher<Node*> value_matcher_;
+ const Matcher<Node*> effect_matcher_;
+};
+
+
+template <typename T>
+class IsConstantMatcher FINAL : public NodeMatcher {
+ public:
+ IsConstantMatcher(IrOpcode::Value opcode, const Matcher<T>&
value_matcher)
+ : NodeMatcher(opcode), value_matcher_(value_matcher) {}
+
+ virtual void DescribeTo(std::ostream* os) const OVERRIDE {
+ NodeMatcher::DescribeTo(os);
+ *os << " whose value (";
+ value_matcher_.DescribeTo(os);
+ *os << ")";
+ }
+
+ virtual bool MatchAndExplain(Node* node,
+ MatchResultListener* listener) const
OVERRIDE {
+ return (NodeMatcher::MatchAndExplain(node, listener) &&
+ PrintMatchAndExplain(OpParameter<T>(node), "value",
value_matcher_,
+ listener));
+ }
+
+ private:
+ const Matcher<T> value_matcher_;
+};
+
+
+class IsPhiMatcher FINAL : public NodeMatcher {
+ public:
+ IsPhiMatcher(const Matcher<MachineType>& type_matcher,
+ const Matcher<Node*>& value0_matcher,
+ const Matcher<Node*>& value1_matcher,
+ const Matcher<Node*>& control_matcher)
+ : NodeMatcher(IrOpcode::kPhi),
+ type_matcher_(type_matcher),
+ value0_matcher_(value0_matcher),
+ value1_matcher_(value1_matcher),
+ control_matcher_(control_matcher) {}
+
+ virtual void DescribeTo(std::ostream* os) const OVERRIDE {
+ NodeMatcher::DescribeTo(os);
+ *os << " whose type (";
+ type_matcher_.DescribeTo(os);
+ *os << "), value0 (";
+ value0_matcher_.DescribeTo(os);
+ *os << "), value1 (";
+ value1_matcher_.DescribeTo(os);
+ *os << ") and control (";
+ control_matcher_.DescribeTo(os);
+ *os << ")";
+ }
+
+ virtual bool MatchAndExplain(Node* node,
+ MatchResultListener* listener) const
OVERRIDE {
+ return (NodeMatcher::MatchAndExplain(node, listener) &&
+ PrintMatchAndExplain(OpParameter<MachineType>(node), "type",
+ type_matcher_, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
+ "value0", value0_matcher_, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
+ "value1", value1_matcher_, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetControlInput(node),
+ "control", control_matcher_, listener));
+ }
+
+ private:
+ const Matcher<MachineType> type_matcher_;
+ const Matcher<Node*> value0_matcher_;
+ const Matcher<Node*> value1_matcher_;
+ const Matcher<Node*> control_matcher_;
+};
+
+
+class IsProjectionMatcher FINAL : public NodeMatcher {
+ public:
+ IsProjectionMatcher(const Matcher<size_t>& index_matcher,
+ const Matcher<Node*>& base_matcher)
+ : NodeMatcher(IrOpcode::kProjection),
+ index_matcher_(index_matcher),
+ base_matcher_(base_matcher) {}
+
+ virtual void DescribeTo(std::ostream* os) const OVERRIDE {
+ NodeMatcher::DescribeTo(os);
+ *os << " whose index (";
+ index_matcher_.DescribeTo(os);
+ *os << ") and base (";
+ base_matcher_.DescribeTo(os);
+ *os << ")";
+ }
+
+ virtual bool MatchAndExplain(Node* node,
+ MatchResultListener* listener) const
OVERRIDE {
+ return (NodeMatcher::MatchAndExplain(node, listener) &&
+ PrintMatchAndExplain(OpParameter<size_t>(node), "index",
+ index_matcher_, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetValueInput(node,
0), "base",
+ base_matcher_, listener));
+ }
+
+ private:
+ const Matcher<size_t> index_matcher_;
+ const Matcher<Node*> base_matcher_;
+};
+
+
+class IsCallMatcher FINAL : public NodeMatcher {
+ public:
+ IsCallMatcher(const Matcher<CallDescriptor*>& descriptor_matcher,
+ const Matcher<Node*>& value0_matcher,
+ const Matcher<Node*>& value1_matcher,
+ const Matcher<Node*>& value2_matcher,
+ const Matcher<Node*>& value3_matcher,
+ const Matcher<Node*>& effect_matcher,
+ const Matcher<Node*>& control_matcher)
+ : NodeMatcher(IrOpcode::kCall),
+ descriptor_matcher_(descriptor_matcher),
+ value0_matcher_(value0_matcher),
+ value1_matcher_(value1_matcher),
+ value2_matcher_(value2_matcher),
+ value3_matcher_(value3_matcher),
+ effect_matcher_(effect_matcher),
+ control_matcher_(control_matcher) {}
+
+ virtual void DescribeTo(std::ostream* os) const OVERRIDE {
+ NodeMatcher::DescribeTo(os);
+ *os << " whose value0 (";
+ value0_matcher_.DescribeTo(os);
+ *os << ") and value1 (";
+ value1_matcher_.DescribeTo(os);
+ *os << ") and value2 (";
+ value2_matcher_.DescribeTo(os);
+ *os << ") and value3 (";
+ value3_matcher_.DescribeTo(os);
+ *os << ") and effect (";
+ effect_matcher_.DescribeTo(os);
+ *os << ") and control (";
+ control_matcher_.DescribeTo(os);
+ *os << ")";
+ }
+
+ virtual bool MatchAndExplain(Node* node,
+ MatchResultListener* listener) const
OVERRIDE {
+ return (NodeMatcher::MatchAndExplain(node, listener) &&
+ PrintMatchAndExplain(OpParameter<CallDescriptor*>(node),
+ "descriptor", descriptor_matcher_,
listener) &&
+ PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
+ "value0", value0_matcher_, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
+ "value1", value1_matcher_, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2),
+ "value2", value2_matcher_, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetValueInput(node, 3),
+ "value3", value3_matcher_, listener) &&
+
PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
+ effect_matcher_, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetControlInput(node),
+ "control", control_matcher_, listener));
+ }
+
+ private:
+ const Matcher<CallDescriptor*> descriptor_matcher_;
+ const Matcher<Node*> value0_matcher_;
+ const Matcher<Node*> value1_matcher_;
+ const Matcher<Node*> value2_matcher_;
+ const Matcher<Node*> value3_matcher_;
+ const Matcher<Node*> effect_matcher_;
+ const Matcher<Node*> control_matcher_;
+};
+
+
+class IsLoadFieldMatcher FINAL : public NodeMatcher {
+ public:
+ IsLoadFieldMatcher(const Matcher<FieldAccess>& access_matcher,
+ const Matcher<Node*>& base_matcher,
+ const Matcher<Node*>& effect_matcher)
+ : NodeMatcher(IrOpcode::kLoadField),
+ access_matcher_(access_matcher),
+ base_matcher_(base_matcher),
+ effect_matcher_(effect_matcher) {}
+
+ virtual void DescribeTo(std::ostream* os) const OVERRIDE {
+ NodeMatcher::DescribeTo(os);
+ *os << " whose access (";
+ access_matcher_.DescribeTo(os);
+ *os << "), base (";
+ base_matcher_.DescribeTo(os);
+ *os << ") and effect (";
+ effect_matcher_.DescribeTo(os);
+ *os << ")";
+ }
+
+ virtual bool MatchAndExplain(Node* node,
+ MatchResultListener* listener) const
OVERRIDE {
+ return (NodeMatcher::MatchAndExplain(node, listener) &&
+ PrintMatchAndExplain(OpParameter<FieldAccess>(node), "access",
+ access_matcher_, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetValueInput(node,
0), "base",
+ base_matcher_, listener) &&
+
PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
+ effect_matcher_, listener));
+ }
+
+ private:
+ const Matcher<FieldAccess> access_matcher_;
+ const Matcher<Node*> base_matcher_;
+ const Matcher<Node*> effect_matcher_;
+};
+
+
+class IsLoadElementMatcher FINAL : public NodeMatcher {
+ public:
+ IsLoadElementMatcher(const Matcher<ElementAccess>& access_matcher,
+ const Matcher<Node*>& base_matcher,
+ const Matcher<Node*>& index_matcher,
+ const Matcher<Node*>& length_matcher,
+ const Matcher<Node*>& effect_matcher,
+ const Matcher<Node*>& control_matcher)
+ : NodeMatcher(IrOpcode::kLoadElement),
+ access_matcher_(access_matcher),
+ base_matcher_(base_matcher),
+ index_matcher_(index_matcher),
+ length_matcher_(length_matcher),
+ effect_matcher_(effect_matcher),
+ control_matcher_(control_matcher) {}
+
+ virtual void DescribeTo(std::ostream* os) const OVERRIDE {
+ NodeMatcher::DescribeTo(os);
+ *os << " whose access (";
+ access_matcher_.DescribeTo(os);
+ *os << "), base (";
+ base_matcher_.DescribeTo(os);
+ *os << "), index (";
+ index_matcher_.DescribeTo(os);
+ *os << "), length (";
+ length_matcher_.DescribeTo(os);
+ *os << "), effect (";
+ effect_matcher_.DescribeTo(os);
+ *os << ") and control (";
+ control_matcher_.DescribeTo(os);
+ *os << ")";
+ }
+
+ virtual bool MatchAndExplain(Node* node,
+ MatchResultListener* listener) const
OVERRIDE {
+ return (NodeMatcher::MatchAndExplain(node, listener) &&
+
PrintMatchAndExplain(OpParameter<ElementAccess>(node), "access",
+ access_matcher_, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetValueInput(node,
0), "base",
+ base_matcher_, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
+ "index", index_matcher_, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2),
+ "length", length_matcher_, listener) &&
+
PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
+ effect_matcher_, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetControlInput(node),
+ "control", control_matcher_, listener));
+ }
+
+ private:
+ const Matcher<ElementAccess> access_matcher_;
+ const Matcher<Node*> base_matcher_;
+ const Matcher<Node*> index_matcher_;
+ const Matcher<Node*> length_matcher_;
+ const Matcher<Node*> effect_matcher_;
+ const Matcher<Node*> control_matcher_;
+};
+
+
+class IsStoreElementMatcher FINAL : public NodeMatcher {
+ public:
+ IsStoreElementMatcher(const Matcher<ElementAccess>& access_matcher,
+ const Matcher<Node*>& base_matcher,
+ const Matcher<Node*>& index_matcher,
+ const Matcher<Node*>& length_matcher,
+ const Matcher<Node*>& value_matcher,
+ const Matcher<Node*>& effect_matcher,
+ const Matcher<Node*>& control_matcher)
+ : NodeMatcher(IrOpcode::kStoreElement),
+ access_matcher_(access_matcher),
+ base_matcher_(base_matcher),
+ index_matcher_(index_matcher),
+ length_matcher_(length_matcher),
+ value_matcher_(value_matcher),
+ effect_matcher_(effect_matcher),
+ control_matcher_(control_matcher) {}
+
+ virtual void DescribeTo(std::ostream* os) const OVERRIDE {
+ NodeMatcher::DescribeTo(os);
+ *os << " whose access (";
+ access_matcher_.DescribeTo(os);
+ *os << "), base (";
+ base_matcher_.DescribeTo(os);
+ *os << "), index (";
+ index_matcher_.DescribeTo(os);
+ *os << "), length (";
+ length_matcher_.DescribeTo(os);
+ *os << "), value (";
+ value_matcher_.DescribeTo(os);
+ *os << "), effect (";
+ effect_matcher_.DescribeTo(os);
+ *os << ") and control (";
+ control_matcher_.DescribeTo(os);
+ *os << ")";
+ }
+
+ virtual bool MatchAndExplain(Node* node,
+ MatchResultListener* listener) const
OVERRIDE {
+ return (NodeMatcher::MatchAndExplain(node, listener) &&
+
PrintMatchAndExplain(OpParameter<ElementAccess>(node), "access",
+ access_matcher_, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetValueInput(node,
0), "base",
+ base_matcher_, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
+ "index", index_matcher_, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2),
+ "length", length_matcher_, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetValueInput(node, 3),
+ "value", value_matcher_, listener) &&
+
PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
+ effect_matcher_, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetControlInput(node),
+ "control", control_matcher_, listener));
+ }
+
+ private:
+ const Matcher<ElementAccess> access_matcher_;
+ const Matcher<Node*> base_matcher_;
+ const Matcher<Node*> index_matcher_;
+ const Matcher<Node*> length_matcher_;
+ const Matcher<Node*> value_matcher_;
+ const Matcher<Node*> effect_matcher_;
+ const Matcher<Node*> control_matcher_;
+};
+
+
+class IsLoadMatcher FINAL : public NodeMatcher {
+ public:
+ IsLoadMatcher(const Matcher<LoadRepresentation>& rep_matcher,
+ const Matcher<Node*>& base_matcher,
+ const Matcher<Node*>& index_matcher,
+ const Matcher<Node*>& effect_matcher,
+ const Matcher<Node*>& control_matcher)
+ : NodeMatcher(IrOpcode::kLoad),
+ rep_matcher_(rep_matcher),
+ base_matcher_(base_matcher),
+ index_matcher_(index_matcher),
+ effect_matcher_(effect_matcher),
+ control_matcher_(control_matcher) {}
+
+ virtual void DescribeTo(std::ostream* os) const OVERRIDE {
+ NodeMatcher::DescribeTo(os);
+ *os << " whose rep (";
+ rep_matcher_.DescribeTo(os);
+ *os << "), base (";
+ base_matcher_.DescribeTo(os);
+ *os << "), index (";
+ index_matcher_.DescribeTo(os);
+ *os << "), effect (";
+ effect_matcher_.DescribeTo(os);
+ *os << ") and control (";
+ control_matcher_.DescribeTo(os);
+ *os << ")";
+ }
+
+ virtual bool MatchAndExplain(Node* node,
+ MatchResultListener* listener) const
OVERRIDE {
+ return (NodeMatcher::MatchAndExplain(node, listener) &&
+
PrintMatchAndExplain(OpParameter<LoadRepresentation>(node), "rep",
+ rep_matcher_, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetValueInput(node,
0), "base",
+ base_matcher_, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
+ "index", index_matcher_, listener) &&
+
PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
+ effect_matcher_, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetControlInput(node),
+ "control", control_matcher_, listener));
+ }
+
+ private:
+ const Matcher<LoadRepresentation> rep_matcher_;
+ const Matcher<Node*> base_matcher_;
+ const Matcher<Node*> index_matcher_;
+ const Matcher<Node*> effect_matcher_;
+ const Matcher<Node*> control_matcher_;
+};
+
+
+class IsStoreMatcher FINAL : public NodeMatcher {
+ public:
+ IsStoreMatcher(const Matcher<StoreRepresentation>& rep_matcher,
+ const Matcher<Node*>& base_matcher,
+ const Matcher<Node*>& index_matcher,
+ const Matcher<Node*>& value_matcher,
+ const Matcher<Node*>& effect_matcher,
+ const Matcher<Node*>& control_matcher)
+ : NodeMatcher(IrOpcode::kStore),
+ rep_matcher_(rep_matcher),
+ base_matcher_(base_matcher),
+ index_matcher_(index_matcher),
+ value_matcher_(value_matcher),
+ effect_matcher_(effect_matcher),
+ control_matcher_(control_matcher) {}
+
+ virtual void DescribeTo(std::ostream* os) const OVERRIDE {
+ NodeMatcher::DescribeTo(os);
+ *os << " whose rep (";
+ rep_matcher_.DescribeTo(os);
+ *os << "), base (";
+ base_matcher_.DescribeTo(os);
+ *os << "), index (";
+ index_matcher_.DescribeTo(os);
+ *os << "), value (";
+ value_matcher_.DescribeTo(os);
+ *os << "), effect (";
+ effect_matcher_.DescribeTo(os);
+ *os << ") and control (";
+ control_matcher_.DescribeTo(os);
+ *os << ")";
+ }
+
+ virtual bool MatchAndExplain(Node* node,
+ MatchResultListener* listener) const
OVERRIDE {
+ return (NodeMatcher::MatchAndExplain(node, listener) &&
+
PrintMatchAndExplain(OpParameter<StoreRepresentation>(node), "rep",
+ rep_matcher_, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetValueInput(node,
0), "base",
+ base_matcher_, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
+ "index", index_matcher_, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2),
+ "value", value_matcher_, listener) &&
+
PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
+ effect_matcher_, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetControlInput(node),
+ "control", control_matcher_, listener));
+ }
+
+ private:
+ const Matcher<StoreRepresentation> rep_matcher_;
+ const Matcher<Node*> base_matcher_;
+ const Matcher<Node*> index_matcher_;
+ const Matcher<Node*> value_matcher_;
+ const Matcher<Node*> effect_matcher_;
+ const Matcher<Node*> control_matcher_;
+};
+
+
+class IsBinopMatcher FINAL : public NodeMatcher {
+ public:
+ IsBinopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& lhs_matcher,
+ const Matcher<Node*>& rhs_matcher)
+ : NodeMatcher(opcode),
+ lhs_matcher_(lhs_matcher),
+ rhs_matcher_(rhs_matcher) {}
+
+ virtual void DescribeTo(std::ostream* os) const OVERRIDE {
+ NodeMatcher::DescribeTo(os);
+ *os << " whose lhs (";
+ lhs_matcher_.DescribeTo(os);
+ *os << ") and rhs (";
+ rhs_matcher_.DescribeTo(os);
+ *os << ")";
+ }
+
+ virtual bool MatchAndExplain(Node* node,
+ MatchResultListener* listener) const
OVERRIDE {
+ return (NodeMatcher::MatchAndExplain(node, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetValueInput(node,
0), "lhs",
+ lhs_matcher_, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetValueInput(node,
1), "rhs",
+ rhs_matcher_, listener));
+ }
+
+ private:
+ const Matcher<Node*> lhs_matcher_;
+ const Matcher<Node*> rhs_matcher_;
+};
+
+
+class IsUnopMatcher FINAL : public NodeMatcher {
+ public:
+ IsUnopMatcher(IrOpcode::Value opcode, const Matcher<Node*>&
input_matcher)
+ : NodeMatcher(opcode), input_matcher_(input_matcher) {}
+
+ virtual void DescribeTo(std::ostream* os) const OVERRIDE {
+ NodeMatcher::DescribeTo(os);
+ *os << " whose input (";
+ input_matcher_.DescribeTo(os);
+ *os << ")";
+ }
+
+ virtual bool MatchAndExplain(Node* node,
+ MatchResultListener* listener) const
OVERRIDE {
+ return (NodeMatcher::MatchAndExplain(node, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
+ "input", input_matcher_, listener));
+ }
+
+ private:
+ const Matcher<Node*> input_matcher_;
+};
+}
+
+
+Matcher<Node*> IsBranch(const Matcher<Node*>& value_matcher,
+ const Matcher<Node*>& control_matcher) {
+ return MakeMatcher(new IsBranchMatcher(value_matcher, control_matcher));
+}
+
+
+Matcher<Node*> IsMerge(const Matcher<Node*>& control0_matcher,
+ const Matcher<Node*>& control1_matcher) {
+ return MakeMatcher(new IsMergeMatcher(control0_matcher,
control1_matcher));
+}
+
+
+Matcher<Node*> IsIfTrue(const Matcher<Node*>& control_matcher) {
+ return MakeMatcher(new IsControl1Matcher(IrOpcode::kIfTrue,
control_matcher));
+}
+
+
+Matcher<Node*> IsIfFalse(const Matcher<Node*>& control_matcher) {
+ return MakeMatcher(
+ new IsControl1Matcher(IrOpcode::kIfFalse, control_matcher));
+}
+
+
+Matcher<Node*> IsValueEffect(const Matcher<Node*>& value_matcher) {
+ return MakeMatcher(new IsUnopMatcher(IrOpcode::kValueEffect,
value_matcher));
+}
+
+
+Matcher<Node*> IsFinish(const Matcher<Node*>& value_matcher,
+ const Matcher<Node*>& effect_matcher) {
+ return MakeMatcher(new IsFinishMatcher(value_matcher, effect_matcher));
+}
+
+
+Matcher<Node*> IsExternalConstant(
+ const Matcher<ExternalReference>& value_matcher) {
+ return MakeMatcher(new IsConstantMatcher<ExternalReference>(
+ IrOpcode::kExternalConstant, value_matcher));
+}
+
+
+Matcher<Node*> IsHeapConstant(
+ const Matcher<Unique<HeapObject> >& value_matcher) {
+ return MakeMatcher(new IsConstantMatcher<Unique<HeapObject> >(
+ IrOpcode::kHeapConstant, value_matcher));
+}
+
+
+Matcher<Node*> IsInt32Constant(const Matcher<int32_t>& value_matcher) {
+ return MakeMatcher(
+ new IsConstantMatcher<int32_t>(IrOpcode::kInt32Constant,
value_matcher));
+}
+
+
+Matcher<Node*> IsInt64Constant(const Matcher<int64_t>& value_matcher) {
+ return MakeMatcher(
+ new IsConstantMatcher<int64_t>(IrOpcode::kInt64Constant,
value_matcher));
+}
+
+
+Matcher<Node*> IsFloat32Constant(const Matcher<float>& value_matcher) {
+ return MakeMatcher(
+ new IsConstantMatcher<float>(IrOpcode::kFloat32Constant,
value_matcher));
+}
+
+
+Matcher<Node*> IsFloat64Constant(const Matcher<double>& value_matcher) {
+ return MakeMatcher(
+ new IsConstantMatcher<double>(IrOpcode::kFloat64Constant,
value_matcher));
+}
+
+
+Matcher<Node*> IsNumberConstant(const Matcher<double>& value_matcher) {
+ return MakeMatcher(
+ new IsConstantMatcher<double>(IrOpcode::kNumberConstant,
value_matcher));
+}
+
+
+Matcher<Node*> IsPhi(const Matcher<MachineType>& type_matcher,
+ const Matcher<Node*>& value0_matcher,
+ const Matcher<Node*>& value1_matcher,
+ const Matcher<Node*>& merge_matcher) {
+ return MakeMatcher(new IsPhiMatcher(type_matcher, value0_matcher,
+ value1_matcher, merge_matcher));
+}
+
+
+Matcher<Node*> IsProjection(const Matcher<size_t>& index_matcher,
+ const Matcher<Node*>& base_matcher) {
+ return MakeMatcher(new IsProjectionMatcher(index_matcher, base_matcher));
+}
+
+
+Matcher<Node*> IsCall(const Matcher<CallDescriptor*>& descriptor_matcher,
+ const Matcher<Node*>& value0_matcher,
+ const Matcher<Node*>& value1_matcher,
+ const Matcher<Node*>& value2_matcher,
+ const Matcher<Node*>& value3_matcher,
+ const Matcher<Node*>& effect_matcher,
+ const Matcher<Node*>& control_matcher) {
+ return MakeMatcher(new IsCallMatcher(
+ descriptor_matcher, value0_matcher, value1_matcher, value2_matcher,
+ value3_matcher, effect_matcher, control_matcher));
+}
+
+
+Matcher<Node*> IsLoadField(const Matcher<FieldAccess>& access_matcher,
+ const Matcher<Node*>& base_matcher,
+ const Matcher<Node*>& effect_matcher) {
+ return MakeMatcher(
+ new IsLoadFieldMatcher(access_matcher, base_matcher,
effect_matcher));
+}
+
+
+Matcher<Node*> IsLoadElement(const Matcher<ElementAccess>& access_matcher,
+ const Matcher<Node*>& base_matcher,
+ const Matcher<Node*>& index_matcher,
+ const Matcher<Node*>& length_matcher,
+ const Matcher<Node*>& effect_matcher,
+ const Matcher<Node*>& control_matcher) {
+ return MakeMatcher(new IsLoadElementMatcher(access_matcher, base_matcher,
+ index_matcher,
length_matcher,
+ effect_matcher,
control_matcher));
+}
+
+
+Matcher<Node*> IsStoreElement(const Matcher<ElementAccess>& access_matcher,
+ const Matcher<Node*>& base_matcher,
+ const Matcher<Node*>& index_matcher,
+ const Matcher<Node*>& length_matcher,
+ const Matcher<Node*>& value_matcher,
+ const Matcher<Node*>& effect_matcher,
+ const Matcher<Node*>& control_matcher) {
+ return MakeMatcher(new IsStoreElementMatcher(
+ access_matcher, base_matcher, index_matcher, length_matcher,
+ value_matcher, effect_matcher, control_matcher));
+}
+
+
+Matcher<Node*> IsLoad(const Matcher<LoadRepresentation>& rep_matcher,
+ const Matcher<Node*>& base_matcher,
+ const Matcher<Node*>& index_matcher,
+ const Matcher<Node*>& effect_matcher,
+ const Matcher<Node*>& control_matcher) {
+ return MakeMatcher(new IsLoadMatcher(rep_matcher, base_matcher,
index_matcher,
+ effect_matcher, control_matcher));
+}
+
+
+Matcher<Node*> IsStore(const Matcher<StoreRepresentation>& rep_matcher,
+ const Matcher<Node*>& base_matcher,
+ const Matcher<Node*>& index_matcher,
+ const Matcher<Node*>& value_matcher,
+ const Matcher<Node*>& effect_matcher,
+ const Matcher<Node*>& control_matcher) {
+ return MakeMatcher(new IsStoreMatcher(rep_matcher, base_matcher,
+ index_matcher, value_matcher,
+ effect_matcher, control_matcher));
+}
+
+
+#define IS_BINOP_MATCHER(Name) \
+ Matcher<Node*> Is##Name(const Matcher<Node*>& lhs_matcher, \
+ const Matcher<Node*>& rhs_matcher) { \
+ return MakeMatcher( \
+ new IsBinopMatcher(IrOpcode::k##Name, lhs_matcher, rhs_matcher)); \
+ }
+IS_BINOP_MATCHER(NumberLessThan)
+IS_BINOP_MATCHER(NumberSubtract)
+IS_BINOP_MATCHER(Word32And)
+IS_BINOP_MATCHER(Word32Sar)
+IS_BINOP_MATCHER(Word32Shl)
+IS_BINOP_MATCHER(Word32Shr)
+IS_BINOP_MATCHER(Word32Ror)
+IS_BINOP_MATCHER(Word32Equal)
+IS_BINOP_MATCHER(Word64And)
+IS_BINOP_MATCHER(Word64Sar)
+IS_BINOP_MATCHER(Word64Shl)
+IS_BINOP_MATCHER(Word64Equal)
+IS_BINOP_MATCHER(Int32AddWithOverflow)
+IS_BINOP_MATCHER(Int32Add)
+IS_BINOP_MATCHER(Int32Sub)
+IS_BINOP_MATCHER(Int32Mul)
+IS_BINOP_MATCHER(Int32MulHigh)
+IS_BINOP_MATCHER(Int32LessThan)
+IS_BINOP_MATCHER(Uint32LessThan)
+IS_BINOP_MATCHER(Uint32LessThanOrEqual)
+#undef IS_BINOP_MATCHER
+
+
+#define
IS_UNOP_MATCHER(Name) \
+ Matcher<Node*> Is##Name(const Matcher<Node*>& input_matcher)
{ \
+ return MakeMatcher(new IsUnopMatcher(IrOpcode::k##Name,
input_matcher)); \
+ }
+IS_UNOP_MATCHER(ChangeFloat64ToInt32)
+IS_UNOP_MATCHER(ChangeFloat64ToUint32)
+IS_UNOP_MATCHER(ChangeInt32ToFloat64)
+IS_UNOP_MATCHER(ChangeInt32ToInt64)
+IS_UNOP_MATCHER(ChangeUint32ToFloat64)
+IS_UNOP_MATCHER(ChangeUint32ToUint64)
+IS_UNOP_MATCHER(TruncateFloat64ToFloat32)
+IS_UNOP_MATCHER(TruncateFloat64ToInt32)
+IS_UNOP_MATCHER(TruncateInt64ToInt32)
+IS_UNOP_MATCHER(Float64Sqrt)
+#undef IS_UNOP_MATCHER
+
+} // namespace compiler
+} // namespace internal
+} // namespace v8
=======================================
--- /dev/null
+++ /branches/bleeding_edge/test/unittests/compiler/node-test-utils.h Mon
Oct 20 11:26:23 2014 UTC
@@ -0,0 +1,148 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef V8_UNITTESTS_COMPILER_NODE_TEST_UTILS_H_
+#define V8_UNITTESTS_COMPILER_NODE_TEST_UTILS_H_
+
+#include "src/compiler/machine-operator.h"
+#include "src/compiler/machine-type.h"
+#include "testing/gmock/include/gmock/gmock.h"
+
+namespace v8 {
+namespace internal {
+
+// Forward declarations.
+class ExternalReference;
+class HeapObject;
+template <class T>
+class Unique;
+
+namespace compiler {
+
+// Forward declarations.
+class CallDescriptor;
+struct ElementAccess;
+struct FieldAccess;
+class Node;
+
+
+using ::testing::Matcher;
+
+
+Matcher<Node*> IsBranch(const Matcher<Node*>& value_matcher,
+ const Matcher<Node*>& control_matcher);
+Matcher<Node*> IsMerge(const Matcher<Node*>& control0_matcher,
+ const Matcher<Node*>& control1_matcher);
+Matcher<Node*> IsIfTrue(const Matcher<Node*>& control_matcher);
+Matcher<Node*> IsIfFalse(const Matcher<Node*>& control_matcher);
+Matcher<Node*> IsValueEffect(const Matcher<Node*>& value_matcher);
+Matcher<Node*> IsFinish(const Matcher<Node*>& value_matcher,
+ const Matcher<Node*>& effect_matcher);
+Matcher<Node*> IsExternalConstant(
+ const Matcher<ExternalReference>& value_matcher);
+Matcher<Node*> IsHeapConstant(
+ const Matcher<Unique<HeapObject> >& value_matcher);
+Matcher<Node*> IsFloat32Constant(const Matcher<float>& value_matcher);
+Matcher<Node*> IsFloat64Constant(const Matcher<double>& value_matcher);
+Matcher<Node*> IsInt32Constant(const Matcher<int32_t>& value_matcher);
+Matcher<Node*> IsInt64Constant(const Matcher<int64_t>& value_matcher);
+Matcher<Node*> IsNumberConstant(const Matcher<double>& value_matcher);
+Matcher<Node*> IsPhi(const Matcher<MachineType>& type_matcher,
+ const Matcher<Node*>& value0_matcher,
+ const Matcher<Node*>& value1_matcher,
+ const Matcher<Node*>& merge_matcher);
+Matcher<Node*> IsProjection(const Matcher<size_t>& index_matcher,
+ const Matcher<Node*>& base_matcher);
+Matcher<Node*> IsCall(const Matcher<CallDescriptor*>& descriptor_matcher,
+ const Matcher<Node*>& value0_matcher,
+ const Matcher<Node*>& value1_matcher,
+ const Matcher<Node*>& value2_matcher,
+ const Matcher<Node*>& value3_matcher,
+ const Matcher<Node*>& effect_matcher,
+ const Matcher<Node*>& control_matcher);
+
+Matcher<Node*> IsNumberLessThan(const Matcher<Node*>& lhs_matcher,
+ const Matcher<Node*>& rhs_matcher);
+Matcher<Node*> IsNumberSubtract(const Matcher<Node*>& lhs_matcher,
+ const Matcher<Node*>& rhs_matcher);
+Matcher<Node*> IsLoadField(const Matcher<FieldAccess>& access_matcher,
+ const Matcher<Node*>& base_matcher,
+ const Matcher<Node*>& effect_matcher);
+Matcher<Node*> IsLoadElement(const Matcher<ElementAccess>& access_matcher,
+ const Matcher<Node*>& base_matcher,
+ const Matcher<Node*>& index_matcher,
+ const Matcher<Node*>& length_matcher,
+ const Matcher<Node*>& effect_matcher,
+ const Matcher<Node*>& control_matcher);
+Matcher<Node*> IsStoreElement(const Matcher<ElementAccess>& access_matcher,
+ const Matcher<Node*>& base_matcher,
+ const Matcher<Node*>& index_matcher,
+ const Matcher<Node*>& length_matcher,
+ const Matcher<Node*>& value_matcher,
+ const Matcher<Node*>& effect_matcher,
+ const Matcher<Node*>& control_matcher);
+
+Matcher<Node*> IsLoad(const Matcher<LoadRepresentation>& rep_matcher,
+ const Matcher<Node*>& base_matcher,
+ const Matcher<Node*>& index_matcher,
+ const Matcher<Node*>& effect_matcher,
+ const Matcher<Node*>& control_matcher);
+Matcher<Node*> IsStore(const Matcher<StoreRepresentation>& rep_matcher,
+ const Matcher<Node*>& base_matcher,
+ const Matcher<Node*>& index_matcher,
+ const Matcher<Node*>& value_matcher,
+ const Matcher<Node*>& effect_matcher,
+ const Matcher<Node*>& control_matcher);
+Matcher<Node*> IsWord32And(const Matcher<Node*>& lhs_matcher,
+ const Matcher<Node*>& rhs_matcher);
+Matcher<Node*> IsWord32Sar(const Matcher<Node*>& lhs_matcher,
+ const Matcher<Node*>& rhs_matcher);
+Matcher<Node*> IsWord32Shl(const Matcher<Node*>& lhs_matcher,
+ const Matcher<Node*>& rhs_matcher);
+Matcher<Node*> IsWord32Shr(const Matcher<Node*>& lhs_matcher,
+ const Matcher<Node*>& rhs_matcher);
+Matcher<Node*> IsWord32Ror(const Matcher<Node*>& lhs_matcher,
+ const Matcher<Node*>& rhs_matcher);
+Matcher<Node*> IsWord32Equal(const Matcher<Node*>& lhs_matcher,
+ const Matcher<Node*>& rhs_matcher);
+Matcher<Node*> IsWord64And(const Matcher<Node*>& lhs_matcher,
+ const Matcher<Node*>& rhs_matcher);
+Matcher<Node*> IsWord64Shl(const Matcher<Node*>& lhs_matcher,
+ const Matcher<Node*>& rhs_matcher);
+Matcher<Node*> IsWord64Sar(const Matcher<Node*>& lhs_matcher,
+ const Matcher<Node*>& rhs_matcher);
+Matcher<Node*> IsWord64Equal(const Matcher<Node*>& lhs_matcher,
+ const Matcher<Node*>& rhs_matcher);
+Matcher<Node*> IsInt32AddWithOverflow(const Matcher<Node*>& lhs_matcher,
+ const Matcher<Node*>& rhs_matcher);
+Matcher<Node*> IsInt32Add(const Matcher<Node*>& lhs_matcher,
+ const Matcher<Node*>& rhs_matcher);
+Matcher<Node*> IsInt32Sub(const Matcher<Node*>& lhs_matcher,
+ const Matcher<Node*>& rhs_matcher);
+Matcher<Node*> IsInt32Mul(const Matcher<Node*>& lhs_matcher,
+ const Matcher<Node*>& rhs_matcher);
+Matcher<Node*> IsInt32MulHigh(const Matcher<Node*>& lhs_matcher,
+ const Matcher<Node*>& rhs_matcher);
+Matcher<Node*> IsInt32LessThan(const Matcher<Node*>& lhs_matcher,
+ const Matcher<Node*>& rhs_matcher);
+Matcher<Node*> IsUint32LessThan(const Matcher<Node*>& lhs_matcher,
+ const Matcher<Node*>& rhs_matcher);
+Matcher<Node*> IsUint32LessThanOrEqual(const Matcher<Node*>& lhs_matcher,
+ const Matcher<Node*>& rhs_matcher);
+Matcher<Node*> IsChangeFloat64ToInt32(const Matcher<Node*>& input_matcher);
+Matcher<Node*> IsChangeFloat64ToUint32(const Matcher<Node*>&
input_matcher);
+Matcher<Node*> IsChangeInt32ToFloat64(const Matcher<Node*>& input_matcher);
+Matcher<Node*> IsChangeInt32ToInt64(const Matcher<Node*>& input_matcher);
+Matcher<Node*> IsChangeUint32ToFloat64(const Matcher<Node*>&
input_matcher);
+Matcher<Node*> IsChangeUint32ToUint64(const Matcher<Node*>& input_matcher);
+Matcher<Node*> IsTruncateFloat64ToFloat32(const Matcher<Node*>&
input_matcher);
+Matcher<Node*> IsTruncateFloat64ToInt32(const Matcher<Node*>&
input_matcher);
+Matcher<Node*> IsTruncateInt64ToInt32(const Matcher<Node*>& input_matcher);
+Matcher<Node*> IsFloat64Sqrt(const Matcher<Node*>& input_matcher);
+
+} // namespace compiler
+} // namespace internal
+} // namespace v8
+
+#endif // V8_UNITTESTS_COMPILER_NODE_TEST_UTILS_H_
=======================================
---
/branches/bleeding_edge/test/unittests/compiler/change-lowering-unittest.cc
Wed Oct 15 11:38:04 2014 UTC
+++
/branches/bleeding_edge/test/unittests/compiler/change-lowering-unittest.cc
Mon Oct 20 11:26:23 2014 UTC
@@ -8,6 +8,7 @@
#include "src/compiler/simplified-operator.h"
#include "test/unittests/compiler/compiler-test-utils.h"
#include "test/unittests/compiler/graph-unittest.h"
+#include "test/unittests/compiler/node-test-utils.h"
#include "testing/gmock-support.h"
using testing::_;
=======================================
--- /branches/bleeding_edge/test/unittests/compiler/graph-unittest.cc Tue
Oct 14 11:57:06 2014 UTC
+++ /branches/bleeding_edge/test/unittests/compiler/graph-unittest.cc Mon
Oct 20 11:26:23 2014 UTC
@@ -7,13 +7,7 @@
#include <ostream> // NOLINT(readability/streams)
#include "src/compiler/node-properties-inl.h"
-#include "src/compiler/simplified-operator.h"
-
-using testing::_;
-using testing::MakeMatcher;
-using testing::MatcherInterface;
-using testing::MatchResultListener;
-using testing::StringMatchResultListener;
+#include "test/unittests/compiler/node-test-utils.h"
namespace v8 {
namespace internal {
@@ -99,882 +93,6 @@
Unique<HeapObject>::CreateImmovable(factory()->true_value()));
}
-namespace {
-
-template <typename T>
-bool PrintMatchAndExplain(const T& value, const char* value_name,
- const Matcher<T>& value_matcher,
- MatchResultListener* listener) {
- StringMatchResultListener value_listener;
- if (!value_matcher.MatchAndExplain(value, &value_listener)) {
- *listener << "whose " << value_name << " " << value << " doesn't
match";
- if (value_listener.str() != "") {
- *listener << ", " << value_listener.str();
- }
- return false;
- }
- return true;
-}
-
-
-class NodeMatcher : public MatcherInterface<Node*> {
- public:
- explicit NodeMatcher(IrOpcode::Value opcode) : opcode_(opcode) {}
-
- virtual void DescribeTo(std::ostream* os) const OVERRIDE {
- *os << "is a " << IrOpcode::Mnemonic(opcode_) << " node";
- }
-
- virtual bool MatchAndExplain(Node* node,
- MatchResultListener* listener) const
OVERRIDE {
- if (node == NULL) {
- *listener << "which is NULL";
- return false;
- }
- if (node->opcode() != opcode_) {
- *listener << "whose opcode is " << IrOpcode::Mnemonic(node->opcode())
- << " but should have been " << IrOpcode::Mnemonic(opcode_);
- return false;
- }
- return true;
- }
-
- private:
- const IrOpcode::Value opcode_;
-};
-
-
-class IsBranchMatcher FINAL : public NodeMatcher {
- public:
- IsBranchMatcher(const Matcher<Node*>& value_matcher,
- const Matcher<Node*>& control_matcher)
- : NodeMatcher(IrOpcode::kBranch),
- value_matcher_(value_matcher),
- control_matcher_(control_matcher) {}
-
- virtual void DescribeTo(std::ostream* os) const OVERRIDE {
- NodeMatcher::DescribeTo(os);
- *os << " whose value (";
- value_matcher_.DescribeTo(os);
- *os << ") and control (";
- control_matcher_.DescribeTo(os);
- *os << ")";
- }
-
- virtual bool MatchAndExplain(Node* node,
- MatchResultListener* listener) const
OVERRIDE {
- return (NodeMatcher::MatchAndExplain(node, listener) &&
- PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
- "value", value_matcher_, listener) &&
- PrintMatchAndExplain(NodeProperties::GetControlInput(node),
- "control", control_matcher_, listener));
- }
-
- private:
- const Matcher<Node*> value_matcher_;
- const Matcher<Node*> control_matcher_;
-};
-
-
-class IsMergeMatcher FINAL : public NodeMatcher {
- public:
- IsMergeMatcher(const Matcher<Node*>& control0_matcher,
- const Matcher<Node*>& control1_matcher)
- : NodeMatcher(IrOpcode::kMerge),
- control0_matcher_(control0_matcher),
- control1_matcher_(control1_matcher) {}
-
- virtual void DescribeTo(std::ostream* os) const OVERRIDE {
- NodeMatcher::DescribeTo(os);
- *os << " whose control0 (";
- control0_matcher_.DescribeTo(os);
- *os << ") and control1 (";
- control1_matcher_.DescribeTo(os);
- *os << ")";
- }
-
- virtual bool MatchAndExplain(Node* node,
- MatchResultListener* listener) const
OVERRIDE {
- return (NodeMatcher::MatchAndExplain(node, listener) &&
- PrintMatchAndExplain(NodeProperties::GetControlInput(node, 0),
- "control0", control0_matcher_, listener)
&&
- PrintMatchAndExplain(NodeProperties::GetControlInput(node, 1),
- "control1", control1_matcher_, listener));
- }
-
- private:
- const Matcher<Node*> control0_matcher_;
- const Matcher<Node*> control1_matcher_;
-};
-
-
-class IsControl1Matcher FINAL : public NodeMatcher {
- public:
- IsControl1Matcher(IrOpcode::Value opcode,
- const Matcher<Node*>& control_matcher)
- : NodeMatcher(opcode), control_matcher_(control_matcher) {}
-
- virtual void DescribeTo(std::ostream* os) const OVERRIDE {
- NodeMatcher::DescribeTo(os);
- *os << " whose control (";
- control_matcher_.DescribeTo(os);
- *os << ")";
- }
-
- virtual bool MatchAndExplain(Node* node,
- MatchResultListener* listener) const
OVERRIDE {
- return (NodeMatcher::MatchAndExplain(node, listener) &&
- PrintMatchAndExplain(NodeProperties::GetControlInput(node),
- "control", control_matcher_, listener));
- }
-
- private:
- const Matcher<Node*> control_matcher_;
-};
-
-
-class IsFinishMatcher FINAL : public NodeMatcher {
- public:
- IsFinishMatcher(const Matcher<Node*>& value_matcher,
- const Matcher<Node*>& effect_matcher)
- : NodeMatcher(IrOpcode::kFinish),
- value_matcher_(value_matcher),
- effect_matcher_(effect_matcher) {}
-
- virtual void DescribeTo(std::ostream* os) const OVERRIDE {
- NodeMatcher::DescribeTo(os);
- *os << " whose value (";
- value_matcher_.DescribeTo(os);
- *os << ") and effect (";
- effect_matcher_.DescribeTo(os);
- *os << ")";
- }
-
- virtual bool MatchAndExplain(Node* node,
- MatchResultListener* listener) const
OVERRIDE {
- return (NodeMatcher::MatchAndExplain(node, listener) &&
- PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
- "value", value_matcher_, listener) &&
-
PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
- effect_matcher_, listener));
- }
-
- private:
- const Matcher<Node*> value_matcher_;
- const Matcher<Node*> effect_matcher_;
-};
-
-
-template <typename T>
-class IsConstantMatcher FINAL : public NodeMatcher {
- public:
- IsConstantMatcher(IrOpcode::Value opcode, const Matcher<T>&
value_matcher)
- : NodeMatcher(opcode), value_matcher_(value_matcher) {}
-
- virtual void DescribeTo(std::ostream* os) const OVERRIDE {
- NodeMatcher::DescribeTo(os);
- *os << " whose value (";
- value_matcher_.DescribeTo(os);
- *os << ")";
- }
-
- virtual bool MatchAndExplain(Node* node,
- MatchResultListener* listener) const
OVERRIDE {
- return (NodeMatcher::MatchAndExplain(node, listener) &&
- PrintMatchAndExplain(OpParameter<T>(node), "value",
value_matcher_,
- listener));
- }
-
- private:
- const Matcher<T> value_matcher_;
-};
-
-
-class IsPhiMatcher FINAL : public NodeMatcher {
- public:
- IsPhiMatcher(const Matcher<MachineType>& type_matcher,
- const Matcher<Node*>& value0_matcher,
- const Matcher<Node*>& value1_matcher,
- const Matcher<Node*>& control_matcher)
- : NodeMatcher(IrOpcode::kPhi),
- type_matcher_(type_matcher),
- value0_matcher_(value0_matcher),
- value1_matcher_(value1_matcher),
- control_matcher_(control_matcher) {}
-
- virtual void DescribeTo(std::ostream* os) const OVERRIDE {
- NodeMatcher::DescribeTo(os);
- *os << " whose type (";
- type_matcher_.DescribeTo(os);
- *os << "), value0 (";
- value0_matcher_.DescribeTo(os);
- *os << "), value1 (";
- value1_matcher_.DescribeTo(os);
- *os << ") and control (";
- control_matcher_.DescribeTo(os);
- *os << ")";
- }
-
- virtual bool MatchAndExplain(Node* node,
- MatchResultListener* listener) const
OVERRIDE {
- return (NodeMatcher::MatchAndExplain(node, listener) &&
- PrintMatchAndExplain(OpParameter<MachineType>(node), "type",
- type_matcher_, listener) &&
- PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
- "value0", value0_matcher_, listener) &&
- PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
- "value1", value1_matcher_, listener) &&
- PrintMatchAndExplain(NodeProperties::GetControlInput(node),
- "control", control_matcher_, listener));
- }
-
- private:
- const Matcher<MachineType> type_matcher_;
- const Matcher<Node*> value0_matcher_;
- const Matcher<Node*> value1_matcher_;
- const Matcher<Node*> control_matcher_;
-};
-
-
-class IsProjectionMatcher FINAL : public NodeMatcher {
- public:
- IsProjectionMatcher(const Matcher<size_t>& index_matcher,
- const Matcher<Node*>& base_matcher)
- : NodeMatcher(IrOpcode::kProjection),
- index_matcher_(index_matcher),
- base_matcher_(base_matcher) {}
-
- virtual void DescribeTo(std::ostream* os) const OVERRIDE {
- NodeMatcher::DescribeTo(os);
- *os << " whose index (";
- index_matcher_.DescribeTo(os);
- *os << ") and base (";
- base_matcher_.DescribeTo(os);
- *os << ")";
- }
-
- virtual bool MatchAndExplain(Node* node,
- MatchResultListener* listener) const
OVERRIDE {
- return (NodeMatcher::MatchAndExplain(node, listener) &&
- PrintMatchAndExplain(OpParameter<size_t>(node), "index",
- index_matcher_, listener) &&
- PrintMatchAndExplain(NodeProperties::GetValueInput(node,
0), "base",
- base_matcher_, listener));
- }
-
- private:
- const Matcher<size_t> index_matcher_;
- const Matcher<Node*> base_matcher_;
-};
-
-
-class IsCallMatcher FINAL : public NodeMatcher {
- public:
- IsCallMatcher(const Matcher<CallDescriptor*>& descriptor_matcher,
- const Matcher<Node*>& value0_matcher,
- const Matcher<Node*>& value1_matcher,
- const Matcher<Node*>& value2_matcher,
- const Matcher<Node*>& value3_matcher,
- const Matcher<Node*>& effect_matcher,
- const Matcher<Node*>& control_matcher)
- : NodeMatcher(IrOpcode::kCall),
- descriptor_matcher_(descriptor_matcher),
- value0_matcher_(value0_matcher),
- value1_matcher_(value1_matcher),
- value2_matcher_(value2_matcher),
- value3_matcher_(value3_matcher),
- effect_matcher_(effect_matcher),
- control_matcher_(control_matcher) {}
-
- virtual void DescribeTo(std::ostream* os) const OVERRIDE {
- NodeMatcher::DescribeTo(os);
- *os << " whose value0 (";
- value0_matcher_.DescribeTo(os);
- *os << ") and value1 (";
- value1_matcher_.DescribeTo(os);
- *os << ") and value2 (";
- value2_matcher_.DescribeTo(os);
- *os << ") and value3 (";
- value3_matcher_.DescribeTo(os);
- *os << ") and effect (";
- effect_matcher_.DescribeTo(os);
- *os << ") and control (";
- control_matcher_.DescribeTo(os);
- *os << ")";
- }
-
- virtual bool MatchAndExplain(Node* node,
- MatchResultListener* listener) const
OVERRIDE {
- return (NodeMatcher::MatchAndExplain(node, listener) &&
- PrintMatchAndExplain(OpParameter<CallDescriptor*>(node),
- "descriptor", descriptor_matcher_,
listener) &&
- PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
- "value0", value0_matcher_, listener) &&
- PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
- "value1", value1_matcher_, listener) &&
- PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2),
- "value2", value2_matcher_, listener) &&
- PrintMatchAndExplain(NodeProperties::GetValueInput(node, 3),
- "value3", value3_matcher_, listener) &&
-
PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
- effect_matcher_, listener) &&
- PrintMatchAndExplain(NodeProperties::GetControlInput(node),
- "control", control_matcher_, listener));
- }
-
- private:
- const Matcher<CallDescriptor*> descriptor_matcher_;
- const Matcher<Node*> value0_matcher_;
- const Matcher<Node*> value1_matcher_;
- const Matcher<Node*> value2_matcher_;
- const Matcher<Node*> value3_matcher_;
- const Matcher<Node*> effect_matcher_;
- const Matcher<Node*> control_matcher_;
-};
-
-
-class IsLoadFieldMatcher FINAL : public NodeMatcher {
- public:
- IsLoadFieldMatcher(const Matcher<FieldAccess>& access_matcher,
- const Matcher<Node*>& base_matcher,
- const Matcher<Node*>& effect_matcher)
- : NodeMatcher(IrOpcode::kLoadField),
- access_matcher_(access_matcher),
- base_matcher_(base_matcher),
- effect_matcher_(effect_matcher) {}
-
- virtual void DescribeTo(std::ostream* os) const OVERRIDE {
- NodeMatcher::DescribeTo(os);
- *os << " whose access (";
- access_matcher_.DescribeTo(os);
- *os << "), base (";
- base_matcher_.DescribeTo(os);
- *os << ") and effect (";
- effect_matcher_.DescribeTo(os);
- *os << ")";
- }
-
- virtual bool MatchAndExplain(Node* node,
- MatchResultListener* listener) const
OVERRIDE {
- return (NodeMatcher::MatchAndExplain(node, listener) &&
- PrintMatchAndExplain(OpParameter<FieldAccess>(node), "access",
- access_matcher_, listener) &&
- PrintMatchAndExplain(NodeProperties::GetValueInput(node,
0), "base",
- base_matcher_, listener) &&
-
PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
- effect_matcher_, listener));
- }
-
- private:
- const Matcher<FieldAccess> access_matcher_;
- const Matcher<Node*> base_matcher_;
- const Matcher<Node*> effect_matcher_;
-};
-
-
-class IsLoadElementMatcher FINAL : public NodeMatcher {
- public:
- IsLoadElementMatcher(const Matcher<ElementAccess>& access_matcher,
- const Matcher<Node*>& base_matcher,
- const Matcher<Node*>& index_matcher,
- const Matcher<Node*>& length_matcher,
- const Matcher<Node*>& effect_matcher,
- const Matcher<Node*>& control_matcher)
- : NodeMatcher(IrOpcode::kLoadElement),
- access_matcher_(access_matcher),
- base_matcher_(base_matcher),
- index_matcher_(index_matcher),
- length_matcher_(length_matcher),
- effect_matcher_(effect_matcher),
- control_matcher_(control_matcher) {}
-
- virtual void DescribeTo(std::ostream* os) const OVERRIDE {
- NodeMatcher::DescribeTo(os);
- *os << " whose access (";
- access_matcher_.DescribeTo(os);
- *os << "), base (";
- base_matcher_.DescribeTo(os);
- *os << "), index (";
- index_matcher_.DescribeTo(os);
- *os << "), length (";
- length_matcher_.DescribeTo(os);
- *os << "), effect (";
- effect_matcher_.DescribeTo(os);
- *os << ") and control (";
- control_matcher_.DescribeTo(os);
- *os << ")";
- }
-
- virtual bool MatchAndExplain(Node* node,
- MatchResultListener* listener) const
OVERRIDE {
- return (NodeMatcher::MatchAndExplain(node, listener) &&
-
PrintMatchAndExplain(OpParameter<ElementAccess>(node), "access",
- access_matcher_, listener) &&
- PrintMatchAndExplain(NodeProperties::GetValueInput(node,
0), "base",
- base_matcher_, listener) &&
- PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
- "index", index_matcher_, listener) &&
- PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2),
- "length", length_matcher_, listener) &&
-
PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
- effect_matcher_, listener) &&
- PrintMatchAndExplain(NodeProperties::GetControlInput(node),
- "control", control_matcher_, listener));
- }
-
- private:
- const Matcher<ElementAccess> access_matcher_;
- const Matcher<Node*> base_matcher_;
- const Matcher<Node*> index_matcher_;
- const Matcher<Node*> length_matcher_;
- const Matcher<Node*> effect_matcher_;
- const Matcher<Node*> control_matcher_;
-};
-
-
-class IsStoreElementMatcher FINAL : public NodeMatcher {
- public:
- IsStoreElementMatcher(const Matcher<ElementAccess>& access_matcher,
- const Matcher<Node*>& base_matcher,
- const Matcher<Node*>& index_matcher,
- const Matcher<Node*>& length_matcher,
- const Matcher<Node*>& value_matcher,
- const Matcher<Node*>& effect_matcher,
- const Matcher<Node*>& control_matcher)
- : NodeMatcher(IrOpcode::kStoreElement),
- access_matcher_(access_matcher),
- base_matcher_(base_matcher),
- index_matcher_(index_matcher),
- length_matcher_(length_matcher),
- value_matcher_(value_matcher),
- effect_matcher_(effect_matcher),
- control_matcher_(control_matcher) {}
-
- virtual void DescribeTo(std::ostream* os) const OVERRIDE {
- NodeMatcher::DescribeTo(os);
- *os << " whose access (";
- access_matcher_.DescribeTo(os);
- *os << "), base (";
- base_matcher_.DescribeTo(os);
- *os << "), index (";
- index_matcher_.DescribeTo(os);
- *os << "), length (";
- length_matcher_.DescribeTo(os);
- *os << "), value (";
- value_matcher_.DescribeTo(os);
- *os << "), effect (";
- effect_matcher_.DescribeTo(os);
- *os << ") and control (";
- control_matcher_.DescribeTo(os);
- *os << ")";
- }
-
- virtual bool MatchAndExplain(Node* node,
- MatchResultListener* listener) const
OVERRIDE {
- return (NodeMatcher::MatchAndExplain(node, listener) &&
-
PrintMatchAndExplain(OpParameter<ElementAccess>(node), "access",
- access_matcher_, listener) &&
- PrintMatchAndExplain(NodeProperties::GetValueInput(node,
0), "base",
- base_matcher_, listener) &&
- PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
- "index", index_matcher_, listener) &&
- PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2),
- "length", length_matcher_, listener) &&
- PrintMatchAndExplain(NodeProperties::GetValueInput(node, 3),
- "value", value_matcher_, listener) &&
-
PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
- effect_matcher_, listener) &&
- PrintMatchAndExplain(NodeProperties::GetControlInput(node),
- "control", control_matcher_, listener));
- }
-
- private:
- const Matcher<ElementAccess> access_matcher_;
- const Matcher<Node*> base_matcher_;
- const Matcher<Node*> index_matcher_;
- const Matcher<Node*> length_matcher_;
- const Matcher<Node*> value_matcher_;
- const Matcher<Node*> effect_matcher_;
- const Matcher<Node*> control_matcher_;
-};
-
-
-class IsLoadMatcher FINAL : public NodeMatcher {
- public:
- IsLoadMatcher(const Matcher<LoadRepresentation>& rep_matcher,
- const Matcher<Node*>& base_matcher,
- const Matcher<Node*>& index_matcher,
- const Matcher<Node*>& effect_matcher,
- const Matcher<Node*>& control_matcher)
- : NodeMatcher(IrOpcode::kLoad),
- rep_matcher_(rep_matcher),
- base_matcher_(base_matcher),
- index_matcher_(index_matcher),
- effect_matcher_(effect_matcher),
- control_matcher_(control_matcher) {}
-
- virtual void DescribeTo(std::ostream* os) const OVERRIDE {
- NodeMatcher::DescribeTo(os);
- *os << " whose rep (";
- rep_matcher_.DescribeTo(os);
- *os << "), base (";
- base_matcher_.DescribeTo(os);
- *os << "), index (";
- index_matcher_.DescribeTo(os);
- *os << "), effect (";
- effect_matcher_.DescribeTo(os);
- *os << ") and control (";
- control_matcher_.DescribeTo(os);
- *os << ")";
- }
-
- virtual bool MatchAndExplain(Node* node,
- MatchResultListener* listener) const
OVERRIDE {
- return (NodeMatcher::MatchAndExplain(node, listener) &&
-
PrintMatchAndExplain(OpParameter<LoadRepresentation>(node), "rep",
- rep_matcher_, listener) &&
- PrintMatchAndExplain(NodeProperties::GetValueInput(node,
0), "base",
- base_matcher_, listener) &&
- PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
- "index", index_matcher_, listener) &&
-
PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
- effect_matcher_, listener) &&
- PrintMatchAndExplain(NodeProperties::GetControlInput(node),
- "control", control_matcher_, listener));
- }
-
- private:
- const Matcher<LoadRepresentation> rep_matcher_;
- const Matcher<Node*> base_matcher_;
- const Matcher<Node*> index_matcher_;
- const Matcher<Node*> effect_matcher_;
- const Matcher<Node*> control_matcher_;
-};
-
-
-class IsStoreMatcher FINAL : public NodeMatcher {
- public:
- IsStoreMatcher(const Matcher<StoreRepresentation>& rep_matcher,
- const Matcher<Node*>& base_matcher,
- const Matcher<Node*>& index_matcher,
- const Matcher<Node*>& value_matcher,
- const Matcher<Node*>& effect_matcher,
- const Matcher<Node*>& control_matcher)
- : NodeMatcher(IrOpcode::kStore),
- rep_matcher_(rep_matcher),
- base_matcher_(base_matcher),
- index_matcher_(index_matcher),
- value_matcher_(value_matcher),
- effect_matcher_(effect_matcher),
- control_matcher_(control_matcher) {}
-
- virtual void DescribeTo(std::ostream* os) const OVERRIDE {
- NodeMatcher::DescribeTo(os);
- *os << " whose rep (";
- rep_matcher_.DescribeTo(os);
- *os << "), base (";
- base_matcher_.DescribeTo(os);
- *os << "), index (";
- index_matcher_.DescribeTo(os);
- *os << "), value (";
- value_matcher_.DescribeTo(os);
- *os << "), effect (";
- effect_matcher_.DescribeTo(os);
- *os << ") and control (";
- control_matcher_.DescribeTo(os);
- *os << ")";
- }
-
- virtual bool MatchAndExplain(Node* node,
- MatchResultListener* listener) const
OVERRIDE {
- return (NodeMatcher::MatchAndExplain(node, listener) &&
-
PrintMatchAndExplain(OpParameter<StoreRepresentation>(node), "rep",
- rep_matcher_, listener) &&
- PrintMatchAndExplain(NodeProperties::GetValueInput(node,
0), "base",
- base_matcher_, listener) &&
- PrintMatchAndExplain(NodeProperties::GetValueInput(node, 1),
- "index", index_matcher_, listener) &&
- PrintMatchAndExplain(NodeProperties::GetValueInput(node, 2),
- "value", value_matcher_, listener) &&
-
PrintMatchAndExplain(NodeProperties::GetEffectInput(node), "effect",
- effect_matcher_, listener) &&
- PrintMatchAndExplain(NodeProperties::GetControlInput(node),
- "control", control_matcher_, listener));
- }
-
- private:
- const Matcher<StoreRepresentation> rep_matcher_;
- const Matcher<Node*> base_matcher_;
- const Matcher<Node*> index_matcher_;
- const Matcher<Node*> value_matcher_;
- const Matcher<Node*> effect_matcher_;
- const Matcher<Node*> control_matcher_;
-};
-
-
-class IsBinopMatcher FINAL : public NodeMatcher {
- public:
- IsBinopMatcher(IrOpcode::Value opcode, const Matcher<Node*>& lhs_matcher,
- const Matcher<Node*>& rhs_matcher)
- : NodeMatcher(opcode),
- lhs_matcher_(lhs_matcher),
- rhs_matcher_(rhs_matcher) {}
-
- virtual void DescribeTo(std::ostream* os) const OVERRIDE {
- NodeMatcher::DescribeTo(os);
- *os << " whose lhs (";
- lhs_matcher_.DescribeTo(os);
- *os << ") and rhs (";
- rhs_matcher_.DescribeTo(os);
- *os << ")";
- }
-
- virtual bool MatchAndExplain(Node* node,
- MatchResultListener* listener) const
OVERRIDE {
- return (NodeMatcher::MatchAndExplain(node, listener) &&
- PrintMatchAndExplain(NodeProperties::GetValueInput(node,
0), "lhs",
- lhs_matcher_, listener) &&
- PrintMatchAndExplain(NodeProperties::GetValueInput(node,
1), "rhs",
- rhs_matcher_, listener));
- }
-
- private:
- const Matcher<Node*> lhs_matcher_;
- const Matcher<Node*> rhs_matcher_;
-};
-
-
-class IsUnopMatcher FINAL : public NodeMatcher {
- public:
- IsUnopMatcher(IrOpcode::Value opcode, const Matcher<Node*>&
input_matcher)
- : NodeMatcher(opcode), input_matcher_(input_matcher) {}
-
- virtual void DescribeTo(std::ostream* os) const OVERRIDE {
- NodeMatcher::DescribeTo(os);
- *os << " whose input (";
- input_matcher_.DescribeTo(os);
- *os << ")";
- }
-
- virtual bool MatchAndExplain(Node* node,
- MatchResultListener* listener) const
OVERRIDE {
- return (NodeMatcher::MatchAndExplain(node, listener) &&
- PrintMatchAndExplain(NodeProperties::GetValueInput(node, 0),
- "input", input_matcher_, listener));
- }
-
- private:
- const Matcher<Node*> input_matcher_;
-};
-}
-
-
-Matcher<Node*> IsBranch(const Matcher<Node*>& value_matcher,
- const Matcher<Node*>& control_matcher) {
- return MakeMatcher(new IsBranchMatcher(value_matcher, control_matcher));
-}
-
-
-Matcher<Node*> IsMerge(const Matcher<Node*>& control0_matcher,
- const Matcher<Node*>& control1_matcher) {
- return MakeMatcher(new IsMergeMatcher(control0_matcher,
control1_matcher));
-}
-
-
-Matcher<Node*> IsIfTrue(const Matcher<Node*>& control_matcher) {
- return MakeMatcher(new IsControl1Matcher(IrOpcode::kIfTrue,
control_matcher));
-}
-
-
-Matcher<Node*> IsIfFalse(const Matcher<Node*>& control_matcher) {
- return MakeMatcher(
- new IsControl1Matcher(IrOpcode::kIfFalse, control_matcher));
-}
-
-
-Matcher<Node*> IsValueEffect(const Matcher<Node*>& value_matcher) {
- return MakeMatcher(new IsUnopMatcher(IrOpcode::kValueEffect,
value_matcher));
-}
-
-
-Matcher<Node*> IsFinish(const Matcher<Node*>& value_matcher,
- const Matcher<Node*>& effect_matcher) {
- return MakeMatcher(new IsFinishMatcher(value_matcher, effect_matcher));
-}
-
-
-Matcher<Node*> IsExternalConstant(
- const Matcher<ExternalReference>& value_matcher) {
- return MakeMatcher(new IsConstantMatcher<ExternalReference>(
- IrOpcode::kExternalConstant, value_matcher));
-}
-
-
-Matcher<Node*> IsHeapConstant(
- const Matcher<Unique<HeapObject> >& value_matcher) {
- return MakeMatcher(new IsConstantMatcher<Unique<HeapObject> >(
- IrOpcode::kHeapConstant, value_matcher));
-}
-
-
-Matcher<Node*> IsInt32Constant(const Matcher<int32_t>& value_matcher) {
- return MakeMatcher(
- new IsConstantMatcher<int32_t>(IrOpcode::kInt32Constant,
value_matcher));
-}
-
-
-Matcher<Node*> IsInt64Constant(const Matcher<int64_t>& value_matcher) {
- return MakeMatcher(
- new IsConstantMatcher<int64_t>(IrOpcode::kInt64Constant,
value_matcher));
-}
-
-
-Matcher<Node*> IsFloat32Constant(const Matcher<float>& value_matcher) {
- return MakeMatcher(
- new IsConstantMatcher<float>(IrOpcode::kFloat32Constant,
value_matcher));
-}
-
-
-Matcher<Node*> IsFloat64Constant(const Matcher<double>& value_matcher) {
- return MakeMatcher(
- new IsConstantMatcher<double>(IrOpcode::kFloat64Constant,
value_matcher));
-}
-
-
-Matcher<Node*> IsNumberConstant(const Matcher<double>& value_matcher) {
- return MakeMatcher(
- new IsConstantMatcher<double>(IrOpcode::kNumberConstant,
value_matcher));
-}
-
-
-Matcher<Node*> IsPhi(const Matcher<MachineType>& type_matcher,
- const Matcher<Node*>& value0_matcher,
- const Matcher<Node*>& value1_matcher,
- const Matcher<Node*>& merge_matcher) {
- return MakeMatcher(new IsPhiMatcher(type_matcher, value0_matcher,
- value1_matcher, merge_matcher));
-}
-
-
-Matcher<Node*> IsProjection(const Matcher<size_t>& index_matcher,
- const Matcher<Node*>& base_matcher) {
- return MakeMatcher(new IsProjectionMatcher(index_matcher, base_matcher));
-}
-
-
-Matcher<Node*> IsCall(const Matcher<CallDescriptor*>& descriptor_matcher,
- const Matcher<Node*>& value0_matcher,
- const Matcher<Node*>& value1_matcher,
- const Matcher<Node*>& value2_matcher,
- const Matcher<Node*>& value3_matcher,
- const Matcher<Node*>& effect_matcher,
- const Matcher<Node*>& control_matcher) {
- return MakeMatcher(new IsCallMatcher(
- descriptor_matcher, value0_matcher, value1_matcher, value2_matcher,
- value3_matcher, effect_matcher, control_matcher));
-}
-
-
-Matcher<Node*> IsLoadField(const Matcher<FieldAccess>& access_matcher,
- const Matcher<Node*>& base_matcher,
- const Matcher<Node*>& effect_matcher) {
- return MakeMatcher(
- new IsLoadFieldMatcher(access_matcher, base_matcher,
effect_matcher));
-}
-
-
-Matcher<Node*> IsLoadElement(const Matcher<ElementAccess>& access_matcher,
- const Matcher<Node*>& base_matcher,
- const Matcher<Node*>& index_matcher,
- const Matcher<Node*>& length_matcher,
- const Matcher<Node*>& effect_matcher,
- const Matcher<Node*>& control_matcher) {
- return MakeMatcher(new IsLoadElementMatcher(access_matcher, base_matcher,
- index_matcher,
length_matcher,
- effect_matcher,
control_matcher));
-}
-
-
-Matcher<Node*> IsStoreElement(const Matcher<ElementAccess>& access_matcher,
- const Matcher<Node*>& base_matcher,
- const Matcher<Node*>& index_matcher,
- const Matcher<Node*>& length_matcher,
- const Matcher<Node*>& value_matcher,
- const Matcher<Node*>& effect_matcher,
- const Matcher<Node*>& control_matcher) {
- return MakeMatcher(new IsStoreElementMatcher(
- access_matcher, base_matcher, index_matcher, length_matcher,
- value_matcher, effect_matcher, control_matcher));
-}
-
-
-Matcher<Node*> IsLoad(const Matcher<LoadRepresentation>& rep_matcher,
- const Matcher<Node*>& base_matcher,
- const Matcher<Node*>& index_matcher,
- const Matcher<Node*>& effect_matcher,
- const Matcher<Node*>& control_matcher) {
- return MakeMatcher(new IsLoadMatcher(rep_matcher, base_matcher,
index_matcher,
- effect_matcher, control_matcher));
-}
-
-
-Matcher<Node*> IsStore(const Matcher<StoreRepresentation>& rep_matcher,
- const Matcher<Node*>& base_matcher,
- const Matcher<Node*>& index_matcher,
- const Matcher<Node*>& value_matcher,
- const Matcher<Node*>& effect_matcher,
- const Matcher<Node*>& control_matcher) {
- return MakeMatcher(new IsStoreMatcher(rep_matcher, base_matcher,
- index_matcher, value_matcher,
- effect_matcher, control_matcher));
-}
-
-
-#define IS_BINOP_MATCHER(Name) \
- Matcher<Node*> Is##Name(const Matcher<Node*>& lhs_matcher, \
- const Matcher<Node*>& rhs_matcher) { \
- return MakeMatcher( \
- new IsBinopMatcher(IrOpcode::k##Name, lhs_matcher, rhs_matcher)); \
- }
-IS_BINOP_MATCHER(NumberLessThan)
-IS_BINOP_MATCHER(NumberSubtract)
-IS_BINOP_MATCHER(Word32And)
-IS_BINOP_MATCHER(Word32Sar)
-IS_BINOP_MATCHER(Word32Shl)
-IS_BINOP_MATCHER(Word32Shr)
-IS_BINOP_MATCHER(Word32Ror)
-IS_BINOP_MATCHER(Word32Equal)
-IS_BINOP_MATCHER(Word64And)
-IS_BINOP_MATCHER(Word64Sar)
-IS_BINOP_MATCHER(Word64Shl)
-IS_BINOP_MATCHER(Word64Equal)
-IS_BINOP_MATCHER(Int32AddWithOverflow)
-IS_BINOP_MATCHER(Int32Add)
-IS_BINOP_MATCHER(Int32Sub)
-IS_BINOP_MATCHER(Int32Mul)
-IS_BINOP_MATCHER(Int32MulHigh)
-IS_BINOP_MATCHER(Int32LessThan)
-IS_BINOP_MATCHER(Uint32LessThan)
-IS_BINOP_MATCHER(Uint32LessThanOrEqual)
-#undef IS_BINOP_MATCHER
-
-
-#define
IS_UNOP_MATCHER(Name) \
- Matcher<Node*> Is##Name(const Matcher<Node*>& input_matcher)
{ \
- return MakeMatcher(new IsUnopMatcher(IrOpcode::k##Name,
input_matcher)); \
- }
-IS_UNOP_MATCHER(ChangeFloat64ToInt32)
-IS_UNOP_MATCHER(ChangeFloat64ToUint32)
-IS_UNOP_MATCHER(ChangeInt32ToFloat64)
-IS_UNOP_MATCHER(ChangeInt32ToInt64)
-IS_UNOP_MATCHER(ChangeUint32ToFloat64)
-IS_UNOP_MATCHER(ChangeUint32ToUint64)
-IS_UNOP_MATCHER(TruncateFloat64ToFloat32)
-IS_UNOP_MATCHER(TruncateFloat64ToInt32)
-IS_UNOP_MATCHER(TruncateInt64ToInt32)
-IS_UNOP_MATCHER(Float64Sqrt)
-#undef IS_UNOP_MATCHER
-
} // namespace compiler
} // namespace internal
} // namespace v8
=======================================
--- /branches/bleeding_edge/test/unittests/compiler/graph-unittest.h Wed
Oct 15 11:38:04 2014 UTC
+++ /branches/bleeding_edge/test/unittests/compiler/graph-unittest.h Mon
Oct 20 11:26:23 2014 UTC
@@ -24,11 +24,6 @@
namespace compiler {
-// Forward declarations.
-struct ElementAccess;
-struct FieldAccess;
-
-
using ::testing::Matcher;
@@ -68,8 +63,7 @@
class TypedGraphTest : public GraphTest {
public:
explicit TypedGraphTest(int parameters = 1)
- : GraphTest(parameters),
- typer_(graph(), MaybeHandle<Context>()) {}
+ : GraphTest(parameters), typer_(graph(), MaybeHandle<Context>()) {}
protected:
Typer* typer() { return &typer_; }
@@ -78,118 +72,6 @@
Typer typer_;
};
-
-Matcher<Node*> IsBranch(const Matcher<Node*>& value_matcher,
- const Matcher<Node*>& control_matcher);
-Matcher<Node*> IsMerge(const Matcher<Node*>& control0_matcher,
- const Matcher<Node*>& control1_matcher);
-Matcher<Node*> IsIfTrue(const Matcher<Node*>& control_matcher);
-Matcher<Node*> IsIfFalse(const Matcher<Node*>& control_matcher);
-Matcher<Node*> IsValueEffect(const Matcher<Node*>& value_matcher);
-Matcher<Node*> IsFinish(const Matcher<Node*>& value_matcher,
- const Matcher<Node*>& effect_matcher);
-Matcher<Node*> IsExternalConstant(
- const Matcher<ExternalReference>& value_matcher);
-Matcher<Node*> IsHeapConstant(
- const Matcher<Unique<HeapObject> >& value_matcher);
-Matcher<Node*> IsFloat32Constant(const Matcher<float>& value_matcher);
-Matcher<Node*> IsFloat64Constant(const Matcher<double>& value_matcher);
-Matcher<Node*> IsInt32Constant(const Matcher<int32_t>& value_matcher);
-Matcher<Node*> IsInt64Constant(const Matcher<int64_t>& value_matcher);
-Matcher<Node*> IsNumberConstant(const Matcher<double>& value_matcher);
-Matcher<Node*> IsPhi(const Matcher<MachineType>& type_matcher,
- const Matcher<Node*>& value0_matcher,
- const Matcher<Node*>& value1_matcher,
- const Matcher<Node*>& merge_matcher);
-Matcher<Node*> IsProjection(const Matcher<size_t>& index_matcher,
- const Matcher<Node*>& base_matcher);
-Matcher<Node*> IsCall(const Matcher<CallDescriptor*>& descriptor_matcher,
- const Matcher<Node*>& value0_matcher,
- const Matcher<Node*>& value1_matcher,
- const Matcher<Node*>& value2_matcher,
- const Matcher<Node*>& value3_matcher,
- const Matcher<Node*>& effect_matcher,
- const Matcher<Node*>& control_matcher);
-
-Matcher<Node*> IsNumberLessThan(const Matcher<Node*>& lhs_matcher,
- const Matcher<Node*>& rhs_matcher);
-Matcher<Node*> IsNumberSubtract(const Matcher<Node*>& lhs_matcher,
- const Matcher<Node*>& rhs_matcher);
-Matcher<Node*> IsLoadField(const Matcher<FieldAccess>& access_matcher,
- const Matcher<Node*>& base_matcher,
- const Matcher<Node*>& effect_matcher);
-Matcher<Node*> IsLoadElement(const Matcher<ElementAccess>& access_matcher,
- const Matcher<Node*>& base_matcher,
- const Matcher<Node*>& index_matcher,
- const Matcher<Node*>& length_matcher,
- const Matcher<Node*>& effect_matcher,
- const Matcher<Node*>& control_matcher);
-Matcher<Node*> IsStoreElement(const Matcher<ElementAccess>& access_matcher,
- const Matcher<Node*>& base_matcher,
- const Matcher<Node*>& index_matcher,
- const Matcher<Node*>& length_matcher,
- const Matcher<Node*>& value_matcher,
- const Matcher<Node*>& effect_matcher,
- const Matcher<Node*>& control_matcher);
-
-Matcher<Node*> IsLoad(const Matcher<LoadRepresentation>& rep_matcher,
- const Matcher<Node*>& base_matcher,
- const Matcher<Node*>& index_matcher,
- const Matcher<Node*>& effect_matcher,
- const Matcher<Node*>& control_matcher);
-Matcher<Node*> IsStore(const Matcher<StoreRepresentation>& rep_matcher,
- const Matcher<Node*>& base_matcher,
- const Matcher<Node*>& index_matcher,
- const Matcher<Node*>& value_matcher,
- const Matcher<Node*>& effect_matcher,
- const Matcher<Node*>& control_matcher);
-Matcher<Node*> IsWord32And(const Matcher<Node*>& lhs_matcher,
- const Matcher<Node*>& rhs_matcher);
-Matcher<Node*> IsWord32Sar(const Matcher<Node*>& lhs_matcher,
- const Matcher<Node*>& rhs_matcher);
-Matcher<Node*> IsWord32Shl(const Matcher<Node*>& lhs_matcher,
- const Matcher<Node*>& rhs_matcher);
-Matcher<Node*> IsWord32Shr(const Matcher<Node*>& lhs_matcher,
- const Matcher<Node*>& rhs_matcher);
-Matcher<Node*> IsWord32Ror(const Matcher<Node*>& lhs_matcher,
- const Matcher<Node*>& rhs_matcher);
-Matcher<Node*> IsWord32Equal(const Matcher<Node*>& lhs_matcher,
- const Matcher<Node*>& rhs_matcher);
-Matcher<Node*> IsWord64And(const Matcher<Node*>& lhs_matcher,
- const Matcher<Node*>& rhs_matcher);
-Matcher<Node*> IsWord64Shl(const Matcher<Node*>& lhs_matcher,
- const Matcher<Node*>& rhs_matcher);
-Matcher<Node*> IsWord64Sar(const Matcher<Node*>& lhs_matcher,
- const Matcher<Node*>& rhs_matcher);
-Matcher<Node*> IsWord64Equal(const Matcher<Node*>& lhs_matcher,
- const Matcher<Node*>& rhs_matcher);
-Matcher<Node*> IsInt32AddWithOverflow(const Matcher<Node*>& lhs_matcher,
- const Matcher<Node*>& rhs_matcher);
-Matcher<Node*> IsInt32Add(const Matcher<Node*>& lhs_matcher,
- const Matcher<Node*>& rhs_matcher);
-Matcher<Node*> IsInt32Sub(const Matcher<Node*>& lhs_matcher,
- const Matcher<Node*>& rhs_matcher);
-Matcher<Node*> IsInt32Mul(const Matcher<Node*>& lhs_matcher,
- const Matcher<Node*>& rhs_matcher);
-Matcher<Node*> IsInt32MulHigh(const Matcher<Node*>& lhs_matcher,
- const Matcher<Node*>& rhs_matcher);
-Matcher<Node*> IsInt32LessThan(const Matcher<Node*>& lhs_matcher,
- const Matcher<Node*>& rhs_matcher);
-Matcher<Node*> IsUint32LessThan(const Matcher<Node*>& lhs_matcher,
- const Matcher<Node*>& rhs_matcher);
-Matcher<Node*> IsUint32LessThanOrEqual(const Matcher<Node*>& lhs_matcher,
- const Matcher<Node*>& rhs_matcher);
-Matcher<Node*> IsChangeFloat64ToInt32(const Matcher<Node*>& input_matcher);
-Matcher<Node*> IsChangeFloat64ToUint32(const Matcher<Node*>&
input_matcher);
-Matcher<Node*> IsChangeInt32ToFloat64(const Matcher<Node*>& input_matcher);
-Matcher<Node*> IsChangeInt32ToInt64(const Matcher<Node*>& input_matcher);
-Matcher<Node*> IsChangeUint32ToFloat64(const Matcher<Node*>&
input_matcher);
-Matcher<Node*> IsChangeUint32ToUint64(const Matcher<Node*>& input_matcher);
-Matcher<Node*> IsTruncateFloat64ToFloat32(const Matcher<Node*>&
input_matcher);
-Matcher<Node*> IsTruncateFloat64ToInt32(const Matcher<Node*>&
input_matcher);
-Matcher<Node*> IsTruncateInt64ToInt32(const Matcher<Node*>& input_matcher);
-Matcher<Node*> IsFloat64Sqrt(const Matcher<Node*>& input_matcher);
-
} // namespace compiler
} // namespace internal
} // namespace v8
=======================================
---
/branches/bleeding_edge/test/unittests/compiler/js-builtin-reducer-unittest.cc
Wed Oct 15 11:38:04 2014 UTC
+++
/branches/bleeding_edge/test/unittests/compiler/js-builtin-reducer-unittest.cc
Mon Oct 20 11:26:23 2014 UTC
@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "test/unittests/compiler/graph-unittest.h"
-
#include "src/compiler/js-builtin-reducer.h"
#include "src/compiler/js-graph.h"
#include "src/compiler/node-properties-inl.h"
#include "src/compiler/typer.h"
+#include "test/unittests/compiler/graph-unittest.h"
+#include "test/unittests/compiler/node-test-utils.h"
#include "testing/gmock-support.h"
using testing::Capture;
=======================================
---
/branches/bleeding_edge/test/unittests/compiler/js-typed-lowering-unittest.cc
Fri Oct 17 09:04:58 2014 UTC
+++
/branches/bleeding_edge/test/unittests/compiler/js-typed-lowering-unittest.cc
Mon Oct 20 11:26:23 2014 UTC
@@ -11,7 +11,7 @@
#include "src/compiler/typer.h"
#include "test/unittests/compiler/compiler-test-utils.h"
#include "test/unittests/compiler/graph-unittest.h"
-#include "testing/gtest-support.h"
+#include "test/unittests/compiler/node-test-utils.h"
namespace v8 {
namespace internal {
=======================================
---
/branches/bleeding_edge/test/unittests/compiler/machine-operator-reducer-unittest.cc
Wed Oct 15 11:38:04 2014 UTC
+++
/branches/bleeding_edge/test/unittests/compiler/machine-operator-reducer-unittest.cc
Mon Oct 20 11:26:23 2014 UTC
@@ -8,6 +8,7 @@
#include "src/compiler/machine-operator-reducer.h"
#include "src/compiler/typer.h"
#include "test/unittests/compiler/graph-unittest.h"
+#include "test/unittests/compiler/node-test-utils.h"
#include "testing/gmock-support.h"
using testing::AllOf;
=======================================
---
/branches/bleeding_edge/test/unittests/compiler/simplified-operator-reducer-unittest.cc
Mon Oct 20 06:25:41 2014 UTC
+++
/branches/bleeding_edge/test/unittests/compiler/simplified-operator-reducer-unittest.cc
Mon Oct 20 11:26:23 2014 UTC
@@ -8,6 +8,7 @@
#include "src/conversions.h"
#include "src/types.h"
#include "test/unittests/compiler/graph-unittest.h"
+#include "test/unittests/compiler/node-test-utils.h"
namespace v8 {
namespace internal {
=======================================
--- /branches/bleeding_edge/test/unittests/unittests.gyp Fri Oct 10
08:06:21 2014 UTC
+++ /branches/bleeding_edge/test/unittests/unittests.gyp Mon Oct 20
11:26:23 2014 UTC
@@ -49,6 +49,8 @@
'compiler/js-typed-lowering-unittest.cc',
'compiler/machine-operator-reducer-unittest.cc',
'compiler/machine-operator-unittest.cc',
+ 'compiler/node-test-utils.cc',
+ 'compiler/node-test-utils.h',
'compiler/simplified-operator-reducer-unittest.cc',
'compiler/simplified-operator-unittest.cc',
'compiler/value-numbering-reducer-unittest.cc',
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.