17#define REGISTER_COUNT(R) 1 +
18static const int kMaxAllocatableGeneralRegisterCount =
20static const int kMaxAllocatableDoubleRegisterCount =
22#if V8_TARGET_ARCH_RISCV32 || V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_PPC64
23static const int kMaxAllocatableSIMD128RegisterCount =
27static const int kAllocatableGeneralCodes[] = {
28#define REGISTER_CODE(R) kRegCode_##R,
32#define REGISTER_CODE(R) kDoubleCode_##R,
33static const int kAllocatableDoubleCodes[] = {
36static const int kAllocatableNoVFP32DoubleCodes[] = {
41#if V8_TARGET_ARCH_RISCV32 || V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_PPC64
42static const int kAllocatableSIMD128Codes[] = {
43#if V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_RISCV32
44#define REGISTER_CODE(R) kVRCode_##R,
46#define REGISTER_CODE(R) kSimd128Code_##R,
66static int get_num_simd128_registers() {
68#if V8_TARGET_ARCH_RISCV32 || V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_PPC64
76static int get_num_simd256_registers() {
return 0; }
80static int get_num_allocatable_double_registers() {
82#if V8_TARGET_ARCH_IA32
83 kMaxAllocatableDoubleRegisterCount;
84#elif V8_TARGET_ARCH_X64
85 kMaxAllocatableDoubleRegisterCount;
86#elif V8_TARGET_ARCH_ARM
88 ? kMaxAllocatableDoubleRegisterCount
90#elif V8_TARGET_ARCH_ARM64
91 kMaxAllocatableDoubleRegisterCount;
92#elif V8_TARGET_ARCH_MIPS
93 kMaxAllocatableDoubleRegisterCount;
94#elif V8_TARGET_ARCH_MIPS64
95 kMaxAllocatableDoubleRegisterCount;
96#elif V8_TARGET_ARCH_LOONG64
97 kMaxAllocatableDoubleRegisterCount;
98#elif V8_TARGET_ARCH_PPC64
99 kMaxAllocatableDoubleRegisterCount;
100#elif V8_TARGET_ARCH_S390X
101 kMaxAllocatableDoubleRegisterCount;
102#elif V8_TARGET_ARCH_RISCV64
103 kMaxAllocatableDoubleRegisterCount;
104#elif V8_TARGET_ARCH_RISCV32
105 kMaxAllocatableDoubleRegisterCount;
107#error Unsupported target architecture.
113static int get_num_allocatable_simd128_registers() {
115#if V8_TARGET_ARCH_RISCV32 || V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_PPC64
116 kMaxAllocatableSIMD128RegisterCount;
122static int get_num_allocatable_simd256_registers() {
return 0; }
126static const int* get_allocatable_double_codes() {
128#if V8_TARGET_ARCH_ARM
130 : kAllocatableNoVFP32DoubleCodes;
132 kAllocatableDoubleCodes;
136static const int* get_allocatable_simd128_codes() {
138#if V8_TARGET_ARCH_RISCV32 || V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_PPC64
139 kAllocatableSIMD128Codes;
141 kAllocatableDoubleCodes;
145class ArchDefaultRegisterConfiguration :
public RegisterConfiguration {
147 ArchDefaultRegisterConfiguration()
148 : RegisterConfiguration(
150 get_num_simd128_registers(), get_num_simd256_registers(),
151 kMaxAllocatableGeneralRegisterCount,
152 get_num_allocatable_double_registers(),
153 get_num_allocatable_simd128_registers(),
154 get_num_allocatable_simd256_registers(), kAllocatableGeneralCodes,
155 get_allocatable_double_codes(), get_allocatable_simd128_codes()) {}
159 GetDefaultRegisterConfiguration)
164class RestrictedRegisterConfiguration :
public RegisterConfiguration {
166 RestrictedRegisterConfiguration(
167 int num_allocatable_general_registers,
168 std::unique_ptr<
int[]> allocatable_general_register_codes,
169 std::unique_ptr<
char const*[]> allocatable_general_register_names)
170 : RegisterConfiguration(
172 get_num_simd128_registers(), get_num_simd256_registers(),
173 num_allocatable_general_registers,
174 get_num_allocatable_double_registers(),
175 get_num_allocatable_simd128_registers(),
176 get_num_allocatable_simd256_registers(),
177 allocatable_general_register_codes.get(),
178 get_allocatable_double_codes(), get_allocatable_simd128_codes()),
179 allocatable_general_register_codes_(
180 std::move(allocatable_general_register_codes)),
181 allocatable_general_register_names_(
182 std::move(allocatable_general_register_names)) {
183 for (
int i = 0;
i < num_allocatable_general_registers; ++
i) {
185 IsAllocatableGeneralRegister(allocatable_general_register_codes_[
i]));
189 bool IsAllocatableGeneralRegister(
int code) {
190 for (
int i = 0;
i < kMaxAllocatableGeneralRegisterCount; ++
i) {
191 if (code == kAllocatableGeneralCodes[
i]) {
199 std::unique_ptr<int[]> allocatable_general_register_codes_;
200 std::unique_ptr<char const*[]> allocatable_general_register_names_;
206 return GetDefaultRegisterConfiguration();
212 std::unique_ptr<int[]> codes{
new int[num]};
213 std::unique_ptr<char const* []> names {
new char const*[num] };
215 for (
int i = 0;
i <
Default()->num_allocatable_general_registers(); ++
i) {
219 codes[counter] =
reg.code();
225 return new RestrictedRegisterConfiguration(num, std::move(codes),
230 AliasingKind fp_aliasing_kind,
int num_general_registers,
231 int num_double_registers,
int num_simd128_registers,
232 int num_simd256_registers,
int num_allocatable_general_registers,
233 int num_allocatable_double_registers,
int num_allocatable_simd128_registers,
234 int num_allocatable_simd256_registers,
const int* allocatable_general_codes,
235 const int* allocatable_double_codes,
236 const int* independent_allocatable_simd128_codes)
237 : num_general_registers_(num_general_registers),
238 num_float_registers_(0),
239 num_double_registers_(num_double_registers),
240 num_simd128_registers_(num_simd128_registers),
241 num_simd256_registers_(num_simd256_registers),
242 num_allocatable_general_registers_(num_allocatable_general_registers),
243 num_allocatable_float_registers_(0),
244 num_allocatable_double_registers_(num_allocatable_double_registers),
245 num_allocatable_simd128_registers_(num_allocatable_simd128_registers),
246 num_allocatable_simd256_registers_(num_allocatable_simd256_registers),
247 allocatable_general_codes_mask_(0),
248 allocatable_float_codes_mask_(0),
249 allocatable_double_codes_mask_(0),
250 allocatable_simd128_codes_mask_(0),
251 allocatable_simd256_codes_mask_(0),
252 allocatable_general_codes_(allocatable_general_codes),
253 allocatable_double_codes_(allocatable_double_codes),
254 fp_aliasing_kind_(fp_aliasing_kind) {
284 DCHECK_GE(next_simd128_code, last_simd128_code);
285 if (last_simd128_code == next_simd128_code) {
290 last_simd128_code = next_simd128_code;
299#if V8_TARGET_ARCH_X64
305#if V8_TARGET_ARCH_X64
312 DCHECK_NE(independent_allocatable_simd128_codes,
nullptr);
338 int* alias_base_index)
const {
341 if (rep == other_rep) {
342 *alias_base_index =
index;
345 int rep_int =
static_cast<int>(rep);
346 int other_rep_int =
static_cast<int>(other_rep);
347 if (rep_int > other_rep_int) {
348 int shift = rep_int - other_rep_int;
349 int base_index = index << shift;
354 *alias_base_index = base_index;
357 int shift = other_rep_int - rep_int;
358 *alias_base_index = index >> shift;
364 int other_index)
const {
367 if (rep == other_rep) {
368 return index == other_index;
370 int rep_int =
static_cast<int>(rep);
371 int other_rep_int =
static_cast<int>(other_rep);
372 if (rep_int > other_rep_int) {
373 int shift = rep_int - other_rep_int;
374 return index == other_index >> shift;
376 int shift = other_rep_int - rep_int;
377 return index >> shift == other_index;
static bool IsSupported(CpuFeature f)
static constexpr int8_t kNumRegisters
static const RegisterConfiguration * Default()
AliasingKind fp_aliasing_kind_
static const RegisterConfiguration * RestrictGeneralRegisters(RegList registers)
int num_allocatable_simd256_registers_
static constexpr int kMaxGeneralRegisters
int32_t allocatable_double_codes_mask_
int num_allocatable_simd128_registers_
static constexpr int kMaxFPRegisters
const int * allocatable_general_codes_
const int num_double_registers_
int allocatable_simd256_codes_[kMaxFPRegisters]
int num_allocatable_general_registers_
int num_simd128_registers_
const int num_general_registers_
const int * allocatable_double_codes_
int num_allocatable_double_registers_
int32_t allocatable_simd128_codes_mask_
int num_simd256_registers_
RegisterConfiguration(AliasingKind fp_aliasing_kind, int num_general_registers, int num_double_registers, int num_simd128_registers, int num_simd256_registers, int num_allocatable_general_registers, int num_allocatable_double_registers, int num_allocatable_simd128_registers, int num_allocatable_simd256_registers, const int *allocatable_general_codes, const int *allocatable_double_codes, const int *independent_allocatable_simd128_codes=nullptr)
int num_allocatable_float_registers_
int GetAliases(MachineRepresentation rep, int index, MachineRepresentation other_rep, int *alias_base_index) const
int32_t allocatable_simd256_codes_mask_
bool AreAliases(MachineRepresentation rep, int index, MachineRepresentation other_rep, int other_index) const
int num_allocatable_simd128_registers() const
int GetAllocatableGeneralCode(int index) const
int allocatable_simd128_codes_[kMaxFPRegisters]
int allocatable_float_codes_[kMaxFPRegisters]
int32_t allocatable_general_codes_mask_
int32_t allocatable_float_codes_mask_
static constexpr Register from_code(int code)
#define DEFINE_LAZY_LEAKY_OBJECT_GETTER(T, FunctionName,...)
RegListBase< RegisterT > registers
constexpr AliasingKind kFPAliasing
DwVfpRegister DoubleRegister
constexpr bool IsFloatingPoint(MachineRepresentation rep)
constexpr int kNumRegisters
#define ALLOCATABLE_DOUBLE_REGISTERS(V)
#define ALLOCATABLE_GENERAL_REGISTERS(V)
#define ALLOCATABLE_NO_VFP32_DOUBLE_REGISTERS(V)
#define REGISTER_COUNT(R)
#define ALLOCATABLE_SIMD128_REGISTERS(V)
#define DCHECK_LE(v1, v2)
#define DCHECK_NE(v1, v2)
#define DCHECK_GE(v1, v2)
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)