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 "test/unittests/compiler/instruction-selector-unittest.h" | 5 #include "test/unittests/compiler/instruction-selector-unittest.h" |
6 | 6 |
7 namespace v8 { | 7 namespace v8 { |
8 namespace internal { | 8 namespace internal { |
9 namespace compiler { | 9 namespace compiler { |
10 | 10 |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 ASSERT_EQ(1U, s[0]->OutputCount()); | 632 ASSERT_EQ(1U, s[0]->OutputCount()); |
633 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 633 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
634 EXPECT_TRUE(s.IsFixed(s[0]->OutputAt(0), edx)); | 634 EXPECT_TRUE(s.IsFixed(s[0]->OutputAt(0), edx)); |
635 } | 635 } |
636 | 636 |
637 | 637 |
638 // ----------------------------------------------------------------------------- | 638 // ----------------------------------------------------------------------------- |
639 // Floating point operations. | 639 // Floating point operations. |
640 | 640 |
641 | 641 |
| 642 TEST_F(InstructionSelectorTest, Float32Abs) { |
| 643 StreamBuilder m(this, kMachFloat32, kMachFloat32); |
| 644 Node* const p0 = m.Parameter(0); |
| 645 Node* const n = m.Float32Abs(p0); |
| 646 m.Return(n); |
| 647 Stream s = m.Build(); |
| 648 ASSERT_EQ(1U, s.size()); |
| 649 EXPECT_EQ(kSSEFloat32Abs, s[0]->arch_opcode()); |
| 650 ASSERT_EQ(1U, s[0]->InputCount()); |
| 651 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 652 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 653 EXPECT_TRUE(s.IsSameAsFirst(s[0]->Output())); |
| 654 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 655 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 656 } |
| 657 |
| 658 |
| 659 TEST_F(InstructionSelectorTest, Float64Abs) { |
| 660 StreamBuilder m(this, kMachFloat64, kMachFloat64); |
| 661 Node* const p0 = m.Parameter(0); |
| 662 Node* const n = m.Float64Abs(p0); |
| 663 m.Return(n); |
| 664 Stream s = m.Build(); |
| 665 ASSERT_EQ(1U, s.size()); |
| 666 EXPECT_EQ(kSSEFloat64Abs, s[0]->arch_opcode()); |
| 667 ASSERT_EQ(1U, s[0]->InputCount()); |
| 668 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 669 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 670 EXPECT_TRUE(s.IsSameAsFirst(s[0]->Output())); |
| 671 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 672 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 673 } |
| 674 |
| 675 |
642 TEST_F(InstructionSelectorTest, Float64BinopArithmetic) { | 676 TEST_F(InstructionSelectorTest, Float64BinopArithmetic) { |
643 { | 677 { |
644 StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64); | 678 StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64); |
645 Node* add = m.Float64Add(m.Parameter(0), m.Parameter(1)); | 679 Node* add = m.Float64Add(m.Parameter(0), m.Parameter(1)); |
646 Node* mul = m.Float64Mul(add, m.Parameter(1)); | 680 Node* mul = m.Float64Mul(add, m.Parameter(1)); |
647 Node* sub = m.Float64Sub(mul, add); | 681 Node* sub = m.Float64Sub(mul, add); |
648 Node* ret = m.Float64Div(mul, sub); | 682 Node* ret = m.Float64Div(mul, sub); |
649 m.Return(ret); | 683 m.Return(ret); |
650 Stream s = m.Build(AVX); | 684 Stream s = m.Build(AVX); |
651 ASSERT_EQ(4U, s.size()); | 685 ASSERT_EQ(4U, s.size()); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 EXPECT_EQ(kIA32Lzcnt, s[0]->arch_opcode()); | 770 EXPECT_EQ(kIA32Lzcnt, s[0]->arch_opcode()); |
737 ASSERT_EQ(1U, s[0]->InputCount()); | 771 ASSERT_EQ(1U, s[0]->InputCount()); |
738 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 772 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
739 ASSERT_EQ(1U, s[0]->OutputCount()); | 773 ASSERT_EQ(1U, s[0]->OutputCount()); |
740 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 774 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
741 } | 775 } |
742 | 776 |
743 } // namespace compiler | 777 } // namespace compiler |
744 } // namespace internal | 778 } // namespace internal |
745 } // namespace v8 | 779 } // namespace v8 |
OLD | NEW |