| 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 kMips64TruncWD, kMachFloat64}, | 221 kMips64TruncWD, kMachFloat64}, |
| 222 kMachInt32}, | 222 kMachInt32}, |
| 223 | 223 |
| 224 // mips instructions: | 224 // mips instructions: |
| 225 // trunc double to unsigned word, for more details look at mips macro | 225 // trunc double to unsigned word, for more details look at mips macro |
| 226 // asm and mips asm file | 226 // asm and mips asm file |
| 227 {{&RawMachineAssembler::ChangeFloat64ToUint32, "ChangeFloat64ToUint32", | 227 {{&RawMachineAssembler::ChangeFloat64ToUint32, "ChangeFloat64ToUint32", |
| 228 kMips64TruncUwD, kMachFloat64}, | 228 kMips64TruncUwD, kMachFloat64}, |
| 229 kMachInt32}}; | 229 kMachInt32}}; |
| 230 | 230 |
| 231 const Conversion kFloat64RoundInstructions[] = { |
| 232 {{&RawMachineAssembler::Float64RoundUp, "Float64RoundUp", kMips64CeilWD, |
| 233 kMachFloat64}, |
| 234 kMachInt32}, |
| 235 {{&RawMachineAssembler::Float64RoundDown, "Float64RoundDown", |
| 236 kMips64FloorWD, kMachFloat64}, |
| 237 kMachInt32}, |
| 238 {{&RawMachineAssembler::Float64RoundTiesEven, "Float64RoundTiesEven", |
| 239 kMips64RoundWD, kMachFloat64}, |
| 240 kMachInt32}, |
| 241 {{&RawMachineAssembler::Float64RoundTruncate, "Float64RoundTruncate", |
| 242 kMips64TruncWD, kMachFloat64}, |
| 243 kMachInt32}}; |
| 244 |
| 231 } // namespace | 245 } // namespace |
| 232 | 246 |
| 233 | 247 |
| 234 typedef InstructionSelectorTestWithParam<FPCmp> InstructionSelectorFPCmpTest; | 248 typedef InstructionSelectorTestWithParam<FPCmp> InstructionSelectorFPCmpTest; |
| 235 | 249 |
| 236 TEST_P(InstructionSelectorFPCmpTest, Parameter) { | 250 TEST_P(InstructionSelectorFPCmpTest, Parameter) { |
| 237 const FPCmp cmp = GetParam(); | 251 const FPCmp cmp = GetParam(); |
| 238 StreamBuilder m(this, kMachInt32, cmp.mi.machine_type, cmp.mi.machine_type); | 252 StreamBuilder m(this, kMachInt32, cmp.mi.machine_type, cmp.mi.machine_type); |
| 239 m.Return((m.*cmp.mi.constructor)(m.Parameter(0), m.Parameter(1))); | 253 m.Return((m.*cmp.mi.constructor)(m.Parameter(0), m.Parameter(1))); |
| 240 Stream s = m.Build(); | 254 Stream s = m.Build(); |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 m.Word64Shl(m.ChangeInt32ToInt64(m.Parameter(0)), m.Int32Constant(32))); | 781 m.Word64Shl(m.ChangeInt32ToInt64(m.Parameter(0)), m.Int32Constant(32))); |
| 768 Stream s = m.Build(); | 782 Stream s = m.Build(); |
| 769 ASSERT_EQ(1U, s.size()); | 783 ASSERT_EQ(1U, s.size()); |
| 770 EXPECT_EQ(kMips64Dshl, s[0]->arch_opcode()); | 784 EXPECT_EQ(kMips64Dshl, s[0]->arch_opcode()); |
| 771 ASSERT_EQ(2U, s[0]->InputCount()); | 785 ASSERT_EQ(2U, s[0]->InputCount()); |
| 772 EXPECT_EQ(1U, s[0]->OutputCount()); | 786 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 773 } | 787 } |
| 774 } | 788 } |
| 775 | 789 |
| 776 | 790 |
| 791 typedef InstructionSelectorTestWithParam<Conversion> |
| 792 CombineChangeFloat64ToInt32WithRoundFloat64; |
| 793 |
| 794 TEST_P(CombineChangeFloat64ToInt32WithRoundFloat64, Parameter) { |
| 795 { |
| 796 const Conversion conv = GetParam(); |
| 797 StreamBuilder m(this, conv.mi.machine_type, conv.src_machine_type); |
| 798 m.Return(m.ChangeFloat64ToInt32((m.*conv.mi.constructor)(m.Parameter(0)))); |
| 799 Stream s = m.Build(); |
| 800 ASSERT_EQ(1U, s.size()); |
| 801 EXPECT_EQ(conv.mi.arch_opcode, s[0]->arch_opcode()); |
| 802 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); |
| 803 ASSERT_EQ(1U, s[0]->InputCount()); |
| 804 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 805 } |
| 806 } |
| 807 |
| 808 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, |
| 809 CombineChangeFloat64ToInt32WithRoundFloat64, |
| 810 ::testing::ValuesIn(kFloat64RoundInstructions)); |
| 811 |
| 812 |
| 777 TEST_F(InstructionSelectorTest, CombineShiftsWithMul) { | 813 TEST_F(InstructionSelectorTest, CombineShiftsWithMul) { |
| 778 { | 814 { |
| 779 StreamBuilder m(this, kMachInt32, kMachInt32); | 815 StreamBuilder m(this, kMachInt32, kMachInt32); |
| 780 m.Return(m.Int32Mul(m.Word64Sar(m.Parameter(0), m.Int32Constant(32)), | 816 m.Return(m.Int32Mul(m.Word64Sar(m.Parameter(0), m.Int32Constant(32)), |
| 781 m.Word64Sar(m.Parameter(0), m.Int32Constant(32)))); | 817 m.Word64Sar(m.Parameter(0), m.Int32Constant(32)))); |
| 782 Stream s = m.Build(); | 818 Stream s = m.Build(); |
| 783 ASSERT_EQ(1U, s.size()); | 819 ASSERT_EQ(1U, s.size()); |
| 784 EXPECT_EQ(kMips64DMulHigh, s[0]->arch_opcode()); | 820 EXPECT_EQ(kMips64DMulHigh, s[0]->arch_opcode()); |
| 785 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); | 821 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); |
| 786 ASSERT_EQ(2U, s[0]->InputCount()); | 822 ASSERT_EQ(2U, s[0]->InputCount()); |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1291 ASSERT_EQ(1U, s.size()); | 1327 ASSERT_EQ(1U, s.size()); |
| 1292 EXPECT_EQ(kMips64Float64Min, s[0]->arch_opcode()); | 1328 EXPECT_EQ(kMips64Float64Min, s[0]->arch_opcode()); |
| 1293 ASSERT_EQ(2U, s[0]->InputCount()); | 1329 ASSERT_EQ(2U, s[0]->InputCount()); |
| 1294 ASSERT_EQ(1U, s[0]->OutputCount()); | 1330 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1295 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1331 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 1296 } | 1332 } |
| 1297 | 1333 |
| 1298 } // namespace compiler | 1334 } // namespace compiler |
| 1299 } // namespace internal | 1335 } // namespace internal |
| 1300 } // namespace v8 | 1336 } // namespace v8 |
| OLD | NEW |