OLD | NEW |
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
2 // All Rights Reserved. | 2 // All Rights Reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
10 // | 10 // |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 // | 88 // |
89 | 89 |
90 struct Register { | 90 struct Register { |
91 // The non-allocatable registers are: | 91 // The non-allocatable registers are: |
92 // rsp - stack pointer | 92 // rsp - stack pointer |
93 // rbp - frame pointer | 93 // rbp - frame pointer |
94 // rsi - context register | 94 // rsi - context register |
95 // r10 - fixed scratch register | 95 // r10 - fixed scratch register |
96 // r12 - smi constant register | 96 // r12 - smi constant register |
97 // r13 - root register | 97 // r13 - root register |
| 98 static const int kMaxNumAllocatableRegisters = 10; |
| 99 static int NumAllocatableRegisters() { |
| 100 return kMaxNumAllocatableRegisters; |
| 101 } |
98 static const int kNumRegisters = 16; | 102 static const int kNumRegisters = 16; |
99 static const int kNumAllocatableRegisters = 10; | |
100 | 103 |
101 static int ToAllocationIndex(Register reg) { | 104 static int ToAllocationIndex(Register reg) { |
102 return kAllocationIndexByRegisterCode[reg.code()]; | 105 return kAllocationIndexByRegisterCode[reg.code()]; |
103 } | 106 } |
104 | 107 |
105 static Register FromAllocationIndex(int index) { | 108 static Register FromAllocationIndex(int index) { |
106 ASSERT(index >= 0 && index < kNumAllocatableRegisters); | 109 ASSERT(index >= 0 && index < kMaxNumAllocatableRegisters); |
107 Register result = { kRegisterCodeByAllocationIndex[index] }; | 110 Register result = { kRegisterCodeByAllocationIndex[index] }; |
108 return result; | 111 return result; |
109 } | 112 } |
110 | 113 |
111 static const char* AllocationIndexToString(int index) { | 114 static const char* AllocationIndexToString(int index) { |
112 ASSERT(index >= 0 && index < kNumAllocatableRegisters); | 115 ASSERT(index >= 0 && index < kMaxNumAllocatableRegisters); |
113 const char* const names[] = { | 116 const char* const names[] = { |
114 "rax", | 117 "rax", |
115 "rbx", | 118 "rbx", |
116 "rdx", | 119 "rdx", |
117 "rcx", | 120 "rcx", |
118 "rdi", | 121 "rdi", |
119 "r8", | 122 "r8", |
120 "r9", | 123 "r9", |
121 "r11", | 124 "r11", |
122 "r14", | 125 "r14", |
(...skipping 27 matching lines...) Expand all Loading... |
150 // in modR/M, SIB, and opcode bytes. | 153 // in modR/M, SIB, and opcode bytes. |
151 int low_bits() const { | 154 int low_bits() const { |
152 return code_ & 0x7; | 155 return code_ & 0x7; |
153 } | 156 } |
154 | 157 |
155 // Unfortunately we can't make this private in a struct when initializing | 158 // Unfortunately we can't make this private in a struct when initializing |
156 // by assignment. | 159 // by assignment. |
157 int code_; | 160 int code_; |
158 | 161 |
159 private: | 162 private: |
160 static const int kRegisterCodeByAllocationIndex[kNumAllocatableRegisters]; | 163 static const int kRegisterCodeByAllocationIndex[kMaxNumAllocatableRegisters]; |
161 static const int kAllocationIndexByRegisterCode[kNumRegisters]; | 164 static const int kAllocationIndexByRegisterCode[kNumRegisters]; |
162 }; | 165 }; |
163 | 166 |
164 const int kRegister_rax_Code = 0; | 167 const int kRegister_rax_Code = 0; |
165 const int kRegister_rcx_Code = 1; | 168 const int kRegister_rcx_Code = 1; |
166 const int kRegister_rdx_Code = 2; | 169 const int kRegister_rdx_Code = 2; |
167 const int kRegister_rbx_Code = 3; | 170 const int kRegister_rbx_Code = 3; |
168 const int kRegister_rsp_Code = 4; | 171 const int kRegister_rsp_Code = 4; |
169 const int kRegister_rbp_Code = 5; | 172 const int kRegister_rbp_Code = 5; |
170 const int kRegister_rsi_Code = 6; | 173 const int kRegister_rsi_Code = 6; |
(...skipping 22 matching lines...) Expand all Loading... |
193 const Register r11 = { kRegister_r11_Code }; | 196 const Register r11 = { kRegister_r11_Code }; |
194 const Register r12 = { kRegister_r12_Code }; | 197 const Register r12 = { kRegister_r12_Code }; |
195 const Register r13 = { kRegister_r13_Code }; | 198 const Register r13 = { kRegister_r13_Code }; |
196 const Register r14 = { kRegister_r14_Code }; | 199 const Register r14 = { kRegister_r14_Code }; |
197 const Register r15 = { kRegister_r15_Code }; | 200 const Register r15 = { kRegister_r15_Code }; |
198 const Register no_reg = { kRegister_no_reg_Code }; | 201 const Register no_reg = { kRegister_no_reg_Code }; |
199 | 202 |
200 | 203 |
201 struct XMMRegister { | 204 struct XMMRegister { |
202 static const int kNumRegisters = 16; | 205 static const int kNumRegisters = 16; |
203 static const int kNumAllocatableRegisters = 15; | 206 static const int kMaxNumAllocatableRegisters = 15; |
| 207 static int NumAllocatableRegisters() { |
| 208 return kMaxNumAllocatableRegisters; |
| 209 } |
204 | 210 |
205 static int ToAllocationIndex(XMMRegister reg) { | 211 static int ToAllocationIndex(XMMRegister reg) { |
206 ASSERT(reg.code() != 0); | 212 ASSERT(reg.code() != 0); |
207 return reg.code() - 1; | 213 return reg.code() - 1; |
208 } | 214 } |
209 | 215 |
210 static XMMRegister FromAllocationIndex(int index) { | 216 static XMMRegister FromAllocationIndex(int index) { |
211 ASSERT(0 <= index && index < kNumAllocatableRegisters); | 217 ASSERT(0 <= index && index < kMaxNumAllocatableRegisters); |
212 XMMRegister result = { index + 1 }; | 218 XMMRegister result = { index + 1 }; |
213 return result; | 219 return result; |
214 } | 220 } |
215 | 221 |
216 static const char* AllocationIndexToString(int index) { | 222 static const char* AllocationIndexToString(int index) { |
217 ASSERT(index >= 0 && index < kNumAllocatableRegisters); | 223 ASSERT(index >= 0 && index < kMaxNumAllocatableRegisters); |
218 const char* const names[] = { | 224 const char* const names[] = { |
219 "xmm1", | 225 "xmm1", |
220 "xmm2", | 226 "xmm2", |
221 "xmm3", | 227 "xmm3", |
222 "xmm4", | 228 "xmm4", |
223 "xmm5", | 229 "xmm5", |
224 "xmm6", | 230 "xmm6", |
225 "xmm7", | 231 "xmm7", |
226 "xmm8", | 232 "xmm8", |
227 "xmm9", | 233 "xmm9", |
(...skipping 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1660 private: | 1666 private: |
1661 Assembler* assembler_; | 1667 Assembler* assembler_; |
1662 #ifdef DEBUG | 1668 #ifdef DEBUG |
1663 int space_before_; | 1669 int space_before_; |
1664 #endif | 1670 #endif |
1665 }; | 1671 }; |
1666 | 1672 |
1667 } } // namespace v8::internal | 1673 } } // namespace v8::internal |
1668 | 1674 |
1669 #endif // V8_X64_ASSEMBLER_X64_H_ | 1675 #endif // V8_X64_ASSEMBLER_X64_H_ |
OLD | NEW |