1 //===----- ppc64.cpp - Generic JITLink ppc64 edge kinds, utilities ------===// 2 // 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 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // Generic utilities for graphs representing 64-bit PowerPC objects. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #include "llvm/ExecutionEngine/JITLink/ppc64.h" 14 15 #define DEBUG_TYPE "jitlink" 16 17 namespace llvm::jitlink::ppc64 { 18 19 const char NullPointerContent[8] = {0x00, 0x00, 0x00, 0x00, 20 0x00, 0x00, 0x00, 0x00}; 21 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 28 }; 29 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 36 }; 37 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 48 }; 49 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 59 }; 60 61 const char *getEdgeKindName(Edge::Kind K) { 62 switch (K) { 63 case Pointer64: 64 return "Pointer64"; 65 case Pointer32: 66 return "Pointer32"; 67 case Delta64: 68 return "Delta64"; 69 case Delta32: 70 return "Delta32"; 71 case NegDelta32: 72 return "NegDelta32"; 73 case Delta16: 74 return "Delta16"; 75 case Delta16HA: 76 return "Delta16HA"; 77 case Delta16LO: 78 return "Delta16LO"; 79 case TOCDelta16HA: 80 return "TOCDelta16HA"; 81 case TOCDelta16LO: 82 return "TOCDelta16LO"; 83 case TOCDelta16DS: 84 return "TOCDelta16DS"; 85 case TOCDelta16LODS: 86 return "TOCDelta16LODS"; 87 case CallBranchDelta: 88 return "CallBranchDelta"; 89 case CallBranchDeltaRestoreTOC: 90 return "CallBranchDeltaRestoreTOC"; 91 case RequestPLTCallStub: 92 return "RequestPLTCallStub"; 93 case RequestPLTCallStubSaveTOC: 94 return "RequestPLTCallStubSaveTOC"; 95 case RequestPLTCallStubNoTOC: 96 return "RequestPLTCallStubNoTOC"; 97 default: 98 return getGenericEdgeKindName(static_cast<Edge::Kind>(K)); 99 } 100 } 101 102 } // end namespace llvm::jitlink::ppc64 103