//=== aarch64.h - Generic JITLink aarch64 edge kinds, utilities -*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // Generic utilities for graphs representing aarch64 objects. // //===----------------------------------------------------------------------===// #ifndef LLVM_EXECUTIONENGINE_JITLINK_AARCH64_H #define LLVM_EXECUTIONENGINE_JITLINK_AARCH64_H #include "TableManager.h" #include "llvm/ExecutionEngine/JITLink/JITLink.h" #include "llvm/ExecutionEngine/Orc/Shared/MemoryFlags.h" namespace llvm { namespace jitlink { namespace aarch64 { /// Represents aarch64 fixups and other aarch64-specific edge kinds. enum EdgeKind_aarch64 : Edge::Kind { … }; /// Returns a string name for the given aarch64 edge. For debugging purposes /// only const char *getEdgeKindName(Edge::Kind K); // Returns whether the Instr is LD/ST (imm12) inline bool isLoadStoreImm12(uint32_t Instr) { … } inline bool isTestAndBranchImm14(uint32_t Instr) { … } inline bool isCondBranchImm19(uint32_t Instr) { … } inline bool isCompAndBranchImm19(uint32_t Instr) { … } inline bool isADR(uint32_t Instr) { … } inline bool isLDRLiteral(uint32_t Instr) { … } // Returns the amount the address operand of LD/ST (imm12) // should be shifted right by. // // The shift value varies by the data size of LD/ST instruction. // For instance, LDH instructoin needs the address to be shifted // right by 1. inline unsigned getPageOffset12Shift(uint32_t Instr) { … } // Returns whether the Instr is MOVK/MOVZ (imm16) with a zero immediate field inline bool isMoveWideImm16(uint32_t Instr) { … } // Returns the amount the address operand of MOVK/MOVZ (imm16) // should be shifted right by. // // The shift value is specfied in the assembly as LSL #<shift>. inline unsigned getMoveWide16Shift(uint32_t Instr) { … } /// Apply fixup expression for edge to block content. inline Error applyFixup(LinkGraph &G, Block &B, const Edge &E, const Symbol *GOTSymbol) { … } /// aarch64 pointer size. constexpr uint64_t PointerSize = …; /// AArch64 null pointer content. extern const char NullPointerContent[PointerSize]; /// AArch64 pointer jump stub content. /// /// Contains the instruction sequence for an indirect jump via an in-memory /// pointer: /// ADRP x16, ptr@page21 /// LDR x16, [x16, ptr@pageoff12] /// BR x16 extern const char PointerJumpStubContent[12]; /// 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: 64-bit /// alignment-offset: 0 /// address: highest allowable (~7U) inline Symbol &createAnonymousPointer(LinkGraph &G, Section &PointerSection, Symbol *InitialTarget = nullptr, uint64_t InitialAddend = 0) { … } /// Create a jump stub block that jumps via the pointer at the given symbol. /// /// The stub block will have the following default values: /// alignment: 32-bit /// alignment-offset: 0 /// address: highest allowable: (~11U) inline Block &createPointerJumpStubBlock(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. Return the anonymous symbol. /// /// The stub block will be created by createPointerJumpStubBlock. inline Symbol &createAnonymousPointerJumpStub(LinkGraph &G, Section &StubSection, Symbol &PointerSymbol) { … } /// Global Offset Table Builder. class GOTTableManager : public TableManager<GOTTableManager> { … }; /// Procedure Linkage Table Builder. class PLTTableManager : public TableManager<PLTTableManager> { … }; } // namespace aarch64 } // namespace jitlink } // namespace llvm #endif // LLVM_EXECUTIONENGINE_JITLINK_AARCH64_H