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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 // mips instruction: trunc_w_d | 211 // mips instruction: trunc_w_d |
212 {{&RawMachineAssembler::ChangeFloat64ToInt32, "ChangeFloat64ToInt32", | 212 {{&RawMachineAssembler::ChangeFloat64ToInt32, "ChangeFloat64ToInt32", |
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[] = { |
| 222 {{&RawMachineAssembler::Float64RoundUp, "Float64RoundUp", kMipsCeilWD, |
| 223 kMachFloat64}, |
| 224 kMachInt32}, |
| 225 {{&RawMachineAssembler::Float64RoundDown, "Float64RoundDown", kMipsFloorWD, |
| 226 kMachFloat64}, |
| 227 kMachInt32}, |
| 228 {{&RawMachineAssembler::Float64RoundTiesEven, "Float64RoundTiesEven", |
| 229 kMipsRoundWD, kMachFloat64}, |
| 230 kMachInt32}, |
| 231 {{&RawMachineAssembler::Float64RoundTruncate, "Float64RoundTruncate", |
| 232 kMipsTruncWD, kMachFloat64}, |
| 233 kMachInt32}}; |
| 234 |
221 } // namespace | 235 } // namespace |
222 | 236 |
223 | 237 |
224 typedef InstructionSelectorTestWithParam<FPCmp> InstructionSelectorFPCmpTest; | 238 typedef InstructionSelectorTestWithParam<FPCmp> InstructionSelectorFPCmpTest; |
225 | 239 |
226 | 240 |
227 TEST_P(InstructionSelectorFPCmpTest, Parameter) { | 241 TEST_P(InstructionSelectorFPCmpTest, Parameter) { |
228 const FPCmp cmp = GetParam(); | 242 const FPCmp cmp = GetParam(); |
229 StreamBuilder m(this, kMachInt32, cmp.mi.machine_type, cmp.mi.machine_type); | 243 StreamBuilder m(this, kMachInt32, cmp.mi.machine_type, cmp.mi.machine_type); |
230 m.Return((m.*cmp.mi.constructor)(m.Parameter(0), m.Parameter(1))); | 244 m.Return((m.*cmp.mi.constructor)(m.Parameter(0), m.Parameter(1))); |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 EXPECT_EQ(1U, s[0]->InputCount()); | 636 EXPECT_EQ(1U, s[0]->InputCount()); |
623 EXPECT_EQ(1U, s[0]->OutputCount()); | 637 EXPECT_EQ(1U, s[0]->OutputCount()); |
624 } | 638 } |
625 | 639 |
626 | 640 |
627 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, | 641 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, |
628 InstructionSelectorConversionTest, | 642 InstructionSelectorConversionTest, |
629 ::testing::ValuesIn(kConversionInstructions)); | 643 ::testing::ValuesIn(kConversionInstructions)); |
630 | 644 |
631 | 645 |
| 646 typedef InstructionSelectorTestWithParam<Conversion> |
| 647 CombineChangeFloat64ToInt32WithRoundFloat64; |
| 648 |
| 649 TEST_P(CombineChangeFloat64ToInt32WithRoundFloat64, Parameter) { |
| 650 { |
| 651 const Conversion conv = GetParam(); |
| 652 StreamBuilder m(this, conv.mi.machine_type, conv.src_machine_type); |
| 653 m.Return(m.ChangeFloat64ToInt32((m.*conv.mi.constructor)(m.Parameter(0)))); |
| 654 Stream s = m.Build(); |
| 655 ASSERT_EQ(1U, s.size()); |
| 656 EXPECT_EQ(conv.mi.arch_opcode, s[0]->arch_opcode()); |
| 657 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); |
| 658 ASSERT_EQ(1U, s[0]->InputCount()); |
| 659 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 660 } |
| 661 } |
| 662 |
| 663 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, |
| 664 CombineChangeFloat64ToInt32WithRoundFloat64, |
| 665 ::testing::ValuesIn(kFloat64RoundInstructions)); |
| 666 |
| 667 |
632 // ---------------------------------------------------------------------------- | 668 // ---------------------------------------------------------------------------- |
633 // Loads and stores. | 669 // Loads and stores. |
634 // ---------------------------------------------------------------------------- | 670 // ---------------------------------------------------------------------------- |
635 | 671 |
636 namespace { | 672 namespace { |
637 | 673 |
638 struct MemoryAccess { | 674 struct MemoryAccess { |
639 MachineType type; | 675 MachineType type; |
640 ArchOpcode load_opcode; | 676 ArchOpcode load_opcode; |
641 ArchOpcode store_opcode; | 677 ArchOpcode store_opcode; |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1057 EXPECT_EQ(kMipsFloat64Min, s[0]->arch_opcode()); | 1093 EXPECT_EQ(kMipsFloat64Min, s[0]->arch_opcode()); |
1058 ASSERT_EQ(2U, s[0]->InputCount()); | 1094 ASSERT_EQ(2U, s[0]->InputCount()); |
1059 ASSERT_EQ(1U, s[0]->OutputCount()); | 1095 ASSERT_EQ(1U, s[0]->OutputCount()); |
1060 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1096 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
1061 } | 1097 } |
1062 | 1098 |
1063 | 1099 |
1064 } // namespace compiler | 1100 } // namespace compiler |
1065 } // namespace internal | 1101 } // namespace internal |
1066 } // namespace v8 | 1102 } // namespace v8 |
OLD | NEW |