26 #define DEBUG_TYPE "riscv-disassembler" 47 return new RISCVDisassembler(STI, Ctx);
59 RISCV::X0, RISCV::X1, RISCV::X2, RISCV::X3,
60 RISCV::X4, RISCV::X5, RISCV::X6, RISCV::X7,
61 RISCV::X8, RISCV::X9, RISCV::X10, RISCV::X11,
62 RISCV::X12, RISCV::X13, RISCV::X14, RISCV::X15,
63 RISCV::X16, RISCV::X17, RISCV::X18, RISCV::X19,
64 RISCV::X20, RISCV::X21, RISCV::X22, RISCV::X23,
65 RISCV::X24, RISCV::X25, RISCV::X26, RISCV::X27,
66 RISCV::X28, RISCV::X29, RISCV::X30, RISCV::X31
71 const void *Decoder) {
72 if (RegNo >
sizeof(GPRDecoderTable))
78 unsigned Reg = GPRDecoderTable[RegNo];
84 RISCV::F0_32, RISCV::F1_32, RISCV::F2_32, RISCV::F3_32,
85 RISCV::F4_32, RISCV::F5_32, RISCV::F6_32, RISCV::F7_32,
86 RISCV::F8_32, RISCV::F9_32, RISCV::F10_32, RISCV::F11_32,
87 RISCV::F12_32, RISCV::F13_32, RISCV::F14_32, RISCV::F15_32,
88 RISCV::F16_32, RISCV::F17_32, RISCV::F18_32, RISCV::F19_32,
89 RISCV::F20_32, RISCV::F21_32, RISCV::F22_32, RISCV::F23_32,
90 RISCV::F24_32, RISCV::F25_32, RISCV::F26_32, RISCV::F27_32,
91 RISCV::F28_32, RISCV::F29_32, RISCV::F30_32, RISCV::F31_32
96 const void *Decoder) {
97 if (RegNo >
sizeof(FPR32DecoderTable))
103 unsigned Reg = FPR32DecoderTable[RegNo];
110 const void *Decoder) {
114 unsigned Reg = FPR32DecoderTable[RegNo + 8];
120 RISCV::F0_64, RISCV::F1_64, RISCV::F2_64, RISCV::F3_64,
121 RISCV::F4_64, RISCV::F5_64, RISCV::F6_64, RISCV::F7_64,
122 RISCV::F8_64, RISCV::F9_64, RISCV::F10_64, RISCV::F11_64,
123 RISCV::F12_64, RISCV::F13_64, RISCV::F14_64, RISCV::F15_64,
124 RISCV::F16_64, RISCV::F17_64, RISCV::F18_64, RISCV::F19_64,
125 RISCV::F20_64, RISCV::F21_64, RISCV::F22_64, RISCV::F23_64,
126 RISCV::F24_64, RISCV::F25_64, RISCV::F26_64, RISCV::F27_64,
127 RISCV::F28_64, RISCV::F29_64, RISCV::F30_64, RISCV::F31_64
132 const void *Decoder) {
133 if (RegNo >
sizeof(FPR64DecoderTable))
139 unsigned Reg = FPR64DecoderTable[RegNo];
146 const void *Decoder) {
150 unsigned Reg = FPR64DecoderTable[RegNo + 8];
157 const void *Decoder) {
167 const void *Decoder) {
177 const void *Decoder) {
181 unsigned Reg = GPRDecoderTable[RegNo + 8];
198 if (Inst.
getOpcode() == RISCV::C_ADDI16SP) {
204 template <
unsigned N>
206 int64_t
Address,
const void *Decoder) {
207 assert(isUInt<N>(Imm) &&
"Invalid immediate");
213 template <
unsigned N>
215 int64_t
Address,
const void *Decoder) {
216 assert(isUInt<N>(Imm) &&
"Invalid immediate");
223 template <
unsigned N>
226 const void *Decoder) {
227 assert(isUInt<N>(Imm) &&
"Invalid immediate");
237 const void *Decoder) {
238 assert(isUInt<6>(Imm) &&
"Invalid immediate");
240 Imm = (SignExtend64<6>(Imm) & 0xfffff);
246 #include "RISCVGenDisassemblerTables.inc" 259 if ((Bytes[0] & 0x3) == 0x3) {
267 if (!STI.getFeatureBits()[RISCV::Feature64Bit]) {
269 dbgs() <<
"Trying RISCV32Only_16 table (16-bit Instruction):\n");
279 LLVM_DEBUG(
dbgs() <<
"Trying RISCV_C table (16-bit Instruction):\n");
static MCDisassembler * createRISCVDisassembler(const Target &T, const MCSubtargetInfo &STI, MCContext &Ctx)
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)
Compute iterated dominance frontiers using a linear time algorithm.
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 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)
static const unsigned FPR64DecoderTable[]
Target & getTheRISCV64Target()
static DecodeStatus DecodeFPR64CRegisterClass(MCInst &Inst, uint64_t RegNo, uint64_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.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static DecodeStatus DecodeFPR32RegisterClass(MCInst &Inst, uint64_t RegNo, uint64_t Address, const void *Decoder)
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
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)