30#define DEBUG_TYPE "arc-disassembler"
39 std::unique_ptr<MCInstrInfo const>
const MCII;
57 (Bytes[0] << 16) | (Bytes[1] << 24) | (Bytes[2] << 0) | (Bytes[3] << 8);
83 Insn = (Bytes[0] << 0) | (Bytes[1] << 8);
127 ARC::R0, ARC::R1, ARC::R2, ARC::R3, ARC::R4, ARC::R5, ARC::R6,
128 ARC::R7, ARC::R8, ARC::R9, ARC::R10, ARC::R11, ARC::R12, ARC::R13,
129 ARC::R14, ARC::R15, ARC::R16, ARC::R17, ARC::R18, ARC::R19, ARC::R20,
130 ARC::R21, ARC::R22, ARC::R23, ARC::R24, ARC::R25, ARC::GP, ARC::FP,
131 ARC::SP, ARC::ILINK, ARC::R30, ARC::BLINK};
156#include "ARCGenDisassemblerTables.inc"
174 unsigned S9 = Insn & 0x1ff;
175 unsigned R = (Insn & (0x7fff & ~0x1ff)) >> 9;
203 static_assert(
B > 0,
"field is empty");
213 static_assert(
B > 0,
"field is empty");
224 static_assert(
B > 0,
"field is empty");
225 const unsigned max = (1u <<
B) - 1;
234 unsigned SrcC, DstB, LImm;
251 unsigned DstA, SrcB, LImm;
276 LLVM_DEBUG(
dbgs() <<
"Decoding LdRLimm found non-limm register.");
287 using Field =
decltype(Insn);
293 auto DecodeRegisterOrImm = [&Inst,
Address, Decoder](
Field RegNum,
306 return DecodeRegisterOrImm(
H, Insn >> 16u);
316 using Field =
decltype(Insn);
329 using Field =
decltype(Insn);
340 using Field =
decltype(Insn);
354 if (Bytes.
size() < 2) {
358 uint8_t DecodeByte = (Bytes[1] & 0xF7) >> 3;
361 if (DecodeByte < 0x08) {
363 if (Bytes.
size() < 4) {
368 if (Bytes.
size() >= 8) {
374 decodeInstruction(DecoderTable64, Instr, Insn64, Address,
this, STI);
379 LLVM_DEBUG(
dbgs() <<
"Not a 64-bit instruction, falling back to 32-bit.");
386 return decodeInstruction(DecoderTable32, Instr, Insn32, Address,
this, STI);
388 if (Bytes.
size() >= 6) {
394 decodeInstruction(DecoderTable48, Instr, Insn48, Address,
this, STI);
397 dbgs() <<
"Successfully decoded 16-bit instruction with limm.");
401 dbgs() <<
"Not a 16-bit instruction with limm, try without it.");
409 return decodeInstruction(DecoderTable16, Instr, Insn16, Address,
this, STI);
416 return new ARCDisassembler(STI, Ctx,
T.createMCInstrInfo());
static DecodeStatus DecodeCCRU6Instruction(MCInst &, uint64_t, uint64_t, const MCDisassembler *)
static bool readInstruction48(ArrayRef< uint8_t > Bytes, uint64_t Address, uint64_t &Size, uint64_t &Insn)
static DecodeStatus DecodeLdRLImmInstruction(MCInst &, uint64_t, uint64_t, const MCDisassembler *)
static DecodeStatus DecodeSOPwithRU6(MCInst &, uint64_t, uint64_t, const MCDisassembler *)
static DecodeStatus DecodeMoveHRegInstruction(MCInst &Inst, uint64_t, uint64_t, const MCDisassembler *)
static DecodeStatus DecodeBranchTargetS(MCInst &Inst, unsigned InsnS, uint64_t Address, const MCDisassembler *Decoder)
static unsigned decodeCField(unsigned Insn)
static bool readInstruction64(ArrayRef< uint8_t > Bytes, uint64_t Address, uint64_t &Size, uint64_t &Insn)
static unsigned decodeBField(unsigned Insn)
static MCDisassembler * createARCDisassembler(const Target &T, const MCSubtargetInfo &STI, MCContext &Ctx)
static DecodeStatus DecodeSOPwithRS12(MCInst &, uint64_t, uint64_t, const MCDisassembler *)
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeARCDisassembler()
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)
static DecodeStatus DecodeGPR32RegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeLdLImmInstruction(MCInst &, uint64_t, uint64_t, const MCDisassembler *)
static DecodeStatus DecodeFromCyclicRange(MCInst &Inst, unsigned InsnS, uint64_t Address=0, const MCDisassembler *Decoder=nullptr)
static DecodeStatus DecodeSignedOperand(MCInst &Inst, unsigned InsnS, uint64_t Address=0, const MCDisassembler *Decoder=nullptr)
static DecodeStatus DecodeGBR32ShortRegister(MCInst &Inst, unsigned RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeStLImmInstruction(MCInst &, uint64_t, uint64_t, const MCDisassembler *)
static void DecodeSymbolicOperandOff(MCInst &Inst, uint64_t Address, uint64_t Offset, const MCDisassembler *Decoder)
static const uint16_t GPR32DecoderTable[]
static DecodeStatus DecodeMEMrs9(MCInst &, unsigned, uint64_t, const MCDisassembler *)
static bool DecodeSymbolicOperand(MCInst &Inst, uint64_t Address, uint64_t Value, const MCDisassembler *Decoder)
static unsigned decodeAField(unsigned Insn)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_EXTERNAL_VISIBILITY
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.
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.
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.
void addOperand(const MCOperand Op)
Interface to description of machine instruction set.
static MCOperand createReg(MCRegister Reg)
static MCOperand createImm(int64_t Val)
Generic base class for all target subtargets.
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.
std::enable_if_t< std::is_integral_v< IntType >, IntType > fieldFromInstruction(const IntType &Insn, unsigned StartBit, unsigned NumBits)
This is an optimization pass for GlobalISel generic memory operations.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
Target & getTheARCTarget()
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
constexpr T maskTrailingOnes(unsigned N)
Create a bitmask with the N right-most bits set to 1, and all other bits set to 0.
static void RegisterMCDisassembler(Target &T, Target::MCDisassemblerCtorTy Fn)
RegisterMCDisassembler - Register a MCDisassembler implementation for the given target.