26#define DEBUG_TYPE "msp430-disassembler"
57 return new MSP430Disassembler(STI, Ctx);
66 MSP430::PCB, MSP430::SPB, MSP430::SRB, MSP430::CGB,
67 MSP430::R4B, MSP430::R5B, MSP430::R6B, MSP430::R7B,
68 MSP430::R8B, MSP430::R9B, MSP430::R10B, MSP430::R11B,
69 MSP430::R12B, MSP430::R13B, MSP430::R14B, MSP430::R15B
84 MSP430::PC, MSP430::SP, MSP430::SR, MSP430::CG,
85 MSP430::R4, MSP430::R5, MSP430::R6, MSP430::R7,
86 MSP430::R8, MSP430::R9, MSP430::R10, MSP430::R11,
87 MSP430::R12, MSP430::R13, MSP430::R14, MSP430::R15
108#include "MSP430GenDisassemblerTables.inc"
116 case 0x22: Imm = 4;
break;
117 case 0x32: Imm = 8;
break;
118 case 0x03: Imm = 0;
break;
119 case 0x13: Imm = 1;
break;
120 case 0x23: Imm = 2;
break;
121 case 0x33: Imm = -1;
break;
130 unsigned Reg = Bits & 15;
131 unsigned Imm = Bits >> 4;
181 unsigned Rs = fieldFromInstruction(
Insn, 8, 4);
182 unsigned As = fieldFromInstruction(
Insn, 4, 2);
187 unsigned Rs = fieldFromInstruction(
Insn, 0, 4);
188 unsigned As = fieldFromInstruction(
Insn, 4, 2);
193 unsigned Rd = fieldFromInstruction(
Insn, 0, 4);
194 unsigned Ad = fieldFromInstruction(
Insn, 7, 1);
205 assert(0 < Words && Words < 4 &&
"Incorrect number of words");
210 assert(Words < 3 &&
"Incorrect number of words");
211 return Words == 2 ? DecoderTableAlpha32 : DecoderTableAlpha16;
213 assert(Words < 3 &&
"Incorrect number of words");
214 return Words == 2 ? DecoderTableBeta32 : DecoderTableBeta16;
219 assert(Words > 1 &&
"Incorrect number of words");
220 return Words == 2 ? DecoderTableGamma32 : DecoderTableGamma48;
223 assert(Words < 3 &&
"Incorrect number of words");
224 return Words == 2 ? DecoderTableDelta32 : DecoderTableDelta16;
246 if (Bytes.
size() < (Words + 1) * 2) {
248 return DecodeStatus::Fail;
260 if (Bytes.
size() < (Words + 1) * 2) {
262 return DecodeStatus::Fail;
273 Insn, Address,
this, STI);
280 return DecodeStatus::Fail;
300 if (Bytes.
size() < (Words + 1) * 2) {
302 return DecodeStatus::Fail;
311 const uint8_t *DecoderTable = Words == 2 ? DecoderTable32 : DecoderTable16;
320 return DecodeStatus::Fail;
343 unsigned Cond = fieldFromInstruction(
Insn, 10, 3);
344 unsigned Offset = fieldFromInstruction(
Insn, 0, 10);
349 MI.setOpcode(MSP430::JMP);
351 MI.setOpcode(MSP430::JCC);
356 return DecodeStatus::Success;
363 if (Bytes.
size() < 2) {
369 unsigned Opc = fieldFromInstruction(
Insn, 13, 3);
372 return getInstructionII(
MI,
Size, Bytes, Address, CStream);
374 return getInstructionCJ(
MI,
Size, Bytes, Address, CStream);
376 return getInstructionI(
MI,
Size, Bytes, Address, CStream);
SmallVector< AArch64_IMM::ImmInsnModel, 4 > Insn
#define LLVM_EXTERNAL_VISIBILITY
MCDisassembler::DecodeStatus DecodeStatus
static DecodeStatus DecodeCGImm(MCInst &MI, uint64_t Bits, uint64_t Address, const MCDisassembler *Decoder)
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMSP430Disassembler()
static const unsigned GR16DecoderTable[]
static DecodeStatus DecodeMemOperand(MCInst &MI, uint64_t Bits, uint64_t Address, const MCDisassembler *Decoder)
static AddrMode DecodeSrcAddrModeII(unsigned Insn)
static const uint8_t * getDecoderTable(AddrMode SrcAM, unsigned Words)
static AddrMode DecodeDstAddrMode(unsigned Insn)
static MCDisassembler * createMSP430Disassembler(const Target &T, const MCSubtargetInfo &STI, MCContext &Ctx)
static AddrMode DecodeSrcAddrMode(unsigned Rs, unsigned As)
static AddrMode DecodeSrcAddrModeI(unsigned Insn)
static MSP430CC::CondCodes getCondCode(unsigned Cond)
static const unsigned GR8DecoderTable[]
static DecodeStatus DecodeGR8RegisterClass(MCInst &MI, uint64_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeGR16RegisterClass(MCInst &MI, uint64_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
const SmallVectorImpl< MachineOperand > & Cond
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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.
static MCOperand createReg(MCRegister Reg)
static MCOperand createImm(int64_t Val)
Generic base class for all target subtargets.
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.
uint16_t read16le(const void *P)
This is an optimization pass for GlobalISel generic memory operations.
Target & getTheMSP430Target()
constexpr int32_t SignExtend32(uint32_t X)
Sign-extend the number in the bottom B bits of X to a 32-bit integer.
static void RegisterMCDisassembler(Target &T, Target::MCDisassemblerCtorTy Fn)
RegisterMCDisassembler - Register a MCDisassembler implementation for the given target.