36#define GET_INSTRINFO_MC_DESC
37#define ENABLE_INSTR_PREDICATE_VERIFIER
38#include "RISCVGenInstrInfo.inc"
40#define GET_REGINFO_MC_DESC
41#include "RISCVGenRegisterInfo.inc"
43#define GET_SUBTARGETINFO_MC_DESC
44#include "RISCVGenSubtargetInfo.inc"
50 InitRISCVMCInstrInfo(
X);
56 InitRISCVMCRegisterInfo(
X, RISCV::X1);
65 unsigned SP =
MRI.getDwarfRegNum(RISCV::X2,
true);
74 bool LargeCodeModel =
false) {
82 if (CPU.
empty() || CPU ==
"generic")
83 CPU = TT.isArch64Bit() ?
"generic-rv64" :
"generic-rv32";
86 createRISCVMCSubtargetInfoImpl(TT, CPU, CPU, FS);
94 Features.
set(RISCV::Feature64Bit);
96 Features.
set(RISCV::Feature32Bit);
97 X->setFeatureBits(Features);
104 unsigned SyntaxVariant,
114 if (TT.isOSBinFormatELF())
132 int64_t GPRState[31] = {};
133 std::bitset<31> GPRValidMask;
136 return Reg >= RISCV::X0 &&
Reg <= RISCV::X31;
140 assert(isGPR(Reg) && Reg != RISCV::X0 &&
"Invalid GPR reg");
141 return Reg - RISCV::X1;
145 if (Reg == RISCV::X0)
148 auto Index = getRegIndex(Reg);
152 GPRValidMask.set(Index);
154 GPRValidMask.reset(Index);
158 std::optional<int64_t> getGPRState(
MCRegister Reg)
const {
159 if (Reg == RISCV::X0)
162 auto Index = getRegIndex(Reg);
164 if (GPRValidMask.test(Index))
165 return GPRState[
Index];
170 explicit RISCVMCInstrAnalysis(
const MCInstrInfo *Info)
173 void resetState()
override { GPRValidMask.reset(); }
191 for (
unsigned I = 0;
I < NumDefs; ++
I) {
194 setGPRState(DefReg, std::nullopt);
221 case RISCV::QC_E_JAL:
284 return isBranchImpl(Inst);
291 return isBranchImpl(Inst);
310 std::vector<std::pair<uint64_t, uint64_t>>
315 LoadInsnOpCode = 0x3003;
316 else if (
T.isRISCV32())
317 LoadInsnOpCode = 0x2003;
321 constexpr uint64_t FirstEntryAt = 32, EntrySize = 16;
322 if (PltContents.
size() < FirstEntryAt + EntrySize)
325 std::vector<std::pair<uint64_t, uint64_t>>
Results;
326 for (
uint64_t EntryStart = FirstEntryAt,
327 EntryStartEnd = PltContents.
size() - EntrySize;
328 EntryStart <= EntryStartEnd; EntryStart += EntrySize) {
331 const bool IsAuipc = (AuipcInsn & 0x7F) == 0x17;
337 const bool IsLoad = (LoadInsn & 0x707F) == LoadInsnOpCode;
341 const uint64_t GotPltSlotVA = PltSectionVA + EntryStart +
342 (AuipcInsn & 0xFFFFF000) +
343 SignExtend64<12>(LoadInsn >> 20);
344 Results.emplace_back(PltSectionVA + EntryStart, GotPltSlotVA);
351 static bool maybeReturnAddress(
MCRegister Reg) {
353 return Reg == RISCV::X1 ||
Reg == RISCV::X5;
356 static bool isBranchImpl(
const MCInst &Inst) {
374 return new RISCVMCInstrAnalysis(
Info);
unsigned const MachineRegisterInfo * MRI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Function Alias Analysis Results
Analysis containing CSE Info
#define LLVM_EXTERNAL_VISIBILITY
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
PassInstrumentationCallbacks PIC
static MCRegisterInfo * createRISCVMCRegisterInfo(const Triple &TT)
static MCInstPrinter * createRISCVMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI)
LLVM_ABI LLVM_EXTERNAL_VISIBILITY void LLVMInitializeRISCVTargetMC()
static MCObjectFileInfo * createRISCVMCObjectFileInfo(MCContext &Ctx, bool PIC, bool LargeCodeModel=false)
static MCTargetStreamer * createRISCVNullTargetStreamer(MCStreamer &S)
static MCSubtargetInfo * createRISCVMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS)
static MCTargetStreamer * createRISCVObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
static MCInstrAnalysis * createRISCVInstrAnalysis(const MCInstrInfo *Info)
static MCTargetStreamer * createRISCVAsmTargetStreamer(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint)
static MCInstrInfo * createRISCVMCInstrInfo()
static MCAsmInfo * createRISCVMCAsmInfo(const MCRegisterInfo &MRI, const Triple &TT, const MCTargetOptions &Options)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
Container class for subtarget features.
This class is intended to be used as a base class for asm properties and features specific to the tar...
void addInitialFrameState(const MCCFIInstruction &Inst)
static MCCFIInstruction cfiDefCfa(MCSymbol *L, unsigned Register, int64_t Offset, SMLoc Loc={})
.cfi_def_cfa defines a rule for computing CFA as: take address from Register and add Offset to it.
Context object for machine code objects.
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Instances of this class represent a single low-level machine instruction.
unsigned getOpcode() const
const MCOperand & getOperand(unsigned i) const
virtual std::vector< std::pair< uint64_t, uint64_t > > findPltEntries(uint64_t PltSectionVA, ArrayRef< uint8_t > PltContents, const MCSubtargetInfo &STI) const
Returns (PLT virtual address, GOT virtual address) pairs for PLT entries.
virtual bool isCall(const MCInst &Inst) const
virtual bool isBranch(const MCInst &Inst) const
virtual bool isUnconditionalBranch(const MCInst &Inst) const
virtual bool evaluateBranch(const MCInst &Inst, uint64_t Addr, uint64_t Size, uint64_t &Target) const
Given a branch instruction try to get the address the branch targets.
virtual bool isTerminator(const MCInst &Inst) const
virtual void resetState()
Clear the internal state. See updateState for more information.
virtual bool isConditionalBranch(const MCInst &Inst) const
virtual bool isReturn(const MCInst &Inst) const
virtual void updateState(const MCInst &Inst, uint64_t Addr)
Update internal state with Inst at Addr.
virtual bool isIndirectBranch(const MCInst &Inst) const
Interface to description of machine instruction set.
void initMCObjectFileInfo(MCContext &MCCtx, bool PIC, bool LargeCodeModel=false)
MCRegister getReg() const
Returns the register number.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Wrapper class representing physical registers. Should be passed by value.
Streaming machine code generation interface.
Generic base class for all target subtargets.
const Triple & getTargetTriple() const
Target specific streamer interface.
StringRef - Represent a constant reference to a string, i.e.
constexpr bool empty() const
empty - Check if the string is empty.
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
LLVM Value Representation.
Reg
All possible values of the reg field in the ModR/M byte.
uint32_t read32le(const void *P)
This is an optimization pass for GlobalISel generic memory operations.
MCCodeEmitter * createRISCVMCCodeEmitter(const MCInstrInfo &MCII, MCContext &Ctx)
Target & getTheRISCV32Target()
Target & getTheRISCV64beTarget()
MCStreamer * createRISCVELFStreamer(const Triple &, MCContext &C, std::unique_ptr< MCAsmBackend > &&MAB, std::unique_ptr< MCObjectWriter > &&MOW, std::unique_ptr< MCCodeEmitter > &&MCE)
MCAsmBackend * createRISCVAsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options)
Target & getTheRISCV64Target()
Target & getTheRISCV32beTarget()
static void RegisterMCRegInfo(Target &T, Target::MCRegInfoCtorFnTy Fn)
RegisterMCRegInfo - Register a MCRegisterInfo implementation for the given target.
static void RegisterMCAsmBackend(Target &T, Target::MCAsmBackendCtorTy Fn)
RegisterMCAsmBackend - Register a MCAsmBackend implementation for the given target.
static void RegisterMCCodeEmitter(Target &T, Target::MCCodeEmitterCtorTy Fn)
RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the given target.
static void RegisterMCAsmInfo(Target &T, Target::MCAsmInfoCtorFnTy Fn)
RegisterMCAsmInfo - Register a MCAsmInfo implementation for the given target.
static void RegisterMCSubtargetInfo(Target &T, Target::MCSubtargetInfoCtorFnTy Fn)
RegisterMCSubtargetInfo - Register a MCSubtargetInfo implementation for the given target.
static void RegisterObjectTargetStreamer(Target &T, Target::ObjectTargetStreamerCtorTy Fn)
static void RegisterMCInstrAnalysis(Target &T, Target::MCInstrAnalysisCtorFnTy Fn)
RegisterMCInstrAnalysis - Register a MCInstrAnalysis implementation for the given target.
static void RegisterELFStreamer(Target &T, Target::ELFStreamerCtorTy Fn)
static void RegisterNullTargetStreamer(Target &T, Target::NullTargetStreamerCtorTy Fn)
static void RegisterMCInstPrinter(Target &T, Target::MCInstPrinterCtorTy Fn)
RegisterMCInstPrinter - Register a MCInstPrinter implementation for the given target.
static void RegisterMCInstrInfo(Target &T, Target::MCInstrInfoCtorFnTy Fn)
RegisterMCInstrInfo - Register a MCInstrInfo implementation for the given target.
static void RegisterMCObjectFileInfo(Target &T, Target::MCObjectFileInfoCtorFnTy Fn)
Register a MCObjectFileInfo implementation for the given target.
static void RegisterAsmTargetStreamer(Target &T, Target::AsmTargetStreamerCtorTy Fn)