13#ifndef LLVM_EXECUTIONENGINE_JITLINK_MIPS_H
14#define LLVM_EXECUTIONENGINE_JITLINK_MIPS_H
206 char *
Fixup =
B.getAlreadyMutableContent().data() +
E.getOffset();
208 uint64_t S =
E.getTarget().getAddress().getValue();
209 int64_t
A =
E.getAddend();
217 "MIPS DTPREL relocation requires a TLS template");
219 auto CheckSigned = [&](int64_t V,
unsigned Bits) ->
Error {
224 auto CheckAligned = [&](int64_t V,
unsigned Align) ->
Error {
230 int64_t V =
static_cast<int64_t
>(TargetAddress);
231 std::optional<uint64_t> GP;
233 assert(GPSymbol &&
"missing MIPS GP symbol");
237 switch (
E.getKind()) {
239 if (TargetAddress > UINT32_MAX)
249 if (Page > UINT32_MAX)
259 V =
static_cast<int64_t
>(TargetAddress -
P);
260 if (
auto Err = CheckSigned(V, 32))
268 V =
static_cast<int64_t
>(
P - S +
A);
269 if (
auto Err = CheckSigned(V, 32))
274 if (
auto Err = CheckSigned(V, 16))
306 V =
static_cast<int64_t
>(TargetAddress - FixupPC);
307 if (
auto Err = CheckAligned(V, 1U << Encoding.
Shift))
309 if (
auto Err = CheckSigned(V, Encoding.
Bits + Encoding.
Shift))
317 V =
static_cast<int64_t
>(TargetAddress -
P);
324 V =
static_cast<int64_t
>(*GP +
A -
P);
333 V =
static_cast<int64_t
>(S +
A - *GP);
334 if (
auto Err = CheckSigned(V, 16))
339 V =
static_cast<int64_t
>(S +
A - *GP);
340 if (
auto Err = CheckSigned(V, 32))
348 V =
static_cast<int64_t
>(S +
A - *GP);
363 auto BaseOrErr = TLSBaseAddr();
365 return BaseOrErr.takeError();
366 V =
static_cast<int64_t
>(S +
A - *BaseOrErr);
372 if (
auto Err = CheckSigned(V, 32))
381 V =
static_cast<int64_t
>(*GP - S -
A);
389 "In graph " +
G.getName() +
", section " +
B.getSection().getName() +
390 ": unsupported MIPS edge kind " +
G.getEdgeKindName(
E.getKind()));
400 Symbol *InitialTarget =
nullptr,
401 Edge::AddendT InitialAddend = 0);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
PowerPC TLS Dynamic Call Fixup
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
LLVM Value Representation.
An Addressable with content and edges.
Represents fixups and constraints in the LinkGraph.
Represents an object file section.
orc::ExecutorAddr getAddress() const
Returns the address of this symbol.
Represents an address in the executor process.
uint64_t getValue() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
EdgeKind_mips
MIPS fixup and table-request edge kinds.
@ RequestGOTAndTransformToOffsetHi16
Create an exact-address GOT entry and rewrite to its high/low GP offset.
@ Higher16
Fixup[15:0] <- (Target + Addend + 0x80008000) >> 32.
@ RequestGOTAndTransformToOffsetLo16
@ Lo16
Fixup[15:0] <- Target + Addend.
@ Jump26
J/JAL target. The target must be aligned and in the same 256-MiB region.
@ RequestTLSGDAndTransformToOffset16
Create a two-word general/local-dynamic TLS descriptor.
@ DTPRelHi16
Fixup <- Target + Addend - start-of-ORC-TLS-template.
@ Delta32
Fixup <- Target - Fixup + Addend : int32.
@ Abs16
Fixup[15:0] <- Target + Addend : int16.
@ PCHi16
Paired PC-relative high and low halves.
@ PC32
Fixup <- Target - Fixup + Addend : int32.
@ GPRel16
Fixup <- Target + Addend - _gp.
@ Highest16
Fixup[15:0] <- (Target + Addend + 0x800080008000) >> 48.
@ Pointer64
Fixup <- Target + Addend : uint64.
@ GOTPageOffset16
Low offset complementary to a rounded 64-KiB GOT page entry.
@ RequestGOTAndTransformToOffset16
Create an exact-address GOT entry and rewrite to GOTOffset16.
@ RequestTLSLDMAndTransformToOffset16
@ Pointer32
Fixup <- Target + Addend, checked as an unsigned 32-bit pointer.
@ NegGPRelHi16
Compound N32/N64 neg(gp_rel(Target + Addend)) fixups.
@ Delta64
Fixup <- Target - Fixup + Addend : int64.
@ PC18S3
Release-6 compact branch immediate fields.
@ PC16
Fixup[15:0] <- (Target - Fixup + Addend) >> 2 : int16.
@ PagePointer32
Pointer containing the rounded 64-KiB page of Target + Addend.
@ NegDelta32
Fixup <- Fixup - Target + Addend : int32 (used by .eh_frame).
@ GOTOffset16
Fixup <- address of GOT entry - _gp.
@ RequestGOTPageAndTransformToOffset16
Create a rounded 64-KiB page GOT entry and rewrite to GOTOffset16.
@ Hi16
Fixup[15:0] <- (Target + Addend + 0x8000) >> 16.
@ GPDispHi16
_gp_disp high/low expressions. The O32 low half uses Fixup - 4 as P.
constexpr uint64_t GOTPageMask
bool needsGP(Edge::Kind K)
void writeMaskedInstruction32(char *Fixup, uint32_t Mask, uint32_t Value, endianness Endianness)
uint16_t getLo16(uint64_t Value)
LLVM_ABI Symbol & createAnonymousPointer(LinkGraph &G, Section &PointerSection, Symbol *InitialTarget=nullptr, Edge::AddendT InitialAddend=0)
Creates an anonymous pointer, optionally initialized to InitialTarget.
LLVM_ABI Edge::Kind getPointerEdgeKind(const LinkGraph &G)
Returns Pointer32 or Pointer64, according to G's pointer ABI.
LLVM_ABI Symbol & createAnonymousPointerJumpStub(LinkGraph &G, Section &StubSection, Symbol &PointerSymbol)
Creates a stub that materializes PointerSymbol, loads its value into $t9, and jumps to $t9.
constexpr uint64_t JumpRegionMask
constexpr unsigned GOTPageBits
uint16_t getHighest16(uint64_t Value)
void writeImmediate26(char *Fixup, uint32_t Value, endianness Endianness)
LLVM_ABI const char * getEdgeKindName(Edge::Kind K)
constexpr uint64_t GOTPageBias
void writeImmediate16(char *Fixup, uint16_t Value, endianness Endianness)
uint64_t getGOTPage(uint64_t Value)
uint16_t getHi16(uint64_t Value)
constexpr uint64_t GOTPageSize
constexpr uint32_t InstructionImm26Mask
constexpr unsigned InstructionSize
constexpr uint32_t InstructionImm16Mask
constexpr unsigned JumpRegionBits
LLVM_ABI ArrayRef< char > getPointerBlockContent(const LinkGraph &G)
Returns zero-filled pointer contents in the graph's pointer width.
LLVM_ABI bool isR6(const LinkGraph &G)
Returns true if G uses the MIPS release-6 ISA.
Error applyFixup(LinkGraph &G, Block &B, const Edge &E, const Symbol *GPSymbol, const Symbol *TLSBaseSymbol)
Apply fixup expression for edge to block content.
PCRelEncoding getPCRelEncoding(Edge::Kind Kind)
uint16_t getHigher16(uint64_t Value)
LLVM_ABI Error makeTargetOutOfRangeError(const LinkGraph &G, const Block &B, const Edge &E)
Create an out of range error for the given edge in the given block.
LLVM_ABI Error makeAlignmentError(llvm::orc::ExecutorAddr Loc, uint64_t Value, int N, const Edge &E)
uint32_t read32(const void *P, endianness E)
void write32(void *P, uint32_t V, endianness E)
void write16(void *P, uint16_t V, endianness E)
void write64(void *P, uint64_t V, endianness E)
This is an optimization pass for GlobalISel generic memory operations.
constexpr T alignDown(U Value, V Align, W Skew=0)
Returns the largest unsigned integer less than or equal to Value and is Skew mod Align.
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
constexpr bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
constexpr T maskTrailingOnes(unsigned N)
Create a bitmask with the N right-most bits set to 1, and all other bits set to 0.
This struct is a compact representation of a valid (non-zero power of two) alignment.