Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/register-configuration.cc

Issue 1482963003: Clean up ArchDefaultRegisterConfiguration. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Leave masks. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "src/register-configuration.h" 5 #include "src/register-configuration.h"
6 #include "src/globals.h" 6 #include "src/globals.h"
7 #include "src/macro-assembler.h" 7 #include "src/macro-assembler.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
11 11
12 namespace { 12 namespace {
13 13
14 #define REGISTER_COUNT(R) 1 + 14 #define REGISTER_COUNT(R) 1 +
15 static const int kMaxAllocatableGeneralRegisterCount = 15 static const int kMaxAllocatableGeneralRegisterCount =
16 ALLOCATABLE_GENERAL_REGISTERS(REGISTER_COUNT)0; 16 ALLOCATABLE_GENERAL_REGISTERS(REGISTER_COUNT)0;
17 static const int kMaxAllocatableDoubleRegisterCount = 17 static const int kMaxAllocatableDoubleRegisterCount =
18 ALLOCATABLE_DOUBLE_REGISTERS(REGISTER_COUNT)0; 18 ALLOCATABLE_DOUBLE_REGISTERS(REGISTER_COUNT)0;
19 19
20 static const int kAllocatableGeneralCodes[] = {
21 #define REGISTER_CODE(R) Register::kCode_##R,
22 ALLOCATABLE_GENERAL_REGISTERS(REGISTER_CODE)};
23 #undef REGISTER_CODE
24
25 static const int kAllocatableDoubleCodes[] = {
26 #define REGISTER_CODE(R) DoubleRegister::kCode_##R,
27 ALLOCATABLE_DOUBLE_REGISTERS(REGISTER_CODE)};
28 #undef REGISTER_CODE
29
20 static const char* const kGeneralRegisterNames[] = { 30 static const char* const kGeneralRegisterNames[] = {
21 #define REGISTER_NAME(R) #R, 31 #define REGISTER_NAME(R) #R,
22 GENERAL_REGISTERS(REGISTER_NAME) 32 GENERAL_REGISTERS(REGISTER_NAME)
23 #undef REGISTER_NAME 33 #undef REGISTER_NAME
24 }; 34 };
25 35
26 static const char* const kDoubleRegisterNames[] = { 36 static const char* const kDoubleRegisterNames[] = {
27 #define REGISTER_NAME(R) #R, 37 #define REGISTER_NAME(R) #R,
28 DOUBLE_REGISTERS(REGISTER_NAME) 38 DOUBLE_REGISTERS(REGISTER_NAME)
29 #undef REGISTER_NAME 39 #undef REGISTER_NAME
30 }; 40 };
31 41
32 STATIC_ASSERT(RegisterConfiguration::kMaxGeneralRegisters >= 42 STATIC_ASSERT(RegisterConfiguration::kMaxGeneralRegisters >=
33 Register::kNumRegisters); 43 Register::kNumRegisters);
34 STATIC_ASSERT(RegisterConfiguration::kMaxDoubleRegisters >= 44 STATIC_ASSERT(RegisterConfiguration::kMaxDoubleRegisters >=
35 DoubleRegister::kMaxNumRegisters); 45 DoubleRegister::kMaxNumRegisters);
36 46
37 class ArchDefaultRegisterConfiguration : public RegisterConfiguration { 47 class ArchDefaultRegisterConfiguration : public RegisterConfiguration {
38 public: 48 public:
39 explicit ArchDefaultRegisterConfiguration(CompilerSelector compiler) 49 explicit ArchDefaultRegisterConfiguration(CompilerSelector compiler)
40 : RegisterConfiguration( 50 : RegisterConfiguration(Register::kNumRegisters,
41 Register::kNumRegisters, DoubleRegister::kMaxNumRegisters, 51 DoubleRegister::kMaxNumRegisters,
42 #if V8_TARGET_ARCH_IA32 52 #if V8_TARGET_ARCH_IA32
43 kMaxAllocatableGeneralRegisterCount, 53 kMaxAllocatableGeneralRegisterCount,
44 kMaxAllocatableDoubleRegisterCount, 54 kMaxAllocatableDoubleRegisterCount,
45 kMaxAllocatableDoubleRegisterCount, 55 kMaxAllocatableDoubleRegisterCount,
46 #elif V8_TARGET_ARCH_X87 56 #elif V8_TARGET_ARCH_X87
47 kMaxAllocatableGeneralRegisterCount, 57 kMaxAllocatableGeneralRegisterCount,
48 compiler == TURBOFAN ? 1 : kMaxAllocatableDoubleRegisterCount, 58 compiler == TURBOFAN
49 compiler == TURBOFAN ? 1 : kMaxAllocatableDoubleRegisterCount, 59 ? 1
60 : kMaxAllocatableDoubleRegisterCount,
61 compiler == TURBOFAN
62 ? 1
63 : kMaxAllocatableDoubleRegisterCount,
50 #elif V8_TARGET_ARCH_X64 64 #elif V8_TARGET_ARCH_X64
51 kMaxAllocatableGeneralRegisterCount, 65 kMaxAllocatableGeneralRegisterCount,
52 kMaxAllocatableDoubleRegisterCount, 66 kMaxAllocatableDoubleRegisterCount,
53 kMaxAllocatableDoubleRegisterCount, 67 kMaxAllocatableDoubleRegisterCount,
54 #elif V8_TARGET_ARCH_ARM 68 #elif V8_TARGET_ARCH_ARM
55 FLAG_enable_embedded_constant_pool 69 FLAG_enable_embedded_constant_pool
56 ? (kMaxAllocatableGeneralRegisterCount - 1) 70 ? (kMaxAllocatableGeneralRegisterCount - 1)
57 : kMaxAllocatableGeneralRegisterCount, 71 : kMaxAllocatableGeneralRegisterCount,
58 CpuFeatures::IsSupported(VFP32DREGS) 72 CpuFeatures::IsSupported(VFP32DREGS)
59 ? kMaxAllocatableDoubleRegisterCount 73 ? kMaxAllocatableDoubleRegisterCount
60 : (ALLOCATABLE_NO_VFP32_DOUBLE_REGISTERS(REGISTER_COUNT)0), 74 : (ALLOCATABLE_NO_VFP32_DOUBLE_REGISTERS(
61 ALLOCATABLE_NO_VFP32_DOUBLE_REGISTERS(REGISTER_COUNT)0, 75 REGISTER_COUNT)0),
76 ALLOCATABLE_NO_VFP32_DOUBLE_REGISTERS(
77 REGISTER_COUNT)0,
62 #elif V8_TARGET_ARCH_ARM64 78 #elif V8_TARGET_ARCH_ARM64
63 kMaxAllocatableGeneralRegisterCount, 79 kMaxAllocatableGeneralRegisterCount,
64 kMaxAllocatableDoubleRegisterCount, 80 kMaxAllocatableDoubleRegisterCount,
65 kMaxAllocatableDoubleRegisterCount, 81 kMaxAllocatableDoubleRegisterCount,
66 #elif V8_TARGET_ARCH_MIPS 82 #elif V8_TARGET_ARCH_MIPS
67 kMaxAllocatableGeneralRegisterCount, 83 kMaxAllocatableGeneralRegisterCount,
68 kMaxAllocatableDoubleRegisterCount, 84 kMaxAllocatableDoubleRegisterCount,
69 kMaxAllocatableDoubleRegisterCount, 85 kMaxAllocatableDoubleRegisterCount,
70 #elif V8_TARGET_ARCH_MIPS64 86 #elif V8_TARGET_ARCH_MIPS64
71 kMaxAllocatableGeneralRegisterCount, 87 kMaxAllocatableGeneralRegisterCount,
72 kMaxAllocatableDoubleRegisterCount, 88 kMaxAllocatableDoubleRegisterCount,
73 kMaxAllocatableDoubleRegisterCount, 89 kMaxAllocatableDoubleRegisterCount,
74 #elif V8_TARGET_ARCH_PPC 90 #elif V8_TARGET_ARCH_PPC
75 kMaxAllocatableGeneralRegisterCount, 91 kMaxAllocatableGeneralRegisterCount,
76 kMaxAllocatableDoubleRegisterCount, 92 kMaxAllocatableDoubleRegisterCount,
77 kMaxAllocatableDoubleRegisterCount, 93 kMaxAllocatableDoubleRegisterCount,
78 #else 94 #else
79 GetAllocatableGeneralRegisterCount(), 95 #error Unsupported target architecture.
80 GetAllocatableDoubleRegisterCount(),
81 GetAllocatableAliasedDoubleRegisterCount(),
82 #endif 96 #endif
83 GetAllocatableGeneralCodes(), GetAllocatableDoubleCodes(), 97 kAllocatableGeneralCodes, kAllocatableDoubleCodes,
84 kGeneralRegisterNames, kDoubleRegisterNames) { 98 kGeneralRegisterNames, kDoubleRegisterNames) {
85 }
86
87 const char* general_register_name_table_[Register::kNumRegisters];
88 const char* double_register_name_table_[DoubleRegister::kMaxNumRegisters];
89
90 private:
91 static const int* GetAllocatableGeneralCodes() {
92 #define REGISTER_CODE(R) Register::kCode_##R,
93 static const int general_codes[] = {
94 ALLOCATABLE_GENERAL_REGISTERS(REGISTER_CODE)};
95 #undef REGISTER_CODE
96 return general_codes;
97 }
98
99 static const int* GetAllocatableDoubleCodes() {
100 #define REGISTER_CODE(R) DoubleRegister::kCode_##R,
101 static const int double_codes[] = {
102 ALLOCATABLE_DOUBLE_REGISTERS(REGISTER_CODE)};
103 #undef REGISTER_CODE
104 return double_codes;
105 } 99 }
106 }; 100 };
107 101
108 102
109 template <RegisterConfiguration::CompilerSelector compiler> 103 template <RegisterConfiguration::CompilerSelector compiler>
110 struct RegisterConfigurationInitializer { 104 struct RegisterConfigurationInitializer {
111 static void Construct(ArchDefaultRegisterConfiguration* config) { 105 static void Construct(ArchDefaultRegisterConfiguration* config) {
112 new (config) ArchDefaultRegisterConfiguration(compiler); 106 new (config) ArchDefaultRegisterConfiguration(compiler);
113 } 107 }
114 }; 108 };
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } 153 }
160 for (int i = 0; i < num_allocatable_double_registers_; ++i) { 154 for (int i = 0; i < num_allocatable_double_registers_; ++i) {
161 allocatable_double_codes_mask_ |= (1 << allocatable_double_codes_[i]); 155 allocatable_double_codes_mask_ |= (1 << allocatable_double_codes_[i]);
162 } 156 }
163 } 157 }
164 158
165 #undef REGISTER_COUNT 159 #undef REGISTER_COUNT
166 160
167 } // namespace internal 161 } // namespace internal
168 } // namespace v8 162 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698