28 #define DEBUG_TYPE "riscv-disassembler" 48 return new RISCVDisassembler(STI, Ctx);
61 const void *Decoder) {
66 bool IsRV32E = FeatureBits[RISCV::FeatureRV32E];
68 if (RegNo >= 32 || (IsRV32E && RegNo >= 16))
78 const void *Decoder) {
89 const void *Decoder) {
100 const void *Decoder) {
111 const void *Decoder) {
122 const void *Decoder) {
132 const void *Decoder) {
142 const void *Decoder) {
163 if (Inst.
getOpcode() == RISCV::C_ADDI16SP) {
169 template <
unsigned N>
171 int64_t
Address,
const void *Decoder) {
172 assert(isUInt<N>(Imm) &&
"Invalid immediate");
178 template <
unsigned N>
181 const void *Decoder) {
184 return decodeUImmOperand<N>(Inst, Imm,
Address, Decoder);
187 template <
unsigned N>
189 int64_t
Address,
const void *Decoder) {
190 assert(isUInt<N>(Imm) &&
"Invalid immediate");
197 template <
unsigned N>
200 const void *Decoder) {
203 return decodeSImmOperand<N>(Inst, Imm,
Address, Decoder);
206 template <
unsigned N>
209 const void *Decoder) {
210 assert(isUInt<N>(Imm) &&
"Invalid immediate");
220 const void *Decoder) {
221 assert(isUInt<6>(Imm) &&
"Invalid immediate");
223 Imm = (SignExtend64<6>(Imm) & 0xfffff);
231 const void *Decoder) {
232 assert(isUInt<3>(Imm) &&
"Invalid immediate");
241 uint64_t
Address,
const void *Decoder);
244 uint64_t
Address,
const void *Decoder);
248 const void *Decoder);
251 uint64_t
Address,
const void *Decoder);
255 const void *Decoder);
257 #include "RISCVGenDisassemblerTables.inc" 260 uint64_t
Address,
const void *Decoder) {
262 fieldFromInstruction(Insn, 12, 1) << 5 | fieldFromInstruction(Insn, 2, 5);
271 const void *Decoder) {
274 fieldFromInstruction(Insn, 12, 1) << 5 | fieldFromInstruction(Insn, 2, 5);
283 const void *Decoder) {
287 fieldFromInstruction(Insn, 12, 1) << 5 | fieldFromInstruction(Insn, 2, 5);
295 uint64_t
Address,
const void *Decoder) {
296 unsigned Rd = fieldFromInstruction(Insn, 7, 5);
297 unsigned Rs2 = fieldFromInstruction(Insn, 2, 5);
305 const void *Decoder) {
306 unsigned Rd = fieldFromInstruction(Insn, 7, 5);
307 unsigned Rs2 = fieldFromInstruction(Insn, 2, 5);
324 if ((Bytes[0] & 0x3) == 0x3) {
325 if (Bytes.
size() < 4) {
331 Result = decodeInstruction(DecoderTable32, MI, Insn,
Address,
this, STI);
334 if (Bytes.
size() < 2) {
340 if (!STI.getFeatureBits()[RISCV::Feature64Bit]) {
342 dbgs() <<
"Trying RISCV32Only_16 table (16-bit Instruction):\n");
344 Result = decodeInstruction(DecoderTableRISCV32Only_16, MI, Insn,
Address,
352 LLVM_DEBUG(
dbgs() <<
"Trying RISCV_C table (16-bit Instruction):\n");
354 Result = decodeInstruction(DecoderTable16, MI, Insn,
Address,
this, STI);
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)
Target & getTheRISCV32Target()
Context object for machine code objects.
static DecodeStatus decodeRVCInstrRdRs1Rs2(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
static DecodeStatus decodeRVCInstrSImm(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
Instances of this class represent a single low-level machine instruction.
static DecodeStatus decodeRVCInstrRdRs2(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
Container class for subtarget features.
static DecodeStatus DecodeGPRNoX0RegisterClass(MCInst &Inst, uint64_t RegNo, uint64_t Address, const void *Decoder)
size_t size() const
size - Get the array size.
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 DecodeStatus decodeSImmOperandAndLsl1(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)
const MCOperand & getOperand(unsigned i) const
#define LLVM_EXTERNAL_VISIBILITY
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Target - Wrapper for Target specific information.
static DecodeStatus decodeRVCInstrRdSImm(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeGPRNoX0X2RegisterClass(MCInst &Inst, uint64_t RegNo, uint64_t Address, const void *Decoder)
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeRISCVDisassembler()
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 decodeRVCInstrRdRs1UImm(MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder)
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)
Wrapper class representing virtual and physical registers.
static DecodeStatus decodeCLUIImmOperand(MCInst &Inst, uint64_t Imm, int64_t Address, const void *Decoder)