| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 #define ALLOCATABLE_GENERAL_REGISTERS(V) \ | 56 #define ALLOCATABLE_GENERAL_REGISTERS(V) \ |
| 57 V(v0) V(v1) V(a0) V(a1) V(a2) V(a3) \ | 57 V(v0) V(v1) V(a0) V(a1) V(a2) V(a3) \ |
| 58 V(a4) V(a5) V(a6) V(a7) V(t0) V(t1) V(t2) V(s7) | 58 V(a4) V(a5) V(a6) V(a7) V(t0) V(t1) V(t2) V(s7) |
| 59 | 59 |
| 60 #define DOUBLE_REGISTERS(V) \ | 60 #define DOUBLE_REGISTERS(V) \ |
| 61 V(f0) V(f1) V(f2) V(f3) V(f4) V(f5) V(f6) V(f7) \ | 61 V(f0) V(f1) V(f2) V(f3) V(f4) V(f5) V(f6) V(f7) \ |
| 62 V(f8) V(f9) V(f10) V(f11) V(f12) V(f13) V(f14) V(f15) \ | 62 V(f8) V(f9) V(f10) V(f11) V(f12) V(f13) V(f14) V(f15) \ |
| 63 V(f16) V(f17) V(f18) V(f19) V(f20) V(f21) V(f22) V(f23) \ | 63 V(f16) V(f17) V(f18) V(f19) V(f20) V(f21) V(f22) V(f23) \ |
| 64 V(f24) V(f25) V(f26) V(f27) V(f28) V(f29) V(f30) V(f31) | 64 V(f24) V(f25) V(f26) V(f27) V(f28) V(f29) V(f30) V(f31) |
| 65 | 65 |
| 66 #define FLOAT_REGISTERS DOUBLE_REGISTERS |
| 67 |
| 66 #define ALLOCATABLE_DOUBLE_REGISTERS(V) \ | 68 #define ALLOCATABLE_DOUBLE_REGISTERS(V) \ |
| 67 V(f0) V(f2) V(f4) V(f6) V(f8) V(f10) V(f12) V(f14) \ | 69 V(f0) V(f2) V(f4) V(f6) V(f8) V(f10) V(f12) V(f14) \ |
| 68 V(f16) V(f18) V(f20) V(f22) V(f24) V(f26) | 70 V(f16) V(f18) V(f20) V(f22) V(f24) V(f26) |
| 69 // clang-format on | 71 // clang-format on |
| 70 | 72 |
| 71 // CPU Registers. | 73 // CPU Registers. |
| 72 // | 74 // |
| 73 // 1) We would prefer to use an enum, but enum values are assignment- | 75 // 1) We would prefer to use an enum, but enum values are assignment- |
| 74 // compatible with int, which has caused code-generation bugs. | 76 // compatible with int, which has caused code-generation bugs. |
| 75 // | 77 // |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 GENERAL_REGISTERS(DECLARE_REGISTER) | 149 GENERAL_REGISTERS(DECLARE_REGISTER) |
| 148 #undef DECLARE_REGISTER | 150 #undef DECLARE_REGISTER |
| 149 const Register no_reg = {Register::kCode_no_reg}; | 151 const Register no_reg = {Register::kCode_no_reg}; |
| 150 | 152 |
| 151 | 153 |
| 152 int ToNumber(Register reg); | 154 int ToNumber(Register reg); |
| 153 | 155 |
| 154 Register ToRegister(int num); | 156 Register ToRegister(int num); |
| 155 | 157 |
| 156 // Coprocessor register. | 158 // Coprocessor register. |
| 157 struct DoubleRegister { | 159 struct FPURegister { |
| 158 enum Code { | 160 enum Code { |
| 159 #define REGISTER_CODE(R) kCode_##R, | 161 #define REGISTER_CODE(R) kCode_##R, |
| 160 DOUBLE_REGISTERS(REGISTER_CODE) | 162 DOUBLE_REGISTERS(REGISTER_CODE) |
| 161 #undef REGISTER_CODE | 163 #undef REGISTER_CODE |
| 162 kAfterLast, | 164 kAfterLast, |
| 163 kCode_no_reg = -1 | 165 kCode_no_reg = -1 |
| 164 }; | 166 }; |
| 165 | 167 |
| 166 static const int kMaxNumRegisters = Code::kAfterLast; | 168 static const int kMaxNumRegisters = Code::kAfterLast; |
| 167 | 169 |
| 168 inline static int NumRegisters(); | 170 inline static int NumRegisters(); |
| 169 | 171 |
| 170 // TODO(plind): Warning, inconsistent numbering here. kNumFPURegisters refers | 172 // TODO(plind): Warning, inconsistent numbering here. kNumFPURegisters refers |
| 171 // to number of 32-bit FPU regs, but kNumAllocatableRegisters refers to | 173 // to number of 32-bit FPU regs, but kNumAllocatableRegisters refers to |
| 172 // number of Double regs (64-bit regs, or FPU-reg-pairs). | 174 // number of Double regs (64-bit regs, or FPU-reg-pairs). |
| 173 | 175 |
| 174 const char* ToString(); | 176 const char* ToString(); |
| 175 bool IsAllocatable() const; | 177 bool IsAllocatable() const; |
| 176 bool is_valid() const { return 0 <= reg_code && reg_code < kMaxNumRegisters; } | 178 bool is_valid() const { return 0 <= reg_code && reg_code < kMaxNumRegisters; } |
| 177 bool is(DoubleRegister reg) const { return reg_code == reg.reg_code; } | 179 bool is(FPURegister reg) const { return reg_code == reg.reg_code; } |
| 178 DoubleRegister low() const { | 180 FPURegister low() const { |
| 179 // TODO(plind): Create DCHECK for FR=0 mode. This usage suspect for FR=1. | 181 // TODO(plind): Create DCHECK for FR=0 mode. This usage suspect for FR=1. |
| 180 // Find low reg of a Double-reg pair, which is the reg itself. | 182 // Find low reg of a Double-reg pair, which is the reg itself. |
| 181 DCHECK(reg_code % 2 == 0); // Specified Double reg must be even. | 183 DCHECK(reg_code % 2 == 0); // Specified Double reg must be even. |
| 182 DoubleRegister reg; | 184 FPURegister reg; |
| 183 reg.reg_code = reg_code; | 185 reg.reg_code = reg_code; |
| 184 DCHECK(reg.is_valid()); | 186 DCHECK(reg.is_valid()); |
| 185 return reg; | 187 return reg; |
| 186 } | 188 } |
| 187 DoubleRegister high() const { | 189 FPURegister high() const { |
| 188 // TODO(plind): Create DCHECK for FR=0 mode. This usage illegal in FR=1. | 190 // TODO(plind): Create DCHECK for FR=0 mode. This usage illegal in FR=1. |
| 189 // Find high reg of a Doubel-reg pair, which is reg + 1. | 191 // Find high reg of a Doubel-reg pair, which is reg + 1. |
| 190 DCHECK(reg_code % 2 == 0); // Specified Double reg must be even. | 192 DCHECK(reg_code % 2 == 0); // Specified Double reg must be even. |
| 191 DoubleRegister reg; | 193 FPURegister reg; |
| 192 reg.reg_code = reg_code + 1; | 194 reg.reg_code = reg_code + 1; |
| 193 DCHECK(reg.is_valid()); | 195 DCHECK(reg.is_valid()); |
| 194 return reg; | 196 return reg; |
| 195 } | 197 } |
| 196 | 198 |
| 197 int code() const { | 199 int code() const { |
| 198 DCHECK(is_valid()); | 200 DCHECK(is_valid()); |
| 199 return reg_code; | 201 return reg_code; |
| 200 } | 202 } |
| 201 int bit() const { | 203 int bit() const { |
| 202 DCHECK(is_valid()); | 204 DCHECK(is_valid()); |
| 203 return 1 << reg_code; | 205 return 1 << reg_code; |
| 204 } | 206 } |
| 205 | 207 |
| 206 static DoubleRegister from_code(int code) { | 208 static FPURegister from_code(int code) { |
| 207 DoubleRegister r = {code}; | 209 FPURegister r = {code}; |
| 208 return r; | 210 return r; |
| 209 } | 211 } |
| 210 void setcode(int f) { | 212 void setcode(int f) { |
| 211 reg_code = f; | 213 reg_code = f; |
| 212 DCHECK(is_valid()); | 214 DCHECK(is_valid()); |
| 213 } | 215 } |
| 214 // Unfortunately we can't make this private in a struct. | 216 // Unfortunately we can't make this private in a struct. |
| 215 int reg_code; | 217 int reg_code; |
| 216 }; | 218 }; |
| 217 | 219 |
| 218 // A few double registers are reserved: one as a scratch register and one to | 220 // A few double registers are reserved: one as a scratch register and one to |
| 219 // hold 0.0. | 221 // hold 0.0. |
| 220 // f28: 0.0 | 222 // f28: 0.0 |
| 221 // f30: scratch register. | 223 // f30: scratch register. |
| 222 | 224 |
| 223 // V8 now supports the O32 ABI, and the FPU Registers are organized as 32 | 225 // V8 now supports the O32 ABI, and the FPU Registers are organized as 32 |
| 224 // 32-bit registers, f0 through f31. When used as 'double' they are used | 226 // 32-bit registers, f0 through f31. When used as 'double' they are used |
| 225 // in pairs, starting with the even numbered register. So a double operation | 227 // in pairs, starting with the even numbered register. So a double operation |
| 226 // on f0 really uses f0 and f1. | 228 // on f0 really uses f0 and f1. |
| 227 // (Modern mips hardware also supports 32 64-bit registers, via setting | 229 // (Modern mips hardware also supports 32 64-bit registers, via setting |
| 228 // (privileged) Status Register FR bit to 1. This is used by the N32 ABI, | 230 // (privileged) Status Register FR bit to 1. This is used by the N32 ABI, |
| 229 // but it is not in common use. Someday we will want to support this in v8.) | 231 // but it is not in common use. Someday we will want to support this in v8.) |
| 230 | 232 |
| 231 // For O32 ABI, Floats and Doubles refer to same set of 32 32-bit registers. | 233 // For O32 ABI, Floats and Doubles refer to same set of 32 32-bit registers. |
| 232 typedef DoubleRegister FPURegister; | 234 typedef FPURegister FloatRegister; |
| 233 typedef DoubleRegister FloatRegister; | 235 |
| 236 typedef FPURegister DoubleRegister; |
| 237 |
| 238 // TODO(mips64) Define SIMD registers. |
| 239 typedef FPURegister Simd128Register; |
| 234 | 240 |
| 235 const DoubleRegister no_freg = {-1}; | 241 const DoubleRegister no_freg = {-1}; |
| 236 | 242 |
| 237 const DoubleRegister f0 = {0}; // Return value in hard float mode. | 243 const DoubleRegister f0 = {0}; // Return value in hard float mode. |
| 238 const DoubleRegister f1 = {1}; | 244 const DoubleRegister f1 = {1}; |
| 239 const DoubleRegister f2 = {2}; | 245 const DoubleRegister f2 = {2}; |
| 240 const DoubleRegister f3 = {3}; | 246 const DoubleRegister f3 = {3}; |
| 241 const DoubleRegister f4 = {4}; | 247 const DoubleRegister f4 = {4}; |
| 242 const DoubleRegister f5 = {5}; | 248 const DoubleRegister f5 = {5}; |
| 243 const DoubleRegister f6 = {6}; | 249 const DoubleRegister f6 = {6}; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 reg_code = f; | 305 reg_code = f; |
| 300 DCHECK(is_valid()); | 306 DCHECK(is_valid()); |
| 301 } | 307 } |
| 302 // Unfortunately we can't make this private in a struct. | 308 // Unfortunately we can't make this private in a struct. |
| 303 int reg_code; | 309 int reg_code; |
| 304 }; | 310 }; |
| 305 | 311 |
| 306 const FPUControlRegister no_fpucreg = { kInvalidFPUControlRegister }; | 312 const FPUControlRegister no_fpucreg = { kInvalidFPUControlRegister }; |
| 307 const FPUControlRegister FCSR = { kFCSRRegister }; | 313 const FPUControlRegister FCSR = { kFCSRRegister }; |
| 308 | 314 |
| 309 // TODO(mips64) Define SIMD registers. | |
| 310 typedef DoubleRegister Simd128Register; | |
| 311 | |
| 312 // ----------------------------------------------------------------------------- | 315 // ----------------------------------------------------------------------------- |
| 313 // Machine instruction Operands. | 316 // Machine instruction Operands. |
| 314 const int kSmiShift = kSmiTagSize + kSmiShiftSize; | 317 const int kSmiShift = kSmiTagSize + kSmiShiftSize; |
| 315 const uint64_t kSmiShiftMask = (1UL << kSmiShift) - 1; | 318 const uint64_t kSmiShiftMask = (1UL << kSmiShift) - 1; |
| 316 // Class Operand represents a shifter operand in data processing instructions. | 319 // Class Operand represents a shifter operand in data processing instructions. |
| 317 class Operand BASE_EMBEDDED { | 320 class Operand BASE_EMBEDDED { |
| 318 public: | 321 public: |
| 319 // Immediate. | 322 // Immediate. |
| 320 INLINE(explicit Operand(int64_t immediate, | 323 INLINE(explicit Operand(int64_t immediate, |
| 321 RelocInfo::Mode rmode = RelocInfo::NONE64)); | 324 RelocInfo::Mode rmode = RelocInfo::NONE64)); |
| (...skipping 1194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1516 public: | 1519 public: |
| 1517 explicit EnsureSpace(Assembler* assembler) { | 1520 explicit EnsureSpace(Assembler* assembler) { |
| 1518 assembler->CheckBuffer(); | 1521 assembler->CheckBuffer(); |
| 1519 } | 1522 } |
| 1520 }; | 1523 }; |
| 1521 | 1524 |
| 1522 } // namespace internal | 1525 } // namespace internal |
| 1523 } // namespace v8 | 1526 } // namespace v8 |
| 1524 | 1527 |
| 1525 #endif // V8_ARM_ASSEMBLER_MIPS_H_ | 1528 #endif // V8_ARM_ASSEMBLER_MIPS_H_ |
| OLD | NEW |