28#define DEBUG_TYPE "avr-disassembler"
39 virtual ~AVRDisassembler() =
default;
50 return new AVRDisassembler(STI, Ctx);
60 AVR::R0, AVR::R1, AVR::R2, AVR::R3, AVR::R4, AVR::R5, AVR::R6,
61 AVR::R7, AVR::R8, AVR::R9, AVR::R10, AVR::R11, AVR::R12, AVR::R13,
62 AVR::R14, AVR::R15, AVR::R16, AVR::R17, AVR::R18, AVR::R19, AVR::R20,
63 AVR::R21, AVR::R22, AVR::R23, AVR::R24, AVR::R25, AVR::R26, AVR::R27,
64 AVR::R28, AVR::R29, AVR::R30, AVR::R31,
137#include "AVRGenDisassemblerTables.inc"
142 addr |= fieldFromInstruction(
Insn, 0, 4);
143 addr |= fieldFromInstruction(
Insn, 9, 2) << 4;
144 unsigned reg = fieldFromInstruction(
Insn, 4, 5);
155 addr |= fieldFromInstruction(
Insn, 0, 4);
156 addr |= fieldFromInstruction(
Insn, 9, 2) << 4;
157 unsigned reg = fieldFromInstruction(
Insn, 4, 5);
167 unsigned addr = fieldFromInstruction(
Insn, 3, 5);
168 unsigned b = fieldFromInstruction(
Insn, 0, 3);
185 unsigned d = fieldFromInstruction(
Insn, 4, 5);
203 unsigned d = fieldFromInstruction(
Insn, 4, 3) + 16;
204 unsigned r = fieldFromInstruction(
Insn, 0, 3) + 16;
217 unsigned r = fieldFromInstruction(
Insn, 4, 4) * 2;
218 unsigned d = fieldFromInstruction(
Insn, 0, 4) * 2;
230 unsigned d = fieldFromInstruction(
Insn, 4, 2) * 2 + 24;
232 k |= fieldFromInstruction(
Insn, 0, 4);
233 k |= fieldFromInstruction(
Insn, 6, 2) << 4;
247 unsigned rd = fieldFromInstruction(
Insn, 4, 4) + 16;
248 unsigned rr = fieldFromInstruction(
Insn, 0, 4) + 16;
278 switch (
Insn & 0xf000) {
289 int16_t
Offset = ((int16_t)((
Insn & 0xfff) << 4)) >> 3;
299 {0x000, AVR::BRLOk}, {0x400, AVR::BRSHk}, {0x001, AVR::BREQk},
300 {0x401, AVR::BRNEk}, {0x002, AVR::BRMIk}, {0x402, AVR::BRPLk},
301 {0x004, AVR::BRLTk}, {0x404, AVR::BRGEk}};
304 int16_t
Offset = ((int16_t)((
Insn & 0x3f8) << 6)) >> 8;
307 auto NotAlias = [&
Insn](
const std::pair<unsigned, unsigned> &
I) {
308 return (
Insn & 0x407) !=
I.first;
314 if (It != brInsts.
end()) {
335 if ((
Insn & 0xf000) == 0x8000) {
336 unsigned RegBase = (
Insn & 0x8) ? AVR::R29R28 : AVR::R31R30;
338 if ((
Insn & 0x200) == 0) {
370 if ((
Insn & 0xfc00) != 0x9000 || (
Insn & 0xf) == 0)
375 switch (
Insn & 0xc) {
377 RegBase = AVR::R27R26;
380 RegBase = AVR::R29R28;
383 RegBase = AVR::R31R30;
390 switch (
Insn & 0x203) {
418 if ((
Insn & 0x200) == 0) {
435 if (Bytes.
size() < 2) {
441 Insn = (Bytes[0] << 0) | (Bytes[1] << 8);
449 if (Bytes.
size() < 4) {
456 (Bytes[0] << 16) | (Bytes[1] << 24) | (Bytes[2] << 0) | (Bytes[3] << 8);
465 return DecoderTable16;
467 return DecoderTable32;
489 if (STI.hasFeature(AVR::FeatureTinyEncoding)) {
490 Result = decodeInstruction(DecoderTableAVRTiny16, Instr,
Insn, Address,
SmallVector< AArch64_IMM::ImmInsnModel, 4 > Insn
static DecodeStatus decodeFRd(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus decodeFLPMX(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
MCDisassembler::DecodeStatus DecodeStatus
static DecodeStatus decodeLoadStore(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus decodeFMUL2RdRr(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus decodeFWRdK(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeGPR8RegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus decodeFIOARr(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus decodeCallTarget(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeLD8RegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const MCDisassembler *Decoder)
DecodeStatus(* DecodeFunc)(MCInst &MI, unsigned insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus decodeFIORdA(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus decodeFIOBIT(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)
static DecodeStatus decodeCondBranch(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static const uint16_t GPRDecoderTable[]
static DecodeStatus decodeFFMULRdRr(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
static MCDisassembler * createAVRDisassembler(const Target &T, const MCSubtargetInfo &STI, MCContext &Ctx)
static DecodeStatus decodeMemri(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)
static DecodeStatus decodeFMOVWRdRr(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAVRDisassembler()
static const uint8_t * getDecoderTable(uint64_t Size)
static DecodeStatus decodeFBRk(MCInst &Inst, unsigned Insn, uint64_t Address, const MCDisassembler *Decoder)
#define LLVM_EXTERNAL_VISIBILITY
This file defines the DenseMap class.
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.
void addOperand(const MCOperand Op)
void setOpcode(unsigned Op)
static MCOperand createReg(MCRegister Reg)
static MCOperand createImm(int64_t Val)
Generic base class for all target subtargets.
Wrapper class representing virtual and physical registers.
Target - Wrapper for Target specific information.
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 & getTheAVRTarget()
auto partition_point(R &&Range, Predicate P)
Binary search for the first iterator in a range where a predicate is false.
auto partition(R &&Range, UnaryPredicate P)
Provide wrappers to std::partition which take ranges instead of having to pass begin/end explicitly.
static void RegisterMCDisassembler(Target &T, Target::MCDisassemblerCtorTy Fn)
RegisterMCDisassembler - Register a MCDisassembler implementation for the given target.