LLVM 20.0.0git
Classes | Enumerations | Functions | Variables
llvm::jitlink::loongarch Namespace Reference

Classes

class  GOTTableManager
 Global Offset Table Builder. More...
 
class  PLTTableManager
 Procedure Linkage Table Builder. More...
 

Enumerations

enum  EdgeKind_loongarch : Edge::Kind {
  Pointer64 = Edge::FirstRelocation , Pointer32 , Branch26PCRel , Delta32 ,
  NegDelta32 , Delta64 , Page20 , PageOffset12 ,
  RequestGOTAndTransformToPage20 , RequestGOTAndTransformToPageOffset12 , Call36PCRel
}
 Represents loongarch fixups. More...
 

Functions

const chargetEdgeKindName (Edge::Kind K)
 Returns a string name for the given loongarch edge.
 
uint32_t extractBits (uint64_t Val, unsigned Hi, unsigned Lo)
 
Error applyFixup (LinkGraph &G, Block &B, const Edge &E)
 Apply fixup expression for edge to block content.
 
ArrayRef< chargetGOTEntryBlockContent (LinkGraph &G)
 
ArrayRef< chargetStubBlockContent (LinkGraph &G)
 
SymbolcreateAnonymousPointer (LinkGraph &G, Section &PointerSection, Symbol *InitialTarget=nullptr, uint64_t InitialAddend=0)
 Creates a new pointer block in the given section and returns an Anonymous symbol pointing to it.
 
SymbolcreateAnonymousPointerJumpStub (LinkGraph &G, Section &StubSection, Symbol &PointerSymbol)
 Create a jump stub that jumps via the pointer at the given symbol and an anonymous symbol pointing to it.
 

Variables

const char NullPointerContent [8]
 loongarch null pointer content.
 
constexpr size_t StubEntrySize = 12
 loongarch stub content.
 
const uint8_t LA64StubContent [StubEntrySize]
 
const uint8_t LA32StubContent [StubEntrySize]
 

Enumeration Type Documentation

◆ EdgeKind_loongarch

Represents loongarch fixups.

Enumerator
Pointer64 

A plain 64-bit pointer value relocation.

Fixup expression: Fixup <- Target + Addend : uint64

Pointer32 

A plain 32-bit pointer value relocation.

Fixup expression: Fixup <- Target + Addend : uint32

Errors:

  • The target must reside in the low 32-bits of the address space, otherwise an out-of-range error will be returned.
Branch26PCRel 

A 26-bit PC-relative branch.

Represents a PC-relative call or branch to a target within +/-128Mb. The target must be 4-byte aligned.

Fixup expression: Fixup <- (Target - Fixup + Addend) >> 2 : int26

Notes: The '26' in the name refers to the number operand bits and follows the naming convention used by the corresponding ELF relocations. Since the low two bits must be zero (because of the 4-byte alignment of the target) the operand is effectively a signed 28-bit number.

Errors:

  • The result of the unshifted part of the fixup expression must be 4-byte aligned otherwise an alignment error will be returned.
  • The result of the fixup expression must fit into an int26 otherwise an out-of-range error will be returned.
Delta32 

A 32-bit delta.

Delta from the fixup to the target.

Fixup expression: Fixup <- Target - Fixup + Addend : int32

Errors:

  • The result of the fixup expression must fit into an int32, otherwise an out-of-range error will be returned.
NegDelta32 

A 32-bit negative delta.

Delta from the target back to the fixup.

Fixup expression: Fixup <- Fixup - Target + Addend : int32

Errors:

  • The result of the fixup expression must fit into an int32, otherwise an out-of-range error will be returned.
Delta64 

A 64-bit delta.

Delta from the fixup to the target.

Fixup expression: Fixup <- Target - Fixup + Addend : int64

Page20 

The signed 20-bit delta from the fixup page to the page containing the target.

Fixup expression: Fixup <- (((Target + Addend + ((Target + Addend) & 0x800)) & ~0xfff) Notes: For PCALAU12I fixups.

Errors:

  • The result of the fixup expression must fit into an int20 otherwise an out-of-range error will be returned.
PageOffset12 

The 12-bit offset of the target within its page.

Typically used to fix up ADDI/LD_W/LD_D immediates.

Fixup expression: Fixup <- ((Target + Addend) >> Shift) & 0xfff : int12

RequestGOTAndTransformToPage20 

A GOT entry getter/constructor, transformed to Page20 pointing at the GOT entry for the original target.

Indicates that this edge should be transformed into a Page20 targeting the GOT entry for the edge's current target, maintaining the same addend. A GOT entry for the target should be created if one does not already exist.

Edges of this kind are usually handled by a GOT/PLT builder pass inserted by default.

Fixup expression: NONE

Errors:

  • ASSERTION Failure to handle edges of this kind prior to the fixup phase will result in an assert/unreachable during the fixup phase.
RequestGOTAndTransformToPageOffset12 

A GOT entry getter/constructor, transformed to Pageoffset12 pointing at the GOT entry for the original target.

Indicates that this edge should be transformed into a PageOffset12 targeting the GOT entry for the edge's current target, maintaining the same addend. A GOT entry for the target should be created if one does not already exist.

Edges of this kind are usually handled by a GOT/PLT builder pass inserted by default.

Fixup expression: NONE

Call36PCRel 

A 36-bit PC-relative call.

Represents a PC-relative call to a target within [-128G - 0x20000, +128G

  • 0x20000). The target must be 4-byte aligned. For adjacent pcaddu18i+jirl instruction pairs.

Fixup expression: Fixup <- (Target - Fixup + Addend) >> 2 : int36

Notes: The '36' in the name refers to the number operand bits and follows the naming convention used by the corresponding ELF relocations. Since the low two bits must be zero (because of the 4-byte alignment of the target) the operand is effectively a signed 38-bit number.

Errors:

  • The result of the unshifted part of the fixup expression must be 4-byte aligned otherwise an alignment error will be returned.
  • The result of the fixup expression must fit into an int36 otherwise an out-of-range error will be returned.

Definition at line 25 of file loongarch.h.

Function Documentation

◆ applyFixup()

Error llvm::jitlink::loongarch::applyFixup ( LinkGraph G,
Block B,
const Edge E 
)
inline

◆ createAnonymousPointer()

Symbol & llvm::jitlink::loongarch::createAnonymousPointer ( LinkGraph G,
Section PointerSection,
Symbol InitialTarget = nullptr,
uint64_t  InitialAddend = 0 
)
inline

Creates a new pointer block in the given section and returns an Anonymous symbol pointing to it.

If InitialTarget is given then an Pointer64 relocation will be added to the block pointing at InitialTarget.

The pointer block will have the following default values: alignment: PointerSize alignment-offset: 0

Definition at line 331 of file loongarch.h.

References B, G, getGOTEntryBlockContent(), Pointer32, and Pointer64.

Referenced by llvm::jitlink::loongarch::GOTTableManager::createEntry().

◆ createAnonymousPointerJumpStub()

Symbol & llvm::jitlink::loongarch::createAnonymousPointerJumpStub ( LinkGraph G,
Section StubSection,
Symbol PointerSymbol 
)
inline

Create a jump stub that jumps via the pointer at the given symbol and an anonymous symbol pointing to it.

Return the anonymous symbol.

Definition at line 344 of file loongarch.h.

References llvm::jitlink::Block::addEdge(), G, getStubBlockContent(), Page20, PageOffset12, and StubEntrySize.

Referenced by llvm::jitlink::loongarch::PLTTableManager::createEntry().

◆ extractBits()

uint32_t llvm::jitlink::loongarch::extractBits ( uint64_t  Val,
unsigned  Hi,
unsigned  Lo 
)
inline

Definition at line 191 of file loongarch.h.

References llvm::Hi, and llvm::Lo.

Referenced by applyFixup().

◆ getEdgeKindName()

const char * llvm::jitlink::loongarch::getEdgeKindName ( Edge::Kind  K)

Returns a string name for the given loongarch edge.

For debugging purposes only.

Definition at line 36 of file loongarch.cpp.

References Branch26PCRel, Call36PCRel, Delta32, Delta64, llvm::jitlink::getGenericEdgeKindName(), KIND_NAME_CASE, NegDelta32, Page20, PageOffset12, Pointer32, Pointer64, RequestGOTAndTransformToPage20, and RequestGOTAndTransformToPageOffset12.

Referenced by applyFixup().

◆ getGOTEntryBlockContent()

ArrayRef< char > llvm::jitlink::loongarch::getGOTEntryBlockContent ( LinkGraph G)
inline

Definition at line 301 of file loongarch.h.

References G, and NullPointerContent.

Referenced by createAnonymousPointer().

◆ getStubBlockContent()

ArrayRef< char > llvm::jitlink::loongarch::getStubBlockContent ( LinkGraph G)
inline

Definition at line 316 of file loongarch.h.

References G, LA32StubContent, LA64StubContent, and StubEntrySize.

Referenced by createAnonymousPointerJumpStub().

Variable Documentation

◆ LA32StubContent

const uint8_t llvm::jitlink::loongarch::LA32StubContent
Initial value:
= {
0x14, 0x00, 0x00, 0x1a,
0x94, 0x02, 0x80, 0x28,
0x80, 0x02, 0x00, 0x4c
}

Definition at line 30 of file loongarch.cpp.

Referenced by getStubBlockContent().

◆ LA64StubContent

const uint8_t llvm::jitlink::loongarch::LA64StubContent
Initial value:
= {
0x14, 0x00, 0x00, 0x1a,
0x94, 0x02, 0xc0, 0x28,
0x80, 0x02, 0x00, 0x4c
}

Definition at line 24 of file loongarch.cpp.

Referenced by getStubBlockContent().

◆ NullPointerContent

const char llvm::jitlink::loongarch::NullPointerContent
Initial value:
= {0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00}

loongarch null pointer content.

Definition at line 21 of file loongarch.cpp.

Referenced by getGOTEntryBlockContent().

◆ StubEntrySize

constexpr size_t llvm::jitlink::loongarch::StubEntrySize = 12
constexpr

loongarch stub content.

Contains the instruction sequence for an indirect jump via an in-memory pointer: pcalau12i $t8, page20(ptr) ld.[w/d] $t8, pageoff12(ptr) jr $t8

Definition at line 313 of file loongarch.h.

Referenced by createAnonymousPointerJumpStub(), and getStubBlockContent().