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 #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 #include "test/cctest/compiler/value-helper.h" | 10 #include "test/cctest/compiler/value-helper.h" |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 r.CheckFloat32Constant(c, *i); | 266 r.CheckFloat32Constant(c, *i); |
267 } | 267 } |
268 } | 268 } |
269 | 269 |
270 { | 270 { |
271 FOR_INT32_INPUTS(i) { | 271 FOR_INT32_INPUTS(i) { |
272 if (!IsFloat32Int32(*i)) continue; | 272 if (!IsFloat32Int32(*i)) continue; |
273 Node* n = r.jsgraph()->Int32Constant(*i); | 273 Node* n = r.jsgraph()->Int32Constant(*i); |
274 Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeInt32, | 274 Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeInt32, |
275 kRepFloat32); | 275 kRepFloat32); |
276 r.CheckFloat32Constant(c, *i); | 276 r.CheckFloat32Constant(c, static_cast<float>(*i)); |
277 } | 277 } |
278 } | 278 } |
279 | 279 |
280 { | 280 { |
281 FOR_UINT32_INPUTS(i) { | 281 FOR_UINT32_INPUTS(i) { |
282 if (!IsFloat32Uint32(*i)) continue; | 282 if (!IsFloat32Uint32(*i)) continue; |
283 Node* n = r.jsgraph()->Int32Constant(*i); | 283 Node* n = r.jsgraph()->Int32Constant(*i); |
284 Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeUint32, | 284 Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeUint32, |
285 kRepFloat32); | 285 kRepFloat32); |
286 r.CheckFloat32Constant(c, *i); | 286 r.CheckFloat32Constant(c, static_cast<float>(*i)); |
287 } | 287 } |
288 } | 288 } |
289 } | 289 } |
290 | 290 |
291 | 291 |
292 TEST(ToInt32_constant) { | 292 TEST(ToInt32_constant) { |
293 RepresentationChangerTester r; | 293 RepresentationChangerTester r; |
294 | 294 |
295 { | 295 { |
296 FOR_INT32_INPUTS(i) { | 296 FOR_INT32_INPUTS(i) { |
297 Node* n = r.jsgraph()->Int32Constant(*i); | 297 Node* n = r.jsgraph()->Int32Constant(*i); |
298 Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeInt32, | 298 Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeInt32, |
299 kRepWord32); | 299 kRepWord32); |
300 r.CheckInt32Constant(c, *i); | 300 r.CheckInt32Constant(c, *i); |
301 } | 301 } |
302 } | 302 } |
303 | 303 |
304 { | 304 { |
305 FOR_INT32_INPUTS(i) { | 305 FOR_INT32_INPUTS(i) { |
306 if (!IsFloat32Int32(*i)) continue; | 306 if (!IsFloat32Int32(*i)) continue; |
307 Node* n = r.jsgraph()->Float32Constant(*i); | 307 Node* n = r.jsgraph()->Float32Constant(static_cast<float>(*i)); |
308 Node* c = r.changer()->GetRepresentationFor(n, kRepFloat32 | kTypeInt32, | 308 Node* c = r.changer()->GetRepresentationFor(n, kRepFloat32 | kTypeInt32, |
309 kRepWord32); | 309 kRepWord32); |
310 r.CheckInt32Constant(c, *i); | 310 r.CheckInt32Constant(c, *i); |
311 } | 311 } |
312 } | 312 } |
313 | 313 |
314 { | 314 { |
315 FOR_INT32_INPUTS(i) { | 315 FOR_INT32_INPUTS(i) { |
316 Node* n = r.jsgraph()->Float64Constant(*i); | 316 Node* n = r.jsgraph()->Float64Constant(*i); |
317 Node* c = r.changer()->GetRepresentationFor(n, kRepFloat64 | kTypeInt32, | 317 Node* c = r.changer()->GetRepresentationFor(n, kRepFloat64 | kTypeInt32, |
(...skipping 21 matching lines...) Expand all Loading... |
339 Node* n = r.jsgraph()->Int32Constant(*i); | 339 Node* n = r.jsgraph()->Int32Constant(*i); |
340 Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeUint32, | 340 Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeUint32, |
341 kRepWord32); | 341 kRepWord32); |
342 r.CheckUint32Constant(c, *i); | 342 r.CheckUint32Constant(c, *i); |
343 } | 343 } |
344 } | 344 } |
345 | 345 |
346 { | 346 { |
347 FOR_UINT32_INPUTS(i) { | 347 FOR_UINT32_INPUTS(i) { |
348 if (!IsFloat32Uint32(*i)) continue; | 348 if (!IsFloat32Uint32(*i)) continue; |
349 Node* n = r.jsgraph()->Float32Constant(*i); | 349 Node* n = r.jsgraph()->Float32Constant(static_cast<float>(*i)); |
350 Node* c = r.changer()->GetRepresentationFor(n, kRepFloat32 | kTypeUint32, | 350 Node* c = r.changer()->GetRepresentationFor(n, kRepFloat32 | kTypeUint32, |
351 kRepWord32); | 351 kRepWord32); |
352 r.CheckUint32Constant(c, *i); | 352 r.CheckUint32Constant(c, *i); |
353 } | 353 } |
354 } | 354 } |
355 | 355 |
356 { | 356 { |
357 FOR_UINT32_INPUTS(i) { | 357 FOR_UINT32_INPUTS(i) { |
358 Node* n = r.jsgraph()->Float64Constant(*i); | 358 Node* n = r.jsgraph()->Float64Constant(*i); |
359 Node* c = r.changer()->GetRepresentationFor(n, kRepFloat64 | kTypeUint32, | 359 Node* c = r.changer()->GetRepresentationFor(n, kRepFloat64 | kTypeUint32, |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 r.CheckTypeError(kRepWord32 | kTypeUint32, kRepWord64); | 540 r.CheckTypeError(kRepWord32 | kTypeUint32, kRepWord64); |
541 | 541 |
542 for (size_t i = 0; i < arraysize(all_reps); i++) { | 542 for (size_t i = 0; i < arraysize(all_reps); i++) { |
543 for (size_t j = 0; j < arraysize(all_reps); j++) { | 543 for (size_t j = 0; j < arraysize(all_reps); j++) { |
544 if (i == j) continue; | 544 if (i == j) continue; |
545 // Only a single from representation is allowed. | 545 // Only a single from representation is allowed. |
546 r.CheckTypeError(all_reps[i] | all_reps[j], kRepTagged); | 546 r.CheckTypeError(all_reps[i] | all_reps[j], kRepTagged); |
547 } | 547 } |
548 } | 548 } |
549 } | 549 } |
OLD | NEW |