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

Side by Side Diff: test/cctest/compiler/test-representation-change.cc

Issue 576973003: Hack representation inference to assume current behavior of float32 loads and stores, which include… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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
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 #include <limits> 5 #include <limits>
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 #include "test/cctest/cctest.h" 8 #include "test/cctest/cctest.h"
9 #include "test/cctest/compiler/graph-builder-tester.h" 9 #include "test/cctest/compiler/graph-builder-tester.h"
10 10
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 Node* n = Parameter(0); 81 Node* n = Parameter(0);
82 Node* c = changer()->GetRepresentationFor(n, from, to); 82 Node* c = changer()->GetRepresentationFor(n, from, to);
83 CHECK_EQ(n, c); 83 CHECK_EQ(n, c);
84 } 84 }
85 }; 85 };
86 } 86 }
87 } 87 }
88 } // namespace v8::internal::compiler 88 } // namespace v8::internal::compiler
89 89
90 90
91 // TODO(titzer): add kRepFloat32 when fully supported.
91 static const MachineType all_reps[] = {kRepBit, kRepWord32, kRepWord64, 92 static const MachineType all_reps[] = {kRepBit, kRepWord32, kRepWord64,
92 kRepFloat64, kRepTagged}; 93 kRepFloat64, kRepTagged};
93 94
94 95
95 // TODO(titzer): lift this to ValueHelper 96 // TODO(titzer): lift this to ValueHelper
96 static const double double_inputs[] = { 97 static const double double_inputs[] = {
97 0.0, -0.0, 1.0, -1.0, 0.1, 1.4, -1.7, 98 0.0, -0.0, 1.0, -1.0, 0.1, 1.4, -1.7,
98 2, 5, 6, 982983, 888, -999.8, 3.1e7, 99 2, 5, 6, 982983, 888, -999.8, 3.1e7,
99 -2e66, 2.3e124, -12e73, V8_INFINITY, -V8_INFINITY}; 100 -2e66, 2.3e124, -12e73, V8_INFINITY, -V8_INFINITY};
100 101
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 219
219 220
220 TEST(Nops) { 221 TEST(Nops) {
221 RepresentationChangerTester r; 222 RepresentationChangerTester r;
222 223
223 // X -> X is always a nop for any single representation X. 224 // X -> X is always a nop for any single representation X.
224 for (size_t i = 0; i < arraysize(all_reps); i++) { 225 for (size_t i = 0; i < arraysize(all_reps); i++) {
225 r.CheckNop(all_reps[i], all_reps[i]); 226 r.CheckNop(all_reps[i], all_reps[i]);
226 } 227 }
227 228
229 // 32-bit floats.
230 r.CheckNop(kRepFloat32, kRepFloat32);
231 r.CheckNop(kRepFloat32 | kTypeNumber, kRepFloat32);
232 r.CheckNop(kRepFloat32, kRepFloat32 | kTypeNumber);
233
228 // 32-bit or 64-bit words can be used as branch conditions (kRepBit). 234 // 32-bit or 64-bit words can be used as branch conditions (kRepBit).
229 r.CheckNop(kRepWord32, kRepBit); 235 r.CheckNop(kRepWord32, kRepBit);
230 r.CheckNop(kRepWord32, kRepBit | kTypeBool); 236 r.CheckNop(kRepWord32, kRepBit | kTypeBool);
231 r.CheckNop(kRepWord64, kRepBit); 237 r.CheckNop(kRepWord64, kRepBit);
232 r.CheckNop(kRepWord64, kRepBit | kTypeBool); 238 r.CheckNop(kRepWord64, kRepBit | kTypeBool);
233 239
234 // 32-bit words can be used as smaller word sizes and vice versa, because 240 // 32-bit words can be used as smaller word sizes and vice versa, because
235 // loads from memory implicitly sign or zero extend the value to the 241 // loads from memory implicitly sign or zero extend the value to the
236 // full machine word size, and stores implicitly truncate. 242 // full machine word size, and stores implicitly truncate.
237 r.CheckNop(kRepWord32, kRepWord8); 243 r.CheckNop(kRepWord32, kRepWord8);
(...skipping 16 matching lines...) Expand all
254 260
255 TEST(TypeErrors) { 261 TEST(TypeErrors) {
256 RepresentationChangerTester r; 262 RepresentationChangerTester r;
257 263
258 // Floats cannot be implicitly converted to/from comparison conditions. 264 // Floats cannot be implicitly converted to/from comparison conditions.
259 r.CheckTypeError(kRepFloat64, kRepBit); 265 r.CheckTypeError(kRepFloat64, kRepBit);
260 r.CheckTypeError(kRepFloat64, kRepBit | kTypeBool); 266 r.CheckTypeError(kRepFloat64, kRepBit | kTypeBool);
261 r.CheckTypeError(kRepBit, kRepFloat64); 267 r.CheckTypeError(kRepBit, kRepFloat64);
262 r.CheckTypeError(kRepBit | kTypeBool, kRepFloat64); 268 r.CheckTypeError(kRepBit | kTypeBool, kRepFloat64);
263 269
270 // Floats cannot be implicitly converted to/from comparison conditions.
271 r.CheckTypeError(kRepFloat32, kRepBit);
272 r.CheckTypeError(kRepFloat32, kRepBit | kTypeBool);
273 r.CheckTypeError(kRepBit, kRepFloat32);
274 r.CheckTypeError(kRepBit | kTypeBool, kRepFloat32);
275
264 // Word64 is internal and shouldn't be implicitly converted. 276 // Word64 is internal and shouldn't be implicitly converted.
265 r.CheckTypeError(kRepWord64, kRepTagged | kTypeBool); 277 r.CheckTypeError(kRepWord64, kRepTagged | kTypeBool);
266 r.CheckTypeError(kRepWord64, kRepTagged); 278 r.CheckTypeError(kRepWord64, kRepTagged);
267 r.CheckTypeError(kRepWord64, kRepTagged | kTypeBool); 279 r.CheckTypeError(kRepWord64, kRepTagged | kTypeBool);
268 r.CheckTypeError(kRepTagged, kRepWord64); 280 r.CheckTypeError(kRepTagged, kRepWord64);
269 r.CheckTypeError(kRepTagged | kTypeBool, kRepWord64); 281 r.CheckTypeError(kRepTagged | kTypeBool, kRepWord64);
270 282
271 // Word64 / Word32 shouldn't be implicitly converted. 283 // Word64 / Word32 shouldn't be implicitly converted.
272 r.CheckTypeError(kRepWord64, kRepWord32); 284 r.CheckTypeError(kRepWord64, kRepWord32);
273 r.CheckTypeError(kRepWord32, kRepWord64); 285 r.CheckTypeError(kRepWord32, kRepWord64);
274 r.CheckTypeError(kRepWord64, kRepWord32 | kTypeInt32); 286 r.CheckTypeError(kRepWord64, kRepWord32 | kTypeInt32);
275 r.CheckTypeError(kRepWord32 | kTypeInt32, kRepWord64); 287 r.CheckTypeError(kRepWord32 | kTypeInt32, kRepWord64);
276 r.CheckTypeError(kRepWord64, kRepWord32 | kTypeUint32); 288 r.CheckTypeError(kRepWord64, kRepWord32 | kTypeUint32);
277 r.CheckTypeError(kRepWord32 | kTypeUint32, kRepWord64); 289 r.CheckTypeError(kRepWord32 | kTypeUint32, kRepWord64);
278 290
279 for (size_t i = 0; i < arraysize(all_reps); i++) { 291 for (size_t i = 0; i < arraysize(all_reps); i++) {
280 for (size_t j = 0; j < arraysize(all_reps); j++) { 292 for (size_t j = 0; j < arraysize(all_reps); j++) {
281 if (i == j) continue; 293 if (i == j) continue;
282 // Only a single from representation is allowed. 294 // Only a single from representation is allowed.
283 r.CheckTypeError(all_reps[i] | all_reps[j], kRepTagged); 295 r.CheckTypeError(all_reps[i] | all_reps[j], kRepTagged);
284 } 296 }
285 } 297 }
298
299 // TODO(titzer): Float32 representation changes trigger type errors now.
300 // Enforce current behavior to test all paths through representation changer.
301 for (size_t i = 0; i < arraysize(all_reps); i++) {
302 r.CheckTypeError(all_reps[i], kRepFloat32);
303 r.CheckTypeError(kRepFloat32, all_reps[i]);
304 }
286 } 305 }
287
288
289 TEST(CompleteMatrix) {
290 // TODO(titzer): test all variants in the matrix.
291 // rB
292 // tBrB
293 // tBrT
294 // rW32
295 // tIrW32
296 // tUrW32
297 // rW64
298 // tIrW64
299 // tUrW64
300 // rF64
301 // tIrF64
302 // tUrF64
303 // tArF64
304 // rT
305 // tArT
306 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698