34#define DEBUG_TYPE "mips-disassembler"
47 IsMicroMips(STI.
hasFeature(Mips::FeatureMicroMips)),
48 IsBigEndian(IsBigEndian) {}
50 bool hasMips2()
const {
return STI.
hasFeature(Mips::FeatureMips2); }
51 bool hasMips3()
const {
return STI.
hasFeature(Mips::FeatureMips3); }
52 bool hasMips32()
const {
return STI.
hasFeature(Mips::FeatureMips32); }
54 bool hasMips32r6()
const {
58 bool isFP64()
const {
return STI.
hasFeature(Mips::FeatureFP64Bit); }
60 bool isGP64()
const {
return STI.
hasFeature(Mips::FeatureGP64Bit); }
62 bool isPTR64()
const {
return STI.
hasFeature(Mips::FeaturePTR64Bit); }
64 bool hasCnMips()
const {
return STI.
hasFeature(Mips::FeatureCnMips); }
66 bool hasCnMipsP()
const {
return STI.
hasFeature(Mips::FeatureCnMipsP); }
68 bool hasCOP3()
const {
70 return !hasMips32() && !hasMips3();
346template <
unsigned Bits,
int Offset,
int Scale>
351template <
unsigned Bits,
int Offset>
355 return DecodeUImmWithOffsetAndScale<Bits, Offset, 1>(Inst,
Value, Address,
359template <
unsigned Bits,
int Offset = 0,
int ScaleBy = 1>
388template <
typename InsnType>
392template <
typename InsnType>
397template <
typename InsnType>
401template <
typename InsnType>
406template <
typename InsnType>
411template <
typename InsnType>
416template <
typename InsnType>
421template <
typename InsnType>
426template <
typename InsnType>
431template <
typename InsnType>
436template <
typename InsnType>
441template <
typename InsnType>
446template <
typename InsnType>
451template <
typename InsnType>
456template <
typename InsnType>
461template <
typename InsnType>
465template <
typename InsnType>
469template <
typename InsnType>
497 return new MipsDisassembler(STI, Ctx,
true);
504 return new MipsDisassembler(STI, Ctx,
false);
519#include "MipsGenDisassemblerTables.inc"
523 return *(
RegInfo->getRegClass(RC).begin() + RegNo);
526template <
typename InsnType>
534 InsnType tmp = fieldFromInstruction(insn, 17, 5);
536 DecodeFN RegDecoder =
nullptr;
537 if ((tmp & 0x18) == 0x00) {
540 }
else if ((tmp & 0x1c) == 0x10) {
543 }
else if ((tmp & 0x1e) == 0x18) {
546 }
else if ((tmp & 0x1f) == 0x1c) {
552 assert(NSize != 0 && RegDecoder !=
nullptr);
555 tmp = fieldFromInstruction(insn, 6, 5);
562 tmp = fieldFromInstruction(insn, 16, NSize);
565 tmp = fieldFromInstruction(insn, 11, 5);
574template <
typename InsnType>
578 InsnType Rs = fieldFromInstruction(insn, 16, 5);
579 InsnType Imm = fieldFromInstruction(insn, 0, 16);
589template <
typename InsnType>
592 InsnType Rs = fieldFromInstruction(insn, 21, 5);
593 InsnType Imm = fieldFromInstruction(insn, 0, 16);
603template <
typename InsnType>
617 InsnType Rs = fieldFromInstruction(insn, 21, 5);
618 InsnType Rt = fieldFromInstruction(insn, 16, 5);
619 int64_t Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
623 MI.setOpcode(Mips::BOVC);
625 }
else if (Rs != 0 && Rs < Rt) {
626 MI.setOpcode(Mips::BEQC);
629 MI.setOpcode(Mips::BEQZALC);
642template <
typename InsnType>
646 InsnType Rt = fieldFromInstruction(insn, 21, 5);
647 InsnType Rs = fieldFromInstruction(insn, 16, 5);
651 MI.setOpcode(Mips::BOVC_MMR6);
656 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 2 + 4;
657 }
else if (Rs != 0 && Rs < Rt) {
658 MI.setOpcode(Mips::BEQC_MMR6);
663 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
665 MI.setOpcode(Mips::BEQZALC_MMR6);
668 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 2 + 4;
676template <
typename InsnType>
690 InsnType Rs = fieldFromInstruction(insn, 21, 5);
691 InsnType Rt = fieldFromInstruction(insn, 16, 5);
692 int64_t Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
696 MI.setOpcode(Mips::BNVC);
698 }
else if (Rs != 0 && Rs < Rt) {
699 MI.setOpcode(Mips::BNEC);
702 MI.setOpcode(Mips::BNEZALC);
715template <
typename InsnType>
719 InsnType Rt = fieldFromInstruction(insn, 21, 5);
720 InsnType Rs = fieldFromInstruction(insn, 16, 5);
724 MI.setOpcode(Mips::BNVC_MMR6);
729 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 2 + 4;
730 }
else if (Rs != 0 && Rs < Rt) {
731 MI.setOpcode(Mips::BNEC_MMR6);
736 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
738 MI.setOpcode(Mips::BNEZALC_MMR6);
741 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 2 + 4;
749template <
typename InsnType>
760 InsnType Rt = fieldFromInstruction(insn, 21, 5);
761 InsnType Rs = fieldFromInstruction(insn, 16, 5);
762 int64_t Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
768 MI.setOpcode(Mips::BGTZC_MMR6);
770 MI.setOpcode(Mips::BLTZC_MMR6);
772 MI.setOpcode(Mips::BLTC_MMR6);
788template <
typename InsnType>
799 InsnType Rt = fieldFromInstruction(insn, 21, 5);
800 InsnType Rs = fieldFromInstruction(insn, 16, 5);
801 int64_t Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
807 MI.setOpcode(Mips::BLEZC_MMR6);
809 MI.setOpcode(Mips::BGEZC_MMR6);
812 MI.setOpcode(Mips::BGEC_MMR6);
827template <
typename InsnType>
842 InsnType Rs = fieldFromInstruction(insn, 21, 5);
843 InsnType Rt = fieldFromInstruction(insn, 16, 5);
844 int64_t Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
850 MI.setOpcode(Mips::BLEZC);
852 MI.setOpcode(Mips::BGEZC);
855 MI.setOpcode(Mips::BGEC);
870template <
typename InsnType>
887 InsnType Rs = fieldFromInstruction(insn, 21, 5);
888 InsnType Rt = fieldFromInstruction(insn, 16, 5);
889 int64_t Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
894 MI.setOpcode(Mips::BGTZC);
896 MI.setOpcode(Mips::BLTZC);
898 MI.setOpcode(Mips::BLTC);
914template <
typename InsnType>
929 InsnType Rs = fieldFromInstruction(insn, 21, 5);
930 InsnType Rt = fieldFromInstruction(insn, 16, 5);
931 int64_t Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
936 MI.setOpcode(Mips::BGTZ);
938 }
else if (Rs == 0) {
939 MI.setOpcode(Mips::BGTZALC);
941 }
else if (Rs == Rt) {
942 MI.setOpcode(Mips::BLTZALC);
945 MI.setOpcode(Mips::BLTUC);
963template <
typename InsnType>
978 InsnType Rs = fieldFromInstruction(insn, 21, 5);
979 InsnType Rt = fieldFromInstruction(insn, 16, 5);
980 int64_t Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
986 MI.setOpcode(Mips::BLEZALC);
988 MI.setOpcode(Mips::BGEZALC);
991 MI.setOpcode(Mips::BGEUC);
1007template <
typename InsnType>
1010 unsigned Msbd = fieldFromInstruction(
Insn, 11, 5);
1011 unsigned Lsb = fieldFromInstruction(
Insn, 6, 5);
1015 switch (
MI.getOpcode()) {
1022 Size = Msbd + 1 + 32;
1032 MI.setOpcode(Mips::DEXT);
1034 InsnType Rs = fieldFromInstruction(
Insn, 21, 5);
1035 InsnType Rt = fieldFromInstruction(
Insn, 16, 5);
1049template <
typename InsnType>
1052 unsigned Msbd = fieldFromInstruction(
Insn, 11, 5);
1053 unsigned Lsb = fieldFromInstruction(
Insn, 6, 5);
1057 switch (
MI.getOpcode()) {
1060 Size = Msbd + 1 - Pos;
1064 Size = Msbd + 33 - Pos;
1070 Size = Msbd + 33 - Pos;
1076 InsnType Rs = fieldFromInstruction(
Insn, 21, 5);
1077 InsnType Rt = fieldFromInstruction(
Insn, 16, 5);
1079 MI.setOpcode(Mips::DINS);
1091template <
typename InsnType>
1094 InsnType Rs = fieldFromInstruction(
Insn, 21, 5);
1095 InsnType Rt = fieldFromInstruction(
Insn, 16, 5);
1111 if (Bytes.
size() < 2) {
1117 Insn = (Bytes[0] << 8) | Bytes[1];
1119 Insn = (Bytes[1] << 8) | Bytes[0];
1129 bool IsBigEndian,
bool IsMicroMips) {
1131 if (Bytes.
size() < 4) {
1147 (Bytes[3] << 0) | (Bytes[2] << 8) | (Bytes[1] << 16) | (Bytes[0] << 24);
1150 Insn = (Bytes[2] << 0) | (Bytes[3] << 8) | (Bytes[0] << 16) |
1153 Insn = (Bytes[0] << 0) | (Bytes[1] << 8) | (Bytes[2] << 16) |
1174 if (hasMips32r6()) {
1176 dbgs() <<
"Trying MicroMipsR616 table (16-bit instructions):\n");
1179 Result = decodeInstruction(DecoderTableMicroMipsR616, Instr,
Insn,
1180 Address,
this, STI);
1187 LLVM_DEBUG(
dbgs() <<
"Trying MicroMips16 table (16-bit instructions):\n");
1190 Result = decodeInstruction(DecoderTableMicroMips16, Instr,
Insn, Address,
1201 if (hasMips32r6()) {
1203 dbgs() <<
"Trying MicroMips32r632 table (32-bit instructions):\n");
1205 Result = decodeInstruction(DecoderTableMicroMipsR632, Instr,
Insn,
1206 Address,
this, STI);
1213 LLVM_DEBUG(
dbgs() <<
"Trying MicroMips32 table (32-bit instructions):\n");
1215 Result = decodeInstruction(DecoderTableMicroMips32, Instr,
Insn, Address,
1223 LLVM_DEBUG(
dbgs() <<
"Trying MicroMipsFP64 table (32-bit opcodes):\n");
1224 Result = decodeInstruction(DecoderTableMicroMipsFP6432, Instr,
Insn,
1225 Address,
this, STI);
1254 decodeInstruction(DecoderTableCOP3_32, Instr,
Insn, Address,
this, STI);
1259 if (hasMips32r6() && isGP64()) {
1261 dbgs() <<
"Trying Mips32r6_64r6 (GPR64) table (32-bit opcodes):\n");
1262 Result = decodeInstruction(DecoderTableMips32r6_64r6_GP6432, Instr,
Insn,
1263 Address,
this, STI);
1268 if (hasMips32r6() && isPTR64()) {
1270 dbgs() <<
"Trying Mips32r6_64r6 (PTR64) table (32-bit opcodes):\n");
1271 Result = decodeInstruction(DecoderTableMips32r6_64r6_PTR6432, Instr,
Insn,
1272 Address,
this, STI);
1277 if (hasMips32r6()) {
1278 LLVM_DEBUG(
dbgs() <<
"Trying Mips32r6_64r6 table (32-bit opcodes):\n");
1279 Result = decodeInstruction(DecoderTableMips32r6_64r632, Instr,
Insn,
1280 Address,
this, STI);
1285 if (hasMips2() && isPTR64()) {
1287 dbgs() <<
"Trying Mips32r6_64r6 (PTR64) table (32-bit opcodes):\n");
1288 Result = decodeInstruction(DecoderTableMips32_64_PTR6432, Instr,
Insn,
1289 Address,
this, STI);
1296 Result = decodeInstruction(DecoderTableCnMips32, Instr,
Insn,
1297 Address,
this, STI);
1303 LLVM_DEBUG(
dbgs() <<
"Trying CnMipsP table (32-bit opcodes):\n");
1304 Result = decodeInstruction(DecoderTableCnMipsP32, Instr,
Insn,
1305 Address,
this, STI);
1311 LLVM_DEBUG(
dbgs() <<
"Trying Mips64 (GPR64) table (32-bit opcodes):\n");
1312 Result = decodeInstruction(DecoderTableMips6432, Instr,
Insn,
1313 Address,
this, STI);
1320 dbgs() <<
"Trying MipsFP64 (64 bit FPU) table (32-bit opcodes):\n");
1321 Result = decodeInstruction(DecoderTableMipsFP6432, Instr,
Insn,
1322 Address,
this, STI);
1330 decodeInstruction(DecoderTableMips32, Instr,
Insn, Address,
this, STI);
1349 unsigned Reg =
getReg(Decoder, Mips::GPR64RegClassID, RegNo);
1359 unsigned Reg =
getReg(Decoder, Mips::GPRMM16RegClassID, RegNo);
1369 unsigned Reg =
getReg(Decoder, Mips::GPRMM16ZeroRegClassID, RegNo);
1379 unsigned Reg =
getReg(Decoder, Mips::GPRMM16MovePRegClassID, RegNo);
1389 unsigned Reg =
getReg(Decoder, Mips::GPR32RegClassID, RegNo);
1397 if (
static_cast<const MipsDisassembler *
>(Decoder)->isGP64())
1415 unsigned Reg =
getReg(Decoder, Mips::FGR64RegClassID, RegNo);
1426 unsigned Reg =
getReg(Decoder, Mips::FGR32RegClassID, RegNo);
1436 unsigned Reg =
getReg(Decoder, Mips::CCRRegClassID, RegNo);
1446 unsigned Reg =
getReg(Decoder, Mips::FCCRegClassID, RegNo);
1457 unsigned Reg =
getReg(Decoder, Mips::FGRCCRegClassID, RegNo);
1464 int Offset = SignExtend32<16>(
Insn & 0xffff);
1465 unsigned Reg = fieldFromInstruction(
Insn, 16, 5);
1466 unsigned Base = fieldFromInstruction(
Insn, 21, 5);
1468 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1485 unsigned Reg = fieldFromInstruction(
Insn, 16, 5);
1486 unsigned Base = fieldFromInstruction(
Insn, 21, 5);
1488 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1504 int Offset = SignExtend32<16>(
Insn & 0xffff);
1505 unsigned Base = fieldFromInstruction(
Insn, 16, 5);
1506 unsigned Reg = fieldFromInstruction(
Insn, 21, 5);
1509 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1520 int Offset = SignExtend32<16>(
Insn & 0xffff);
1521 unsigned Hint = fieldFromInstruction(
Insn, 16, 5);
1522 unsigned Base = fieldFromInstruction(
Insn, 21, 5);
1537 unsigned Base = fieldFromInstruction(
Insn, 16, 5);
1538 unsigned Hint = fieldFromInstruction(
Insn, 21, 5);
1553 unsigned Base = fieldFromInstruction(
Insn, 16, 5);
1554 unsigned Hint = fieldFromInstruction(
Insn, 21, 5);
1569 unsigned Hint = fieldFromInstruction(
Insn, 16, 5);
1570 unsigned Base = fieldFromInstruction(
Insn, 21, 5);
1583 int Offset = SignExtend32<16>(
Insn & 0xffff);
1584 unsigned Base = fieldFromInstruction(
Insn, 21, 5);
1597 int Offset = SignExtend32<16>(
Insn & 0xffff);
1598 unsigned Base = fieldFromInstruction(
Insn, 16, 5);
1610 int Immediate = SignExtend32<16>(
Insn & 0xffff);
1611 unsigned Base = fieldFromInstruction(
Insn, 16, 5);
1624 int Offset = SignExtend32<10>(fieldFromInstruction(
Insn, 16, 10));
1625 unsigned Reg = fieldFromInstruction(
Insn, 6, 5);
1626 unsigned Base = fieldFromInstruction(
Insn, 11, 5);
1628 Reg =
getReg(Decoder, Mips::MSA128BRegClassID, Reg);
1644 assert(
false &&
"Unexpected instruction");
1672 unsigned Reg = fieldFromInstruction(
Insn, 7, 3);
1673 unsigned Base = fieldFromInstruction(
Insn, 4, 3);
1676 case Mips::LBU16_MM:
1677 case Mips::LHU16_MM:
1684 case Mips::SB16_MMR6:
1686 case Mips::SH16_MMR6:
1688 case Mips::SW16_MMR6:
1700 case Mips::LBU16_MM:
1707 case Mips::SB16_MMR6:
1710 case Mips::LHU16_MM:
1712 case Mips::SH16_MMR6:
1717 case Mips::SW16_MMR6:
1729 unsigned Reg = fieldFromInstruction(
Insn, 5, 5);
1731 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1744 unsigned Reg = fieldFromInstruction(
Insn, 7, 3);
1746 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1760 case Mips::LWM16_MMR6:
1761 case Mips::SWM16_MMR6:
1783 unsigned Reg = fieldFromInstruction(
Insn, 21, 5);
1784 unsigned Base = fieldFromInstruction(
Insn, 16, 5);
1786 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1802 int Offset = SignExtend32<12>(
Insn & 0x0fff);
1803 unsigned Reg = fieldFromInstruction(
Insn, 21, 5);
1804 unsigned Base = fieldFromInstruction(
Insn, 16, 5);
1806 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1810 case Mips::SWM32_MM:
1811 case Mips::LWM32_MM:
1836 int Offset = SignExtend32<16>(
Insn & 0xffff);
1837 unsigned Reg = fieldFromInstruction(
Insn, 21, 5);
1838 unsigned Base = fieldFromInstruction(
Insn, 16, 5);
1840 Reg =
getReg(Decoder, Mips::GPR32RegClassID, Reg);
1852 int Offset = SignExtend32<16>(
Insn & 0xffff);
1853 unsigned Reg = fieldFromInstruction(
Insn, 16, 5);
1854 unsigned Base = fieldFromInstruction(
Insn, 21, 5);
1856 Reg =
getReg(Decoder, Mips::FGR64RegClassID, Reg);
1871 int Offset = SignExtend32<16>(
Insn & 0xffff);
1872 unsigned Base = fieldFromInstruction(
Insn, 16, 5);
1873 unsigned Reg = fieldFromInstruction(
Insn, 21, 5);
1875 Reg =
getReg(Decoder, Mips::FGR64RegClassID, Reg);
1887 int Offset = SignExtend32<16>(
Insn & 0xffff);
1888 unsigned Reg = fieldFromInstruction(
Insn, 16, 5);
1889 unsigned Base = fieldFromInstruction(
Insn, 21, 5);
1891 Reg =
getReg(Decoder, Mips::COP2RegClassID, Reg);
1903 int Offset = SignExtend32<16>(
Insn & 0xffff);
1904 unsigned Reg = fieldFromInstruction(
Insn, 16, 5);
1905 unsigned Base = fieldFromInstruction(
Insn, 21, 5);
1907 Reg =
getReg(Decoder, Mips::COP3RegClassID, Reg);
1920 int Offset = SignExtend32<11>(
Insn & 0x07ff);
1921 unsigned Reg = fieldFromInstruction(
Insn, 16, 5);
1922 unsigned Base = fieldFromInstruction(
Insn, 11, 5);
1924 Reg =
getReg(Decoder, Mips::COP2RegClassID, Reg);
1937 int Offset = SignExtend32<11>(
Insn & 0x07ff);
1938 unsigned Reg = fieldFromInstruction(
Insn, 21, 5);
1939 unsigned Base = fieldFromInstruction(
Insn, 16, 5);
1941 Reg =
getReg(Decoder, Mips::COP2RegClassID, Reg);
1954 int64_t
Offset = SignExtend64<9>((
Insn >> 7) & 0x1ff);
1955 unsigned Rt = fieldFromInstruction(
Insn, 16, 5);
1956 unsigned Base = fieldFromInstruction(
Insn, 21, 5);
1958 Rt =
getReg(Decoder, Mips::GPR32RegClassID, Rt);
1985 if (RegNo > 30 || RegNo %2)
1988 unsigned Reg =
getReg(Decoder, Mips::AFGR64RegClassID, RegNo /2);
1999 unsigned Reg =
getReg(Decoder, Mips::ACC64DSPRegClassID, RegNo);
2010 unsigned Reg =
getReg(Decoder, Mips::HI32DSPRegClassID, RegNo);
2021 unsigned Reg =
getReg(Decoder, Mips::LO32DSPRegClassID, RegNo);
2032 unsigned Reg =
getReg(Decoder, Mips::MSA128BRegClassID, RegNo);
2043 unsigned Reg =
getReg(Decoder, Mips::MSA128HRegClassID, RegNo);
2054 unsigned Reg =
getReg(Decoder, Mips::MSA128WRegClassID, RegNo);
2065 unsigned Reg =
getReg(Decoder, Mips::MSA128DRegClassID, RegNo);
2076 unsigned Reg =
getReg(Decoder, Mips::MSACtrlRegClassID, RegNo);
2087 unsigned Reg =
getReg(Decoder, Mips::COP0RegClassID, RegNo);
2098 unsigned Reg =
getReg(Decoder, Mips::COP2RegClassID, RegNo);
2106 int32_t BranchOffset = (SignExtend32<16>(
Offset) * 4) + 4;
2114 int32_t BranchOffset = (SignExtend32<16>(
Offset) * 2);
2122 unsigned JumpOffset = fieldFromInstruction(
Insn, 0, 26) << 2;
2130 int32_t BranchOffset = SignExtend32<21>(
Offset) * 4 + 4;
2139 int32_t BranchOffset = SignExtend32<21>(
Offset) * 4 + 4;
2148 int32_t BranchOffset = SignExtend32<26>(
Offset) * 4 + 4;
2157 int32_t BranchOffset = SignExtend32<8>(
Offset << 1);
2165 int32_t BranchOffset = SignExtend32<11>(
Offset << 1);
2173 int32_t BranchOffset = SignExtend32<16>(
Offset) * 2 + 4;
2181 int32_t BranchOffset = SignExtend32<27>(
Offset << 1);
2190 unsigned JumpOffset = fieldFromInstruction(
Insn, 0, 26) << 1;
2198 unsigned JumpOffset = fieldFromInstruction(
Insn, 0, 26) << 2;
2208 else if (
Value == 0x7)
2232template <
unsigned Bits,
int Offset,
int Scale>
2236 Value &= ((1 << Bits) - 1);
2242template <
unsigned Bits,
int Offset,
int ScaleBy>
2246 int32_t Imm = SignExtend32<Bits>(
Value) * ScaleBy;
2278 int32_t DecodedValue;
2280 case 0: DecodedValue = 256;
break;
2281 case 1: DecodedValue = 257;
break;
2282 case 510: DecodedValue = -258;
break;
2283 case 511: DecodedValue = -257;
break;
2284 default: DecodedValue = SignExtend32<9>(
Insn);
break;
2295 int32_t DecodedValues[] = {128, 1, 2, 3, 4, 7, 8, 15, 16, 31, 32, 63, 64,
2304 unsigned Regs[] = {Mips::S0, Mips::S1, Mips::S2, Mips::S3, Mips::S4, Mips::S5,
2305 Mips::S6, Mips::S7, Mips::FP};
2308 unsigned RegLst = fieldFromInstruction(
Insn, 21, 5);
2314 RegNum = RegLst & 0xf;
2320 for (
unsigned i = 0; i < RegNum; i++)
2332 unsigned Regs[] = {Mips::S0, Mips::S1, Mips::S2, Mips::S3};
2336 RegLst = fieldFromInstruction(
Insn, 4, 2);
2338 case Mips::LWM16_MMR6:
2339 case Mips::SWM16_MMR6:
2340 RegLst = fieldFromInstruction(
Insn, 8, 2);
2343 unsigned RegNum = RegLst & 0x3;
2345 for (
unsigned i = 0; i <= RegNum; i++)
2356 unsigned RegPair = fieldFromInstruction(
Insn, 7, 3);
2362 if (
static_cast<const MipsDisassembler*
>(Decoder)->hasMips32r6())
2363 RegRs = fieldFromInstruction(
Insn, 0, 2) |
2364 (fieldFromInstruction(
Insn, 3, 1) << 2);
2366 RegRs = fieldFromInstruction(
Insn, 1, 3);
2371 unsigned RegRt = fieldFromInstruction(
Insn, 4, 3);
2429template <
typename InsnType>
2440 InsnType Rt = fieldFromInstruction(insn, 21, 5);
2441 InsnType Rs = fieldFromInstruction(insn, 16, 5);
2449 MI.setOpcode(Mips::BGTZALC_MMR6);
2451 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 2 + 4;
2453 else if (Rs == Rt) {
2454 MI.setOpcode(Mips::BLTZALC_MMR6);
2456 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 2 + 4;
2459 MI.setOpcode(Mips::BLTUC_MMR6);
2462 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
2478template <
typename InsnType>
2489 InsnType Rt = fieldFromInstruction(insn, 21, 5);
2490 InsnType Rs = fieldFromInstruction(insn, 16, 5);
2497 MI.setOpcode(Mips::BLEZALC_MMR6);
2498 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 2 + 4;
2500 else if (Rs == Rt) {
2501 MI.setOpcode(Mips::BGEZALC_MMR6);
2502 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 2 + 4;
2506 MI.setOpcode(Mips::BGEUC_MMR6);
2507 Imm =
SignExtend64(fieldFromInstruction(insn, 0, 16), 16) * 4 + 4;
SmallVector< AArch64_IMM::ImmInsnModel, 4 > Insn
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
#define LLVM_EXTERNAL_VISIBILITY
static DecodeStatus DecodePOOL16BEncodedField(MCInst &Inst, unsigned Value, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeFMemCop2MMR6(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeSimm19Lsl2(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeMemEVA(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeBgtzlGroupBranch(MCInst &MI, InsnType insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeRegListOperand(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *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 DecodeBranchTarget21(MCInst &Inst, unsigned Offset, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeJumpTargetXMM(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeFGR32RegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeCCRRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeCOP2RegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const MCDisassembler *Decoder)
static unsigned getReg(const MCDisassembler *D, unsigned RC, unsigned RegNo)
static DecodeStatus DecodeFCCRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeCacheOpMM(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *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 DecodeGPRMM16RegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeSImmWithOffsetAndScale(MCInst &Inst, unsigned Value, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeSimm23Lsl2(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeGPRMM16MovePRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeBranchTarget1SImm16(MCInst &Inst, unsigned Offset, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeMemMMImm9(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeMovePOperands(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeCRC(MCInst &MI, InsnType Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodePOP75GroupBranchMMR6(MCInst &MI, InsnType insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeDINS(MCInst &MI, InsnType Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeMSA128Mem(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodePrefeOpMM(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeCPU16RegsRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeMSA128WRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeBranchTarget26(MCInst &Inst, unsigned Offset, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeFMem(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeCacheOp(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeSyncI_MM(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeLoadByte15(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeSimm9SP(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeFMem2(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeUImmWithOffsetAndScale(MCInst &Inst, unsigned Value, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeMemMMImm12(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeDEXT(MCInst &MI, InsnType Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeGPRMM16ZeroRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodePtrRegisterClass(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeLi16Imm(MCInst &Inst, unsigned Value, uint64_t Address, const MCDisassembler *Decoder)
static MCDisassembler * createMipselDisassembler(const Target &T, const MCSubtargetInfo &STI, MCContext &Ctx)
static DecodeStatus DecodeSimm18Lsl3(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeFMem3(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeBlezlGroupBranch(MCInst &MI, InsnType insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeCOP0RegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeBranchTarget(MCInst &Inst, unsigned Offset, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeMemMMReglistImm4Lsl2(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeBgtzGroupBranch(MCInst &MI, InsnType insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeBranchTargetMM(MCInst &Inst, unsigned Offset, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodePOP35GroupBranchMMR6(MCInst &MI, InsnType insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeFIXMEInstruction(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeBranchTarget10MM(MCInst &Inst, unsigned Offset, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeANDI16Imm(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeMSA128DRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeMemMMImm4(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static MCDisassembler * createMipsDisassembler(const Target &T, const MCSubtargetInfo &STI, MCContext &Ctx)
static DecodeStatus DecodeGPR32RegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeMSA128BRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeHWRegsRegisterClass(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeDaddiGroupBranch(MCInst &MI, InsnType insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeMovePRegPair(MCInst &Inst, unsigned RegPair, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeDAHIDATIMMR6(MCInst &MI, InsnType insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeBranchTarget21MM(MCInst &Inst, unsigned Offset, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeBranchTarget26MM(MCInst &Inst, unsigned Offset, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeAFGR64RegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeDAHIDATI(MCInst &MI, InsnType insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeLO32DSPRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeSpecial3LlSc(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeHI32DSPRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const MCDisassembler *Decoder)
MCDisassembler::DecodeStatus DecodeStatus
static DecodeStatus DecodeSynciR6(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeUImmWithOffset(MCInst &Inst, unsigned Value, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeRegListOperand16(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeAddiGroupBranch(MCInst &MI, InsnType insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeMemMMSPImm5Lsl2(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeAddiur2Simm7(MCInst &Inst, unsigned Value, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeMSACtrlRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeMSA128HRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeFMemMMR2(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeCacheeOp_CacheOpR6(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeMemMMImm16(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeBranchTarget7MM(MCInst &Inst, unsigned Offset, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeFGR64RegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeGPR64RegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeBlezGroupBranchMMR6(MCInst &MI, InsnType insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeJumpTargetMM(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodePOP37GroupBranchMMR6(MCInst &MI, InsnType insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeSyncI(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeJumpTarget(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeACC64DSPRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeFMemCop2R6(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeBgtzGroupBranchMMR6(MCInst &MI, InsnType insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodePOP65GroupBranchMMR6(MCInst &MI, InsnType insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeDSPRRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeInsSize(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMipsDisassembler()
static DecodeStatus DecodeBlezGroupBranch(MCInst &MI, InsnType insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeMem(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeFGRCCRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeINSVE_DF(MCInst &MI, InsnType insn, uint64_t Address, const MCDisassembler *Decoder)
INSVE_[BHWD] have an implicit operand that the generated decoder doesn't handle.
static DecodeStatus DecodeMemMMGPImm7Lsl2(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
Context object for machine code objects.
Superclass for all disassemblers.
DecodeStatus
Ternary decode status.
virtual DecodeStatus getInstruction(MCInst &Instr, uint64_t &Size, ArrayRef< uint8_t > Bytes, uint64_t Address, raw_ostream &CStream) const =0
Returns the disassembly of a single instruction.
Instances of this class represent a single low-level machine instruction.
unsigned getOpcode() const
void addOperand(const MCOperand Op)
const MCOperand & getOperand(unsigned i) const
static MCOperand createReg(unsigned Reg)
static MCOperand createImm(int64_t Val)
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Generic base class for all target subtargets.
bool hasFeature(unsigned Feature) const
Target - Wrapper for Target specific information.
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
Target & getTheMips64Target()
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Target & getTheMips64elTarget()
Target & getTheMipselTarget()
constexpr int64_t SignExtend64(uint64_t x)
Sign-extend the number in the bottom B bits of X to a 64-bit integer.
Target & getTheMipsTarget()
static void RegisterMCDisassembler(Target &T, Target::MCDisassemblerCtorTy Fn)
RegisterMCDisassembler - Register a MCDisassembler implementation for the given target.