40 return Value & 0xfffc;
44 return Value & 0x3fffffc;
46 return Value & 0xffff;
49 return Value & 0xfffc;
52 return Value & 0x3ffffffff;
89 PPCAsmBackend(
const Target &
T,
const Triple &TT)
94 MCFixupKindInfo getFixupKindInfo(
MCFixupKind Kind)
const override;
97 const MCValue &Target, uint8_t *
Data, uint64_t
Value,
98 bool IsResolved)
override;
103 if (
Target.getSpecifier())
106 switch ((
unsigned)Kind) {
115 if (
const auto *
A =
Target.getAddSym()) {
120 unsigned Other =
static_cast<const MCSymbolELF *
>(
A)->getOther() << 2;
124 auto *S =
static_cast<const MCSymbolXCOFF *
>(
A);
125 return !
Target.isAbsolute() && S->isExternal() &&
133 bool writeNopData(raw_ostream &OS, uint64_t
Count,
134 const MCSubtargetInfo *STI)
const override {
135 uint64_t NumNops =
Count / 4;
136 for (uint64_t i = 0; i != NumNops; ++i)
150 {
"fixup_ppc_br24", 6, 24, 0},
151 {
"fixup_ppc_br24_notoc", 6, 24, 0},
152 {
"fixup_ppc_brcond14", 16, 14, 0},
153 {
"fixup_ppc_br24abs", 6, 24, 0},
154 {
"fixup_ppc_brcond14abs", 16, 14, 0},
155 {
"fixup_ppc_half16", 0, 16, 0},
156 {
"fixup_ppc_half16ds", 0, 14, 0},
157 {
"fixup_ppc_pcrel34", 0, 34, 0},
158 {
"fixup_ppc_imm34", 0, 34, 0},
159 {
"fixup_ppc_nofixup", 0, 0, 0}};
162 {
"fixup_ppc_br24", 2, 24, 0},
163 {
"fixup_ppc_br24_notoc", 2, 24, 0},
164 {
"fixup_ppc_brcond14", 2, 14, 0},
165 {
"fixup_ppc_br24abs", 2, 24, 0},
166 {
"fixup_ppc_brcond14abs", 2, 14, 0},
167 {
"fixup_ppc_half16", 0, 16, 0},
168 {
"fixup_ppc_half16ds", 2, 14, 0},
169 {
"fixup_ppc_pcrel34", 0, 34, 0},
170 {
"fixup_ppc_imm34", 0, 34, 0},
171 {
"fixup_ppc_nofixup", 0, 0, 0}};
189void PPCAsmBackend::applyFixup(
const MCFragment &
F,
const MCFixup &
Fixup,
190 const MCValue &TargetVal, uint8_t *
Data,
191 uint64_t
Value,
bool IsResolved) {
196 Target.setAddSym(
nullptr);
214 for (
unsigned i = 0; i != NumBytes; ++i) {
216 Data[i] |= uint8_t((
Value >> (Idx * 8)) & 0xff);
223class ELFPPCAsmBackend :
public PPCAsmBackend {
225 ELFPPCAsmBackend(
const Target &
T,
const Triple &TT) : PPCAsmBackend(
T,
TT) {}
227 std::unique_ptr<MCObjectTargetWriter>
228 createObjectTargetWriter()
const override {
230 bool Is64 =
TT.isPPC64();
234 std::optional<MCFixupKind>
getFixupKind(StringRef Name)
const override;
237class XCOFFPPCAsmBackend :
public PPCAsmBackend {
239 XCOFFPPCAsmBackend(
const Target &
T,
const Triple &TT)
240 : PPCAsmBackend(
T,
TT) {}
242 std::unique_ptr<MCObjectTargetWriter>
243 createObjectTargetWriter()
const override {
250std::optional<MCFixupKind>
251ELFPPCAsmBackend::getFixupKind(StringRef Name)
const {
252 if (
TT.isOSBinFormatELF()) {
255 Type = llvm::StringSwitch<unsigned>(Name)
256#define ELF_RELOC(X, Y) .Case(#X, Y)
257#include "llvm/BinaryFormat/ELFRelocs/PowerPC64.def"
259 .Case(
"BFD_RELOC_NONE", ELF::R_PPC64_NONE)
260 .Case(
"BFD_RELOC_16", ELF::R_PPC64_ADDR16)
261 .Case(
"BFD_RELOC_32", ELF::R_PPC64_ADDR32)
262 .Case(
"BFD_RELOC_64", ELF::R_PPC64_ADDR64)
265 Type = llvm::StringSwitch<unsigned>(Name)
266#define ELF_RELOC(X, Y) .Case(#X, Y)
267#include "llvm/BinaryFormat/ELFRelocs/PowerPC.def"
269 .Case(
"BFD_RELOC_NONE", ELF::R_PPC_NONE)
270 .Case(
"BFD_RELOC_16", ELF::R_PPC_ADDR16)
271 .Case(
"BFD_RELOC_32", ELF::R_PPC_ADDR32)
285 if (TT.isOSBinFormatXCOFF())
286 return new XCOFFPPCAsmBackend(
T, TT);
288 return new ELFPPCAsmBackend(
T, TT);
unsigned const MachineRegisterInfo * MRI
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)
static bool shouldForceRelocation(const MCFixup &Fixup)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static uint64_t adjustFixupValue(unsigned Kind, uint64_t Value)
static unsigned getFixupKindNumBytes(unsigned Kind)
PowerPC TLS Dynamic Call Fixup
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
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
LLVM Value Representation.
raw_ostream & write_zeros(unsigned NumZeros)
write_zeros - Insert 'NumZeros' nulls.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ fixup_ppc_brcond14abs
14-bit absolute relocation for conditional branches.
@ fixup_ppc_half16
A 16-bit fixup corresponding to lo16(_foo) or ha16(_foo) for instrs like 'li' or 'addis'.
@ fixup_ppc_brcond14
14-bit PC relative relocation for conditional branches.
@ fixup_ppc_half16dq
A 16-bit fixup corresponding to lo16(_foo) with implied 3 zero bits for instrs like 'lxv'.
@ fixup_ppc_half16ds
A 14-bit fixup corresponding to lo16(_foo) with implied 2 zero bits for instrs like 'std'.
@ fixup_ppc_nofixup
Not a true fixup, but ties a symbol to a call to __tls_get_addr for the TLS general and local dynamic...
@ fixup_ppc_br24abs
24-bit absolute relocation for direct branches like 'ba' and 'bla'.
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)
Context & getContext() const
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.
FunctionAddr VTableAddr Value
MCAsmBackend * createPPCAsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options)
uint16_t MCFixupKind
Extensible enumeration to represent the type of a fixup.
std::unique_ptr< MCObjectTargetWriter > createPPCXCOFFObjectWriter(bool Is64Bit)
Construct a PPC XCOFF object writer.
FunctionAddr VTableAddr Count
@ FirstLiteralRelocationKind
@ 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.
FunctionAddr VTableAddr uintptr_t uintptr_t Data
std::unique_ptr< MCObjectTargetWriter > createPPCELFObjectWriter(bool Is64Bit, uint8_t OSABI)
Construct an PPC ELF object writer.
Target independent information on a fixup kind.