xref: /freebsd/contrib/llvm-project/llvm/lib/ExecutionEngine/JITLink/aarch64.cpp (revision bdd1243df58e60e85101c09001d9812a789b6bc4)
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 
21*bdd1243dSDimitry Andric const char NullPointerContent[8] = {0x00, 0x00, 0x00, 0x00,
2281ad6265SDimitry Andric                                     0x00, 0x00, 0x00, 0x00};
2381ad6265SDimitry Andric 
24*bdd1243dSDimitry Andric const char PointerJumpStubContent[12] = {
25*bdd1243dSDimitry Andric     0x10, 0x00, 0x00, (char)0x90u, // ADRP x16, <imm>@page21
26*bdd1243dSDimitry Andric     0x10, 0x02, 0x40, (char)0xf9u, // LDR x16, [x16, <imm>@pageoff12]
27*bdd1243dSDimitry Andric     0x00, 0x02, 0x1f, (char)0xd6u  // BR  x16
2881ad6265SDimitry Andric };
2981ad6265SDimitry Andric 
3081ad6265SDimitry Andric const char *getEdgeKindName(Edge::Kind R) {
3181ad6265SDimitry Andric   switch (R) {
3281ad6265SDimitry Andric   case Pointer64:
3381ad6265SDimitry Andric     return "Pointer64";
34*bdd1243dSDimitry Andric   case Pointer32:
35*bdd1243dSDimitry Andric     return "Pointer32";
36*bdd1243dSDimitry Andric   case Delta64:
37*bdd1243dSDimitry Andric     return "Delta64";
38*bdd1243dSDimitry Andric   case Delta32:
39*bdd1243dSDimitry Andric     return "Delta32";
40*bdd1243dSDimitry Andric   case NegDelta64:
41*bdd1243dSDimitry Andric     return "NegDelta64";
42*bdd1243dSDimitry Andric   case NegDelta32:
43*bdd1243dSDimitry Andric     return "NegDelta32";
44*bdd1243dSDimitry Andric   case Branch26PCRel:
45*bdd1243dSDimitry Andric     return "Branch26PCRel";
46*bdd1243dSDimitry Andric   case MoveWide16:
47*bdd1243dSDimitry Andric     return "MoveWide16";
48*bdd1243dSDimitry Andric   case LDRLiteral19:
49*bdd1243dSDimitry Andric     return "LDRLiteral19";
5081ad6265SDimitry Andric   case Page21:
5181ad6265SDimitry Andric     return "Page21";
5281ad6265SDimitry Andric   case PageOffset12:
5381ad6265SDimitry Andric     return "PageOffset12";
54*bdd1243dSDimitry Andric   case RequestGOTAndTransformToPage21:
55*bdd1243dSDimitry Andric     return "RequestGOTAndTransformToPage21";
56*bdd1243dSDimitry Andric   case RequestGOTAndTransformToPageOffset12:
57*bdd1243dSDimitry Andric     return "RequestGOTAndTransformToPageOffset12";
58*bdd1243dSDimitry Andric   case RequestGOTAndTransformToDelta32:
59*bdd1243dSDimitry Andric     return "RequestGOTAndTransformToDelta32";
60*bdd1243dSDimitry Andric   case RequestTLVPAndTransformToPage21:
61*bdd1243dSDimitry Andric     return "RequestTLVPAndTransformToPage21";
62*bdd1243dSDimitry Andric   case RequestTLVPAndTransformToPageOffset12:
63*bdd1243dSDimitry Andric     return "RequestTLVPAndTransformToPageOffset12";
64*bdd1243dSDimitry Andric   case RequestTLSDescEntryAndTransformToPage21:
65*bdd1243dSDimitry Andric     return "RequestTLSDescEntryAndTransformToPage21";
66*bdd1243dSDimitry Andric   case RequestTLSDescEntryAndTransformToPageOffset12:
67*bdd1243dSDimitry Andric     return "RequestTLSDescEntryAndTransformToPageOffset12";
6881ad6265SDimitry Andric   default:
6981ad6265SDimitry Andric     return getGenericEdgeKindName(static_cast<Edge::Kind>(R));
70349cc55cSDimitry Andric   }
71349cc55cSDimitry Andric }
7281ad6265SDimitry Andric 
73349cc55cSDimitry Andric } // namespace aarch64
74349cc55cSDimitry Andric } // namespace jitlink
75349cc55cSDimitry Andric } // namespace llvm
76