OLD | NEW |
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 #ifndef V8_UNITTESTS_COMPILER_GRAPH_UNITTEST_H_ | 5 #ifndef V8_UNITTESTS_COMPILER_NODE_TEST_UTILS_H_ |
6 #define V8_UNITTESTS_COMPILER_GRAPH_UNITTEST_H_ | 6 #define V8_UNITTESTS_COMPILER_NODE_TEST_UTILS_H_ |
7 | 7 |
8 #include "src/compiler/common-operator.h" | |
9 #include "src/compiler/graph.h" | |
10 #include "src/compiler/machine-operator.h" | 8 #include "src/compiler/machine-operator.h" |
11 #include "src/compiler/typer.h" | 9 #include "src/compiler/machine-type.h" |
12 #include "test/unittests/test-utils.h" | |
13 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
14 | 11 |
15 namespace v8 { | 12 namespace v8 { |
16 namespace internal { | 13 namespace internal { |
17 | 14 |
18 // Forward declarations. | 15 // Forward declarations. |
19 template <class T> | 16 class ExternalReference; |
20 class Handle; | |
21 class HeapObject; | 17 class HeapObject; |
22 template <class T> | 18 template <class T> |
23 class Unique; | 19 class Unique; |
24 | 20 |
25 namespace compiler { | 21 namespace compiler { |
26 | 22 |
27 // Forward declarations. | 23 // Forward declarations. |
| 24 class CallDescriptor; |
28 struct ElementAccess; | 25 struct ElementAccess; |
29 struct FieldAccess; | 26 struct FieldAccess; |
| 27 class Node; |
30 | 28 |
31 | 29 |
32 using ::testing::Matcher; | 30 using ::testing::Matcher; |
33 | 31 |
34 | 32 |
35 class GraphTest : public TestWithContext, public TestWithZone { | |
36 public: | |
37 explicit GraphTest(int parameters = 1); | |
38 virtual ~GraphTest(); | |
39 | |
40 protected: | |
41 Node* Parameter(int32_t index); | |
42 Node* Float32Constant(volatile float value); | |
43 Node* Float64Constant(volatile double value); | |
44 Node* Int32Constant(int32_t value); | |
45 Node* Uint32Constant(uint32_t value) { | |
46 return Int32Constant(bit_cast<int32_t>(value)); | |
47 } | |
48 Node* Int64Constant(int64_t value); | |
49 Node* NumberConstant(volatile double value); | |
50 Node* HeapConstant(const Handle<HeapObject>& value); | |
51 Node* HeapConstant(const Unique<HeapObject>& value); | |
52 Node* FalseConstant(); | |
53 Node* TrueConstant(); | |
54 Node* UndefinedConstant(); | |
55 | |
56 Matcher<Node*> IsFalseConstant(); | |
57 Matcher<Node*> IsTrueConstant(); | |
58 | |
59 CommonOperatorBuilder* common() { return &common_; } | |
60 Graph* graph() { return &graph_; } | |
61 | |
62 private: | |
63 CommonOperatorBuilder common_; | |
64 Graph graph_; | |
65 }; | |
66 | |
67 | |
68 class TypedGraphTest : public GraphTest { | |
69 public: | |
70 explicit TypedGraphTest(int parameters = 1) | |
71 : GraphTest(parameters), | |
72 typer_(graph(), MaybeHandle<Context>()) {} | |
73 | |
74 protected: | |
75 Typer* typer() { return &typer_; } | |
76 | |
77 private: | |
78 Typer typer_; | |
79 }; | |
80 | |
81 | |
82 Matcher<Node*> IsBranch(const Matcher<Node*>& value_matcher, | 33 Matcher<Node*> IsBranch(const Matcher<Node*>& value_matcher, |
83 const Matcher<Node*>& control_matcher); | 34 const Matcher<Node*>& control_matcher); |
84 Matcher<Node*> IsMerge(const Matcher<Node*>& control0_matcher, | 35 Matcher<Node*> IsMerge(const Matcher<Node*>& control0_matcher, |
85 const Matcher<Node*>& control1_matcher); | 36 const Matcher<Node*>& control1_matcher); |
86 Matcher<Node*> IsIfTrue(const Matcher<Node*>& control_matcher); | 37 Matcher<Node*> IsIfTrue(const Matcher<Node*>& control_matcher); |
87 Matcher<Node*> IsIfFalse(const Matcher<Node*>& control_matcher); | 38 Matcher<Node*> IsIfFalse(const Matcher<Node*>& control_matcher); |
88 Matcher<Node*> IsValueEffect(const Matcher<Node*>& value_matcher); | 39 Matcher<Node*> IsValueEffect(const Matcher<Node*>& value_matcher); |
89 Matcher<Node*> IsFinish(const Matcher<Node*>& value_matcher, | 40 Matcher<Node*> IsFinish(const Matcher<Node*>& value_matcher, |
90 const Matcher<Node*>& effect_matcher); | 41 const Matcher<Node*>& effect_matcher); |
91 Matcher<Node*> IsExternalConstant( | 42 Matcher<Node*> IsExternalConstant( |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 Matcher<Node*> IsChangeFloat64ToUint32(const Matcher<Node*>& input_matcher); | 134 Matcher<Node*> IsChangeFloat64ToUint32(const Matcher<Node*>& input_matcher); |
184 Matcher<Node*> IsChangeInt32ToFloat64(const Matcher<Node*>& input_matcher); | 135 Matcher<Node*> IsChangeInt32ToFloat64(const Matcher<Node*>& input_matcher); |
185 Matcher<Node*> IsChangeInt32ToInt64(const Matcher<Node*>& input_matcher); | 136 Matcher<Node*> IsChangeInt32ToInt64(const Matcher<Node*>& input_matcher); |
186 Matcher<Node*> IsChangeUint32ToFloat64(const Matcher<Node*>& input_matcher); | 137 Matcher<Node*> IsChangeUint32ToFloat64(const Matcher<Node*>& input_matcher); |
187 Matcher<Node*> IsChangeUint32ToUint64(const Matcher<Node*>& input_matcher); | 138 Matcher<Node*> IsChangeUint32ToUint64(const Matcher<Node*>& input_matcher); |
188 Matcher<Node*> IsTruncateFloat64ToFloat32(const Matcher<Node*>& input_matcher); | 139 Matcher<Node*> IsTruncateFloat64ToFloat32(const Matcher<Node*>& input_matcher); |
189 Matcher<Node*> IsTruncateFloat64ToInt32(const Matcher<Node*>& input_matcher); | 140 Matcher<Node*> IsTruncateFloat64ToInt32(const Matcher<Node*>& input_matcher); |
190 Matcher<Node*> IsTruncateInt64ToInt32(const Matcher<Node*>& input_matcher); | 141 Matcher<Node*> IsTruncateInt64ToInt32(const Matcher<Node*>& input_matcher); |
191 Matcher<Node*> IsFloat64Sqrt(const Matcher<Node*>& input_matcher); | 142 Matcher<Node*> IsFloat64Sqrt(const Matcher<Node*>& input_matcher); |
192 | 143 |
193 } // namespace compiler | 144 } // namespace compiler |
194 } // namespace internal | 145 } // namespace internal |
195 } // namespace v8 | 146 } // namespace v8 |
196 | 147 |
197 #endif // V8_UNITTESTS_COMPILER_GRAPH_UNITTEST_H_ | 148 #endif // V8_UNITTESTS_COMPILER_NODE_TEST_UTILS_H_ |
OLD | NEW |