OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_MIPS_CONSTANTS_H_ | 5 #ifndef V8_MIPS_CONSTANTS_H_ |
6 #define V8_MIPS_CONSTANTS_H_ | 6 #define V8_MIPS_CONSTANTS_H_ |
7 | 7 |
8 #include "src/base/logging.h" | 8 #include "src/base/logging.h" |
9 #include "src/base/macros.h" | 9 #include "src/base/macros.h" |
10 #include "src/globals.h" | 10 #include "src/globals.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 // Number of registers with HI, LO, and pc. | 108 // Number of registers with HI, LO, and pc. |
109 const int kNumSimuRegisters = 35; | 109 const int kNumSimuRegisters = 35; |
110 | 110 |
111 // In the simulator, the PC register is simulated as the 34th register. | 111 // In the simulator, the PC register is simulated as the 34th register. |
112 const int kPCRegister = 34; | 112 const int kPCRegister = 34; |
113 | 113 |
114 // Number coprocessor registers. | 114 // Number coprocessor registers. |
115 const int kNumFPURegisters = 32; | 115 const int kNumFPURegisters = 32; |
116 const int kInvalidFPURegister = -1; | 116 const int kInvalidFPURegister = -1; |
117 | 117 |
| 118 // Number of MSA registers |
| 119 const int kNumMSARegisters = 32; |
| 120 const int kInvalidMSARegister = -1; |
| 121 |
| 122 const int kInvalidMSAControlRegister = -1; |
| 123 const int kMSAIRRegister = 0; |
| 124 const int kMSACSRRegister = 1; |
| 125 |
118 // FPU (coprocessor 1) control registers. Currently only FCSR is implemented. | 126 // FPU (coprocessor 1) control registers. Currently only FCSR is implemented. |
119 const int kFCSRRegister = 31; | 127 const int kFCSRRegister = 31; |
120 const int kInvalidFPUControlRegister = -1; | 128 const int kInvalidFPUControlRegister = -1; |
121 const uint32_t kFPUInvalidResult = static_cast<uint32_t>(1 << 31) - 1; | 129 const uint32_t kFPUInvalidResult = static_cast<uint32_t>(1 << 31) - 1; |
122 const int32_t kFPUInvalidResultNegative = static_cast<int32_t>(1 << 31); | 130 const int32_t kFPUInvalidResultNegative = static_cast<int32_t>(1 << 31); |
123 const uint64_t kFPU64InvalidResult = | 131 const uint64_t kFPU64InvalidResult = |
124 static_cast<uint64_t>(static_cast<uint64_t>(1) << 63) - 1; | 132 static_cast<uint64_t>(static_cast<uint64_t>(1) << 63) - 1; |
125 const int64_t kFPU64InvalidResultNegative = | 133 const int64_t kFPU64InvalidResultNegative = |
126 static_cast<int64_t>(static_cast<uint64_t>(1) << 63); | 134 static_cast<int64_t>(static_cast<uint64_t>(1) << 63); |
127 | 135 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 struct RegisterAlias { | 201 struct RegisterAlias { |
194 int creg; | 202 int creg; |
195 const char* name; | 203 const char* name; |
196 }; | 204 }; |
197 | 205 |
198 private: | 206 private: |
199 static const char* names_[kNumFPURegisters]; | 207 static const char* names_[kNumFPURegisters]; |
200 static const RegisterAlias aliases_[]; | 208 static const RegisterAlias aliases_[]; |
201 }; | 209 }; |
202 | 210 |
| 211 // Helper functions for converting between register numbers and names. |
| 212 class MSARegisters { |
| 213 public: |
| 214 // Return the name of the register. |
| 215 static const char* Name(int reg); |
| 216 |
| 217 // Lookup the register number for the name provided. |
| 218 static int Number(const char* name); |
| 219 |
| 220 struct RegisterAlias { |
| 221 int creg; |
| 222 const char* name; |
| 223 }; |
| 224 |
| 225 private: |
| 226 static const char* names_[kNumMSARegisters]; |
| 227 static const RegisterAlias aliases_[]; |
| 228 }; |
203 | 229 |
204 // ----------------------------------------------------------------------------- | 230 // ----------------------------------------------------------------------------- |
205 // Instructions encoding constants. | 231 // Instructions encoding constants. |
206 | 232 |
207 // On MIPS all instructions are 32 bits. | 233 // On MIPS all instructions are 32 bits. |
208 typedef int32_t Instr; | 234 typedef int32_t Instr; |
209 | 235 |
210 // Special Software Interrupt codes when used in the presence of the MIPS | 236 // Special Software Interrupt codes when used in the presence of the MIPS |
211 // simulator. | 237 // simulator. |
212 enum SoftwareInterruptCodes { | 238 enum SoftwareInterruptCodes { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 const int kImm19Shift = 0; | 279 const int kImm19Shift = 0; |
254 const int kImm19Bits = 19; | 280 const int kImm19Bits = 19; |
255 const int kImm21Shift = 0; | 281 const int kImm21Shift = 0; |
256 const int kImm21Bits = 21; | 282 const int kImm21Bits = 21; |
257 const int kImm26Shift = 0; | 283 const int kImm26Shift = 0; |
258 const int kImm26Bits = 26; | 284 const int kImm26Bits = 26; |
259 const int kImm28Shift = 0; | 285 const int kImm28Shift = 0; |
260 const int kImm28Bits = 28; | 286 const int kImm28Bits = 28; |
261 const int kImm32Shift = 0; | 287 const int kImm32Shift = 0; |
262 const int kImm32Bits = 32; | 288 const int kImm32Bits = 32; |
| 289 const int kMsaImm8Shift = 16; |
| 290 const int kMsaImm8Bits = 8; |
| 291 const int kMsaImm5Shift = 16; |
| 292 const int kMsaImm5Bits = 5; |
| 293 const int kMsaImm10Shift = 11; |
| 294 const int kMsaImm10Bits = 10; |
| 295 const int kMsaImmMI10Shift = 16; |
| 296 const int kMsaImmMI10Bits = 10; |
263 | 297 |
264 // In branches and jumps immediate fields point to words, not bytes, | 298 // In branches and jumps immediate fields point to words, not bytes, |
265 // and are therefore shifted by 2. | 299 // and are therefore shifted by 2. |
266 const int kImmFieldShift = 2; | 300 const int kImmFieldShift = 2; |
267 | 301 |
268 const int kFrBits = 5; | 302 const int kFrBits = 5; |
269 const int kFrShift = 21; | 303 const int kFrShift = 21; |
270 const int kFsShift = 11; | 304 const int kFsShift = 11; |
271 const int kFsBits = 5; | 305 const int kFsBits = 5; |
272 const int kFtShift = 16; | 306 const int kFtShift = 16; |
273 const int kFtBits = 5; | 307 const int kFtBits = 5; |
274 const int kFdShift = 6; | 308 const int kFdShift = 6; |
275 const int kFdBits = 5; | 309 const int kFdBits = 5; |
276 const int kFCccShift = 8; | 310 const int kFCccShift = 8; |
277 const int kFCccBits = 3; | 311 const int kFCccBits = 3; |
278 const int kFBccShift = 18; | 312 const int kFBccShift = 18; |
279 const int kFBccBits = 3; | 313 const int kFBccBits = 3; |
280 const int kFBtrueShift = 16; | 314 const int kFBtrueShift = 16; |
281 const int kFBtrueBits = 1; | 315 const int kFBtrueBits = 1; |
| 316 const int kWtBits = 5; |
| 317 const int kWtShift = 16; |
| 318 const int kWsBits = 5; |
| 319 const int kWsShift = 11; |
| 320 const int kWdBits = 5; |
| 321 const int kWdShift = 6; |
282 | 322 |
283 // ----- Miscellaneous useful masks. | 323 // ----- Miscellaneous useful masks. |
284 // Instruction bit masks. | 324 // Instruction bit masks. |
285 const int kOpcodeMask = ((1 << kOpcodeBits) - 1) << kOpcodeShift; | 325 const int kOpcodeMask = ((1 << kOpcodeBits) - 1) << kOpcodeShift; |
286 const int kImm16Mask = ((1 << kImm16Bits) - 1) << kImm16Shift; | 326 const int kImm16Mask = ((1 << kImm16Bits) - 1) << kImm16Shift; |
287 const int kImm18Mask = ((1 << kImm18Bits) - 1) << kImm18Shift; | 327 const int kImm18Mask = ((1 << kImm18Bits) - 1) << kImm18Shift; |
288 const int kImm19Mask = ((1 << kImm19Bits) - 1) << kImm19Shift; | 328 const int kImm19Mask = ((1 << kImm19Bits) - 1) << kImm19Shift; |
289 const int kImm21Mask = ((1 << kImm21Bits) - 1) << kImm21Shift; | 329 const int kImm21Mask = ((1 << kImm21Bits) - 1) << kImm21Shift; |
290 const int kImm26Mask = ((1 << kImm26Bits) - 1) << kImm26Shift; | 330 const int kImm26Mask = ((1 << kImm26Bits) - 1) << kImm26Shift; |
291 const int kImm28Mask = ((1 << kImm28Bits) - 1) << kImm28Shift; | 331 const int kImm28Mask = ((1 << kImm28Bits) - 1) << kImm28Shift; |
| 332 const int kImm5Mask = ((1 << 5) - 1); |
| 333 const int kImm8Mask = ((1 << 8) - 1); |
| 334 const int kImm10Mask = ((1 << 10) - 1); |
| 335 const int kMsaI5I10Mask = ((7U << 23) | ((1 << 6) - 1)); |
292 const int kRsFieldMask = ((1 << kRsBits) - 1) << kRsShift; | 336 const int kRsFieldMask = ((1 << kRsBits) - 1) << kRsShift; |
293 const int kRtFieldMask = ((1 << kRtBits) - 1) << kRtShift; | 337 const int kRtFieldMask = ((1 << kRtBits) - 1) << kRtShift; |
294 const int kRdFieldMask = ((1 << kRdBits) - 1) << kRdShift; | 338 const int kRdFieldMask = ((1 << kRdBits) - 1) << kRdShift; |
295 const int kSaFieldMask = ((1 << kSaBits) - 1) << kSaShift; | 339 const int kSaFieldMask = ((1 << kSaBits) - 1) << kSaShift; |
296 const int kFunctionFieldMask = ((1 << kFunctionBits) - 1) << kFunctionShift; | 340 const int kFunctionFieldMask = ((1 << kFunctionBits) - 1) << kFunctionShift; |
297 // Misc masks. | 341 // Misc masks. |
298 const int kHiMask = 0xffff << 16; | 342 const int kHiMask = 0xffff << 16; |
299 const int kLoMask = 0xffff; | 343 const int kLoMask = 0xffff; |
300 const int kSignMask = 0x80000000; | 344 const int kSignMask = 0x80000000; |
301 const int kJumpAddrMask = (1 << (kImm26Bits + kImmFieldShift)) - 1; | 345 const int kJumpAddrMask = (1 << (kImm26Bits + kImmFieldShift)) - 1; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 BEQL = ((2U << 3) + 4) << kOpcodeShift, | 379 BEQL = ((2U << 3) + 4) << kOpcodeShift, |
336 BNEL = ((2U << 3) + 5) << kOpcodeShift, | 380 BNEL = ((2U << 3) + 5) << kOpcodeShift, |
337 BLEZL = ((2U << 3) + 6) << kOpcodeShift, | 381 BLEZL = ((2U << 3) + 6) << kOpcodeShift, |
338 BGTZL = ((2U << 3) + 7) << kOpcodeShift, | 382 BGTZL = ((2U << 3) + 7) << kOpcodeShift, |
339 | 383 |
340 DADDI = ((3U << 3) + 0) << kOpcodeShift, // This is also BNEC. | 384 DADDI = ((3U << 3) + 0) << kOpcodeShift, // This is also BNEC. |
341 DADDIU = ((3U << 3) + 1) << kOpcodeShift, | 385 DADDIU = ((3U << 3) + 1) << kOpcodeShift, |
342 LDL = ((3U << 3) + 2) << kOpcodeShift, | 386 LDL = ((3U << 3) + 2) << kOpcodeShift, |
343 LDR = ((3U << 3) + 3) << kOpcodeShift, | 387 LDR = ((3U << 3) + 3) << kOpcodeShift, |
344 SPECIAL2 = ((3U << 3) + 4) << kOpcodeShift, | 388 SPECIAL2 = ((3U << 3) + 4) << kOpcodeShift, |
| 389 MSA = ((3U << 3) + 6) << kOpcodeShift, |
345 SPECIAL3 = ((3U << 3) + 7) << kOpcodeShift, | 390 SPECIAL3 = ((3U << 3) + 7) << kOpcodeShift, |
346 | 391 |
347 LB = ((4U << 3) + 0) << kOpcodeShift, | 392 LB = ((4U << 3) + 0) << kOpcodeShift, |
348 LH = ((4U << 3) + 1) << kOpcodeShift, | 393 LH = ((4U << 3) + 1) << kOpcodeShift, |
349 LWL = ((4U << 3) + 2) << kOpcodeShift, | 394 LWL = ((4U << 3) + 2) << kOpcodeShift, |
350 LW = ((4U << 3) + 3) << kOpcodeShift, | 395 LW = ((4U << 3) + 3) << kOpcodeShift, |
351 LBU = ((4U << 3) + 4) << kOpcodeShift, | 396 LBU = ((4U << 3) + 4) << kOpcodeShift, |
352 LHU = ((4U << 3) + 5) << kOpcodeShift, | 397 LHU = ((4U << 3) + 5) << kOpcodeShift, |
353 LWR = ((4U << 3) + 6) << kOpcodeShift, | 398 LWR = ((4U << 3) + 6) << kOpcodeShift, |
354 LWU = ((4U << 3) + 7) << kOpcodeShift, | 399 LWU = ((4U << 3) + 7) << kOpcodeShift, |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 // reserved ((1U << 3) + 6), | 710 // reserved ((1U << 3) + 6), |
666 AUIPC = ((3U << 3) + 6), | 711 AUIPC = ((3U << 3) + 6), |
667 ALUIPC = ((3U << 3) + 7), | 712 ALUIPC = ((3U << 3) + 7), |
668 | 713 |
669 // POP66 Encoding of rs Field. | 714 // POP66 Encoding of rs Field. |
670 JIC = ((0U << 5) + 0), | 715 JIC = ((0U << 5) + 0), |
671 | 716 |
672 // POP76 Encoding of rs Field. | 717 // POP76 Encoding of rs Field. |
673 JIALC = ((0U << 5) + 0), | 718 JIALC = ((0U << 5) + 0), |
674 | 719 |
| 720 // COP1 Encoding of rs Field for MSA Branch Instructions |
| 721 BZ_V = (((1U << 3) + 3) << kRsShift), |
| 722 BNZ_V = (((1U << 3) + 7) << kRsShift), |
| 723 BZ_B = (((3U << 3) + 0) << kRsShift), |
| 724 BZ_H = (((3U << 3) + 1) << kRsShift), |
| 725 BZ_W = (((3U << 3) + 2) << kRsShift), |
| 726 BZ_D = (((3U << 3) + 3) << kRsShift), |
| 727 BNZ_B = (((3U << 3) + 4) << kRsShift), |
| 728 BNZ_H = (((3U << 3) + 5) << kRsShift), |
| 729 BNZ_W = (((3U << 3) + 6) << kRsShift), |
| 730 BNZ_D = (((3U << 3) + 7) << kRsShift), |
| 731 |
| 732 // MSA: Operation Field for MI10 Instruction Formats |
| 733 MSA_LD = (8U << 2), |
| 734 MSA_ST = (9U << 2), |
| 735 LD_B = ((8U << 2) + 0), |
| 736 LD_H = ((8U << 2) + 1), |
| 737 LD_W = ((8U << 2) + 2), |
| 738 LD_D = ((8U << 2) + 3), |
| 739 ST_B = ((9U << 2) + 0), |
| 740 ST_H = ((9U << 2) + 1), |
| 741 ST_W = ((9U << 2) + 2), |
| 742 ST_D = ((9U << 2) + 3), |
| 743 |
| 744 // MSA: Operation Field for I5 Instruction Format |
| 745 ADDVI = ((0U << 23) + 6), |
| 746 SUBVI = ((1U << 23) + 6), |
| 747 MAXI_S = ((2U << 23) + 6), |
| 748 MAXI_U = ((3U << 23) + 6), |
| 749 MINI_S = ((4U << 23) + 6), |
| 750 MINI_U = ((5U << 23) + 6), |
| 751 CEQI = ((0U << 23) + 7), |
| 752 CLTI_S = ((2U << 23) + 7), |
| 753 CLTI_U = ((3U << 23) + 7), |
| 754 CLEI_S = ((4U << 23) + 7), |
| 755 CLEI_U = ((5U << 23) + 7), |
| 756 LDI = ((6U << 23) + 7), // I10 instruction format |
| 757 I5_DF_b = (0U << 21), |
| 758 I5_DF_h = (1U << 21), |
| 759 I5_DF_w = (2U << 21), |
| 760 I5_DF_d = (3U << 21), |
| 761 |
| 762 // MSA: Operation Field for I8 Instruction Format |
| 763 ANDI_B = ((0U << 24) + 0), |
| 764 ORI_B = ((1U << 24) + 0), |
| 765 NORI_B = ((2U << 24) + 0), |
| 766 XORI_B = ((3U << 24) + 0), |
| 767 BMNZI_B = ((0U << 24) + 1), |
| 768 BMZI_B = ((1U << 24) + 1), |
| 769 BSELI_B = ((2U << 24) + 1), |
| 770 SHF_B = ((0U << 24) + 2), |
| 771 SHF_H = ((1U << 24) + 2), |
| 772 SHF_W = ((2U << 24) + 2), |
| 773 |
| 774 MSA_VEC_2R_2RF_MINOR = ((3U << 3) + 6), |
| 775 |
| 776 // MSA: Operation Field for VEC Instruction Formats |
| 777 AND_V = (((0U << 2) + 0) << 21), |
| 778 OR_V = (((0U << 2) + 1) << 21), |
| 779 NOR_V = (((0U << 2) + 2) << 21), |
| 780 XOR_V = (((0U << 2) + 3) << 21), |
| 781 BMNZ_V = (((1U << 2) + 0) << 21), |
| 782 BMZ_V = (((1U << 2) + 1) << 21), |
| 783 BSEL_V = (((1U << 2) + 2) << 21), |
| 784 |
| 785 // MSA: Operation Field for 2R Instruction Formats |
| 786 MSA_2R_FORMAT = (((6U << 2) + 0) << 21), |
| 787 FILL = (0U << 18), |
| 788 PCNT = (1U << 18), |
| 789 NLOC = (2U << 18), |
| 790 NLZC = (3U << 18), |
| 791 MSA_2R_DF_b = (0U << 16), |
| 792 MSA_2R_DF_h = (1U << 16), |
| 793 MSA_2R_DF_w = (2U << 16), |
| 794 MSA_2R_DF_d = (3U << 16), |
| 795 |
| 796 // MSA: Operation Field for 2RF Instruction Formats |
| 797 MSA_2RF_FORMAT = (((6U << 2) + 1) << 21), |
| 798 FCLASS = (0U << 17), |
| 799 FTRUNC_S = (1U << 17), |
| 800 FTRUNC_U = (2U << 17), |
| 801 FSQRT = (3U << 17), |
| 802 FRSQRT = (4U << 17), |
| 803 FRCP = (5U << 17), |
| 804 FRINT = (6U << 17), |
| 805 FLOG2 = (7U << 17), |
| 806 FEXUPL = (8U << 17), |
| 807 FEXUPR = (9U << 17), |
| 808 FFQL = (10U << 17), |
| 809 FFQR = (11U << 17), |
| 810 FTINT_S = (12U << 17), |
| 811 FTINT_U = (13U << 17), |
| 812 FFINT_S = (14U << 17), |
| 813 FFINT_U = (15U << 17), |
| 814 MSA_2RF_DF_w = (0U << 16), |
| 815 MSA_2RF_DF_d = (1U << 16), |
| 816 |
| 817 // MSA: Operation Field for 3R Instruction Format |
| 818 SLL_MSA = ((0U << 23) + 13), |
| 819 SRA_MSA = ((1U << 23) + 13), |
| 820 SRL_MSA = ((2U << 23) + 13), |
| 821 BCLR = ((3U << 23) + 13), |
| 822 BSET = ((4U << 23) + 13), |
| 823 BNEG = ((5U << 23) + 13), |
| 824 BINSL = ((6U << 23) + 13), |
| 825 BINSR = ((7U << 23) + 13), |
| 826 ADDV = ((0U << 23) + 14), |
| 827 SUBV = ((1U << 23) + 14), |
| 828 MAX_S = ((2U << 23) + 14), |
| 829 MAX_U = ((3U << 23) + 14), |
| 830 MIN_S = ((4U << 23) + 14), |
| 831 MIN_U = ((5U << 23) + 14), |
| 832 MAX_A = ((6U << 23) + 14), |
| 833 MIN_A = ((7U << 23) + 14), |
| 834 CEQ = ((0U << 23) + 15), |
| 835 CLT_S = ((2U << 23) + 15), |
| 836 CLT_U = ((3U << 23) + 15), |
| 837 CLE_S = ((4U << 23) + 15), |
| 838 CLE_U = ((5U << 23) + 15), |
| 839 ADD_A = ((0U << 23) + 16), |
| 840 ADDS_A = ((1U << 23) + 16), |
| 841 ADDS_S = ((2U << 23) + 16), |
| 842 ADDS_U = ((3U << 23) + 16), |
| 843 AVE_S = ((4U << 23) + 16), |
| 844 AVE_U = ((5U << 23) + 16), |
| 845 AVER_S = ((6U << 23) + 16), |
| 846 AVER_U = ((7U << 23) + 16), |
| 847 SUBS_S = ((0U << 23) + 17), |
| 848 SUBS_U = ((1U << 23) + 17), |
| 849 SUBSUS_U = ((2U << 23) + 17), |
| 850 SUBSUU_S = ((3U << 23) + 17), |
| 851 ASUB_S = ((4U << 23) + 17), |
| 852 ASUB_U = ((5U << 23) + 17), |
| 853 MULV = ((0U << 23) + 18), |
| 854 MADDV = ((1U << 23) + 18), |
| 855 MSUBV = ((2U << 23) + 18), |
| 856 DIV_S_MSA = ((4U << 23) + 18), |
| 857 DIV_U = ((5U << 23) + 18), |
| 858 MOD_S = ((6U << 23) + 18), |
| 859 MOD_U = ((7U << 23) + 18), |
| 860 DOTP_S = ((0U << 23) + 19), |
| 861 DOTP_U = ((1U << 23) + 19), |
| 862 DPADD_S = ((2U << 23) + 19), |
| 863 DPADD_U = ((3U << 23) + 19), |
| 864 DPSUB_S = ((4U << 23) + 19), |
| 865 DPSUB_U = ((5U << 23) + 19), |
| 866 SLD = ((0U << 23) + 20), |
| 867 SPLAT = ((1U << 23) + 20), |
| 868 PCKEV = ((2U << 23) + 20), |
| 869 PCKOD = ((3U << 23) + 20), |
| 870 ILVL = ((4U << 23) + 20), |
| 871 ILVR = ((5U << 23) + 20), |
| 872 ILVEV = ((6U << 23) + 20), |
| 873 ILVOD = ((7U << 23) + 20), |
| 874 VSHF = ((0U << 23) + 21), |
| 875 SRAR = ((1U << 23) + 21), |
| 876 SRLR = ((2U << 23) + 21), |
| 877 HADD_S = ((4U << 23) + 21), |
| 878 HADD_U = ((5U << 23) + 21), |
| 879 HSUB_S = ((6U << 23) + 21), |
| 880 HSUB_U = ((7U << 23) + 21), |
| 881 MSA_3R_DF_b = (0U << 21), |
| 882 MSA_3R_DF_h = (1U << 21), |
| 883 MSA_3R_DF_w = (2U << 21), |
| 884 MSA_3R_DF_d = (3U << 21), |
| 885 |
| 886 // MSA: Operation Field for 3RF Instruction Format |
| 887 FCAF = ((0U << 22) + 26), |
| 888 FCUN = ((1U << 22) + 26), |
| 889 FCEQ = ((2U << 22) + 26), |
| 890 FCUEQ = ((3U << 22) + 26), |
| 891 FCLT = ((4U << 22) + 26), |
| 892 FCULT = ((5U << 22) + 26), |
| 893 FCLE = ((6U << 22) + 26), |
| 894 FCULE = ((7U << 22) + 26), |
| 895 FSAF = ((8U << 22) + 26), |
| 896 FSUN = ((9U << 22) + 26), |
| 897 FSEQ = ((10U << 22) + 26), |
| 898 FSUEQ = ((11U << 22) + 26), |
| 899 FSLT = ((12U << 22) + 26), |
| 900 FSULT = ((13U << 22) + 26), |
| 901 FSLE = ((14U << 22) + 26), |
| 902 FSULE = ((15U << 22) + 26), |
| 903 FADD = ((0U << 22) + 27), |
| 904 FSUB = ((1U << 22) + 27), |
| 905 FMUL = ((2U << 22) + 27), |
| 906 FDIV = ((3U << 22) + 27), |
| 907 FMADD = ((4U << 22) + 27), |
| 908 FMSUB = ((5U << 22) + 27), |
| 909 FEXP2 = ((7U << 22) + 27), |
| 910 FEXDO = ((8U << 22) + 27), |
| 911 FTQ = ((10U << 22) + 27), |
| 912 FMIN = ((12U << 22) + 27), |
| 913 FMIN_A = ((13U << 22) + 27), |
| 914 FMAX = ((14U << 22) + 27), |
| 915 FMAX_A = ((15U << 22) + 27), |
| 916 FCOR = ((1U << 22) + 28), |
| 917 FCUNE = ((2U << 22) + 28), |
| 918 FCNE = ((3U << 22) + 28), |
| 919 MUL_Q = ((4U << 22) + 28), |
| 920 MADD_Q = ((5U << 22) + 28), |
| 921 MSUB_Q = ((6U << 22) + 28), |
| 922 FSOR = ((9U << 22) + 28), |
| 923 FSUNE = ((10U << 22) + 28), |
| 924 FSNE = ((11U << 22) + 28), |
| 925 MULR_Q = ((12U << 22) + 28), |
| 926 MADDR_Q = ((13U << 22) + 28), |
| 927 MSUBR_Q = ((14U << 22) + 28), |
| 928 |
| 929 // MSA: Operation Field for ELM Instruction Format |
| 930 MSA_ELM_MINOR = ((3U << 3) + 1), |
| 931 SLDI = (0U << 22), |
| 932 CTCMSA = ((0U << 22) | (62U << 16)), |
| 933 SPLATI = (1U << 22), |
| 934 CFCMSA = ((1U << 22) | (62U << 16)), |
| 935 COPY_S = (2U << 22), |
| 936 MOVE_V = ((2U << 22) | (62U << 16)), |
| 937 COPY_U = (3U << 22), |
| 938 INSERT = (4U << 22), |
| 939 INSVE = (5U << 22), |
| 940 ELM_DF_B = ((0U << 4) << 16), |
| 941 ELM_DF_H = ((4U << 3) << 16), |
| 942 ELM_DF_W = ((12U << 2) << 16), |
| 943 ELM_DF_D = ((28U << 1) << 16), |
| 944 |
| 945 // MSA: Operation Field for BIT Instruction Format |
| 946 SLLI = ((0U << 23) + 9), |
| 947 SRAI = ((1U << 23) + 9), |
| 948 SRLI = ((2U << 23) + 9), |
| 949 BCLRI = ((3U << 23) + 9), |
| 950 BSETI = ((4U << 23) + 9), |
| 951 BNEGI = ((5U << 23) + 9), |
| 952 BINSLI = ((6U << 23) + 9), |
| 953 BINSRI = ((7U << 23) + 9), |
| 954 SAT_S = ((0U << 23) + 10), |
| 955 SAT_U = ((1U << 23) + 10), |
| 956 SRARI = ((2U << 23) + 10), |
| 957 SRLRI = ((3U << 23) + 10), |
| 958 BIT_DF_b = ((14U << 3) << 16), |
| 959 BIT_DF_h = ((6U << 4) << 16), |
| 960 BIT_DF_w = ((2U << 5) << 16), |
| 961 BIT_DF_d = ((0U << 6) << 16), |
| 962 |
675 NULLSF = 0U | 963 NULLSF = 0U |
676 }; | 964 }; |
677 | 965 |
| 966 enum MSAMinorOpcode : uint32_t { |
| 967 kMsaMinorUndefined = 0, |
| 968 kMsaMinorI8, |
| 969 kMsaMinorI5, |
| 970 kMsaMinorI10, |
| 971 kMsaMinorBIT, |
| 972 kMsaMinor3R, |
| 973 kMsaMinor3RF, |
| 974 kMsaMinorELM, |
| 975 kMsaMinorVEC, |
| 976 kMsaMinor2R, |
| 977 kMsaMinor2RF, |
| 978 kMsaMinorMI10 |
| 979 }; |
| 980 |
678 // ----- Emulated conditions. | 981 // ----- Emulated conditions. |
679 // On MIPS we use this enum to abstract from conditional branch instructions. | 982 // On MIPS we use this enum to abstract from conditional branch instructions. |
680 // The 'U' prefix is used to specify unsigned comparisons. | 983 // The 'U' prefix is used to specify unsigned comparisons. |
681 // Opposite conditions must be paired as odd/even numbers | 984 // Opposite conditions must be paired as odd/even numbers |
682 // because 'NegateCondition' function flips LSB to negate condition. | 985 // because 'NegateCondition' function flips LSB to negate condition. |
683 enum Condition { | 986 enum Condition { |
684 // Any value < 0 is considered no_condition. | 987 // Any value < 0 is considered no_condition. |
685 kNoCondition = -1, | 988 kNoCondition = -1, |
686 overflow = 0, | 989 overflow = 0, |
687 no_overflow = 1, | 990 no_overflow = 1, |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 // Safe to call within InstructionType(). | 1310 // Safe to call within InstructionType(). |
1008 inline int RsFieldRawNoAssert() const { | 1311 inline int RsFieldRawNoAssert() const { |
1009 return InstructionBits() & kRsFieldMask; | 1312 return InstructionBits() & kRsFieldMask; |
1010 } | 1313 } |
1011 | 1314 |
1012 inline int SaFieldRaw() const { return InstructionBits() & kSaFieldMask; } | 1315 inline int SaFieldRaw() const { return InstructionBits() & kSaFieldMask; } |
1013 | 1316 |
1014 // Get the encoding type of the instruction. | 1317 // Get the encoding type of the instruction. |
1015 inline Type InstructionType() const; | 1318 inline Type InstructionType() const; |
1016 | 1319 |
| 1320 inline MSAMinorOpcode MSAMinorOpcodeField() const { |
| 1321 int op = this->FunctionFieldRaw(); |
| 1322 switch (op) { |
| 1323 case 0: |
| 1324 case 1: |
| 1325 case 2: |
| 1326 return kMsaMinorI8; |
| 1327 case 6: |
| 1328 return kMsaMinorI5; |
| 1329 case 7: |
| 1330 return (((this->InstructionBits() & kMsaI5I10Mask) == LDI) |
| 1331 ? kMsaMinorI10 |
| 1332 : kMsaMinorI5); |
| 1333 case 9: |
| 1334 case 10: |
| 1335 return kMsaMinorBIT; |
| 1336 case 13: |
| 1337 case 14: |
| 1338 case 15: |
| 1339 case 16: |
| 1340 case 17: |
| 1341 case 18: |
| 1342 case 19: |
| 1343 case 20: |
| 1344 case 21: |
| 1345 return kMsaMinor3R; |
| 1346 case 25: |
| 1347 return kMsaMinorELM; |
| 1348 case 26: |
| 1349 case 27: |
| 1350 case 28: |
| 1351 return kMsaMinor3RF; |
| 1352 case 30: |
| 1353 switch (this->RsFieldRawNoAssert()) { |
| 1354 case MSA_2R_FORMAT: |
| 1355 return kMsaMinor2R; |
| 1356 case MSA_2RF_FORMAT: |
| 1357 return kMsaMinor2RF; |
| 1358 default: |
| 1359 return kMsaMinorVEC; |
| 1360 } |
| 1361 break; |
| 1362 case 32: |
| 1363 case 33: |
| 1364 case 34: |
| 1365 case 35: |
| 1366 case 36: |
| 1367 case 37: |
| 1368 case 38: |
| 1369 case 39: |
| 1370 return kMsaMinorMI10; |
| 1371 default: |
| 1372 return kMsaMinorUndefined; |
| 1373 } |
| 1374 } |
| 1375 |
1017 protected: | 1376 protected: |
1018 InstructionBase() {} | 1377 InstructionBase() {} |
1019 }; | 1378 }; |
1020 | 1379 |
1021 template <class T> | 1380 template <class T> |
1022 class InstructionGetters : public T { | 1381 class InstructionGetters : public T { |
1023 public: | 1382 public: |
1024 inline int RsValue() const { | 1383 inline int RsValue() const { |
1025 DCHECK(this->InstructionType() == InstructionBase::kRegisterType || | 1384 DCHECK(this->InstructionType() == InstructionBase::kRegisterType || |
1026 this->InstructionType() == InstructionBase::kImmediateType); | 1385 this->InstructionType() == InstructionBase::kImmediateType); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1063 } | 1422 } |
1064 | 1423 |
1065 inline int FtValue() const { | 1424 inline int FtValue() const { |
1066 return this->Bits(kFtShift + kFtBits - 1, kFtShift); | 1425 return this->Bits(kFtShift + kFtBits - 1, kFtShift); |
1067 } | 1426 } |
1068 | 1427 |
1069 inline int FrValue() const { | 1428 inline int FrValue() const { |
1070 return this->Bits(kFrShift + kFrBits - 1, kFrShift); | 1429 return this->Bits(kFrShift + kFrBits - 1, kFrShift); |
1071 } | 1430 } |
1072 | 1431 |
| 1432 inline int WdValue() const { |
| 1433 return this->Bits(kWdShift + kWdBits - 1, kWdShift); |
| 1434 } |
| 1435 |
| 1436 inline int WsValue() const { |
| 1437 return this->Bits(kWsShift + kWsBits - 1, kWsShift); |
| 1438 } |
| 1439 |
| 1440 inline int WtValue() const { |
| 1441 return this->Bits(kWtShift + kWtBits - 1, kWtShift); |
| 1442 } |
| 1443 |
1073 inline int Bp2Value() const { | 1444 inline int Bp2Value() const { |
1074 DCHECK(this->InstructionType() == InstructionBase::kRegisterType); | 1445 DCHECK(this->InstructionType() == InstructionBase::kRegisterType); |
1075 return this->Bits(kBp2Shift + kBp2Bits - 1, kBp2Shift); | 1446 return this->Bits(kBp2Shift + kBp2Bits - 1, kBp2Shift); |
1076 } | 1447 } |
1077 | 1448 |
1078 inline int Bp3Value() const { | 1449 inline int Bp3Value() const { |
1079 DCHECK(this->InstructionType() == InstructionBase::kRegisterType); | 1450 DCHECK(this->InstructionType() == InstructionBase::kRegisterType); |
1080 return this->Bits(kBp3Shift + kBp3Bits - 1, kBp3Shift); | 1451 return this->Bits(kBp3Shift + kBp3Bits - 1, kBp3Shift); |
1081 } | 1452 } |
1082 | 1453 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1170 DCHECK(this->InstructionType() == InstructionBase::kImmediateType); | 1541 DCHECK(this->InstructionType() == InstructionBase::kImmediateType); |
1171 return this->Bits(kImm21Shift + kImm21Bits - 1, kImm21Shift); | 1542 return this->Bits(kImm21Shift + kImm21Bits - 1, kImm21Shift); |
1172 } | 1543 } |
1173 | 1544 |
1174 inline int32_t Imm26Value() const { | 1545 inline int32_t Imm26Value() const { |
1175 DCHECK((this->InstructionType() == InstructionBase::kJumpType) || | 1546 DCHECK((this->InstructionType() == InstructionBase::kJumpType) || |
1176 (this->InstructionType() == InstructionBase::kImmediateType)); | 1547 (this->InstructionType() == InstructionBase::kImmediateType)); |
1177 return this->Bits(kImm26Shift + kImm26Bits - 1, kImm26Shift); | 1548 return this->Bits(kImm26Shift + kImm26Bits - 1, kImm26Shift); |
1178 } | 1549 } |
1179 | 1550 |
| 1551 inline int32_t MsaImm8Value() const { |
| 1552 DCHECK(this->InstructionType() == InstructionBase::kImmediateType); |
| 1553 return this->Bits(kMsaImm8Shift + kMsaImm8Bits - 1, kMsaImm8Shift); |
| 1554 } |
| 1555 |
| 1556 inline int32_t MsaImm5Value() const { |
| 1557 DCHECK(this->InstructionType() == InstructionBase::kImmediateType); |
| 1558 return this->Bits(kMsaImm5Shift + kMsaImm5Bits - 1, kMsaImm5Shift); |
| 1559 } |
| 1560 |
| 1561 inline int32_t MsaImm10Value() const { |
| 1562 DCHECK(this->InstructionType() == InstructionBase::kImmediateType); |
| 1563 return this->Bits(kMsaImm10Shift + kMsaImm10Bits - 1, kMsaImm10Shift); |
| 1564 } |
| 1565 |
| 1566 inline int32_t MsaImmMI10Value() const { |
| 1567 DCHECK(this->InstructionType() == InstructionBase::kImmediateType); |
| 1568 return this->Bits(kMsaImmMI10Shift + kMsaImmMI10Bits - 1, kMsaImmMI10Shift); |
| 1569 } |
| 1570 |
| 1571 inline int32_t MsaBitDf() const { |
| 1572 DCHECK(this->InstructionType() == InstructionBase::kImmediateType); |
| 1573 int32_t df_m = this->Bits(22, 16); |
| 1574 if (((df_m >> 6) & 1U) == 0) { |
| 1575 return 3; |
| 1576 } else if (((df_m >> 5) & 3U) == 2) { |
| 1577 return 2; |
| 1578 } else if (((df_m >> 4) & 7U) == 6) { |
| 1579 return 1; |
| 1580 } else if (((df_m >> 3) & 15U) == 14) { |
| 1581 return 0; |
| 1582 } else { |
| 1583 return -1; |
| 1584 } |
| 1585 } |
| 1586 |
| 1587 inline int32_t MsaBitMValue() const { |
| 1588 DCHECK(this->InstructionType() == InstructionBase::kImmediateType); |
| 1589 return this->Bits(16 + this->MsaBitDf() + 3, 16); |
| 1590 } |
| 1591 |
| 1592 inline int32_t MsaElmDf() const { |
| 1593 DCHECK(this->InstructionType() == InstructionBase::kImmediateType); |
| 1594 int32_t df_n = this->Bits(21, 16); |
| 1595 if (((df_n >> 4) & 3U) == 0) { |
| 1596 return 0; |
| 1597 } else if (((df_n >> 3) & 7U) == 4) { |
| 1598 return 1; |
| 1599 } else if (((df_n >> 2) & 15U) == 12) { |
| 1600 return 2; |
| 1601 } else if (((df_n >> 1) & 31U) == 28) { |
| 1602 return 3; |
| 1603 } else { |
| 1604 return -1; |
| 1605 } |
| 1606 } |
| 1607 |
| 1608 inline int32_t MsaElmNValue() const { |
| 1609 DCHECK(this->InstructionType() == InstructionBase::kImmediateType); |
| 1610 return this->Bits(16 + 4 - this->MsaElmDf(), 16); |
| 1611 } |
| 1612 |
1180 static bool IsForbiddenAfterBranchInstr(Instr instr); | 1613 static bool IsForbiddenAfterBranchInstr(Instr instr); |
1181 | 1614 |
1182 // Say if the instruction should not be used in a branch delay slot or | 1615 // Say if the instruction should not be used in a branch delay slot or |
1183 // immediately after a compact branch. | 1616 // immediately after a compact branch. |
1184 inline bool IsForbiddenAfterBranch() const { | 1617 inline bool IsForbiddenAfterBranch() const { |
1185 return IsForbiddenAfterBranchInstr(this->InstructionBits()); | 1618 return IsForbiddenAfterBranchInstr(this->InstructionBits()); |
1186 } | 1619 } |
1187 | 1620 |
1188 inline bool IsForbiddenInBranchDelay() const { | 1621 inline bool IsForbiddenInBranchDelay() const { |
1189 return IsForbiddenAfterBranch(); | 1622 return IsForbiddenAfterBranch(); |
1190 } | 1623 } |
1191 | 1624 |
1192 // Say if the instruction 'links'. e.g. jal, bal. | 1625 // Say if the instruction 'links'. e.g. jal, bal. |
1193 bool IsLinkingInstruction() const; | 1626 bool IsLinkingInstruction() const; |
1194 // Say if the instruction is a break or a trap. | 1627 // Say if the instruction is a break or a trap. |
1195 bool IsTrap() const; | 1628 bool IsTrap() const; |
| 1629 |
| 1630 inline bool IsMSABranchInstr() const { |
| 1631 if (this->OpcodeFieldRaw() == COP1) { |
| 1632 switch (this->RsFieldRaw()) { |
| 1633 case BZ_V: |
| 1634 case BZ_B: |
| 1635 case BZ_H: |
| 1636 case BZ_W: |
| 1637 case BZ_D: |
| 1638 case BNZ_V: |
| 1639 case BNZ_B: |
| 1640 case BNZ_H: |
| 1641 case BNZ_W: |
| 1642 case BNZ_D: |
| 1643 return true; |
| 1644 default: |
| 1645 return false; |
| 1646 } |
| 1647 } |
| 1648 return false; |
| 1649 } |
| 1650 |
| 1651 inline bool IsMSAInstr() const { |
| 1652 if (this->IsMSABranchInstr() || (this->OpcodeFieldRaw() == MSA)) |
| 1653 return true; |
| 1654 return false; |
| 1655 } |
1196 }; | 1656 }; |
1197 | 1657 |
1198 class Instruction : public InstructionGetters<InstructionBase> { | 1658 class Instruction : public InstructionGetters<InstructionBase> { |
1199 public: | 1659 public: |
1200 // Instructions are read of out a code stream. The only way to get a | 1660 // Instructions are read of out a code stream. The only way to get a |
1201 // reference to an instruction is to convert a pointer. There is no way | 1661 // reference to an instruction is to convert a pointer. There is no way |
1202 // to allocate or create instances of class Instruction. | 1662 // to allocate or create instances of class Instruction. |
1203 // Use the At(pc) function to create references to Instruction. | 1663 // Use the At(pc) function to create references to Instruction. |
1204 static Instruction* At(byte* pc) { | 1664 static Instruction* At(byte* pc) { |
1205 return reinterpret_cast<Instruction*>(pc); | 1665 return reinterpret_cast<Instruction*>(pc); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1288 default: | 1748 default: |
1289 return kUnsupported; | 1749 return kUnsupported; |
1290 } | 1750 } |
1291 break; | 1751 break; |
1292 case COP1: // Coprocessor instructions. | 1752 case COP1: // Coprocessor instructions. |
1293 switch (RsFieldRawNoAssert()) { | 1753 switch (RsFieldRawNoAssert()) { |
1294 case BC1: // Branch on coprocessor condition. | 1754 case BC1: // Branch on coprocessor condition. |
1295 case BC1EQZ: | 1755 case BC1EQZ: |
1296 case BC1NEZ: | 1756 case BC1NEZ: |
1297 return kImmediateType; | 1757 return kImmediateType; |
| 1758 // MSA Branch instructions |
| 1759 case BZ_V: |
| 1760 case BNZ_V: |
| 1761 case BZ_B: |
| 1762 case BZ_H: |
| 1763 case BZ_W: |
| 1764 case BZ_D: |
| 1765 case BNZ_B: |
| 1766 case BNZ_H: |
| 1767 case BNZ_W: |
| 1768 case BNZ_D: |
| 1769 return kImmediateType; |
1298 default: | 1770 default: |
1299 return kRegisterType; | 1771 return kRegisterType; |
1300 } | 1772 } |
1301 break; | 1773 break; |
1302 case COP1X: | 1774 case COP1X: |
1303 return kRegisterType; | 1775 return kRegisterType; |
1304 | 1776 |
1305 // 26 bits immediate type instructions. e.g.: j imm26. | 1777 // 26 bits immediate type instructions. e.g.: j imm26. |
1306 case J: | 1778 case J: |
1307 case JAL: | 1779 case JAL: |
1308 return kJumpType; | 1780 return kJumpType; |
1309 | 1781 |
| 1782 case MSA: |
| 1783 switch (MSAMinorOpcodeField()) { |
| 1784 case kMsaMinor3R: |
| 1785 case kMsaMinor3RF: |
| 1786 case kMsaMinorVEC: |
| 1787 case kMsaMinor2R: |
| 1788 case kMsaMinor2RF: |
| 1789 return kRegisterType; |
| 1790 default: |
| 1791 return kImmediateType; |
| 1792 } |
| 1793 |
1310 default: | 1794 default: |
1311 return kImmediateType; | 1795 return kImmediateType; |
1312 } | 1796 } |
1313 return kUnsupported; | 1797 return kUnsupported; |
1314 } | 1798 } |
1315 #undef OpcodeToBitNumber | 1799 #undef OpcodeToBitNumber |
1316 #undef FunctionFieldToBitNumber | 1800 #undef FunctionFieldToBitNumber |
1317 | 1801 |
1318 // ----------------------------------------------------------------------------- | 1802 // ----------------------------------------------------------------------------- |
1319 // Instructions. | 1803 // Instructions. |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1422 } | 1906 } |
1423 break; | 1907 break; |
1424 default: | 1908 default: |
1425 return false; | 1909 return false; |
1426 } | 1910 } |
1427 } | 1911 } |
1428 } // namespace internal | 1912 } // namespace internal |
1429 } // namespace v8 | 1913 } // namespace v8 |
1430 | 1914 |
1431 #endif // #ifndef V8_MIPS_CONSTANTS_H_ | 1915 #endif // #ifndef V8_MIPS_CONSTANTS_H_ |
OLD | NEW |