34 #define DEBUG_TYPE "mips-disassembler" 48 IsBigEndian(IsBigEndian) {}
50 bool hasMips2()
const {
return STI.
getFeatureBits()[Mips::FeatureMips2]; }
51 bool hasMips3()
const {
return STI.
getFeatureBits()[Mips::FeatureMips3]; }
52 bool hasMips32()
const {
return STI.
getFeatureBits()[Mips::FeatureMips32]; }
54 bool hasMips32r6()
const {
58 bool isFP64()
const {
return STI.
getFeatureBits()[Mips::FeatureFP64Bit]; }
60 bool isGP64()
const {
return STI.
getFeatureBits()[Mips::FeatureGP64Bit]; }
62 bool isPTR64()
const {
return STI.
getFeatureBits()[Mips::FeaturePTR64Bit]; }
64 bool hasCnMips()
const {
return STI.
getFeatureBits()[Mips::FeatureCnMips]; }
66 bool hasCOP3()
const {
68 return !hasMips32() && !hasMips3();
104 const void *Decoder);
109 const void *Decoder);
114 const void *Decoder);
119 const void *Decoder);
124 const void *Decoder);
129 const void *Decoder);
134 const void *Decoder);
139 const void *Decoder);
143 const void *Decoder);
148 const void *Decoder);
153 const void *Decoder);
158 const void *Decoder);
163 const void *Decoder);
168 const void *Decoder);
173 const void *Decoder);
178 const void *Decoder);
183 const void *Decoder);
188 const void *Decoder);
193 const void *Decoder);
198 const void *Decoder);
203 const void *Decoder);
208 const void *Decoder);
213 const void *Decoder);
218 const void *Decoder);
223 const void *Decoder);
228 const void *Decoder);
233 const void *Decoder);
240 const void *Decoder);
247 const void *Decoder);
254 const void *Decoder);
261 const void *Decoder);
268 const void *Decoder);
273 const void *Decoder);
278 const void *Decoder);
283 const void *Decoder);
286 const void *Decoder);
291 const void *Decoder);
296 const void *Decoder);
301 const void *Decoder);
306 const void *Decoder);
311 const void *Decoder);
316 const void *Decoder);
319 uint64_t
Address,
const void *Decoder);
324 const void *Decoder);
329 const void *Decoder);
334 const void *Decoder);
339 const void *Decoder);
344 const void *Decoder);
349 const void *Decoder);
354 const void *Decoder);
358 const void *Decoder);
362 const void *Decoder);
365 const void *Decoder);
368 const void *Decoder);
371 uint64_t
Address,
const void *Decoder);
375 const void *Decoder);
380 const void *Decoder);
385 const void *Decoder);
390 const void *Decoder);
395 const void *Decoder);
397 template <
unsigned Bits,
int Offset,
int Scale>
400 const void *Decoder);
402 template <
unsigned Bits,
int Offset>
405 const void *Decoder) {
406 return DecodeUImmWithOffsetAndScale<Bits, Offset, 1>(Inst, Value,
Address,
410 template <
unsigned Bits,
int Offset = 0,
int ScaleBy = 1>
413 const void *Decoder);
418 const void *Decoder);
421 uint64_t
Address,
const void *Decoder);
424 uint64_t
Address,
const void *Decoder);
427 uint64_t
Address,
const void *Decoder);
430 uint64_t
Address,
const void *Decoder);
433 uint64_t
Address,
const void *Decoder);
437 template <
typename InsnType>
439 const void *Decoder);
441 template <
typename InsnType>
443 const void *Decoder);
445 template <
typename InsnType>
447 const void *Decoder);
449 template <
typename InsnType>
451 const void *Decoder);
453 template <
typename InsnType>
455 const void *Decoder);
457 template <
typename InsnType>
460 const void *Decoder);
462 template <
typename InsnType>
465 const void *Decoder);
467 template <
typename InsnType>
470 const void *Decoder);
472 template <
typename InsnType>
475 const void *Decoder);
477 template <
typename InsnType>
480 const void *Decoder);
482 template <
typename InsnType>
485 const void *Decoder);
487 template <
typename InsnType>
490 const void *Decoder);
492 template <
typename InsnType>
495 const void *Decoder);
497 template <
typename InsnType>
500 const void *Decoder);
502 template <
typename InsnType>
505 const void *Decoder);
507 template <
typename InsnType>
510 const void *Decoder);
512 template <
typename InsnType>
515 const void *Decoder);
517 template <
typename InsnType>
519 const void *Decoder);
521 template <
typename InsnType>
523 const void *Decoder);
525 template <
typename InsnType>
527 const void *Decoder);
531 const void *Decoder);
535 const void *Decoder);
539 const void *Decoder);
542 uint64_t
Address,
const void *Decoder);
557 return new MipsDisassembler(STI, Ctx,
true);
564 return new MipsDisassembler(STI, Ctx,
false);
579 #include "MipsGenDisassemblerTables.inc" 581 static unsigned getReg(
const void *
D,
unsigned RC,
unsigned RegNo) {
582 const MipsDisassembler *Dis =
static_cast<const MipsDisassembler*
>(
D);
583 const MCRegisterInfo *RegInfo = Dis->getContext().getRegisterInfo();
587 template <
typename InsnType>
589 const void *Decoder) {
594 InsnType tmp = fieldFromInstruction(insn, 17, 5);
596 DecodeFN RegDecoder =
nullptr;
597 if ((tmp & 0x18) == 0x00) {
600 }
else if ((tmp & 0x1c) == 0x10) {
603 }
else if ((tmp & 0x1e) == 0x18) {
606 }
else if ((tmp & 0x1f) == 0x1c) {
612 assert(NSize != 0 && RegDecoder !=
nullptr);
615 tmp = fieldFromInstruction(insn, 6, 5);
622 tmp = fieldFromInstruction(insn, 16, NSize);
625 tmp = fieldFromInstruction(insn, 11, 5);
634 template <
typename InsnType>
636 const void *Decoder) {
637 InsnType Rs = fieldFromInstruction(insn, 16, 5);
638 InsnType Imm = fieldFromInstruction(insn, 0, 16);
648 template <
typename InsnType>
650 const void *Decoder) {
651 InsnType Rs = fieldFromInstruction(insn, 21, 5);
652 InsnType Imm = fieldFromInstruction(insn, 0, 16);
662 template <
typename InsnType>
665 const void *Decoder) {
676 InsnType Rs = fieldFromInstruction(insn, 21, 5);
677 InsnType Rt = fieldFromInstruction(insn, 16, 5);
678 int64_t Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
684 }
else if (Rs != 0 && Rs < Rt) {
701 template <
typename InsnType>
704 const void *Decoder) {
705 InsnType Rt = fieldFromInstruction(insn, 21, 5);
706 InsnType Rs = fieldFromInstruction(insn, 16, 5);
715 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 2 + 4;
716 }
else if (Rs != 0 && Rs < Rt) {
722 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
727 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 2 + 4;
735 template <
typename InsnType>
738 const void *Decoder) {
749 InsnType Rs = fieldFromInstruction(insn, 21, 5);
750 InsnType Rt = fieldFromInstruction(insn, 16, 5);
751 int64_t Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
757 }
else if (Rs != 0 && Rs < Rt) {
774 template <
typename InsnType>
777 const void *Decoder) {
778 InsnType Rt = fieldFromInstruction(insn, 21, 5);
779 InsnType Rs = fieldFromInstruction(insn, 16, 5);
788 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 2 + 4;
789 }
else if (Rs != 0 && Rs < Rt) {
795 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
800 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 2 + 4;
808 template <
typename InsnType>
811 const void *Decoder) {
819 InsnType Rt = fieldFromInstruction(insn, 21, 5);
820 InsnType Rs = fieldFromInstruction(insn, 16, 5);
821 int64_t Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
847 template <
typename InsnType>
850 const void *Decoder) {
858 InsnType Rt = fieldFromInstruction(insn, 21, 5);
859 InsnType Rs = fieldFromInstruction(insn, 16, 5);
860 int64_t Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
886 template <
typename InsnType>
889 const void *Decoder) {
901 InsnType Rs = fieldFromInstruction(insn, 21, 5);
902 InsnType Rt = fieldFromInstruction(insn, 16, 5);
903 int64_t Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
929 template <
typename InsnType>
932 const void *Decoder) {
946 InsnType Rs = fieldFromInstruction(insn, 21, 5);
947 InsnType Rt = fieldFromInstruction(insn, 16, 5);
948 int64_t Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
973 template <
typename InsnType>
976 const void *Decoder) {
988 InsnType Rs = fieldFromInstruction(insn, 21, 5);
989 InsnType Rt = fieldFromInstruction(insn, 16, 5);
990 int64_t Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
997 }
else if (Rs == 0) {
1000 }
else if (Rs == Rt) {
1022 template <
typename InsnType>
1025 const void *Decoder) {
1037 InsnType Rs = fieldFromInstruction(insn, 21, 5);
1038 InsnType Rt = fieldFromInstruction(insn, 16, 5);
1039 int64_t Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
1066 template <
typename InsnType>
1068 const void *Decoder) {
1069 unsigned Msbd = fieldFromInstruction(Insn, 11, 5);
1070 unsigned Lsb = fieldFromInstruction(Insn, 6, 5);
1081 Size = Msbd + 1 + 32;
1093 InsnType Rs = fieldFromInstruction(Insn, 21, 5);
1094 InsnType Rt = fieldFromInstruction(Insn, 16, 5);
1106 template <
typename InsnType>
1108 const void *Decoder) {
1109 unsigned Msbd = fieldFromInstruction(Insn, 11, 5);
1110 unsigned Lsb = fieldFromInstruction(Insn, 6, 5);
1117 Size = Msbd + 1 - Pos;
1121 Size = Msbd + 33 - Pos;
1127 Size = Msbd + 33 - Pos;
1133 InsnType Rs = fieldFromInstruction(Insn, 21, 5);
1134 InsnType Rt = fieldFromInstruction(Insn, 16, 5);
1146 template <
typename InsnType>
1148 const void *Decoder) {
1149 InsnType Rs = fieldFromInstruction(Insn, 21, 5);
1150 InsnType Rt = fieldFromInstruction(Insn, 16, 5);
1166 if (Bytes.
size() < 2) {
1172 Insn = (Bytes[0] << 8) | Bytes[1];
1174 Insn = (Bytes[1] << 8) | Bytes[0];
1184 bool IsBigEndian,
bool IsMicroMips) {
1186 if (Bytes.
size() < 4) {
1202 (Bytes[3] << 0) | (Bytes[2] << 8) | (Bytes[1] << 16) | (Bytes[0] << 24);
1205 Insn = (Bytes[2] << 0) | (Bytes[3] << 8) | (Bytes[0] << 16) |
1208 Insn = (Bytes[0] << 0) | (Bytes[1] << 8) | (Bytes[2] << 16) |
1230 if (hasMips32r6()) {
1232 dbgs() <<
"Trying MicroMipsR616 table (16-bit instructions):\n");
1243 LLVM_DEBUG(
dbgs() <<
"Trying MicroMips16 table (16-bit instructions):\n");
1257 if (hasMips32r6()) {
1259 dbgs() <<
"Trying MicroMips32r632 table (32-bit instructions):\n");
1269 LLVM_DEBUG(
dbgs() <<
"Trying MicroMips32 table (32-bit instructions):\n");
1279 LLVM_DEBUG(
dbgs() <<
"Trying MicroMipsFP64 table (32-bit opcodes):\n");
1315 if (hasMips32r6() && isGP64()) {
1317 dbgs() <<
"Trying Mips32r6_64r6 (GPR64) table (32-bit opcodes):\n");
1324 if (hasMips32r6() && isPTR64()) {
1326 dbgs() <<
"Trying Mips32r6_64r6 (PTR64) table (32-bit opcodes):\n");
1333 if (hasMips32r6()) {
1334 LLVM_DEBUG(
dbgs() <<
"Trying Mips32r6_64r6 table (32-bit opcodes):\n");
1341 if (hasMips2() && isPTR64()) {
1343 dbgs() <<
"Trying Mips32r6_64r6 (PTR64) table (32-bit opcodes):\n");
1359 LLVM_DEBUG(
dbgs() <<
"Trying Mips64 (GPR64) table (32-bit opcodes):\n");
1368 dbgs() <<
"Trying MipsFP64 (64 bit FPU) table (32-bit opcodes):\n");
1388 const void *Decoder) {
1395 const void *Decoder) {
1399 unsigned Reg =
getReg(Decoder, Mips::GPR64RegClassID, RegNo);
1407 const void *Decoder) {
1410 unsigned Reg =
getReg(Decoder, Mips::GPRMM16RegClassID, RegNo);
1418 const void *Decoder) {
1421 unsigned Reg =
getReg(Decoder, Mips::GPRMM16ZeroRegClassID, RegNo);
1429 const void *Decoder) {
1432 unsigned Reg =
getReg(Decoder, Mips::GPRMM16MovePRegClassID, RegNo);
1440 const void *Decoder) {
1443 unsigned Reg =
getReg(Decoder, Mips::GPR32RegClassID, RegNo);
1451 const void *Decoder) {
1452 if (static_cast<const MipsDisassembler *>(Decoder)->isGP64())
1461 const void *Decoder) {
1468 const void *Decoder) {
1472 unsigned Reg =
getReg(Decoder, Mips::FGR64RegClassID, RegNo);
1480 const void *Decoder) {
1484 unsigned Reg =
getReg(Decoder, Mips::FGR32RegClassID, RegNo);
1492 const void *Decoder) {
1495 unsigned Reg =
getReg(Decoder, Mips::CCRRegClassID, RegNo);
1503 const void *Decoder) {
1506 unsigned Reg =
getReg(Decoder, Mips::FCCRegClassID, RegNo);
1513 const void *Decoder) {
1517 unsigned Reg =
getReg(Decoder, Mips::FGRCCRegClassID, RegNo);
1525 const void *Decoder) {
1526 int Offset = SignExtend32<16>(Insn & 0xffff);
1527 unsigned Reg = fieldFromInstruction(Insn, 16, 5);
1528 unsigned Base = fieldFromInstruction(Insn, 21, 5);
1530 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1531 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1547 const void *Decoder) {
1548 int Offset = SignExtend32<9>(Insn >> 7);
1549 unsigned Reg = fieldFromInstruction(Insn, 16, 5);
1550 unsigned Base = fieldFromInstruction(Insn, 21, 5);
1552 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1553 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1568 const void *Decoder) {
1569 int Offset = SignExtend32<16>(Insn & 0xffff);
1570 unsigned Base = fieldFromInstruction(Insn, 16, 5);
1571 unsigned Reg = fieldFromInstruction(Insn, 21, 5);
1573 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1574 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1586 const void *Decoder) {
1587 int Offset = SignExtend32<16>(Insn & 0xffff);
1588 unsigned Hint = fieldFromInstruction(Insn, 16, 5);
1589 unsigned Base = fieldFromInstruction(Insn, 21, 5);
1591 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1603 const void *Decoder) {
1604 int Offset = SignExtend32<12>(Insn & 0xfff);
1605 unsigned Base = fieldFromInstruction(Insn, 16, 5);
1606 unsigned Hint = fieldFromInstruction(Insn, 21, 5);
1608 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1620 const void *Decoder) {
1621 int Offset = SignExtend32<9>(Insn & 0x1ff);
1622 unsigned Base = fieldFromInstruction(Insn, 16, 5);
1623 unsigned Hint = fieldFromInstruction(Insn, 21, 5);
1625 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1637 const void *Decoder) {
1638 int Offset = SignExtend32<9>(Insn >> 7);
1639 unsigned Hint = fieldFromInstruction(Insn, 16, 5);
1640 unsigned Base = fieldFromInstruction(Insn, 21, 5);
1642 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1654 const void *Decoder) {
1655 int Offset = SignExtend32<16>(Insn & 0xffff);
1656 unsigned Base = fieldFromInstruction(Insn, 21, 5);
1658 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1667 uint64_t
Address,
const void *Decoder) {
1668 int Offset = SignExtend32<16>(Insn & 0xffff);
1669 unsigned Base = fieldFromInstruction(Insn, 16, 5);
1671 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1682 const void *Decoder) {
1683 int Immediate = SignExtend32<16>(Insn & 0xffff);
1684 unsigned Base = fieldFromInstruction(Insn, 16, 5);
1686 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1695 uint64_t
Address,
const void *Decoder) {
1696 int Offset = SignExtend32<10>(fieldFromInstruction(Insn, 16, 10));
1697 unsigned Reg = fieldFromInstruction(Insn, 6, 5);
1698 unsigned Base = fieldFromInstruction(Insn, 11, 5);
1700 Reg =
getReg(Decoder, Mips::MSA128BRegClassID, Reg);
1701 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1716 assert(
false &&
"Unexpected instruction");
1743 const void *Decoder) {
1744 unsigned Offset = Insn & 0xf;
1745 unsigned Reg = fieldFromInstruction(Insn, 7, 3);
1746 unsigned Base = fieldFromInstruction(Insn, 4, 3);
1749 case Mips::LBU16_MM:
1750 case Mips::LHU16_MM:
1757 case Mips::SB16_MMR6:
1759 case Mips::SH16_MMR6:
1761 case Mips::SW16_MMR6:
1773 case Mips::LBU16_MM:
1780 case Mips::SB16_MMR6:
1783 case Mips::LHU16_MM:
1785 case Mips::SH16_MMR6:
1790 case Mips::SW16_MMR6:
1801 const void *Decoder) {
1802 unsigned Offset = Insn & 0x1F;
1803 unsigned Reg = fieldFromInstruction(Insn, 5, 5);
1805 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1817 const void *Decoder) {
1818 unsigned Offset = Insn & 0x7F;
1819 unsigned Reg = fieldFromInstruction(Insn, 7, 3);
1821 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1833 const void *Decoder) {
1836 case Mips::LWM16_MMR6:
1837 case Mips::SWM16_MMR6:
1838 Offset = fieldFromInstruction(Insn, 4, 4);
1841 Offset = SignExtend32<4>(Insn & 0xf);
1858 const void *Decoder) {
1859 int Offset = SignExtend32<9>(Insn & 0x1ff);
1860 unsigned Reg = fieldFromInstruction(Insn, 21, 5);
1861 unsigned Base = fieldFromInstruction(Insn, 16, 5);
1863 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1864 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1879 const void *Decoder) {
1880 int Offset = SignExtend32<12>(Insn & 0x0fff);
1881 unsigned Reg = fieldFromInstruction(Insn, 21, 5);
1882 unsigned Base = fieldFromInstruction(Insn, 16, 5);
1884 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1885 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1888 case Mips::SWM32_MM:
1889 case Mips::LWM32_MM:
1914 const void *Decoder) {
1915 int Offset = SignExtend32<16>(Insn & 0xffff);
1916 unsigned Reg = fieldFromInstruction(Insn, 21, 5);
1917 unsigned Base = fieldFromInstruction(Insn, 16, 5);
1919 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1920 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1932 const void *Decoder) {
1933 int Offset = SignExtend32<16>(Insn & 0xffff);
1934 unsigned Reg = fieldFromInstruction(Insn, 16, 5);
1935 unsigned Base = fieldFromInstruction(Insn, 21, 5);
1937 Reg =
getReg(Decoder, Mips::FGR64RegClassID, Reg);
1938 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1948 uint64_t
Address,
const void *Decoder) {
1951 int Offset = SignExtend32<16>(Insn & 0xffff);
1952 unsigned Base = fieldFromInstruction(Insn, 16, 5);
1953 unsigned Reg = fieldFromInstruction(Insn, 21, 5);
1955 Reg =
getReg(Decoder, Mips::FGR64RegClassID, Reg);
1956 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1968 const void *Decoder) {
1969 int Offset = SignExtend32<16>(Insn & 0xffff);
1970 unsigned Reg = fieldFromInstruction(Insn, 16, 5);
1971 unsigned Base = fieldFromInstruction(Insn, 21, 5);
1973 Reg =
getReg(Decoder, Mips::COP2RegClassID, Reg);
1974 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1986 const void *Decoder) {
1987 int Offset = SignExtend32<16>(Insn & 0xffff);
1988 unsigned Reg = fieldFromInstruction(Insn, 16, 5);
1989 unsigned Base = fieldFromInstruction(Insn, 21, 5);
1991 Reg =
getReg(Decoder, Mips::COP3RegClassID, Reg);
1992 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
2004 const void *Decoder) {
2005 int Offset = SignExtend32<11>(Insn & 0x07ff);
2006 unsigned Reg = fieldFromInstruction(Insn, 16, 5);
2007 unsigned Base = fieldFromInstruction(Insn, 11, 5);
2009 Reg =
getReg(Decoder, Mips::COP2RegClassID, Reg);
2010 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
2020 uint64_t
Address,
const void *Decoder) {
2021 int Offset = SignExtend32<11>(Insn & 0x07ff);
2022 unsigned Reg = fieldFromInstruction(Insn, 21, 5);
2023 unsigned Base = fieldFromInstruction(Insn, 16, 5);
2025 Reg =
getReg(Decoder, Mips::COP2RegClassID, Reg);
2026 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
2038 const void *Decoder) {
2039 int64_t Offset = SignExtend64<9>((Insn >> 7) & 0x1ff);
2040 unsigned Rt = fieldFromInstruction(Insn, 16, 5);
2041 unsigned Base = fieldFromInstruction(Insn, 21, 5);
2043 Rt =
getReg(Decoder, Mips::GPR32RegClassID, Rt);
2044 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
2060 const void *Decoder) {
2071 const void *Decoder) {
2072 if (RegNo > 30 || RegNo %2)
2075 unsigned Reg =
getReg(Decoder, Mips::AFGR64RegClassID, RegNo /2);
2083 const void *Decoder) {
2087 unsigned Reg =
getReg(Decoder, Mips::ACC64DSPRegClassID, RegNo);
2095 const void *Decoder) {
2099 unsigned Reg =
getReg(Decoder, Mips::HI32DSPRegClassID, RegNo);
2107 const void *Decoder) {
2111 unsigned Reg =
getReg(Decoder, Mips::LO32DSPRegClassID, RegNo);
2119 const void *Decoder) {
2123 unsigned Reg =
getReg(Decoder, Mips::MSA128BRegClassID, RegNo);
2131 const void *Decoder) {
2135 unsigned Reg =
getReg(Decoder, Mips::MSA128HRegClassID, RegNo);
2143 const void *Decoder) {
2147 unsigned Reg =
getReg(Decoder, Mips::MSA128WRegClassID, RegNo);
2155 const void *Decoder) {
2159 unsigned Reg =
getReg(Decoder, Mips::MSA128DRegClassID, RegNo);
2167 const void *Decoder) {
2171 unsigned Reg =
getReg(Decoder, Mips::MSACtrlRegClassID, RegNo);
2179 const void *Decoder) {
2183 unsigned Reg =
getReg(Decoder, Mips::COP0RegClassID, RegNo);
2191 const void *Decoder) {
2195 unsigned Reg =
getReg(Decoder, Mips::COP2RegClassID, RegNo);
2203 const void *Decoder) {
2204 int32_t BranchOffset = (SignExtend32<16>(
Offset) * 4) + 4;
2212 const void *Decoder) {
2213 int32_t BranchOffset = (SignExtend32<16>(
Offset) * 2);
2221 const void *Decoder) {
2222 unsigned JumpOffset = fieldFromInstruction(Insn, 0, 26) << 2;
2230 const void *Decoder) {
2231 int32_t BranchOffset = SignExtend32<21>(
Offset) * 4 + 4;
2240 const void *Decoder) {
2241 int32_t BranchOffset = SignExtend32<21>(
Offset) * 4 + 4;
2250 const void *Decoder) {
2251 int32_t BranchOffset = SignExtend32<26>(
Offset) * 4 + 4;
2260 const void *Decoder) {
2261 int32_t BranchOffset = SignExtend32<8>(Offset << 1);
2269 const void *Decoder) {
2270 int32_t BranchOffset = SignExtend32<11>(Offset << 1);
2278 const void *Decoder) {
2279 int32_t BranchOffset = SignExtend32<16>(
Offset) * 2 + 4;
2287 const void *Decoder) {
2288 int32_t BranchOffset = SignExtend32<27>(Offset << 1);
2297 const void *Decoder) {
2298 unsigned JumpOffset = fieldFromInstruction(Insn, 0, 26) << 1;
2306 const void *Decoder) {
2309 else if (Value == 0x7)
2319 const void *Decoder) {
2330 const void *Decoder) {
2335 template <
unsigned Bits,
int Offset,
int Scale>
2338 const void *Decoder) {
2339 Value &= ((1 <<
Bits) - 1);
2345 template <
unsigned Bits,
int Offset,
int ScaleBy>
2348 const void *Decoder) {
2349 int32_t Imm = SignExtend32<Bits>(Value) * ScaleBy;
2357 const void *Decoder) {
2362 int Size = (int) Insn - Pos + 1;
2368 uint64_t
Address,
const void *Decoder) {
2374 uint64_t
Address,
const void *Decoder) {
2380 uint64_t
Address,
const void *Decoder) {
2381 int32_t DecodedValue;
2383 case 0: DecodedValue = 256;
break;
2384 case 1: DecodedValue = 257;
break;
2385 case 510: DecodedValue = -258;
break;
2386 case 511: DecodedValue = -257;
break;
2387 default: DecodedValue = SignExtend32<9>(Insn);
break;
2394 uint64_t
Address,
const void *Decoder) {
2397 int32_t DecodedValues[] = {128, 1, 2, 3, 4, 7, 8, 15, 16, 31, 32, 63, 64,
2406 const void *Decoder) {
2407 unsigned Regs[] = {Mips::S0, Mips::S1, Mips::S2, Mips::S3, Mips::S4, Mips::S5,
2411 unsigned RegLst = fieldFromInstruction(Insn, 21, 5);
2417 RegNum = RegLst & 0xf;
2423 for (
unsigned i = 0; i < RegNum; i++)
2434 const void *Decoder) {
2435 unsigned Regs[] = {Mips::S0, Mips::S1, Mips::S2, Mips::S3};
2439 RegLst = fieldFromInstruction(Insn, 4, 2);
2441 case Mips::LWM16_MMR6:
2442 case Mips::SWM16_MMR6:
2443 RegLst = fieldFromInstruction(Insn, 8, 2);
2446 unsigned RegNum = RegLst & 0x3;
2448 for (
unsigned i = 0; i <= RegNum; i++)
2458 const void *Decoder) {
2459 unsigned RegPair = fieldFromInstruction(Insn, 7, 3);
2465 if (static_cast<const MipsDisassembler*>(Decoder)->hasMips32r6())
2466 RegRs = fieldFromInstruction(Insn, 0, 2) |
2467 (fieldFromInstruction(Insn, 3, 1) << 2);
2469 RegRs = fieldFromInstruction(Insn, 1, 3);
2474 unsigned RegRt = fieldFromInstruction(Insn, 4, 3);
2483 uint64_t
Address,
const void *Decoder) {
2525 uint64_t
Address,
const void *Decoder) {
2530 template <
typename InsnType>
2533 const void *Decoder) {
2541 InsnType Rt = fieldFromInstruction(insn, 21, 5);
2542 InsnType Rs = fieldFromInstruction(insn, 16, 5);
2552 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 2 + 4;
2554 else if (Rs == Rt) {
2557 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 2 + 4;
2563 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
2579 template <
typename InsnType>
2582 const void *Decoder) {
2590 InsnType Rt = fieldFromInstruction(insn, 21, 5);
2591 InsnType Rs = fieldFromInstruction(insn, 16, 5);
2599 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 2 + 4;
2601 else if (Rs == Rt) {
2603 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 2 + 4;
2608 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)
iterator begin() const
begin/end - Return all of the registers in this class.
This class represents lattice values for constants.
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)
SI optimize exec mask operations pre RA
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)
const FeatureBitset & getFeatureBits() const
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)
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)
static DecodeStatus DecodeSyncI_MM(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
Context object for machine code objects.
static DecodeStatus DecodeDEXT(MCInst &MI, InsnType Insn, uint64_t Address, const void *Decoder)
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 DecodeMovePRegPair(MCInst &Inst, unsigned RegPair, 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)
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)
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)
size_t size() const
size - Get the array size.
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 DecodeDINS(MCInst &MI, InsnType Insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeCacheOpMM(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
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)
MCDisassembler::DecodeStatus DecodeStatus
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)
const MCOperand & getOperand(unsigned i) const
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)
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
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()
static DecodeStatus DecodeGPRMM16ZeroRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
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)
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)
static DecodeStatus DecodeCRC(MCInst &MI, InsnType Insn, uint64_t Address, const void *Decoder)
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 DecodeMovePOperands(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeHI32DSPRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
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)
unsigned getOpcode() const
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 DecodeDSPRRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
const MCRegisterClass & getRegClass(unsigned i) const
Returns the register class associated with the enumeration value.
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)