23#define DEBUG_TYPE "loongarch-asmbackend"
27std::optional<MCFixupKind>
31#define ELF_RELOC(X, Y) .Case(#X, Y)
32#include "llvm/BinaryFormat/ELFRelocs/LoongArch.def"
34 .
Case(
"BFD_RELOC_NONE", ELF::R_LARCH_NONE)
35 .
Case(
"BFD_RELOC_32", ELF::R_LARCH_32)
36 .
Case(
"BFD_RELOC_64", ELF::R_LARCH_64)
54 {
"fixup_loongarch_abs_hi20", 5, 20, 0},
55 {
"fixup_loongarch_abs_lo12", 10, 12, 0},
56 {
"fixup_loongarch_abs64_lo20", 5, 20, 0},
57 {
"fixup_loongarch_abs64_hi12", 10, 12, 0},
58 {
"fixup_loongarch_tls_le_hi20", 5, 20, 0},
59 {
"fixup_loongarch_tls_le_lo12", 10, 12, 0},
60 {
"fixup_loongarch_tls_le64_lo20", 5, 20, 0},
61 {
"fixup_loongarch_tls_le64_hi12", 10, 12, 0},
66 "Not all fixup kinds added to Infos array");
88 switch (
Fixup.getTargetKind()) {
97 if (!isInt<18>(
Value))
101 return (
Value >> 2) & 0xffff;
104 if (!isInt<23>(
Value))
108 return ((
Value & 0x3fffc) << 8) | ((
Value >> 18) & 0x1f);
111 if (!isInt<28>(
Value))
115 return ((
Value & 0x3fffc) << 8) | ((
Value >> 18) & 0x3ff);
119 return (
Value >> 12) & 0xfffff;
122 return Value & 0xfff;
125 return (
Value >> 32) & 0xfffff;
128 return (
Value >> 52) & 0xfff;
154 unsigned NumBytes =
alignTo(
Info.TargetSize +
Info.TargetOffset, 8) / 8;
159 for (
unsigned I = 0;
I != NumBytes; ++
I) {
169 switch (
Fixup.getTargetKind()) {
176 return !
Target.isAbsolute();
188 for (; Count >= 4; Count -= 4)
194std::unique_ptr<MCObjectTargetWriter>
unsigned const MachineRegisterInfo * MRI
static uint64_t adjustFixupValue(const MCFixup &Fixup, const MCValue &Target, uint64_t Value, MCContext &Ctx, const Triple &TheTriple, bool IsResolved)
Analysis containing CSE Info
static void reportOutOfRangeError(MCContext &Ctx, SMLoc Loc, unsigned N)
PowerPC TLS Dynamic Call Fixup
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, const MCValue &Target, MutableArrayRef< char > Data, uint64_t Value, bool IsResolved, const MCSubtargetInfo *STI) const override
Apply the Value for given Fixup into the provided data fragment, at the offset specified by the fixup...
std::unique_ptr< MCObjectTargetWriter > createObjectTargetWriter() const override
std::optional< MCFixupKind > getFixupKind(StringRef Name) const override
Map a relocation name used in .reloc to a fixup kind.
bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup, const MCValue &Target) override
Hook to check if a relocation is needed for some target specific reason.
const MCFixupKindInfo & getFixupKindInfo(MCFixupKind Kind) const override
Get information on a fixup kind.
unsigned getNumFixupKinds() const override
Get the number of target specific fixup kinds.
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.
Generic interface to target specific assembler backends.
virtual const MCFixupKindInfo & getFixupKindInfo(MCFixupKind Kind) const
Get information on a fixup kind.
Context object for machine code objects.
void reportError(SMLoc L, const Twine &Msg)
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Generic base class for all target subtargets.
const Triple & getTargetTriple() const
This represents an "assembler immediate".
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Represents a location in source code.
StringRef - 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.
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
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.
raw_ostream & write(unsigned char C)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ fixup_loongarch_abs64_hi12
@ fixup_loongarch_tls_le_lo12
@ fixup_loongarch_abs_hi20
@ fixup_loongarch_abs_lo12
@ fixup_loongarch_abs64_lo20
@ fixup_loongarch_tls_le64_hi12
@ fixup_loongarch_tls_le64_lo20
@ fixup_loongarch_tls_le_hi20
This is an optimization pass for GlobalISel generic memory operations.
int64_t maxIntN(int64_t N)
Gets the maximum value for a N-bit signed integer.
std::unique_ptr< MCObjectTargetWriter > createLoongArchELFObjectWriter(uint8_t OSABI, bool Is64Bit)
MCAsmBackend * createLoongArchAsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options)
MCFixupKind
Extensible enumeration to represent the type of a fixup.
@ FirstLiteralRelocationKind
The range [FirstLiteralRelocationKind, MaxTargetFixupKind) is used for relocations coming from ....
@ FK_Data_8
A eight-byte fixup.
@ FK_Data_1
A one-byte fixup.
@ FK_Data_4
A four-byte fixup.
@ FK_Data_2
A two-byte fixup.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
int64_t minIntN(int64_t N)
Gets the minimum value for a N-bit signed integer.
Target independent information on a fixup kind.
@ FKF_IsPCRel
Is this fixup kind PCrelative? This is used by the assembler backend to evaluate fixup values in a ta...