31 auto checkFixupInRange = [&](int64_t Min, int64_t Max) ->
bool {
32 int64_t SVal = int64_t(
Value);
33 if (SVal < Min || SVal > Max) {
35 " not between " +
Twine(Min) +
36 " and " +
Twine(Max) +
")");
42 auto handlePCRelFixupValue = [&](
unsigned W) ->
uint64_t {
47 return (int64_t)
Value / 2;
50 switch (
unsigned(Kind)) {
52 return handlePCRelFixupValue(12);
54 return handlePCRelFixupValue(16);
56 return handlePCRelFixupValue(24);
58 return handlePCRelFixupValue(32);
61 if (!checkFixupInRange(0,
maxUIntN(12)))
71 return (DLo << 8) | DHi;
85 SystemZMCAsmBackend(uint8_t osABI)
107 std::unique_ptr<MCObjectTargetWriter>
114std::optional<MCFixupKind>
117#define ELF_RELOC(X, Y) .Case(#X, Y)
118#include "llvm/BinaryFormat/ELFRelocs/SystemZ.def"
120 .
Case(
"BFD_RELOC_NONE", ELF::R_390_NONE)
121 .
Case(
"BFD_RELOC_8", ELF::R_390_8)
122 .
Case(
"BFD_RELOC_16", ELF::R_390_16)
123 .
Case(
"BFD_RELOC_32", ELF::R_390_32)
124 .
Case(
"BFD_RELOC_64", ELF::R_390_64)
132SystemZMCAsmBackend::getFixupKindInfo(
MCFixupKind Kind)
const {
138 {
"FK_390_TLS_CALL", 0, 0, 0 },
139 {
"FK_390_12", 4, 12, 0 },
140 {
"FK_390_20", 4, 20, 0 }
156bool SystemZMCAsmBackend::shouldForceRelocation(
const MCAssembler &,
162void SystemZMCAsmBackend::applyFixup(
const MCAssembler &Asm,
172 unsigned BitSize = getFixupKindInfo(Kind).TargetSize;
173 unsigned Size = (BitSize + 7) / 8;
181 unsigned ShiftValue = (
Size * 8) - 8;
182 for (
unsigned I = 0;
I !=
Size; ++
I) {
201 return new SystemZMCAsmBackend(OSABI);
unsigned const MachineRegisterInfo * MRI
PowerPC TLS Dynamic Call Fixup
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
static uint64_t extractBitsForFixup(MCFixupKind Kind, uint64_t Value, const MCFixup &Fixup, MCContext &Ctx)
Generic interface to target specific assembler backends.
virtual bool writeNopData(raw_ostream &OS, uint64_t Count, const MCSubtargetInfo *STI) const =0
Write an (optimal) nop sequence of Count bytes to the given output.
virtual bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value, const MCRelaxableFragment *DF, const MCAsmLayout &Layout) const =0
Simple predicate for targets where !Resolved implies requiring relaxation.
virtual bool shouldForceRelocation(const MCAssembler &Asm, const MCFixup &Fixup, const MCValue &Target)
Hook to check if a relocation is needed for some target specific reason.
virtual std::unique_ptr< MCObjectTargetWriter > createObjectTargetWriter() const =0
virtual unsigned getNumFixupKinds() const =0
Get the number of target specific fixup kinds.
virtual const MCFixupKindInfo & getFixupKindInfo(MCFixupKind Kind) const
Get information on a fixup kind.
virtual std::optional< MCFixupKind > getFixupKind(StringRef Name) const
Map a relocation name used in .reloc to a fixup kind.
virtual void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup, const MCValue &Target, MutableArrayRef< char > Data, uint64_t Value, bool IsResolved, const MCSubtargetInfo *STI) const =0
Apply the Value for given Fixup into the provided data fragment, at the offset specified by the fixup...
Encapsulates the layout of an assembly file at a particular point in time.
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...
A relaxable fragment holds on to its MCInst, since it may need to be relaxed during the assembler lay...
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...
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.
OSType getOS() const
Get the parsed operating system type of this triple.
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.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
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.
MCAsmBackend * createSystemZMCAsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options)
std::unique_ptr< MCObjectTargetWriter > createSystemZObjectWriter(uint8_t OSABI)
MCFixupKind
Extensible enumeration to represent the type of a fixup.
@ FirstLiteralRelocationKind
The range [FirstLiteralRelocationKind, MaxTargetFixupKind) is used for relocations coming from ....
int64_t minIntN(int64_t N)
Gets the minimum value for a N-bit signed integer.
uint64_t maxUIntN(uint64_t N)
Gets the maximum value for a N-bit unsigned 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...