| 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 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 TEST_F(RegisterConfigurationUnitTest, BasicProperties) { | 22 TEST_F(RegisterConfigurationUnitTest, BasicProperties) { |
| 23 const int kNumGeneralRegs = 3; | 23 const int kNumGeneralRegs = 3; |
| 24 const int kNumDoubleRegs = 4; | 24 const int kNumDoubleRegs = 4; |
| 25 const int kNumAllocatableGeneralRegs = 2; | 25 const int kNumAllocatableGeneralRegs = 2; |
| 26 const int kNumAllocatableDoubleRegs = 2; | 26 const int kNumAllocatableDoubleRegs = 2; |
| 27 int general_codes[kNumAllocatableGeneralRegs] = {1, 2}; | 27 int general_codes[kNumAllocatableGeneralRegs] = {1, 2}; |
| 28 int double_codes[kNumAllocatableDoubleRegs] = {2, 3}; | 28 int double_codes[kNumAllocatableDoubleRegs] = {2, 3}; |
| 29 | 29 |
| 30 RegisterConfiguration test( | 30 RegisterConfiguration test( |
| 31 kNumGeneralRegs, kNumDoubleRegs, kNumAllocatableGeneralRegs, | 31 kNumGeneralRegs, kNumDoubleRegs, kNumAllocatableGeneralRegs, |
| 32 kNumAllocatableDoubleRegs, RegisterConfiguration::OVERLAP, general_codes, | 32 kNumAllocatableDoubleRegs, general_codes, double_codes, |
| 33 double_codes, nullptr, nullptr, nullptr); | 33 RegisterConfiguration::OVERLAP, nullptr, nullptr, nullptr); |
| 34 | 34 |
| 35 EXPECT_EQ(test.num_general_registers(), kNumGeneralRegs); | 35 EXPECT_EQ(test.num_general_registers(), kNumGeneralRegs); |
| 36 EXPECT_EQ(test.num_double_registers(), kNumDoubleRegs); | 36 EXPECT_EQ(test.num_double_registers(), kNumDoubleRegs); |
| 37 EXPECT_EQ(test.num_allocatable_general_registers(), | 37 EXPECT_EQ(test.num_allocatable_general_registers(), |
| 38 kNumAllocatableGeneralRegs); | 38 kNumAllocatableGeneralRegs); |
| 39 EXPECT_EQ(test.num_allocatable_double_registers(), kNumAllocatableDoubleRegs); | 39 EXPECT_EQ(test.num_allocatable_double_registers(), kNumAllocatableDoubleRegs); |
| 40 EXPECT_EQ(test.num_allocatable_float_registers(), kNumAllocatableDoubleRegs); | 40 EXPECT_EQ(test.num_allocatable_float_registers(), kNumAllocatableDoubleRegs); |
| 41 | 41 |
| 42 EXPECT_EQ(test.allocatable_general_codes_mask(), | 42 EXPECT_EQ(test.allocatable_general_codes_mask(), |
| 43 (1 << general_codes[0]) | (1 << general_codes[1])); | 43 (1 << general_codes[0]) | (1 << general_codes[1])); |
| 44 EXPECT_EQ(test.GetAllocatableGeneralCode(0), general_codes[0]); | 44 EXPECT_EQ(test.GetAllocatableGeneralCode(0), general_codes[0]); |
| 45 EXPECT_EQ(test.GetAllocatableGeneralCode(1), general_codes[1]); | 45 EXPECT_EQ(test.GetAllocatableGeneralCode(1), general_codes[1]); |
| 46 EXPECT_EQ(test.allocatable_double_codes_mask(), | 46 EXPECT_EQ(test.allocatable_double_codes_mask(), |
| 47 (1 << double_codes[0]) | (1 << double_codes[1])); | 47 (1 << double_codes[0]) | (1 << double_codes[1])); |
| 48 EXPECT_EQ(test.GetAllocatableDoubleCode(0), double_codes[0]); | 48 EXPECT_EQ(test.GetAllocatableDoubleCode(0), double_codes[0]); |
| 49 EXPECT_EQ(test.GetAllocatableDoubleCode(1), double_codes[1]); | 49 EXPECT_EQ(test.GetAllocatableDoubleCode(1), double_codes[1]); |
| 50 } | 50 } |
| 51 | 51 |
| 52 TEST_F(RegisterConfigurationUnitTest, Aliasing) { | 52 TEST_F(RegisterConfigurationUnitTest, Aliasing) { |
| 53 const int kNumGeneralRegs = 3; | 53 const int kNumGeneralRegs = 3; |
| 54 const int kNumDoubleRegs = 4; | 54 const int kNumDoubleRegs = 4; |
| 55 const int kNumAllocatableGeneralRegs = 2; | 55 const int kNumAllocatableGeneralRegs = 2; |
| 56 const int kNumAllocatableDoubleRegs = 3; | 56 const int kNumAllocatableDoubleRegs = 3; |
| 57 int general_codes[] = {1, 2}; | 57 int general_codes[] = {1, 2}; |
| 58 int double_codes[] = {2, 3, 16}; // reg 16 should not alias registers 32, 33. | 58 int double_codes[] = {2, 3, 16}; // reg 16 should not alias registers 32, 33. |
| 59 | 59 |
| 60 RegisterConfiguration test( | 60 RegisterConfiguration test( |
| 61 kNumGeneralRegs, kNumDoubleRegs, kNumAllocatableGeneralRegs, | 61 kNumGeneralRegs, kNumDoubleRegs, kNumAllocatableGeneralRegs, |
| 62 kNumAllocatableDoubleRegs, RegisterConfiguration::COMBINE, general_codes, | 62 kNumAllocatableDoubleRegs, general_codes, double_codes, |
| 63 double_codes, nullptr, nullptr, nullptr); | 63 RegisterConfiguration::COMBINE, nullptr, nullptr, nullptr); |
| 64 | 64 |
| 65 // There are 3 allocatable double regs, but only 2 can alias float regs. | 65 // There are 3 allocatable double regs, but only 2 can alias float regs. |
| 66 EXPECT_EQ(test.num_allocatable_float_registers(), 4); | 66 EXPECT_EQ(test.num_allocatable_float_registers(), 4); |
| 67 | 67 |
| 68 // Test that float registers combine in pairs to form double registers. | 68 // Test that float registers combine in pairs to form double registers. |
| 69 EXPECT_EQ(test.GetAllocatableFloatCode(0), double_codes[0] * 2); | 69 EXPECT_EQ(test.GetAllocatableFloatCode(0), double_codes[0] * 2); |
| 70 EXPECT_EQ(test.GetAllocatableFloatCode(1), double_codes[0] * 2 + 1); | 70 EXPECT_EQ(test.GetAllocatableFloatCode(1), double_codes[0] * 2 + 1); |
| 71 EXPECT_EQ(test.GetAllocatableFloatCode(2), double_codes[1] * 2); | 71 EXPECT_EQ(test.GetAllocatableFloatCode(2), double_codes[1] * 2); |
| 72 EXPECT_EQ(test.GetAllocatableFloatCode(3), double_codes[1] * 2 + 1); | 72 EXPECT_EQ(test.GetAllocatableFloatCode(3), double_codes[1] * 2 + 1); |
| 73 | 73 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 test.GetAliases(kFloat64, RegisterConfiguration::kMaxFPRegisters / 2 + 1, | 121 test.GetAliases(kFloat64, RegisterConfiguration::kMaxFPRegisters / 2 + 1, |
| 122 kFloat32, &alias_base_index), | 122 kFloat32, &alias_base_index), |
| 123 0); | 123 0); |
| 124 EXPECT_EQ(test.GetAliases(kFloat64, RegisterConfiguration::kMaxFPRegisters, | 124 EXPECT_EQ(test.GetAliases(kFloat64, RegisterConfiguration::kMaxFPRegisters, |
| 125 kFloat32, &alias_base_index), | 125 kFloat32, &alias_base_index), |
| 126 0); | 126 0); |
| 127 } | 127 } |
| 128 | 128 |
| 129 } // namespace internal | 129 } // namespace internal |
| 130 } // namespace v8 | 130 } // namespace v8 |
| OLD | NEW |