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_CCTEST_COMPILER_CODEGEN_TESTER_H_ | 5 #ifndef V8_CCTEST_COMPILER_CODEGEN_TESTER_H_ |
6 #define V8_CCTEST_COMPILER_CODEGEN_TESTER_H_ | 6 #define V8_CCTEST_COMPILER_CODEGEN_TESTER_H_ |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/compiler/pipeline.h" | 10 #include "src/compiler/pipeline.h" |
11 #include "src/compiler/raw-machine-assembler.h" | 11 #include "src/compiler/raw-machine-assembler.h" |
12 #include "src/simulator.h" | 12 #include "src/simulator.h" |
13 #include "test/cctest/compiler/call-tester.h" | 13 #include "test/cctest/compiler/call-tester.h" |
14 #include "test/cctest/compiler/structured-machine-assembler.h" | |
15 | 14 |
16 namespace v8 { | 15 namespace v8 { |
17 namespace internal { | 16 namespace internal { |
18 namespace compiler { | 17 namespace compiler { |
19 | 18 |
20 template <typename MachineAssembler> | 19 template <typename MachineAssembler> |
21 class MachineAssemblerTester : public HandleAndZoneScope, | 20 class MachineAssemblerTester : public HandleAndZoneScope, |
22 public CallHelper, | 21 public CallHelper, |
23 public MachineAssembler { | 22 public MachineAssembler { |
24 public: | 23 public: |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 typename Cj::const_iterator j; | 106 typename Cj::const_iterator j; |
108 for (i = ci.begin(); i != ci.end(); ++i) { | 107 for (i = ci.begin(); i != ci.end(); ++i) { |
109 for (j = cj.begin(); j != cj.end(); ++j) { | 108 for (j = cj.begin(); j != cj.end(); ++j) { |
110 CHECK_EQ(fn(*i, *j), this->Call(*i, *j)); | 109 CHECK_EQ(fn(*i, *j), this->Call(*i, *j)); |
111 } | 110 } |
112 } | 111 } |
113 } | 112 } |
114 }; | 113 }; |
115 | 114 |
116 | 115 |
117 template <typename ReturnType> | |
118 class StructuredMachineAssemblerTester | |
119 : public MachineAssemblerTester<StructuredMachineAssembler>, | |
120 public CallHelper2<ReturnType, | |
121 StructuredMachineAssemblerTester<ReturnType> > { | |
122 public: | |
123 StructuredMachineAssemblerTester(MachineType p0 = kMachNone, | |
124 MachineType p1 = kMachNone, | |
125 MachineType p2 = kMachNone, | |
126 MachineType p3 = kMachNone, | |
127 MachineType p4 = kMachNone) | |
128 : MachineAssemblerTester<StructuredMachineAssembler>( | |
129 ReturnValueTraits<ReturnType>::Representation(), p0, p1, p2, p3, | |
130 p4) {} | |
131 }; | |
132 | |
133 | |
134 static const bool USE_RESULT_BUFFER = true; | 116 static const bool USE_RESULT_BUFFER = true; |
135 static const bool USE_RETURN_REGISTER = false; | 117 static const bool USE_RETURN_REGISTER = false; |
136 static const int32_t CHECK_VALUE = 0x99BEEDCE; | 118 static const int32_t CHECK_VALUE = 0x99BEEDCE; |
137 | 119 |
138 | 120 |
139 // TODO(titzer): use the C-style calling convention, or any register-based | 121 // TODO(titzer): use the C-style calling convention, or any register-based |
140 // calling convention for binop tests. | 122 // calling convention for binop tests. |
141 template <typename CType, MachineType rep, bool use_result_buffer> | 123 template <typename CType, MachineType rep, bool use_result_buffer> |
142 class BinopTester { | 124 class BinopTester { |
143 public: | 125 public: |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 | 329 |
348 void Run(RawMachineAssemblerTester<int32_t>* m); | 330 void Run(RawMachineAssemblerTester<int32_t>* m); |
349 void RunLeft(RawMachineAssemblerTester<int32_t>* m); | 331 void RunLeft(RawMachineAssemblerTester<int32_t>* m); |
350 void RunRight(RawMachineAssemblerTester<int32_t>* m); | 332 void RunRight(RawMachineAssemblerTester<int32_t>* m); |
351 }; | 333 }; |
352 } // namespace compiler | 334 } // namespace compiler |
353 } // namespace internal | 335 } // namespace internal |
354 } // namespace v8 | 336 } // namespace v8 |
355 | 337 |
356 #endif // V8_CCTEST_COMPILER_CODEGEN_TESTER_H_ | 338 #endif // V8_CCTEST_COMPILER_CODEGEN_TESTER_H_ |
OLD | NEW |