1 //===----- ppc64.cpp - Generic JITLink ppc64 edge kinds, utilities ------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // Generic utilities for graphs representing 64-bit PowerPC objects.
11 //===----------------------------------------------------------------------===//
13 #include "llvm/ExecutionEngine/JITLink/ppc64.h"
15 #define DEBUG_TYPE "jitlink"
17 namespace llvm::jitlink::ppc64
{
19 const char NullPointerContent
[8] = {0x00, 0x00, 0x00, 0x00,
20 0x00, 0x00, 0x00, 0x00};
22 const char PointerJumpStubContent_little
[20] = {
23 0x18, 0x00, 0x41, (char)0xf8, // std r2, 24(r1)
24 0x00, 0x00, (char)0x82, 0x3d, // addis r12, r2, OffHa
25 0x00, 0x00, (char)0x8c, (char)0xe9, // ld r12, OffLo(r12)
26 (char)0xa6, 0x03, (char)0x89, 0x7d, // mtctr r12
27 0x20, 0x04, (char)0x80, 0x4e, // bctr
30 const char PointerJumpStubContent_big
[20] = {
31 (char)0xf8, 0x41, 0x00, 0x18, // std r2, 24(r1)
32 0x3d, (char)0x82, 0x00, 0x00, // addis r12, r2, OffHa
33 (char)0xe9, (char)0x8c, 0x00, 0x00, // ld r12, OffLo(r12)
34 0x7d, (char)0x89, 0x03, (char)0xa6, // mtctr r12
35 0x4e, (char)0x80, 0x04, 0x20, // bctr
38 // TODO: We can use prefixed instructions if LLJIT is running on power10.
39 const char PointerJumpStubNoTOCContent_little
[32] = {
40 (char)0xa6, 0x02, (char)0x88, 0x7d, // mflr 12
41 0x05, (char)0x00, (char)0x9f, 0x42, // bcl 20,31,.+4
42 (char)0xa6, 0x02, 0x68, 0x7d, // mflr 11
43 (char)0xa6, 0x03, (char)0x88, 0x7d, // mtlr 12
44 0x00, 0x00, (char)0x8b, 0x3d, // addis 12,11,OffHa
45 0x00, 0x00, (char)0x8c, (char)0xe9, // ld 12, OffLo(12)
46 (char)0xa6, 0x03, (char)0x89, 0x7d, // mtctr 12
47 0x20, 0x04, (char)0x80, 0x4e, // bctr
50 const char PointerJumpStubNoTOCContent_big
[32] = {
51 0x7d, (char)0x88, 0x02, (char)0xa6, // mflr 12
52 0x42, (char)0x9f, 0x00, 0x05, // bcl 20,31,.+4
53 0x7d, 0x68, 0x02, (char)0xa6, // mflr 11
54 0x7d, (char)0x88, 0x03, (char)0xa6, // mtlr 12
55 0x3d, (char)0x8b, 0x00, 0x00, // addis 12,11,OffHa
56 (char)0xe9, (char)0x8c, 0x00, 0x00, // ld 12, OffLo(12)
57 0x7d, (char)0x89, 0x03, (char)0xa6, // mtctr 12
58 0x4e, (char)0x80, 0x04, 0x20, // bctr
61 const char *getEdgeKindName(Edge::Kind K
) {
76 return "Pointer16HIGH";
78 return "Pointer16HIGHA";
80 return "Pointer16HIGHER";
81 case Pointer16HIGHERA
:
82 return "Pointer16HIGHERA";
83 case Pointer16HIGHEST
:
84 return "Pointer16HIGHEST";
85 case Pointer16HIGHESTA
:
86 return "Pointer16HIGHESTA";
90 return "Pointer16LODS";
114 return "TOCDelta16DS";
116 return "TOCDelta16HA";
118 return "TOCDelta16HI";
120 return "TOCDelta16LO";
122 return "TOCDelta16LODS";
123 case RequestGOTAndTransformToDelta34
:
124 return "RequestGOTAndTransformToDelta34";
125 case CallBranchDelta
:
126 return "CallBranchDelta";
127 case CallBranchDeltaRestoreTOC
:
128 return "CallBranchDeltaRestoreTOC";
130 return "RequestCall";
131 case RequestCallNoTOC
:
132 return "RequestCallNoTOC";
133 case RequestTLSDescInGOTAndTransformToTOCDelta16HA
:
134 return "RequestTLSDescInGOTAndTransformToTOCDelta16HA";
135 case RequestTLSDescInGOTAndTransformToTOCDelta16LO
:
136 return "RequestTLSDescInGOTAndTransformToTOCDelta16LO";
137 case RequestTLSDescInGOTAndTransformToDelta34
:
138 return "RequestTLSDescInGOTAndTransformToDelta34";
140 return getGenericEdgeKindName(static_cast<Edge::Kind
>(K
));
144 } // end namespace llvm::jitlink::ppc64