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 12 matching lines...) Expand all Loading... |
23 TEST_F(RegisterConfigurationUnitTest, BasicProperties) { | 23 TEST_F(RegisterConfigurationUnitTest, BasicProperties) { |
24 const int kNumGeneralRegs = 3; | 24 const int kNumGeneralRegs = 3; |
25 const int kNumDoubleRegs = 4; | 25 const int kNumDoubleRegs = 4; |
26 const int kNumAllocatableGeneralRegs = 2; | 26 const int kNumAllocatableGeneralRegs = 2; |
27 const int kNumAllocatableDoubleRegs = 2; | 27 const int kNumAllocatableDoubleRegs = 2; |
28 int general_codes[kNumAllocatableGeneralRegs] = {1, 2}; | 28 int general_codes[kNumAllocatableGeneralRegs] = {1, 2}; |
29 int double_codes[kNumAllocatableDoubleRegs] = {2, 3}; | 29 int double_codes[kNumAllocatableDoubleRegs] = {2, 3}; |
30 | 30 |
31 RegisterConfiguration test( | 31 RegisterConfiguration test( |
32 kNumGeneralRegs, kNumDoubleRegs, kNumAllocatableGeneralRegs, | 32 kNumGeneralRegs, kNumDoubleRegs, kNumAllocatableGeneralRegs, |
33 kNumAllocatableDoubleRegs, general_codes, double_codes, | 33 kNumAllocatableDoubleRegs, kNumAllocatableDoubleRegs, general_codes, |
34 RegisterConfiguration::OVERLAP, nullptr, nullptr, nullptr, nullptr); | 34 double_codes, RegisterConfiguration::OVERLAP, nullptr, nullptr, nullptr, |
| 35 nullptr); |
35 | 36 |
36 EXPECT_EQ(test.num_general_registers(), kNumGeneralRegs); | 37 EXPECT_EQ(test.num_general_registers(), kNumGeneralRegs); |
37 EXPECT_EQ(test.num_double_registers(), kNumDoubleRegs); | 38 EXPECT_EQ(test.num_double_registers(), kNumDoubleRegs); |
38 EXPECT_EQ(test.num_allocatable_general_registers(), | 39 EXPECT_EQ(test.num_allocatable_general_registers(), |
39 kNumAllocatableGeneralRegs); | 40 kNumAllocatableGeneralRegs); |
40 EXPECT_EQ(test.num_allocatable_double_registers(), kNumAllocatableDoubleRegs); | 41 EXPECT_EQ(test.num_allocatable_double_registers(), kNumAllocatableDoubleRegs); |
41 EXPECT_EQ(test.num_allocatable_float_registers(), kNumAllocatableDoubleRegs); | 42 EXPECT_EQ(test.num_allocatable_float_registers(), kNumAllocatableDoubleRegs); |
42 EXPECT_EQ(test.num_allocatable_simd128_registers(), | 43 EXPECT_EQ(test.num_allocatable_simd128_registers(), |
43 kNumAllocatableDoubleRegs); | 44 kNumAllocatableDoubleRegs); |
44 | 45 |
(...skipping 14 matching lines...) Expand all Loading... |
59 TEST_F(RegisterConfigurationUnitTest, CombineAliasing) { | 60 TEST_F(RegisterConfigurationUnitTest, CombineAliasing) { |
60 const int kNumGeneralRegs = 3; | 61 const int kNumGeneralRegs = 3; |
61 const int kNumDoubleRegs = 4; | 62 const int kNumDoubleRegs = 4; |
62 const int kNumAllocatableGeneralRegs = 2; | 63 const int kNumAllocatableGeneralRegs = 2; |
63 const int kNumAllocatableDoubleRegs = 3; | 64 const int kNumAllocatableDoubleRegs = 3; |
64 int general_codes[] = {1, 2}; | 65 int general_codes[] = {1, 2}; |
65 int double_codes[] = {2, 3, 16}; // reg 16 should not alias registers 32, 33. | 66 int double_codes[] = {2, 3, 16}; // reg 16 should not alias registers 32, 33. |
66 | 67 |
67 RegisterConfiguration test( | 68 RegisterConfiguration test( |
68 kNumGeneralRegs, kNumDoubleRegs, kNumAllocatableGeneralRegs, | 69 kNumGeneralRegs, kNumDoubleRegs, kNumAllocatableGeneralRegs, |
69 kNumAllocatableDoubleRegs, general_codes, double_codes, | 70 kNumAllocatableDoubleRegs, kNumAllocatableDoubleRegs, general_codes, |
70 RegisterConfiguration::COMBINE, nullptr, nullptr, nullptr, nullptr); | 71 double_codes, RegisterConfiguration::COMBINE, nullptr, nullptr, nullptr, |
| 72 nullptr); |
71 | 73 |
72 // There are 3 allocatable double regs, but only 2 can alias float regs. | 74 // There are 3 allocatable double regs, but only 2 can alias float regs. |
73 EXPECT_EQ(test.num_allocatable_float_registers(), 4); | 75 EXPECT_EQ(test.num_allocatable_float_registers(), 4); |
74 | 76 |
75 // Test that float registers combine in pairs to form double registers. | 77 // Test that float registers combine in pairs to form double registers. |
76 EXPECT_EQ(test.GetAllocatableFloatCode(0), double_codes[0] * 2); | 78 EXPECT_EQ(test.GetAllocatableFloatCode(0), double_codes[0] * 2); |
77 EXPECT_EQ(test.GetAllocatableFloatCode(1), double_codes[0] * 2 + 1); | 79 EXPECT_EQ(test.GetAllocatableFloatCode(1), double_codes[0] * 2 + 1); |
78 EXPECT_EQ(test.GetAllocatableFloatCode(2), double_codes[1] * 2); | 80 EXPECT_EQ(test.GetAllocatableFloatCode(2), double_codes[1] * 2); |
79 EXPECT_EQ(test.GetAllocatableFloatCode(3), double_codes[1] * 2 + 1); | 81 EXPECT_EQ(test.GetAllocatableFloatCode(3), double_codes[1] * 2 + 1); |
80 | 82 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 test.GetAliases(kFloat64, RegisterConfiguration::kMaxFPRegisters / 2 + 1, | 157 test.GetAliases(kFloat64, RegisterConfiguration::kMaxFPRegisters / 2 + 1, |
156 kFloat32, &alias_base_index), | 158 kFloat32, &alias_base_index), |
157 0); | 159 0); |
158 EXPECT_EQ(test.GetAliases(kFloat64, RegisterConfiguration::kMaxFPRegisters, | 160 EXPECT_EQ(test.GetAliases(kFloat64, RegisterConfiguration::kMaxFPRegisters, |
159 kFloat32, &alias_base_index), | 161 kFloat32, &alias_base_index), |
160 0); | 162 0); |
161 } | 163 } |
162 | 164 |
163 } // namespace internal | 165 } // namespace internal |
164 } // namespace v8 | 166 } // namespace v8 |
OLD | NEW |