| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "src/register-configuration.h" |
| 6 #include "src/globals.h" |
| 7 #include "src/macro-assembler.h" |
| 8 |
| 9 namespace v8 { |
| 10 namespace internal { |
| 11 |
| 12 namespace { |
| 13 |
| 14 #define REGISTER_COUNT(R) 1 + |
| 15 static const int kMaxAllocatableGeneralRegisterCount = |
| 16 ALLOCATABLE_GENERAL_REGISTERS(REGISTER_COUNT)0; |
| 17 static const int kMaxAllocatableDoubleRegisterCount = |
| 18 ALLOCATABLE_DOUBLE_REGISTERS(REGISTER_COUNT)0; |
| 19 |
| 20 static const char* const kGeneralRegisterNames[] = { |
| 21 #define REGISTER_NAME(R) #R, |
| 22 GENERAL_REGISTERS(REGISTER_NAME) |
| 23 #undef REGISTER_NAME |
| 24 }; |
| 25 |
| 26 static const char* const kDoubleRegisterNames[] = { |
| 27 #define REGISTER_NAME(R) #R, |
| 28 DOUBLE_REGISTERS(REGISTER_NAME) |
| 29 #undef REGISTER_NAME |
| 30 }; |
| 31 |
| 32 STATIC_ASSERT(RegisterConfiguration::kMaxGeneralRegisters >= |
| 33 Register::kNumRegisters); |
| 34 STATIC_ASSERT(RegisterConfiguration::kMaxDoubleRegisters >= |
| 35 DoubleRegister::kMaxNumRegisters); |
| 36 |
| 37 class ArchDefaultRegisterConfiguration : public RegisterConfiguration { |
| 38 public: |
| 39 ArchDefaultRegisterConfiguration() |
| 40 : RegisterConfiguration( |
| 41 Register::kNumRegisters, DoubleRegister::kMaxNumRegisters, |
| 42 #if V8_TARGET_ARCH_IA32 |
| 43 kMaxAllocatableGeneralRegisterCount, |
| 44 kMaxAllocatableDoubleRegisterCount, |
| 45 kMaxAllocatableDoubleRegisterCount, |
| 46 #elif V8_TARGET_ARCH_X87 |
| 47 kMaxAllocatableGeneralRegisterCount, 1, 1, |
| 48 #elif V8_TARGET_ARCH_X64 |
| 49 kMaxAllocatableGeneralRegisterCount, |
| 50 kMaxAllocatableDoubleRegisterCount, |
| 51 kMaxAllocatableDoubleRegisterCount, |
| 52 #elif V8_TARGET_ARCH_ARM |
| 53 FLAG_enable_embedded_constant_pool |
| 54 ? (kMaxAllocatableGeneralRegisterCount - 1) |
| 55 : kMaxAllocatableGeneralRegisterCount, |
| 56 CpuFeatures::IsSupported(VFP32DREGS) |
| 57 ? kMaxAllocatableDoubleRegisterCount |
| 58 : (ALLOCATABLE_NO_VFP32_DOUBLE_REGISTERS(REGISTER_COUNT)0), |
| 59 ALLOCATABLE_NO_VFP32_DOUBLE_REGISTERS(REGISTER_COUNT)0, |
| 60 #elif V8_TARGET_ARCH_ARM64 |
| 61 kMaxAllocatableGeneralRegisterCount, |
| 62 kMaxAllocatableDoubleRegisterCount, |
| 63 kMaxAllocatableDoubleRegisterCount, |
| 64 #elif V8_TARGET_ARCH_MIPS |
| 65 kMaxAllocatableGeneralRegisterCount, |
| 66 kMaxAllocatableDoubleRegisterCount, |
| 67 kMaxAllocatableDoubleRegisterCount, |
| 68 #elif V8_TARGET_ARCH_MIPS64 |
| 69 kMaxAllocatableGeneralRegisterCount, |
| 70 kMaxAllocatableDoubleRegisterCount, |
| 71 kMaxAllocatableDoubleRegisterCount, |
| 72 #else |
| 73 GetAllocatableGeneralRegisterCount(), |
| 74 GetAllocatableDoubleRegisterCount(), |
| 75 GetAllocatableAliasedDoubleRegisterCount(), |
| 76 #endif |
| 77 GetAllocatableGeneralCodes(), GetAllocatableDoubleCodes(), |
| 78 kGeneralRegisterNames, kDoubleRegisterNames) { |
| 79 } |
| 80 |
| 81 const char* general_register_name_table_[Register::kNumRegisters]; |
| 82 const char* double_register_name_table_[DoubleRegister::kMaxNumRegisters]; |
| 83 |
| 84 private: |
| 85 friend struct Register; |
| 86 friend struct DoubleRegister; |
| 87 |
| 88 static const int* GetAllocatableGeneralCodes() { |
| 89 #define REGISTER_CODE(R) Register::kCode_##R, |
| 90 static const int general_codes[] = { |
| 91 ALLOCATABLE_GENERAL_REGISTERS(REGISTER_CODE)}; |
| 92 #undef REGISTER_CODE |
| 93 return general_codes; |
| 94 } |
| 95 |
| 96 static const int* GetAllocatableDoubleCodes() { |
| 97 #define REGISTER_CODE(R) DoubleRegister::kCode_##R, |
| 98 static const int double_codes[] = { |
| 99 ALLOCATABLE_DOUBLE_REGISTERS(REGISTER_CODE)}; |
| 100 #undef REGISTER_CODE |
| 101 return double_codes; |
| 102 } |
| 103 }; |
| 104 |
| 105 |
| 106 static base::LazyInstance<ArchDefaultRegisterConfiguration>::type |
| 107 kDefaultRegisterConfiguration = LAZY_INSTANCE_INITIALIZER; |
| 108 |
| 109 } // namespace |
| 110 |
| 111 |
| 112 const RegisterConfiguration* RegisterConfiguration::ArchDefault() { |
| 113 return &kDefaultRegisterConfiguration.Get(); |
| 114 } |
| 115 |
| 116 RegisterConfiguration::RegisterConfiguration( |
| 117 int num_general_registers, int num_double_registers, |
| 118 int num_allocatable_general_registers, int num_allocatable_double_registers, |
| 119 int num_allocatable_aliased_double_registers, |
| 120 const int* allocatable_general_codes, const int* allocatable_double_codes, |
| 121 const char* const* general_register_names, |
| 122 const char* const* double_register_names) |
| 123 : num_general_registers_(num_general_registers), |
| 124 num_double_registers_(num_double_registers), |
| 125 num_allocatable_general_registers_(num_allocatable_general_registers), |
| 126 num_allocatable_double_registers_(num_allocatable_double_registers), |
| 127 num_allocatable_aliased_double_registers_( |
| 128 num_allocatable_aliased_double_registers), |
| 129 allocatable_general_codes_mask_(0), |
| 130 allocatable_double_codes_mask_(0), |
| 131 allocatable_general_codes_(allocatable_general_codes), |
| 132 allocatable_double_codes_(allocatable_double_codes), |
| 133 general_register_names_(general_register_names), |
| 134 double_register_names_(double_register_names) { |
| 135 for (int i = 0; i < num_allocatable_general_registers_; ++i) { |
| 136 allocatable_general_codes_mask_ |= (1 << allocatable_general_codes_[i]); |
| 137 } |
| 138 for (int i = 0; i < num_allocatable_double_registers_; ++i) { |
| 139 allocatable_double_codes_mask_ |= (1 << allocatable_double_codes_[i]); |
| 140 } |
| 141 } |
| 142 |
| 143 #undef REGISTER_COUNT |
| 144 |
| 145 } // namespace internal |
| 146 } // namespace v8 |
| OLD | NEW |