5 #ifndef V8_MIPS64_CONSTANTS_MIPS64_H_ 6 #define V8_MIPS64_CONSTANTS_MIPS64_H_ 8 #include "src/base/logging.h" 9 #include "src/base/macros.h" 10 #include "src/globals.h" 14 #define UNIMPLEMENTED_MIPS() \ 15 v8::internal::PrintF("%s, \tline %d: \tfunction %s not implemented. \n", \ 16 __FILE__, __LINE__, __func__) 18 #define UNIMPLEMENTED_MIPS() 21 #define UNSUPPORTED_MIPS() v8::internal::PrintF("Unsupported instruction.\n") 29 #ifdef _MIPS_ARCH_MIPS64R2 30 static const ArchVariants kArchVariant = kMips64r2;
31 #elif _MIPS_ARCH_MIPS64R6 32 static const ArchVariants kArchVariant = kMips64r6;
34 static const ArchVariants kArchVariant = kMips64r2;
38 enum Endianness { kLittle, kBig };
40 #if defined(V8_TARGET_LITTLE_ENDIAN) 41 static const Endianness kArchEndian = kLittle;
42 #elif defined(V8_TARGET_BIG_ENDIAN) 43 static const Endianness kArchEndian = kBig;
45 #error Unknown endianness 50 #if(defined(__mips_hard_float) && __mips_hard_float != 0) 53 const bool IsMipsSoftFloatABI =
false;
54 #elif(defined(__mips_soft_float) && __mips_soft_float != 0) 58 const bool IsMipsSoftFloatABI =
true;
60 const bool IsMipsSoftFloatABI =
true;
63 #if defined(V8_TARGET_LITTLE_ENDIAN) 72 #elif defined(V8_TARGET_BIG_ENDIAN) 82 #error Unknown endianness 85 #if defined(V8_TARGET_LITTLE_ENDIAN) 86 const uint32_t kLeastSignificantByteInInt32Offset = 0;
87 const uint32_t kLessSignificantWordInDoublewordOffset = 0;
88 #elif defined(V8_TARGET_BIG_ENDIAN) 89 const uint32_t kLeastSignificantByteInInt32Offset = 3;
90 const uint32_t kLessSignificantWordInDoublewordOffset = 4;
92 #error Unknown endianness 95 #ifndef __STDC_FORMAT_MACROS 96 #define __STDC_FORMAT_MACROS 111 constexpr
size_t kMaxPCRelativeCodeRangeInMB = 0;
117 const int kNumRegisters = 32;
118 const int kInvalidRegister = -1;
121 const int kNumSimuRegisters = 35;
124 const int kPCRegister = 34;
127 const int kNumFPURegisters = 32;
128 const int kInvalidFPURegister = -1;
131 const int kNumMSARegisters = 32;
132 const int kInvalidMSARegister = -1;
134 const int kInvalidMSAControlRegister = -1;
135 const int kMSAIRRegister = 0;
136 const int kMSACSRRegister = 1;
137 const int kMSARegSize = 128;
138 const int kMSALanesByte = kMSARegSize / 8;
139 const int kMSALanesHalf = kMSARegSize / 16;
140 const int kMSALanesWord = kMSARegSize / 32;
141 const int kMSALanesDword = kMSARegSize / 64;
144 const int kFCSRRegister = 31;
145 const int kInvalidFPUControlRegister = -1;
147 const int32_t kFPUInvalidResultNegative =
static_cast<int32_t
>(1u << 31);
148 const uint64_t kFPU64InvalidResult =
149 static_cast<uint64_t
>(
static_cast<uint64_t
>(1) << 63) - 1;
150 const int64_t kFPU64InvalidResultNegative =
151 static_cast<int64_t>(
static_cast<uint64_t
>(1) << 63);
154 const uint32_t kFCSRInexactFlagBit = 2;
155 const uint32_t kFCSRUnderflowFlagBit = 3;
156 const uint32_t kFCSROverflowFlagBit = 4;
157 const uint32_t kFCSRDivideByZeroFlagBit = 5;
158 const uint32_t kFCSRInvalidOpFlagBit = 6;
159 const uint32_t kFCSRNaN2008FlagBit = 18;
161 const uint32_t kFCSRInexactFlagMask = 1 << kFCSRInexactFlagBit;
162 const uint32_t kFCSRUnderflowFlagMask = 1 << kFCSRUnderflowFlagBit;
163 const uint32_t kFCSROverflowFlagMask = 1 << kFCSROverflowFlagBit;
164 const uint32_t kFCSRDivideByZeroFlagMask = 1 << kFCSRDivideByZeroFlagBit;
165 const uint32_t kFCSRInvalidOpFlagMask = 1 << kFCSRInvalidOpFlagBit;
166 const uint32_t kFCSRNaN2008FlagMask = 1 << kFCSRNaN2008FlagBit;
169 kFCSRInexactFlagMask |
170 kFCSRUnderflowFlagMask |
171 kFCSROverflowFlagMask |
172 kFCSRDivideByZeroFlagMask |
173 kFCSRInvalidOpFlagMask;
175 const uint32_t kFCSRExceptionFlagMask = kFCSRFlagMask ^ kFCSRInexactFlagMask;
178 const int32_t kPrefHintLoad = 0;
179 const int32_t kPrefHintStore = 1;
180 const int32_t kPrefHintLoadStreamed = 4;
181 const int32_t kPrefHintStoreStreamed = 5;
182 const int32_t kPrefHintLoadRetained = 6;
183 const int32_t kPrefHintStoreRetained = 7;
184 const int32_t kPrefHintWritebackInvalidate = 25;
185 const int32_t kPrefHintPrepareForStore = 30;
190 constexpr
int kRootRegisterBias = 256;
196 static const char* Name(
int reg);
199 static int Number(
const char* name);
201 struct RegisterAlias {
206 static const int64_t kMaxValue = 0x7fffffffffffffffl;
207 static const int64_t kMinValue = 0x8000000000000000l;
210 static const char* names_[kNumSimuRegisters];
211 static const RegisterAlias aliases_[];
218 static const char* Name(
int reg);
221 static int Number(
const char* name);
223 struct RegisterAlias {
229 static const char* names_[kNumFPURegisters];
230 static const RegisterAlias aliases_[];
237 static const char* Name(
int reg);
240 static int Number(
const char* name);
242 struct RegisterAlias {
248 static const char* names_[kNumMSARegisters];
249 static const RegisterAlias aliases_[];
256 typedef int32_t Instr;
260 enum SoftwareInterruptCodes {
262 call_rt_redirected = 0xfffff
272 const uint32_t kMaxWatchpointCode = 31;
274 STATIC_ASSERT(kMaxWatchpointCode < kMaxStopCode);
278 const int kOpcodeShift = 26;
279 const int kOpcodeBits = 6;
280 const int kRsShift = 21;
281 const int kRsBits = 5;
282 const int kRtShift = 16;
283 const int kRtBits = 5;
284 const int kRdShift = 11;
285 const int kRdBits = 5;
286 const int kSaShift = 6;
287 const int kSaBits = 5;
288 const int kLsaSaBits = 2;
289 const int kFunctionShift = 0;
290 const int kFunctionBits = 6;
291 const int kLuiShift = 16;
292 const int kBp2Shift = 6;
293 const int kBp2Bits = 2;
294 const int kBp3Shift = 6;
295 const int kBp3Bits = 3;
296 const int kBaseShift = 21;
297 const int kBaseBits = 5;
298 const int kBit6Shift = 6;
299 const int kBit6Bits = 1;
301 const int kImm9Shift = 7;
302 const int kImm9Bits = 9;
303 const int kImm16Shift = 0;
304 const int kImm16Bits = 16;
305 const int kImm18Shift = 0;
306 const int kImm18Bits = 18;
307 const int kImm19Shift = 0;
308 const int kImm19Bits = 19;
309 const int kImm21Shift = 0;
310 const int kImm21Bits = 21;
311 const int kImm26Shift = 0;
312 const int kImm26Bits = 26;
313 const int kImm28Shift = 0;
314 const int kImm28Bits = 28;
315 const int kImm32Shift = 0;
316 const int kImm32Bits = 32;
317 const int kMsaImm8Shift = 16;
318 const int kMsaImm8Bits = 8;
319 const int kMsaImm5Shift = 16;
320 const int kMsaImm5Bits = 5;
321 const int kMsaImm10Shift = 11;
322 const int kMsaImm10Bits = 10;
323 const int kMsaImmMI10Shift = 16;
324 const int kMsaImmMI10Bits = 10;
328 const int kImmFieldShift = 2;
330 const int kFrBits = 5;
331 const int kFrShift = 21;
332 const int kFsShift = 11;
333 const int kFsBits = 5;
334 const int kFtShift = 16;
335 const int kFtBits = 5;
336 const int kFdShift = 6;
337 const int kFdBits = 5;
338 const int kFCccShift = 8;
339 const int kFCccBits = 3;
340 const int kFBccShift = 18;
341 const int kFBccBits = 3;
342 const int kFBtrueShift = 16;
343 const int kFBtrueBits = 1;
344 const int kWtBits = 5;
345 const int kWtShift = 16;
346 const int kWsBits = 5;
347 const int kWsShift = 11;
348 const int kWdBits = 5;
349 const int kWdShift = 6;
353 const int kOpcodeMask = ((1 << kOpcodeBits) - 1) << kOpcodeShift;
354 const int kImm9Mask = ((1 << kImm9Bits) - 1) << kImm9Shift;
355 const int kImm16Mask = ((1 << kImm16Bits) - 1) << kImm16Shift;
356 const int kImm18Mask = ((1 << kImm18Bits) - 1) << kImm18Shift;
357 const int kImm19Mask = ((1 << kImm19Bits) - 1) << kImm19Shift;
358 const int kImm21Mask = ((1 << kImm21Bits) - 1) << kImm21Shift;
359 const int kImm26Mask = ((1 << kImm26Bits) - 1) << kImm26Shift;
360 const int kImm28Mask = ((1 << kImm28Bits) - 1) << kImm28Shift;
361 const int kImm5Mask = ((1 << 5) - 1);
362 const int kImm8Mask = ((1 << 8) - 1);
363 const int kImm10Mask = ((1 << 10) - 1);
364 const int kMsaI5I10Mask = ((7U << 23) | ((1 << 6) - 1));
365 const int kMsaI8Mask = ((3U << 24) | ((1 << 6) - 1));
366 const int kMsaI5Mask = ((7U << 23) | ((1 << 6) - 1));
367 const int kMsaMI10Mask = (15U << 2);
368 const int kMsaBITMask = ((7U << 23) | ((1 << 6) - 1));
369 const int kMsaELMMask = (15U << 22);
370 const int kMsaLongerELMMask = kMsaELMMask | (63U << 16);
371 const int kMsa3RMask = ((7U << 23) | ((1 << 6) - 1));
372 const int kMsa3RFMask = ((15U << 22) | ((1 << 6) - 1));
373 const int kMsaVECMask = (23U << 21);
374 const int kMsa2RMask = (7U << 18);
375 const int kMsa2RFMask = (15U << 17);
376 const int kRsFieldMask = ((1 << kRsBits) - 1) << kRsShift;
377 const int kRtFieldMask = ((1 << kRtBits) - 1) << kRtShift;
378 const int kRdFieldMask = ((1 << kRdBits) - 1) << kRdShift;
379 const int kSaFieldMask = ((1 << kSaBits) - 1) << kSaShift;
380 const int kFunctionFieldMask = ((1 << kFunctionBits) - 1) << kFunctionShift;
382 const int kHiMaskOf32 = 0xffff << 16;
383 const int kLoMaskOf32 = 0xffff;
384 const int kSignMaskOf32 = 0x80000000;
385 const int kJumpAddrMask = (1 << (kImm26Bits + kImmFieldShift)) - 1;
389 const int32_t kJalRawMark = 0x00000000;
390 const int32_t kJRawMark = 0xf0000000;
391 const int32_t kJumpRawMask = 0xf0000000;
397 SPECIAL = 0U << kOpcodeShift,
398 REGIMM = 1U << kOpcodeShift,
400 J = ((0U << 3) + 2) << kOpcodeShift,
401 JAL = ((0U << 3) + 3) << kOpcodeShift,
402 BEQ = ((0U << 3) + 4) << kOpcodeShift,
403 BNE = ((0U << 3) + 5) << kOpcodeShift,
404 BLEZ = ((0U << 3) + 6) << kOpcodeShift,
405 BGTZ = ((0U << 3) + 7) << kOpcodeShift,
407 ADDI = ((1U << 3) + 0) << kOpcodeShift,
408 ADDIU = ((1U << 3) + 1) << kOpcodeShift,
409 SLTI = ((1U << 3) + 2) << kOpcodeShift,
410 SLTIU = ((1U << 3) + 3) << kOpcodeShift,
411 ANDI = ((1U << 3) + 4) << kOpcodeShift,
412 ORI = ((1U << 3) + 5) << kOpcodeShift,
413 XORI = ((1U << 3) + 6) << kOpcodeShift,
414 LUI = ((1U << 3) + 7) << kOpcodeShift,
415 DAUI = ((3U << 3) + 5) << kOpcodeShift,
417 BEQC = ((2U << 3) + 0) << kOpcodeShift,
418 COP1 = ((2U << 3) + 1) << kOpcodeShift,
419 BEQL = ((2U << 3) + 4) << kOpcodeShift,
420 BNEL = ((2U << 3) + 5) << kOpcodeShift,
421 BLEZL = ((2U << 3) + 6) << kOpcodeShift,
422 BGTZL = ((2U << 3) + 7) << kOpcodeShift,
424 DADDI = ((3U << 3) + 0) << kOpcodeShift,
425 DADDIU = ((3U << 3) + 1) << kOpcodeShift,
426 LDL = ((3U << 3) + 2) << kOpcodeShift,
427 LDR = ((3U << 3) + 3) << kOpcodeShift,
428 SPECIAL2 = ((3U << 3) + 4) << kOpcodeShift,
429 MSA = ((3U << 3) + 6) << kOpcodeShift,
430 SPECIAL3 = ((3U << 3) + 7) << kOpcodeShift,
432 LB = ((4U << 3) + 0) << kOpcodeShift,
433 LH = ((4U << 3) + 1) << kOpcodeShift,
434 LWL = ((4U << 3) + 2) << kOpcodeShift,
435 LW = ((4U << 3) + 3) << kOpcodeShift,
436 LBU = ((4U << 3) + 4) << kOpcodeShift,
437 LHU = ((4U << 3) + 5) << kOpcodeShift,
438 LWR = ((4U << 3) + 6) << kOpcodeShift,
439 LWU = ((4U << 3) + 7) << kOpcodeShift,
441 SB = ((5U << 3) + 0) << kOpcodeShift,
442 SH = ((5U << 3) + 1) << kOpcodeShift,
443 SWL = ((5U << 3) + 2) << kOpcodeShift,
444 SW = ((5U << 3) + 3) << kOpcodeShift,
445 SDL = ((5U << 3) + 4) << kOpcodeShift,
446 SDR = ((5U << 3) + 5) << kOpcodeShift,
447 SWR = ((5U << 3) + 6) << kOpcodeShift,
449 LL = ((6U << 3) + 0) << kOpcodeShift,
450 LWC1 = ((6U << 3) + 1) << kOpcodeShift,
451 BC = ((6U << 3) + 2) << kOpcodeShift,
452 LLD = ((6U << 3) + 4) << kOpcodeShift,
453 LDC1 = ((6U << 3) + 5) << kOpcodeShift,
454 POP66 = ((6U << 3) + 6) << kOpcodeShift,
455 LD = ((6U << 3) + 7) << kOpcodeShift,
457 PREF = ((6U << 3) + 3) << kOpcodeShift,
459 SC = ((7U << 3) + 0) << kOpcodeShift,
460 SWC1 = ((7U << 3) + 1) << kOpcodeShift,
461 BALC = ((7U << 3) + 2) << kOpcodeShift,
462 PCREL = ((7U << 3) + 3) << kOpcodeShift,
463 SCD = ((7U << 3) + 4) << kOpcodeShift,
464 SDC1 = ((7U << 3) + 5) << kOpcodeShift,
465 POP76 = ((7U << 3) + 6) << kOpcodeShift,
466 SD = ((7U << 3) + 7) << kOpcodeShift,
468 COP1X = ((1U << 4) + 3) << kOpcodeShift,
481 SLL = ((0U << 3) + 0),
482 MOVCI = ((0U << 3) + 1),
483 SRL = ((0U << 3) + 2),
484 SRA = ((0U << 3) + 3),
485 SLLV = ((0U << 3) + 4),
486 LSA = ((0U << 3) + 5),
487 SRLV = ((0U << 3) + 6),
488 SRAV = ((0U << 3) + 7),
490 JR = ((1U << 3) + 0),
491 JALR = ((1U << 3) + 1),
492 MOVZ = ((1U << 3) + 2),
493 MOVN = ((1U << 3) + 3),
494 BREAK = ((1U << 3) + 5),
495 SYNC = ((1U << 3) + 7),
497 MFHI = ((2U << 3) + 0),
498 CLZ_R6 = ((2U << 3) + 0),
499 CLO_R6 = ((2U << 3) + 1),
500 MFLO = ((2U << 3) + 2),
501 DCLZ_R6 = ((2U << 3) + 2),
502 DCLO_R6 = ((2U << 3) + 3),
503 DSLLV = ((2U << 3) + 4),
504 DLSA = ((2U << 3) + 5),
505 DSRLV = ((2U << 3) + 6),
506 DSRAV = ((2U << 3) + 7),
508 MULT = ((3U << 3) + 0),
509 MULTU = ((3U << 3) + 1),
510 DIV = ((3U << 3) + 2),
511 DIVU = ((3U << 3) + 3),
512 DMULT = ((3U << 3) + 4),
513 DMULTU = ((3U << 3) + 5),
514 DDIV = ((3U << 3) + 6),
515 DDIVU = ((3U << 3) + 7),
517 ADD = ((4U << 3) + 0),
518 ADDU = ((4U << 3) + 1),
519 SUB = ((4U << 3) + 2),
520 SUBU = ((4U << 3) + 3),
521 AND = ((4U << 3) + 4),
522 OR = ((4U << 3) + 5),
523 XOR = ((4U << 3) + 6),
524 NOR = ((4U << 3) + 7),
526 SLT = ((5U << 3) + 2),
527 SLTU = ((5U << 3) + 3),
528 DADD = ((5U << 3) + 4),
529 DADDU = ((5U << 3) + 5),
530 DSUB = ((5U << 3) + 6),
531 DSUBU = ((5U << 3) + 7),
533 TGE = ((6U << 3) + 0),
534 TGEU = ((6U << 3) + 1),
535 TLT = ((6U << 3) + 2),
536 TLTU = ((6U << 3) + 3),
537 TEQ = ((6U << 3) + 4),
538 SELEQZ_S = ((6U << 3) + 5),
539 TNE = ((6U << 3) + 6),
540 SELNEZ_S = ((6U << 3) + 7),
542 DSLL = ((7U << 3) + 0),
543 DSRL = ((7U << 3) + 2),
544 DSRA = ((7U << 3) + 3),
545 DSLL32 = ((7U << 3) + 4),
546 DSRL32 = ((7U << 3) + 6),
547 DSRA32 = ((7U << 3) + 7),
550 MUL_MUH = ((3U << 3) + 0),
551 MUL_MUH_U = ((3U << 3) + 1),
552 D_MUL_MUH = ((7U << 2) + 0),
553 D_MUL_MUH_U = ((7U << 2) + 1),
554 RINT = ((3U << 3) + 2),
556 MUL_OP = ((0U << 3) + 2),
557 MUH_OP = ((0U << 3) + 3),
558 DIV_OP = ((0U << 3) + 2),
559 MOD_OP = ((0U << 3) + 3),
561 DIV_MOD = ((3U << 3) + 2),
562 DIV_MOD_U = ((3U << 3) + 3),
563 D_DIV_MOD = ((3U << 3) + 6),
564 D_DIV_MOD_U = ((3U << 3) + 7),
569 MUL = ((0U << 3) + 2),
570 CLZ = ((4U << 3) + 0),
571 CLO = ((4U << 3) + 1),
572 DCLZ = ((4U << 3) + 4),
573 DCLO = ((4U << 3) + 5),
576 EXT = ((0U << 3) + 0),
577 DEXTM = ((0U << 3) + 1),
578 DEXTU = ((0U << 3) + 2),
579 DEXT = ((0U << 3) + 3),
580 INS = ((0U << 3) + 4),
581 DINSM = ((0U << 3) + 5),
582 DINSU = ((0U << 3) + 6),
583 DINS = ((0U << 3) + 7),
585 BSHFL = ((4U << 3) + 0),
586 DBSHFL = ((4U << 3) + 4),
587 SC_R6 = ((4U << 3) + 6),
588 SCD_R6 = ((4U << 3) + 7),
589 LL_R6 = ((6U << 3) + 6),
590 LLD_R6 = ((6U << 3) + 7),
593 BITSWAP = ((0U << 3) + 0),
594 ALIGN = ((0U << 3) + 2),
595 WSBH = ((0U << 3) + 2),
596 SEB = ((2U << 3) + 0),
597 SEH = ((3U << 3) + 0),
599 DBITSWAP = ((0U << 3) + 0),
600 DALIGN = ((0U << 3) + 1),
601 DBITSWAP_SA = ((0U << 3) + 0) << kSaShift,
602 DSBH = ((0U << 3) + 2),
603 DSHD = ((0U << 3) + 5),
606 BLTZ = ((0U << 3) + 0) << 16,
607 BGEZ = ((0U << 3) + 1) << 16,
608 BLTZAL = ((2U << 3) + 0) << 16,
609 BGEZAL = ((2U << 3) + 1) << 16,
610 BGEZALL = ((2U << 3) + 3) << 16,
611 DAHI = ((0U << 3) + 6) << 16,
612 DATI = ((3U << 3) + 6) << 16,
615 MFC1 = ((0U << 3) + 0) << 21,
616 DMFC1 = ((0U << 3) + 1) << 21,
617 CFC1 = ((0U << 3) + 2) << 21,
618 MFHC1 = ((0U << 3) + 3) << 21,
619 MTC1 = ((0U << 3) + 4) << 21,
620 DMTC1 = ((0U << 3) + 5) << 21,
621 CTC1 = ((0U << 3) + 6) << 21,
622 MTHC1 = ((0U << 3) + 7) << 21,
623 BC1 = ((1U << 3) + 0) << 21,
624 S = ((2U << 3) + 0) << 21,
625 D = ((2U << 3) + 1) << 21,
626 W = ((2U << 3) + 4) << 21,
627 L = ((2U << 3) + 5) << 21,
628 PS = ((2U << 3) + 6) << 21,
631 ADD_S = ((0U << 3) + 0),
632 SUB_S = ((0U << 3) + 1),
633 MUL_S = ((0U << 3) + 2),
634 DIV_S = ((0U << 3) + 3),
635 ABS_S = ((0U << 3) + 5),
636 SQRT_S = ((0U << 3) + 4),
637 MOV_S = ((0U << 3) + 6),
638 NEG_S = ((0U << 3) + 7),
639 ROUND_L_S = ((1U << 3) + 0),
640 TRUNC_L_S = ((1U << 3) + 1),
641 CEIL_L_S = ((1U << 3) + 2),
642 FLOOR_L_S = ((1U << 3) + 3),
643 ROUND_W_S = ((1U << 3) + 4),
644 TRUNC_W_S = ((1U << 3) + 5),
645 CEIL_W_S = ((1U << 3) + 6),
646 FLOOR_W_S = ((1U << 3) + 7),
647 RECIP_S = ((2U << 3) + 5),
648 RSQRT_S = ((2U << 3) + 6),
649 MADDF_S = ((3U << 3) + 0),
650 MSUBF_S = ((3U << 3) + 1),
651 CLASS_S = ((3U << 3) + 3),
652 CVT_D_S = ((4U << 3) + 1),
653 CVT_W_S = ((4U << 3) + 4),
654 CVT_L_S = ((4U << 3) + 5),
655 CVT_PS_S = ((4U << 3) + 6),
657 ADD_D = ((0U << 3) + 0),
658 SUB_D = ((0U << 3) + 1),
659 MUL_D = ((0U << 3) + 2),
660 DIV_D = ((0U << 3) + 3),
661 SQRT_D = ((0U << 3) + 4),
662 ABS_D = ((0U << 3) + 5),
663 MOV_D = ((0U << 3) + 6),
664 NEG_D = ((0U << 3) + 7),
665 ROUND_L_D = ((1U << 3) + 0),
666 TRUNC_L_D = ((1U << 3) + 1),
667 CEIL_L_D = ((1U << 3) + 2),
668 FLOOR_L_D = ((1U << 3) + 3),
669 ROUND_W_D = ((1U << 3) + 4),
670 TRUNC_W_D = ((1U << 3) + 5),
671 CEIL_W_D = ((1U << 3) + 6),
672 FLOOR_W_D = ((1U << 3) + 7),
673 RECIP_D = ((2U << 3) + 5),
674 RSQRT_D = ((2U << 3) + 6),
675 MADDF_D = ((3U << 3) + 0),
676 MSUBF_D = ((3U << 3) + 1),
677 CLASS_D = ((3U << 3) + 3),
678 MIN = ((3U << 3) + 4),
679 MINA = ((3U << 3) + 5),
680 MAX = ((3U << 3) + 6),
681 MAXA = ((3U << 3) + 7),
682 CVT_S_D = ((4U << 3) + 0),
683 CVT_W_D = ((4U << 3) + 4),
684 CVT_L_D = ((4U << 3) + 5),
685 C_F_D = ((6U << 3) + 0),
686 C_UN_D = ((6U << 3) + 1),
687 C_EQ_D = ((6U << 3) + 2),
688 C_UEQ_D = ((6U << 3) + 3),
689 C_OLT_D = ((6U << 3) + 4),
690 C_ULT_D = ((6U << 3) + 5),
691 C_OLE_D = ((6U << 3) + 6),
692 C_ULE_D = ((6U << 3) + 7),
695 CVT_S_W = ((4U << 3) + 0),
696 CVT_D_W = ((4U << 3) + 1),
697 CVT_S_L = ((4U << 3) + 0),
698 CVT_D_L = ((4U << 3) + 1),
699 BC1EQZ = ((2U << 2) + 1) << 21,
700 BC1NEZ = ((3U << 2) + 1) << 21,
702 CMP_AF = ((0U << 3) + 0),
703 CMP_UN = ((0U << 3) + 1),
704 CMP_EQ = ((0U << 3) + 2),
705 CMP_UEQ = ((0U << 3) + 3),
706 CMP_LT = ((0U << 3) + 4),
707 CMP_ULT = ((0U << 3) + 5),
708 CMP_LE = ((0U << 3) + 6),
709 CMP_ULE = ((0U << 3) + 7),
710 CMP_SAF = ((1U << 3) + 0),
711 CMP_SUN = ((1U << 3) + 1),
712 CMP_SEQ = ((1U << 3) + 2),
713 CMP_SUEQ = ((1U << 3) + 3),
714 CMP_SSLT = ((1U << 3) + 4),
715 CMP_SSULT = ((1U << 3) + 5),
716 CMP_SLE = ((1U << 3) + 6),
717 CMP_SULE = ((1U << 3) + 7),
719 CMP_AT = ((2U << 3) + 0),
720 CMP_OR = ((2U << 3) + 1),
721 CMP_UNE = ((2U << 3) + 2),
722 CMP_NE = ((2U << 3) + 3),
723 CMP_UGE = ((2U << 3) + 4),
724 CMP_OGE = ((2U << 3) + 5),
725 CMP_UGT = ((2U << 3) + 6),
726 CMP_OGT = ((2U << 3) + 7),
727 CMP_SAT = ((3U << 3) + 0),
728 CMP_SOR = ((3U << 3) + 1),
729 CMP_SUNE = ((3U << 3) + 2),
730 CMP_SNE = ((3U << 3) + 3),
731 CMP_SUGE = ((3U << 3) + 4),
732 CMP_SOGE = ((3U << 3) + 5),
733 CMP_SUGT = ((3U << 3) + 6),
734 CMP_SOGT = ((3U << 3) + 7),
736 SEL = ((2U << 3) + 0),
737 MOVF = ((2U << 3) + 1),
738 MOVZ_C = ((2U << 3) + 2),
739 MOVN_C = ((2U << 3) + 3),
740 SELEQZ_C = ((2U << 3) + 4),
741 SELNEZ_C = ((2U << 3) + 7),
746 MADD_S = ((4U << 3) + 0),
747 MADD_D = ((4U << 3) + 1),
748 MSUB_S = ((5U << 3) + 0),
749 MSUB_D = ((5U << 3) + 1),
752 ADDIUPC = ((0U << 2) + 0),
753 LWPC = ((0U << 2) + 1),
754 LWUPC = ((0U << 2) + 2),
755 LDPC = ((0U << 3) + 6),
757 AUIPC = ((3U << 3) + 6),
758 ALUIPC = ((3U << 3) + 7),
761 JIC = ((0U << 5) + 0),
764 JIALC = ((0U << 5) + 0),
767 BZ_V = (((1U << 3) + 3) << kRsShift),
768 BNZ_V = (((1U << 3) + 7) << kRsShift),
769 BZ_B = (((3U << 3) + 0) << kRsShift),
770 BZ_H = (((3U << 3) + 1) << kRsShift),
771 BZ_W = (((3U << 3) + 2) << kRsShift),
772 BZ_D = (((3U << 3) + 3) << kRsShift),
773 BNZ_B = (((3U << 3) + 4) << kRsShift),
774 BNZ_H = (((3U << 3) + 5) << kRsShift),
775 BNZ_W = (((3U << 3) + 6) << kRsShift),
776 BNZ_D = (((3U << 3) + 7) << kRsShift),
781 LD_B = ((8U << 2) + 0),
782 LD_H = ((8U << 2) + 1),
783 LD_W = ((8U << 2) + 2),
784 LD_D = ((8U << 2) + 3),
785 ST_B = ((9U << 2) + 0),
786 ST_H = ((9U << 2) + 1),
787 ST_W = ((9U << 2) + 2),
788 ST_D = ((9U << 2) + 3),
791 ADDVI = ((0U << 23) + 6),
792 SUBVI = ((1U << 23) + 6),
793 MAXI_S = ((2U << 23) + 6),
794 MAXI_U = ((3U << 23) + 6),
795 MINI_S = ((4U << 23) + 6),
796 MINI_U = ((5U << 23) + 6),
797 CEQI = ((0U << 23) + 7),
798 CLTI_S = ((2U << 23) + 7),
799 CLTI_U = ((3U << 23) + 7),
800 CLEI_S = ((4U << 23) + 7),
801 CLEI_U = ((5U << 23) + 7),
802 LDI = ((6U << 23) + 7),
803 I5_DF_b = (0U << 21),
804 I5_DF_h = (1U << 21),
805 I5_DF_w = (2U << 21),
806 I5_DF_d = (3U << 21),
809 ANDI_B = ((0U << 24) + 0),
810 ORI_B = ((1U << 24) + 0),
811 NORI_B = ((2U << 24) + 0),
812 XORI_B = ((3U << 24) + 0),
813 BMNZI_B = ((0U << 24) + 1),
814 BMZI_B = ((1U << 24) + 1),
815 BSELI_B = ((2U << 24) + 1),
816 SHF_B = ((0U << 24) + 2),
817 SHF_H = ((1U << 24) + 2),
818 SHF_W = ((2U << 24) + 2),
820 MSA_VEC_2R_2RF_MINOR = ((3U << 3) + 6),
823 AND_V = (((0U << 2) + 0) << 21),
824 OR_V = (((0U << 2) + 1) << 21),
825 NOR_V = (((0U << 2) + 2) << 21),
826 XOR_V = (((0U << 2) + 3) << 21),
827 BMNZ_V = (((1U << 2) + 0) << 21),
828 BMZ_V = (((1U << 2) + 1) << 21),
829 BSEL_V = (((1U << 2) + 2) << 21),
832 MSA_2R_FORMAT = (((6U << 2) + 0) << 21),
837 MSA_2R_DF_b = (0U << 16),
838 MSA_2R_DF_h = (1U << 16),
839 MSA_2R_DF_w = (2U << 16),
840 MSA_2R_DF_d = (3U << 16),
843 MSA_2RF_FORMAT = (((6U << 2) + 1) << 21),
845 FTRUNC_S = (1U << 17),
846 FTRUNC_U = (2U << 17),
856 FTINT_S = (12U << 17),
857 FTINT_U = (13U << 17),
858 FFINT_S = (14U << 17),
859 FFINT_U = (15U << 17),
860 MSA_2RF_DF_w = (0U << 16),
861 MSA_2RF_DF_d = (1U << 16),
864 SLL_MSA = ((0U << 23) + 13),
865 SRA_MSA = ((1U << 23) + 13),
866 SRL_MSA = ((2U << 23) + 13),
867 BCLR = ((3U << 23) + 13),
868 BSET = ((4U << 23) + 13),
869 BNEG = ((5U << 23) + 13),
870 BINSL = ((6U << 23) + 13),
871 BINSR = ((7U << 23) + 13),
872 ADDV = ((0U << 23) + 14),
873 SUBV = ((1U << 23) + 14),
874 MAX_S = ((2U << 23) + 14),
875 MAX_U = ((3U << 23) + 14),
876 MIN_S = ((4U << 23) + 14),
877 MIN_U = ((5U << 23) + 14),
878 MAX_A = ((6U << 23) + 14),
879 MIN_A = ((7U << 23) + 14),
880 CEQ = ((0U << 23) + 15),
881 CLT_S = ((2U << 23) + 15),
882 CLT_U = ((3U << 23) + 15),
883 CLE_S = ((4U << 23) + 15),
884 CLE_U = ((5U << 23) + 15),
885 ADD_A = ((0U << 23) + 16),
886 ADDS_A = ((1U << 23) + 16),
887 ADDS_S = ((2U << 23) + 16),
888 ADDS_U = ((3U << 23) + 16),
889 AVE_S = ((4U << 23) + 16),
890 AVE_U = ((5U << 23) + 16),
891 AVER_S = ((6U << 23) + 16),
892 AVER_U = ((7U << 23) + 16),
893 SUBS_S = ((0U << 23) + 17),
894 SUBS_U = ((1U << 23) + 17),
895 SUBSUS_U = ((2U << 23) + 17),
896 SUBSUU_S = ((3U << 23) + 17),
897 ASUB_S = ((4U << 23) + 17),
898 ASUB_U = ((5U << 23) + 17),
899 MULV = ((0U << 23) + 18),
900 MADDV = ((1U << 23) + 18),
901 MSUBV = ((2U << 23) + 18),
902 DIV_S_MSA = ((4U << 23) + 18),
903 DIV_U = ((5U << 23) + 18),
904 MOD_S = ((6U << 23) + 18),
905 MOD_U = ((7U << 23) + 18),
906 DOTP_S = ((0U << 23) + 19),
907 DOTP_U = ((1U << 23) + 19),
908 DPADD_S = ((2U << 23) + 19),
909 DPADD_U = ((3U << 23) + 19),
910 DPSUB_S = ((4U << 23) + 19),
911 DPSUB_U = ((5U << 23) + 19),
912 SLD = ((0U << 23) + 20),
913 SPLAT = ((1U << 23) + 20),
914 PCKEV = ((2U << 23) + 20),
915 PCKOD = ((3U << 23) + 20),
916 ILVL = ((4U << 23) + 20),
917 ILVR = ((5U << 23) + 20),
918 ILVEV = ((6U << 23) + 20),
919 ILVOD = ((7U << 23) + 20),
920 VSHF = ((0U << 23) + 21),
921 SRAR = ((1U << 23) + 21),
922 SRLR = ((2U << 23) + 21),
923 HADD_S = ((4U << 23) + 21),
924 HADD_U = ((5U << 23) + 21),
925 HSUB_S = ((6U << 23) + 21),
926 HSUB_U = ((7U << 23) + 21),
927 MSA_3R_DF_b = (0U << 21),
928 MSA_3R_DF_h = (1U << 21),
929 MSA_3R_DF_w = (2U << 21),
930 MSA_3R_DF_d = (3U << 21),
933 FCAF = ((0U << 22) + 26),
934 FCUN = ((1U << 22) + 26),
935 FCEQ = ((2U << 22) + 26),
936 FCUEQ = ((3U << 22) + 26),
937 FCLT = ((4U << 22) + 26),
938 FCULT = ((5U << 22) + 26),
939 FCLE = ((6U << 22) + 26),
940 FCULE = ((7U << 22) + 26),
941 FSAF = ((8U << 22) + 26),
942 FSUN = ((9U << 22) + 26),
943 FSEQ = ((10U << 22) + 26),
944 FSUEQ = ((11U << 22) + 26),
945 FSLT = ((12U << 22) + 26),
946 FSULT = ((13U << 22) + 26),
947 FSLE = ((14U << 22) + 26),
948 FSULE = ((15U << 22) + 26),
949 FADD = ((0U << 22) + 27),
950 FSUB = ((1U << 22) + 27),
951 FMUL = ((2U << 22) + 27),
952 FDIV = ((3U << 22) + 27),
953 FMADD = ((4U << 22) + 27),
954 FMSUB = ((5U << 22) + 27),
955 FEXP2 = ((7U << 22) + 27),
956 FEXDO = ((8U << 22) + 27),
957 FTQ = ((10U << 22) + 27),
958 FMIN = ((12U << 22) + 27),
959 FMIN_A = ((13U << 22) + 27),
960 FMAX = ((14U << 22) + 27),
961 FMAX_A = ((15U << 22) + 27),
962 FCOR = ((1U << 22) + 28),
963 FCUNE = ((2U << 22) + 28),
964 FCNE = ((3U << 22) + 28),
965 MUL_Q = ((4U << 22) + 28),
966 MADD_Q = ((5U << 22) + 28),
967 MSUB_Q = ((6U << 22) + 28),
968 FSOR = ((9U << 22) + 28),
969 FSUNE = ((10U << 22) + 28),
970 FSNE = ((11U << 22) + 28),
971 MULR_Q = ((12U << 22) + 28),
972 MADDR_Q = ((13U << 22) + 28),
973 MSUBR_Q = ((14U << 22) + 28),
976 MSA_ELM_MINOR = ((3U << 3) + 1),
978 CTCMSA = ((0U << 22) | (62U << 16)),
980 CFCMSA = ((1U << 22) | (62U << 16)),
982 MOVE_V = ((2U << 22) | (62U << 16)),
986 ELM_DF_B = ((0U << 4) << 16),
987 ELM_DF_H = ((4U << 3) << 16),
988 ELM_DF_W = ((12U << 2) << 16),
989 ELM_DF_D = ((28U << 1) << 16),
992 SLLI = ((0U << 23) + 9),
993 SRAI = ((1U << 23) + 9),
994 SRLI = ((2U << 23) + 9),
995 BCLRI = ((3U << 23) + 9),
996 BSETI = ((4U << 23) + 9),
997 BNEGI = ((5U << 23) + 9),
998 BINSLI = ((6U << 23) + 9),
999 BINSRI = ((7U << 23) + 9),
1000 SAT_S = ((0U << 23) + 10),
1001 SAT_U = ((1U << 23) + 10),
1002 SRARI = ((2U << 23) + 10),
1003 SRLRI = ((3U << 23) + 10),
1004 BIT_DF_b = ((14U << 3) << 16),
1005 BIT_DF_h = ((6U << 4) << 16),
1006 BIT_DF_w = ((2U << 5) << 16),
1007 BIT_DF_d = ((0U << 6) << 16),
1013 kMsaMinorUndefined = 0,
1057 not_carry = Ugreater_equal,
1060 not_zero = not_equal,
1064 not_sign = positive,
1073 hs = Ugreater_equal,
1077 uge = Ugreater_equal,
1080 cc_default = kNoCondition
1088 inline Condition NegateCondition(Condition cc) {
1089 DCHECK(cc != cc_always);
1090 return static_cast<Condition
>(cc ^ 1);
1094 inline Condition NegateFpuCondition(Condition cc) {
1095 DCHECK(cc != cc_always);
1126 enum MSABranchCondition {
1134 inline MSABranchCondition NegateMSABranchCondition(MSABranchCondition cond) {
1137 return one_elem_zero;
1138 case one_elem_not_zero:
1141 return all_not_zero;
1143 return one_elem_not_zero;
1160 kNoFPUCondition = -1,
1181 enum FPURoundingMode {
1188 kRoundToNearest = RN,
1190 kRoundToPlusInf = RP,
1191 kRoundToMinusInf = RM,
1199 const uint32_t kFPURoundingModeMask = 3 << 0;
1201 enum CheckForInexactConversion {
1202 kCheckForInexactConversion,
1203 kDontCheckForInexactConversion
1206 enum class MaxMinKind :
int { kMin = 0, kMax = 1 };
1219 inline Hint NegateHint(Hint hint) {
1231 extern const Instr kPopInstruction;
1233 extern const Instr kPushInstruction;
1235 extern const Instr kPushRegPattern;
1237 extern const Instr kPopRegPattern;
1238 extern const Instr kLwRegFpOffsetPattern;
1239 extern const Instr kSwRegFpOffsetPattern;
1240 extern const Instr kLwRegFpNegOffsetPattern;
1241 extern const Instr kSwRegFpNegOffsetPattern;
1243 extern const Instr kRtMask;
1244 extern const Instr kLwSwInstrTypeMask;
1245 extern const Instr kLwSwInstrArgumentMask;
1246 extern const Instr kLwSwOffsetMask;
1249 const Instr rtCallRedirInstr = SPECIAL | BREAK | call_rt_redirected << 6;
1251 const Instr nopInstr = 0;
1253 static constexpr uint64_t OpcodeToBitNumber(Opcode opcode) {
1254 return 1ULL << (static_cast<uint32_t>(opcode) >> kOpcodeShift);
1257 constexpr uint8_t kInstrSize = 4;
1258 constexpr uint8_t kInstrSizeLog2 = 2;
1260 class InstructionBase {
1269 enum Type { kRegisterType, kImmediateType, kJumpType, kUnsupported = -1 };
1272 inline Instr InstructionBits()
const {
1273 return *
reinterpret_cast<const Instr*
>(
this);
1277 inline void SetInstructionBits(Instr value) {
1278 *
reinterpret_cast<Instr*
>(
this) = value;
1282 inline int Bit(
int nr)
const {
1283 return (InstructionBits() >> nr) & 1;
1287 inline int Bits(
int hi,
int lo)
const {
1288 return (InstructionBits() >> lo) & ((2U << (hi - lo)) - 1);
1291 static constexpr uint64_t kOpcodeImmediateTypeMask =
1292 OpcodeToBitNumber(REGIMM) | OpcodeToBitNumber(BEQ) |
1293 OpcodeToBitNumber(BNE) | OpcodeToBitNumber(BLEZ) |
1294 OpcodeToBitNumber(BGTZ) | OpcodeToBitNumber(ADDI) |
1295 OpcodeToBitNumber(DADDI) | OpcodeToBitNumber(ADDIU) |
1296 OpcodeToBitNumber(DADDIU) | OpcodeToBitNumber(SLTI) |
1297 OpcodeToBitNumber(SLTIU) | OpcodeToBitNumber(ANDI) |
1298 OpcodeToBitNumber(ORI) | OpcodeToBitNumber(XORI) |
1299 OpcodeToBitNumber(LUI) | OpcodeToBitNumber(BEQL) |
1300 OpcodeToBitNumber(BNEL) | OpcodeToBitNumber(BLEZL) |
1301 OpcodeToBitNumber(BGTZL) | OpcodeToBitNumber(POP66) |
1302 OpcodeToBitNumber(POP76) | OpcodeToBitNumber(LB) | OpcodeToBitNumber(LH) |
1303 OpcodeToBitNumber(LWL) | OpcodeToBitNumber(LW) | OpcodeToBitNumber(LWU) |
1304 OpcodeToBitNumber(LD) | OpcodeToBitNumber(LBU) | OpcodeToBitNumber(LHU) |
1305 OpcodeToBitNumber(LDL) | OpcodeToBitNumber(LDR) | OpcodeToBitNumber(LWR) |
1306 OpcodeToBitNumber(SDL) | OpcodeToBitNumber(SB) | OpcodeToBitNumber(SH) |
1307 OpcodeToBitNumber(SWL) | OpcodeToBitNumber(SW) | OpcodeToBitNumber(SD) |
1308 OpcodeToBitNumber(SWR) | OpcodeToBitNumber(SDR) |
1309 OpcodeToBitNumber(LWC1) | OpcodeToBitNumber(LDC1) |
1310 OpcodeToBitNumber(SWC1) | OpcodeToBitNumber(SDC1) |
1311 OpcodeToBitNumber(PCREL) | OpcodeToBitNumber(DAUI) |
1312 OpcodeToBitNumber(BC) | OpcodeToBitNumber(BALC);
1314 #define FunctionFieldToBitNumber(function) (1ULL << function) 1317 static const uint64_t kFunctionFieldRegisterTypeMask =
1318 FunctionFieldToBitNumber(JR) | FunctionFieldToBitNumber(JALR) |
1319 FunctionFieldToBitNumber(BREAK) | FunctionFieldToBitNumber(SLL) |
1320 FunctionFieldToBitNumber(DSLL) | FunctionFieldToBitNumber(DSLL32) |
1321 FunctionFieldToBitNumber(SRL) | FunctionFieldToBitNumber(DSRL) |
1322 FunctionFieldToBitNumber(DSRL32) | FunctionFieldToBitNumber(SRA) |
1323 FunctionFieldToBitNumber(DSRA) | FunctionFieldToBitNumber(DSRA32) |
1324 FunctionFieldToBitNumber(SLLV) | FunctionFieldToBitNumber(DSLLV) |
1325 FunctionFieldToBitNumber(SRLV) | FunctionFieldToBitNumber(DSRLV) |
1326 FunctionFieldToBitNumber(SRAV) | FunctionFieldToBitNumber(DSRAV) |
1327 FunctionFieldToBitNumber(LSA) | FunctionFieldToBitNumber(DLSA) |
1328 FunctionFieldToBitNumber(MFHI) | FunctionFieldToBitNumber(MFLO) |
1329 FunctionFieldToBitNumber(MULT) | FunctionFieldToBitNumber(DMULT) |
1330 FunctionFieldToBitNumber(MULTU) | FunctionFieldToBitNumber(DMULTU) |
1331 FunctionFieldToBitNumber(DIV) | FunctionFieldToBitNumber(DDIV) |
1332 FunctionFieldToBitNumber(DIVU) | FunctionFieldToBitNumber(DDIVU) |
1333 FunctionFieldToBitNumber(ADD) | FunctionFieldToBitNumber(DADD) |
1334 FunctionFieldToBitNumber(ADDU) | FunctionFieldToBitNumber(DADDU) |
1335 FunctionFieldToBitNumber(SUB) | FunctionFieldToBitNumber(DSUB) |
1336 FunctionFieldToBitNumber(SUBU) | FunctionFieldToBitNumber(DSUBU) |
1337 FunctionFieldToBitNumber(AND) | FunctionFieldToBitNumber(OR) |
1338 FunctionFieldToBitNumber(XOR) | FunctionFieldToBitNumber(NOR) |
1339 FunctionFieldToBitNumber(SLT) | FunctionFieldToBitNumber(SLTU) |
1340 FunctionFieldToBitNumber(TGE) | FunctionFieldToBitNumber(TGEU) |
1341 FunctionFieldToBitNumber(TLT) | FunctionFieldToBitNumber(TLTU) |
1342 FunctionFieldToBitNumber(TEQ) | FunctionFieldToBitNumber(TNE) |
1343 FunctionFieldToBitNumber(MOVZ) | FunctionFieldToBitNumber(MOVN) |
1344 FunctionFieldToBitNumber(MOVCI) | FunctionFieldToBitNumber(SELEQZ_S) |
1345 FunctionFieldToBitNumber(SELNEZ_S) | FunctionFieldToBitNumber(SYNC);
1349 inline Opcode OpcodeValue()
const {
1350 return static_cast<Opcode
>(
1351 Bits(kOpcodeShift + kOpcodeBits - 1, kOpcodeShift));
1354 inline int FunctionFieldRaw()
const {
1355 return InstructionBits() & kFunctionFieldMask;
1359 inline Opcode OpcodeFieldRaw()
const {
1360 return static_cast<Opcode
>(InstructionBits() & kOpcodeMask);
1364 inline int RsFieldRawNoAssert()
const {
1365 return InstructionBits() & kRsFieldMask;
1368 inline int SaFieldRaw()
const {
return InstructionBits() & kSaFieldMask; }
1371 inline Type InstructionType()
const;
1373 inline MSAMinorOpcode MSAMinorOpcodeField()
const {
1374 int op = this->FunctionFieldRaw();
1383 return (((this->InstructionBits() & kMsaI5I10Mask) == LDI)
1388 return kMsaMinorBIT;
1400 return kMsaMinorELM;
1404 return kMsaMinor3RF;
1406 switch (this->RsFieldRawNoAssert()) {
1409 case MSA_2RF_FORMAT:
1410 return kMsaMinor2RF;
1412 return kMsaMinorVEC;
1423 return kMsaMinorMI10;
1425 return kMsaMinorUndefined;
1430 InstructionBase() {}
1434 class InstructionGetters :
public T {
1436 inline int RsValue()
const {
1437 DCHECK(this->InstructionType() == InstructionBase::kRegisterType ||
1438 this->InstructionType() == InstructionBase::kImmediateType);
1439 return this->Bits(kRsShift + kRsBits - 1, kRsShift);
1442 inline int RtValue()
const {
1443 DCHECK(this->InstructionType() == InstructionBase::kRegisterType ||
1444 this->InstructionType() == InstructionBase::kImmediateType);
1445 return this->Bits(kRtShift + kRtBits - 1, kRtShift);
1448 inline int RdValue()
const {
1449 DCHECK_EQ(this->InstructionType(), InstructionBase::kRegisterType);
1450 return this->Bits(kRdShift + kRdBits - 1, kRdShift);
1453 inline int BaseValue()
const {
1454 DCHECK_EQ(this->InstructionType(), InstructionBase::kImmediateType);
1455 return this->Bits(kBaseShift + kBaseBits - 1, kBaseShift);
1458 inline int SaValue()
const {
1459 DCHECK_EQ(this->InstructionType(), InstructionBase::kRegisterType);
1460 return this->Bits(kSaShift + kSaBits - 1, kSaShift);
1463 inline int LsaSaValue()
const {
1464 DCHECK_EQ(this->InstructionType(), InstructionBase::kRegisterType);
1465 return this->Bits(kSaShift + kLsaSaBits - 1, kSaShift);
1468 inline int FunctionValue()
const {
1469 DCHECK(this->InstructionType() == InstructionBase::kRegisterType ||
1470 this->InstructionType() == InstructionBase::kImmediateType);
1471 return this->Bits(kFunctionShift + kFunctionBits - 1, kFunctionShift);
1474 inline int FdValue()
const {
1475 return this->Bits(kFdShift + kFdBits - 1, kFdShift);
1478 inline int FsValue()
const {
1479 return this->Bits(kFsShift + kFsBits - 1, kFsShift);
1482 inline int FtValue()
const {
1483 return this->Bits(kFtShift + kFtBits - 1, kFtShift);
1486 inline int FrValue()
const {
1487 return this->Bits(kFrShift + kFrBits - 1, kFrShift);
1490 inline int WdValue()
const {
1491 return this->Bits(kWdShift + kWdBits - 1, kWdShift);
1494 inline int WsValue()
const {
1495 return this->Bits(kWsShift + kWsBits - 1, kWsShift);
1498 inline int WtValue()
const {
1499 return this->Bits(kWtShift + kWtBits - 1, kWtShift);
1502 inline int Bp2Value()
const {
1503 DCHECK_EQ(this->InstructionType(), InstructionBase::kRegisterType);
1504 return this->Bits(kBp2Shift + kBp2Bits - 1, kBp2Shift);
1507 inline int Bp3Value()
const {
1508 DCHECK_EQ(this->InstructionType(), InstructionBase::kRegisterType);
1509 return this->Bits(kBp3Shift + kBp3Bits - 1, kBp3Shift);
1513 inline int FCccValue()
const {
1514 return this->Bits(kFCccShift + kFCccBits - 1, kFCccShift);
1518 inline int FBccValue()
const {
1519 return this->Bits(kFBccShift + kFBccBits - 1, kFBccShift);
1523 inline int FBtrueValue()
const {
1524 return this->Bits(kFBtrueShift + kFBtrueBits - 1, kFBtrueShift);
1528 inline Opcode OpcodeFieldRaw()
const {
1529 return static_cast<Opcode
>(this->InstructionBits() & kOpcodeMask);
1532 inline int RsFieldRaw()
const {
1533 DCHECK(this->InstructionType() == InstructionBase::kRegisterType ||
1534 this->InstructionType() == InstructionBase::kImmediateType);
1535 return this->InstructionBits() & kRsFieldMask;
1539 inline int RsFieldRawNoAssert()
const {
1540 return this->InstructionBits() & kRsFieldMask;
1543 inline int RtFieldRaw()
const {
1544 DCHECK(this->InstructionType() == InstructionBase::kRegisterType ||
1545 this->InstructionType() == InstructionBase::kImmediateType);
1546 return this->InstructionBits() & kRtFieldMask;
1549 inline int RdFieldRaw()
const {
1550 DCHECK_EQ(this->InstructionType(), InstructionBase::kRegisterType);
1551 return this->InstructionBits() & kRdFieldMask;
1554 inline int SaFieldRaw()
const {
1555 return this->InstructionBits() & kSaFieldMask;
1558 inline int FunctionFieldRaw()
const {
1559 return this->InstructionBits() & kFunctionFieldMask;
1563 inline int SecondaryValue()
const {
1564 Opcode op = this->OpcodeFieldRaw();
1568 return FunctionValue();
1578 inline int32_t ImmValue(
int bits)
const {
1579 DCHECK_EQ(this->InstructionType(), InstructionBase::kImmediateType);
1580 return this->Bits(bits - 1, 0);
1583 inline int32_t Imm9Value()
const {
1584 DCHECK_EQ(this->InstructionType(), InstructionBase::kImmediateType);
1585 return this->Bits(kImm9Shift + kImm9Bits - 1, kImm9Shift);
1588 inline int32_t Imm16Value()
const {
1589 DCHECK_EQ(this->InstructionType(), InstructionBase::kImmediateType);
1590 return this->Bits(kImm16Shift + kImm16Bits - 1, kImm16Shift);
1593 inline int32_t Imm18Value()
const {
1594 DCHECK_EQ(this->InstructionType(), InstructionBase::kImmediateType);
1595 return this->Bits(kImm18Shift + kImm18Bits - 1, kImm18Shift);
1598 inline int32_t Imm19Value()
const {
1599 DCHECK_EQ(this->InstructionType(), InstructionBase::kImmediateType);
1600 return this->Bits(kImm19Shift + kImm19Bits - 1, kImm19Shift);
1603 inline int32_t Imm21Value()
const {
1604 DCHECK_EQ(this->InstructionType(), InstructionBase::kImmediateType);
1605 return this->Bits(kImm21Shift + kImm21Bits - 1, kImm21Shift);
1608 inline int32_t Imm26Value()
const {
1609 DCHECK((this->InstructionType() == InstructionBase::kJumpType) ||
1610 (this->InstructionType() == InstructionBase::kImmediateType));
1611 return this->Bits(kImm26Shift + kImm26Bits - 1, kImm26Shift);
1614 inline int32_t MsaImm8Value()
const {
1615 DCHECK_EQ(this->InstructionType(), InstructionBase::kImmediateType);
1616 return this->Bits(kMsaImm8Shift + kMsaImm8Bits - 1, kMsaImm8Shift);
1619 inline int32_t MsaImm5Value()
const {
1620 DCHECK_EQ(this->InstructionType(), InstructionBase::kImmediateType);
1621 return this->Bits(kMsaImm5Shift + kMsaImm5Bits - 1, kMsaImm5Shift);
1624 inline int32_t MsaImm10Value()
const {
1625 DCHECK_EQ(this->InstructionType(), InstructionBase::kImmediateType);
1626 return this->Bits(kMsaImm10Shift + kMsaImm10Bits - 1, kMsaImm10Shift);
1629 inline int32_t MsaImmMI10Value()
const {
1630 DCHECK_EQ(this->InstructionType(), InstructionBase::kImmediateType);
1631 return this->Bits(kMsaImmMI10Shift + kMsaImmMI10Bits - 1, kMsaImmMI10Shift);
1634 inline int32_t MsaBitDf()
const {
1635 DCHECK_EQ(this->InstructionType(), InstructionBase::kImmediateType);
1636 int32_t df_m = this->Bits(22, 16);
1637 if (((df_m >> 6) & 1U) == 0) {
1639 }
else if (((df_m >> 5) & 3U) == 2) {
1641 }
else if (((df_m >> 4) & 7U) == 6) {
1643 }
else if (((df_m >> 3) & 15U) == 14) {
1650 inline int32_t MsaBitMValue()
const {
1651 DCHECK_EQ(this->InstructionType(), InstructionBase::kImmediateType);
1652 return this->Bits(16 + this->MsaBitDf() + 3, 16);
1655 inline int32_t MsaElmDf()
const {
1656 DCHECK(this->InstructionType() == InstructionBase::kRegisterType ||
1657 this->InstructionType() == InstructionBase::kImmediateType);
1658 int32_t df_n = this->Bits(21, 16);
1659 if (((df_n >> 4) & 3U) == 0) {
1661 }
else if (((df_n >> 3) & 7U) == 4) {
1663 }
else if (((df_n >> 2) & 15U) == 12) {
1665 }
else if (((df_n >> 1) & 31U) == 28) {
1672 inline int32_t MsaElmNValue()
const {
1673 DCHECK(this->InstructionType() == InstructionBase::kRegisterType ||
1674 this->InstructionType() == InstructionBase::kImmediateType);
1675 return this->Bits(16 + 4 - this->MsaElmDf(), 16);
1678 static bool IsForbiddenAfterBranchInstr(Instr instr);
1682 inline bool IsForbiddenAfterBranch()
const {
1683 return IsForbiddenAfterBranchInstr(this->InstructionBits());
1686 inline bool IsForbiddenInBranchDelay()
const {
1687 return IsForbiddenAfterBranch();
1691 bool IsLinkingInstruction()
const;
1693 bool IsTrap()
const;
1695 inline bool IsMSABranchInstr()
const {
1696 if (this->OpcodeFieldRaw() == COP1) {
1697 switch (this->RsFieldRaw()) {
1716 inline bool IsMSAInstr()
const {
1717 if (this->IsMSABranchInstr() || (this->OpcodeFieldRaw() == MSA))
1723 class Instruction :
public InstructionGetters<InstructionBase> {
1729 static Instruction* At(byte* pc) {
1730 return reinterpret_cast<Instruction*
>(pc);
1735 DISALLOW_IMPLICIT_CONSTRUCTORS(Instruction);
1743 const int kCArgSlotCount = 0;
1747 const int kCArgsSlotsSize = kCArgSlotCount * kInstrSize * 2;
1749 const int kInvalidStackOffset = -1;
1750 const int kBranchReturnOffset = 2 * kInstrSize;
1752 static const int kNegOffset = 0x00008000;
1754 InstructionBase::Type InstructionBase::InstructionType()
const {
1755 switch (OpcodeFieldRaw()) {
1757 if (FunctionFieldToBitNumber(FunctionFieldRaw()) &
1758 kFunctionFieldRegisterTypeMask) {
1759 return kRegisterType;
1761 return kUnsupported;
1763 switch (FunctionFieldRaw()) {
1767 return kRegisterType;
1769 return kUnsupported;
1773 switch (FunctionFieldRaw()) {
1782 return kRegisterType;
1784 int sa = SaFieldRaw() >> kSaShift;
1790 return kRegisterType;
1795 return kRegisterType;
1797 return kUnsupported;
1804 DCHECK_EQ(kArchVariant, kMips64r6);
1805 return kImmediateType;
1808 int sa = SaFieldRaw() >> kSaShift;
1813 return kRegisterType;
1815 sa = SaFieldRaw() >> kSaShift;
1819 return kRegisterType;
1821 return kUnsupported;
1825 return kUnsupported;
1829 switch (RsFieldRawNoAssert()) {
1833 return kImmediateType;
1845 return kImmediateType;
1847 return kRegisterType;
1851 return kRegisterType;
1859 switch (MSAMinorOpcodeField()) {
1865 return kRegisterType;
1867 switch (InstructionBits() & kMsaLongerELMMask) {
1871 return kRegisterType;
1873 return kImmediateType;
1876 return kImmediateType;
1880 return kImmediateType;
1882 return kUnsupported;
1884 #undef OpcodeToBitNumber 1885 #undef FunctionFieldToBitNumber 1891 bool InstructionGetters<P>::IsLinkingInstruction()
const {
1892 switch (OpcodeFieldRaw()) {
1896 if (RsFieldRawNoAssert() == JIALC)
1901 switch (RtFieldRaw()) {
1909 switch (FunctionFieldRaw()) {
1921 bool InstructionGetters<P>::IsTrap()
const {
1922 if (OpcodeFieldRaw() != SPECIAL) {
1925 switch (FunctionFieldRaw()) {
1942 bool InstructionGetters<T>::IsForbiddenAfterBranchInstr(Instr instr) {
1943 Opcode opcode =
static_cast<Opcode
>(instr & kOpcodeMask);
1963 switch (instr & kRtFieldMask) {
1974 switch (instr & kFunctionFieldMask) {
1983 switch (instr & kRsFieldMask) {
2010 #endif // V8_MIPS64_CONSTANTS_MIPS64_H_