| 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/instruction-selector.h" | 10 #include "src/compiler/instruction-selector.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 Node* param0; | 136 Node* param0; |
| 137 Node* param1; | 137 Node* param1; |
| 138 | 138 |
| 139 CType call(CType a0, CType a1) { | 139 CType call(CType a0, CType a1) { |
| 140 p0 = a0; | 140 p0 = a0; |
| 141 p1 = a1; | 141 p1 = a1; |
| 142 if (use_result_buffer) { | 142 if (use_result_buffer) { |
| 143 CHECK_EQ(CHECK_VALUE, T->Call()); | 143 CHECK_EQ(CHECK_VALUE, T->Call()); |
| 144 return result; | 144 return result; |
| 145 } else { | 145 } else { |
| 146 return T->Call(); | 146 return static_cast<CType>(T->Call()); |
| 147 } | 147 } |
| 148 } | 148 } |
| 149 | 149 |
| 150 void AddReturn(Node* val) { | 150 void AddReturn(Node* val) { |
| 151 if (use_result_buffer) { | 151 if (use_result_buffer) { |
| 152 T->Store(rep, T->PointerConstant(&result), T->Int32Constant(0), val); | 152 T->Store(rep, T->PointerConstant(&result), T->Int32Constant(0), val); |
| 153 T->Return(T->Int32Constant(CHECK_VALUE)); | 153 T->Return(T->Int32Constant(CHECK_VALUE)); |
| 154 } else { | 154 } else { |
| 155 T->Return(val); | 155 T->Return(val); |
| 156 } | 156 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 : BinopTester<uint32_t, kMachUint32, USE_RETURN_REGISTER>(tester) {} | 193 : BinopTester<uint32_t, kMachUint32, USE_RETURN_REGISTER>(tester) {} |
| 194 | 194 |
| 195 uint32_t call(uint32_t a0, uint32_t a1) { | 195 uint32_t call(uint32_t a0, uint32_t a1) { |
| 196 p0 = a0; | 196 p0 = a0; |
| 197 p1 = a1; | 197 p1 = a1; |
| 198 return static_cast<uint32_t>(T->Call()); | 198 return static_cast<uint32_t>(T->Call()); |
| 199 } | 199 } |
| 200 }; | 200 }; |
| 201 | 201 |
| 202 | 202 |
| 203 // A helper class for testing code sequences that take two float parameters and |
| 204 // return a float value. |
| 205 // TODO(titzer): figure out how to return floats correctly on ia32. |
| 206 class Float32BinopTester |
| 207 : public BinopTester<float, kMachFloat32, USE_RESULT_BUFFER> { |
| 208 public: |
| 209 explicit Float32BinopTester(RawMachineAssemblerTester<int32_t>* tester) |
| 210 : BinopTester<float, kMachFloat32, USE_RESULT_BUFFER>(tester) {} |
| 211 }; |
| 212 |
| 213 |
| 203 // A helper class for testing code sequences that take two double parameters and | 214 // A helper class for testing code sequences that take two double parameters and |
| 204 // return a double value. | 215 // return a double value. |
| 205 // TODO(titzer): figure out how to return doubles correctly on ia32. | 216 // TODO(titzer): figure out how to return doubles correctly on ia32. |
| 206 class Float64BinopTester | 217 class Float64BinopTester |
| 207 : public BinopTester<double, kMachFloat64, USE_RESULT_BUFFER> { | 218 : public BinopTester<double, kMachFloat64, USE_RESULT_BUFFER> { |
| 208 public: | 219 public: |
| 209 explicit Float64BinopTester(RawMachineAssemblerTester<int32_t>* tester) | 220 explicit Float64BinopTester(RawMachineAssemblerTester<int32_t>* tester) |
| 210 : BinopTester<double, kMachFloat64, USE_RESULT_BUFFER>(tester) {} | 221 : BinopTester<double, kMachFloat64, USE_RESULT_BUFFER>(tester) {} |
| 211 }; | 222 }; |
| 212 | 223 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 BinopGen<int32_t>* gen; | 338 BinopGen<int32_t>* gen; |
| 328 int32_t input_a; | 339 int32_t input_a; |
| 329 int32_t input_b; | 340 int32_t input_b; |
| 330 | 341 |
| 331 void Run(RawMachineAssemblerTester<int32_t>* m); | 342 void Run(RawMachineAssemblerTester<int32_t>* m); |
| 332 void RunLeft(RawMachineAssemblerTester<int32_t>* m); | 343 void RunLeft(RawMachineAssemblerTester<int32_t>* m); |
| 333 void RunRight(RawMachineAssemblerTester<int32_t>* m); | 344 void RunRight(RawMachineAssemblerTester<int32_t>* m); |
| 334 }; | 345 }; |
| 335 | 346 |
| 336 // TODO(bmeurer): Drop this crap once we switch to GTest/Gmock. | 347 // TODO(bmeurer): Drop this crap once we switch to GTest/Gmock. |
| 348 static inline void CheckFloatEq(volatile float x, volatile float y) { |
| 349 if (std::isnan(x)) { |
| 350 CHECK(std::isnan(y)); |
| 351 } else { |
| 352 CHECK(x == y); |
| 353 } |
| 354 } |
| 355 |
| 337 static inline void CheckDoubleEq(volatile double x, volatile double y) { | 356 static inline void CheckDoubleEq(volatile double x, volatile double y) { |
| 338 if (std::isnan(x)) { | 357 if (std::isnan(x)) { |
| 339 CHECK(std::isnan(y)); | 358 CHECK(std::isnan(y)); |
| 340 } else { | 359 } else { |
| 341 CHECK_EQ(x, y); | 360 CHECK_EQ(x, y); |
| 342 } | 361 } |
| 343 } | 362 } |
| 344 | 363 |
| 345 } // namespace compiler | 364 } // namespace compiler |
| 346 } // namespace internal | 365 } // namespace internal |
| 347 } // namespace v8 | 366 } // namespace v8 |
| 348 | 367 |
| 349 #endif // V8_CCTEST_COMPILER_CODEGEN_TESTER_H_ | 368 #endif // V8_CCTEST_COMPILER_CODEGEN_TESTER_H_ |
| OLD | NEW |