xref: /freebsd/contrib/llvm-project/llvm/lib/ExecutionEngine/JITLink/aarch64.cpp (revision 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e)
1349cc55cSDimitry Andric //===---- aarch64.cpp - Generic JITLink aarch64 edge kinds, utilities -----===//
2349cc55cSDimitry Andric //
3349cc55cSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4349cc55cSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5349cc55cSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6349cc55cSDimitry Andric //
7349cc55cSDimitry Andric //===----------------------------------------------------------------------===//
8349cc55cSDimitry Andric //
9349cc55cSDimitry Andric // Generic utilities for graphs representing aarch64 objects.
10349cc55cSDimitry Andric //
11349cc55cSDimitry Andric //===----------------------------------------------------------------------===//
12349cc55cSDimitry Andric 
13349cc55cSDimitry Andric #include "llvm/ExecutionEngine/JITLink/aarch64.h"
14349cc55cSDimitry Andric 
15349cc55cSDimitry Andric #define DEBUG_TYPE "jitlink"
16349cc55cSDimitry Andric 
17349cc55cSDimitry Andric namespace llvm {
18349cc55cSDimitry Andric namespace jitlink {
19349cc55cSDimitry Andric namespace aarch64 {
20349cc55cSDimitry Andric 
21bdd1243dSDimitry Andric const char NullPointerContent[8] = {0x00, 0x00, 0x00, 0x00,
2281ad6265SDimitry Andric                                     0x00, 0x00, 0x00, 0x00};
2381ad6265SDimitry Andric 
24bdd1243dSDimitry Andric const char PointerJumpStubContent[12] = {
25bdd1243dSDimitry Andric     0x10, 0x00, 0x00, (char)0x90u, // ADRP x16, <imm>@page21
26bdd1243dSDimitry Andric     0x10, 0x02, 0x40, (char)0xf9u, // LDR x16, [x16, <imm>@pageoff12]
27bdd1243dSDimitry Andric     0x00, 0x02, 0x1f, (char)0xd6u  // BR  x16
2881ad6265SDimitry Andric };
2981ad6265SDimitry Andric 
getEdgeKindName(Edge::Kind R)3081ad6265SDimitry Andric const char *getEdgeKindName(Edge::Kind R) {
3181ad6265SDimitry Andric   switch (R) {
3281ad6265SDimitry Andric   case Pointer64:
3381ad6265SDimitry Andric     return "Pointer64";
34bdd1243dSDimitry Andric   case Pointer32:
35bdd1243dSDimitry Andric     return "Pointer32";
36bdd1243dSDimitry Andric   case Delta64:
37bdd1243dSDimitry Andric     return "Delta64";
38bdd1243dSDimitry Andric   case Delta32:
39bdd1243dSDimitry Andric     return "Delta32";
40bdd1243dSDimitry Andric   case NegDelta64:
41bdd1243dSDimitry Andric     return "NegDelta64";
42bdd1243dSDimitry Andric   case NegDelta32:
43bdd1243dSDimitry Andric     return "NegDelta32";
44bdd1243dSDimitry Andric   case Branch26PCRel:
45bdd1243dSDimitry Andric     return "Branch26PCRel";
46bdd1243dSDimitry Andric   case MoveWide16:
47bdd1243dSDimitry Andric     return "MoveWide16";
48bdd1243dSDimitry Andric   case LDRLiteral19:
49bdd1243dSDimitry Andric     return "LDRLiteral19";
50*06c3fb27SDimitry Andric   case TestAndBranch14PCRel:
51*06c3fb27SDimitry Andric     return "TestAndBranch14PCRel";
52*06c3fb27SDimitry Andric   case CondBranch19PCRel:
53*06c3fb27SDimitry Andric     return "CondBranch19PCRel";
54*06c3fb27SDimitry Andric   case ADRLiteral21:
55*06c3fb27SDimitry Andric     return "ADRLiteral21";
5681ad6265SDimitry Andric   case Page21:
5781ad6265SDimitry Andric     return "Page21";
5881ad6265SDimitry Andric   case PageOffset12:
5981ad6265SDimitry Andric     return "PageOffset12";
60bdd1243dSDimitry Andric   case RequestGOTAndTransformToPage21:
61bdd1243dSDimitry Andric     return "RequestGOTAndTransformToPage21";
62bdd1243dSDimitry Andric   case RequestGOTAndTransformToPageOffset12:
63bdd1243dSDimitry Andric     return "RequestGOTAndTransformToPageOffset12";
64bdd1243dSDimitry Andric   case RequestGOTAndTransformToDelta32:
65bdd1243dSDimitry Andric     return "RequestGOTAndTransformToDelta32";
66bdd1243dSDimitry Andric   case RequestTLVPAndTransformToPage21:
67bdd1243dSDimitry Andric     return "RequestTLVPAndTransformToPage21";
68bdd1243dSDimitry Andric   case RequestTLVPAndTransformToPageOffset12:
69bdd1243dSDimitry Andric     return "RequestTLVPAndTransformToPageOffset12";
70bdd1243dSDimitry Andric   case RequestTLSDescEntryAndTransformToPage21:
71bdd1243dSDimitry Andric     return "RequestTLSDescEntryAndTransformToPage21";
72bdd1243dSDimitry Andric   case RequestTLSDescEntryAndTransformToPageOffset12:
73bdd1243dSDimitry Andric     return "RequestTLSDescEntryAndTransformToPageOffset12";
7481ad6265SDimitry Andric   default:
7581ad6265SDimitry Andric     return getGenericEdgeKindName(static_cast<Edge::Kind>(R));
76349cc55cSDimitry Andric   }
77349cc55cSDimitry Andric }
7881ad6265SDimitry Andric 
79349cc55cSDimitry Andric } // namespace aarch64
80349cc55cSDimitry Andric } // namespace jitlink
81349cc55cSDimitry Andric } // namespace llvm
82