33 #define DEBUG_TYPE "mips-disassembler"
47 IsBigEndian(IsBigEndian) {}
49 bool hasMips2()
const {
return STI.
getFeatureBits()[Mips::FeatureMips2]; }
50 bool hasMips3()
const {
return STI.
getFeatureBits()[Mips::FeatureMips3]; }
51 bool hasMips32()
const {
return STI.
getFeatureBits()[Mips::FeatureMips32]; }
53 bool hasMips32r6()
const {
57 bool isFP64()
const {
return STI.
getFeatureBits()[Mips::FeatureFP64Bit]; }
59 bool isGP64()
const {
return STI.
getFeatureBits()[Mips::FeatureGP64Bit]; }
61 bool isPTR64()
const {
return STI.
getFeatureBits()[Mips::FeaturePTR64Bit]; }
63 bool hasCnMips()
const {
return STI.
getFeatureBits()[Mips::FeatureCnMips]; }
65 bool hasCOP3()
const {
67 return !hasMips32() && !hasMips3();
103 const void *Decoder);
108 const void *Decoder);
113 const void *Decoder);
118 const void *Decoder);
123 const void *Decoder);
128 const void *Decoder);
133 const void *Decoder);
138 const void *Decoder);
142 const void *Decoder);
147 const void *Decoder);
152 const void *Decoder);
157 const void *Decoder);
162 const void *Decoder);
167 const void *Decoder);
172 const void *Decoder);
177 const void *Decoder);
182 const void *Decoder);
187 const void *Decoder);
192 const void *Decoder);
197 const void *Decoder);
202 const void *Decoder);
207 const void *Decoder);
212 const void *Decoder);
217 const void *Decoder);
222 const void *Decoder);
227 const void *Decoder);
232 const void *Decoder);
239 const void *Decoder);
246 const void *Decoder);
253 const void *Decoder);
260 const void *Decoder);
267 const void *Decoder);
272 const void *Decoder);
277 const void *Decoder);
282 const void *Decoder);
287 const void *Decoder);
292 const void *Decoder);
297 const void *Decoder);
302 const void *Decoder);
307 const void *Decoder);
312 const void *Decoder);
317 const void *Decoder);
322 const void *Decoder);
325 uint64_t
Address,
const void *Decoder);
330 const void *Decoder);
335 const void *Decoder);
340 const void *Decoder);
345 const void *Decoder);
350 const void *Decoder);
355 const void *Decoder);
360 const void *Decoder);
364 const void *Decoder);
368 const void *Decoder);
372 const void *Decoder);
376 const void *Decoder);
380 const void *Decoder);
384 const void *Decoder);
389 const void *Decoder);
394 const void *Decoder);
399 const void *Decoder);
404 const void *Decoder);
406 template <
unsigned Bits,
int Offset,
int Scale>
409 const void *Decoder);
411 template <
unsigned Bits,
int Offset>
414 const void *Decoder) {
415 return DecodeUImmWithOffsetAndScale<Bits, Offset, 1>(Inst, Value,
Address,
419 template <
unsigned Bits,
int Offset = 0,
int ScaleBy = 1>
422 const void *Decoder);
427 const void *Decoder);
430 uint64_t
Address,
const void *Decoder);
433 uint64_t
Address,
const void *Decoder);
436 uint64_t
Address,
const void *Decoder);
439 uint64_t
Address,
const void *Decoder);
442 uint64_t
Address,
const void *Decoder);
446 template <
typename InsnType>
448 const void *Decoder);
450 template <
typename InsnType>
452 const void *Decoder);
454 template <
typename InsnType>
456 const void *Decoder);
458 template <
typename InsnType>
460 const void *Decoder);
462 template <
typename InsnType>
464 const void *Decoder);
466 template <
typename InsnType>
469 const void *Decoder);
471 template <
typename InsnType>
474 const void *Decoder);
476 template <
typename InsnType>
479 const void *Decoder);
481 template <
typename InsnType>
484 const void *Decoder);
486 template <
typename InsnType>
489 const void *Decoder);
491 template <
typename InsnType>
494 const void *Decoder);
496 template <
typename InsnType>
499 const void *Decoder);
501 template <
typename InsnType>
504 const void *Decoder);
506 template <
typename InsnType>
509 const void *Decoder);
511 template <
typename InsnType>
514 const void *Decoder);
516 template <
typename InsnType>
519 const void *Decoder);
521 template <
typename InsnType>
524 const void *Decoder);
528 const void *Decoder);
532 const void *Decoder);
536 const void *Decoder);
551 return new MipsDisassembler(STI, Ctx,
true);
558 return new MipsDisassembler(STI, Ctx,
false);
573 #include "MipsGenDisassemblerTables.inc"
575 static unsigned getReg(
const void *
D,
unsigned RC,
unsigned RegNo) {
576 const MipsDisassembler *Dis =
static_cast<const MipsDisassembler*
>(
D);
577 const MCRegisterInfo *RegInfo = Dis->getContext().getRegisterInfo();
581 template <
typename InsnType>
583 const void *Decoder) {
587 InsnType tmp = fieldFromInstruction(insn, 17, 5);
589 DecodeFN RegDecoder =
nullptr;
590 if ((tmp & 0x18) == 0x00) {
593 }
else if ((tmp & 0x1c) == 0x10) {
596 }
else if ((tmp & 0x1e) == 0x18) {
599 }
else if ((tmp & 0x1f) == 0x1c) {
605 assert(NSize != 0 && RegDecoder !=
nullptr);
608 tmp = fieldFromInstruction(insn, 6, 5);
615 tmp = fieldFromInstruction(insn, 16, NSize);
618 tmp = fieldFromInstruction(insn, 11, 5);
627 template <
typename InsnType>
629 const void *Decoder) {
630 InsnType Rs = fieldFromInstruction(insn, 16, 5);
631 InsnType Imm = fieldFromInstruction(insn, 0, 16);
641 template <
typename InsnType>
643 const void *Decoder) {
644 InsnType Rs = fieldFromInstruction(insn, 21, 5);
645 InsnType Imm = fieldFromInstruction(insn, 0, 16);
655 template <
typename InsnType>
658 const void *Decoder) {
669 InsnType Rs = fieldFromInstruction(insn, 21, 5);
670 InsnType Rt = fieldFromInstruction(insn, 16, 5);
671 int64_t Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
677 }
else if (Rs != 0 && Rs < Rt) {
694 template <
typename InsnType>
697 const void *Decoder) {
698 InsnType Rt = fieldFromInstruction(insn, 21, 5);
699 InsnType Rs = fieldFromInstruction(insn, 16, 5);
708 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 2 + 4;
709 }
else if (Rs != 0 && Rs < Rt) {
715 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
720 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 2 + 4;
728 template <
typename InsnType>
731 const void *Decoder) {
742 InsnType Rs = fieldFromInstruction(insn, 21, 5);
743 InsnType Rt = fieldFromInstruction(insn, 16, 5);
744 int64_t Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
750 }
else if (Rs != 0 && Rs < Rt) {
767 template <
typename InsnType>
770 const void *Decoder) {
771 InsnType Rt = fieldFromInstruction(insn, 21, 5);
772 InsnType Rs = fieldFromInstruction(insn, 16, 5);
781 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 2 + 4;
782 }
else if (Rs != 0 && Rs < Rt) {
788 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
793 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 2 + 4;
801 template <
typename InsnType>
804 const void *Decoder) {
812 InsnType Rt = fieldFromInstruction(insn, 21, 5);
813 InsnType Rs = fieldFromInstruction(insn, 16, 5);
814 int64_t Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
840 template <
typename InsnType>
843 const void *Decoder) {
851 InsnType Rt = fieldFromInstruction(insn, 21, 5);
852 InsnType Rs = fieldFromInstruction(insn, 16, 5);
853 int64_t Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
879 template <
typename InsnType>
882 const void *Decoder) {
894 InsnType Rs = fieldFromInstruction(insn, 21, 5);
895 InsnType Rt = fieldFromInstruction(insn, 16, 5);
896 int64_t Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
922 template <
typename InsnType>
925 const void *Decoder) {
939 InsnType Rs = fieldFromInstruction(insn, 21, 5);
940 InsnType Rt = fieldFromInstruction(insn, 16, 5);
941 int64_t Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
966 template <
typename InsnType>
969 const void *Decoder) {
981 InsnType Rs = fieldFromInstruction(insn, 21, 5);
982 InsnType Rt = fieldFromInstruction(insn, 16, 5);
983 int64_t Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
990 }
else if (Rs == 0) {
993 }
else if (Rs == Rt) {
1015 template <
typename InsnType>
1018 const void *Decoder) {
1030 InsnType Rs = fieldFromInstruction(insn, 21, 5);
1031 InsnType Rt = fieldFromInstruction(insn, 16, 5);
1032 int64_t Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
1063 if (Bytes.
size() < 2) {
1069 Insn = (Bytes[0] << 8) | Bytes[1];
1071 Insn = (Bytes[1] << 8) | Bytes[0];
1081 bool IsBigEndian,
bool IsMicroMips) {
1083 if (Bytes.
size() < 4) {
1099 (Bytes[3] << 0) | (Bytes[2] << 8) | (Bytes[1] << 16) | (Bytes[0] << 24);
1102 Insn = (Bytes[2] << 0) | (Bytes[3] << 8) | (Bytes[0] << 16) |
1105 Insn = (Bytes[0] << 0) | (Bytes[1] << 8) | (Bytes[2] << 16) |
1127 if (hasMips32r6()) {
1128 DEBUG(
dbgs() <<
"Trying MicroMipsR616 table (16-bit instructions):\n");
1132 Address,
this, STI);
1139 DEBUG(
dbgs() <<
"Trying MicroMips16 table (16-bit instructions):\n");
1153 if (hasMips32r6()) {
1154 DEBUG(
dbgs() <<
"Trying MicroMips32r632 table (32-bit instructions):\n");
1164 DEBUG(
dbgs() <<
"Trying MicroMips32 table (32-bit instructions):\n");
1173 if (hasMips32r6() && isFP64()) {
1174 DEBUG(
dbgs() <<
"Trying MicroMips32r6FP64 table (32-bit opcodes):\n");
1176 Address,
this, STI);
1203 DEBUG(
dbgs() <<
"Trying COP3_ table (32-bit opcodes):\n");
1210 if (hasMips32r6() && isGP64()) {
1211 DEBUG(
dbgs() <<
"Trying Mips32r6_64r6 (GPR64) table (32-bit opcodes):\n");
1213 Address,
this, STI);
1218 if (hasMips32r6() && isPTR64()) {
1219 DEBUG(
dbgs() <<
"Trying Mips32r6_64r6 (PTR64) table (32-bit opcodes):\n");
1221 Address,
this, STI);
1226 if (hasMips32r6()) {
1227 DEBUG(
dbgs() <<
"Trying Mips32r6_64r6 table (32-bit opcodes):\n");
1229 Address,
this, STI);
1234 if (hasMips2() && isPTR64()) {
1235 DEBUG(
dbgs() <<
"Trying Mips32r6_64r6 (PTR64) table (32-bit opcodes):\n");
1237 Address,
this, STI);
1243 DEBUG(
dbgs() <<
"Trying CnMips table (32-bit opcodes):\n");
1245 Address,
this, STI);
1251 DEBUG(
dbgs() <<
"Trying Mips64 (GPR64) table (32-bit opcodes):\n");
1253 Address,
this, STI);
1258 DEBUG(
dbgs() <<
"Trying Mips table (32-bit opcodes):\n");
1271 const void *Decoder) {
1278 const void *Decoder) {
1282 unsigned Reg =
getReg(Decoder, Mips::GPR64RegClassID, RegNo);
1290 const void *Decoder) {
1293 unsigned Reg =
getReg(Decoder, Mips::GPRMM16RegClassID, RegNo);
1301 const void *Decoder) {
1304 unsigned Reg =
getReg(Decoder, Mips::GPRMM16ZeroRegClassID, RegNo);
1312 const void *Decoder) {
1315 unsigned Reg =
getReg(Decoder, Mips::GPRMM16MovePRegClassID, RegNo);
1323 const void *Decoder) {
1326 unsigned Reg =
getReg(Decoder, Mips::GPR32RegClassID, RegNo);
1334 const void *Decoder) {
1335 if (static_cast<const MipsDisassembler *>(Decoder)->isGP64())
1344 const void *Decoder) {
1351 const void *Decoder) {
1355 unsigned Reg =
getReg(Decoder, Mips::FGR64RegClassID, RegNo);
1363 const void *Decoder) {
1367 unsigned Reg =
getReg(Decoder, Mips::FGR32RegClassID, RegNo);
1375 const void *Decoder) {
1378 unsigned Reg =
getReg(Decoder, Mips::CCRRegClassID, RegNo);
1386 const void *Decoder) {
1389 unsigned Reg =
getReg(Decoder, Mips::FCCRegClassID, RegNo);
1396 const void *Decoder) {
1400 unsigned Reg =
getReg(Decoder, Mips::FGRCCRegClassID, RegNo);
1408 const void *Decoder) {
1409 int Offset = SignExtend32<16>(Insn & 0xffff);
1410 unsigned Reg = fieldFromInstruction(Insn, 16, 5);
1411 unsigned Base = fieldFromInstruction(Insn, 21, 5);
1413 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1414 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1430 const void *Decoder) {
1431 int Offset = SignExtend32<9>(Insn >> 7);
1432 unsigned Reg = fieldFromInstruction(Insn, 16, 5);
1433 unsigned Base = fieldFromInstruction(Insn, 21, 5);
1435 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1436 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1451 const void *Decoder) {
1452 int Offset = SignExtend32<9>(Insn & 0x1ff);
1453 unsigned Base = fieldFromInstruction(Insn, 16, 5);
1454 unsigned Reg = fieldFromInstruction(Insn, 21, 5);
1456 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1457 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1469 const void *Decoder) {
1470 int Offset = SignExtend32<16>(Insn & 0xffff);
1471 unsigned Base = fieldFromInstruction(Insn, 16, 5);
1472 unsigned Reg = fieldFromInstruction(Insn, 21, 5);
1474 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1475 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1487 const void *Decoder) {
1488 int Offset = SignExtend32<16>(Insn & 0xffff);
1489 unsigned Hint = fieldFromInstruction(Insn, 16, 5);
1490 unsigned Base = fieldFromInstruction(Insn, 21, 5);
1492 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1504 const void *Decoder) {
1505 int Offset = SignExtend32<12>(Insn & 0xfff);
1506 unsigned Base = fieldFromInstruction(Insn, 16, 5);
1507 unsigned Hint = fieldFromInstruction(Insn, 21, 5);
1509 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1521 const void *Decoder) {
1522 int Offset = SignExtend32<9>(Insn & 0x1ff);
1523 unsigned Base = fieldFromInstruction(Insn, 16, 5);
1524 unsigned Hint = fieldFromInstruction(Insn, 21, 5);
1526 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1538 const void *Decoder) {
1539 int Offset = SignExtend32<9>(Insn >> 7);
1540 unsigned Hint = fieldFromInstruction(Insn, 16, 5);
1541 unsigned Base = fieldFromInstruction(Insn, 21, 5);
1543 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1555 const void *Decoder) {
1556 int Offset = SignExtend32<9>(Insn & 0x1ff);
1557 unsigned Reg = fieldFromInstruction(Insn, 21, 5);
1558 unsigned Base = fieldFromInstruction(Insn, 16, 5);
1560 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1561 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1573 const void *Decoder) {
1574 int Offset = SignExtend32<16>(Insn & 0xffff);
1575 unsigned Base = fieldFromInstruction(Insn, 21, 5);
1577 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1588 const void *Decoder) {
1589 int Immediate = SignExtend32<16>(Insn & 0xffff);
1590 unsigned Base = fieldFromInstruction(Insn, 16, 5);
1592 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1601 uint64_t Address,
const void *Decoder) {
1602 int Offset = SignExtend32<10>(fieldFromInstruction(Insn, 16, 10));
1603 unsigned Reg = fieldFromInstruction(Insn, 6, 5);
1604 unsigned Base = fieldFromInstruction(Insn, 11, 5);
1606 Reg =
getReg(Decoder, Mips::MSA128BRegClassID, Reg);
1607 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1622 assert(
false &&
"Unexpected instruction");
1649 const void *Decoder) {
1650 unsigned Offset = Insn & 0xf;
1651 unsigned Reg = fieldFromInstruction(Insn, 7, 3);
1652 unsigned Base = fieldFromInstruction(Insn, 4, 3);
1655 case Mips::LBU16_MM:
1656 case Mips::LHU16_MM:
1663 case Mips::SB16_MMR6:
1665 case Mips::SH16_MMR6:
1667 case Mips::SW16_MMR6:
1679 case Mips::LBU16_MM:
1686 case Mips::SB16_MMR6:
1689 case Mips::LHU16_MM:
1691 case Mips::SH16_MMR6:
1696 case Mips::SW16_MMR6:
1707 const void *Decoder) {
1708 unsigned Offset = Insn & 0x1F;
1709 unsigned Reg = fieldFromInstruction(Insn, 5, 5);
1711 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1723 const void *Decoder) {
1724 unsigned Offset = Insn & 0x7F;
1725 unsigned Reg = fieldFromInstruction(Insn, 7, 3);
1727 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1739 const void *Decoder) {
1742 case Mips::LWM16_MMR6:
1743 case Mips::SWM16_MMR6:
1744 Offset = fieldFromInstruction(Insn, 4, 4);
1747 Offset = SignExtend32<4>(Insn & 0xf);
1764 const void *Decoder) {
1765 int Offset = SignExtend32<9>(Insn & 0x1ff);
1766 unsigned Reg = fieldFromInstruction(Insn, 21, 5);
1767 unsigned Base = fieldFromInstruction(Insn, 16, 5);
1769 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1770 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1785 const void *Decoder) {
1786 int Offset = SignExtend32<12>(Insn & 0x0fff);
1787 unsigned Reg = fieldFromInstruction(Insn, 21, 5);
1788 unsigned Base = fieldFromInstruction(Insn, 16, 5);
1790 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1791 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1794 case Mips::SWM32_MM:
1795 case Mips::LWM32_MM:
1821 const void *Decoder) {
1822 int Offset = SignExtend32<16>(Insn & 0xffff);
1823 unsigned Reg = fieldFromInstruction(Insn, 21, 5);
1824 unsigned Base = fieldFromInstruction(Insn, 16, 5);
1826 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1827 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1839 const void *Decoder) {
1840 int Offset = SignExtend32<16>(Insn & 0xffff);
1841 unsigned Reg = fieldFromInstruction(Insn, 16, 5);
1842 unsigned Base = fieldFromInstruction(Insn, 21, 5);
1844 Reg =
getReg(Decoder, Mips::FGR64RegClassID, Reg);
1845 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1855 uint64_t Address,
const void *Decoder) {
1858 int Offset = SignExtend32<16>(Insn & 0xffff);
1859 unsigned Base = fieldFromInstruction(Insn, 16, 5);
1860 unsigned Reg = fieldFromInstruction(Insn, 21, 5);
1862 Reg =
getReg(Decoder, Mips::FGR64RegClassID, Reg);
1863 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1875 const void *Decoder) {
1876 int Offset = SignExtend32<16>(Insn & 0xffff);
1877 unsigned Reg = fieldFromInstruction(Insn, 16, 5);
1878 unsigned Base = fieldFromInstruction(Insn, 21, 5);
1880 Reg =
getReg(Decoder, Mips::COP2RegClassID, Reg);
1881 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1893 const void *Decoder) {
1894 int Offset = SignExtend32<16>(Insn & 0xffff);
1895 unsigned Reg = fieldFromInstruction(Insn, 16, 5);
1896 unsigned Base = fieldFromInstruction(Insn, 21, 5);
1898 Reg =
getReg(Decoder, Mips::COP3RegClassID, Reg);
1899 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1911 const void *Decoder) {
1912 int Offset = SignExtend32<11>(Insn & 0x07ff);
1913 unsigned Reg = fieldFromInstruction(Insn, 16, 5);
1914 unsigned Base = fieldFromInstruction(Insn, 11, 5);
1916 Reg =
getReg(Decoder, Mips::COP2RegClassID, Reg);
1917 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1927 uint64_t Address,
const void *Decoder) {
1928 int Offset = SignExtend32<11>(Insn & 0x07ff);
1929 unsigned Reg = fieldFromInstruction(Insn, 21, 5);
1930 unsigned Base = fieldFromInstruction(Insn, 16, 5);
1932 Reg =
getReg(Decoder, Mips::COP2RegClassID, Reg);
1933 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1945 const void *Decoder) {
1946 int64_t
Offset = SignExtend64<9>((Insn >> 7) & 0x1ff);
1947 unsigned Rt = fieldFromInstruction(Insn, 16, 5);
1948 unsigned Base = fieldFromInstruction(Insn, 21, 5);
1950 Rt =
getReg(Decoder, Mips::GPR32RegClassID, Rt);
1951 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1967 const void *Decoder) {
1978 const void *Decoder) {
1979 if (RegNo > 30 || RegNo %2)
1982 unsigned Reg =
getReg(Decoder, Mips::AFGR64RegClassID, RegNo /2);
1990 const void *Decoder) {
1994 unsigned Reg =
getReg(Decoder, Mips::ACC64DSPRegClassID, RegNo);
2002 const void *Decoder) {
2006 unsigned Reg =
getReg(Decoder, Mips::HI32DSPRegClassID, RegNo);
2014 const void *Decoder) {
2018 unsigned Reg =
getReg(Decoder, Mips::LO32DSPRegClassID, RegNo);
2026 const void *Decoder) {
2030 unsigned Reg =
getReg(Decoder, Mips::MSA128BRegClassID, RegNo);
2038 const void *Decoder) {
2042 unsigned Reg =
getReg(Decoder, Mips::MSA128HRegClassID, RegNo);
2050 const void *Decoder) {
2054 unsigned Reg =
getReg(Decoder, Mips::MSA128WRegClassID, RegNo);
2062 const void *Decoder) {
2066 unsigned Reg =
getReg(Decoder, Mips::MSA128DRegClassID, RegNo);
2074 const void *Decoder) {
2078 unsigned Reg =
getReg(Decoder, Mips::MSACtrlRegClassID, RegNo);
2086 const void *Decoder) {
2090 unsigned Reg =
getReg(Decoder, Mips::COP0RegClassID, RegNo);
2098 const void *Decoder) {
2102 unsigned Reg =
getReg(Decoder, Mips::COP2RegClassID, RegNo);
2110 const void *Decoder) {
2111 int32_t BranchOffset = (SignExtend32<16>(
Offset) * 4) + 4;
2119 const void *Decoder) {
2120 int32_t BranchOffset = (SignExtend32<16>(
Offset) * 2);
2128 const void *Decoder) {
2129 unsigned JumpOffset = fieldFromInstruction(Insn, 0, 26) << 2;
2137 const void *Decoder) {
2138 int32_t BranchOffset = SignExtend32<21>(
Offset) * 4 + 4;
2147 const void *Decoder) {
2148 int32_t BranchOffset = SignExtend32<21>(
Offset) * 4 + 4;
2157 const void *Decoder) {
2158 int32_t BranchOffset = SignExtend32<26>(
Offset) * 4 + 4;
2167 const void *Decoder) {
2168 int32_t BranchOffset = SignExtend32<7>(
Offset) << 1;
2176 const void *Decoder) {
2177 int32_t BranchOffset = SignExtend32<10>(
Offset) << 1;
2185 const void *Decoder) {
2186 int32_t BranchOffset = SignExtend32<16>(
Offset) * 2 + 4;
2194 const void *Decoder) {
2195 int32_t BranchOffset = SignExtend32<26>(
Offset) << 1;
2204 const void *Decoder) {
2205 unsigned JumpOffset = fieldFromInstruction(Insn, 0, 26) << 1;
2213 const void *Decoder) {
2216 else if (Value == 0x7)
2226 const void *Decoder) {
2237 const void *Decoder) {
2242 template <
unsigned Bits,
int Offset,
int Scale>
2245 const void *Decoder) {
2246 Value &= ((1 <<
Bits) - 1);
2252 template <
unsigned Bits,
int Offset,
int ScaleBy>
2255 const void *Decoder) {
2256 int32_t Imm = SignExtend32<Bits>(Value) * ScaleBy;
2264 const void *Decoder) {
2272 Size = (
int) Insn - Pos + 33;
2274 Size = (int) Insn - Pos + 1;
2280 uint64_t Address,
const void *Decoder) {
2286 uint64_t Address,
const void *Decoder) {
2292 uint64_t Address,
const void *Decoder) {
2293 int32_t DecodedValue;
2295 case 0: DecodedValue = 256;
break;
2296 case 1: DecodedValue = 257;
break;
2297 case 510: DecodedValue = -258;
break;
2298 case 511: DecodedValue = -257;
break;
2299 default: DecodedValue = SignExtend32<9>(Insn);
break;
2306 uint64_t Address,
const void *Decoder) {
2309 int32_t DecodedValues[] = {128, 1, 2, 3, 4, 7, 8, 15, 16, 31, 32, 63, 64,
2318 const void *Decoder) {
2319 unsigned Regs[] = {Mips::S0, Mips::S1, Mips::S2, Mips::S3, Mips::S4, Mips::S5,
2320 Mips::S6, Mips::S7, Mips::FP};
2323 unsigned RegLst = fieldFromInstruction(Insn, 21, 5);
2329 RegNum = RegLst & 0xf;
2335 for (
unsigned i = 0; i < RegNum; i++)
2346 const void *Decoder) {
2347 unsigned Regs[] = {Mips::S0, Mips::S1, Mips::S2, Mips::S3};
2351 RegLst = fieldFromInstruction(Insn, 4, 2);
2353 case Mips::LWM16_MMR6:
2354 case Mips::SWM16_MMR6:
2355 RegLst = fieldFromInstruction(Insn, 8, 2);
2358 unsigned RegNum = RegLst & 0x3;
2360 for (
unsigned i = 0; i <= RegNum; i++)
2369 uint64_t Address,
const void *Decoder) {
2370 unsigned RegPair = fieldFromInstruction(Insn, 7, 3);
2413 uint64_t Address,
const void *Decoder) {
2418 template <
typename InsnType>
2421 const void *Decoder) {
2429 InsnType Rt = fieldFromInstruction(insn, 21, 5);
2430 InsnType Rs = fieldFromInstruction(insn, 16, 5);
2440 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 2 + 4;
2442 else if (Rs == Rt) {
2445 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 2 + 4;
2451 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
2467 template <
typename InsnType>
2470 const void *Decoder) {
2478 InsnType Rt = fieldFromInstruction(insn, 21, 5);
2479 InsnType Rs = fieldFromInstruction(insn, 16, 5);
2487 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 2 + 4;
2489 else if (Rs == Rt) {
2491 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 2 + 4;
2496 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
static DecodeStatus DecodeCacheOp(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeJumpTargetMM(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeLi16Imm(MCInst &Inst, unsigned Value, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeFMemCop2MMR6(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeBranchTarget21(MCInst &Inst, unsigned Offset, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeINSVE_DF(MCInst &MI, InsnType insn, uint64_t Address, const void *Decoder)
INSVE_[BHWD] have an implicit operand that the generated decoder doesn't handle.
DecodeStatus
Ternary decode status.
static DecodeStatus DecodeCPU16RegsRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeCOP2RegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
Superclass for all disassemblers.
static DecodeStatus DecodeFMemCop2R6(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeBranchTarget(MCInst &Inst, unsigned Offset, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeBgtzGroupBranchMMR6(MCInst &MI, InsnType insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeSyncI(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeGPR64RegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeInsSize(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeDaddiGroupBranch(MCInst &MI, InsnType insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeBranchTargetMM(MCInst &Inst, unsigned Offset, uint64_t Address, const void *Decoder)
Target & getTheMipselTarget()
static DecodeStatus DecodeAFGR64RegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeSimm19Lsl2(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeFCCRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
static MCDisassembler * createMipsDisassembler(const Target &T, const MCSubtargetInfo &STI, MCContext &Ctx)
static void RegisterMCDisassembler(Target &T, Target::MCDisassemblerCtorTy Fn)
RegisterMCDisassembler - Register a MCDisassembler implementation for the given target.
static DecodeStatus DecodeBlezlGroupBranch(MCInst &MI, InsnType insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeFMemMMR2(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeMSA128Mem(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeMemMMImm4(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeSImmWithOffsetAndScale(MCInst &Inst, unsigned Value, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeGPR32RegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
static DecodeStatus DecodePOP75GroupBranchMMR6(MCInst &MI, InsnType insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeRegListOperand16(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeMemMMReglistImm4Lsl2(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
static MCOperand createReg(unsigned Reg)
static DecodeStatus DecodeDAHIDATIMMR6(MCInst &MI, InsnType insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeFMem(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeMemMMSPImm5Lsl2(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
Reg
All possible values of the reg field in the ModR/M byte.
static DecodeStatus DecodeLO32DSPRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
static DecodeStatus DecodePOP65GroupBranchMMR6(MCInst &MI, InsnType insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeMSA128DRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
Context object for machine code objects.
static DecodeStatus DecodeMemMMImm12(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeCacheeOp_CacheOpR6(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
int decodeInstruction(InternalInstruction *insn, byteReader_t reader, const void *readerArg, dlog_t logger, void *loggerArg, const void *miiArg, uint64_t startLoc, DisassemblerMode mode)
Decode one instruction and store the decoding results in a buffer provided by the consumer...
static DecodeStatus DecodeUImmWithOffsetAndScale(MCInst &Inst, unsigned Value, uint64_t Address, const void *Decoder)
Target & getTheMips64Target()
static DecodeStatus DecodeRegListOperand(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeHWRegsRegisterClass(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeBlezGroupBranchMMR6(MCInst &MI, InsnType insn, uint64_t Address, const void *Decoder)
size_t size() const
size - Get the array size.
static DecodeStatus DecodeMovePRegPair(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
Instances of this class represent a single low-level machine instruction.
static DecodeStatus DecodePOP35GroupBranchMMR6(MCInst &MI, InsnType insn, uint64_t Address, const void *Decoder)
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
static DecodeStatus DecodeMemMMImm9(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeGPRMM16RegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
static MCDisassembler * createMipselDisassembler(const Target &T, const MCSubtargetInfo &STI, MCContext &Ctx)
static DecodeStatus DecodePOP37GroupBranchMMR6(MCInst &MI, InsnType insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeStoreEvaOpMM(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
Target & getTheMips64elTarget()
static DecodeStatus DecodeBgtzlGroupBranch(MCInst &MI, InsnType insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeSimm18Lsl3(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
const MCRegisterClass & getRegClass(unsigned i) const
Returns the register class associated with the enumeration value.
static DecodeStatus DecodeFGR64RegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
void LLVMInitializeMipsDisassembler()
static DecodeStatus DecodePtrRegisterClass(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeSimm23Lsl2(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeCacheOpMM(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeBranchTarget7MM(MCInst &Inst, unsigned Offset, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeDAHIDATI(MCInst &MI, InsnType insn, uint64_t Address, const void *Decoder)
void setOpcode(unsigned Op)
static DecodeStatus DecodeSpecial3LlSc(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
static DecodeStatus readInstruction16(ArrayRef< uint8_t > Bytes, uint64_t Address, uint64_t &Size, uint32_t &Insn, bool IsBigEndian)
Read two bytes from the ArrayRef and return 16 bit halfword sorted according to the given endianness...
static DecodeStatus DecodeBranchTarget26MM(MCInst &Inst, unsigned Offset, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeMemEVA(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeMSA128BRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeSynciR6(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeMem(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
CHAIN = SC CHAIN, Imm128 - System call.
static DecodeStatus DecodeACC64DSPRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
const FeatureBitset & getFeatureBits() const
getFeatureBits - Return the feature bits.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
unsigned getOpcode() const
Target - Wrapper for Target specific information.
static DecodeStatus DecodeCOP0RegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
static unsigned getReg(const void *D, unsigned RC, unsigned RegNo)
static DecodeStatus DecodePOOL16BEncodedField(MCInst &Inst, unsigned Value, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeFGR32RegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
Target & getTheMipsTarget()
MCDisassembler::DecodeStatus DecodeStatus
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
static DecodeStatus DecodeGPRMM16ZeroRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
llvm_unreachable("Unknown RegBank!")
static DecodeStatus DecodeCCRRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeBgtzGroupBranch(MCInst &MI, InsnType insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeBranchTarget10MM(MCInst &Inst, unsigned Offset, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeMSA128WRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeANDI16Imm(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeFMem2(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeBranchTarget1SImm16(MCInst &Inst, unsigned Offset, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeBranchTarget21MM(MCInst &Inst, unsigned Offset, uint64_t Address, const void *Decoder)
MCSubtargetInfo - Generic base class for all target subtargets.
constexpr int64_t SignExtend64(uint64_t x)
Sign-extend the number in the bottom B bits of X to a 64-bit integer.
static DecodeStatus DecodeBranchTarget26(MCInst &Inst, unsigned Offset, uint64_t Address, const void *Decoder)
iterator begin() const
begin/end - Return all of the registers in this class.
static DecodeStatus DecodeAddiGroupBranch(MCInst &MI, InsnType insn, uint64_t Address, const void *Decoder)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static DecodeStatus DecodeGPRMM16MovePRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
static DecodeStatus DecodePrefeOpMM(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
LLVM Value Representation.
static DecodeStatus DecodeFGRCCRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeHI32DSPRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
static DecodeStatus DecodeJumpTarget(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
This class implements an extremely fast bulk output stream that can only output to a stream...
static DecodeStatus DecodeSimm9SP(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
void addOperand(const MCOperand &Op)
static DecodeStatus DecodeMemMMGPImm7Lsl2(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
static DecodeStatus readInstruction32(ArrayRef< uint8_t > Bytes, uint64_t Address, uint64_t &Size, uint32_t &Insn, bool IsBigEndian, bool IsMicroMips)
Read four bytes from the ArrayRef and return 32 bit word sorted according to the given endianness...
static DecodeStatus DecodeMSACtrlRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeAddiur2Simm7(MCInst &Inst, unsigned Value, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeMSA128HRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
static MCOperand createImm(int64_t Val)
static DecodeStatus DecodeFMem3(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeLoadByte9(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
const MCOperand & getOperand(unsigned i) const
static DecodeStatus DecodeDSPRRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeMemMMImm16(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeBlezGroupBranch(MCInst &MI, InsnType insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeUImmWithOffset(MCInst &Inst, unsigned Value, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeLoadByte15(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)