Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1248)

Unified Diff: test/compiler-unittests/graph-unittest.cc

Issue 480863002: Refactor ChangeLowering class to avoid template specialization. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/compiler-unittests/graph-unittest.cc
diff --git a/test/compiler-unittests/node-matchers.cc b/test/compiler-unittests/graph-unittest.cc
similarity index 82%
rename from test/compiler-unittests/node-matchers.cc
rename to test/compiler-unittests/graph-unittest.cc
index afff34ab2aad530665460ed9083e6602230138c8..6c946de590aa2ce45e8a3d6c86a05bdb065d18f2 100644
--- a/test/compiler-unittests/node-matchers.cc
+++ b/test/compiler-unittests/graph-unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "test/compiler-unittests/node-matchers.h"
+#include "test/compiler-unittests/graph-unittest.h"
#include <ostream> // NOLINT(readability/streams)
@@ -25,6 +25,14 @@ inline std::ostream& operator<<(std::ostream& os,
namespace compiler {
+GraphTest::GraphTest(int num_parameters) : graph_(zone()) {
+ graph()->SetStart(graph()->NewNode(common()->Start(num_parameters)));
+}
+
+
+GraphTest::~GraphTest() {}
+
+
namespace {
template <typename T>
@@ -101,6 +109,86 @@ class IsBranchMatcher V8_FINAL : public NodeMatcher {
};
+class IsMergeMatcher V8_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 V8_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
+ V8_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 IsIfTrueMatcher V8_FINAL : public NodeMatcher {
+ public:
+ explicit IsIfTrueMatcher(const Matcher<Node*>& control_matcher)
+ : NodeMatcher(IrOpcode::kIfTrue), control_matcher_(control_matcher) {}
+
+ virtual void DescribeTo(std::ostream* os) const V8_OVERRIDE {
+ NodeMatcher::DescribeTo(os);
+ *os << " whose control (";
+ control_matcher_.DescribeTo(os);
+ *os << ")";
+ }
+
+ virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const
+ V8_OVERRIDE {
+ return (NodeMatcher::MatchAndExplain(node, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetControlInput(node),
+ "control", control_matcher_, listener));
+ }
+
+ private:
+ const Matcher<Node*> control_matcher_;
+};
+
+
+class IsIfFalseMatcher V8_FINAL : public NodeMatcher {
+ public:
+ explicit IsIfFalseMatcher(const Matcher<Node*>& control_matcher)
+ : NodeMatcher(IrOpcode::kIfFalse), control_matcher_(control_matcher) {}
+
+ virtual void DescribeTo(std::ostream* os) const V8_OVERRIDE {
+ NodeMatcher::DescribeTo(os);
+ *os << " whose control (";
+ control_matcher_.DescribeTo(os);
+ *os << ")";
+ }
+
+ virtual bool MatchAndExplain(Node* node, MatchResultListener* listener) const
+ V8_OVERRIDE {
+ return (NodeMatcher::MatchAndExplain(node, listener) &&
+ PrintMatchAndExplain(NodeProperties::GetControlInput(node),
+ "control", control_matcher_, listener));
+ }
+
+ private:
+ const Matcher<Node*> control_matcher_;
+};
+
+
template <typename T>
class IsConstantMatcher V8_FINAL : public NodeMatcher {
public:
@@ -366,7 +454,6 @@ class IsUnopMatcher V8_FINAL : public NodeMatcher {
private:
const Matcher<Node*> input_matcher_;
};
-
}
@@ -376,6 +463,22 @@ Matcher<Node*> IsBranch(const Matcher<Node*>& value_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 IsIfTrueMatcher(control_matcher));
+}
+
+
+Matcher<Node*> IsIfFalse(const Matcher<Node*>& control_matcher) {
+ return MakeMatcher(new IsIfFalseMatcher(control_matcher));
+}
+
+
Matcher<Node*> IsInt32Constant(const Matcher<int32_t>& value_matcher) {
return MakeMatcher(
new IsConstantMatcher<int32_t>(IrOpcode::kInt32Constant, value_matcher));
« no previous file with comments | « test/compiler-unittests/graph-unittest.h ('k') | test/compiler-unittests/machine-operator-reducer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698