LLVM 20.0.0git
Macros | Typedefs | Functions
RISCVDisassembler.cpp File Reference
#include "MCTargetDesc/RISCVBaseInfo.h"
#include "MCTargetDesc/RISCVMCTargetDesc.h"
#include "TargetInfo/RISCVTargetInfo.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCDecoderOps.h"
#include "llvm/MC/MCDisassembler/MCDisassembler.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstrInfo.h"
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/TargetRegistry.h"
#include "llvm/Support/Endian.h"
#include "RISCVGenDisassemblerTables.inc"

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "riscv-disassembler"
 
#define TRY_TO_DECODE_WITH_ADDITIONAL_OPERATION(FEATURE_CHECKS, DECODER_TABLE, DESC, ADDITIONAL_OPERATION)
 
#define TRY_TO_DECODE_AND_ADD_SP(FEATURE_CHECKS, DECODER_TABLE, DESC)
 
#define TRY_TO_DECODE(FEATURE_CHECKS, DECODER_TABLE, DESC)
 
#define TRY_TO_DECODE_FEATURE(FEATURE, DECODER_TABLE, DESC)    TRY_TO_DECODE(STI.hasFeature(FEATURE), DECODER_TABLE, DESC)
 

Typedefs

typedef MCDisassembler::DecodeStatus DecodeStatus
 

Functions

static MCDisassemblercreateRISCVDisassembler (const Target &T, const MCSubtargetInfo &STI, MCContext &Ctx)
 
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeRISCVDisassembler ()
 
static DecodeStatus DecodeGPRRegisterClass (MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
 
static DecodeStatus DecodeGPRF16RegisterClass (MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
 
static DecodeStatus DecodeGPRF32RegisterClass (MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
 
static DecodeStatus DecodeGPRX1X5RegisterClass (MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
 
static DecodeStatus DecodeFPR16RegisterClass (MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
 
static DecodeStatus DecodeFPR32RegisterClass (MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
 
static DecodeStatus DecodeFPR32CRegisterClass (MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
 
static DecodeStatus DecodeFPR64RegisterClass (MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
 
static DecodeStatus DecodeFPR64CRegisterClass (MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
 
static DecodeStatus DecodeGPRNoX0RegisterClass (MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
 
static DecodeStatus DecodeGPRNoX0X2RegisterClass (MCInst &Inst, uint64_t RegNo, uint32_t Address, const MCDisassembler *Decoder)
 
static DecodeStatus DecodeGPRCRegisterClass (MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
 
static DecodeStatus DecodeGPRPairRegisterClass (MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
 
static DecodeStatus DecodeSR07RegisterClass (MCInst &Inst, uint32_t RegNo, uint64_t Address, const void *Decoder)
 
static DecodeStatus DecodeVRRegisterClass (MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
 
static DecodeStatus DecodeVRM2RegisterClass (MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
 
static DecodeStatus DecodeVRM4RegisterClass (MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
 
static DecodeStatus DecodeVRM8RegisterClass (MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
 
static DecodeStatus decodeVMaskReg (MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
 
template<unsigned N>
static DecodeStatus decodeUImmOperand (MCInst &Inst, uint32_t Imm, int64_t Address, const MCDisassembler *Decoder)
 
static DecodeStatus decodeUImmLog2XLenOperand (MCInst &Inst, uint32_t Imm, int64_t Address, const MCDisassembler *Decoder)
 
template<unsigned N>
static DecodeStatus decodeUImmNonZeroOperand (MCInst &Inst, uint32_t Imm, int64_t Address, const MCDisassembler *Decoder)
 
static DecodeStatus decodeUImmLog2XLenNonZeroOperand (MCInst &Inst, uint32_t Imm, int64_t Address, const MCDisassembler *Decoder)
 
template<unsigned N>
static DecodeStatus decodeSImmOperand (MCInst &Inst, uint32_t Imm, int64_t Address, const MCDisassembler *Decoder)
 
template<unsigned N>
static DecodeStatus decodeSImmNonZeroOperand (MCInst &Inst, uint32_t Imm, int64_t Address, const MCDisassembler *Decoder)
 
template<unsigned N>
static DecodeStatus decodeSImmOperandAndLsl1 (MCInst &Inst, uint32_t Imm, int64_t Address, const MCDisassembler *Decoder)
 
static DecodeStatus decodeCLUIImmOperand (MCInst &Inst, uint32_t Imm, int64_t Address, const MCDisassembler *Decoder)
 
static DecodeStatus decodeFRMArg (MCInst &Inst, uint32_t Imm, int64_t Address, const MCDisassembler *Decoder)
 
static DecodeStatus decodeRTZArg (MCInst &Inst, uint32_t Imm, int64_t Address, const MCDisassembler *Decoder)
 
static DecodeStatus decodeRVCInstrRdRs1ImmZero (MCInst &Inst, uint32_t Insn, uint64_t Address, const MCDisassembler *Decoder)
 
static DecodeStatus decodeRVCInstrRdSImm (MCInst &Inst, uint32_t Insn, uint64_t Address, const MCDisassembler *Decoder)
 
static DecodeStatus decodeRVCInstrRdRs1UImm (MCInst &Inst, uint32_t Insn, uint64_t Address, const MCDisassembler *Decoder)
 
static DecodeStatus decodeRVCInstrRdRs2 (MCInst &Inst, uint32_t Insn, uint64_t Address, const MCDisassembler *Decoder)
 
static DecodeStatus decodeRVCInstrRdRs1Rs2 (MCInst &Inst, uint32_t Insn, uint64_t Address, const MCDisassembler *Decoder)
 
static DecodeStatus decodeXTHeadMemPair (MCInst &Inst, uint32_t Insn, uint64_t Address, const MCDisassembler *Decoder)
 
static DecodeStatus decodeZcmpRlist (MCInst &Inst, uint32_t Imm, uint64_t Address, const void *Decoder)
 
static DecodeStatus decodeRegReg (MCInst &Inst, uint32_t Insn, uint64_t Address, const MCDisassembler *Decoder)
 
static DecodeStatus decodeZcmpSpimm (MCInst &Inst, uint32_t Imm, uint64_t Address, const void *Decoder)
 
static DecodeStatus decodeCSSPushPopchk (MCInst &Inst, uint32_t Insn, uint64_t Address, const MCDisassembler *Decoder)
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "riscv-disassembler"

Definition at line 28 of file RISCVDisassembler.cpp.

◆ TRY_TO_DECODE

#define TRY_TO_DECODE (   FEATURE_CHECKS,
  DECODER_TABLE,
  DESC 
)
Value:
TRY_TO_DECODE_WITH_ADDITIONAL_OPERATION(FEATURE_CHECKS, DECODER_TABLE, DESC, \
(void)nullptr)
#define DESC
#define TRY_TO_DECODE_WITH_ADDITIONAL_OPERATION(FEATURE_CHECKS, DECODER_TABLE, DESC, ADDITIONAL_OPERATION)

Definition at line 590 of file RISCVDisassembler.cpp.

◆ TRY_TO_DECODE_AND_ADD_SP

#define TRY_TO_DECODE_AND_ADD_SP (   FEATURE_CHECKS,
  DECODER_TABLE,
  DESC 
)
Value:
TRY_TO_DECODE_WITH_ADDITIONAL_OPERATION(FEATURE_CHECKS, DECODER_TABLE, DESC, \
addSPOperands(MI))
IRTranslator LLVM IR MI

Definition at line 587 of file RISCVDisassembler.cpp.

◆ TRY_TO_DECODE_FEATURE

#define TRY_TO_DECODE_FEATURE (   FEATURE,
  DECODER_TABLE,
  DESC 
)     TRY_TO_DECODE(STI.hasFeature(FEATURE), DECODER_TABLE, DESC)

Definition at line 593 of file RISCVDisassembler.cpp.

◆ TRY_TO_DECODE_WITH_ADDITIONAL_OPERATION

#define TRY_TO_DECODE_WITH_ADDITIONAL_OPERATION (   FEATURE_CHECKS,
  DECODER_TABLE,
  DESC,
  ADDITIONAL_OPERATION 
)
Value:
do { \
if (FEATURE_CHECKS) { \
LLVM_DEBUG(dbgs() << "Trying " DESC ":\n"); \
DecodeStatus Result = \
decodeInstruction(DECODER_TABLE, MI, Insn, Address, this, STI); \
if (Result != MCDisassembler::Fail) { \
ADDITIONAL_OPERATION; \
return Result; \
} \
} \
} while (false)
SmallVector< AArch64_IMM::ImmInsnModel, 4 > Insn
DecodeStatus
Ternary decode status.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163

Definition at line 574 of file RISCVDisassembler.cpp.

Typedef Documentation

◆ DecodeStatus

Definition at line 30 of file RISCVDisassembler.cpp.

Function Documentation

◆ createRISCVDisassembler()

static MCDisassembler * createRISCVDisassembler ( const Target T,
const MCSubtargetInfo STI,
MCContext Ctx 
)
static

Definition at line 57 of file RISCVDisassembler.cpp.

Referenced by LLVMInitializeRISCVDisassembler().

◆ decodeCLUIImmOperand()

static DecodeStatus decodeCLUIImmOperand ( MCInst Inst,
uint32_t  Imm,
int64_t  Address,
const MCDisassembler Decoder 
)
static

◆ decodeCSSPushPopchk()

static DecodeStatus decodeCSSPushPopchk ( MCInst Inst,
uint32_t  Insn,
uint64_t  Address,
const MCDisassembler Decoder 
)
static

◆ DecodeFPR16RegisterClass()

static DecodeStatus DecodeFPR16RegisterClass ( MCInst Inst,
uint32_t  RegNo,
uint64_t  Address,
const MCDisassembler Decoder 
)
static

◆ DecodeFPR32CRegisterClass()

static DecodeStatus DecodeFPR32CRegisterClass ( MCInst Inst,
uint32_t  RegNo,
uint64_t  Address,
const MCDisassembler Decoder 
)
static

◆ DecodeFPR32RegisterClass()

static DecodeStatus DecodeFPR32RegisterClass ( MCInst Inst,
uint32_t  RegNo,
uint64_t  Address,
const MCDisassembler Decoder 
)
static

◆ DecodeFPR64CRegisterClass()

static DecodeStatus DecodeFPR64CRegisterClass ( MCInst Inst,
uint32_t  RegNo,
uint64_t  Address,
const MCDisassembler Decoder 
)
static

◆ DecodeFPR64RegisterClass()

static DecodeStatus DecodeFPR64RegisterClass ( MCInst Inst,
uint32_t  RegNo,
uint64_t  Address,
const MCDisassembler Decoder 
)
static

◆ decodeFRMArg()

static DecodeStatus decodeFRMArg ( MCInst Inst,
uint32_t  Imm,
int64_t  Address,
const MCDisassembler Decoder 
)
static

◆ DecodeGPRCRegisterClass()

static DecodeStatus DecodeGPRCRegisterClass ( MCInst Inst,
uint32_t  RegNo,
uint64_t  Address,
const MCDisassembler Decoder 
)
static

◆ DecodeGPRF16RegisterClass()

static DecodeStatus DecodeGPRF16RegisterClass ( MCInst Inst,
uint32_t  RegNo,
uint64_t  Address,
const MCDisassembler Decoder 
)
static

◆ DecodeGPRF32RegisterClass()

static DecodeStatus DecodeGPRF32RegisterClass ( MCInst Inst,
uint32_t  RegNo,
uint64_t  Address,
const MCDisassembler Decoder 
)
static

◆ DecodeGPRNoX0RegisterClass()

static DecodeStatus DecodeGPRNoX0RegisterClass ( MCInst Inst,
uint32_t  RegNo,
uint64_t  Address,
const MCDisassembler Decoder 
)
static

◆ DecodeGPRNoX0X2RegisterClass()

static DecodeStatus DecodeGPRNoX0X2RegisterClass ( MCInst Inst,
uint64_t  RegNo,
uint32_t  Address,
const MCDisassembler Decoder 
)
static

◆ DecodeGPRPairRegisterClass()

static DecodeStatus DecodeGPRPairRegisterClass ( MCInst Inst,
uint32_t  RegNo,
uint64_t  Address,
const MCDisassembler Decoder 
)
static

◆ DecodeGPRRegisterClass()

static DecodeStatus DecodeGPRRegisterClass ( MCInst Inst,
uint32_t  RegNo,
uint64_t  Address,
const MCDisassembler Decoder 
)
static

◆ DecodeGPRX1X5RegisterClass()

static DecodeStatus DecodeGPRX1X5RegisterClass ( MCInst Inst,
uint32_t  RegNo,
uint64_t  Address,
const MCDisassembler Decoder 
)
static

◆ decodeRegReg()

static DecodeStatus decodeRegReg ( MCInst Inst,
uint32_t  Insn,
uint64_t  Address,
const MCDisassembler Decoder 
)
static

◆ decodeRTZArg()

static DecodeStatus decodeRTZArg ( MCInst Inst,
uint32_t  Imm,
int64_t  Address,
const MCDisassembler Decoder 
)
static

◆ decodeRVCInstrRdRs1ImmZero()

static DecodeStatus decodeRVCInstrRdRs1ImmZero ( MCInst Inst,
uint32_t  Insn,
uint64_t  Address,
const MCDisassembler Decoder 
)
static

◆ decodeRVCInstrRdRs1Rs2()

static DecodeStatus decodeRVCInstrRdRs1Rs2 ( MCInst Inst,
uint32_t  Insn,
uint64_t  Address,
const MCDisassembler Decoder 
)
static

◆ decodeRVCInstrRdRs1UImm()

static DecodeStatus decodeRVCInstrRdRs1UImm ( MCInst Inst,
uint32_t  Insn,
uint64_t  Address,
const MCDisassembler Decoder 
)
static

◆ decodeRVCInstrRdRs2()

static DecodeStatus decodeRVCInstrRdRs2 ( MCInst Inst,
uint32_t  Insn,
uint64_t  Address,
const MCDisassembler Decoder 
)
static

◆ decodeRVCInstrRdSImm()

static DecodeStatus decodeRVCInstrRdSImm ( MCInst Inst,
uint32_t  Insn,
uint64_t  Address,
const MCDisassembler Decoder 
)
static

◆ decodeSImmNonZeroOperand()

template<unsigned N>
static DecodeStatus decodeSImmNonZeroOperand ( MCInst Inst,
uint32_t  Imm,
int64_t  Address,
const MCDisassembler Decoder 
)
static

Definition at line 358 of file RISCVDisassembler.cpp.

References Address, and llvm::MCDisassembler::Fail.

◆ decodeSImmOperand()

template<unsigned N>
static DecodeStatus decodeSImmOperand ( MCInst Inst,
uint32_t  Imm,
int64_t  Address,
const MCDisassembler Decoder 
)
static

◆ decodeSImmOperandAndLsl1()

template<unsigned N>
static DecodeStatus decodeSImmOperandAndLsl1 ( MCInst Inst,
uint32_t  Imm,
int64_t  Address,
const MCDisassembler Decoder 
)
static

◆ DecodeSR07RegisterClass()

static DecodeStatus DecodeSR07RegisterClass ( MCInst Inst,
uint32_t  RegNo,
uint64_t  Address,
const void *  Decoder 
)
static

◆ decodeUImmLog2XLenNonZeroOperand()

static DecodeStatus decodeUImmLog2XLenNonZeroOperand ( MCInst Inst,
uint32_t  Imm,
int64_t  Address,
const MCDisassembler Decoder 
)
static

◆ decodeUImmLog2XLenOperand()

static DecodeStatus decodeUImmLog2XLenOperand ( MCInst Inst,
uint32_t  Imm,
int64_t  Address,
const MCDisassembler Decoder 
)
static

◆ decodeUImmNonZeroOperand()

template<unsigned N>
static DecodeStatus decodeUImmNonZeroOperand ( MCInst Inst,
uint32_t  Imm,
int64_t  Address,
const MCDisassembler Decoder 
)
static

Definition at line 331 of file RISCVDisassembler.cpp.

References Address, and llvm::MCDisassembler::Fail.

◆ decodeUImmOperand()

template<unsigned N>
static DecodeStatus decodeUImmOperand ( MCInst Inst,
uint32_t  Imm,
int64_t  Address,
const MCDisassembler Decoder 
)
static

◆ decodeVMaskReg()

static DecodeStatus decodeVMaskReg ( MCInst Inst,
uint32_t  RegNo,
uint64_t  Address,
const MCDisassembler Decoder 
)
static

◆ DecodeVRM2RegisterClass()

static DecodeStatus DecodeVRM2RegisterClass ( MCInst Inst,
uint32_t  RegNo,
uint64_t  Address,
const MCDisassembler Decoder 
)
static

◆ DecodeVRM4RegisterClass()

static DecodeStatus DecodeVRM4RegisterClass ( MCInst Inst,
uint32_t  RegNo,
uint64_t  Address,
const MCDisassembler Decoder 
)
static

◆ DecodeVRM8RegisterClass()

static DecodeStatus DecodeVRM8RegisterClass ( MCInst Inst,
uint32_t  RegNo,
uint64_t  Address,
const MCDisassembler Decoder 
)
static

◆ DecodeVRRegisterClass()

static DecodeStatus DecodeVRRegisterClass ( MCInst Inst,
uint32_t  RegNo,
uint64_t  Address,
const MCDisassembler Decoder 
)
static

◆ decodeXTHeadMemPair()

static DecodeStatus decodeXTHeadMemPair ( MCInst Inst,
uint32_t  Insn,
uint64_t  Address,
const MCDisassembler Decoder 
)
static

◆ decodeZcmpRlist()

static DecodeStatus decodeZcmpRlist ( MCInst Inst,
uint32_t  Imm,
uint64_t  Address,
const void *  Decoder 
)
static

◆ decodeZcmpSpimm()

static DecodeStatus decodeZcmpSpimm ( MCInst Inst,
uint32_t  Imm,
uint64_t  Address,
const void *  Decoder 
)
static

◆ LLVMInitializeRISCVDisassembler()

LLVM_EXTERNAL_VISIBILITY void LLVMInitializeRISCVDisassembler ( )