27 #define DEBUG_TYPE "riscv-disassembler" 48 return new RISCVDisassembler(STI, Ctx);
60 RISCV::X0, RISCV::X1, RISCV::X2, RISCV::X3,
61 RISCV::X4, RISCV::X5, RISCV::X6, RISCV::X7,
62 RISCV::X8, RISCV::X9, RISCV::X10, RISCV::X11,
63 RISCV::X12, RISCV::X13, RISCV::X14, RISCV::X15,
64 RISCV::X16, RISCV::X17, RISCV::X18, RISCV::X19,
65 RISCV::X20, RISCV::X21, RISCV::X22, RISCV::X23,
66 RISCV::X24, RISCV::X25, RISCV::X26, RISCV::X27,
67 RISCV::X28, RISCV::X29, RISCV::X30, RISCV::X31
72 const void *Decoder) {
73 if (RegNo >
sizeof(GPRDecoderTable))
79 unsigned Reg = GPRDecoderTable[RegNo];
85 RISCV::F0_32, RISCV::F1_32, RISCV::F2_32, RISCV::F3_32,
86 RISCV::F4_32, RISCV::F5_32, RISCV::F6_32, RISCV::F7_32,
87 RISCV::F8_32, RISCV::F9_32, RISCV::F10_32, RISCV::F11_32,
88 RISCV::F12_32, RISCV::F13_32, RISCV::F14_32, RISCV::F15_32,
89 RISCV::F16_32, RISCV::F17_32, RISCV::F18_32, RISCV::F19_32,
90 RISCV::F20_32, RISCV::F21_32, RISCV::F22_32, RISCV::F23_32,
91 RISCV::F24_32, RISCV::F25_32, RISCV::F26_32, RISCV::F27_32,
92 RISCV::F28_32, RISCV::F29_32, RISCV::F30_32, RISCV::F31_32
97 const void *Decoder) {
98 if (RegNo >
sizeof(FPR32DecoderTable))
104 unsigned Reg = FPR32DecoderTable[RegNo];
111 const void *Decoder) {
115 unsigned Reg = FPR32DecoderTable[RegNo + 8];
121 RISCV::F0_64, RISCV::F1_64, RISCV::F2_64, RISCV::F3_64,
122 RISCV::F4_64, RISCV::F5_64, RISCV::F6_64, RISCV::F7_64,
123 RISCV::F8_64, RISCV::F9_64, RISCV::F10_64, RISCV::F11_64,
124 RISCV::F12_64, RISCV::F13_64, RISCV::F14_64, RISCV::F15_64,
125 RISCV::F16_64, RISCV::F17_64, RISCV::F18_64, RISCV::F19_64,
126 RISCV::F20_64, RISCV::F21_64, RISCV::F22_64, RISCV::F23_64,
127 RISCV::F24_64, RISCV::F25_64, RISCV::F26_64, RISCV::F27_64,
128 RISCV::F28_64, RISCV::F29_64, RISCV::F30_64, RISCV::F31_64
133 const void *Decoder) {
134 if (RegNo >
sizeof(FPR64DecoderTable))
140 unsigned Reg = FPR64DecoderTable[RegNo];
147 const void *Decoder) {
151 unsigned Reg = FPR64DecoderTable[RegNo + 8];
158 const void *Decoder) {
168 const void *Decoder) {
178 const void *Decoder) {
182 unsigned Reg = GPRDecoderTable[RegNo + 8];
199 if (Inst.
getOpcode() == RISCV::C_ADDI16SP) {
205 template <
unsigned N>
207 int64_t
Address,
const void *Decoder) {
208 assert(isUInt<N>(Imm) &&
"Invalid immediate");
214 template <
unsigned N>
217 const void *Decoder) {
220 return decodeUImmOperand<N>(Inst, Imm,
Address, Decoder);
223 template <
unsigned N>
225 int64_t
Address,
const void *Decoder) {
226 assert(isUInt<N>(Imm) &&
"Invalid immediate");
233 template <
unsigned N>
236 const void *Decoder) {
239 return decodeSImmOperand<N>(Inst, Imm,
Address, Decoder);
242 template <
unsigned N>
245 const void *Decoder) {
246 assert(isUInt<N>(Imm) &&
"Invalid immediate");
256 const void *Decoder) {
257 assert(isUInt<6>(Imm) &&
"Invalid immediate");
259 Imm = (SignExtend64<6>(Imm) & 0xfffff);
267 const void *Decoder) {
268 assert(isUInt<3>(Imm) &&
"Invalid immediate");
276 #include "RISCVGenDisassemblerTables.inc" 289 if ((Bytes[0] & 0x3) == 0x3) {
290 if (Bytes.
size() < 4) {
299 if (Bytes.
size() < 2) {
305 if (!STI.getFeatureBits()[RISCV::Feature64Bit]) {
307 dbgs() <<
"Trying RISCV32Only_16 table (16-bit Instruction):\n");
317 LLVM_DEBUG(
dbgs() <<
"Trying RISCV_C table (16-bit Instruction):\n");
static MCDisassembler * createRISCVDisassembler(const Target &T, const MCSubtargetInfo &STI, MCContext &Ctx)
static bool isValidRoundingMode(unsigned Mode)
static DecodeStatus DecodeFPR32CRegisterClass(MCInst &Inst, uint64_t RegNo, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeGPRRegisterClass(MCInst &Inst, uint64_t RegNo, uint64_t Address, const void *Decoder)
This class represents lattice values for constants.
DecodeStatus
Ternary decode status.
MCDisassembler::DecodeStatus DecodeStatus
Superclass for all disassemblers.
static DecodeStatus DecodeGPRCRegisterClass(MCInst &Inst, uint64_t RegNo, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeFPR64RegisterClass(MCInst &Inst, uint64_t RegNo, uint64_t Address, const void *Decoder)
uint16_t read16le(const void *P)
static void RegisterMCDisassembler(Target &T, Target::MCDisassemblerCtorTy Fn)
RegisterMCDisassembler - Register a MCDisassembler implementation for the given target.
static DecodeStatus decodeSImmNonZeroOperand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static MCOperand createReg(unsigned Reg)
static const unsigned FPR32DecoderTable[]
void LLVMInitializeRISCVDisassembler()
Target & getTheRISCV32Target()
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...
Instances of this class represent a single low-level machine instruction.
static DecodeStatus DecodeGPRNoX0RegisterClass(MCInst &Inst, uint64_t RegNo, uint64_t Address, const void *Decoder)
size_t size() const
size - Get the array size.
static const unsigned FPR64DecoderTable[]
Target & getTheRISCV64Target()
static DecodeStatus DecodeFPR64CRegisterClass(MCInst &Inst, uint64_t RegNo, uint64_t Address, const void *Decoder)
static DecodeStatus decodeFRMArg(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static DecodeStatus decodeUImmOperand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static const unsigned GPRDecoderTable[]
static DecodeStatus decodeSImmOperandAndLsl1(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Target - Wrapper for Target specific information.
static DecodeStatus DecodeGPRNoX0X2RegisterClass(MCInst &Inst, uint64_t RegNo, uint64_t Address, const void *Decoder)
static void addImplySP(MCInst &Inst, int64_t Address, const void *Decoder)
uint32_t read32le(const void *P)
Generic base class for all target subtargets.
static DecodeStatus decodeUImmNonZeroOperand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static DecodeStatus DecodeFPR32RegisterClass(MCInst &Inst, uint64_t RegNo, uint64_t Address, const void *Decoder)
This class implements an extremely fast bulk output stream that can only output to a stream...
void addOperand(const MCOperand &Op)
unsigned getOpcode() const
static DecodeStatus decodeSImmOperand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
static MCOperand createImm(int64_t Val)
static DecodeStatus decodeCLUIImmOperand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)