28 #define DEBUG_TYPE "arc-disassembler" 37 std::unique_ptr<MCInstrInfo const>
const MCII;
56 (Bytes[0] << 16) | (Bytes[1] << 24) | (Bytes[2] << 0) | (Bytes[3] << 8);
61 uint64_t &
Size, uint64_t &Insn) {
63 Insn = ((uint64_t)Bytes[0] << 16) | ((uint64_t)Bytes[1] << 24) |
64 ((uint64_t)Bytes[2] << 0) | ((uint64_t)Bytes[3] << 8) |
65 ((uint64_t)Bytes[4] << 48) | ((uint64_t)Bytes[5] << 56) |
66 ((uint64_t)Bytes[6] << 32) | ((uint64_t)Bytes[7] << 40);
71 uint64_t &
Size, uint64_t &Insn) {
73 Insn = ((uint64_t)Bytes[0] << 0) | ((uint64_t)Bytes[1] << 8) |
74 ((uint64_t)Bytes[2] << 32) | ((uint64_t)Bytes[3] << 40) |
75 ((uint64_t)Bytes[4] << 16) | ((uint64_t)Bytes[5] << 24);
82 Insn = (Bytes[0] << 0) | (Bytes[1] << 8);
89 const void *Decoder =
nullptr);
94 const void *Decoder =
nullptr);
98 uint64_t
Address,
const void *Decoder);
116 ARC::R7, ARC::R8, ARC::R9, ARC::R10, ARC::R11, ARC::R12, ARC::R13,
117 ARC::R14, ARC::R15, ARC::R16, ARC::R17, ARC::R18, ARC::R19, ARC::R20,
118 ARC::R21, ARC::R22, ARC::R23, ARC::R24, ARC::R25, ARC::GP,
ARC::FP,
119 ARC::SP, ARC::ILINK, ARC::R30, ARC::BLINK};
123 const void *Decoder) {
136 const void *Decoder) {
144 #include "ARCGenDisassemblerTables.inc" 147 return fieldFromInstruction(Insn, 6, 6);
151 return (fieldFromInstruction(Insn, 12, 3) << 3) |
152 fieldFromInstruction(Insn, 24, 3);
156 return fieldFromInstruction(Insn, 0, 6);
162 unsigned S9 = Insn & 0x1ff;
163 unsigned R = (Insn & (0x7fff & ~0x1ff)) >> 9;
170 uint64_t
Value,
const void *Decoder) {
171 static const uint64_t atLeast = 2;
174 return (
nullptr != Disassembler &&
175 Disassembler->tryAddingSymbolicOperand(Inst, Value, Address,
true, 0,
180 uint64_t
Offset,
const void *Decoder) {
181 uint64_t nextAddress = Address +
Offset;
187 template <
unsigned B>
189 uint64_t
Address,
const void *Decoder) {
191 static_assert(
B > 0,
"field is empty");
196 template <
unsigned B>
201 static_assert(
B > 0,
"field is empty");
207 template <
unsigned B>
212 static_assert(
B > 0,
"field is empty");
213 const unsigned max = (1u <<
B) - 1;
221 const void *Decoder) {
222 unsigned SrcC, DstB, LImm;
238 const void *Decoder) {
239 unsigned DstA, SrcB, LImm;
256 const void *Decoder) {
264 LLVM_DEBUG(
dbgs() <<
"Decoding LdRLimm found non-limm register.");
273 const void *Decoder) {
275 using Field = decltype(Insn);
276 Field h = fieldFromInstruction(Insn, 5, 3) |
277 (fieldFromInstruction(Insn, 0, 2) << 3);
278 Field g = fieldFromInstruction(Insn, 8, 3) |
279 (fieldFromInstruction(Insn, 3, 2) << 3);
281 auto DecodeRegisterOrImm = [&Inst,
Address, Decoder](
Field RegNum,
294 return DecodeRegisterOrImm(h, Insn >> 16u);
303 if (Bytes.
size() < 2) {
307 uint8_t DecodeByte = (Bytes[1] & 0xF7) >> 3;
310 if (DecodeByte < 0x08) {
312 if (Bytes.
size() < 4) {
317 if (Bytes.
size() >= 8) {
328 LLVM_DEBUG(
dbgs() <<
"Not a 64-bit instruction, falling back to 32-bit.");
337 if (Bytes.
size() >= 6) {
346 dbgs() <<
"Successfully decoded 16-bit instruction with limm.");
350 dbgs() <<
"Not a 16-bit instruction with limm, try without it.");
static unsigned decodeCField(unsigned Insn)
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
This class represents lattice values for constants.
static bool DecodeSymbolicOperand(MCInst &Inst, uint64_t Address, uint64_t Value, const void *Decoder)
DecodeStatus
Ternary decode status.
static const uint16_t GPR32DecoderTable[]
Superclass for all disassemblers.
MCInstrInfo * createMCInstrInfo() const
createMCInstrInfo - Create a MCInstrInfo implementation.
static DecodeStatus DecodeSignedOperand(MCInst &Inst, unsigned InsnS, uint64_t Address=0, const void *Decoder=nullptr)
static DecodeStatus DecodeFromCyclicRange(MCInst &Inst, unsigned InsnS, uint64_t Address=0, const void *Decoder=nullptr)
static DecodeStatus DecodeBranchTargetS(MCInst &Inst, unsigned InsnS, uint64_t Address, const void *Decoder)
Target & getTheARCTarget()
static void RegisterMCDisassembler(Target &T, Target::MCDisassemblerCtorTy Fn)
RegisterMCDisassembler - Register a MCDisassembler implementation for the given target.
T maskTrailingOnes(unsigned N)
Create a bitmask with the N right-most bits set to 1, and all other bits set to 0.
static bool readInstruction64(ArrayRef< uint8_t > Bytes, uint64_t Address, uint64_t &Size, uint64_t &Insn)
static MCOperand createReg(unsigned Reg)
static bool readInstruction16(ArrayRef< uint8_t > Bytes, uint64_t Address, uint64_t &Size, uint32_t &Insn)
void LLVMInitializeARCDisassembler()
static void DecodeSymbolicOperandOff(MCInst &Inst, uint64_t Address, uint64_t Offset, const void *Decoder)
static DecodeStatus DecodeStLImmInstruction(MCInst &, uint64_t, uint64_t, const void *)
Context object for machine code objects.
int decodeInstruction(InternalInstruction *insn, byteReader_t reader, const void *readerArg, dlog_t logger, void *loggerArg, const void *miiArg, uint64_t startLoc, DisassemblerMode mode)
Decode one instruction and store the decoding results in a buffer provided by the consumer...
static DecodeStatus DecodeLdRLImmInstruction(MCInst &, uint64_t, uint64_t, const void *)
Instances of this class represent a single low-level machine instruction.
static bool readInstruction48(ArrayRef< uint8_t > Bytes, uint64_t Address, uint64_t &Size, uint64_t &Insn)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
size_t size() const
size - Get the array size.
Interface to description of machine instruction set.
static DecodeStatus DecodeGBR32ShortRegister(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeMoveHRegInstruction(MCInst &Inst, uint64_t, uint64_t, const void *)
static DecodeStatus DecodeMEMrs9(MCInst &, unsigned, uint64_t, const void *)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Target - Wrapper for Target specific information.
static DecodeStatus DecodeGPR32RegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const void *Decoder)
static bool readInstruction32(ArrayRef< uint8_t > Bytes, uint64_t Address, uint64_t &Size, uint32_t &Insn)
static MCDisassembler * createARCDisassembler(const Target &T, const MCSubtargetInfo &STI, MCContext &Ctx)
Generic base class for all target subtargets.
static unsigned decodeBField(unsigned Insn)
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream...
void addOperand(const MCOperand &Op)
static unsigned decodeAField(unsigned Insn)
static MCOperand createImm(int64_t Val)
static DecodeStatus DecodeLdLImmInstruction(MCInst &, uint64_t, uint64_t, const void *)