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

Side by Side Diff: test/unittests/compiler/node-test-utils.cc

Issue 639293006: [turbofan] Move node matchers to separate file. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "test/unittests/compiler/graph-unittest.h" 5 #include "test/unittests/compiler/node-test-utils.h"
6
7 #include <ostream> // NOLINT(readability/streams)
8 6
9 #include "src/compiler/node-properties-inl.h" 7 #include "src/compiler/node-properties-inl.h"
10 #include "src/compiler/simplified-operator.h" 8 #include "src/compiler/simplified-operator.h"
11 9
12 using testing::_; 10 using testing::_;
13 using testing::MakeMatcher; 11 using testing::MakeMatcher;
14 using testing::MatcherInterface; 12 using testing::MatcherInterface;
15 using testing::MatchResultListener; 13 using testing::MatchResultListener;
16 using testing::StringMatchResultListener; 14 using testing::StringMatchResultListener;
17 15
18 namespace v8 { 16 namespace v8 {
19 namespace internal { 17 namespace internal {
20 namespace compiler { 18 namespace compiler {
21 19
22 GraphTest::GraphTest(int num_parameters) : common_(zone()), graph_(zone()) {
23 graph()->SetStart(graph()->NewNode(common()->Start(num_parameters)));
24 }
25
26
27 GraphTest::~GraphTest() {}
28
29
30 Node* GraphTest::Parameter(int32_t index) {
31 return graph()->NewNode(common()->Parameter(index), graph()->start());
32 }
33
34
35 Node* GraphTest::Float32Constant(volatile float value) {
36 return graph()->NewNode(common()->Float32Constant(value));
37 }
38
39
40 Node* GraphTest::Float64Constant(volatile double value) {
41 return graph()->NewNode(common()->Float64Constant(value));
42 }
43
44
45 Node* GraphTest::Int32Constant(int32_t value) {
46 return graph()->NewNode(common()->Int32Constant(value));
47 }
48
49
50 Node* GraphTest::Int64Constant(int64_t value) {
51 return graph()->NewNode(common()->Int64Constant(value));
52 }
53
54
55 Node* GraphTest::NumberConstant(volatile double value) {
56 return graph()->NewNode(common()->NumberConstant(value));
57 }
58
59
60 Node* GraphTest::HeapConstant(const Handle<HeapObject>& value) {
61 return HeapConstant(Unique<HeapObject>::CreateUninitialized(value));
62 }
63
64
65 Node* GraphTest::HeapConstant(const Unique<HeapObject>& value) {
66 Node* node = graph()->NewNode(common()->HeapConstant(value));
67 Type* type = Type::Constant(value.handle(), zone());
68 NodeProperties::SetBounds(node, Bounds(type));
69 return node;
70 }
71
72
73 Node* GraphTest::FalseConstant() {
74 return HeapConstant(
75 Unique<HeapObject>::CreateImmovable(factory()->false_value()));
76 }
77
78
79 Node* GraphTest::TrueConstant() {
80 return HeapConstant(
81 Unique<HeapObject>::CreateImmovable(factory()->true_value()));
82 }
83
84
85 Node* GraphTest::UndefinedConstant() {
86 return HeapConstant(
87 Unique<HeapObject>::CreateImmovable(factory()->undefined_value()));
88 }
89
90
91 Matcher<Node*> GraphTest::IsFalseConstant() {
92 return IsHeapConstant(
93 Unique<HeapObject>::CreateImmovable(factory()->false_value()));
94 }
95
96
97 Matcher<Node*> GraphTest::IsTrueConstant() {
98 return IsHeapConstant(
99 Unique<HeapObject>::CreateImmovable(factory()->true_value()));
100 }
101
102 namespace { 20 namespace {
103 21
104 template <typename T> 22 template <typename T>
105 bool PrintMatchAndExplain(const T& value, const char* value_name, 23 bool PrintMatchAndExplain(const T& value, const char* value_name,
106 const Matcher<T>& value_matcher, 24 const Matcher<T>& value_matcher,
107 MatchResultListener* listener) { 25 MatchResultListener* listener) {
108 StringMatchResultListener value_listener; 26 StringMatchResultListener value_listener;
109 if (!value_matcher.MatchAndExplain(value, &value_listener)) { 27 if (!value_matcher.MatchAndExplain(value, &value_listener)) {
110 *listener << "whose " << value_name << " " << value << " doesn't match"; 28 *listener << "whose " << value_name << " " << value << " doesn't match";
111 if (value_listener.str() != "") { 29 if (value_listener.str() != "") {
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 IS_UNOP_MATCHER(ChangeUint32ToUint64) 889 IS_UNOP_MATCHER(ChangeUint32ToUint64)
972 IS_UNOP_MATCHER(TruncateFloat64ToFloat32) 890 IS_UNOP_MATCHER(TruncateFloat64ToFloat32)
973 IS_UNOP_MATCHER(TruncateFloat64ToInt32) 891 IS_UNOP_MATCHER(TruncateFloat64ToInt32)
974 IS_UNOP_MATCHER(TruncateInt64ToInt32) 892 IS_UNOP_MATCHER(TruncateInt64ToInt32)
975 IS_UNOP_MATCHER(Float64Sqrt) 893 IS_UNOP_MATCHER(Float64Sqrt)
976 #undef IS_UNOP_MATCHER 894 #undef IS_UNOP_MATCHER
977 895
978 } // namespace compiler 896 } // namespace compiler
979 } // namespace internal 897 } // namespace internal
980 } // namespace v8 898 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/node-test-utils.h ('k') | test/unittests/compiler/simplified-operator-reducer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698