| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 // r13 - root register | 96 // r13 - root register |
| 97 // r15 - smi constant register | 97 // r15 - smi constant register |
| 98 static const int kNumRegisters = 16; | 98 static const int kNumRegisters = 16; |
| 99 static const int kNumAllocatableRegisters = 10; | 99 static const int kNumAllocatableRegisters = 10; |
| 100 | 100 |
| 101 static int ToAllocationIndex(Register reg) { |
| 102 return allocationIndexByRegisterCode[reg.code()]; |
| 103 } |
| 104 |
| 105 static Register FromAllocationIndex(int index) { |
| 106 ASSERT(index >= 0 && index < kNumAllocatableRegisters); |
| 107 Register result = { registerCodeByAllocationIndex[index] }; |
| 108 return result; |
| 109 } |
| 110 |
| 101 static const char* AllocationIndexToString(int index) { | 111 static const char* AllocationIndexToString(int index) { |
| 102 ASSERT(index >= 0 && index < kNumAllocatableRegisters); | 112 ASSERT(index >= 0 && index < kNumAllocatableRegisters); |
| 103 const char* const names[] = { | 113 const char* const names[] = { |
| 104 "rax", | 114 "rax", |
| 105 "rcx", | 115 "rcx", |
| 106 "rdx", | 116 "rdx", |
| 107 "rbx", | 117 "rbx", |
| 108 "rdi", | 118 "rdi", |
| 109 "r8", | 119 "r8", |
| 110 "r9", | 120 "r9", |
| (...skipping 25 matching lines...) Expand all Loading... |
| 136 } | 146 } |
| 137 // Return the 3 low bits of the register code. Used when encoding registers | 147 // Return the 3 low bits of the register code. Used when encoding registers |
| 138 // in modR/M, SIB, and opcode bytes. | 148 // in modR/M, SIB, and opcode bytes. |
| 139 int low_bits() const { | 149 int low_bits() const { |
| 140 return code_ & 0x7; | 150 return code_ & 0x7; |
| 141 } | 151 } |
| 142 | 152 |
| 143 // Unfortunately we can't make this private in a struct when initializing | 153 // Unfortunately we can't make this private in a struct when initializing |
| 144 // by assignment. | 154 // by assignment. |
| 145 int code_; | 155 int code_; |
| 156 private: |
| 157 static const int registerCodeByAllocationIndex[kNumAllocatableRegisters]; |
| 158 static const int allocationIndexByRegisterCode[kNumRegisters]; |
| 146 }; | 159 }; |
| 147 | 160 |
| 148 const Register rax = { 0 }; | 161 const Register rax = { 0 }; |
| 149 const Register rcx = { 1 }; | 162 const Register rcx = { 1 }; |
| 150 const Register rdx = { 2 }; | 163 const Register rdx = { 2 }; |
| 151 const Register rbx = { 3 }; | 164 const Register rbx = { 3 }; |
| 152 const Register rsp = { 4 }; | 165 const Register rsp = { 4 }; |
| 153 const Register rbp = { 5 }; | 166 const Register rbp = { 5 }; |
| 154 const Register rsi = { 6 }; | 167 const Register rsi = { 6 }; |
| 155 const Register rdi = { 7 }; | 168 const Register rdi = { 7 }; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 166 | 179 |
| 167 struct XMMRegister { | 180 struct XMMRegister { |
| 168 static const int kNumRegisters = 16; | 181 static const int kNumRegisters = 16; |
| 169 static const int kNumAllocatableRegisters = 15; | 182 static const int kNumAllocatableRegisters = 15; |
| 170 | 183 |
| 171 static int ToAllocationIndex(XMMRegister reg) { | 184 static int ToAllocationIndex(XMMRegister reg) { |
| 172 ASSERT(reg.code() != 0); | 185 ASSERT(reg.code() != 0); |
| 173 return reg.code() - 1; | 186 return reg.code() - 1; |
| 174 } | 187 } |
| 175 | 188 |
| 189 static XMMRegister FromAllocationIndex(int index) { |
| 190 ASSERT(0 <= index && index < kNumAllocatableRegisters); |
| 191 XMMRegister result = { index + 1 }; |
| 192 return result; |
| 193 } |
| 194 |
| 176 static const char* AllocationIndexToString(int index) { | 195 static const char* AllocationIndexToString(int index) { |
| 177 ASSERT(index >= 0 && index < kNumAllocatableRegisters); | 196 ASSERT(index >= 0 && index < kNumAllocatableRegisters); |
| 178 const char* const names[] = { | 197 const char* const names[] = { |
| 179 "xmm1", | 198 "xmm1", |
| 180 "xmm2", | 199 "xmm2", |
| 181 "xmm3", | 200 "xmm3", |
| 182 "xmm4", | 201 "xmm4", |
| 183 "xmm5", | 202 "xmm5", |
| 184 "xmm6", | 203 "xmm6", |
| 185 "xmm7", | 204 "xmm7", |
| (...skipping 1312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1498 private: | 1517 private: |
| 1499 Assembler* assembler_; | 1518 Assembler* assembler_; |
| 1500 #ifdef DEBUG | 1519 #ifdef DEBUG |
| 1501 int space_before_; | 1520 int space_before_; |
| 1502 #endif | 1521 #endif |
| 1503 }; | 1522 }; |
| 1504 | 1523 |
| 1505 } } // namespace v8::internal | 1524 } } // namespace v8::internal |
| 1506 | 1525 |
| 1507 #endif // V8_X64_ASSEMBLER_X64_H_ | 1526 #endif // V8_X64_ASSEMBLER_X64_H_ |
| OLD | NEW |