LLVM 24.0.0git
LoongArchAsmBackend.cpp
Go to the documentation of this file.
1//===-- LoongArchAsmBackend.cpp - LoongArch Assembler Backend -*- C++ -*---===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the LoongArchAsmBackend class.
10//
11//===----------------------------------------------------------------------===//
12
13#include "LoongArchAsmBackend.h"
14#include "LoongArchFixupKinds.h"
16#include "llvm/MC/MCAsmInfo.h"
17#include "llvm/MC/MCAssembler.h"
18#include "llvm/MC/MCContext.h"
20#include "llvm/MC/MCExpr.h"
21#include "llvm/MC/MCSection.h"
22#include "llvm/MC/MCValue.h"
24#include "llvm/Support/LEB128.h"
26
27#define DEBUG_TYPE "loongarch-asmbackend"
28
29using namespace llvm;
30
32 uint8_t OSABI, bool Is64Bit,
34 : MCAsmBackend(llvm::endianness::little), STI(STI), OSABI(OSABI),
35 Is64Bit(Is64Bit), TargetOptions(Options) {}
36
37std::optional<MCFixupKind>
39 if (STI.getTargetTriple().isOSBinFormatELF()) {
41#define ELF_RELOC(X, Y) .Case(#X, Y)
42#include "llvm/BinaryFormat/ELFRelocs/LoongArch.def"
43#undef ELF_RELOC
44 .Case("BFD_RELOC_NONE", ELF::R_LARCH_NONE)
45 .Case("BFD_RELOC_32", ELF::R_LARCH_32)
46 .Case("BFD_RELOC_64", ELF::R_LARCH_64)
47 .Default(-1u);
48 if (Type != -1u)
49 return static_cast<MCFixupKind>(FirstLiteralRelocationKind + Type);
50 }
51 return std::nullopt;
52}
53
55 const static MCFixupKindInfo Infos[] = {
56 // This table *must* be in the order that the fixup_* kinds are defined in
57 // LoongArchFixupKinds.h.
58 //
59 // {name, offset, bits, flags}
60 {"fixup_loongarch_b16", 10, 16, 0},
61 {"fixup_loongarch_b21", 0, 26, 0},
62 {"fixup_loongarch_b26", 0, 26, 0},
63 {"fixup_loongarch_abs_hi20", 5, 20, 0},
64 {"fixup_loongarch_abs_lo12", 10, 12, 0},
65 {"fixup_loongarch_abs64_lo20", 5, 20, 0},
66 {"fixup_loongarch_abs64_hi12", 10, 12, 0},
67 {"fixup_loongarch_dtprel32", 0, 32, 0},
68 {"fixup_loongarch_dtprel64", 0, 64, 0},
69 };
70
71 static_assert((std::size(Infos)) == LoongArch::NumTargetFixupKinds,
72 "Not all fixup kinds added to Infos array");
73
74 // Fixup kinds from .reloc directive are like R_LARCH_NONE. They
75 // do not require any extra processing.
76 if (mc::isRelocation(Kind))
77 return {};
78
79 if (Kind < FirstTargetFixupKind)
81
82 assert(unsigned(Kind - FirstTargetFixupKind) <
84 "Invalid kind!");
85 return Infos[Kind - FirstTargetFixupKind];
86}
87
88static void reportOutOfRangeError(MCContext &Ctx, SMLoc Loc, unsigned N) {
89 Ctx.reportError(Loc, "fixup value out of range [" + Twine(llvm::minIntN(N)) +
90 ", " + Twine(llvm::maxIntN(N)) + "]");
91}
92
94 MCContext &Ctx) {
95 switch (Fixup.getKind()) {
96 default:
97 llvm_unreachable("Unknown fixup kind");
98 case FK_Data_1:
99 case FK_Data_2:
100 case FK_Data_4:
101 case FK_Data_8:
102 case FK_Data_leb128:
105 return Value;
107 if (!isInt<18>(Value))
108 reportOutOfRangeError(Ctx, Fixup.getLoc(), 18);
109 if (Value % 4)
110 Ctx.reportError(Fixup.getLoc(), "fixup value must be 4-byte aligned");
111 return (Value >> 2) & 0xffff;
112 }
114 if (!isInt<23>(Value))
115 reportOutOfRangeError(Ctx, Fixup.getLoc(), 23);
116 if (Value % 4)
117 Ctx.reportError(Fixup.getLoc(), "fixup value must be 4-byte aligned");
118 return ((Value & 0x3fffc) << 8) | ((Value >> 18) & 0x1f);
119 }
121 if (!isInt<28>(Value))
122 reportOutOfRangeError(Ctx, Fixup.getLoc(), 28);
123 if (Value % 4)
124 Ctx.reportError(Fixup.getLoc(), "fixup value must be 4-byte aligned");
125 return ((Value & 0x3fffc) << 8) | ((Value >> 18) & 0x3ff);
126 }
128 return (Value >> 12) & 0xfffff;
130 return Value & 0xfff;
132 return (Value >> 32) & 0xfffff;
134 return (Value >> 52) & 0xfff;
135 }
136}
137
138static void fixupLeb128(MCContext &Ctx, const MCFixup &Fixup, uint8_t *Data,
139 uint64_t Value) {
140 unsigned I;
141 for (I = 0; Value; ++I, Value >>= 7)
142 Data[I] |= uint8_t(Value & 0x7f);
143}
144
146 const MCValue &Target, uint8_t *Data,
147 uint64_t Value, bool IsResolved) {
148 addReloc(F, Fixup, Target, Value, IsResolved);
149 if (!Value)
150 return; // Doesn't change encoding.
151
152 auto Kind = Fixup.getKind();
153 if (mc::isRelocation(Kind))
154 return;
156 MCContext &Ctx = getContext();
157
158 // Fixup leb128 separately.
159 if (Fixup.getKind() == FK_Data_leb128)
160 return fixupLeb128(Ctx, Fixup, Data, Value);
161
162 // Apply any target-specific value adjustments.
164
165 // Shift the value into position.
166 Value <<= Info.TargetOffset;
167
168 unsigned NumBytes = alignTo(Info.TargetSize + Info.TargetOffset, 8) / 8;
169
170 assert(Fixup.getOffset() + NumBytes <= F.getSize() &&
171 "Invalid fixup offset!");
172 // For each byte of the fragment that the fixup touches, mask in the
173 // bits from the fixup value.
174 for (unsigned I = 0; I != NumBytes; ++I) {
175 Data[I] |= uint8_t((Value >> (I * 8)) & 0xff);
176 }
177}
178
179static inline std::pair<MCFixupKind, MCFixupKind>
181 switch (Size) {
182 default:
183 llvm_unreachable("unsupported fixup size");
184 case 6:
185 return std::make_pair(ELF::R_LARCH_ADD6, ELF::R_LARCH_SUB6);
186 case 8:
187 return std::make_pair(ELF::R_LARCH_ADD8, ELF::R_LARCH_SUB8);
188 case 16:
189 return std::make_pair(ELF::R_LARCH_ADD16, ELF::R_LARCH_SUB16);
190 case 32:
191 return std::make_pair(ELF::R_LARCH_ADD32, ELF::R_LARCH_SUB32);
192 case 64:
193 return std::make_pair(ELF::R_LARCH_ADD64, ELF::R_LARCH_SUB64);
194 case 128:
195 return std::make_pair(ELF::R_LARCH_ADD_ULEB128, ELF::R_LARCH_SUB_ULEB128);
196 }
197}
198
199// Check whether an alignment fragment needs linker relaxation.
201 // Alignments before the first linker-relaxable instruction have fixed sizes
202 // and do not require relocations. Alignments after a linker-relaxable
203 // instruction require a relocation, even if the STI specifies norelax.
204 //
205 // firstLinkerRelaxable is the layout order within the subsection, which may
206 // be smaller than the section's order. Therefore, alignments in a
207 // lower-numbered subsection may be unnecessarily treated as linker-relaxable.
208 auto *Sec = F.getParent();
209 if (F.getLayoutOrder() <= Sec->firstLinkerRelaxable())
210 return false;
211
212 const unsigned MinNopLen = 4;
213 if (F.getAlignMaxBytesToEmit() < MinNopLen)
214 return false;
215 if (F.getAlignment() <= MinNopLen)
216 return false;
217
218 return true;
219}
220
221// Check if an R_LARCH_ALIGN relocation is needed for an alignment directive.
222// If conditions are met, compute the padding size and create a fixup encoding
223// the padding size in the addend. If MaxBytesToEmit is smaller than the padding
224// size, the fixup encodes MaxBytesToEmit in the higher bits and references a
225// per-section marker symbol.
227 if (!shouldRelaxAlign(F))
228 return false;
229
230 Size = F.getAlignment().value() - 4;
231 unsigned MaxBytesToEmit = F.getAlignMaxBytesToEmit();
232
233 MCContext &Ctx = getContext();
234 const MCExpr *Expr = nullptr;
235 if (MaxBytesToEmit >= Size) {
237 } else {
238 MCSection *Sec = F.getParent();
239 const MCSymbolRefExpr *SymRef = getSecToAlignSym()[Sec];
240 if (SymRef == nullptr) {
241 // Define a marker symbol at the section with an offset of 0.
242 MCSymbol *Sym = Ctx.createNamedTempSymbol("la-relax-align");
243 Sym->setFragment(&*Sec->getBeginSymbol()->getFragment());
244 Asm->registerSymbol(*Sym);
245 SymRef = MCSymbolRefExpr::create(Sym, Ctx);
246 getSecToAlignSym()[Sec] = SymRef;
247 }
249 SymRef,
250 MCConstantExpr::create((MaxBytesToEmit << 8) | Log2(F.getAlignment()),
251 Ctx),
252 Ctx);
253 }
254 MCFixup Fixup =
255 MCFixup::create(0, Expr, FirstLiteralRelocationKind + ELF::R_LARCH_ALIGN);
256 F.setVarFixups({Fixup});
257 F.setLinkerRelaxable();
258 return true;
259}
260
262 int64_t &Value) const {
263 const MCExpr &Expr = F.getLEBValue();
264 if (F.isLEBSigned() || !Expr.evaluateKnownAbsolute(Value, *Asm))
265 return std::make_pair(false, false);
266 F.setVarFixups({MCFixup::create(0, &Expr, FK_Data_leb128)});
267 return std::make_pair(true, true);
268}
269
272 int64_t LineDelta = F.getDwarfLineDelta();
273 const MCExpr &AddrDelta = F.getDwarfAddrDelta();
274 int64_t Value;
275 if (AddrDelta.evaluateAsAbsolute(Value, *Asm))
276 return false;
277 [[maybe_unused]] bool IsAbsolute =
278 AddrDelta.evaluateKnownAbsolute(Value, *Asm);
279 assert(IsAbsolute);
280
283
284 // INT64_MAX is a signal that this is actually a DW_LNE_end_sequence.
285 if (LineDelta != INT64_MAX) {
286 OS << uint8_t(dwarf::DW_LNS_advance_line);
287 encodeSLEB128(LineDelta, OS);
288 }
289
290 // According to the DWARF specification, the `DW_LNS_fixed_advance_pc` opcode
291 // takes a single unsigned half (unencoded) operand. The maximum encodable
292 // value is therefore 65535. Set a conservative upper bound for relaxation.
293 unsigned PCBytes;
294 if (Value > 60000) {
295 unsigned PtrSize = C.getAsmInfo().getCodePointerSize();
296 assert((PtrSize == 4 || PtrSize == 8) && "Unexpected pointer size");
297 PCBytes = PtrSize;
298 OS << uint8_t(dwarf::DW_LNS_extended_op) << uint8_t(PtrSize + 1)
299 << uint8_t(dwarf::DW_LNE_set_address);
300 OS.write_zeros(PtrSize);
301 } else {
302 PCBytes = 2;
303 OS << uint8_t(dwarf::DW_LNS_fixed_advance_pc);
305 }
306 auto Offset = OS.tell() - PCBytes;
307
308 if (LineDelta == INT64_MAX) {
309 OS << uint8_t(dwarf::DW_LNS_extended_op);
310 OS << uint8_t(1);
311 OS << uint8_t(dwarf::DW_LNE_end_sequence);
312 } else {
313 OS << uint8_t(dwarf::DW_LNS_copy);
314 }
315
316 F.setVarContents(Data);
317 F.setVarFixups({MCFixup::create(Offset, &AddrDelta,
318 MCFixup::getDataKindForSize(PCBytes))});
319 return true;
320}
321
323 const MCExpr &AddrDelta = F.getDwarfAddrDelta();
325 int64_t Value;
326 if (AddrDelta.evaluateAsAbsolute(Value, *Asm))
327 return false;
328 bool IsAbsolute = AddrDelta.evaluateKnownAbsolute(Value, *Asm);
329 assert(IsAbsolute && "CFA with invalid expression");
330 (void)IsAbsolute;
331
332 assert(getContext().getAsmInfo().getMinInstAlignment() == 1 &&
333 "expected 1-byte alignment");
334 if (Value == 0) {
335 F.clearVarContents();
336 F.clearVarFixups();
337 return true;
338 }
339
340 auto AddFixups = [&Fixups,
341 &AddrDelta](unsigned Offset,
342 std::pair<MCFixupKind, MCFixupKind> FK) {
343 const MCBinaryExpr &MBE = cast<MCBinaryExpr>(AddrDelta);
344 Fixups.push_back(MCFixup::create(Offset, MBE.getLHS(), std::get<0>(FK)));
345 Fixups.push_back(MCFixup::create(Offset, MBE.getRHS(), std::get<1>(FK)));
346 };
347
350 if (isUIntN(6, Value)) {
351 OS << uint8_t(dwarf::DW_CFA_advance_loc);
352 AddFixups(0, getRelocPairForSize(6));
353 } else if (isUInt<8>(Value)) {
354 OS << uint8_t(dwarf::DW_CFA_advance_loc1);
356 AddFixups(1, getRelocPairForSize(8));
357 } else if (isUInt<16>(Value)) {
358 OS << uint8_t(dwarf::DW_CFA_advance_loc2);
360 AddFixups(1, getRelocPairForSize(16));
361 } else if (isUInt<32>(Value)) {
362 OS << uint8_t(dwarf::DW_CFA_advance_loc4);
364 AddFixups(1, getRelocPairForSize(32));
365 } else {
366 llvm_unreachable("unsupported CFA encoding");
367 }
368 F.setVarContents(Data);
369 F.setVarFixups(Fixups);
370 return true;
371}
372
374 const MCSubtargetInfo *STI) const {
375 // We mostly follow binutils' convention here: align to 4-byte boundary with a
376 // 0-fill padding.
377 OS.write_zeros(Count % 4);
378
379 // The remainder is now padded with 4-byte nops.
380 // nop: andi r0, r0, 0
381 for (; Count >= 4; Count -= 4)
382 OS.write("\0\0\x40\x03", 4);
383
384 return true;
385}
386
387bool LoongArchAsmBackend::isPCRelFixupResolved(const MCSymbol *SymA,
388 const MCFragment &F) {
389 // If the section does not contain linker-relaxable fragments, PC-relative
390 // fixups can be resolved.
391 if (!F.getParent()->isLinkerRelaxable())
392 return true;
393
394 // Otherwise, check if the offset between the symbol and fragment is fully
395 // resolved, unaffected by linker-relaxable fragments (e.g. instructions or
396 // offset-affected FT_Align fragments). Complements the generic
397 // isSymbolRefDifferenceFullyResolvedImpl.
398 if (!PCRelTemp)
399 PCRelTemp = getContext().createTempSymbol();
400 PCRelTemp->setFragment(const_cast<MCFragment *>(&F));
401 MCValue Res;
403 MCValue::get(nullptr, PCRelTemp), Res);
404 return !Res.getSubSym();
405}
406
408 const MCValue &Target, uint64_t &FixedValue,
409 bool IsResolved) {
410 auto Fallback = [&]() {
411 MCAsmBackend::maybeAddReloc(F, Fixup, Target, FixedValue, IsResolved);
412 return;
413 };
414 uint64_t FixedValueA, FixedValueB;
415 if (Target.getSubSym()) {
416 // It's possible for Target to have (SymB != nullptr && SymA == nullptr).
417 // Go to the fallback path when we encounter this. See also #196927.
418 if (!Target.getAddSym())
419 return Fallback();
420
421 assert(Target.getSpecifier() == 0 &&
422 "relocatable SymA-SymB cannot have relocation specifier");
423 std::pair<MCFixupKind, MCFixupKind> FK;
424 const MCSymbol &SA = *Target.getAddSym();
425 const MCSymbol &SB = *Target.getSubSym();
426
427 bool force = !SA.isInSection() || !SB.isInSection();
428 if (!force) {
429 const MCSection &SecA = SA.getSection();
430 const MCSection &SecB = SB.getSection();
431 const MCSection &SecCur = *F.getParent();
432
433 // To handle the case of A - B which B is same section with the current,
434 // generate PCRel relocations is better than ADD/SUB relocation pair.
435 // We can resolve it as A - PC + PC - B. The A - PC will be resolved
436 // as a PCRel relocation, while PC - B will serve as the addend.
437 // If the linker relaxation is disabled, it can be done directly since
438 // PC - B is constant. Otherwise, we should evaluate whether PC - B
439 // is constant. If it can be resolved as PCRel, use Fallback which
440 // generates R_LARCH_{32,64}_PCREL relocation later.
441 if (&SecA != &SecB && &SecB == &SecCur &&
442 isPCRelFixupResolved(Target.getSubSym(), F))
443 return Fallback();
444
445 // In SecA == SecB case. If the section is not linker-relaxable, the
446 // FixedValue has already been calculated out in evaluateFixup,
447 // return true and avoid record relocations.
448 if (&SecA == &SecB && !SecA.isLinkerRelaxable())
449 return;
450 }
451
452 switch (Fixup.getKind()) {
453 case FK_Data_1:
454 FK = getRelocPairForSize(8);
455 break;
456 case FK_Data_2:
457 FK = getRelocPairForSize(16);
458 break;
459 case FK_Data_4:
460 FK = getRelocPairForSize(32);
461 break;
462 case FK_Data_8:
463 FK = getRelocPairForSize(64);
464 break;
465 case FK_Data_leb128:
466 FK = getRelocPairForSize(128);
467 break;
468 default:
469 llvm_unreachable("unsupported fixup size");
470 }
471 MCValue A = MCValue::get(Target.getAddSym(), nullptr, Target.getConstant());
472 MCValue B = MCValue::get(Target.getSubSym());
473 auto FA = MCFixup::create(Fixup.getOffset(), nullptr, std::get<0>(FK));
474 auto FB = MCFixup::create(Fixup.getOffset(), nullptr, std::get<1>(FK));
475 Asm->getWriter().recordRelocation(F, FA, A, FixedValueA);
476 Asm->getWriter().recordRelocation(F, FB, B, FixedValueB);
477 FixedValue = FixedValueA - FixedValueB;
478 return;
479 }
480
481 // If linker relaxation is enabled and supported by the current relocation,
482 // generate a relocation and then append a RELAX.
483 if (Fixup.isLinkerRelaxable()) {
484 Asm->getWriter().recordRelocation(F, Fixup, Target, FixedValue);
485 auto FA = MCFixup::create(Fixup.getOffset(), nullptr, ELF::R_LARCH_RELAX);
486 Asm->getWriter().recordRelocation(F, FA, MCValue::get(nullptr),
487 FixedValueA);
488 return;
489 }
490
491 if (!IsResolved) {
492 Asm->getWriter().recordRelocation(F, Fixup, Target, FixedValue);
493 return;
494 }
495
496 if (Fixup.isPCRel() && !isPCRelFixupResolved(Target.getAddSym(), F))
497 Asm->getWriter().recordRelocation(F, Fixup, Target, FixedValue);
498}
499
500std::unique_ptr<MCObjectTargetWriter>
504
506 const MCSubtargetInfo &STI,
507 const MCRegisterInfo &MRI,
508 const MCTargetOptions &Options) {
509 const Triple &TT = STI.getTargetTriple();
510 uint8_t OSABI = MCELFObjectTargetWriter::getOSABI(TT.getOS());
511 return new LoongArchAsmBackend(STI, OSABI, TT.isArch64Bit(), Options);
512}
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!")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static LVOptions Options
Definition LVOptions.cpp:25
static std::pair< MCFixupKind, MCFixupKind > getRelocPairForSize(unsigned Size)
static void fixupLeb128(MCContext &Ctx, const MCFixup &Fixup, uint8_t *Data, uint64_t Value)
static void reportOutOfRangeError(MCContext &Ctx, SMLoc Loc, unsigned N)
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
#define T
PowerPC TLS Dynamic Call Fixup
bool relaxDwarfCFA(MCFragment &) const override
std::unique_ptr< MCObjectTargetWriter > createObjectTargetWriter() const override
void addReloc(const MCFragment &, const MCFixup &, const MCValue &, uint64_t &FixedValue, bool IsResolved)
std::optional< MCFixupKind > getFixupKind(StringRef Name) const override
Map a relocation name used in .reloc to a fixup kind.
DenseMap< MCSection *, const MCSymbolRefExpr * > & getSecToAlignSym()
bool relaxDwarfLineAddr(MCFragment &) const override
LoongArchAsmBackend(const MCSubtargetInfo &STI, uint8_t OSABI, bool Is64Bit, const MCTargetOptions &Options)
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.
void applyFixup(const MCFragment &, const MCFixup &, const MCValue &Target, uint8_t *Data, uint64_t Value, bool IsResolved) override
static bool shouldRelaxAlign(const MCFragment &F)
Check whether an alignment fragment needs linker relaxation.
bool relaxAlign(MCFragment &F, unsigned &Size) override
std::pair< bool, bool > relaxLEB128(MCFragment &F, int64_t &Value) const override
MCFixupKindInfo getFixupKindInfo(MCFixupKind Kind) const override
Get information on a fixup kind.
Generic interface to target specific assembler backends.
MCAsmBackend(llvm::endianness Endian)
virtual MCFixupKindInfo getFixupKindInfo(MCFixupKind Kind) const
Get information on a fixup kind.
MCAssembler * Asm
MCContext & getContext() const
void maybeAddReloc(const MCFragment &, const MCFixup &, const MCValue &, uint64_t &Value, bool IsResolved)
Binary assembler expressions.
Definition MCExpr.h:298
const MCExpr * getLHS() const
Get the left-hand side expression of the binary operator.
Definition MCExpr.h:445
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition MCExpr.h:342
const MCExpr * getRHS() const
Get the right-hand side expression of the binary operator.
Definition MCExpr.h:448
static LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Definition MCExpr.cpp:212
Context object for machine code objects.
Definition MCContext.h:83
LLVM_ABI MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
Base class for the full range of assembler expressions which are needed for parsing.
Definition MCExpr.h:34
static LLVM_ABI bool evaluateSymbolicAdd(const MCAssembler *, bool, const MCValue &, const MCValue &, MCValue &)
Definition MCExpr.cpp:407
LLVM_ABI bool evaluateKnownAbsolute(int64_t &Res, const MCAssembler &Asm) const
Aggressive variant of evaluateAsRelocatable when relocations are unavailable (e.g.
Definition MCExpr.cpp:250
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition MCFixup.h:61
static MCFixupKind getDataKindForSize(unsigned Size)
Return the generic fixup kind for a value with the given size.
Definition MCFixup.h:110
static MCFixup create(uint32_t Offset, const MCExpr *Value, MCFixupKind Kind, bool PCRel=false)
Consider bit fields if we need more flags.
Definition MCFixup.h:86
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition MCSection.h:580
bool isLinkerRelaxable() const
Definition MCSection.h:683
MCSymbol * getBeginSymbol()
Definition MCSection.h:653
Generic base class for all target subtargets.
const Triple & getTargetTriple() const
Represent a reference to a symbol from inside an expression.
Definition MCExpr.h:190
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition MCExpr.h:213
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
bool isInSection() const
isInSection - Check if this symbol is defined in some section (i.e., it is defined but not absolute).
Definition MCSymbol.h:237
void setFragment(MCFragment *F) const
Mark the symbol as defined in the fragment F.
Definition MCSymbol.h:257
MCSection & getSection() const
Get the section associated with a defined, non-absolute symbol.
Definition MCSymbol.h:251
MCFragment * getFragment() const
Definition MCSymbol.h:345
static MCValue get(const MCSymbol *SymA, const MCSymbol *SymB=nullptr, int64_t Val=0, uint32_t Specifier=0)
Definition MCValue.h:56
const MCSymbol * getSubSym() const
Definition MCValue.h:51
Represents a location in source code.
Definition SMLoc.h:22
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.
Definition StringRef.h:56
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.
Definition Triple.h:48
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
LLVM Value Representation.
Definition Value.h:75
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
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 INT64_MAX
Definition DataTypes.h:71
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool isRelocation(MCFixupKind FixupKind)
Definition MCFixup.h:130
void write(void *memory, value_type value, endianness endian)
Write a value to memory with a particular endianness.
Definition Endian.h:96
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:578
std::unique_ptr< MCObjectTargetWriter > createLoongArchELFObjectWriter(uint8_t OSABI, bool Is64Bit)
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
Definition MathExtras.h:166
constexpr int64_t minIntN(int64_t N)
Gets the minimum value for a N-bit signed integer.
Definition MathExtras.h:224
constexpr bool isUIntN(unsigned N, uint64_t x)
Checks if an unsigned integer fits into the given (dynamic) bit width.
Definition MathExtras.h:244
uint16_t MCFixupKind
Extensible enumeration to represent the type of a fixup.
Definition MCFixup.h:22
MCAsmBackend * createLoongArchAsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options)
constexpr uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Definition Alignment.h:144
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.
Definition MathExtras.h:190
@ FirstTargetFixupKind
Definition MCFixup.h:44
@ FirstLiteralRelocationKind
Definition MCFixup.h:29
@ FK_Data_8
A eight-byte fixup.
Definition MCFixup.h:37
@ FK_Data_1
A one-byte fixup.
Definition MCFixup.h:34
@ FK_Data_4
A four-byte fixup.
Definition MCFixup.h:36
@ FK_Data_leb128
A leb128 fixup.
Definition MCFixup.h:38
@ FK_Data_2
A two-byte fixup.
Definition MCFixup.h:35
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
Definition InstrProf.h:145
constexpr int64_t maxIntN(int64_t N)
Gets the maximum value for a N-bit signed integer.
Definition MathExtras.h:233
unsigned encodeSLEB128(int64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a SLEB128 value to an output stream.
Definition LEB128.h:24
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
unsigned Log2(Align A)
Returns the log2 of the alignment.
Definition Alignment.h:197
endianness
Definition bit.h:71
#define N
Target independent information on a fixup kind.