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 1464763003: [turbofan] Replace information about uses by UseInfo in representation selection. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: final goodness Created 5 years 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
« no previous file with comments | « src/compiler/simplified-lowering.cc ('k') | no next file » | 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 // TODO(jochen): Remove this after the setting is turned on globally. 5 // TODO(jochen): Remove this after the setting is turned on globally.
6 #define V8_IMMINENT_DEPRECATION_WARNINGS 6 #define V8_IMMINENT_DEPRECATION_WARNINGS
7 7
8 #include <limits> 8 #include <limits>
9 9
10 #include "test/cctest/cctest.h" 10 #include "test/cctest/cctest.h"
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64, 445 CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64,
446 IrOpcode::kChangeFloat64ToTagged, kRepFloat32, kRepTagged); 446 IrOpcode::kChangeFloat64ToTagged, kRepFloat32, kRepTagged);
447 CheckTwoChanges(IrOpcode::kChangeTaggedToFloat64, 447 CheckTwoChanges(IrOpcode::kChangeTaggedToFloat64,
448 IrOpcode::kTruncateFloat64ToFloat32, kRepTagged, kRepFloat32); 448 IrOpcode::kTruncateFloat64ToFloat32, kRepTagged, kRepFloat32);
449 } 449 }
450 450
451 451
452 TEST(SignednessInWord32) { 452 TEST(SignednessInWord32) {
453 RepresentationChangerTester r; 453 RepresentationChangerTester r;
454 454
455 // TODO(titzer): assume that uses of a word32 without a sign mean kTypeInt32.
456 CheckChange(IrOpcode::kChangeTaggedToInt32, kRepTagged | kTypeInt32, 455 CheckChange(IrOpcode::kChangeTaggedToInt32, kRepTagged | kTypeInt32,
457 kRepWord32 | kTypeInt32); 456 kRepWord32);
458 CheckChange(IrOpcode::kChangeTaggedToUint32, kRepTagged | kTypeUint32, 457 CheckChange(IrOpcode::kChangeTaggedToUint32, kRepTagged | kTypeUint32,
459 kRepWord32 | kTypeUint32); 458 kRepWord32);
460 CheckChange(IrOpcode::kChangeInt32ToFloat64, kRepWord32, kRepFloat64); 459 CheckChange(IrOpcode::kChangeInt32ToFloat64, kRepWord32, kRepFloat64);
461 CheckChange(IrOpcode::kChangeFloat64ToInt32, kRepFloat64 | kTypeInt32, 460 CheckChange(IrOpcode::kChangeFloat64ToInt32, kRepFloat64 | kTypeInt32,
462 kRepWord32); 461 kRepWord32);
463 CheckChange(IrOpcode::kTruncateFloat64ToInt32, kRepFloat64, kRepWord32); 462 CheckChange(IrOpcode::kTruncateFloat64ToInt32, kRepFloat64, kRepWord32);
464 463
465 CheckTwoChanges(IrOpcode::kChangeInt32ToFloat64, 464 CheckTwoChanges(IrOpcode::kChangeInt32ToFloat64,
466 IrOpcode::kTruncateFloat64ToFloat32, kRepWord32, kRepFloat32); 465 IrOpcode::kTruncateFloat64ToFloat32, kRepWord32, kRepFloat32);
467 CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64, 466 CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64,
468 IrOpcode::kTruncateFloat64ToInt32, kRepFloat32, kRepWord32); 467 IrOpcode::kTruncateFloat64ToInt32, kRepFloat32, kRepWord32);
469 } 468 }
470 469
471 470
472 TEST(Nops) { 471 TEST(Nops) {
473 RepresentationChangerTester r; 472 RepresentationChangerTester r;
474 473
475 // X -> X is always a nop for any single representation X. 474 // X -> X is always a nop for any single representation X.
476 for (size_t i = 0; i < arraysize(all_reps); i++) { 475 for (size_t i = 0; i < arraysize(all_reps); i++) {
477 r.CheckNop(all_reps[i], all_reps[i]); 476 r.CheckNop(all_reps[i], all_reps[i]);
478 } 477 }
479 478
480 // 32-bit floats. 479 // 32-bit floats.
481 r.CheckNop(kRepFloat32, kRepFloat32); 480 r.CheckNop(kRepFloat32, kRepFloat32);
482 r.CheckNop(kRepFloat32 | kTypeNumber, kRepFloat32); 481 r.CheckNop(kRepFloat32 | kTypeNumber, kRepFloat32);
483 r.CheckNop(kRepFloat32, kRepFloat32 | kTypeNumber);
484 482
485 // 32-bit words can be used as smaller word sizes and vice versa, because 483 // 32-bit words can be used as smaller word sizes and vice versa, because
486 // loads from memory implicitly sign or zero extend the value to the 484 // loads from memory implicitly sign or zero extend the value to the
487 // full machine word size, and stores implicitly truncate. 485 // full machine word size, and stores implicitly truncate.
488 r.CheckNop(kRepWord32, kRepWord8); 486 r.CheckNop(kRepWord32, kRepWord8);
489 r.CheckNop(kRepWord32, kRepWord16); 487 r.CheckNop(kRepWord32, kRepWord16);
490 r.CheckNop(kRepWord32, kRepWord32); 488 r.CheckNop(kRepWord32, kRepWord32);
491 r.CheckNop(kRepWord8, kRepWord32); 489 r.CheckNop(kRepWord8, kRepWord32);
492 r.CheckNop(kRepWord16, kRepWord32); 490 r.CheckNop(kRepWord16, kRepWord32);
493 491
494 // kRepBit (result of comparison) is implicitly a wordish thing. 492 // kRepBit (result of comparison) is implicitly a wordish thing.
495 r.CheckNop(kRepBit, kRepWord8); 493 r.CheckNop(kRepBit, kRepWord8);
496 r.CheckNop(kRepBit | kTypeBool, kRepWord8); 494 r.CheckNop(kRepBit | kTypeBool, kRepWord8);
497 r.CheckNop(kRepBit, kRepWord16); 495 r.CheckNop(kRepBit, kRepWord16);
498 r.CheckNop(kRepBit | kTypeBool, kRepWord16); 496 r.CheckNop(kRepBit | kTypeBool, kRepWord16);
499 r.CheckNop(kRepBit, kRepWord32); 497 r.CheckNop(kRepBit, kRepWord32);
500 r.CheckNop(kRepBit | kTypeBool, kRepWord32); 498 r.CheckNop(kRepBit | kTypeBool, kRepWord32);
501 r.CheckNop(kRepBit, kRepWord64); 499 r.CheckNop(kRepBit, kRepWord64);
502 r.CheckNop(kRepBit | kTypeBool, kRepWord64); 500 r.CheckNop(kRepBit | kTypeBool, kRepWord64);
503 } 501 }
504 502
505 503
506 TEST(TypeErrors) { 504 TEST(TypeErrors) {
507 RepresentationChangerTester r; 505 RepresentationChangerTester r;
508 506
509 // Wordish cannot be implicitly converted to/from comparison conditions. 507 // Wordish cannot be implicitly converted to/from comparison conditions.
510 r.CheckTypeError(kRepWord8, kRepBit); 508 r.CheckTypeError(kRepWord8, kRepBit);
511 r.CheckTypeError(kRepWord8, kRepBit | kTypeBool);
512 r.CheckTypeError(kRepWord16, kRepBit); 509 r.CheckTypeError(kRepWord16, kRepBit);
513 r.CheckTypeError(kRepWord16, kRepBit | kTypeBool);
514 r.CheckTypeError(kRepWord32, kRepBit); 510 r.CheckTypeError(kRepWord32, kRepBit);
515 r.CheckTypeError(kRepWord32, kRepBit | kTypeBool);
516 r.CheckTypeError(kRepWord64, kRepBit); 511 r.CheckTypeError(kRepWord64, kRepBit);
517 r.CheckTypeError(kRepWord64, kRepBit | kTypeBool);
518 512
519 // Floats cannot be implicitly converted to/from comparison conditions. 513 // Floats cannot be implicitly converted to/from comparison conditions.
520 r.CheckTypeError(kRepFloat64, kRepBit); 514 r.CheckTypeError(kRepFloat64, kRepBit);
521 r.CheckTypeError(kRepFloat64, kRepBit | kTypeBool);
522 r.CheckTypeError(kRepBit, kRepFloat64); 515 r.CheckTypeError(kRepBit, kRepFloat64);
523 r.CheckTypeError(kRepBit | kTypeBool, kRepFloat64); 516 r.CheckTypeError(kRepBit | kTypeBool, kRepFloat64);
524 517
525 // Floats cannot be implicitly converted to/from comparison conditions. 518 // Floats cannot be implicitly converted to/from comparison conditions.
526 r.CheckTypeError(kRepFloat32, kRepBit); 519 r.CheckTypeError(kRepFloat32, kRepBit);
527 r.CheckTypeError(kRepFloat32, kRepBit | kTypeBool);
528 r.CheckTypeError(kRepBit, kRepFloat32); 520 r.CheckTypeError(kRepBit, kRepFloat32);
529 r.CheckTypeError(kRepBit | kTypeBool, kRepFloat32); 521 r.CheckTypeError(kRepBit | kTypeBool, kRepFloat32);
530 522
531 // Word64 is internal and shouldn't be implicitly converted. 523 // Word64 is internal and shouldn't be implicitly converted.
532 r.CheckTypeError(kRepWord64, kRepTagged | kTypeBool);
533 r.CheckTypeError(kRepWord64, kRepTagged); 524 r.CheckTypeError(kRepWord64, kRepTagged);
534 r.CheckTypeError(kRepWord64, kRepTagged | kTypeBool);
535 r.CheckTypeError(kRepTagged, kRepWord64); 525 r.CheckTypeError(kRepTagged, kRepWord64);
536 r.CheckTypeError(kRepTagged | kTypeBool, kRepWord64); 526 r.CheckTypeError(kRepTagged | kTypeBool, kRepWord64);
537 527
538 // Word64 / Word32 shouldn't be implicitly converted. 528 // Word64 / Word32 shouldn't be implicitly converted.
539 r.CheckTypeError(kRepWord64, kRepWord32); 529 r.CheckTypeError(kRepWord64, kRepWord32);
540 r.CheckTypeError(kRepWord32, kRepWord64); 530 r.CheckTypeError(kRepWord32, kRepWord64);
541 r.CheckTypeError(kRepWord64, kRepWord32 | kTypeInt32);
542 r.CheckTypeError(kRepWord32 | kTypeInt32, kRepWord64); 531 r.CheckTypeError(kRepWord32 | kTypeInt32, kRepWord64);
543 r.CheckTypeError(kRepWord64, kRepWord32 | kTypeUint32);
544 r.CheckTypeError(kRepWord32 | kTypeUint32, kRepWord64); 532 r.CheckTypeError(kRepWord32 | kTypeUint32, kRepWord64);
545 533
546 for (size_t i = 0; i < arraysize(all_reps); i++) { 534 for (size_t i = 0; i < arraysize(all_reps); i++) {
547 for (size_t j = 0; j < arraysize(all_reps); j++) { 535 for (size_t j = 0; j < arraysize(all_reps); j++) {
548 if (i == j) continue; 536 if (i == j) continue;
549 // Only a single from representation is allowed. 537 // Only a single from representation is allowed.
550 r.CheckTypeError(all_reps[i] | all_reps[j], kRepTagged); 538 r.CheckTypeError(all_reps[i] | all_reps[j], kRepTagged);
551 } 539 }
552 } 540 }
553 } 541 }
554 542
555 } // namespace compiler 543 } // namespace compiler
556 } // namespace internal 544 } // namespace internal
557 } // namespace v8 545 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/simplified-lowering.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698