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 #else |
| 65 GetAllocatableGeneralRegisterCount(), |
| 66 GetAllocatableDoubleRegisterCount(), |
| 67 GetAllocatableAliasedDoubleRegisterCount(), |
| 68 #endif |
| 69 GetAllocatableGeneralCodes(), GetAllocatableDoubleCodes(), |
| 70 kGeneralRegisterNames, kDoubleRegisterNames) { |
| 71 } |
| 72 |
| 73 const char* general_register_name_table_[Register::kNumRegisters]; |
| 74 const char* double_register_name_table_[DoubleRegister::kMaxNumRegisters]; |
| 75 |
| 76 private: |
| 77 friend struct Register; |
| 78 friend struct DoubleRegister; |
| 79 |
| 80 static const int* GetAllocatableGeneralCodes() { |
| 81 #define REGISTER_CODE(R) Register::kCode_##R, |
| 82 static const int general_codes[] = { |
| 83 ALLOCATABLE_GENERAL_REGISTERS(REGISTER_CODE)}; |
| 84 #undef REGISTER_CODE |
| 85 return general_codes; |
| 86 } |
| 87 |
| 88 static const int* GetAllocatableDoubleCodes() { |
| 89 #define REGISTER_CODE(R) DoubleRegister::kCode_##R, |
| 90 static const int double_codes[] = { |
| 91 ALLOCATABLE_DOUBLE_REGISTERS(REGISTER_CODE)}; |
| 92 #undef REGISTER_CODE |
| 93 return double_codes; |
| 94 } |
| 95 }; |
| 96 |
| 97 |
| 98 static base::LazyInstance<ArchDefaultRegisterConfiguration>::type |
| 99 kDefaultRegisterConfiguration = LAZY_INSTANCE_INITIALIZER; |
| 100 |
| 101 } // namespace |
| 102 |
| 103 |
| 104 const RegisterConfiguration* RegisterConfiguration::ArchDefault() { |
| 105 return &kDefaultRegisterConfiguration.Get(); |
| 106 } |
| 107 |
| 108 RegisterConfiguration::RegisterConfiguration( |
| 109 int num_general_registers, int num_double_registers, |
| 110 int num_allocatable_general_registers, int num_allocatable_double_registers, |
| 111 int num_allocatable_aliased_double_registers, |
| 112 const int* allocatable_general_codes, const int* allocatable_double_codes, |
| 113 const char* const* general_register_names, |
| 114 const char* const* double_register_names) |
| 115 : num_general_registers_(num_general_registers), |
| 116 num_double_registers_(num_double_registers), |
| 117 num_allocatable_general_registers_(num_allocatable_general_registers), |
| 118 num_allocatable_double_registers_(num_allocatable_double_registers), |
| 119 num_allocatable_aliased_double_registers_( |
| 120 num_allocatable_aliased_double_registers), |
| 121 allocatable_general_codes_mask_(0), |
| 122 allocatable_double_codes_mask_(0), |
| 123 allocatable_general_codes_(allocatable_general_codes), |
| 124 allocatable_double_codes_(allocatable_double_codes), |
| 125 general_register_names_(general_register_names), |
| 126 double_register_names_(double_register_names) { |
| 127 for (int i = 0; i < num_allocatable_general_registers_; ++i) { |
| 128 allocatable_general_codes_mask_ |= (1 << allocatable_general_codes_[i]); |
| 129 } |
| 130 for (int i = 0; i < num_allocatable_double_registers_; ++i) { |
| 131 allocatable_double_codes_mask_ |= (1 << allocatable_double_codes_[i]); |
| 132 } |
| 133 } |
| 134 |
| 135 #undef REGISTER_COUNT |
| 136 |
| 137 } // namespace internal |
| 138 } // namespace v8 |
OLD | NEW |