30#define DEBUG_TYPE "Xtensa-disassembler"
43 bool hasDensity()
const {
return STI.
hasFeature(Xtensa::FeatureDensity); }
45 bool hasESP32S3Ops()
const {
58 return new XtensaDisassembler(STI, Ctx,
true);
67 Xtensa::A0, Xtensa::SP, Xtensa::A2, Xtensa::A3, Xtensa::A4, Xtensa::A5,
68 Xtensa::A6, Xtensa::A7, Xtensa::A8, Xtensa::A9, Xtensa::A10, Xtensa::A11,
69 Xtensa::A12, Xtensa::A13, Xtensa::A14, Xtensa::A15};
116 Xtensa::Q3, Xtensa::Q4, Xtensa::Q5,
117 Xtensa::Q6, Xtensa::Q7};
151 const XtensaDisassembler *Dis =
152 static_cast<const XtensaDisassembler *
>(
Decoder);
169 {Xtensa::LBEG, 0}, {Xtensa::LEND, 1},
170 {Xtensa::LCOUNT, 2}, {Xtensa::SAR, 3},
171 {Xtensa::BREG, 4}, {Xtensa::LITBASE, 5},
172 {Xtensa::SCOMPARE1, 12}, {Xtensa::ACCLO, 16},
173 {Xtensa::ACCHI, 17}, {Xtensa::M0, 32},
174 {Xtensa::M1, 33}, {Xtensa::M2, 34},
175 {Xtensa::M3, 35}, {Xtensa::WINDOWBASE, 72},
176 {Xtensa::WINDOWSTART, 73}, {Xtensa::IBREAKENABLE, 96},
177 {Xtensa::MEMCTL, 97}, {Xtensa::ATOMCTL, 99},
178 {Xtensa::DDR, 104}, {Xtensa::IBREAKA0, 128},
179 {Xtensa::IBREAKA1, 129}, {Xtensa::DBREAKA0, 144},
180 {Xtensa::DBREAKA1, 145}, {Xtensa::DBREAKC0, 160},
181 {Xtensa::DBREAKC1, 161}, {Xtensa::CONFIGID0, 176},
182 {Xtensa::EPC1, 177}, {Xtensa::EPC2, 178},
183 {Xtensa::EPC3, 179}, {Xtensa::EPC4, 180},
184 {Xtensa::EPC5, 181}, {Xtensa::EPC6, 182},
185 {Xtensa::EPC7, 183}, {Xtensa::DEPC, 192},
186 {Xtensa::EPS2, 194}, {Xtensa::EPS3, 195},
187 {Xtensa::EPS4, 196}, {Xtensa::EPS5, 197},
188 {Xtensa::EPS6, 198}, {Xtensa::EPS7, 199},
189 {Xtensa::CONFIGID1, 208}, {Xtensa::EXCSAVE1, 209},
190 {Xtensa::EXCSAVE2, 210}, {Xtensa::EXCSAVE3, 211},
191 {Xtensa::EXCSAVE4, 212}, {Xtensa::EXCSAVE5, 213},
192 {Xtensa::EXCSAVE6, 214}, {Xtensa::EXCSAVE7, 215},
193 {Xtensa::CPENABLE, 224}, {Xtensa::INTERRUPT, 226},
194 {Xtensa::INTCLEAR, 227}, {Xtensa::INTENABLE, 228},
195 {Xtensa::PS, 230}, {Xtensa::VECBASE, 231},
196 {Xtensa::EXCCAUSE, 232}, {Xtensa::DEBUGCAUSE, 233},
197 {Xtensa::CCOUNT, 234}, {Xtensa::PRID, 235},
198 {Xtensa::ICOUNT, 236}, {Xtensa::ICOUNTLEVEL, 237},
199 {Xtensa::EXCVADDR, 238}, {Xtensa::CCOMPARE0, 240},
200 {Xtensa::CCOMPARE1, 241}, {Xtensa::CCOMPARE2, 242},
201 {Xtensa::MISC0, 244}, {Xtensa::MISC1, 245},
202 {Xtensa::MISC2, 246}, {Xtensa::MISC3, 247}};
223 Reg = Xtensa::INTSET;
227 Reg,
Decoder->getSubtargetInfo().getFeatureBits(), RAType))
259 int64_t Address,
const void *
Decoder) {
267 int64_t Address,
const void *
Decoder) {
274 int64_t Address,
const void *
Decoder) {
295 int64_t Address,
const void *
Decoder) {
305 int64_t Address,
const void *
Decoder) {
314 int64_t Address,
const void *
Decoder) {
329 int64_t Address,
const void *
Decoder) {
336 int64_t Address,
const void *
Decoder) {
343 int64_t Address,
const void *
Decoder) {
350 int64_t Address,
const void *
Decoder) {
371 if ((
Imm & 0x60) == 0x60)
379 int64_t Address,
const void *
Decoder) {
410 8, 10, 12, 16, 32, 64, 128, 256};
412 int64_t Address,
const void *
Decoder) {
420 8, 10, 12, 16, 32, 64, 128, 256};
431 int64_t Address,
const void *
Decoder) {
481 if ((
Imm & 0xf) != 0)
492 if ((
Imm & 0x7) != 0)
503 if ((
Imm & 0xf) != 0)
514 if ((
Imm & 0x2) != 0)
525 if ((
Imm & 0x1) != 0)
544 if ((
Imm & 0xf) != 0)
552 int64_t Address,
const void *
Decoder) {
560 int64_t Address,
const void *
Decoder) {
568 int64_t Address,
const void *
Decoder) {
576 int64_t Address,
const void *
Decoder) {
587 bool IsLittleEndian) {
589 if (Bytes.
size() < 2) {
594 if (!IsLittleEndian) {
597 Insn = (Bytes[1] << 8) | Bytes[0];
607 bool CheckTIE =
false) {
609 if (Bytes.
size() < 3) {
614 if (!IsLittleEndian) {
617 if (CheckTIE && (Bytes[0] & 0x8) != 0)
619 Insn = (Bytes[2] << 16) | (Bytes[1] << 8) | (Bytes[0] << 0);
628 bool IsLittleEndian) {
630 if (Bytes.
size() < 4) {
635 if (!IsLittleEndian) {
638 if ((Bytes[0] & 0x8) == 0)
641 (Bytes[3] << 24) | (Bytes[2] << 16) | (Bytes[1] << 8) | (Bytes[0] << 0);
647#include "XtensaGenDisassemblerTables.inc"
661 LLVM_DEBUG(
dbgs() <<
"Trying Xtensa 16-bit instruction table :\n");
662 Result = decodeInstruction(DecoderTable16,
MI, Insn,
Address,
this, STI);
673 LLVM_DEBUG(
dbgs() <<
"Trying Xtensa 24-bit instruction table :\n");
674 Result = decodeInstruction(DecoderTable24,
MI, Insn,
Address,
this, STI);
680 if (hasESP32S3Ops()) {
686 Result = decodeInstruction(DecoderTableESP32S324,
MI, Insn,
Address,
this,
700 decodeInstruction(DecoderTableESP32S332,
MI, Insn,
Address,
this, STI);
MCDisassembler::DecodeStatus DecodeStatus
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
unsigned const MCDisassembler * Decoder
static bool readInstruction16(ArrayRef< uint8_t > Bytes, uint64_t Address, uint64_t &Size, uint32_t &Insn)
static bool readInstruction32(ArrayRef< uint8_t > Bytes, uint64_t Address, uint64_t &Size, uint32_t &Insn)
#define LLVM_EXTERNAL_VISIBILITY
static bool isBranch(unsigned Opcode)
static DecodeStatus decodeMem16Operand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static DecodeStatus decodeOffset_16_16Operand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static DecodeStatus decodeOffset_128_2Operand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static DecodeStatus decodeSelect_2Operand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static DecodeStatus DecodeMR23RegisterClass(MCInst &Inst, uint64_t RegNo, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeMRRegisterClass(MCInst &Inst, uint64_t RegNo, uint64_t Address, const void *Decoder)
static const unsigned QRDecoderTable[]
static DecodeStatus decodeOffset_256_16Operand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static int64_t TableB4const[16]
static DecodeStatus decodeImm1n_15Operand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static DecodeStatus decodeOffset_128_1Operand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static DecodeStatus decodeSelect_16Operand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static DecodeStatus decodeOffset_256_4Operand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static DecodeStatus DecodeFPRRegisterClass(MCInst &Inst, uint64_t RegNo, uint64_t Address, const void *Decoder)
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeXtensaDisassembler()
static DecodeStatus DecodeMR01RegisterClass(MCInst &Inst, uint64_t RegNo, uint64_t Address, const void *Decoder)
static DecodeStatus decodeImm8_sh8Operand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static DecodeStatus decodeImm8Operand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static DecodeStatus decodeL32ROperand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static DecodeStatus decodeEntry_Imm12OpValue(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static DecodeStatus decodeMem32nOperand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static DecodeStatus decodeImm12Operand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static DecodeStatus DecodeARRegisterClass(MCInst &Inst, uint64_t RegNo, uint64_t Address, const void *Decoder)
static bool tryAddingSymbolicOperand(int64_t Value, bool isBranch, uint64_t Address, uint64_t Offset, uint64_t InstSize, MCInst &MI, const void *Decoder)
const MCPhysReg ARDecoderTable[]
static DecodeStatus decodeMem32Operand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static DecodeStatus decodeUimm4Operand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static DecodeStatus DecodeURRegisterClass(MCInst &Inst, uint64_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus decodeSelect_256Operand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static DecodeStatus decodeImm64n_4nOperand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static DecodeStatus decodeImm1_16Operand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static DecodeStatus readInstruction24(ArrayRef< uint8_t > Bytes, uint64_t Address, uint64_t &Size, uint64_t &Insn, bool IsLittleEndian, bool CheckTIE=false)
Read three bytes from the ArrayRef and return 24 bit data.
static DecodeStatus decodeMem8Operand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static DecodeStatus DecodeQRRegisterClass(MCInst &Inst, uint64_t RegNo, uint64_t Address, const void *Decoder)
static DecodeStatus decodeImm7_22Operand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static DecodeStatus decodeUimm5Operand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static DecodeStatus decodeImm32n_95Operand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static DecodeStatus readInstruction16(ArrayRef< uint8_t > Bytes, uint64_t Address, uint64_t &Size, uint64_t &Insn, bool IsLittleEndian)
Read two bytes from the ArrayRef and return 16 bit data sorted according to the given endianness.
static DecodeStatus decodeSelect_4Operand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static MCDisassembler * createXtensaDisassembler(const Target &T, const MCSubtargetInfo &STI, MCContext &Ctx)
static DecodeStatus decodeOffset_256_8Operand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static DecodeStatus decodeCallOperand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static DecodeStatus decodeB4constuOperand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static DecodeStatus decodeB4constOperand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static DecodeStatus decodeImm8n_7Operand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static int64_t TableB4constu[16]
static DecodeStatus DecodeSRRegisterClass(MCInst &Inst, uint64_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus decodeOffset_64_16Operand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static DecodeStatus DecodeBRRegisterClass(MCInst &Inst, uint64_t RegNo, uint64_t Address, const void *Decoder)
static DecodeStatus decodeShimm1_31Operand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static DecodeStatus decodeSelect_8Operand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static DecodeStatus decodeLoopOperand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static DecodeStatus decodeJumpOperand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static DecodeStatus decodeBranchOperand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
const DecodeRegister SRDecoderTable[]
static DecodeStatus readInstruction32(ArrayRef< uint8_t > Bytes, uint64_t Address, uint64_t &Size, uint64_t &Insn, bool IsLittleEndian)
Read four bytes from the ArrayRef and return 32 bit data.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
Get the array size.
Context object for machine code objects.
Superclass for all disassemblers.
bool tryAddingSymbolicOperand(MCInst &Inst, int64_t Value, uint64_t Address, bool IsBranch, uint64_t Offset, uint64_t OpSize, uint64_t InstSize) const
DecodeStatus
Ternary decode status.
Instances of this class represent a single low-level machine instruction.
unsigned getOpcode() const
void addOperand(const MCOperand Op)
static MCOperand createReg(MCRegister 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
const FeatureBitset & getFeatureBits() 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.
bool checkRegister(MCRegister RegNo, const FeatureBitset &FeatureBits, RegisterAccessType RA)
MCRegister getUserRegister(unsigned Code, const MCRegisterInfo &MRI)
This is an optimization pass for GlobalISel generic memory operations.
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.
Target & getTheXtensaTarget()
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
constexpr int64_t SignExtend64(uint64_t x)
Sign-extend the number in the bottom B bits of X to a 64-bit integer.
static void RegisterMCDisassembler(Target &T, Target::MCDisassemblerCtorTy Fn)
RegisterMCDisassembler - Register a MCDisassembler implementation for the given target.