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 "test/cctest/cctest.h" | 7 #include "test/cctest/cctest.h" |
8 #include "test/cctest/compiler/codegen-tester.h" | 8 #include "test/cctest/compiler/codegen-tester.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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 Node* n = r.jsgraph()->Constant(static_cast<double>(*i)); | 435 Node* n = r.jsgraph()->Constant(static_cast<double>(*i)); |
436 Node* use = r.Return(n); | 436 Node* use = r.Return(n); |
437 Node* c = r.changer()->GetRepresentationFor( | 437 Node* c = r.changer()->GetRepresentationFor( |
438 n, MachineRepresentation::kTagged, Type::Unsigned32(), use, | 438 n, MachineRepresentation::kTagged, Type::Unsigned32(), use, |
439 UseInfo(MachineRepresentation::kWord32, Truncation::None())); | 439 UseInfo(MachineRepresentation::kWord32, Truncation::None())); |
440 r.CheckUint32Constant(c, *i); | 440 r.CheckUint32Constant(c, *i); |
441 } | 441 } |
442 } | 442 } |
443 } | 443 } |
444 | 444 |
445 | |
446 static void CheckChange(IrOpcode::Value expected, MachineRepresentation from, | 445 static void CheckChange(IrOpcode::Value expected, MachineRepresentation from, |
447 Type* from_type, MachineRepresentation to) { | 446 Type* from_type, MachineRepresentation to) { |
448 RepresentationChangerTester r; | 447 RepresentationChangerTester r; |
449 | 448 |
450 Node* n = r.Parameter(); | 449 Node* n = r.Parameter(); |
451 Node* use = r.Return(n); | 450 Node* use = r.Return(n); |
452 Node* c = r.changer()->GetRepresentationFor(n, from, from_type, use, | 451 Node* c = r.changer()->GetRepresentationFor(n, from, from_type, use, |
453 UseInfo(to, Truncation::None())); | 452 UseInfo(to, Truncation::None())); |
454 | 453 |
455 CHECK_NE(c, n); | 454 CHECK_NE(c, n); |
(...skipping 14 matching lines...) Expand all Loading... |
470 UseInfo(to, Truncation::None())); | 469 UseInfo(to, Truncation::None())); |
471 | 470 |
472 CHECK_NE(c1, n); | 471 CHECK_NE(c1, n); |
473 CHECK_EQ(expected1, c1->opcode()); | 472 CHECK_EQ(expected1, c1->opcode()); |
474 Node* c2 = c1->InputAt(0); | 473 Node* c2 = c1->InputAt(0); |
475 CHECK_NE(c2, n); | 474 CHECK_NE(c2, n); |
476 CHECK_EQ(expected2, c2->opcode()); | 475 CHECK_EQ(expected2, c2->opcode()); |
477 CHECK_EQ(n, c2->InputAt(0)); | 476 CHECK_EQ(n, c2->InputAt(0)); |
478 } | 477 } |
479 | 478 |
| 479 static void CheckChange(IrOpcode::Value expected, MachineRepresentation from, |
| 480 Type* from_type, MachineRepresentation to, |
| 481 UseInfo use_info) { |
| 482 RepresentationChangerTester r; |
| 483 |
| 484 Node* n = r.Parameter(); |
| 485 Node* use = r.Return(n); |
| 486 Node* c = |
| 487 r.changer()->GetRepresentationFor(n, from, from_type, use, use_info); |
| 488 |
| 489 CHECK_NE(c, n); |
| 490 CHECK_EQ(expected, c->opcode()); |
| 491 CHECK_EQ(n, c->InputAt(0)); |
| 492 } |
480 | 493 |
481 TEST(SingleChanges) { | 494 TEST(SingleChanges) { |
482 CheckChange(IrOpcode::kChangeTaggedToBit, MachineRepresentation::kTagged, | 495 CheckChange(IrOpcode::kChangeTaggedToBit, MachineRepresentation::kTagged, |
483 Type::None(), MachineRepresentation::kBit); | 496 Type::None(), MachineRepresentation::kBit); |
484 CheckChange(IrOpcode::kChangeBitToTagged, MachineRepresentation::kBit, | 497 CheckChange(IrOpcode::kChangeBitToTagged, MachineRepresentation::kBit, |
485 Type::None(), MachineRepresentation::kTagged); | 498 Type::None(), MachineRepresentation::kTagged); |
486 | 499 |
487 CheckChange(IrOpcode::kChangeInt31ToTaggedSigned, | 500 CheckChange(IrOpcode::kChangeInt31ToTaggedSigned, |
488 MachineRepresentation::kWord32, Type::Signed31(), | 501 MachineRepresentation::kWord32, Type::Signed31(), |
489 MachineRepresentation::kTagged); | 502 MachineRepresentation::kTagged); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 Type::Signed32(), MachineRepresentation::kWord32); | 586 Type::Signed32(), MachineRepresentation::kWord32); |
574 CheckChange(IrOpcode::kChangeTaggedToUint32, MachineRepresentation::kTagged, | 587 CheckChange(IrOpcode::kChangeTaggedToUint32, MachineRepresentation::kTagged, |
575 Type::Unsigned32(), MachineRepresentation::kWord32); | 588 Type::Unsigned32(), MachineRepresentation::kWord32); |
576 CheckChange(IrOpcode::kChangeInt32ToFloat64, MachineRepresentation::kWord32, | 589 CheckChange(IrOpcode::kChangeInt32ToFloat64, MachineRepresentation::kWord32, |
577 Type::None(), MachineRepresentation::kFloat64); | 590 Type::None(), MachineRepresentation::kFloat64); |
578 CheckChange(IrOpcode::kChangeFloat64ToInt32, MachineRepresentation::kFloat64, | 591 CheckChange(IrOpcode::kChangeFloat64ToInt32, MachineRepresentation::kFloat64, |
579 Type::Signed32(), MachineRepresentation::kWord32); | 592 Type::Signed32(), MachineRepresentation::kWord32); |
580 CheckChange(IrOpcode::kTruncateFloat64ToWord32, | 593 CheckChange(IrOpcode::kTruncateFloat64ToWord32, |
581 MachineRepresentation::kFloat64, Type::Number(), | 594 MachineRepresentation::kFloat64, Type::Number(), |
582 MachineRepresentation::kWord32); | 595 MachineRepresentation::kWord32); |
| 596 CheckChange(IrOpcode::kCheckedTruncateTaggedToWord32, |
| 597 MachineRepresentation::kTagged, Type::NumberOrOddball(), |
| 598 MachineRepresentation::kWord32, |
| 599 UseInfo::CheckedNumberOrOddballAsWord32()); |
583 | 600 |
584 CheckTwoChanges(IrOpcode::kChangeInt32ToFloat64, | 601 CheckTwoChanges(IrOpcode::kChangeInt32ToFloat64, |
585 IrOpcode::kTruncateFloat64ToFloat32, | 602 IrOpcode::kTruncateFloat64ToFloat32, |
586 MachineRepresentation::kWord32, Type::None(), | 603 MachineRepresentation::kWord32, Type::None(), |
587 MachineRepresentation::kFloat32); | 604 MachineRepresentation::kFloat32); |
588 CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64, | 605 CheckTwoChanges(IrOpcode::kChangeFloat32ToFloat64, |
589 IrOpcode::kTruncateFloat64ToWord32, | 606 IrOpcode::kTruncateFloat64ToWord32, |
590 MachineRepresentation::kFloat32, Type::Number(), | 607 MachineRepresentation::kFloat32, Type::Number(), |
591 MachineRepresentation::kWord32); | 608 MachineRepresentation::kWord32); |
592 } | 609 } |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 MachineRepresentation::kWord64); | 698 MachineRepresentation::kWord64); |
682 r.CheckTypeError(MachineRepresentation::kWord32, Type::Signed32(), | 699 r.CheckTypeError(MachineRepresentation::kWord32, Type::Signed32(), |
683 MachineRepresentation::kWord64); | 700 MachineRepresentation::kWord64); |
684 r.CheckTypeError(MachineRepresentation::kWord32, Type::Unsigned32(), | 701 r.CheckTypeError(MachineRepresentation::kWord32, Type::Unsigned32(), |
685 MachineRepresentation::kWord64); | 702 MachineRepresentation::kWord64); |
686 } | 703 } |
687 | 704 |
688 } // namespace compiler | 705 } // namespace compiler |
689 } // namespace internal | 706 } // namespace internal |
690 } // namespace v8 | 707 } // namespace v8 |
OLD | NEW |