LoongArchFixupKinds.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. //===- LoongArchFixupKinds.h - LoongArch Specific Fixup Entries -*- C++ -*-===//
  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. #ifndef LLVM_LIB_TARGET_LOONGARCH_MCTARGETDESC_LOONGARCHFIXUPKINDS_H
  9. #define LLVM_LIB_TARGET_LOONGARCH_MCTARGETDESC_LOONGARCHFIXUPKINDS_H
  10. #include "llvm/BinaryFormat/ELF.h"
  11. #include "llvm/MC/MCFixup.h"
  12. #undef LoongArch
  13. namespace llvm {
  14. namespace LoongArch {
  15. //
  16. // This table *must* be in the same order of
  17. // MCFixupKindInfo Infos[LoongArch::NumTargetFixupKinds] in
  18. // LoongArchAsmBackend.cpp.
  19. //
  20. enum Fixups {
  21. // Define fixups can be handled by LoongArchAsmBackend::applyFixup.
  22. // 16-bit fixup corresponding to %b16(foo) for instructions like bne.
  23. fixup_loongarch_b16 = FirstTargetFixupKind,
  24. // 21-bit fixup corresponding to %b21(foo) for instructions like bnez.
  25. fixup_loongarch_b21,
  26. // 26-bit fixup corresponding to %b26(foo)/%plt(foo) for instructions b/bl.
  27. fixup_loongarch_b26,
  28. // 20-bit fixup corresponding to %abs_hi20(foo) for instruction lu12i.w.
  29. fixup_loongarch_abs_hi20,
  30. // 12-bit fixup corresponding to %abs_lo12(foo) for instruction ori.
  31. fixup_loongarch_abs_lo12,
  32. // 20-bit fixup corresponding to %abs64_lo20(foo) for instruction lu32i.d.
  33. fixup_loongarch_abs64_lo20,
  34. // 12-bit fixup corresponding to %abs_hi12(foo) for instruction lu52i.d.
  35. fixup_loongarch_abs64_hi12,
  36. // 20-bit fixup corresponding to %le_hi20(foo) for instruction lu12i.w.
  37. fixup_loongarch_tls_le_hi20,
  38. // 12-bit fixup corresponding to %le_lo12(foo) for instruction ori.
  39. fixup_loongarch_tls_le_lo12,
  40. // 20-bit fixup corresponding to %le64_lo20(foo) for instruction lu32i.d.
  41. fixup_loongarch_tls_le64_lo20,
  42. // 12-bit fixup corresponding to %le64_hi12(foo) for instruction lu52i.d.
  43. fixup_loongarch_tls_le64_hi12,
  44. // TODO: Add more fixup kind.
  45. // Used as a sentinel, must be the last of the fixup which can be handled by
  46. // LoongArchAsmBackend::applyFixup.
  47. fixup_loongarch_invalid,
  48. NumTargetFixupKinds = fixup_loongarch_invalid - FirstTargetFixupKind,
  49. // Define fixups for force relocation as FirstLiteralRelocationKind+V
  50. // represents the relocation type with number V.
  51. // 20-bit fixup corresponding to %pc_hi20(foo) for instruction pcalau12i.
  52. fixup_loongarch_pcala_hi20 =
  53. FirstLiteralRelocationKind + ELF::R_LARCH_PCALA_HI20,
  54. // 12-bit fixup corresponding to %pc_lo12(foo) for instructions like addi.w/d.
  55. fixup_loongarch_pcala_lo12,
  56. // 20-bit fixup corresponding to %pc64_lo20(foo) for instruction lu32i.d.
  57. fixup_loongarch_pcala64_lo20,
  58. // 12-bit fixup corresponding to %pc64_hi12(foo) for instruction lu52i.d.
  59. fixup_loongarch_pcala64_hi12,
  60. // 20-bit fixup corresponding to %got_pc_hi20(foo) for instruction pcalau12i.
  61. fixup_loongarch_got_pc_hi20,
  62. // 12-bit fixup corresponding to %got_pc_lo12(foo) for instructions
  63. // ld.w/ld.d/add.d.
  64. fixup_loongarch_got_pc_lo12,
  65. // 20-bit fixup corresponding to %got64_pc_lo20(foo) for instruction lu32i.d.
  66. fixup_loongarch_got64_pc_lo20,
  67. // 12-bit fixup corresponding to %got64_pc_hi12(foo) for instruction lu52i.d.
  68. fixup_loongarch_got64_pc_hi12,
  69. // 20-bit fixup corresponding to %got_hi20(foo) for instruction lu12i.w.
  70. fixup_loongarch_got_hi20,
  71. // 12-bit fixup corresponding to %got_lo12(foo) for instruction ori.
  72. fixup_loongarch_got_lo12,
  73. // 20-bit fixup corresponding to %got64_lo20(foo) for instruction lu32i.d.
  74. fixup_loongarch_got64_lo20,
  75. // 12-bit fixup corresponding to %got64_hi12(foo) for instruction lu52i.d.
  76. fixup_loongarch_got64_hi12,
  77. // Skip R_LARCH_TLS_LE_*.
  78. // 20-bit fixup corresponding to %ie_pc_hi20(foo) for instruction pcalau12i.
  79. fixup_loongarch_tls_ie_pc_hi20 =
  80. FirstLiteralRelocationKind + ELF::R_LARCH_TLS_IE_PC_HI20,
  81. // 12-bit fixup corresponding to %ie_pc_lo12(foo) for instructions
  82. // ld.w/ld.d/add.d.
  83. fixup_loongarch_tls_ie_pc_lo12,
  84. // 20-bit fixup corresponding to %ie64_pc_lo20(foo) for instruction lu32i.d.
  85. fixup_loongarch_tls_ie64_pc_lo20,
  86. // 12-bit fixup corresponding to %ie64_pc_hi12(foo) for instruction lu52i.d.
  87. fixup_loongarch_tls_ie64_pc_hi12,
  88. // 20-bit fixup corresponding to %ie_hi20(foo) for instruction lu12i.w.
  89. fixup_loongarch_tls_ie_hi20,
  90. // 12-bit fixup corresponding to %ie_lo12(foo) for instruction ori.
  91. fixup_loongarch_tls_ie_lo12,
  92. // 20-bit fixup corresponding to %ie64_lo20(foo) for instruction lu32i.d.
  93. fixup_loongarch_tls_ie64_lo20,
  94. // 12-bit fixup corresponding to %ie64_hi12(foo) for instruction lu52i.d.
  95. fixup_loongarch_tls_ie64_hi12,
  96. // 20-bit fixup corresponding to %ld_pc_hi20(foo) for instruction pcalau12i.
  97. fixup_loongarch_tls_ld_pc_hi20,
  98. // 20-bit fixup corresponding to %ld_hi20(foo) for instruction lu12i.w.
  99. fixup_loongarch_tls_ld_hi20,
  100. // 20-bit fixup corresponding to %gd_pc_hi20(foo) for instruction pcalau12i.
  101. fixup_loongarch_tls_gd_pc_hi20,
  102. // 20-bit fixup corresponding to %gd_hi20(foo) for instruction lu12i.w.
  103. fixup_loongarch_tls_gd_hi20
  104. };
  105. } // end namespace LoongArch
  106. } // end namespace llvm
  107. #endif