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