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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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[] = { | 231 const Conversion kFloat64RoundInstructions[] = { |
232 {{&RawMachineAssembler::Float64RoundUp, "Float64RoundUp", kMips64CeilWD, | 232 {{&RawMachineAssembler::Float64RoundUp, "Float64RoundUp", kMips64CeilWD, |
233 kMachFloat64}, | 233 kMachInt32}, |
234 kMachInt32}, | 234 kMachFloat64}, |
235 {{&RawMachineAssembler::Float64RoundDown, "Float64RoundDown", | 235 {{&RawMachineAssembler::Float64RoundDown, "Float64RoundDown", |
236 kMips64FloorWD, kMachFloat64}, | 236 kMips64FloorWD, kMachInt32}, |
237 kMachInt32}, | 237 kMachFloat64}, |
238 {{&RawMachineAssembler::Float64RoundTiesEven, "Float64RoundTiesEven", | 238 {{&RawMachineAssembler::Float64RoundTiesEven, "Float64RoundTiesEven", |
239 kMips64RoundWD, kMachFloat64}, | 239 kMips64RoundWD, kMachInt32}, |
240 kMachInt32}, | 240 kMachFloat64}, |
241 {{&RawMachineAssembler::Float64RoundTruncate, "Float64RoundTruncate", | 241 {{&RawMachineAssembler::Float64RoundTruncate, "Float64RoundTruncate", |
242 kMips64TruncWD, kMachFloat64}, | 242 kMips64TruncWD, kMachInt32}, |
243 kMachInt32}}; | 243 kMachFloat64}}; |
| 244 |
| 245 const Conversion kFloat32RoundInstructions[] = { |
| 246 {{&RawMachineAssembler::Float32RoundUp, "Float32RoundUp", kMips64CeilWS, |
| 247 kMachInt32}, |
| 248 kMachFloat32}, |
| 249 {{&RawMachineAssembler::Float32RoundDown, "Float32RoundDown", |
| 250 kMips64FloorWS, kMachInt32}, |
| 251 kMachFloat32}, |
| 252 {{&RawMachineAssembler::Float32RoundTiesEven, "Float32RoundTiesEven", |
| 253 kMips64RoundWS, kMachInt32}, |
| 254 kMachFloat32}, |
| 255 {{&RawMachineAssembler::Float32RoundTruncate, "Float32RoundTruncate", |
| 256 kMips64TruncWS, kMachInt32}, |
| 257 kMachFloat32}}; |
244 | 258 |
245 } // namespace | 259 } // namespace |
246 | 260 |
247 | 261 |
248 typedef InstructionSelectorTestWithParam<FPCmp> InstructionSelectorFPCmpTest; | 262 typedef InstructionSelectorTestWithParam<FPCmp> InstructionSelectorFPCmpTest; |
249 | 263 |
250 TEST_P(InstructionSelectorFPCmpTest, Parameter) { | 264 TEST_P(InstructionSelectorFPCmpTest, Parameter) { |
251 const FPCmp cmp = GetParam(); | 265 const FPCmp cmp = GetParam(); |
252 StreamBuilder m(this, kMachInt32, cmp.mi.machine_type, cmp.mi.machine_type); | 266 StreamBuilder m(this, kMachInt32, cmp.mi.machine_type, cmp.mi.machine_type); |
253 m.Return((m.*cmp.mi.constructor)(m.Parameter(0), m.Parameter(1))); | 267 m.Return((m.*cmp.mi.constructor)(m.Parameter(0), m.Parameter(1))); |
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); | 854 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); |
841 ASSERT_EQ(1U, s[0]->InputCount()); | 855 ASSERT_EQ(1U, s[0]->InputCount()); |
842 EXPECT_EQ(1U, s[0]->OutputCount()); | 856 EXPECT_EQ(1U, s[0]->OutputCount()); |
843 } | 857 } |
844 } | 858 } |
845 | 859 |
846 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, | 860 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, |
847 CombineChangeFloat64ToInt32WithRoundFloat64, | 861 CombineChangeFloat64ToInt32WithRoundFloat64, |
848 ::testing::ValuesIn(kFloat64RoundInstructions)); | 862 ::testing::ValuesIn(kFloat64RoundInstructions)); |
849 | 863 |
| 864 typedef InstructionSelectorTestWithParam<Conversion> |
| 865 CombineChangeFloat32ToInt32WithRoundFloat32; |
| 866 |
| 867 TEST_P(CombineChangeFloat32ToInt32WithRoundFloat32, Parameter) { |
| 868 { |
| 869 const Conversion conv = GetParam(); |
| 870 StreamBuilder m(this, conv.mi.machine_type, conv.src_machine_type); |
| 871 m.Return(m.ChangeFloat64ToInt32( |
| 872 m.ChangeFloat32ToFloat64((m.*conv.mi.constructor)(m.Parameter(0))))); |
| 873 Stream s = m.Build(); |
| 874 ASSERT_EQ(1U, s.size()); |
| 875 EXPECT_EQ(conv.mi.arch_opcode, s[0]->arch_opcode()); |
| 876 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); |
| 877 ASSERT_EQ(1U, s[0]->InputCount()); |
| 878 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 879 } |
| 880 } |
| 881 |
| 882 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, |
| 883 CombineChangeFloat32ToInt32WithRoundFloat32, |
| 884 ::testing::ValuesIn(kFloat32RoundInstructions)); |
| 885 |
| 886 |
| 887 TEST_F(InstructionSelectorTest, ChangeFloat64ToInt32OfChangeFloat32ToFloat64) { |
| 888 { |
| 889 StreamBuilder m(this, kMachInt32, kMachFloat32); |
| 890 m.Return(m.ChangeFloat64ToInt32(m.ChangeFloat32ToFloat64(m.Parameter(0)))); |
| 891 Stream s = m.Build(); |
| 892 ASSERT_EQ(1U, s.size()); |
| 893 EXPECT_EQ(kMips64TruncWS, s[0]->arch_opcode()); |
| 894 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); |
| 895 ASSERT_EQ(1U, s[0]->InputCount()); |
| 896 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 897 } |
| 898 } |
| 899 |
| 900 |
| 901 TEST_F(InstructionSelectorTest, |
| 902 TruncateFloat64ToFloat32OfChangeInt32ToFloat64) { |
| 903 { |
| 904 StreamBuilder m(this, kMachFloat32, kMachInt32); |
| 905 m.Return( |
| 906 m.TruncateFloat64ToFloat32(m.ChangeInt32ToFloat64(m.Parameter(0)))); |
| 907 Stream s = m.Build(); |
| 908 ASSERT_EQ(1U, s.size()); |
| 909 EXPECT_EQ(kMips64CvtSW, s[0]->arch_opcode()); |
| 910 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); |
| 911 ASSERT_EQ(1U, s[0]->InputCount()); |
| 912 EXPECT_EQ(1U, s[0]->OutputCount()); |
| 913 } |
| 914 } |
| 915 |
850 | 916 |
851 TEST_F(InstructionSelectorTest, CombineShiftsWithMul) { | 917 TEST_F(InstructionSelectorTest, CombineShiftsWithMul) { |
852 { | 918 { |
853 StreamBuilder m(this, kMachInt32, kMachInt32); | 919 StreamBuilder m(this, kMachInt32, kMachInt32); |
854 m.Return(m.Int32Mul(m.Word64Sar(m.Parameter(0), m.Int32Constant(32)), | 920 m.Return(m.Int32Mul(m.Word64Sar(m.Parameter(0), m.Int32Constant(32)), |
855 m.Word64Sar(m.Parameter(0), m.Int32Constant(32)))); | 921 m.Word64Sar(m.Parameter(0), m.Int32Constant(32)))); |
856 Stream s = m.Build(); | 922 Stream s = m.Build(); |
857 ASSERT_EQ(1U, s.size()); | 923 ASSERT_EQ(1U, s.size()); |
858 EXPECT_EQ(kMips64DMulHigh, s[0]->arch_opcode()); | 924 EXPECT_EQ(kMips64DMulHigh, s[0]->arch_opcode()); |
859 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); | 925 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1365 ASSERT_EQ(1U, s.size()); | 1431 ASSERT_EQ(1U, s.size()); |
1366 EXPECT_EQ(kMips64Float64Min, s[0]->arch_opcode()); | 1432 EXPECT_EQ(kMips64Float64Min, s[0]->arch_opcode()); |
1367 ASSERT_EQ(2U, s[0]->InputCount()); | 1433 ASSERT_EQ(2U, s[0]->InputCount()); |
1368 ASSERT_EQ(1U, s[0]->OutputCount()); | 1434 ASSERT_EQ(1U, s[0]->OutputCount()); |
1369 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1435 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
1370 } | 1436 } |
1371 | 1437 |
1372 } // namespace compiler | 1438 } // namespace compiler |
1373 } // namespace internal | 1439 } // namespace internal |
1374 } // namespace v8 | 1440 } // namespace v8 |
OLD | NEW |