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 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
909 -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, | 909 -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, |
910 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, | 910 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}, |
911 {MachineType::Float64(), | 911 {MachineType::Float64(), |
912 kMipsLdc1, | 912 kMipsLdc1, |
913 kMipsSdc1, | 913 kMipsSdc1, |
914 &InstructionSelectorTest::Stream::IsDouble, | 914 &InstructionSelectorTest::Stream::IsDouble, |
915 {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, | 915 {-4095, -3340, -3231, -3224, -3088, -1758, -1203, -123, -117, -91, -89, |
916 -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, | 916 -87, -86, -82, -44, -23, -3, 0, 7, 10, 39, 52, 69, 71, 91, 92, 107, 109, |
917 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}}; | 917 115, 124, 286, 655, 1362, 1569, 2587, 3067, 3096, 3462, 3510, 4095}}}; |
918 | 918 |
919 | |
920 const MemoryAccessImm1 kMemoryAccessImmMoreThan16bit[] = { | 919 const MemoryAccessImm1 kMemoryAccessImmMoreThan16bit[] = { |
921 {MachineType::Int8(), | 920 {MachineType::Int8(), |
922 kMipsLb, | 921 kMipsLb, |
923 kMipsSb, | 922 kMipsSb, |
924 &InstructionSelectorTest::Stream::IsInteger, | 923 &InstructionSelectorTest::Stream::IsInteger, |
925 {-65000, -55000, 32777, 55000, 65000}}, | 924 {-65000, -55000, 32777, 55000, 65000}}, |
926 {MachineType::Int8(), | 925 {MachineType::Uint8(), |
927 kMipsLbu, | 926 kMipsLbu, |
928 kMipsSb, | 927 kMipsSb, |
929 &InstructionSelectorTest::Stream::IsInteger, | 928 &InstructionSelectorTest::Stream::IsInteger, |
930 {-65000, -55000, 32777, 55000, 65000}}, | 929 {-65000, -55000, 32777, 55000, 65000}}, |
931 {MachineType::Int16(), | 930 {MachineType::Int16(), |
932 kMipsLh, | 931 kMipsLh, |
933 kMipsSh, | 932 kMipsSh, |
934 &InstructionSelectorTest::Stream::IsInteger, | 933 &InstructionSelectorTest::Stream::IsInteger, |
935 {-65000, -55000, 32777, 55000, 65000}}, | 934 {-65000, -55000, 32777, 55000, 65000}}, |
936 {MachineType::Int16(), | 935 {MachineType::Uint16(), |
937 kMipsLhu, | 936 kMipsLhu, |
938 kMipsSh, | 937 kMipsSh, |
939 &InstructionSelectorTest::Stream::IsInteger, | 938 &InstructionSelectorTest::Stream::IsInteger, |
940 {-65000, -55000, 32777, 55000, 65000}}, | 939 {-65000, -55000, 32777, 55000, 65000}}, |
941 {MachineType::Int32(), | 940 {MachineType::Int32(), |
942 kMipsLw, | 941 kMipsLw, |
943 kMipsSw, | 942 kMipsSw, |
944 &InstructionSelectorTest::Stream::IsInteger, | 943 &InstructionSelectorTest::Stream::IsInteger, |
945 {-65000, -55000, 32777, 55000, 65000}}, | 944 {-65000, -55000, 32777, 55000, 65000}}, |
946 {MachineType::Float32(), | 945 {MachineType::Float32(), |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 InstructionSelectorMemoryAccessImmMoreThan16bitTest; | 1057 InstructionSelectorMemoryAccessImmMoreThan16bitTest; |
1059 | 1058 |
1060 | 1059 |
1061 TEST_P(InstructionSelectorMemoryAccessImmMoreThan16bitTest, | 1060 TEST_P(InstructionSelectorMemoryAccessImmMoreThan16bitTest, |
1062 LoadWithImmediateIndex) { | 1061 LoadWithImmediateIndex) { |
1063 const MemoryAccessImm1 memacc = GetParam(); | 1062 const MemoryAccessImm1 memacc = GetParam(); |
1064 TRACED_FOREACH(int32_t, index, memacc.immediates) { | 1063 TRACED_FOREACH(int32_t, index, memacc.immediates) { |
1065 StreamBuilder m(this, memacc.type, MachineType::Pointer()); | 1064 StreamBuilder m(this, memacc.type, MachineType::Pointer()); |
1066 m.Return(m.Load(memacc.type, m.Parameter(0), m.Int32Constant(index))); | 1065 m.Return(m.Load(memacc.type, m.Parameter(0), m.Int32Constant(index))); |
1067 Stream s = m.Build(); | 1066 Stream s = m.Build(); |
1068 ASSERT_EQ(2U, s.size()); | 1067 ASSERT_EQ(1U, s.size()); |
1069 // kMipsAdd is expected opcode. | 1068 EXPECT_EQ(memacc.load_opcode, s[0]->arch_opcode()); |
1070 // size more than 16 bits wide. | 1069 EXPECT_EQ(kMode_MRI, s[0]->addressing_mode()); |
1071 EXPECT_EQ(kMipsAdd, s[0]->arch_opcode()); | |
1072 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); | |
1073 EXPECT_EQ(2U, s[0]->InputCount()); | 1070 EXPECT_EQ(2U, s[0]->InputCount()); |
1074 EXPECT_EQ(1U, s[0]->OutputCount()); | 1071 EXPECT_EQ(1U, s[0]->OutputCount()); |
1075 } | 1072 } |
1076 } | 1073 } |
1077 | 1074 |
1078 | 1075 |
1079 TEST_P(InstructionSelectorMemoryAccessImmMoreThan16bitTest, | 1076 TEST_P(InstructionSelectorMemoryAccessImmMoreThan16bitTest, |
1080 StoreWithImmediateIndex) { | 1077 StoreWithImmediateIndex) { |
1081 const MemoryAccessImm1 memacc = GetParam(); | 1078 const MemoryAccessImm1 memacc = GetParam(); |
1082 TRACED_FOREACH(int32_t, index, memacc.immediates) { | 1079 TRACED_FOREACH(int32_t, index, memacc.immediates) { |
1083 StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), | 1080 StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(), |
1084 memacc.type); | 1081 memacc.type); |
1085 m.Store(memacc.type.representation(), m.Parameter(0), | 1082 m.Store(memacc.type.representation(), m.Parameter(0), |
1086 m.Int32Constant(index), m.Parameter(1), kNoWriteBarrier); | 1083 m.Int32Constant(index), m.Parameter(1), kNoWriteBarrier); |
1087 m.Return(m.Int32Constant(0)); | 1084 m.Return(m.Int32Constant(0)); |
1088 Stream s = m.Build(); | 1085 Stream s = m.Build(); |
1089 ASSERT_EQ(2U, s.size()); | 1086 ASSERT_EQ(1U, s.size()); |
1090 // kMipsAdd is expected opcode | 1087 EXPECT_EQ(memacc.store_opcode, s[0]->arch_opcode()); |
1091 // size more than 16 bits wide | 1088 EXPECT_EQ(kMode_MRI, s[0]->addressing_mode()); |
1092 EXPECT_EQ(kMipsAdd, s[0]->arch_opcode()); | 1089 EXPECT_EQ(3U, s[0]->InputCount()); |
1093 EXPECT_EQ(kMode_None, s[0]->addressing_mode()); | 1090 EXPECT_EQ(0, s[0]->OutputCount()); |
1094 EXPECT_EQ(2U, s[0]->InputCount()); | |
1095 EXPECT_EQ(1U, s[0]->OutputCount()); | |
1096 } | 1091 } |
1097 } | 1092 } |
1098 | 1093 |
1099 | 1094 |
1100 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, | 1095 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, |
1101 InstructionSelectorMemoryAccessImmMoreThan16bitTest, | 1096 InstructionSelectorMemoryAccessImmMoreThan16bitTest, |
1102 ::testing::ValuesIn(kMemoryAccessImmMoreThan16bit)); | 1097 ::testing::ValuesIn(kMemoryAccessImmMoreThan16bit)); |
1103 | 1098 |
1104 | 1099 |
1105 // ---------------------------------------------------------------------------- | 1100 // ---------------------------------------------------------------------------- |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1420 ASSERT_EQ(1U, s.size()); | 1415 ASSERT_EQ(1U, s.size()); |
1421 EXPECT_EQ(kMipsFloat64Min, s[0]->arch_opcode()); | 1416 EXPECT_EQ(kMipsFloat64Min, s[0]->arch_opcode()); |
1422 ASSERT_EQ(2U, s[0]->InputCount()); | 1417 ASSERT_EQ(2U, s[0]->InputCount()); |
1423 ASSERT_EQ(1U, s[0]->OutputCount()); | 1418 ASSERT_EQ(1U, s[0]->OutputCount()); |
1424 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1419 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
1425 } | 1420 } |
1426 | 1421 |
1427 } // namespace compiler | 1422 } // namespace compiler |
1428 } // namespace internal | 1423 } // namespace internal |
1429 } // namespace v8 | 1424 } // namespace v8 |
OLD | NEW |