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 hasCnMipsP()
const {
return STI.
getFeatureBits()[Mips::FeatureCnMipsP]; }
68 bool hasCOP3()
const {
70 return !hasMips32() && !hasMips3();
100 const void *Decoder);
105 const void *Decoder);
110 const void *Decoder);
115 const void *Decoder);
120 const void *Decoder);
125 const void *Decoder);
130 const void *Decoder);
135 const void *Decoder);
140 const void *Decoder);
144 const void *Decoder);
149 const void *Decoder);
154 const void *Decoder);
159 const void *Decoder);
164 const void *Decoder);
169 const void *Decoder);
174 const void *Decoder);
179 const void *Decoder);
184 const void *Decoder);
189 const void *Decoder);
194 const void *Decoder);
199 const void *Decoder);
204 const void *Decoder);
209 const void *Decoder);
214 const void *Decoder);
219 const void *Decoder);
224 const void *Decoder);
229 const void *Decoder);
234 const void *Decoder);
241 const void *Decoder);
248 const void *Decoder);
255 const void *Decoder);
262 const void *Decoder);
269 const void *Decoder);
276 const void *Decoder);
281 const void *Decoder);
286 const void *Decoder);
291 const void *Decoder);
294 const void *Decoder);
299 const void *Decoder);
304 const void *Decoder);
309 const void *Decoder);
314 const void *Decoder);
319 const void *Decoder);
324 const void *Decoder);
327 uint64_t
Address,
const void *Decoder);
332 const void *Decoder);
337 const void *Decoder);
342 const void *Decoder);
347 const void *Decoder);
352 const void *Decoder);
357 const void *Decoder);
362 const void *Decoder);
366 const void *Decoder);
370 const void *Decoder);
373 const void *Decoder);
376 const void *Decoder);
379 uint64_t
Address,
const void *Decoder);
383 const void *Decoder);
388 const void *Decoder);
393 const void *Decoder);
398 const void *Decoder);
403 const void *Decoder);
405 template <
unsigned Bits,
int Offset,
int Scale>
408 const void *Decoder);
410 template <
unsigned Bits,
int Offset>
413 const void *Decoder) {
414 return DecodeUImmWithOffsetAndScale<Bits, Offset, 1>(Inst,
Value,
Address,
418 template <
unsigned Bits,
int Offset = 0,
int ScaleBy = 1>
421 const void *Decoder);
426 const void *Decoder);
429 uint64_t
Address,
const void *Decoder);
432 uint64_t
Address,
const void *Decoder);
435 uint64_t
Address,
const void *Decoder);
438 uint64_t
Address,
const void *Decoder);
441 uint64_t
Address,
const void *Decoder);
445 template <
typename InsnType>
447 const void *Decoder);
449 template <
typename InsnType>
451 uint64_t
Address,
const void *Decoder);
453 template <
typename InsnType>
455 const void *Decoder);
457 template <
typename InsnType>
459 uint64_t
Address,
const void *Decoder);
461 template <
typename InsnType>
463 const void *Decoder);
465 template <
typename InsnType>
468 const void *Decoder);
470 template <
typename InsnType>
473 const void *Decoder);
475 template <
typename InsnType>
478 const void *Decoder);
480 template <
typename InsnType>
483 const void *Decoder);
485 template <
typename InsnType>
488 const void *Decoder);
490 template <
typename InsnType>
493 const void *Decoder);
495 template <
typename InsnType>
498 const void *Decoder);
500 template <
typename InsnType>
503 const void *Decoder);
505 template <
typename InsnType>
508 const void *Decoder);
510 template <
typename InsnType>
513 const void *Decoder);
515 template <
typename InsnType>
518 const void *Decoder);
520 template <
typename InsnType>
523 const void *Decoder);
525 template <
typename InsnType>
527 const void *Decoder);
529 template <
typename InsnType>
531 const void *Decoder);
533 template <
typename InsnType>
535 const void *Decoder);
539 const void *Decoder);
543 const void *Decoder);
547 const void *Decoder);
550 uint64_t
Address,
const void *Decoder);
556 return new MipsDisassembler(STI, Ctx,
true);
563 return new MipsDisassembler(STI, Ctx,
false);
578 #include "MipsGenDisassemblerTables.inc" 580 static unsigned getReg(
const void *
D,
unsigned RC,
unsigned RegNo) {
581 const MipsDisassembler *Dis =
static_cast<const MipsDisassembler*
>(
D);
582 const MCRegisterInfo *RegInfo = Dis->getContext().getRegisterInfo();
586 template <
typename InsnType>
588 const void *Decoder) {
593 InsnType tmp = fieldFromInstruction(insn, 17, 5);
595 DecodeFN RegDecoder =
nullptr;
596 if ((tmp & 0x18) == 0x00) {
599 }
else if ((tmp & 0x1c) == 0x10) {
602 }
else if ((tmp & 0x1e) == 0x18) {
605 }
else if ((tmp & 0x1f) == 0x1c) {
611 assert(NSize != 0 && RegDecoder !=
nullptr);
614 tmp = fieldFromInstruction(insn, 6, 5);
621 tmp = fieldFromInstruction(insn, 16, NSize);
624 tmp = fieldFromInstruction(insn, 11, 5);
633 template <
typename InsnType>
635 uint64_t
Address,
const void *Decoder) {
636 InsnType Rs = fieldFromInstruction(insn, 16, 5);
637 InsnType Imm = fieldFromInstruction(insn, 0, 16);
647 template <
typename InsnType>
649 const void *Decoder) {
650 InsnType Rs = fieldFromInstruction(insn, 21, 5);
651 InsnType Imm = fieldFromInstruction(insn, 0, 16);
661 template <
typename InsnType>
664 const void *Decoder) {
675 InsnType Rs = fieldFromInstruction(insn, 21, 5);
676 InsnType Rt = fieldFromInstruction(insn, 16, 5);
677 int64_t Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
683 }
else if (Rs != 0 && Rs < Rt) {
700 template <
typename InsnType>
703 const void *Decoder) {
704 InsnType Rt = fieldFromInstruction(insn, 21, 5);
705 InsnType Rs = fieldFromInstruction(insn, 16, 5);
714 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 2 + 4;
715 }
else if (Rs != 0 && Rs < Rt) {
721 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
726 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 2 + 4;
734 template <
typename InsnType>
737 const void *Decoder) {
748 InsnType Rs = fieldFromInstruction(insn, 21, 5);
749 InsnType Rt = fieldFromInstruction(insn, 16, 5);
750 int64_t Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
756 }
else if (Rs != 0 && Rs < Rt) {
773 template <
typename InsnType>
776 const void *Decoder) {
777 InsnType Rt = fieldFromInstruction(insn, 21, 5);
778 InsnType Rs = fieldFromInstruction(insn, 16, 5);
787 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 2 + 4;
788 }
else if (Rs != 0 && Rs < Rt) {
794 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
799 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 2 + 4;
807 template <
typename InsnType>
810 const void *Decoder) {
818 InsnType Rt = fieldFromInstruction(insn, 21, 5);
819 InsnType Rs = fieldFromInstruction(insn, 16, 5);
820 int64_t Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
846 template <
typename InsnType>
849 const void *Decoder) {
857 InsnType Rt = fieldFromInstruction(insn, 21, 5);
858 InsnType Rs = fieldFromInstruction(insn, 16, 5);
859 int64_t Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
885 template <
typename InsnType>
888 const void *Decoder) {
900 InsnType Rs = fieldFromInstruction(insn, 21, 5);
901 InsnType Rt = fieldFromInstruction(insn, 16, 5);
902 int64_t Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
928 template <
typename InsnType>
931 const void *Decoder) {
945 InsnType Rs = fieldFromInstruction(insn, 21, 5);
946 InsnType Rt = fieldFromInstruction(insn, 16, 5);
947 int64_t Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
972 template <
typename InsnType>
975 const void *Decoder) {
987 InsnType Rs = fieldFromInstruction(insn, 21, 5);
988 InsnType Rt = fieldFromInstruction(insn, 16, 5);
989 int64_t Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
996 }
else if (Rs == 0) {
999 }
else if (Rs == Rt) {
1021 template <
typename InsnType>
1024 const void *Decoder) {
1036 InsnType Rs = fieldFromInstruction(insn, 21, 5);
1037 InsnType Rt = fieldFromInstruction(insn, 16, 5);
1038 int64_t Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
1065 template <
typename InsnType>
1067 const void *Decoder) {
1068 unsigned Msbd = fieldFromInstruction(Insn, 11, 5);
1069 unsigned Lsb = fieldFromInstruction(Insn, 6, 5);
1080 Size = Msbd + 1 + 32;
1092 InsnType Rs = fieldFromInstruction(Insn, 21, 5);
1093 InsnType Rt = fieldFromInstruction(Insn, 16, 5);
1107 template <
typename InsnType>
1109 const void *Decoder) {
1110 unsigned Msbd = fieldFromInstruction(Insn, 11, 5);
1111 unsigned Lsb = fieldFromInstruction(Insn, 6, 5);
1118 Size = Msbd + 1 - Pos;
1122 Size = Msbd + 33 - Pos;
1128 Size = Msbd + 33 - Pos;
1134 InsnType Rs = fieldFromInstruction(Insn, 21, 5);
1135 InsnType Rt = fieldFromInstruction(Insn, 16, 5);
1149 template <
typename InsnType>
1151 const void *Decoder) {
1152 InsnType Rs = fieldFromInstruction(Insn, 21, 5);
1153 InsnType Rt = fieldFromInstruction(Insn, 16, 5);
1169 if (Bytes.
size() < 2) {
1175 Insn = (Bytes[0] << 8) | Bytes[1];
1177 Insn = (Bytes[1] << 8) | Bytes[0];
1187 bool IsBigEndian,
bool IsMicroMips) {
1189 if (Bytes.
size() < 4) {
1205 (Bytes[3] << 0) | (Bytes[2] << 8) | (Bytes[1] << 16) | (Bytes[0] << 24);
1208 Insn = (Bytes[2] << 0) | (Bytes[3] << 8) | (Bytes[0] << 16) |
1211 Insn = (Bytes[0] << 0) | (Bytes[1] << 8) | (Bytes[2] << 16) |
1232 if (hasMips32r6()) {
1234 dbgs() <<
"Trying MicroMipsR616 table (16-bit instructions):\n");
1237 Result = decodeInstruction(DecoderTableMicroMipsR616, Instr, Insn,
1245 LLVM_DEBUG(
dbgs() <<
"Trying MicroMips16 table (16-bit instructions):\n");
1248 Result = decodeInstruction(DecoderTableMicroMips16, Instr, Insn,
Address,
1259 if (hasMips32r6()) {
1261 dbgs() <<
"Trying MicroMips32r632 table (32-bit instructions):\n");
1263 Result = decodeInstruction(DecoderTableMicroMipsR632, Instr, Insn,
1271 LLVM_DEBUG(
dbgs() <<
"Trying MicroMips32 table (32-bit instructions):\n");
1273 Result = decodeInstruction(DecoderTableMicroMips32, Instr, Insn,
Address,
1281 LLVM_DEBUG(
dbgs() <<
"Trying MicroMipsFP64 table (32-bit opcodes):\n");
1282 Result = decodeInstruction(DecoderTableMicroMipsFP6432, Instr, Insn,
1312 decodeInstruction(DecoderTableCOP3_32, Instr, Insn,
Address,
this, STI);
1317 if (hasMips32r6() && isGP64()) {
1319 dbgs() <<
"Trying Mips32r6_64r6 (GPR64) table (32-bit opcodes):\n");
1320 Result = decodeInstruction(DecoderTableMips32r6_64r6_GP6432, Instr, Insn,
1326 if (hasMips32r6() && isPTR64()) {
1328 dbgs() <<
"Trying Mips32r6_64r6 (PTR64) table (32-bit opcodes):\n");
1329 Result = decodeInstruction(DecoderTableMips32r6_64r6_PTR6432, Instr, Insn,
1335 if (hasMips32r6()) {
1336 LLVM_DEBUG(
dbgs() <<
"Trying Mips32r6_64r6 table (32-bit opcodes):\n");
1337 Result = decodeInstruction(DecoderTableMips32r6_64r632, Instr, Insn,
1343 if (hasMips2() && isPTR64()) {
1345 dbgs() <<
"Trying Mips32r6_64r6 (PTR64) table (32-bit opcodes):\n");
1346 Result = decodeInstruction(DecoderTableMips32_64_PTR6432, Instr, Insn,
1354 Result = decodeInstruction(DecoderTableCnMips32, Instr, Insn,
1361 LLVM_DEBUG(
dbgs() <<
"Trying CnMipsP table (32-bit opcodes):\n");
1362 Result = decodeInstruction(DecoderTableCnMipsP32, Instr, Insn,
1369 LLVM_DEBUG(
dbgs() <<
"Trying Mips64 (GPR64) table (32-bit opcodes):\n");
1370 Result = decodeInstruction(DecoderTableMips6432, Instr, Insn,
1378 dbgs() <<
"Trying MipsFP64 (64 bit FPU) table (32-bit opcodes):\n");
1379 Result = decodeInstruction(DecoderTableMipsFP6432, Instr, Insn,
1388 decodeInstruction(DecoderTableMips32, Instr, Insn,
Address,
this, STI);
1398 const void *Decoder) {
1405 const void *Decoder) {
1409 unsigned Reg =
getReg(Decoder, Mips::GPR64RegClassID, RegNo);
1417 const void *Decoder) {
1420 unsigned Reg =
getReg(Decoder, Mips::GPRMM16RegClassID, RegNo);
1428 const void *Decoder) {
1431 unsigned Reg =
getReg(Decoder, Mips::GPRMM16ZeroRegClassID, RegNo);
1439 const void *Decoder) {
1442 unsigned Reg =
getReg(Decoder, Mips::GPRMM16MovePRegClassID, RegNo);
1450 const void *Decoder) {
1453 unsigned Reg =
getReg(Decoder, Mips::GPR32RegClassID, RegNo);
1461 const void *Decoder) {
1462 if (static_cast<const MipsDisassembler *>(Decoder)->isGP64())
1471 const void *Decoder) {
1478 const void *Decoder) {
1482 unsigned Reg =
getReg(Decoder, Mips::FGR64RegClassID, RegNo);
1490 const void *Decoder) {
1494 unsigned Reg =
getReg(Decoder, Mips::FGR32RegClassID, RegNo);
1502 const void *Decoder) {
1505 unsigned Reg =
getReg(Decoder, Mips::CCRRegClassID, RegNo);
1513 const void *Decoder) {
1516 unsigned Reg =
getReg(Decoder, Mips::FCCRegClassID, RegNo);
1523 const void *Decoder) {
1527 unsigned Reg =
getReg(Decoder, Mips::FGRCCRegClassID, RegNo);
1535 const void *Decoder) {
1536 int Offset = SignExtend32<16>(Insn & 0xffff);
1537 unsigned Reg = fieldFromInstruction(Insn, 16, 5);
1538 unsigned Base = fieldFromInstruction(Insn, 21, 5);
1540 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1541 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1557 const void *Decoder) {
1558 int Offset = SignExtend32<9>(Insn >> 7);
1559 unsigned Reg = fieldFromInstruction(Insn, 16, 5);
1560 unsigned Base = fieldFromInstruction(Insn, 21, 5);
1562 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1563 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1578 const void *Decoder) {
1579 int Offset = SignExtend32<16>(Insn & 0xffff);
1580 unsigned Base = fieldFromInstruction(Insn, 16, 5);
1581 unsigned Reg = fieldFromInstruction(Insn, 21, 5);
1583 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1584 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1596 const void *Decoder) {
1597 int Offset = SignExtend32<16>(Insn & 0xffff);
1598 unsigned Hint = fieldFromInstruction(Insn, 16, 5);
1599 unsigned Base = fieldFromInstruction(Insn, 21, 5);
1601 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1613 const void *Decoder) {
1614 int Offset = SignExtend32<12>(Insn & 0xfff);
1615 unsigned Base = fieldFromInstruction(Insn, 16, 5);
1616 unsigned Hint = fieldFromInstruction(Insn, 21, 5);
1618 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1630 const void *Decoder) {
1631 int Offset = SignExtend32<9>(Insn & 0x1ff);
1632 unsigned Base = fieldFromInstruction(Insn, 16, 5);
1633 unsigned Hint = fieldFromInstruction(Insn, 21, 5);
1635 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1647 const void *Decoder) {
1648 int Offset = SignExtend32<9>(Insn >> 7);
1649 unsigned Hint = fieldFromInstruction(Insn, 16, 5);
1650 unsigned Base = fieldFromInstruction(Insn, 21, 5);
1652 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1664 const void *Decoder) {
1665 int Offset = SignExtend32<16>(Insn & 0xffff);
1666 unsigned Base = fieldFromInstruction(Insn, 21, 5);
1668 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1677 uint64_t
Address,
const void *Decoder) {
1678 int Offset = SignExtend32<16>(Insn & 0xffff);
1679 unsigned Base = fieldFromInstruction(Insn, 16, 5);
1681 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1692 const void *Decoder) {
1693 int Immediate = SignExtend32<16>(Insn & 0xffff);
1694 unsigned Base = fieldFromInstruction(Insn, 16, 5);
1696 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1705 uint64_t
Address,
const void *Decoder) {
1706 int Offset = SignExtend32<10>(fieldFromInstruction(Insn, 16, 10));
1707 unsigned Reg = fieldFromInstruction(Insn, 6, 5);
1708 unsigned Base = fieldFromInstruction(Insn, 11, 5);
1710 Reg =
getReg(Decoder, Mips::MSA128BRegClassID, Reg);
1711 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1726 assert(
false &&
"Unexpected instruction");
1753 const void *Decoder) {
1754 unsigned Offset = Insn & 0xf;
1755 unsigned Reg = fieldFromInstruction(Insn, 7, 3);
1756 unsigned Base = fieldFromInstruction(Insn, 4, 3);
1759 case Mips::LBU16_MM:
1760 case Mips::LHU16_MM:
1767 case Mips::SB16_MMR6:
1769 case Mips::SH16_MMR6:
1771 case Mips::SW16_MMR6:
1783 case Mips::LBU16_MM:
1790 case Mips::SB16_MMR6:
1793 case Mips::LHU16_MM:
1795 case Mips::SH16_MMR6:
1800 case Mips::SW16_MMR6:
1811 const void *Decoder) {
1812 unsigned Offset = Insn & 0x1F;
1813 unsigned Reg = fieldFromInstruction(Insn, 5, 5);
1815 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1827 const void *Decoder) {
1828 unsigned Offset = Insn & 0x7F;
1829 unsigned Reg = fieldFromInstruction(Insn, 7, 3);
1831 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1843 const void *Decoder) {
1846 case Mips::LWM16_MMR6:
1847 case Mips::SWM16_MMR6:
1848 Offset = fieldFromInstruction(Insn, 4, 4);
1851 Offset = SignExtend32<4>(Insn & 0xf);
1868 const void *Decoder) {
1869 int Offset = SignExtend32<9>(Insn & 0x1ff);
1870 unsigned Reg = fieldFromInstruction(Insn, 21, 5);
1871 unsigned Base = fieldFromInstruction(Insn, 16, 5);
1873 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1874 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1889 const void *Decoder) {
1890 int Offset = SignExtend32<12>(Insn & 0x0fff);
1891 unsigned Reg = fieldFromInstruction(Insn, 21, 5);
1892 unsigned Base = fieldFromInstruction(Insn, 16, 5);
1894 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1895 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1898 case Mips::SWM32_MM:
1899 case Mips::LWM32_MM:
1924 const void *Decoder) {
1925 int Offset = SignExtend32<16>(Insn & 0xffff);
1926 unsigned Reg = fieldFromInstruction(Insn, 21, 5);
1927 unsigned Base = fieldFromInstruction(Insn, 16, 5);
1929 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1930 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1942 const void *Decoder) {
1943 int Offset = SignExtend32<16>(Insn & 0xffff);
1944 unsigned Reg = fieldFromInstruction(Insn, 16, 5);
1945 unsigned Base = fieldFromInstruction(Insn, 21, 5);
1947 Reg =
getReg(Decoder, Mips::FGR64RegClassID, Reg);
1948 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1958 uint64_t
Address,
const void *Decoder) {
1961 int Offset = SignExtend32<16>(Insn & 0xffff);
1962 unsigned Base = fieldFromInstruction(Insn, 16, 5);
1963 unsigned Reg = fieldFromInstruction(Insn, 21, 5);
1965 Reg =
getReg(Decoder, Mips::FGR64RegClassID, Reg);
1966 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1978 const void *Decoder) {
1979 int Offset = SignExtend32<16>(Insn & 0xffff);
1980 unsigned Reg = fieldFromInstruction(Insn, 16, 5);
1981 unsigned Base = fieldFromInstruction(Insn, 21, 5);
1983 Reg =
getReg(Decoder, Mips::COP2RegClassID, Reg);
1984 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
1996 const void *Decoder) {
1997 int Offset = SignExtend32<16>(Insn & 0xffff);
1998 unsigned Reg = fieldFromInstruction(Insn, 16, 5);
1999 unsigned Base = fieldFromInstruction(Insn, 21, 5);
2001 Reg =
getReg(Decoder, Mips::COP3RegClassID, Reg);
2002 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
2014 const void *Decoder) {
2015 int Offset = SignExtend32<11>(Insn & 0x07ff);
2016 unsigned Reg = fieldFromInstruction(Insn, 16, 5);
2017 unsigned Base = fieldFromInstruction(Insn, 11, 5);
2019 Reg =
getReg(Decoder, Mips::COP2RegClassID, Reg);
2020 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
2030 uint64_t
Address,
const void *Decoder) {
2031 int Offset = SignExtend32<11>(Insn & 0x07ff);
2032 unsigned Reg = fieldFromInstruction(Insn, 21, 5);
2033 unsigned Base = fieldFromInstruction(Insn, 16, 5);
2035 Reg =
getReg(Decoder, Mips::COP2RegClassID, Reg);
2036 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
2048 const void *Decoder) {
2049 int64_t Offset = SignExtend64<9>((Insn >> 7) & 0x1ff);
2050 unsigned Rt = fieldFromInstruction(Insn, 16, 5);
2051 unsigned Base = fieldFromInstruction(Insn, 21, 5);
2053 Rt =
getReg(Decoder, Mips::GPR32RegClassID, Rt);
2054 Base =
getReg(Decoder, Mips::GPR32RegClassID, Base);
2070 const void *Decoder) {
2081 const void *Decoder) {
2082 if (RegNo > 30 || RegNo %2)
2085 unsigned Reg =
getReg(Decoder, Mips::AFGR64RegClassID, RegNo /2);
2093 const void *Decoder) {
2097 unsigned Reg =
getReg(Decoder, Mips::ACC64DSPRegClassID, RegNo);
2105 const void *Decoder) {
2109 unsigned Reg =
getReg(Decoder, Mips::HI32DSPRegClassID, RegNo);
2117 const void *Decoder) {
2121 unsigned Reg =
getReg(Decoder, Mips::LO32DSPRegClassID, RegNo);
2129 const void *Decoder) {
2133 unsigned Reg =
getReg(Decoder, Mips::MSA128BRegClassID, RegNo);
2141 const void *Decoder) {
2145 unsigned Reg =
getReg(Decoder, Mips::MSA128HRegClassID, RegNo);
2153 const void *Decoder) {
2157 unsigned Reg =
getReg(Decoder, Mips::MSA128WRegClassID, RegNo);
2165 const void *Decoder) {
2169 unsigned Reg =
getReg(Decoder, Mips::MSA128DRegClassID, RegNo);
2177 const void *Decoder) {
2181 unsigned Reg =
getReg(Decoder, Mips::MSACtrlRegClassID, RegNo);
2189 const void *Decoder) {
2193 unsigned Reg =
getReg(Decoder, Mips::COP0RegClassID, RegNo);
2201 const void *Decoder) {
2205 unsigned Reg =
getReg(Decoder, Mips::COP2RegClassID, RegNo);
2213 const void *Decoder) {
2214 int32_t BranchOffset = (SignExtend32<16>(
Offset) * 4) + 4;
2222 const void *Decoder) {
2223 int32_t BranchOffset = (SignExtend32<16>(
Offset) * 2);
2231 const void *Decoder) {
2232 unsigned JumpOffset = fieldFromInstruction(Insn, 0, 26) << 2;
2240 const void *Decoder) {
2241 int32_t BranchOffset = SignExtend32<21>(
Offset) * 4 + 4;
2250 const void *Decoder) {
2251 int32_t BranchOffset = SignExtend32<21>(
Offset) * 4 + 4;
2260 const void *Decoder) {
2261 int32_t BranchOffset = SignExtend32<26>(
Offset) * 4 + 4;
2270 const void *Decoder) {
2271 int32_t BranchOffset = SignExtend32<8>(Offset << 1);
2279 const void *Decoder) {
2280 int32_t BranchOffset = SignExtend32<11>(Offset << 1);
2288 const void *Decoder) {
2289 int32_t BranchOffset = SignExtend32<16>(
Offset) * 2 + 4;
2297 const void *Decoder) {
2298 int32_t BranchOffset = SignExtend32<27>(Offset << 1);
2307 const void *Decoder) {
2308 unsigned JumpOffset = fieldFromInstruction(Insn, 0, 26) << 1;
2316 const void *Decoder) {
2317 unsigned JumpOffset = fieldFromInstruction(Insn, 0, 26) << 2;
2325 const void *Decoder) {
2328 else if (Value == 0x7)
2338 const void *Decoder) {
2349 const void *Decoder) {
2354 template <
unsigned Bits,
int Offset,
int Scale>
2357 const void *Decoder) {
2358 Value &= ((1 <<
Bits) - 1);
2364 template <
unsigned Bits,
int Offset,
int ScaleBy>
2367 const void *Decoder) {
2368 int32_t Imm = SignExtend32<Bits>(
Value) * ScaleBy;
2376 const void *Decoder) {
2381 int Size = (int) Insn - Pos + 1;
2387 uint64_t
Address,
const void *Decoder) {
2393 uint64_t
Address,
const void *Decoder) {
2399 uint64_t
Address,
const void *Decoder) {
2400 int32_t DecodedValue;
2402 case 0: DecodedValue = 256;
break;
2403 case 1: DecodedValue = 257;
break;
2404 case 510: DecodedValue = -258;
break;
2405 case 511: DecodedValue = -257;
break;
2406 default: DecodedValue = SignExtend32<9>(Insn);
break;
2413 uint64_t
Address,
const void *Decoder) {
2416 int32_t DecodedValues[] = {128, 1, 2, 3, 4, 7, 8, 15, 16, 31, 32, 63, 64,
2425 const void *Decoder) {
2426 unsigned Regs[] = {Mips::S0, Mips::S1, Mips::S2, Mips::S3, Mips::S4, Mips::S5,
2427 Mips::S6, Mips::S7, Mips::FP};
2430 unsigned RegLst = fieldFromInstruction(Insn, 21, 5);
2436 RegNum = RegLst & 0xf;
2442 for (
unsigned i = 0; i < RegNum; i++)
2453 const void *Decoder) {
2454 unsigned Regs[] = {Mips::S0, Mips::S1, Mips::S2, Mips::S3};
2458 RegLst = fieldFromInstruction(Insn, 4, 2);
2460 case Mips::LWM16_MMR6:
2461 case Mips::SWM16_MMR6:
2462 RegLst = fieldFromInstruction(Insn, 8, 2);
2465 unsigned RegNum = RegLst & 0x3;
2467 for (
unsigned i = 0; i <= RegNum; i++)
2477 const void *Decoder) {
2478 unsigned RegPair = fieldFromInstruction(Insn, 7, 3);
2484 if (static_cast<const MipsDisassembler*>(Decoder)->hasMips32r6())
2485 RegRs = fieldFromInstruction(Insn, 0, 2) |
2486 (fieldFromInstruction(Insn, 3, 1) << 2);
2488 RegRs = fieldFromInstruction(Insn, 1, 3);
2493 unsigned RegRt = fieldFromInstruction(Insn, 4, 3);
2502 uint64_t
Address,
const void *Decoder) {
2544 uint64_t
Address,
const void *Decoder) {
2549 template <
typename InsnType>
2552 const void *Decoder) {
2560 InsnType Rt = fieldFromInstruction(insn, 21, 5);
2561 InsnType Rs = fieldFromInstruction(insn, 16, 5);
2571 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 2 + 4;
2573 else if (Rs == Rt) {
2576 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 2 + 4;
2582 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
2598 template <
typename InsnType>
2601 const void *Decoder) {
2609 InsnType Rt = fieldFromInstruction(insn, 21, 5);
2610 InsnType Rs = fieldFromInstruction(insn, 16, 5);
2618 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 2 + 4;
2620 else if (Rs == Rt) {
2622 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 2 + 4;
2627 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)
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMipsDisassembler()
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.
static DecodeStatus DecodeJumpTargetXMM(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
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)
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)
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")
#define LLVM_EXTERNAL_VISIBILITY
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)
#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)
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)