v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
register-configuration.h
Go to the documentation of this file.
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#ifndef V8_CODEGEN_REGISTER_CONFIGURATION_H_
6#define V8_CODEGEN_REGISTER_CONFIGURATION_H_
7
8#include "src/base/macros.h"
10#include "src/codegen/reglist.h"
11#include "src/common/globals.h"
12#include "src/utils/utils.h"
13
14namespace v8 {
15namespace internal {
16
18 public:
19 // Architecture independent maxes.
20 static constexpr int kMaxGeneralRegisters = 32;
21 static constexpr int kMaxFPRegisters = 32;
22 static constexpr int kMaxRegisters =
23 std::max(kMaxFPRegisters, kMaxGeneralRegisters);
24
25 // Default RegisterConfigurations for the target architecture.
26 static const RegisterConfiguration* Default();
27
28 // Register configuration with reserved masking register.
30
31 static const RegisterConfiguration* RestrictGeneralRegisters(
33
35 AliasingKind fp_aliasing_kind, int num_general_registers,
36 int num_double_registers, int num_simd128_registers,
37 int num_simd256_registers, int num_allocatable_general_registers,
38 int num_allocatable_double_registers,
39 int num_allocatable_simd128_registers,
40 int num_allocatable_simd256_registers,
41 const int* allocatable_general_codes, const int* allocatable_double_codes,
42 const int* independent_allocatable_simd128_codes = nullptr);
43
44 int num_general_registers() const { return num_general_registers_; }
45 int num_float_registers() const { return num_float_registers_; }
46 int num_double_registers() const { return num_double_registers_; }
47 int num_simd128_registers() const { return num_simd128_registers_; }
48 int num_simd256_registers() const { return num_simd256_registers_; }
50 return num_allocatable_general_registers_;
51 }
53 return num_allocatable_float_registers_;
54 }
55 // Caution: this value depends on the current cpu and may change between
56 // build and runtime. At the time of writing, the only architecture with a
57 // variable allocatable double register set is Arm.
59 return num_allocatable_double_registers_;
60 }
62 return num_allocatable_simd128_registers_;
63 }
65 return num_allocatable_simd256_registers_;
66 }
67
68 AliasingKind fp_aliasing_kind() const { return fp_aliasing_kind_; }
70 return allocatable_general_codes_mask_;
71 }
73 return allocatable_double_codes_mask_;
74 }
76 return allocatable_float_codes_mask_;
77 }
79 return allocatable_simd128_codes_mask_;
80 }
81 int GetAllocatableGeneralCode(int index) const {
82 DCHECK(index >= 0 && index < num_allocatable_general_registers());
83 return allocatable_general_codes_[index];
84 }
85 bool IsAllocatableGeneralCode(int index) const {
86 return ((1 << index) & allocatable_general_codes_mask_) != 0;
87 }
88 int GetAllocatableFloatCode(int index) const {
89 DCHECK(index >= 0 && index < num_allocatable_float_registers());
90 return allocatable_float_codes_[index];
91 }
92 bool IsAllocatableFloatCode(int index) const {
93 return ((1 << index) & allocatable_float_codes_mask_) != 0;
94 }
95 int GetAllocatableDoubleCode(int index) const {
96 DCHECK(index >= 0 && index < num_allocatable_double_registers());
97 return allocatable_double_codes_[index];
98 }
99 bool IsAllocatableDoubleCode(int index) const {
100 return ((1 << index) & allocatable_double_codes_mask_) != 0;
101 }
102 int GetAllocatableSimd128Code(int index) const {
103 DCHECK(index >= 0 && index < num_allocatable_simd128_registers());
104 return allocatable_simd128_codes_[index];
105 }
106 bool IsAllocatableSimd128Code(int index) const {
107 return ((1 << index) & allocatable_simd128_codes_mask_) != 0;
108 }
109 int GetAllocatableSimd256Code(int index) const {
110 DCHECK(index >= 0 && index < num_allocatable_simd256_registers());
111 return allocatable_simd256_codes_[index];
112 }
113 bool IsAllocatableSimd256Code(int index) const {
114 return ((1 << index) & allocatable_simd256_codes_mask_) != 0;
115 }
116
117 const int* allocatable_general_codes() const {
118 return allocatable_general_codes_;
119 }
120 const int* allocatable_float_codes() const {
121 return allocatable_float_codes_;
122 }
123 const int* allocatable_double_codes() const {
124 return allocatable_double_codes_;
125 }
126 const int* allocatable_simd128_codes() const {
127 return allocatable_simd128_codes_;
128 }
129 const int* allocatable_simd256_codes() const {
130 return allocatable_simd256_codes_;
131 }
132
133 // Aliasing calculations for floating point registers, when fp_aliasing_kind()
134 // is COMBINE. Currently only implemented for kFloat32, kFloat64, or kSimd128
135 // reps. Returns the number of aliases, and if > 0, alias_base_index is set to
136 // the index of the first alias.
137 int GetAliases(MachineRepresentation rep, int index,
138 MachineRepresentation other_rep, int* alias_base_index) const;
139 // Returns a value indicating whether two registers alias each other, when
140 // fp_aliasing_kind() is COMBINE. Currently implemented for kFloat32,
141 // kFloat64, or kSimd128 reps.
142 bool AreAliases(MachineRepresentation rep, int index,
143 MachineRepresentation other_rep, int other_index) const;
144
145 virtual ~RegisterConfiguration() = default;
146
147 private:
164 int allocatable_float_codes_[kMaxFPRegisters];
166 int allocatable_simd128_codes_[kMaxFPRegisters];
167 int allocatable_simd256_codes_[kMaxFPRegisters];
169};
170
171} // namespace internal
172} // namespace v8
173
174#endif // V8_CODEGEN_REGISTER_CONFIGURATION_H_
static const RegisterConfiguration * Poisoning()
virtual ~RegisterConfiguration()=default
OptionalOpIndex index
RegListBase< RegisterT > registers
#define DCHECK(condition)
Definition logging.h:482
#define V8_EXPORT_PRIVATE
Definition macros.h:460