29 bool Is64Bit,
bool IsLittleEndian,
39 if (
STI.getTargetTriple().isOSBinFormatELF()) {
42#define ELF_RELOC(NAME, ID) .Case(#NAME, ID)
43#include "llvm/BinaryFormat/ELFRelocs/RISCV.def"
45#define ELF_RISCV_NONSTANDARD_RELOC(_VENDOR, NAME, ID) .Case(#NAME, ID)
46#include "llvm/BinaryFormat/ELFRelocs/RISCV_nonstandard.def"
47#undef ELF_RISCV_NONSTANDARD_RELOC
48 .
Case(
"BFD_RELOC_NONE", ELF::R_RISCV_NONE)
49 .
Case(
"BFD_RELOC_32", ELF::R_RISCV_32)
50 .
Case(
"BFD_RELOC_64", ELF::R_RISCV_64)
64 {
"fixup_riscv_hi20", 12, 20, 0},
65 {
"fixup_riscv_lo12_i", 20, 12, 0},
66 {
"fixup_riscv_12_i", 20, 12, 0},
67 {
"fixup_riscv_lo12_s", 0, 32, 0},
68 {
"fixup_riscv_pcrel_hi20", 12, 20, 0},
69 {
"fixup_riscv_pcrel_lo12_i", 20, 12, 0},
70 {
"fixup_riscv_pcrel_lo12_s", 0, 32, 0},
71 {
"fixup_riscv_jal", 12, 20, 0},
72 {
"fixup_riscv_branch", 0, 32, 0},
73 {
"fixup_riscv_rvc_jump", 2, 11, 0},
74 {
"fixup_riscv_rvc_branch", 0, 16, 0},
75 {
"fixup_riscv_rvc_imm", 0, 16, 0},
76 {
"fixup_riscv_call", 0, 64, 0},
77 {
"fixup_riscv_call_plt", 0, 64, 0},
80 {
"fixup_riscv_qc_e_branch", 0, 48, 0},
81 {
"fixup_riscv_qc_e_32", 16, 32, 0},
82 {
"fixup_riscv_qc_abs20_u", 0, 32, 0},
83 {
"fixup_riscv_qc_e_call_plt", 0, 48, 0},
84 {
"fixup_qc_access_16", 0, 0, 0},
85 {
"fixup_qc_access_32", 0, 0, 0},
88 {
"fixup_riscv_nds_branch_10", 0, 32, 0},
91 "Not all fixup kinds added to Infos array");
110 bool Resolved)
const {
112 auto Kind = Fixup.getKind();
161 if (!STI.
hasFeature(RISCV::FeatureVendorXqcili))
171 return RISCV::QC_E_LI;
174 if (!STI.
hasFeature(RISCV::FeatureVendorXqcilb))
179 if (
Reg == RISCV::X0)
180 return RISCV::QC_E_J;
181 if (
Reg == RISCV::X1)
182 return RISCV::QC_E_JAL;
187 return RISCV::PseudoLongBEQ;
189 return RISCV::PseudoLongBNE;
191 return RISCV::PseudoLongBEQI;
193 return RISCV::PseudoLongBNEI;
195 return RISCV::PseudoLongBLT;
197 return RISCV::PseudoLongBGE;
199 return RISCV::PseudoLongBLTU;
201 return RISCV::PseudoLongBGEU;
203 return RISCV::PseudoLongQC_BEQI;
205 return RISCV::PseudoLongQC_BNEI;
207 return RISCV::PseudoLongQC_BLTI;
209 return RISCV::PseudoLongQC_BGEI;
210 case RISCV::QC_BLTUI:
211 return RISCV::PseudoLongQC_BLTUI;
212 case RISCV::QC_BGEUI:
213 return RISCV::PseudoLongQC_BGEUI;
214 case RISCV::QC_E_BEQI:
215 return RISCV::PseudoLongQC_E_BEQI;
216 case RISCV::QC_E_BNEI:
217 return RISCV::PseudoLongQC_E_BNEI;
218 case RISCV::QC_E_BLTI:
219 return RISCV::PseudoLongQC_E_BLTI;
220 case RISCV::QC_E_BGEI:
221 return RISCV::PseudoLongQC_E_BGEI;
222 case RISCV::QC_E_BLTUI:
223 return RISCV::PseudoLongQC_E_BLTUI;
224 case RISCV::QC_E_BGEUI:
225 return RISCV::PseudoLongQC_E_BGEUI;
226 case RISCV::CV_BEQIMM:
227 return RISCV::PseudoLongCV_BEQIMM;
228 case RISCV::CV_BNEIMM:
229 return RISCV::PseudoLongCV_BNEIMM;
238 if (
STI.hasFeature(RISCV::FeatureExactAssembly))
259 Inst.
getOpcode() == RISCV::C_J ? RISCV::X0 : RISCV::X1));
265 assert(
STI.hasFeature(RISCV::FeatureVendorXqcilb) &&
266 "JAL is only relaxable with Xqcilb");
269 "JAL only relaxable with rd=x0 or rd=x1");
284 assert(
STI.hasFeature(RISCV::FeatureVendorXqcili) &&
285 "C.LI is only relaxable with Xqcili");
303 case RISCV::QC_BLTUI:
304 case RISCV::QC_BGEUI:
305 case RISCV::QC_E_BEQI:
306 case RISCV::QC_E_BNEI:
307 case RISCV::QC_E_BLTI:
308 case RISCV::QC_E_BGEI:
309 case RISCV::QC_E_BLTUI:
310 case RISCV::QC_E_BGEUI:
311 case RISCV::CV_BEQIMM:
312 case RISCV::CV_BNEIMM:
319 Inst = std::move(Res);
331 case RISCV::PseudoLongBEQ:
332 case RISCV::PseudoLongBNE:
333 case RISCV::PseudoLongBEQI:
334 case RISCV::PseudoLongBNEI:
335 case RISCV::PseudoLongBLT:
336 case RISCV::PseudoLongBGE:
337 case RISCV::PseudoLongBLTU:
338 case RISCV::PseudoLongBGEU:
339 case RISCV::PseudoLongQC_BEQI:
340 case RISCV::PseudoLongQC_BNEI:
341 case RISCV::PseudoLongQC_BLTI:
342 case RISCV::PseudoLongQC_BGEI:
343 case RISCV::PseudoLongQC_BLTUI:
344 case RISCV::PseudoLongQC_BGEUI:
345 case RISCV::PseudoLongQC_E_BEQI:
346 case RISCV::PseudoLongQC_E_BNEI:
347 case RISCV::PseudoLongQC_E_BLTI:
348 case RISCV::PseudoLongQC_E_BGEI:
349 case RISCV::PseudoLongQC_E_BLTUI:
350 case RISCV::PseudoLongQC_E_BGEUI:
351 case RISCV::PseudoLongCV_BEQIMM:
352 case RISCV::PseudoLongCV_BNEIMM:
353 if (
STI.hasFeature(RISCV::FeatureRelax)) {
355 assert(
F.isLinkerRelaxable() &&
F.getNext());
357 Skip->setFragment(
F.getNext());
358 Asm->registerSymbol(*Skip);
378 auto *Sec =
F.getParent();
379 if (
F.getLayoutOrder() <= Sec->firstLinkerRelaxable())
385 CLOpts.align_rvc ||
STI->hasFeature(RISCV::FeatureStdExtZca) ? 2 : 4;
386 if (
F.getAlignment() <= MinNopLen)
389 Size =
F.getAlignment().value() - MinNopLen;
393 F.setVarFixups({Fixup});
394 F.setLinkerRelaxable();
399 int64_t LineDelta =
F.getDwarfLineDelta();
400 const MCExpr &AddrDelta =
F.getDwarfAddrDelta();
404 if (AddrDelta.evaluateAsAbsolute(
Value, *
Asm))
406 [[maybe_unused]]
bool IsAbsolute =
408 assert(IsAbsolute &&
"CFA with invalid expression");
415 OS <<
uint8_t(dwarf::DW_LNS_advance_line);
426 <<
uint8_t(dwarf::DW_LNE_set_address);
430 OS <<
uint8_t(dwarf::DW_LNS_fixed_advance_pc);
436 OS <<
uint8_t(dwarf::DW_LNS_extended_op);
438 OS <<
uint8_t(dwarf::DW_LNE_end_sequence);
440 OS <<
uint8_t(dwarf::DW_LNS_copy);
443 F.setVarContents(
Data);
450 const MCExpr &AddrDelta =
F.getDwarfAddrDelta();
453 if (AddrDelta.evaluateAsAbsolute(
Value, *
Asm))
455 [[maybe_unused]]
bool IsAbsolute =
457 assert(IsAbsolute &&
"CFA with invalid expression");
460 "expected 1-byte alignment");
462 F.clearVarContents();
467 auto AddFixups = [&Fixups, &AddrDelta](
unsigned Offset,
468 std::pair<unsigned, unsigned> Fixup) {
477 OS <<
uint8_t(dwarf::DW_CFA_advance_loc);
478 AddFixups(0, {ELF::R_RISCV_SET6, ELF::R_RISCV_SUB6});
480 OS <<
uint8_t(dwarf::DW_CFA_advance_loc1);
482 AddFixups(1, {ELF::R_RISCV_SET8, ELF::R_RISCV_SUB8});
484 OS <<
uint8_t(dwarf::DW_CFA_advance_loc2);
486 AddFixups(1, {ELF::R_RISCV_SET16, ELF::R_RISCV_SUB16});
488 OS <<
uint8_t(dwarf::DW_CFA_advance_loc4);
490 AddFixups(1, {ELF::R_RISCV_SET32, ELF::R_RISCV_SUB32});
494 F.setVarContents(
Data);
495 F.setVarFixups(Fixups);
500 int64_t &
Value)
const {
502 return std::make_pair(
false,
false);
504 if (
CLOpts.uleb128_reloc) {
516 if (
STI.hasFeature(RISCV::FeatureExactAssembly))
537 if (
Count % 4 == 2) {
540 OS.
write(
"\x01\0", 2);
546 OS.
write(
"\x13\0\0\0", 4);
553 switch (Fixup.getKind()) {
564 return Value & 0xfff;
567 Ctx.reportError(Fixup.getLoc(),
568 "operand must be a constant 12-bit integer");
570 return Value & 0xfff;
573 return (((
Value >> 5) & 0x7f) << 25) | ((
Value & 0x1f) << 7);
577 return ((
Value + 0x800) >> 12) & 0xfffff;
580 Ctx.reportError(Fixup.getLoc(),
"fixup value out of range");
582 Ctx.reportError(Fixup.getLoc(),
"fixup value must be 2-byte aligned");
584 unsigned Sbit = (
Value >> 20) & 0x1;
585 unsigned Hi8 = (
Value >> 12) & 0xff;
586 unsigned Mid1 = (
Value >> 11) & 0x1;
587 unsigned Lo10 = (
Value >> 1) & 0x3ff;
592 Value = (Sbit << 19) | (Lo10 << 9) | (Mid1 << 8) | Hi8;
598 Ctx.reportError(Fixup.getLoc(),
"fixup value out of range");
600 Ctx.reportError(Fixup.getLoc(),
"fixup value must be 2-byte aligned");
603 unsigned Sbit = (
Value >> 12) & 0x1;
604 unsigned Hi1 = (
Value >> 11) & 0x1;
605 unsigned Mid6 = (
Value >> 5) & 0x3f;
606 unsigned Lo4 = (
Value >> 1) & 0xf;
611 Value = (Sbit << 31) | (Mid6 << 25) | (Lo4 << 8) | (Hi1 << 7);
621 return UpperImm | ((LowerImm << 20) << 32);
625 Ctx.reportError(Fixup.getLoc(),
"fixup value out of range");
627 unsigned Bit11 = (
Value >> 11) & 0x1;
628 unsigned Bit4 = (
Value >> 4) & 0x1;
629 unsigned Bit9_8 = (
Value >> 8) & 0x3;
630 unsigned Bit10 = (
Value >> 10) & 0x1;
631 unsigned Bit6 = (
Value >> 6) & 0x1;
632 unsigned Bit7 = (
Value >> 7) & 0x1;
633 unsigned Bit3_1 = (
Value >> 1) & 0x7;
634 unsigned Bit5 = (
Value >> 5) & 0x1;
635 Value = (Bit11 << 10) | (Bit4 << 9) | (Bit9_8 << 7) | (Bit10 << 6) |
636 (Bit6 << 5) | (Bit7 << 4) | (Bit3_1 << 1) | Bit5;
641 Ctx.reportError(Fixup.getLoc(),
"fixup value out of range");
643 unsigned Bit8 = (
Value >> 8) & 0x1;
644 unsigned Bit7_6 = (
Value >> 6) & 0x3;
645 unsigned Bit5 = (
Value >> 5) & 0x1;
646 unsigned Bit4_3 = (
Value >> 3) & 0x3;
647 unsigned Bit2_1 = (
Value >> 1) & 0x3;
648 Value = (Bit8 << 12) | (Bit4_3 << 10) | (Bit7_6 << 5) | (Bit2_1 << 3) |
654 Ctx.reportError(Fixup.getLoc(),
"fixup value out of range");
655 unsigned Bit5 = (
Value >> 5) & 0x1;
656 unsigned Bit4_0 =
Value & 0x1f;
657 Value = (Bit5 << 12) | (Bit4_0 << 2);
662 Ctx.reportError(Fixup.getLoc(),
"fixup value out of range");
663 return Value & 0xffffffffu;
667 Ctx.reportError(Fixup.getLoc(),
"fixup value out of range");
668 unsigned Bit19 = (
Value >> 19) & 0x1;
669 unsigned Bit14_0 =
Value & 0x7fff;
670 unsigned Bit18_15 = (
Value >> 15) & 0xf;
671 Value = (Bit19 << 31) | (Bit14_0 << 16) | (Bit18_15 << 12);
676 Ctx.reportError(Fixup.getLoc(),
"fixup value out of range");
678 Ctx.reportError(Fixup.getLoc(),
"fixup value must be 2-byte aligned");
685 Value = (Bit31_16 << 32ull) | (Bit12 << 31) | (Bit10_5 << 25) |
686 (Bit15_13 << 17) | (Bit4_1 << 8) | (Bit11 << 7);
694 Ctx.reportError(Fixup.getLoc(),
"fixup value out of range");
696 Ctx.reportError(Fixup.getLoc(),
"fixup value must be 2-byte aligned");
698 unsigned Sbit = (
Value >> 10) & 0x1;
699 unsigned Hi5 = (
Value >> 5) & 0x1f;
700 unsigned Lo4 = (
Value >> 1) & 0xf;
704 Value = (Sbit << 31) | (Hi5 << 25) | (Lo4 << 8);
714 if (!
F.getParent()->isLinkerRelaxable())
749 if (
DF->getContents().size() ==
Offset) {
759 auto Kind =
F.getKind();
768 case ELF::R_RISCV_GOT_HI20:
769 case ELF::R_RISCV_TLS_GOT_HI20:
770 case ELF::R_RISCV_TLS_GD_HI20:
771 case ELF::R_RISCV_TLSDESC_HI20:
785static std::optional<MCValue>
789 if (!Fixup.isPCRel() ||
790 !Fixup.getValue()->evaluateAsRelocatable(Raw,
nullptr) ||
795 if (!
Sub.isInSection() || &
Sub.getSection() !=
F.getParent())
801 uint64_t InsnStart = Fixup.getOffset() >=
F.getFixedSize()
804 if (Asm.getSymbolOffset(
Sub) != Asm.getFragmentOffset(
F) + InsnStart)
817 switch (Fixup.getKind()) {
833 "could not find corresponding %pcrel_hi");
850 if (SA.isUndefined())
869 switch (Fixup.getKind()) {
879 VendorIdentifier =
"QUALCOMM";
882 VendorIdentifier =
"ANDES";
889 MCSymbol *VendorSymbol = Ctx.createLocalSymbol(VendorIdentifier);
890 auto [It, Inserted] =
896 Asm->registerSymbol(*VendorSymbol);
899 VendorSymbol = It->getValue();
907 uint64_t VendorValue;
908 Asm->getWriter().recordRelocation(
F, VendorFixup, VendorTarget, VendorValue);
933 uint64_t FixedValueA, FixedValueB;
936 "relocatable SymA-SymB cannot have relocation specifier");
937 unsigned TA = 0, TB = 0;
938 switch (Fixup.getKind()) {
940 TA = ELF::R_RISCV_ADD8;
941 TB = ELF::R_RISCV_SUB8;
944 TA = ELF::R_RISCV_ADD16;
945 TB = ELF::R_RISCV_SUB16;
948 TA = ELF::R_RISCV_ADD32;
949 TB = ELF::R_RISCV_SUB32;
952 TA = ELF::R_RISCV_ADD64;
953 TB = ELF::R_RISCV_SUB64;
956 TA = ELF::R_RISCV_SET_ULEB128;
957 TB = ELF::R_RISCV_SUB_ULEB128;
964 "unsupported symbol difference in instruction");
972 Asm->getWriter().recordRelocation(
F, FA,
A, FixedValueA);
973 Asm->getWriter().recordRelocation(
F, FB,
B, FixedValueB);
974 FixedValue = FixedValueA - FixedValueB;
980 bool NeedsRelax = Fixup.isLinkerRelaxable() &&
985 if (IsResolved && Fixup.isPCRel())
993 Asm->getWriter().recordRelocation(
F, Fixup,
Target, FixedValue);
1001 uint64_t RelaxValue;
1002 Asm->getWriter().recordRelocation(
F, RelaxFixup, RelaxTarget, RelaxValue);
1027 uint64_t
Value,
bool IsResolved) {
1040 Value <<= Info.TargetOffset;
1042 unsigned NumBytes =
alignTo(Info.TargetSize + Info.TargetOffset, 8) / 8;
1043 assert(Fixup.getOffset() + NumBytes <=
F.getSize() &&
1044 "Invalid fixup offset!");
1050 for (
unsigned i = 0; i != NumBytes; ++i) {
1051 unsigned Idx = SwapValue ? (NumBytes - 1 - i) : i;
1056std::unique_ptr<MCObjectTargetWriter>
1067 std::unique_ptr<MCObjectTargetWriter>
1069 const Triple &TT =
STI.getTargetTriple();
1076 uint64_t &FixedValue,
bool IsResolved)
override;
1089 "could not find corresponding %pcrel_hi");
1107 if (TT.isOSBinFormatMachO())
1109 TT.isLittleEndian(),
Options);
1111 return new RISCVAsmBackend(STI, OSABI, TT.isArch64Bit(), TT.isLittleEndian(),
1117 uint64_t &FixedValue,
bool IsResolved) {
1119 Asm->getWriter().recordRelocation(
F, Fixup,
Target, FixedValue);
static uint64_t adjustFixupValue(const MCFixup &Fixup, const MCValue &Target, uint64_t Value, MCContext &Ctx, const Triple &TheTriple, bool IsResolved)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file implements a class to represent arbitrary precision integral constant values and operations...
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static RegisterPass< DebugifyFunctionPass > DF("debugify-function", "Attach debug info to a function")
static unsigned getRelaxedOpcode(unsigned Opcode)
static std::optional< MCValue > getPCRelTargetOfDotDifference(const MCAssembler &Asm, const MCFragment &F, const MCFixup &Fixup)
static bool relaxableFixupNeedsRelocation(const MCFixupKind Kind)
static bool isDataFixup(unsigned Kind)
const MCFixup * getPCRelHiFixup(const MCSpecifierExpr &Expr, const MCFragment **DFOut)
MachineRegisterInfo & MRI
Func getContext().diagnose(DiagnosticInfoUnsupported(Func
std::optional< bool > evaluateFixup(const MCFragment &F, MCFixup &Fixup, MCValue &Target, uint64_t &Value) override
bool addReloc(const MCFragment &, const MCFixup &, const MCValue &, uint64_t &FixedValue, bool IsResolved) override
std::unique_ptr< MCObjectTargetWriter > createObjectTargetWriter() const override
DarwinRISCVAsmBackend(const MCSubtargetInfo &STI, uint8_t OSABI, bool Is64Bit, bool IsLittleEndian, const MCTargetOptions &Options)
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Generic interface to target specific assembler backends.
const llvm::endianness Endian
MCAsmBackend(llvm::endianness Endian)
virtual MCFixupKindInfo getFixupKindInfo(MCFixupKind Kind) const
Get information on a fixup kind.
MCContext & getContext() const
unsigned getCodePointerSize() const
Get the code pointer size in bytes.
Binary assembler expressions.
const MCExpr * getLHS() const
Get the left-hand side expression of the binary operator.
const MCExpr * getRHS() const
Get the right-hand side expression of the binary operator.
static LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Context object for machine code objects.
LLVM_ABI MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
LLVM_ABI void reportError(SMLoc L, const Twine &Msg)
const MCAsmInfo & getAsmInfo() const
Base class for the full range of assembler expressions which are needed for parsing.
LLVM_ABI bool evaluateAsRelocatable(MCValue &Res, const MCAssembler *Asm) const
Try to evaluate the expression to a relocatable value, i.e.
static LLVM_ABI bool evaluateSymbolicAdd(const MCAssembler *, bool, const MCValue &, const MCValue &, MCValue &)
LLVM_ABI bool evaluateKnownAbsolute(int64_t &Res, const MCAssembler &Asm) const
Aggressive variant of evaluateAsRelocatable when relocations are unavailable (e.g.
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
static MCFixupKind getDataKindForSize(unsigned Size)
Return the generic fixup kind for a value with the given size.
const MCExpr * getValue() const
uint32_t getOffset() const
static MCFixup create(uint32_t Offset, const MCExpr *Value, MCFixupKind Kind, bool PCRel=false)
Consider bit fields if we need more flags.
MCFixupKind getKind() const
const MCExpr & getLEBValue() const
MCSection * getParent() const
LLVM_ABI void setVarFixups(ArrayRef< MCFixup > Fixups)
Instances of this class represent a single low-level machine instruction.
unsigned getOpcode() const
ArrayRef< MCOperand > getOperands() const
void addOperand(const MCOperand Op)
void setOpcode(unsigned Op)
const MCOperand & getOperand(unsigned i) const
static MCOperand createExpr(const MCExpr *Val)
static MCOperand createReg(MCRegister Reg)
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 and target specific virtual registers.
Extension point for target-specific MCExpr subclasses with a relocation specifier,...
const MCExpr * getSubExpr() const
Generic base class for all target subtargets.
bool hasFeature(unsigned Feature) const
const Triple & getTargetTriple() const
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
LLVM_ABI void setVariableValue(const MCExpr *Value)
MCSection & getSection() const
Get the section associated with a defined, non-absolute symbol.
MCFragment * getFragment() const
uint64_t getOffset() const
static MCValue get(const MCSymbol *SymA, const MCSymbol *SymB=nullptr, int64_t Val=0, uint32_t Specifier=0)
const MCSymbol * getAddSym() const
int64_t getConstant() const
uint32_t getSpecifier() const
const MCSymbol * getSubSym() const
std::optional< bool > evaluateFixup(const MCFragment &, MCFixup &, MCValue &, uint64_t &) override
std::unique_ptr< MCObjectTargetWriter > createObjectTargetWriter() const override
bool isPCRelFixupResolved(const MCSymbol *SymA, const MCFragment &F)
void relaxInstruction(MCInst &Inst, const MCSubtargetInfo &STI) const override
Relax the instruction in the given fragment to the next wider instruction.
bool relaxAlign(MCFragment &F, unsigned &Size) override
virtual bool addReloc(const MCFragment &, const MCFixup &, const MCValue &, uint64_t &FixedValue, bool IsResolved)
MCFixupKindInfo getFixupKindInfo(MCFixupKind Kind) const override
Get information on a fixup kind.
RISCVAsmBackend(const MCSubtargetInfo &STI, uint8_t OSABI, bool Is64Bit, bool IsLittleEndian, const MCTargetOptions &Options)
std::pair< bool, bool > relaxLEB128(MCFragment &LF, int64_t &Value) const override
void applyFixup(const MCFragment &, const MCFixup &, const MCValue &Target, uint8_t *Data, uint64_t Value, bool IsResolved) override
bool writeNopData(raw_ostream &OS, uint64_t Count, const MCSubtargetInfo *STI) const override
Write an (optimal) nop sequence of Count bytes to the given output.
const MCSubtargetInfo & STI
void maybeAddVendorReloc(const MCFragment &, const MCFixup &)
StringMap< MCSymbol * > VendorSymbols
bool mayNeedRelaxation(unsigned Opcode, ArrayRef< MCOperand > Operands, const MCSubtargetInfo &STI) const override
Check whether the given instruction (encoded as Opcode+Operands) may need relaxation.
bool fixupNeedsRelaxationAdvanced(const MCFragment &, const MCFixup &, const MCValue &, uint64_t, bool) const override
Target specific predicate for whether a given fixup requires the associated instruction to be relaxed...
const RISCVMCOptions & CLOpts
std::optional< MCFixupKind > getFixupKind(StringRef Name) const override
Map a relocation name used in .reloc to a fixup kind.
bool relaxDwarfCFA(MCFragment &) const override
bool relaxDwarfLineAddr(MCFragment &) const override
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
A switch()-like statement whose cases are string literals.
StringSwitch & Case(StringLiteral S, T Value)
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream.
raw_ostream & write_zeros(unsigned NumZeros)
write_zeros - Insert 'NumZeros' nulls.
uint64_t tell() const
tell - Return the current offset with the file.
raw_ostream & write(unsigned char C)
A raw_ostream that writes to an SmallVector or SmallString.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
LLVM_ABI Expected< uint32_t > getCPUSubType(const Triple &T)
LLVM_ABI Expected< uint32_t > getCPUType(const Triple &T)
void validate(const Triple &TT, const FeatureBitset &FeatureBits)
@ fixup_riscv_pcrel_lo12_i
@ fixup_riscv_pcrel_lo12_s
@ fixup_riscv_nds_branch_10
@ fixup_riscv_qc_e_call_plt
@ fixup_riscv_qc_e_branch
bool isRelocation(MCFixupKind FixupKind)
void write(void *memory, value_type value, endianness endian)
Write a value to memory with a particular endianness.
This is an optimization pass for GlobalISel generic memory operations.
std::unique_ptr< MCObjectTargetWriter > createRISCVELFObjectWriter(uint8_t OSABI, bool Is64Bit)
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
constexpr bool isUIntN(unsigned N, uint64_t x)
Checks if an unsigned integer fits into the given (dynamic) bit width.
constexpr MCFixupKind FirstTargetFixupKind
std::unique_ptr< MCObjectTargetWriter > createRISCVMachObjectWriter(uint32_t CPUType, uint32_t CPUSubtype)
uint16_t MCFixupKind
Extensible enumeration to represent the type of a fixup.
constexpr uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.
@ FK_Data_8
A eight-byte fixup.
@ FK_Data_1
A one-byte fixup.
@ FK_Data_4
A four-byte fixup.
@ FK_Data_leb128
A leb128 fixup.
@ FK_Data_2
A two-byte fixup.
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
MCAsmBackend * createRISCVAsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options)
@ Sub
Subtraction of integers.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
unsigned encodeSLEB128(int64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a SLEB128 value to an output stream.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
constexpr MCFixupKind FirstLiteralRelocationKind
Target independent information on a fixup kind.