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

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

Issue 2086653003: [Turbofan] Add the concept of aliasing to RegisterConfiguration. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase. Created 4 years, 6 months 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
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 #ifndef V8_COMPILER_REGISTER_CONFIGURATION_H_ 5 #ifndef V8_COMPILER_REGISTER_CONFIGURATION_H_
6 #define V8_COMPILER_REGISTER_CONFIGURATION_H_ 6 #define V8_COMPILER_REGISTER_CONFIGURATION_H_
7 7
8 #include "src/base/macros.h" 8 #include "src/base/macros.h"
9 #include "src/machine-type.h"
9 10
10 namespace v8 { 11 namespace v8 {
11 namespace internal { 12 namespace internal {
12 13
13 // An architecture independent representation of the sets of registers available 14 // An architecture independent representation of the sets of registers available
14 // for instruction creation. 15 // for instruction creation.
15 class RegisterConfiguration { 16 class RegisterConfiguration {
16 public: 17 public:
17 // Define the optimized compiler selector for register configuration 18 // Define the optimized compiler selector for register configuration
18 // selection. 19 // selection.
19 // 20 //
20 // TODO(X87): This distinction in RegisterConfigurations is temporary 21 // TODO(X87): This distinction in RegisterConfigurations is temporary
21 // until x87 TF supports all of the registers that Crankshaft does. 22 // until x87 TF supports all of the registers that Crankshaft does.
22 enum CompilerSelector { CRANKSHAFT, TURBOFAN }; 23 enum CompilerSelector { CRANKSHAFT, TURBOFAN };
23 24
25 enum AliasingKind {
26 // Registers alias a single register of every other size (e.g. Intel).
27 OVERLAP,
28 // Registers alias two registers of the next smaller size (e.g. ARM).
29 COMBINE
30 };
31
24 // Architecture independent maxes. 32 // Architecture independent maxes.
25 static const int kMaxGeneralRegisters = 32; 33 static const int kMaxGeneralRegisters = 32;
26 static const int kMaxFPRegisters = 32; 34 static const int kMaxFPRegisters = 32;
27 35
28 static const RegisterConfiguration* ArchDefault(CompilerSelector compiler); 36 static const RegisterConfiguration* ArchDefault(CompilerSelector compiler);
29 37
30 RegisterConfiguration(int num_general_registers, int num_double_registers, 38 RegisterConfiguration(int num_general_registers, int num_double_registers,
31 int num_allocatable_general_registers, 39 int num_allocatable_general_registers,
32 int num_allocatable_double_registers, 40 int num_allocatable_double_registers,
33 int num_allocatable_aliased_double_registers, 41 AliasingKind fp_aliasing_kind,
34 const int* allocatable_general_codes, 42 const int* allocatable_general_codes,
35 const int* allocatable_double_codes, 43 const int* allocatable_double_codes,
36 char const* const* general_names, 44 char const* const* general_names,
37 char const* const* float_names, 45 char const* const* float_names,
38 char const* const* double_names); 46 char const* const* double_names);
39 47
40 int num_general_registers() const { return num_general_registers_; } 48 int num_general_registers() const { return num_general_registers_; }
49 int num_float_registers() const { return num_float_registers_; }
41 int num_double_registers() const { return num_double_registers_; } 50 int num_double_registers() const { return num_double_registers_; }
42 int num_allocatable_general_registers() const { 51 int num_allocatable_general_registers() const {
43 return num_allocatable_general_registers_; 52 return num_allocatable_general_registers_;
44 } 53 }
45 int num_allocatable_double_registers() const { 54 int num_allocatable_double_registers() const {
46 return num_allocatable_double_registers_; 55 return num_allocatable_double_registers_;
47 } 56 }
48 // TODO(turbofan): This is a temporary work-around required because our 57 int num_allocatable_float_registers() const {
49 // register allocator does not yet support the aliasing of single/double 58 return num_allocatable_float_registers_;
50 // registers on ARM.
51 int num_allocatable_aliased_double_registers() const {
52 return num_allocatable_aliased_double_registers_;
53 } 59 }
60 AliasingKind fp_aliasing_kind() const { return fp_aliasing_kind_; }
54 int32_t allocatable_general_codes_mask() const { 61 int32_t allocatable_general_codes_mask() const {
55 return allocatable_general_codes_mask_; 62 return allocatable_general_codes_mask_;
56 } 63 }
57 int32_t allocatable_double_codes_mask() const { 64 int32_t allocatable_double_codes_mask() const {
58 return allocatable_double_codes_mask_; 65 return allocatable_double_codes_mask_;
59 } 66 }
60 int GetAllocatableGeneralCode(int index) const { 67 int GetAllocatableGeneralCode(int index) const {
61 return allocatable_general_codes_[index]; 68 return allocatable_general_codes_[index];
62 } 69 }
63 int GetAllocatableDoubleCode(int index) const { 70 int GetAllocatableDoubleCode(int index) const {
64 return allocatable_double_codes_[index]; 71 return allocatable_double_codes_[index];
65 } 72 }
73 int GetAllocatableFloatCode(int index) const {
74 return allocatable_float_codes_[index];
75 }
66 const char* GetGeneralRegisterName(int code) const { 76 const char* GetGeneralRegisterName(int code) const {
67 return general_register_names_[code]; 77 return general_register_names_[code];
68 } 78 }
69 const char* GetFloatRegisterName(int code) const { 79 const char* GetFloatRegisterName(int code) const {
70 return float_register_names_[code]; 80 return float_register_names_[code];
71 } 81 }
72 const char* GetDoubleRegisterName(int code) const { 82 const char* GetDoubleRegisterName(int code) const {
73 return double_register_names_[code]; 83 return double_register_names_[code];
74 } 84 }
75 const int* allocatable_general_codes() const { 85 const int* allocatable_general_codes() const {
76 return allocatable_general_codes_; 86 return allocatable_general_codes_;
77 } 87 }
78 const int* allocatable_double_codes() const { 88 const int* allocatable_double_codes() const {
79 return allocatable_double_codes_; 89 return allocatable_double_codes_;
80 } 90 }
91 const int* allocatable_float_codes() const {
92 return allocatable_float_codes_;
93 }
94
95 // Aliasing calculations for floating point registers, when fp_aliasing_kind()
96 // is COMBINE. Currently only implemented for kFloat32, or kFloat64 reps.
97 // Returns the number of aliases, and if > 0, alias_base_index is set to the
98 // index of the first alias.
99 int GetAliases(MachineRepresentation rep, int index,
100 MachineRepresentation other_rep, int* alias_base_index) const;
101 // Returns a value indicating whether two registers alias each other, when
102 // fp_aliasing_kind() is COMBINE. Currently only implemented for kFloat32, or
103 // kFloat64 reps.
104 bool AreAliases(MachineRepresentation rep, int index,
105 MachineRepresentation other_rep, int other_index) const;
81 106
82 private: 107 private:
83 const int num_general_registers_; 108 const int num_general_registers_;
109 int num_float_registers_;
84 const int num_double_registers_; 110 const int num_double_registers_;
85 int num_allocatable_general_registers_; 111 int num_allocatable_general_registers_;
86 int num_allocatable_double_registers_; 112 int num_allocatable_double_registers_;
87 int num_allocatable_aliased_double_registers_; 113 int num_allocatable_float_registers_;
114 AliasingKind fp_aliasing_kind_;
88 int32_t allocatable_general_codes_mask_; 115 int32_t allocatable_general_codes_mask_;
89 int32_t allocatable_double_codes_mask_; 116 int32_t allocatable_double_codes_mask_;
90 const int* allocatable_general_codes_; 117 const int* allocatable_general_codes_;
91 const int* allocatable_double_codes_; 118 const int* allocatable_double_codes_;
119 int allocatable_float_codes_[kMaxFPRegisters];
92 char const* const* general_register_names_; 120 char const* const* general_register_names_;
93 char const* const* float_register_names_; 121 char const* const* float_register_names_;
94 char const* const* double_register_names_; 122 char const* const* double_register_names_;
95 }; 123 };
96 124
97 } // namespace internal 125 } // namespace internal
98 } // namespace v8 126 } // namespace v8
99 127
100 #endif // V8_COMPILER_REGISTER_CONFIGURATION_H_ 128 #endif // V8_COMPILER_REGISTER_CONFIGURATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698