#include "RISCVAsmBackend.h"
#include "RISCVMCExpr.h"
#include "llvm/ADT/APInt.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCDirectives.h"
#include "llvm/MC/MCELFObjectWriter.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCObjectWriter.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCValue.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/EndianStream.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/LEB128.h"
#include "llvm/Support/raw_ostream.h"
usingnamespacellvm;
static cl::opt<bool> RelaxBranches("riscv-asm-relax-branches", cl::init(true),
cl::Hidden);
static cl::opt<bool> ULEB128Reloc(
"riscv-uleb128-reloc", cl::init(true), cl::Hidden,
cl::desc("Emit R_RISCV_SET_ULEB128/E_RISCV_SUB_ULEB128 if appropriate"));
std::optional<MCFixupKind> RISCVAsmBackend::getFixupKind(StringRef Name) const { … }
const MCFixupKindInfo &
RISCVAsmBackend::getFixupKindInfo(MCFixupKind Kind) const { … }
bool RISCVAsmBackend::shouldForceRelocation(const MCAssembler &Asm,
const MCFixup &Fixup,
const MCValue &Target,
const MCSubtargetInfo *STI) { … }
bool RISCVAsmBackend::fixupNeedsRelaxationAdvanced(
const MCAssembler &Asm, const MCFixup &Fixup, bool Resolved, uint64_t Value,
const MCRelaxableFragment *DF, const bool WasForced) const { … }
void RISCVAsmBackend::relaxInstruction(MCInst &Inst,
const MCSubtargetInfo &STI) const { … }
bool RISCVAsmBackend::relaxDwarfLineAddr(const MCAssembler &Asm,
MCDwarfLineAddrFragment &DF,
bool &WasRelaxed) const { … }
bool RISCVAsmBackend::relaxDwarfCFA(const MCAssembler &Asm,
MCDwarfCallFrameFragment &DF,
bool &WasRelaxed) const { … }
std::pair<bool, bool> RISCVAsmBackend::relaxLEB128(const MCAssembler &Asm,
MCLEBFragment &LF,
int64_t &Value) const { … }
unsigned RISCVAsmBackend::getRelaxedOpcode(unsigned Op) const { … }
bool RISCVAsmBackend::mayNeedRelaxation(const MCInst &Inst,
const MCSubtargetInfo &STI) const { … }
bool RISCVAsmBackend::writeNopData(raw_ostream &OS, uint64_t Count,
const MCSubtargetInfo *STI) const { … }
static uint64_t adjustFixupValue(const MCFixup &Fixup, uint64_t Value,
MCContext &Ctx) { … }
bool RISCVAsmBackend::evaluateTargetFixup(const MCAssembler &Asm,
const MCFixup &Fixup,
const MCFragment *DF,
const MCValue &Target,
const MCSubtargetInfo *STI,
uint64_t &Value, bool &WasForced) { … }
bool RISCVAsmBackend::handleAddSubRelocations(const MCAssembler &Asm,
const MCFragment &F,
const MCFixup &Fixup,
const MCValue &Target,
uint64_t &FixedValue) const { … }
void RISCVAsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
const MCValue &Target,
MutableArrayRef<char> Data, uint64_t Value,
bool IsResolved,
const MCSubtargetInfo *STI) const { … }
bool RISCVAsmBackend::shouldInsertExtraNopBytesForCodeAlign(
const MCAlignFragment &AF, unsigned &Size) { … }
bool RISCVAsmBackend::shouldInsertFixupForCodeAlign(MCAssembler &Asm,
MCAlignFragment &AF) { … }
std::unique_ptr<MCObjectTargetWriter>
RISCVAsmBackend::createObjectTargetWriter() const { … }
MCAsmBackend *llvm::createRISCVAsmBackend(const Target &T,
const MCSubtargetInfo &STI,
const MCRegisterInfo &MRI,
const MCTargetOptions &Options) { … }