37 return (
Value >> 2) & 0x3fffffff;
39 case ELF::R_SPARC_WDISP22:
40 return (
Value >> 2) & 0x3fffff;
42 case ELF::R_SPARC_WDISP19:
43 return (
Value >> 2) & 0x7ffff;
45 case ELF::R_SPARC_WDISP16: {
49 unsigned d16hi = (
Value >> 16) & 0x3;
50 unsigned d16lo = (
Value >> 2) & 0x3fff;
51 return (d16hi << 20) | d16lo;
54 case ELF::R_SPARC_WDISP10: {
61 unsigned d10hi = (
Value >> 10) & 0x3;
62 unsigned d10lo = (
Value >> 2) & 0xff;
63 return (d10hi << 19) | (d10lo << 5);
66 case ELF::R_SPARC_HIX22:
67 return (~
Value >> 10) & 0x3fffff;
71 case ELF::R_SPARC_PC22:
72 case ELF::R_SPARC_HI22:
73 case ELF::R_SPARC_GOT22:
74 case ELF::R_SPARC_LM22:
75 return (
Value >> 10) & 0x3fffff;
78 return Value & 0x3fffff;
81 return Value & 0x1fff;
95 case ELF::R_SPARC_LOX10:
96 return (
Value & 0x3ff) | 0x1c00;
98 case ELF::R_SPARC_PC10:
99 case ELF::R_SPARC_LO10:
100 case ELF::R_SPARC_GOT10:
101 return Value & 0x3ff;
103 case ELF::R_SPARC_H34:
104 return (
Value >> 12) & 0x3fffff;
105 case ELF::R_SPARC_H44:
106 return (
Value >> 22) & 0x3fffff;
107 case ELF::R_SPARC_M44:
108 return (
Value >> 12) & 0x3ff;
109 case ELF::R_SPARC_L44:
110 return Value & 0xfff;
112 case ELF::R_SPARC_HH22:
113 return (
Value >> 42) & 0x3fffff;
114 case ELF::R_SPARC_HM10:
115 return (
Value >> 32) & 0x3ff;
140 SparcAsmBackend(
const MCSubtargetInfo &STI)
141 : MCAsmBackend(STI.getTargetTriple().isLittleEndian()
144 Is64Bit(STI.getTargetTriple().isArch64Bit()),
145 IsV8Plus(STI.
hasFeature(Sparc::FeatureV8Plus)) {}
147 std::optional<MCFixupKind>
getFixupKind(StringRef Name)
const override;
148 MCFixupKindInfo getFixupKindInfo(
MCFixupKind Kind)
const override;
149 void applyFixup(
const MCFragment &,
const MCFixup &,
const MCValue &Target,
153 const MCSubtargetInfo *STI)
const override {
161 for (
uint64_t i = 0; i != NumNops; ++i)
168class ELFSparcAsmBackend :
public SparcAsmBackend {
172 ELFSparcAsmBackend(
const MCSubtargetInfo &STI,
Triple::OSType OSType)
173 : SparcAsmBackend(STI), OSType(OSType) {}
175 std::unique_ptr<MCObjectTargetWriter>
176 createObjectTargetWriter()
const override {
183std::optional<MCFixupKind> SparcAsmBackend::getFixupKind(
StringRef Name)
const {
185 Type = llvm::StringSwitch<unsigned>(Name)
186#define ELF_RELOC(X, Y) .Case(#X, Y)
187#include "llvm/BinaryFormat/ELFRelocs/Sparc.def"
189 .Case(
"BFD_RELOC_NONE", ELF::R_SPARC_NONE)
190 .Case(
"BFD_RELOC_8", ELF::R_SPARC_8)
191 .Case(
"BFD_RELOC_16", ELF::R_SPARC_16)
192 .Case(
"BFD_RELOC_32", ELF::R_SPARC_32)
193 .Case(
"BFD_RELOC_64", ELF::R_SPARC_64)
200MCFixupKindInfo SparcAsmBackend::getFixupKindInfo(
MCFixupKind Kind)
const {
204 {
"fixup_sparc_call30", 2, 30, 0},
205 {
"fixup_sparc_13", 19, 13, 0},
210 {
"fixup_sparc_call30", 0, 30, 0},
211 {
"fixup_sparc_13", 0, 13, 0},
226 MCFixupKindInfo
Info{};
227 switch (uint16_t(Kind)) {
228 case ELF::R_SPARC_PC10:
229 Info = {
"", 22, 10, 0};
232 Info = {
"", 25, 7, 0};
234 case ELF::R_SPARC_10:
235 Info = {
"", 22, 10, 0};
237 case ELF::R_SPARC_11:
238 Info = {
"", 21, 11, 0};
240 case ELF::R_SPARC_22:
241 Info = {
"", 10, 22, 0};
243 case ELF::R_SPARC_PC22:
244 Info = {
"", 10, 22, 0};
246 case ELF::R_SPARC_WDISP10:
247 Info = {
"", 0, 32, 0};
249 case ELF::R_SPARC_WDISP16:
250 Info = {
"", 0, 32, 0};
252 case ELF::R_SPARC_WDISP19:
253 Info = {
"", 13, 19, 0};
255 case ELF::R_SPARC_WDISP22:
256 Info = {
"", 10, 22, 0};
259 case ELF::R_SPARC_HI22:
260 Info = {
"", 10, 22, 0};
262 case ELF::R_SPARC_LO10:
263 Info = {
"", 22, 10, 0};
265 case ELF::R_SPARC_HH22:
266 Info = {
"", 10, 22, 0};
268 case ELF::R_SPARC_HM10:
269 Info = {
"", 22, 10, 0};
271 case ELF::R_SPARC_LM22:
272 Info = {
"", 10, 22, 0};
274 case ELF::R_SPARC_HIX22:
275 Info = {
"", 10, 22, 0};
277 case ELF::R_SPARC_LOX10:
278 Info = {
"", 19, 13, 0};
282 Info.TargetOffset = 32 -
Info.TargetOffset -
Info.TargetSize;
286void SparcAsmBackend::applyFixup(
const MCFragment &
F,
const MCFixup &Fixup,
287 const MCValue &Target, uint8_t *
Data,
289 maybeAddReloc(
F, Fixup, Target,
Value, IsResolved);
295 switch (
Target.getSpecifier()) {
296 case ELF::R_SPARC_DISP8:
297 case ELF::R_SPARC_DISP16:
298 case ELF::R_SPARC_DISP32:
299 case ELF::R_SPARC_DISP64:
300 case ELF::R_SPARC_PLT32:
301 case ELF::R_SPARC_PLT64:
302 case ELF::R_SPARC_TLS_DTPOFF32:
303 case ELF::R_SPARC_TLS_DTPOFF64:
306 " cannot be applied to a constant");
317 for (
unsigned i = 0; i != NumBytes; ++i) {
static unsigned getFixupKindNumBytes(unsigned Kind)
The number of bytes the fixup may change.
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 bool hasFeature(StringRef Feature, const FeatureBitset &FeatureBits, ArrayRef< SubtargetFeatureKV > ProcFeatures)
MachineRegisterInfo & MRI
Func getContext().diagnose(DiagnosticInfoUnsupported(Func
static unsigned adjustFixupValue(unsigned Kind, uint64_t Value)
static unsigned getFixupKindNumBytes(unsigned Kind)
getFixupKindNumBytes - The number of bytes the fixup may change.
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
Generic interface to target specific assembler backends.
virtual MCFixupKindInfo getFixupKindInfo(MCFixupKind Kind) const
Get information on a fixup kind.
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
Represent a constant reference to a string, i.e.
Target - Wrapper for Target specific information.
OSType getOS() const
Get the parsed operating system type of this triple.
LLVM Value Representation.
raw_ostream & write_zeros(unsigned NumZeros)
write_zeros - Insert 'NumZeros' nulls.
@ fixup_sparc_13
fixup_sparc_13 - 13-bit fixup
StringRef getSpecifierName(uint16_t S)
VE::Fixups getFixupKind(uint8_t S)
Error applyFixup(LinkGraph &G, Block &B, const Edge &E, const ArmConfig &ArmCfg)
Apply fixup expression for edge to block content.
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.
constexpr MCFixupKind FirstTargetFixupKind
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
uint16_t MCFixupKind
Extensible enumeration to represent the type of a fixup.
std::unique_ptr< MCObjectTargetWriter > createSparcELFObjectWriter(bool Is64Bit, bool IsV8Plus, uint8_t OSABI)
@ 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.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
MCAsmBackend * createSparcAsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options)
constexpr MCFixupKind FirstLiteralRelocationKind