28#define DEBUG_TYPE "arc-disassembler"
37 std::unique_ptr<MCInstrInfo const>
const MCII;
55 (Bytes[0] << 16) | (Bytes[1] << 24) | (Bytes[2] << 0) | (Bytes[3] << 8);
81 Insn = (Bytes[0] << 0) | (Bytes[1] << 8);
125 ARC::R0, ARC::R1, ARC::R2, ARC::R3, ARC::R4, ARC::R5, ARC::R6,
126 ARC::R7, ARC::R8, ARC::R9, ARC::R10, ARC::R11, ARC::R12, ARC::R13,
127 ARC::R14, ARC::R15, ARC::R16, ARC::R17, ARC::R18, ARC::R19, ARC::R20,
128 ARC::R21, ARC::R22, ARC::R23, ARC::R24, ARC::R25, ARC::GP, ARC::FP,
129 ARC::SP, ARC::ILINK, ARC::R30, ARC::BLINK};
154#include "ARCGenDisassemblerTables.inc"
157 return fieldFromInstruction(
Insn, 6, 6);
161 return (fieldFromInstruction(
Insn, 12, 3) << 3) |
162 fieldFromInstruction(
Insn, 24, 3);
166 return fieldFromInstruction(
Insn, 0, 6);
172 unsigned S9 =
Insn & 0x1ff;
173 unsigned R = (
Insn & (0x7fff & ~0x1ff)) >> 9;
184 Inst,
Value, Address,
true, 0, AtLeast, 0));
201 static_assert(
B > 0,
"field is empty");
211 static_assert(
B > 0,
"field is empty");
222 static_assert(
B > 0,
"field is empty");
223 const unsigned max = (1u <<
B) - 1;
232 unsigned SrcC, DstB, LImm;
249 unsigned DstA, SrcB, LImm;
274 LLVM_DEBUG(
dbgs() <<
"Decoding LdRLimm found non-limm register.");
287 (fieldFromInstruction(
Insn, 0, 2) << 3);
289 (fieldFromInstruction(
Insn, 3, 2) << 3);
291 auto DecodeRegisterOrImm = [&Inst, Address, Decoder](
Field RegNum,
304 return DecodeRegisterOrImm(
H,
Insn >> 16u);
315 Field U6Field = fieldFromInstruction(
Insn, 6, 6);
317 Field CCField = fieldFromInstruction(
Insn, 0, 4);
328 Field U6 = fieldFromInstruction(
Insn, 6, 6);
341 Field Sign = fieldFromInstruction(
Insn, 5, 1) ? -1 : 1;
352 if (Bytes.
size() < 2) {
356 uint8_t DecodeByte = (Bytes[1] & 0xF7) >> 3;
359 if (DecodeByte < 0x08) {
361 if (Bytes.
size() < 4) {
366 if (Bytes.
size() >= 8) {
372 decodeInstruction(DecoderTable64, Instr, Insn64, Address,
this, STI);
377 LLVM_DEBUG(
dbgs() <<
"Not a 64-bit instruction, falling back to 32-bit.");
384 return decodeInstruction(DecoderTable32, Instr, Insn32, Address,
this, STI);
386 if (Bytes.
size() >= 6) {
392 decodeInstruction(DecoderTable48, Instr, Insn48, Address,
this, STI);
395 dbgs() <<
"Successfully decoded 16-bit instruction with limm.");
399 dbgs() <<
"Not a 16-bit instruction with limm, try without it.");
407 return decodeInstruction(DecoderTable16, Instr, Insn16, Address,
this, STI);
414 return new ARCDisassembler(STI, Ctx,
T.createMCInstrInfo());
SmallVector< AArch64_IMM::ImmInsnModel, 4 > Insn
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(unsigned 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.
This is an optimization pass for GlobalISel generic memory operations.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
Target & getTheARCTarget()
T maskTrailingOnes(unsigned N)
Create a bitmask with the N right-most bits set to 1, and all other bits set to 0.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
static void RegisterMCDisassembler(Target &T, Target::MCDisassemblerCtorTy Fn)
RegisterMCDisassembler - Register a MCDisassembler implementation for the given target.