LLVM 22.0.0git
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 , Branch16PCRel , Branch21PCRel ,
  Branch26PCRel , Delta32 , NegDelta32 , Delta64 ,
  Page20 , PageOffset12 , RequestGOTAndTransformToPage20 , RequestGOTAndTransformToPageOffset12 ,
  Call36PCRel , Add6 , Add8 , Add16 ,
  Add32 , Add64 , AddUleb128 , Sub6 ,
  Sub8 , Sub16 , Sub32 , Sub64 ,
  SubUleb128 , AlignRelaxable
}
 Represents loongarch fixups. More...

Functions

LLVM_ABI 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

LLVM_ABI const char NullPointerContent [8]
 loongarch null pointer content.
constexpr size_t StubEntrySize = 12
 loongarch stub content.
LLVM_ABI const uint8_t LA64StubContent [StubEntrySize]
LLVM_ABI 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.
Branch16PCRel 

A 16-bit PC-relative branch.

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

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

Notes: The '16' 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 18-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 int16 otherwise an out-of-range error will be returned.
Branch21PCRel 

A 21-bit PC-relative branch.

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

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

Notes: The '21' 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 23-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 int21 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.
Add6 

low 6 bits label addition

Fixup expression: Fixup <- (*{1}Fixup + (Target + Addend) & 0x3f) : int8

Add8 

8 bits label addition

Fixup expression: Fixup <- (*{1}Fixup + Target + Addend) : int8

Add16 

16 bits label addition

Fixup expression: Fixup <- (*{2}Fixup + Target + Addend) : int16

Add32 

32 bits label addition

Fixup expression: Fixup <- (*{4}Fixup + Target + Addend) : int32

Add64 

64 bits label addition

Fixup expression: Fixup <- (*{8}Fixup + Target + Addend) : int64

AddUleb128 

ULEB128 bits label addition.

Fixup expression: Fixup <- (Fixup + Target + Addend) : uleb128

Sub6 

low 6 bits label subtraction

Fixup expression: Fixup <- (*{1}Fixup - (Target + Addend) & 0x3f) : int8

Sub8 

8 bits label subtraction

Fixup expression: Fixup <- (*{1}Fixup - Target - Addend) : int8

Sub16 

16 bits label subtraction

Fixup expression: Fixup <- (*{2}Fixup - Target - Addend) : int16

Sub32 

32 bits label subtraction

Fixup expression: Fixup <- (*{4}Fixup - Target - Addend) : int32

Sub64 

64 bits label subtraction

Fixup expression: Fixup <- (*{8}Fixup - Target - Addend) : int64

SubUleb128 

ULEB128 bits label subtraction.

Fixup expression: Fixup <- (Fixup - Target - Addend) : uleb128

AlignRelaxable 

Alignment requirement used by linker relaxation.

Linker relaxation will use this to ensure all code sequences are properly aligned and then remove these edges from the graph.

Definition at line 28 of file loongarch.h.

Function Documentation

◆ applyFixup()

◆ 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 597 of file loongarch.h.

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

Referenced by llvm::jitlink::loongarch::GOTTableManager::createEntry(), and llvm::jitlink::getAnonymousPointerCreator().

◆ 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 610 of file loongarch.h.

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

Referenced by llvm::jitlink::loongarch::PLTTableManager::createEntry(), and llvm::jitlink::getPointerJumpStubCreator().

◆ extractBits()

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

Definition at line 329 of file loongarch.h.

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

Referenced by applyFixup().

◆ getEdgeKindName()

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

◆ getGOTEntryBlockContent()

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

Definition at line 567 of file loongarch.h.

References G, and NullPointerContent.

Referenced by createAnonymousPointer().

◆ getStubBlockContent()

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

Definition at line 582 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

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 579 of file loongarch.h.

Referenced by createAnonymousPointerJumpStub(), and getStubBlockContent().