1 //===--- loongarch.cpp - Generic JITLink loongarch 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 loongarch objects. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #include "llvm/ExecutionEngine/JITLink/loongarch.h" 14 15 #define DEBUG_TYPE "jitlink" 16 17 namespace llvm { 18 namespace jitlink { 19 namespace loongarch { 20 21 const char NullPointerContent[8] = {0x00, 0x00, 0x00, 0x00, 22 0x00, 0x00, 0x00, 0x00}; 23 24 const uint8_t LA64StubContent[StubEntrySize] = { 25 0x14, 0x00, 0x00, 0x1a, // pcalau12i $t8, %page20(imm) 26 0x94, 0x02, 0xc0, 0x28, // ld.d $t8, $t8, %pageoff12(imm) 27 0x80, 0x02, 0x00, 0x4c // jr $t8 28 }; 29 30 const uint8_t LA32StubContent[StubEntrySize] = { 31 0x14, 0x00, 0x00, 0x1a, // pcalau12i $t8, %page20(imm) 32 0x94, 0x02, 0x80, 0x28, // ld.w $t8, $t8, %pageoff12(imm) 33 0x80, 0x02, 0x00, 0x4c // jr $t8 34 }; 35 36 const char *getEdgeKindName(Edge::Kind K) { 37 #define KIND_NAME_CASE(K) \ 38 case K: \ 39 return #K; 40 41 switch (K) { 42 KIND_NAME_CASE(Pointer64) 43 KIND_NAME_CASE(Pointer32) 44 KIND_NAME_CASE(Delta32) 45 KIND_NAME_CASE(NegDelta32) 46 KIND_NAME_CASE(Delta64) 47 KIND_NAME_CASE(Branch16PCRel) 48 KIND_NAME_CASE(Branch21PCRel) 49 KIND_NAME_CASE(Branch26PCRel) 50 KIND_NAME_CASE(Page20) 51 KIND_NAME_CASE(PageOffset12) 52 KIND_NAME_CASE(RequestGOTAndTransformToPage20) 53 KIND_NAME_CASE(RequestGOTAndTransformToPageOffset12) 54 KIND_NAME_CASE(Call36PCRel) 55 KIND_NAME_CASE(Add6) 56 KIND_NAME_CASE(Add8) 57 KIND_NAME_CASE(Add16) 58 KIND_NAME_CASE(Add32) 59 KIND_NAME_CASE(Add64) 60 KIND_NAME_CASE(AddUleb128) 61 KIND_NAME_CASE(Sub6) 62 KIND_NAME_CASE(Sub8) 63 KIND_NAME_CASE(Sub16) 64 KIND_NAME_CASE(Sub32) 65 KIND_NAME_CASE(Sub64) 66 KIND_NAME_CASE(SubUleb128) 67 KIND_NAME_CASE(AlignRelaxable) 68 default: 69 return getGenericEdgeKindName(K); 70 } 71 #undef KIND_NAME_CASE 72 } 73 74 } // namespace loongarch 75 } // namespace jitlink 76 } // namespace llvm 77