| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 "src/register-configuration.h" | 5 #include "src/register-configuration.h" |
| 6 #include "testing/gtest-support.h" | 6 #include "testing/gtest-support.h" |
| 7 | 7 |
| 8 namespace v8 { | 8 namespace v8 { |
| 9 namespace internal { | 9 namespace internal { |
| 10 | 10 |
| 11 const MachineRepresentation kFloat32 = MachineRepresentation::kFloat32; | 11 const MachineRepresentation kFloat32 = MachineRepresentation::kFloat32; |
| 12 const MachineRepresentation kFloat64 = MachineRepresentation::kFloat64; | 12 const MachineRepresentation kFloat64 = MachineRepresentation::kFloat64; |
| 13 const MachineRepresentation kSimd128 = MachineRepresentation::kSimd128; | 13 const MachineRepresentation kSimd128 = MachineRepresentation::kSimd128; |
| 14 | 14 |
| 15 class RegisterConfigurationUnitTest : public ::testing::Test { | 15 class RegisterConfigurationUnitTest : public ::testing::Test { |
| 16 public: | 16 public: |
| 17 RegisterConfigurationUnitTest() {} | 17 RegisterConfigurationUnitTest() {} |
| 18 virtual ~RegisterConfigurationUnitTest() {} | 18 virtual ~RegisterConfigurationUnitTest() {} |
| 19 | |
| 20 private: | |
| 21 }; | 19 }; |
| 22 | 20 |
| 23 TEST_F(RegisterConfigurationUnitTest, BasicProperties) { | 21 TEST_F(RegisterConfigurationUnitTest, BasicProperties) { |
| 24 const int kNumGeneralRegs = 3; | 22 const int kNumGeneralRegs = 3; |
| 25 const int kNumDoubleRegs = 4; | 23 const int kNumDoubleRegs = 4; |
| 26 const int kNumAllocatableGeneralRegs = 2; | 24 const int kNumAllocatableGeneralRegs = 2; |
| 27 const int kNumAllocatableDoubleRegs = 2; | 25 const int kNumAllocatableDoubleRegs = 2; |
| 28 int general_codes[kNumAllocatableGeneralRegs] = {1, 2}; | 26 int general_codes[kNumAllocatableGeneralRegs] = {1, 2}; |
| 29 int double_codes[kNumAllocatableDoubleRegs] = {2, 3}; | 27 int double_codes[kNumAllocatableDoubleRegs] = {2, 3}; |
| 30 | 28 |
| 31 RegisterConfiguration test( | 29 RegisterConfiguration test( |
| 32 kNumGeneralRegs, kNumDoubleRegs, kNumAllocatableGeneralRegs, | 30 kNumGeneralRegs, kNumDoubleRegs, kNumAllocatableGeneralRegs, |
| 33 kNumAllocatableDoubleRegs, kNumAllocatableDoubleRegs, general_codes, | 31 kNumAllocatableDoubleRegs, general_codes, double_codes, |
| 34 double_codes, RegisterConfiguration::OVERLAP, nullptr, nullptr, nullptr, | 32 RegisterConfiguration::OVERLAP, nullptr, nullptr, nullptr, nullptr); |
| 35 nullptr); | |
| 36 | 33 |
| 37 EXPECT_EQ(test.num_general_registers(), kNumGeneralRegs); | 34 EXPECT_EQ(test.num_general_registers(), kNumGeneralRegs); |
| 38 EXPECT_EQ(test.num_double_registers(), kNumDoubleRegs); | 35 EXPECT_EQ(test.num_double_registers(), kNumDoubleRegs); |
| 39 EXPECT_EQ(test.num_allocatable_general_registers(), | 36 EXPECT_EQ(test.num_allocatable_general_registers(), |
| 40 kNumAllocatableGeneralRegs); | 37 kNumAllocatableGeneralRegs); |
| 41 EXPECT_EQ(test.num_allocatable_double_registers(), kNumAllocatableDoubleRegs); | 38 EXPECT_EQ(test.num_allocatable_double_registers(), kNumAllocatableDoubleRegs); |
| 42 EXPECT_EQ(test.num_allocatable_float_registers(), kNumAllocatableDoubleRegs); | 39 EXPECT_EQ(test.num_allocatable_float_registers(), kNumAllocatableDoubleRegs); |
| 43 EXPECT_EQ(test.num_allocatable_simd128_registers(), | 40 EXPECT_EQ(test.num_allocatable_simd128_registers(), |
| 44 kNumAllocatableDoubleRegs); | 41 kNumAllocatableDoubleRegs); |
| 45 | 42 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 60 TEST_F(RegisterConfigurationUnitTest, CombineAliasing) { | 57 TEST_F(RegisterConfigurationUnitTest, CombineAliasing) { |
| 61 const int kNumGeneralRegs = 3; | 58 const int kNumGeneralRegs = 3; |
| 62 const int kNumDoubleRegs = 4; | 59 const int kNumDoubleRegs = 4; |
| 63 const int kNumAllocatableGeneralRegs = 2; | 60 const int kNumAllocatableGeneralRegs = 2; |
| 64 const int kNumAllocatableDoubleRegs = 3; | 61 const int kNumAllocatableDoubleRegs = 3; |
| 65 int general_codes[] = {1, 2}; | 62 int general_codes[] = {1, 2}; |
| 66 int double_codes[] = {2, 3, 16}; // reg 16 should not alias registers 32, 33. | 63 int double_codes[] = {2, 3, 16}; // reg 16 should not alias registers 32, 33. |
| 67 | 64 |
| 68 RegisterConfiguration test( | 65 RegisterConfiguration test( |
| 69 kNumGeneralRegs, kNumDoubleRegs, kNumAllocatableGeneralRegs, | 66 kNumGeneralRegs, kNumDoubleRegs, kNumAllocatableGeneralRegs, |
| 70 kNumAllocatableDoubleRegs, kNumAllocatableDoubleRegs, general_codes, | 67 kNumAllocatableDoubleRegs, general_codes, double_codes, |
| 71 double_codes, RegisterConfiguration::COMBINE, nullptr, nullptr, nullptr, | 68 RegisterConfiguration::COMBINE, nullptr, nullptr, nullptr, nullptr); |
| 72 nullptr); | |
| 73 | 69 |
| 74 // There are 3 allocatable double regs, but only 2 can alias float regs. | 70 // There are 3 allocatable double regs, but only 2 can alias float regs. |
| 75 EXPECT_EQ(test.num_allocatable_float_registers(), 4); | 71 EXPECT_EQ(test.num_allocatable_float_registers(), 4); |
| 76 | 72 |
| 77 // Test that float registers combine in pairs to form double registers. | 73 // Test that float registers combine in pairs to form double registers. |
| 78 EXPECT_EQ(test.GetAllocatableFloatCode(0), double_codes[0] * 2); | 74 EXPECT_EQ(test.GetAllocatableFloatCode(0), double_codes[0] * 2); |
| 79 EXPECT_EQ(test.GetAllocatableFloatCode(1), double_codes[0] * 2 + 1); | 75 EXPECT_EQ(test.GetAllocatableFloatCode(1), double_codes[0] * 2 + 1); |
| 80 EXPECT_EQ(test.GetAllocatableFloatCode(2), double_codes[1] * 2); | 76 EXPECT_EQ(test.GetAllocatableFloatCode(2), double_codes[1] * 2); |
| 81 EXPECT_EQ(test.GetAllocatableFloatCode(3), double_codes[1] * 2 + 1); | 77 EXPECT_EQ(test.GetAllocatableFloatCode(3), double_codes[1] * 2 + 1); |
| 82 | 78 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 EXPECT_EQ(alias_base_index, 4); | 146 EXPECT_EQ(alias_base_index, 4); |
| 151 // High numbered double and simd regs don't alias nonexistent float registers. | 147 // High numbered double and simd regs don't alias nonexistent float registers. |
| 152 EXPECT_EQ( | 148 EXPECT_EQ( |
| 153 test.GetAliases(kFloat64, RegisterConfiguration::kMaxFPRegisters / 2, | 149 test.GetAliases(kFloat64, RegisterConfiguration::kMaxFPRegisters / 2, |
| 154 kFloat32, &alias_base_index), | 150 kFloat32, &alias_base_index), |
| 155 0); | 151 0); |
| 156 EXPECT_EQ( | 152 EXPECT_EQ( |
| 157 test.GetAliases(kFloat64, RegisterConfiguration::kMaxFPRegisters / 2 + 1, | 153 test.GetAliases(kFloat64, RegisterConfiguration::kMaxFPRegisters / 2 + 1, |
| 158 kFloat32, &alias_base_index), | 154 kFloat32, &alias_base_index), |
| 159 0); | 155 0); |
| 160 EXPECT_EQ(test.GetAliases(kFloat64, RegisterConfiguration::kMaxFPRegisters, | 156 EXPECT_EQ( |
| 161 kFloat32, &alias_base_index), | 157 test.GetAliases(kFloat64, RegisterConfiguration::kMaxFPRegisters - 1, |
| 162 0); | 158 kFloat32, &alias_base_index), |
| 159 0); |
| 163 } | 160 } |
| 164 | 161 |
| 165 } // namespace internal | 162 } // namespace internal |
| 166 } // namespace v8 | 163 } // namespace v8 |
| OLD | NEW |