| 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_GRAPH_UNITTEST_H_ |
| 6 #define V8_UNITTESTS_COMPILER_GRAPH_UNITTEST_H_ | 6 #define V8_UNITTESTS_COMPILER_GRAPH_UNITTEST_H_ |
| 7 | 7 |
| 8 #include "src/compiler/common-operator.h" | 8 #include "src/compiler/common-operator.h" |
| 9 #include "src/compiler/graph.h" | 9 #include "src/compiler/graph.h" |
| 10 #include "src/compiler/machine-operator.h" | 10 #include "src/compiler/machine-operator.h" |
| 11 #include "src/compiler/typer.h" | 11 #include "src/compiler/typer.h" |
| 12 #include "test/unittests/test-utils.h" | 12 #include "test/unittests/test-utils.h" |
| 13 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
| 14 | 14 |
| 15 namespace v8 { | 15 namespace v8 { |
| 16 namespace internal { | 16 namespace internal { |
| 17 | 17 |
| 18 // Forward declarations. | 18 // Forward declarations. |
| 19 template <class T> | 19 template <class T> |
| 20 class Handle; | 20 class Handle; |
| 21 class HeapObject; | 21 class HeapObject; |
| 22 template <class T> | 22 template <class T> |
| 23 class Unique; | 23 class Unique; |
| 24 | 24 |
| 25 namespace compiler { | 25 namespace compiler { |
| 26 | 26 |
| 27 // Forward declarations. | |
| 28 struct ElementAccess; | |
| 29 struct FieldAccess; | |
| 30 | |
| 31 | |
| 32 using ::testing::Matcher; | 27 using ::testing::Matcher; |
| 33 | 28 |
| 34 | 29 |
| 35 class GraphTest : public TestWithContext, public TestWithZone { | 30 class GraphTest : public TestWithContext, public TestWithZone { |
| 36 public: | 31 public: |
| 37 explicit GraphTest(int parameters = 1); | 32 explicit GraphTest(int parameters = 1); |
| 38 virtual ~GraphTest(); | 33 virtual ~GraphTest(); |
| 39 | 34 |
| 40 protected: | 35 protected: |
| 41 Node* Parameter(int32_t index); | 36 Node* Parameter(int32_t index); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 61 | 56 |
| 62 private: | 57 private: |
| 63 CommonOperatorBuilder common_; | 58 CommonOperatorBuilder common_; |
| 64 Graph graph_; | 59 Graph graph_; |
| 65 }; | 60 }; |
| 66 | 61 |
| 67 | 62 |
| 68 class TypedGraphTest : public GraphTest { | 63 class TypedGraphTest : public GraphTest { |
| 69 public: | 64 public: |
| 70 explicit TypedGraphTest(int parameters = 1) | 65 explicit TypedGraphTest(int parameters = 1) |
| 71 : GraphTest(parameters), | 66 : GraphTest(parameters), typer_(graph(), MaybeHandle<Context>()) {} |
| 72 typer_(graph(), MaybeHandle<Context>()) {} | |
| 73 | 67 |
| 74 protected: | 68 protected: |
| 75 Typer* typer() { return &typer_; } | 69 Typer* typer() { return &typer_; } |
| 76 | 70 |
| 77 private: | 71 private: |
| 78 Typer typer_; | 72 Typer typer_; |
| 79 }; | 73 }; |
| 80 | 74 |
| 81 | |
| 82 Matcher<Node*> IsBranch(const Matcher<Node*>& value_matcher, | |
| 83 const Matcher<Node*>& control_matcher); | |
| 84 Matcher<Node*> IsMerge(const Matcher<Node*>& control0_matcher, | |
| 85 const Matcher<Node*>& control1_matcher); | |
| 86 Matcher<Node*> IsIfTrue(const Matcher<Node*>& control_matcher); | |
| 87 Matcher<Node*> IsIfFalse(const Matcher<Node*>& control_matcher); | |
| 88 Matcher<Node*> IsValueEffect(const Matcher<Node*>& value_matcher); | |
| 89 Matcher<Node*> IsFinish(const Matcher<Node*>& value_matcher, | |
| 90 const Matcher<Node*>& effect_matcher); | |
| 91 Matcher<Node*> IsExternalConstant( | |
| 92 const Matcher<ExternalReference>& value_matcher); | |
| 93 Matcher<Node*> IsHeapConstant( | |
| 94 const Matcher<Unique<HeapObject> >& value_matcher); | |
| 95 Matcher<Node*> IsFloat32Constant(const Matcher<float>& value_matcher); | |
| 96 Matcher<Node*> IsFloat64Constant(const Matcher<double>& value_matcher); | |
| 97 Matcher<Node*> IsInt32Constant(const Matcher<int32_t>& value_matcher); | |
| 98 Matcher<Node*> IsInt64Constant(const Matcher<int64_t>& value_matcher); | |
| 99 Matcher<Node*> IsNumberConstant(const Matcher<double>& value_matcher); | |
| 100 Matcher<Node*> IsPhi(const Matcher<MachineType>& type_matcher, | |
| 101 const Matcher<Node*>& value0_matcher, | |
| 102 const Matcher<Node*>& value1_matcher, | |
| 103 const Matcher<Node*>& merge_matcher); | |
| 104 Matcher<Node*> IsProjection(const Matcher<size_t>& index_matcher, | |
| 105 const Matcher<Node*>& base_matcher); | |
| 106 Matcher<Node*> IsCall(const Matcher<CallDescriptor*>& descriptor_matcher, | |
| 107 const Matcher<Node*>& value0_matcher, | |
| 108 const Matcher<Node*>& value1_matcher, | |
| 109 const Matcher<Node*>& value2_matcher, | |
| 110 const Matcher<Node*>& value3_matcher, | |
| 111 const Matcher<Node*>& effect_matcher, | |
| 112 const Matcher<Node*>& control_matcher); | |
| 113 | |
| 114 Matcher<Node*> IsNumberLessThan(const Matcher<Node*>& lhs_matcher, | |
| 115 const Matcher<Node*>& rhs_matcher); | |
| 116 Matcher<Node*> IsNumberSubtract(const Matcher<Node*>& lhs_matcher, | |
| 117 const Matcher<Node*>& rhs_matcher); | |
| 118 Matcher<Node*> IsLoadField(const Matcher<FieldAccess>& access_matcher, | |
| 119 const Matcher<Node*>& base_matcher, | |
| 120 const Matcher<Node*>& effect_matcher); | |
| 121 Matcher<Node*> IsLoadElement(const Matcher<ElementAccess>& access_matcher, | |
| 122 const Matcher<Node*>& base_matcher, | |
| 123 const Matcher<Node*>& index_matcher, | |
| 124 const Matcher<Node*>& length_matcher, | |
| 125 const Matcher<Node*>& effect_matcher, | |
| 126 const Matcher<Node*>& control_matcher); | |
| 127 Matcher<Node*> IsStoreElement(const Matcher<ElementAccess>& access_matcher, | |
| 128 const Matcher<Node*>& base_matcher, | |
| 129 const Matcher<Node*>& index_matcher, | |
| 130 const Matcher<Node*>& length_matcher, | |
| 131 const Matcher<Node*>& value_matcher, | |
| 132 const Matcher<Node*>& effect_matcher, | |
| 133 const Matcher<Node*>& control_matcher); | |
| 134 | |
| 135 Matcher<Node*> IsLoad(const Matcher<LoadRepresentation>& rep_matcher, | |
| 136 const Matcher<Node*>& base_matcher, | |
| 137 const Matcher<Node*>& index_matcher, | |
| 138 const Matcher<Node*>& effect_matcher, | |
| 139 const Matcher<Node*>& control_matcher); | |
| 140 Matcher<Node*> IsStore(const Matcher<StoreRepresentation>& rep_matcher, | |
| 141 const Matcher<Node*>& base_matcher, | |
| 142 const Matcher<Node*>& index_matcher, | |
| 143 const Matcher<Node*>& value_matcher, | |
| 144 const Matcher<Node*>& effect_matcher, | |
| 145 const Matcher<Node*>& control_matcher); | |
| 146 Matcher<Node*> IsWord32And(const Matcher<Node*>& lhs_matcher, | |
| 147 const Matcher<Node*>& rhs_matcher); | |
| 148 Matcher<Node*> IsWord32Sar(const Matcher<Node*>& lhs_matcher, | |
| 149 const Matcher<Node*>& rhs_matcher); | |
| 150 Matcher<Node*> IsWord32Shl(const Matcher<Node*>& lhs_matcher, | |
| 151 const Matcher<Node*>& rhs_matcher); | |
| 152 Matcher<Node*> IsWord32Shr(const Matcher<Node*>& lhs_matcher, | |
| 153 const Matcher<Node*>& rhs_matcher); | |
| 154 Matcher<Node*> IsWord32Ror(const Matcher<Node*>& lhs_matcher, | |
| 155 const Matcher<Node*>& rhs_matcher); | |
| 156 Matcher<Node*> IsWord32Equal(const Matcher<Node*>& lhs_matcher, | |
| 157 const Matcher<Node*>& rhs_matcher); | |
| 158 Matcher<Node*> IsWord64And(const Matcher<Node*>& lhs_matcher, | |
| 159 const Matcher<Node*>& rhs_matcher); | |
| 160 Matcher<Node*> IsWord64Shl(const Matcher<Node*>& lhs_matcher, | |
| 161 const Matcher<Node*>& rhs_matcher); | |
| 162 Matcher<Node*> IsWord64Sar(const Matcher<Node*>& lhs_matcher, | |
| 163 const Matcher<Node*>& rhs_matcher); | |
| 164 Matcher<Node*> IsWord64Equal(const Matcher<Node*>& lhs_matcher, | |
| 165 const Matcher<Node*>& rhs_matcher); | |
| 166 Matcher<Node*> IsInt32AddWithOverflow(const Matcher<Node*>& lhs_matcher, | |
| 167 const Matcher<Node*>& rhs_matcher); | |
| 168 Matcher<Node*> IsInt32Add(const Matcher<Node*>& lhs_matcher, | |
| 169 const Matcher<Node*>& rhs_matcher); | |
| 170 Matcher<Node*> IsInt32Sub(const Matcher<Node*>& lhs_matcher, | |
| 171 const Matcher<Node*>& rhs_matcher); | |
| 172 Matcher<Node*> IsInt32Mul(const Matcher<Node*>& lhs_matcher, | |
| 173 const Matcher<Node*>& rhs_matcher); | |
| 174 Matcher<Node*> IsInt32MulHigh(const Matcher<Node*>& lhs_matcher, | |
| 175 const Matcher<Node*>& rhs_matcher); | |
| 176 Matcher<Node*> IsInt32LessThan(const Matcher<Node*>& lhs_matcher, | |
| 177 const Matcher<Node*>& rhs_matcher); | |
| 178 Matcher<Node*> IsUint32LessThan(const Matcher<Node*>& lhs_matcher, | |
| 179 const Matcher<Node*>& rhs_matcher); | |
| 180 Matcher<Node*> IsUint32LessThanOrEqual(const Matcher<Node*>& lhs_matcher, | |
| 181 const Matcher<Node*>& rhs_matcher); | |
| 182 Matcher<Node*> IsChangeFloat64ToInt32(const Matcher<Node*>& input_matcher); | |
| 183 Matcher<Node*> IsChangeFloat64ToUint32(const Matcher<Node*>& input_matcher); | |
| 184 Matcher<Node*> IsChangeInt32ToFloat64(const Matcher<Node*>& input_matcher); | |
| 185 Matcher<Node*> IsChangeInt32ToInt64(const Matcher<Node*>& input_matcher); | |
| 186 Matcher<Node*> IsChangeUint32ToFloat64(const Matcher<Node*>& input_matcher); | |
| 187 Matcher<Node*> IsChangeUint32ToUint64(const Matcher<Node*>& input_matcher); | |
| 188 Matcher<Node*> IsTruncateFloat64ToFloat32(const Matcher<Node*>& input_matcher); | |
| 189 Matcher<Node*> IsTruncateFloat64ToInt32(const Matcher<Node*>& input_matcher); | |
| 190 Matcher<Node*> IsTruncateInt64ToInt32(const Matcher<Node*>& input_matcher); | |
| 191 Matcher<Node*> IsFloat64Sqrt(const Matcher<Node*>& input_matcher); | |
| 192 | |
| 193 } // namespace compiler | 75 } // namespace compiler |
| 194 } // namespace internal | 76 } // namespace internal |
| 195 } // namespace v8 | 77 } // namespace v8 |
| 196 | 78 |
| 197 #endif // V8_UNITTESTS_COMPILER_GRAPH_UNITTEST_H_ | 79 #endif // V8_UNITTESTS_COMPILER_GRAPH_UNITTEST_H_ |
| OLD | NEW |