Chromium Code Reviews| 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" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 private: | 84 private: |
| 85 MaybeHandle<Code> code_; | 85 MaybeHandle<Code> code_; |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 | 88 |
| 89 template <typename ReturnType> | 89 template <typename ReturnType> |
| 90 class RawMachineAssemblerTester | 90 class RawMachineAssemblerTester |
| 91 : public MachineAssemblerTester<RawMachineAssembler>, | 91 : public MachineAssemblerTester<RawMachineAssembler>, |
| 92 public CallHelper2<ReturnType, RawMachineAssemblerTester<ReturnType> > { | 92 public CallHelper2<ReturnType, RawMachineAssemblerTester<ReturnType> > { |
| 93 public: | 93 public: |
| 94 RawMachineAssemblerTester(MachineType p0 = kMachineLast, | 94 RawMachineAssemblerTester(MachineType p0 = mNone, MachineType p1 = mNone, |
| 95 MachineType p1 = kMachineLast, | 95 MachineType p2 = mNone, MachineType p3 = mNone, |
| 96 MachineType p2 = kMachineLast, | 96 MachineType p4 = mNone) |
| 97 MachineType p3 = kMachineLast, | |
| 98 MachineType p4 = kMachineLast) | |
| 99 : MachineAssemblerTester<RawMachineAssembler>( | 97 : MachineAssemblerTester<RawMachineAssembler>( |
| 100 ReturnValueTraits<ReturnType>::Representation(), p0, p1, p2, p3, | 98 ReturnValueTraits<ReturnType>::Representation(), p0, p1, p2, p3, |
| 101 p4) {} | 99 p4) {} |
| 102 | 100 |
| 103 template <typename Ci, typename Fn> | 101 template <typename Ci, typename Fn> |
| 104 void Run(const Ci& ci, const Fn& fn) { | 102 void Run(const Ci& ci, const Fn& fn) { |
| 105 typename Ci::const_iterator i; | 103 typename Ci::const_iterator i; |
| 106 for (i = ci.begin(); i != ci.end(); ++i) { | 104 for (i = ci.begin(); i != ci.end(); ++i) { |
| 107 CHECK_EQ(fn(*i), this->Call(*i)); | 105 CHECK_EQ(fn(*i), this->Call(*i)); |
| 108 } | 106 } |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 120 } | 118 } |
| 121 }; | 119 }; |
| 122 | 120 |
| 123 | 121 |
| 124 template <typename ReturnType> | 122 template <typename ReturnType> |
| 125 class StructuredMachineAssemblerTester | 123 class StructuredMachineAssemblerTester |
| 126 : public MachineAssemblerTester<StructuredMachineAssembler>, | 124 : public MachineAssemblerTester<StructuredMachineAssembler>, |
| 127 public CallHelper2<ReturnType, | 125 public CallHelper2<ReturnType, |
| 128 StructuredMachineAssemblerTester<ReturnType> > { | 126 StructuredMachineAssemblerTester<ReturnType> > { |
| 129 public: | 127 public: |
| 130 StructuredMachineAssemblerTester(MachineType p0 = kMachineLast, | 128 StructuredMachineAssemblerTester(MachineType p0 = mNone, |
| 131 MachineType p1 = kMachineLast, | 129 MachineType p1 = mNone, |
| 132 MachineType p2 = kMachineLast, | 130 MachineType p2 = mNone, |
| 133 MachineType p3 = kMachineLast, | 131 MachineType p3 = mNone, |
| 134 MachineType p4 = kMachineLast) | 132 MachineType p4 = mNone) |
| 135 : MachineAssemblerTester<StructuredMachineAssembler>( | 133 : MachineAssemblerTester<StructuredMachineAssembler>( |
| 136 ReturnValueTraits<ReturnType>::Representation(), p0, p1, p2, p3, | 134 ReturnValueTraits<ReturnType>::Representation(), p0, p1, p2, p3, |
| 137 p4) {} | 135 p4) {} |
| 138 }; | 136 }; |
| 139 | 137 |
| 140 | 138 |
| 141 static const bool USE_RESULT_BUFFER = true; | 139 static const bool USE_RESULT_BUFFER = true; |
| 142 static const bool USE_RETURN_REGISTER = false; | 140 static const bool USE_RETURN_REGISTER = false; |
| 143 static const int32_t CHECK_VALUE = 0x99BEEDCE; | 141 static const int32_t CHECK_VALUE = 0x99BEEDCE; |
| 144 | 142 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 protected: | 192 protected: |
| 195 CType p0; | 193 CType p0; |
| 196 CType p1; | 194 CType p1; |
| 197 CType result; | 195 CType result; |
| 198 }; | 196 }; |
| 199 | 197 |
| 200 | 198 |
| 201 // A helper class for testing code sequences that take two int parameters and | 199 // A helper class for testing code sequences that take two int parameters and |
| 202 // return an int value. | 200 // return an int value. |
| 203 class Int32BinopTester | 201 class Int32BinopTester |
| 204 : public BinopTester<int32_t, kMachineWord32, USE_RETURN_REGISTER> { | 202 : public BinopTester<int32_t, mInt32, USE_RETURN_REGISTER> { |
| 205 public: | 203 public: |
| 206 explicit Int32BinopTester(RawMachineAssemblerTester<int32_t>* tester) | 204 explicit Int32BinopTester(RawMachineAssemblerTester<int32_t>* tester) |
| 207 : BinopTester<int32_t, kMachineWord32, USE_RETURN_REGISTER>(tester) {} | 205 : BinopTester<int32_t, mInt32, USE_RETURN_REGISTER>(tester) {} |
| 206 }; | |
| 208 | 207 |
| 209 int32_t call(uint32_t a0, uint32_t a1) { | 208 |
| 210 p0 = static_cast<int32_t>(a0); | 209 // A helper class for testing code sequences that take two int parameters and |
| 211 p1 = static_cast<int32_t>(a1); | 210 // return an int value. |
|
Michael Starzinger
2014/08/13 15:40:05
nit: s/int/uint/ (twice).
titzer
2014/08/13 16:12:59
Done.
| |
| 212 return T->Call(); | 211 class Uint32BinopTester |
| 212 : public BinopTester<uint32_t, mUint32, USE_RETURN_REGISTER> { | |
| 213 public: | |
| 214 explicit Uint32BinopTester(RawMachineAssemblerTester<int32_t>* tester) | |
| 215 : BinopTester<uint32_t, mUint32, USE_RETURN_REGISTER>(tester) {} | |
| 216 | |
| 217 uint32_t call(uint32_t a0, uint32_t a1) { | |
| 218 p0 = a0; | |
| 219 p1 = a1; | |
| 220 return static_cast<uint32_t>(T->Call()); | |
| 213 } | 221 } |
| 214 }; | 222 }; |
| 215 | 223 |
| 216 | 224 |
| 217 // A helper class for testing code sequences that take two double parameters and | 225 // A helper class for testing code sequences that take two double parameters and |
| 218 // return a double value. | 226 // return a double value. |
| 219 // TODO(titzer): figure out how to return doubles correctly on ia32. | 227 // TODO(titzer): figure out how to return doubles correctly on ia32. |
| 220 class Float64BinopTester | 228 class Float64BinopTester |
| 221 : public BinopTester<double, kMachineFloat64, USE_RESULT_BUFFER> { | 229 : public BinopTester<double, mFloat64, USE_RESULT_BUFFER> { |
| 222 public: | 230 public: |
| 223 explicit Float64BinopTester(RawMachineAssemblerTester<int32_t>* tester) | 231 explicit Float64BinopTester(RawMachineAssemblerTester<int32_t>* tester) |
| 224 : BinopTester<double, kMachineFloat64, USE_RESULT_BUFFER>(tester) {} | 232 : BinopTester<double, mFloat64, USE_RESULT_BUFFER>(tester) {} |
| 225 }; | 233 }; |
| 226 | 234 |
| 227 | 235 |
| 228 // A helper class for testing code sequences that take two pointer parameters | 236 // A helper class for testing code sequences that take two pointer parameters |
| 229 // and return a pointer value. | 237 // and return a pointer value. |
| 230 // TODO(titzer): pick word size of pointers based on V8_TARGET. | 238 // TODO(titzer): pick word size of pointers based on V8_TARGET. |
| 231 template <typename Type> | 239 template <typename Type> |
| 232 class PointerBinopTester | 240 class PointerBinopTester |
| 233 : public BinopTester<Type*, kMachineWord32, USE_RETURN_REGISTER> { | 241 : public BinopTester<Type*, mPtr, USE_RETURN_REGISTER> { |
| 234 public: | 242 public: |
| 235 explicit PointerBinopTester(RawMachineAssemblerTester<int32_t>* tester) | 243 explicit PointerBinopTester(RawMachineAssemblerTester<int32_t>* tester) |
| 236 : BinopTester<Type*, kMachineWord32, USE_RETURN_REGISTER>(tester) {} | 244 : BinopTester<Type*, mPtr, USE_RETURN_REGISTER>(tester) {} |
| 237 }; | 245 }; |
| 238 | 246 |
| 239 | 247 |
| 240 // A helper class for testing code sequences that take two tagged parameters and | 248 // A helper class for testing code sequences that take two tagged parameters and |
| 241 // return a tagged value. | 249 // return a tagged value. |
| 242 template <typename Type> | 250 template <typename Type> |
| 243 class TaggedBinopTester | 251 class TaggedBinopTester |
| 244 : public BinopTester<Type*, kMachineTagged, USE_RETURN_REGISTER> { | 252 : public BinopTester<Type*, mAnyTagged, USE_RETURN_REGISTER> { |
| 245 public: | 253 public: |
| 246 explicit TaggedBinopTester(RawMachineAssemblerTester<int32_t>* tester) | 254 explicit TaggedBinopTester(RawMachineAssemblerTester<int32_t>* tester) |
| 247 : BinopTester<Type*, kMachineTagged, USE_RETURN_REGISTER>(tester) {} | 255 : BinopTester<Type*, mAnyTagged, USE_RETURN_REGISTER>(tester) {} |
| 248 }; | 256 }; |
| 249 | 257 |
| 250 // A helper class for testing compares. Wraps a machine opcode and provides | 258 // A helper class for testing compares. Wraps a machine opcode and provides |
| 251 // evaluation routines and the operators. | 259 // evaluation routines and the operators. |
| 252 class CompareWrapper { | 260 class CompareWrapper { |
| 253 public: | 261 public: |
| 254 explicit CompareWrapper(IrOpcode::Value op) : opcode(op) {} | 262 explicit CompareWrapper(IrOpcode::Value op) : opcode(op) {} |
| 255 | 263 |
| 256 Node* MakeNode(RawMachineAssemblerTester<int32_t>* m, Node* a, Node* b) { | 264 Node* MakeNode(RawMachineAssemblerTester<int32_t>* m, Node* a, Node* b) { |
| 257 return m->NewNode(op(m->machine()), a, b); | 265 return m->NewNode(op(m->machine()), a, b); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 344 | 352 |
| 345 void Run(RawMachineAssemblerTester<int32_t>* m); | 353 void Run(RawMachineAssemblerTester<int32_t>* m); |
| 346 void RunLeft(RawMachineAssemblerTester<int32_t>* m); | 354 void RunLeft(RawMachineAssemblerTester<int32_t>* m); |
| 347 void RunRight(RawMachineAssemblerTester<int32_t>* m); | 355 void RunRight(RawMachineAssemblerTester<int32_t>* m); |
| 348 }; | 356 }; |
| 349 } // namespace compiler | 357 } // namespace compiler |
| 350 } // namespace internal | 358 } // namespace internal |
| 351 } // namespace v8 | 359 } // namespace v8 |
| 352 | 360 |
| 353 #endif // V8_CCTEST_COMPILER_CODEGEN_TESTER_H_ | 361 #endif // V8_CCTEST_COMPILER_CODEGEN_TESTER_H_ |
| OLD | NEW |