loongarch.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. #include "llvm/ExecutionEngine/JITLink/loongarch.h"
  13. #define DEBUG_TYPE "jitlink"
  14. namespace llvm {
  15. namespace jitlink {
  16. namespace loongarch {
  17. const char NullPointerContent[8] = {0x00, 0x00, 0x00, 0x00,
  18. 0x00, 0x00, 0x00, 0x00};
  19. const uint8_t LA64StubContent[StubEntrySize] = {
  20. 0x14, 0x00, 0x00, 0x1a, // pcalau12i $t8, %page20(imm)
  21. 0x94, 0x02, 0xc0, 0x28, // ld.d $t8, $t8, %pageoff12(imm)
  22. 0x80, 0x02, 0x00, 0x4c // jr $t8
  23. };
  24. const uint8_t LA32StubContent[StubEntrySize] = {
  25. 0x14, 0x00, 0x00, 0x1a, // pcalau12i $t8, %page20(imm)
  26. 0x94, 0x02, 0x80, 0x28, // ld.w $t8, $t8, %pageoff12(imm)
  27. 0x80, 0x02, 0x00, 0x4c // jr $t8
  28. };
  29. const char *getEdgeKindName(Edge::Kind K) {
  30. #define KIND_NAME_CASE(K) \
  31. case K: \
  32. return #K;
  33. switch (K) {
  34. KIND_NAME_CASE(Pointer64)
  35. KIND_NAME_CASE(Pointer32)
  36. KIND_NAME_CASE(Delta32)
  37. KIND_NAME_CASE(NegDelta32)
  38. KIND_NAME_CASE(Delta64)
  39. KIND_NAME_CASE(Branch26PCRel)
  40. KIND_NAME_CASE(Page20)
  41. KIND_NAME_CASE(PageOffset12)
  42. KIND_NAME_CASE(RequestGOTAndTransformToPage20)
  43. KIND_NAME_CASE(RequestGOTAndTransformToPageOffset12)
  44. default:
  45. return getGenericEdgeKindName(K);
  46. }
  47. #undef KIND_NAME_CASE
  48. }
  49. } // namespace loongarch
  50. } // namespace jitlink
  51. } // namespace llvm