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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 kMipsTruncWD, kMachFloat64}, | 213 kMipsTruncWD, kMachFloat64}, |
214 kMachInt32}, | 214 kMachInt32}, |
215 | 215 |
216 // mips instruction: trunc_uw_d | 216 // mips instruction: trunc_uw_d |
217 {{&RawMachineAssembler::ChangeFloat64ToUint32, "ChangeFloat64ToUint32", | 217 {{&RawMachineAssembler::ChangeFloat64ToUint32, "ChangeFloat64ToUint32", |
218 kMipsTruncUwD, kMachFloat64}, | 218 kMipsTruncUwD, kMachFloat64}, |
219 kMachInt32}}; | 219 kMachInt32}}; |
220 | 220 |
221 const Conversion kFloat64RoundInstructions[] = { | 221 const Conversion kFloat64RoundInstructions[] = { |
222 {{&RawMachineAssembler::Float64RoundUp, "Float64RoundUp", kMipsCeilWD, | 222 {{&RawMachineAssembler::Float64RoundUp, "Float64RoundUp", kMipsCeilWD, |
223 kMachFloat64}, | 223 kMachInt32}, |
224 kMachInt32}, | 224 kMachFloat64}, |
225 {{&RawMachineAssembler::Float64RoundDown, "Float64RoundDown", kMipsFloorWD, | 225 {{&RawMachineAssembler::Float64RoundDown, "Float64RoundDown", kMipsFloorWD, |
226 kMachFloat64}, | 226 kMachInt32}, |
227 kMachInt32}, | 227 kMachFloat64}, |
228 {{&RawMachineAssembler::Float64RoundTiesEven, "Float64RoundTiesEven", | 228 {{&RawMachineAssembler::Float64RoundTiesEven, "Float64RoundTiesEven", |
229 kMipsRoundWD, kMachFloat64}, | 229 kMipsRoundWD, kMachInt32}, |
230 kMachInt32}, | 230 kMachFloat64}, |
231 {{&RawMachineAssembler::Float64RoundTruncate, "Float64RoundTruncate", | 231 {{&RawMachineAssembler::Float64RoundTruncate, "Float64RoundTruncate", |
232 kMipsTruncWD, kMachFloat64}, | 232 kMipsTruncWD, kMachInt32}, |
233 kMachInt32}}; | 233 kMachFloat64}}; |
| 234 |
| 235 const Conversion kFloat32RoundInstructions[] = { |
| 236 {{&RawMachineAssembler::Float32RoundUp, "Float32RoundUp", kMipsCeilWS, |
| 237 kMachInt32}, |
| 238 kMachFloat32}, |
| 239 {{&RawMachineAssembler::Float32RoundDown, "Float32RoundDown", kMipsFloorWS, |
| 240 kMachInt32}, |
| 241 kMachFloat32}, |
| 242 {{&RawMachineAssembler::Float32RoundTiesEven, "Float32RoundTiesEven", |
| 243 kMipsRoundWS, kMachInt32}, |
| 244 kMachFloat32}, |
| 245 {{&RawMachineAssembler::Float32RoundTruncate, "Float32RoundTruncate", |
| 246 kMipsTruncWS, kMachInt32}, |
| 247 kMachFloat32}}; |
234 | 248 |
235 } // namespace | 249 } // namespace |
236 | 250 |
237 | 251 |
238 typedef InstructionSelectorTestWithParam<FPCmp> InstructionSelectorFPCmpTest; | 252 typedef InstructionSelectorTestWithParam<FPCmp> InstructionSelectorFPCmpTest; |
239 | 253 |
240 | 254 |
241 TEST_P(InstructionSelectorFPCmpTest, Parameter) { | 255 TEST_P(InstructionSelectorFPCmpTest, Parameter) { |
242 const FPCmp cmp = GetParam(); | 256 const FPCmp cmp = GetParam(); |
243 StreamBuilder m(this, kMachInt32, cmp.mi.machine_type, cmp.mi.machine_type); | 257 StreamBuilder m(this, kMachInt32, cmp.mi.machine_type, cmp.mi.machine_type); |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 ASSERT_EQ(1U, s[0]->InputCount()); | 691 ASSERT_EQ(1U, s[0]->InputCount()); |
678 EXPECT_EQ(1U, s[0]->OutputCount()); | 692 EXPECT_EQ(1U, s[0]->OutputCount()); |
679 } | 693 } |
680 } | 694 } |
681 | 695 |
682 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, | 696 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, |
683 CombineChangeFloat64ToInt32WithRoundFloat64, | 697 CombineChangeFloat64ToInt32WithRoundFloat64, |
684 ::testing::ValuesIn(kFloat64RoundInstructions)); | 698 ::testing::ValuesIn(kFloat64RoundInstructions)); |
685 | 699 |
686 | 700 |
| 701 typedef InstructionSelectorTestWithParam<Conversion> |
| 702 CombineChangeFloat32ToInt32WithRoundFloat32; |
| 703 |
| 704 TEST_P(CombineChangeFloat32ToInt32WithRoundFloat32, Parameter) { |
| 705 { |
| 706 const Conversion conv = GetParam(); |
| 707 StreamBuilder m(this, conv.mi.machine_type, conv.src_machine_type); |
| 708 m.Return(m.ChangeFloat64ToInt32( |
| 709 m.ChangeFloat32ToFloat64((m.*conv.mi.constructor)(m.Parameter(0))))); |
| 710 Stream s = m.Build(); |
| 711 ASSERT_EQ(1U, s.size()); |
| 712 EXPECT_EQ(conv.mi.arch_opcode, s[0]->arch_opcode()); |
| 713 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); |
| 714 ASSERT_EQ(1U, s[0]->InputCount()); |
| 715 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 716 } |
| 717 } |
| 718 |
| 719 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, |
| 720 CombineChangeFloat32ToInt32WithRoundFloat32, |
| 721 ::testing::ValuesIn(kFloat32RoundInstructions)); |
| 722 |
| 723 |
| 724 TEST_F(InstructionSelectorTest, ChangeFloat64ToInt32OfChangeFloat32ToFloat64) { |
| 725 { |
| 726 StreamBuilder m(this, kMachInt32, kMachFloat32); |
| 727 m.Return(m.ChangeFloat64ToInt32(m.ChangeFloat32ToFloat64(m.Parameter(0)))); |
| 728 Stream s = m.Build(); |
| 729 ASSERT_EQ(1U, s.size()); |
| 730 EXPECT_EQ(kMipsTruncWS, s[0]->arch_opcode()); |
| 731 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); |
| 732 ASSERT_EQ(1U, s[0]->InputCount()); |
| 733 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 734 } |
| 735 } |
| 736 |
| 737 |
| 738 TEST_F(InstructionSelectorTest, |
| 739 TruncateFloat64ToFloat32OfChangeInt32ToFloat64) { |
| 740 { |
| 741 StreamBuilder m(this, kMachFloat32, kMachInt32); |
| 742 m.Return( |
| 743 m.TruncateFloat64ToFloat32(m.ChangeInt32ToFloat64(m.Parameter(0)))); |
| 744 Stream s = m.Build(); |
| 745 ASSERT_EQ(1U, s.size()); |
| 746 EXPECT_EQ(kMipsCvtSW, s[0]->arch_opcode()); |
| 747 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); |
| 748 ASSERT_EQ(1U, s[0]->InputCount()); |
| 749 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 750 } |
| 751 } |
| 752 |
| 753 |
687 // ---------------------------------------------------------------------------- | 754 // ---------------------------------------------------------------------------- |
688 // Loads and stores. | 755 // Loads and stores. |
689 // ---------------------------------------------------------------------------- | 756 // ---------------------------------------------------------------------------- |
690 | 757 |
691 namespace { | 758 namespace { |
692 | 759 |
693 struct MemoryAccess { | 760 struct MemoryAccess { |
694 MachineType type; | 761 MachineType type; |
695 ArchOpcode load_opcode; | 762 ArchOpcode load_opcode; |
696 ArchOpcode store_opcode; | 763 ArchOpcode store_opcode; |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1112 EXPECT_EQ(kMipsFloat64Min, s[0]->arch_opcode()); | 1179 EXPECT_EQ(kMipsFloat64Min, s[0]->arch_opcode()); |
1113 ASSERT_EQ(2U, s[0]->InputCount()); | 1180 ASSERT_EQ(2U, s[0]->InputCount()); |
1114 ASSERT_EQ(1U, s[0]->OutputCount()); | 1181 ASSERT_EQ(1U, s[0]->OutputCount()); |
1115 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1182 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
1116 } | 1183 } |
1117 | 1184 |
1118 | 1185 |
1119 } // namespace compiler | 1186 } // namespace compiler |
1120 } // namespace internal | 1187 } // namespace internal |
1121 } // namespace v8 | 1188 } // namespace v8 |
OLD | NEW |