Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(336)

Side by Side Diff: test/cctest/compiler/codegen-tester.h

Issue 470593002: Unify MachineType and RepType. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/compiler/call-tester.h ('k') | test/cctest/compiler/codegen-tester.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 = kMachNone,
95 MachineType p1 = kMachineLast, 95 MachineType p1 = kMachNone,
96 MachineType p2 = kMachineLast, 96 MachineType p2 = kMachNone,
97 MachineType p3 = kMachineLast, 97 MachineType p3 = kMachNone,
98 MachineType p4 = kMachineLast) 98 MachineType p4 = kMachNone)
99 : MachineAssemblerTester<RawMachineAssembler>( 99 : MachineAssemblerTester<RawMachineAssembler>(
100 ReturnValueTraits<ReturnType>::Representation(), p0, p1, p2, p3, 100 ReturnValueTraits<ReturnType>::Representation(), p0, p1, p2, p3,
101 p4) {} 101 p4) {}
102 102
103 template <typename Ci, typename Fn> 103 template <typename Ci, typename Fn>
104 void Run(const Ci& ci, const Fn& fn) { 104 void Run(const Ci& ci, const Fn& fn) {
105 typename Ci::const_iterator i; 105 typename Ci::const_iterator i;
106 for (i = ci.begin(); i != ci.end(); ++i) { 106 for (i = ci.begin(); i != ci.end(); ++i) {
107 CHECK_EQ(fn(*i), this->Call(*i)); 107 CHECK_EQ(fn(*i), this->Call(*i));
108 } 108 }
(...skipping 11 matching lines...) Expand all
120 } 120 }
121 }; 121 };
122 122
123 123
124 template <typename ReturnType> 124 template <typename ReturnType>
125 class StructuredMachineAssemblerTester 125 class StructuredMachineAssemblerTester
126 : public MachineAssemblerTester<StructuredMachineAssembler>, 126 : public MachineAssemblerTester<StructuredMachineAssembler>,
127 public CallHelper2<ReturnType, 127 public CallHelper2<ReturnType,
128 StructuredMachineAssemblerTester<ReturnType> > { 128 StructuredMachineAssemblerTester<ReturnType> > {
129 public: 129 public:
130 StructuredMachineAssemblerTester(MachineType p0 = kMachineLast, 130 StructuredMachineAssemblerTester(MachineType p0 = kMachNone,
131 MachineType p1 = kMachineLast, 131 MachineType p1 = kMachNone,
132 MachineType p2 = kMachineLast, 132 MachineType p2 = kMachNone,
133 MachineType p3 = kMachineLast, 133 MachineType p3 = kMachNone,
134 MachineType p4 = kMachineLast) 134 MachineType p4 = kMachNone)
135 : MachineAssemblerTester<StructuredMachineAssembler>( 135 : MachineAssemblerTester<StructuredMachineAssembler>(
136 ReturnValueTraits<ReturnType>::Representation(), p0, p1, p2, p3, 136 ReturnValueTraits<ReturnType>::Representation(), p0, p1, p2, p3,
137 p4) {} 137 p4) {}
138 }; 138 };
139 139
140 140
141 static const bool USE_RESULT_BUFFER = true; 141 static const bool USE_RESULT_BUFFER = true;
142 static const bool USE_RETURN_REGISTER = false; 142 static const bool USE_RETURN_REGISTER = false;
143 static const int32_t CHECK_VALUE = 0x99BEEDCE; 143 static const int32_t CHECK_VALUE = 0x99BEEDCE;
144 144
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 protected: 194 protected:
195 CType p0; 195 CType p0;
196 CType p1; 196 CType p1;
197 CType result; 197 CType result;
198 }; 198 };
199 199
200 200
201 // A helper class for testing code sequences that take two int parameters and 201 // A helper class for testing code sequences that take two int parameters and
202 // return an int value. 202 // return an int value.
203 class Int32BinopTester 203 class Int32BinopTester
204 : public BinopTester<int32_t, kMachineWord32, USE_RETURN_REGISTER> { 204 : public BinopTester<int32_t, kMachInt32, USE_RETURN_REGISTER> {
205 public: 205 public:
206 explicit Int32BinopTester(RawMachineAssemblerTester<int32_t>* tester) 206 explicit Int32BinopTester(RawMachineAssemblerTester<int32_t>* tester)
207 : BinopTester<int32_t, kMachineWord32, USE_RETURN_REGISTER>(tester) {} 207 : BinopTester<int32_t, kMachInt32, USE_RETURN_REGISTER>(tester) {}
208 };
208 209
209 int32_t call(uint32_t a0, uint32_t a1) { 210
210 p0 = static_cast<int32_t>(a0); 211 // A helper class for testing code sequences that take two uint parameters and
211 p1 = static_cast<int32_t>(a1); 212 // return an uint value.
212 return T->Call(); 213 class Uint32BinopTester
214 : public BinopTester<uint32_t, kMachUint32, USE_RETURN_REGISTER> {
215 public:
216 explicit Uint32BinopTester(RawMachineAssemblerTester<int32_t>* tester)
217 : BinopTester<uint32_t, kMachUint32, USE_RETURN_REGISTER>(tester) {}
218
219 uint32_t call(uint32_t a0, uint32_t a1) {
220 p0 = a0;
221 p1 = a1;
222 return static_cast<uint32_t>(T->Call());
213 } 223 }
214 }; 224 };
215 225
216 226
217 // A helper class for testing code sequences that take two double parameters and 227 // A helper class for testing code sequences that take two double parameters and
218 // return a double value. 228 // return a double value.
219 // TODO(titzer): figure out how to return doubles correctly on ia32. 229 // TODO(titzer): figure out how to return doubles correctly on ia32.
220 class Float64BinopTester 230 class Float64BinopTester
221 : public BinopTester<double, kMachineFloat64, USE_RESULT_BUFFER> { 231 : public BinopTester<double, kMachFloat64, USE_RESULT_BUFFER> {
222 public: 232 public:
223 explicit Float64BinopTester(RawMachineAssemblerTester<int32_t>* tester) 233 explicit Float64BinopTester(RawMachineAssemblerTester<int32_t>* tester)
224 : BinopTester<double, kMachineFloat64, USE_RESULT_BUFFER>(tester) {} 234 : BinopTester<double, kMachFloat64, USE_RESULT_BUFFER>(tester) {}
225 }; 235 };
226 236
227 237
228 // A helper class for testing code sequences that take two pointer parameters 238 // A helper class for testing code sequences that take two pointer parameters
229 // and return a pointer value. 239 // and return a pointer value.
230 // TODO(titzer): pick word size of pointers based on V8_TARGET. 240 // TODO(titzer): pick word size of pointers based on V8_TARGET.
231 template <typename Type> 241 template <typename Type>
232 class PointerBinopTester 242 class PointerBinopTester
233 : public BinopTester<Type*, kMachineWord32, USE_RETURN_REGISTER> { 243 : public BinopTester<Type*, kMachPtr, USE_RETURN_REGISTER> {
234 public: 244 public:
235 explicit PointerBinopTester(RawMachineAssemblerTester<int32_t>* tester) 245 explicit PointerBinopTester(RawMachineAssemblerTester<int32_t>* tester)
236 : BinopTester<Type*, kMachineWord32, USE_RETURN_REGISTER>(tester) {} 246 : BinopTester<Type*, kMachPtr, USE_RETURN_REGISTER>(tester) {}
237 }; 247 };
238 248
239 249
240 // A helper class for testing code sequences that take two tagged parameters and 250 // A helper class for testing code sequences that take two tagged parameters and
241 // return a tagged value. 251 // return a tagged value.
242 template <typename Type> 252 template <typename Type>
243 class TaggedBinopTester 253 class TaggedBinopTester
244 : public BinopTester<Type*, kMachineTagged, USE_RETURN_REGISTER> { 254 : public BinopTester<Type*, kMachAnyTagged, USE_RETURN_REGISTER> {
245 public: 255 public:
246 explicit TaggedBinopTester(RawMachineAssemblerTester<int32_t>* tester) 256 explicit TaggedBinopTester(RawMachineAssemblerTester<int32_t>* tester)
247 : BinopTester<Type*, kMachineTagged, USE_RETURN_REGISTER>(tester) {} 257 : BinopTester<Type*, kMachAnyTagged, USE_RETURN_REGISTER>(tester) {}
248 }; 258 };
249 259
250 // A helper class for testing compares. Wraps a machine opcode and provides 260 // A helper class for testing compares. Wraps a machine opcode and provides
251 // evaluation routines and the operators. 261 // evaluation routines and the operators.
252 class CompareWrapper { 262 class CompareWrapper {
253 public: 263 public:
254 explicit CompareWrapper(IrOpcode::Value op) : opcode(op) {} 264 explicit CompareWrapper(IrOpcode::Value op) : opcode(op) {}
255 265
256 Node* MakeNode(RawMachineAssemblerTester<int32_t>* m, Node* a, Node* b) { 266 Node* MakeNode(RawMachineAssemblerTester<int32_t>* m, Node* a, Node* b) {
257 return m->NewNode(op(m->machine()), a, b); 267 return m->NewNode(op(m->machine()), a, b);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 354
345 void Run(RawMachineAssemblerTester<int32_t>* m); 355 void Run(RawMachineAssemblerTester<int32_t>* m);
346 void RunLeft(RawMachineAssemblerTester<int32_t>* m); 356 void RunLeft(RawMachineAssemblerTester<int32_t>* m);
347 void RunRight(RawMachineAssemblerTester<int32_t>* m); 357 void RunRight(RawMachineAssemblerTester<int32_t>* m);
348 }; 358 };
349 } // namespace compiler 359 } // namespace compiler
350 } // namespace internal 360 } // namespace internal
351 } // namespace v8 361 } // namespace v8
352 362
353 #endif // V8_CCTEST_COMPILER_CODEGEN_TESTER_H_ 363 #endif // V8_CCTEST_COMPILER_CODEGEN_TESTER_H_
OLDNEW
« no previous file with comments | « test/cctest/compiler/call-tester.h ('k') | test/cctest/compiler/codegen-tester.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698