1*bdd1243dSDimitry Andric //===--- loongarch.cpp - Generic JITLink loongarch edge kinds, utilities --===//
2*bdd1243dSDimitry Andric //
3*bdd1243dSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*bdd1243dSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*bdd1243dSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*bdd1243dSDimitry Andric //
7*bdd1243dSDimitry Andric //===----------------------------------------------------------------------===//
8*bdd1243dSDimitry Andric //
9*bdd1243dSDimitry Andric // Generic utilities for graphs representing loongarch objects.
10*bdd1243dSDimitry Andric //
11*bdd1243dSDimitry Andric //===----------------------------------------------------------------------===//
12*bdd1243dSDimitry Andric
13*bdd1243dSDimitry Andric #include "llvm/ExecutionEngine/JITLink/loongarch.h"
14*bdd1243dSDimitry Andric
15*bdd1243dSDimitry Andric #define DEBUG_TYPE "jitlink"
16*bdd1243dSDimitry Andric
17*bdd1243dSDimitry Andric namespace llvm {
18*bdd1243dSDimitry Andric namespace jitlink {
19*bdd1243dSDimitry Andric namespace loongarch {
20*bdd1243dSDimitry Andric
21*bdd1243dSDimitry Andric const char NullPointerContent[8] = {0x00, 0x00, 0x00, 0x00,
22*bdd1243dSDimitry Andric 0x00, 0x00, 0x00, 0x00};
23*bdd1243dSDimitry Andric
24*bdd1243dSDimitry Andric const uint8_t LA64StubContent[StubEntrySize] = {
25*bdd1243dSDimitry Andric 0x14, 0x00, 0x00, 0x1a, // pcalau12i $t8, %page20(imm)
26*bdd1243dSDimitry Andric 0x94, 0x02, 0xc0, 0x28, // ld.d $t8, $t8, %pageoff12(imm)
27*bdd1243dSDimitry Andric 0x80, 0x02, 0x00, 0x4c // jr $t8
28*bdd1243dSDimitry Andric };
29*bdd1243dSDimitry Andric
30*bdd1243dSDimitry Andric const uint8_t LA32StubContent[StubEntrySize] = {
31*bdd1243dSDimitry Andric 0x14, 0x00, 0x00, 0x1a, // pcalau12i $t8, %page20(imm)
32*bdd1243dSDimitry Andric 0x94, 0x02, 0x80, 0x28, // ld.w $t8, $t8, %pageoff12(imm)
33*bdd1243dSDimitry Andric 0x80, 0x02, 0x00, 0x4c // jr $t8
34*bdd1243dSDimitry Andric };
35*bdd1243dSDimitry Andric
getEdgeKindName(Edge::Kind K)36*bdd1243dSDimitry Andric const char *getEdgeKindName(Edge::Kind K) {
37*bdd1243dSDimitry Andric #define KIND_NAME_CASE(K) \
38*bdd1243dSDimitry Andric case K: \
39*bdd1243dSDimitry Andric return #K;
40*bdd1243dSDimitry Andric
41*bdd1243dSDimitry Andric switch (K) {
42*bdd1243dSDimitry Andric KIND_NAME_CASE(Pointer64)
43*bdd1243dSDimitry Andric KIND_NAME_CASE(Pointer32)
44*bdd1243dSDimitry Andric KIND_NAME_CASE(Delta32)
45*bdd1243dSDimitry Andric KIND_NAME_CASE(NegDelta32)
46*bdd1243dSDimitry Andric KIND_NAME_CASE(Delta64)
47*bdd1243dSDimitry Andric KIND_NAME_CASE(Branch26PCRel)
48*bdd1243dSDimitry Andric KIND_NAME_CASE(Page20)
49*bdd1243dSDimitry Andric KIND_NAME_CASE(PageOffset12)
50*bdd1243dSDimitry Andric KIND_NAME_CASE(RequestGOTAndTransformToPage20)
51*bdd1243dSDimitry Andric KIND_NAME_CASE(RequestGOTAndTransformToPageOffset12)
52*bdd1243dSDimitry Andric default:
53*bdd1243dSDimitry Andric return getGenericEdgeKindName(K);
54*bdd1243dSDimitry Andric }
55*bdd1243dSDimitry Andric #undef KIND_NAME_CASE
56*bdd1243dSDimitry Andric }
57*bdd1243dSDimitry Andric
58*bdd1243dSDimitry Andric } // namespace loongarch
59*bdd1243dSDimitry Andric } // namespace jitlink
60*bdd1243dSDimitry Andric } // namespace llvm
61