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 } | |
102 static const int kNumRegisters = 16; | 98 static const int kNumRegisters = 16; |
| 99 static const int kNumAllocatableRegisters = 10; |
103 | 100 |
104 static int ToAllocationIndex(Register reg) { | 101 static int ToAllocationIndex(Register reg) { |
105 return kAllocationIndexByRegisterCode[reg.code()]; | 102 return kAllocationIndexByRegisterCode[reg.code()]; |
106 } | 103 } |
107 | 104 |
108 static Register FromAllocationIndex(int index) { | 105 static Register FromAllocationIndex(int index) { |
109 ASSERT(index >= 0 && index < kMaxNumAllocatableRegisters); | 106 ASSERT(index >= 0 && index < kNumAllocatableRegisters); |
110 Register result = { kRegisterCodeByAllocationIndex[index] }; | 107 Register result = { kRegisterCodeByAllocationIndex[index] }; |
111 return result; | 108 return result; |
112 } | 109 } |
113 | 110 |
114 static const char* AllocationIndexToString(int index) { | 111 static const char* AllocationIndexToString(int index) { |
115 ASSERT(index >= 0 && index < kMaxNumAllocatableRegisters); | 112 ASSERT(index >= 0 && index < kNumAllocatableRegisters); |
116 const char* const names[] = { | 113 const char* const names[] = { |
117 "rax", | 114 "rax", |
118 "rbx", | 115 "rbx", |
119 "rdx", | 116 "rdx", |
120 "rcx", | 117 "rcx", |
121 "rdi", | 118 "rdi", |
122 "r8", | 119 "r8", |
123 "r9", | 120 "r9", |
124 "r11", | 121 "r11", |
125 "r14", | 122 "r14", |
(...skipping 27 matching lines...) Expand all Loading... |
153 // in modR/M, SIB, and opcode bytes. | 150 // in modR/M, SIB, and opcode bytes. |
154 int low_bits() const { | 151 int low_bits() const { |
155 return code_ & 0x7; | 152 return code_ & 0x7; |
156 } | 153 } |
157 | 154 |
158 // Unfortunately we can't make this private in a struct when initializing | 155 // Unfortunately we can't make this private in a struct when initializing |
159 // by assignment. | 156 // by assignment. |
160 int code_; | 157 int code_; |
161 | 158 |
162 private: | 159 private: |
163 static const int kRegisterCodeByAllocationIndex[kMaxNumAllocatableRegisters]; | 160 static const int kRegisterCodeByAllocationIndex[kNumAllocatableRegisters]; |
164 static const int kAllocationIndexByRegisterCode[kNumRegisters]; | 161 static const int kAllocationIndexByRegisterCode[kNumRegisters]; |
165 }; | 162 }; |
166 | 163 |
167 const int kRegister_rax_Code = 0; | 164 const int kRegister_rax_Code = 0; |
168 const int kRegister_rcx_Code = 1; | 165 const int kRegister_rcx_Code = 1; |
169 const int kRegister_rdx_Code = 2; | 166 const int kRegister_rdx_Code = 2; |
170 const int kRegister_rbx_Code = 3; | 167 const int kRegister_rbx_Code = 3; |
171 const int kRegister_rsp_Code = 4; | 168 const int kRegister_rsp_Code = 4; |
172 const int kRegister_rbp_Code = 5; | 169 const int kRegister_rbp_Code = 5; |
173 const int kRegister_rsi_Code = 6; | 170 const int kRegister_rsi_Code = 6; |
(...skipping 22 matching lines...) Expand all Loading... |
196 const Register r11 = { kRegister_r11_Code }; | 193 const Register r11 = { kRegister_r11_Code }; |
197 const Register r12 = { kRegister_r12_Code }; | 194 const Register r12 = { kRegister_r12_Code }; |
198 const Register r13 = { kRegister_r13_Code }; | 195 const Register r13 = { kRegister_r13_Code }; |
199 const Register r14 = { kRegister_r14_Code }; | 196 const Register r14 = { kRegister_r14_Code }; |
200 const Register r15 = { kRegister_r15_Code }; | 197 const Register r15 = { kRegister_r15_Code }; |
201 const Register no_reg = { kRegister_no_reg_Code }; | 198 const Register no_reg = { kRegister_no_reg_Code }; |
202 | 199 |
203 | 200 |
204 struct XMMRegister { | 201 struct XMMRegister { |
205 static const int kNumRegisters = 16; | 202 static const int kNumRegisters = 16; |
206 static const int kMaxNumAllocatableRegisters = 15; | 203 static const int kNumAllocatableRegisters = 15; |
207 static int NumAllocatableRegisters() { | |
208 return kMaxNumAllocatableRegisters; | |
209 } | |
210 | 204 |
211 static int ToAllocationIndex(XMMRegister reg) { | 205 static int ToAllocationIndex(XMMRegister reg) { |
212 ASSERT(reg.code() != 0); | 206 ASSERT(reg.code() != 0); |
213 return reg.code() - 1; | 207 return reg.code() - 1; |
214 } | 208 } |
215 | 209 |
216 static XMMRegister FromAllocationIndex(int index) { | 210 static XMMRegister FromAllocationIndex(int index) { |
217 ASSERT(0 <= index && index < kMaxNumAllocatableRegisters); | 211 ASSERT(0 <= index && index < kNumAllocatableRegisters); |
218 XMMRegister result = { index + 1 }; | 212 XMMRegister result = { index + 1 }; |
219 return result; | 213 return result; |
220 } | 214 } |
221 | 215 |
222 static const char* AllocationIndexToString(int index) { | 216 static const char* AllocationIndexToString(int index) { |
223 ASSERT(index >= 0 && index < kMaxNumAllocatableRegisters); | 217 ASSERT(index >= 0 && index < kNumAllocatableRegisters); |
224 const char* const names[] = { | 218 const char* const names[] = { |
225 "xmm1", | 219 "xmm1", |
226 "xmm2", | 220 "xmm2", |
227 "xmm3", | 221 "xmm3", |
228 "xmm4", | 222 "xmm4", |
229 "xmm5", | 223 "xmm5", |
230 "xmm6", | 224 "xmm6", |
231 "xmm7", | 225 "xmm7", |
232 "xmm8", | 226 "xmm8", |
233 "xmm9", | 227 "xmm9", |
(...skipping 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1666 private: | 1660 private: |
1667 Assembler* assembler_; | 1661 Assembler* assembler_; |
1668 #ifdef DEBUG | 1662 #ifdef DEBUG |
1669 int space_before_; | 1663 int space_before_; |
1670 #endif | 1664 #endif |
1671 }; | 1665 }; |
1672 | 1666 |
1673 } } // namespace v8::internal | 1667 } } // namespace v8::internal |
1674 | 1668 |
1675 #endif // V8_X64_ASSEMBLER_X64_H_ | 1669 #endif // V8_X64_ASSEMBLER_X64_H_ |
OLD | NEW |