xref: /freebsd/contrib/llvm-project/llvm/lib/Target/ARM/MCTargetDesc/ARMFixupKinds.h (revision 7a6dacaca14b62ca4b74406814becb87a3fefac0)
10b57cec5SDimitry Andric //===-- ARMFixupKinds.h - ARM Specific Fixup Entries ------------*- C++ -*-===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric 
90b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_ARM_MCTARGETDESC_ARMFIXUPKINDS_H
100b57cec5SDimitry Andric #define LLVM_LIB_TARGET_ARM_MCTARGETDESC_ARMFIXUPKINDS_H
110b57cec5SDimitry Andric 
120b57cec5SDimitry Andric #include "llvm/MC/MCFixup.h"
130b57cec5SDimitry Andric 
140b57cec5SDimitry Andric namespace llvm {
150b57cec5SDimitry Andric namespace ARM {
160b57cec5SDimitry Andric enum Fixups {
170b57cec5SDimitry Andric   // 12-bit PC relative relocation for symbol addresses
180b57cec5SDimitry Andric   fixup_arm_ldst_pcrel_12 = FirstTargetFixupKind,
190b57cec5SDimitry Andric 
200b57cec5SDimitry Andric   // Equivalent to fixup_arm_ldst_pcrel_12, with the 16-bit halfwords reordered.
210b57cec5SDimitry Andric   fixup_t2_ldst_pcrel_12,
220b57cec5SDimitry Andric 
230b57cec5SDimitry Andric   // 10-bit PC relative relocation for symbol addresses used in
240b57cec5SDimitry Andric   // LDRD/LDRH/LDRB/etc. instructions. All bits are encoded.
250b57cec5SDimitry Andric   fixup_arm_pcrel_10_unscaled,
260b57cec5SDimitry Andric   // 10-bit PC relative relocation for symbol addresses used in VFP instructions
270b57cec5SDimitry Andric   // where the lower 2 bits are not encoded (so it's encoded as an 8-bit
280b57cec5SDimitry Andric   // immediate).
290b57cec5SDimitry Andric   fixup_arm_pcrel_10,
300b57cec5SDimitry Andric   // Equivalent to fixup_arm_pcrel_10, accounting for the short-swapped encoding
31*7a6dacacSDimitry Andric   // of Thumb2 instructions. Also used by LDRD in Thumb mode.
320b57cec5SDimitry Andric   fixup_t2_pcrel_10,
330b57cec5SDimitry Andric   // 9-bit PC relative relocation for symbol addresses used in VFP instructions
340b57cec5SDimitry Andric   // where bit 0 not encoded (so it's encoded as an 8-bit immediate).
350b57cec5SDimitry Andric   fixup_arm_pcrel_9,
360b57cec5SDimitry Andric   // Equivalent to fixup_arm_pcrel_9, accounting for the short-swapped encoding
370b57cec5SDimitry Andric   // of Thumb2 instructions.
380b57cec5SDimitry Andric   fixup_t2_pcrel_9,
39fe6060f1SDimitry Andric   // 12-bit immediate value.
40fe6060f1SDimitry Andric   fixup_arm_ldst_abs_12,
410b57cec5SDimitry Andric   // 10-bit PC relative relocation for symbol addresses where the lower 2 bits
420b57cec5SDimitry Andric   // are not encoded (so it's encoded as an 8-bit immediate).
430b57cec5SDimitry Andric   fixup_thumb_adr_pcrel_10,
440b57cec5SDimitry Andric   // 12-bit PC relative relocation for the ADR instruction.
450b57cec5SDimitry Andric   fixup_arm_adr_pcrel_12,
460b57cec5SDimitry Andric   // 12-bit PC relative relocation for the ADR instruction.
470b57cec5SDimitry Andric   fixup_t2_adr_pcrel_12,
480b57cec5SDimitry Andric   // 24-bit PC relative relocation for conditional branch instructions.
490b57cec5SDimitry Andric   fixup_arm_condbranch,
500b57cec5SDimitry Andric   // 24-bit PC relative relocation for branch instructions. (unconditional)
510b57cec5SDimitry Andric   fixup_arm_uncondbranch,
520b57cec5SDimitry Andric   // 20-bit PC relative relocation for Thumb2 direct uconditional branch
530b57cec5SDimitry Andric   // instructions.
540b57cec5SDimitry Andric   fixup_t2_condbranch,
550b57cec5SDimitry Andric   // 20-bit PC relative relocation for Thumb2 direct branch unconditional branch
560b57cec5SDimitry Andric   // instructions.
570b57cec5SDimitry Andric   fixup_t2_uncondbranch,
580b57cec5SDimitry Andric 
590b57cec5SDimitry Andric   // 12-bit fixup for Thumb B instructions.
600b57cec5SDimitry Andric   fixup_arm_thumb_br,
610b57cec5SDimitry Andric 
620b57cec5SDimitry Andric   // The following fixups handle the ARM BL instructions. These can be
630b57cec5SDimitry Andric   // conditionalised; however, the ARM ELF ABI requires a different relocation
640b57cec5SDimitry Andric   // in that case: R_ARM_JUMP24 instead of R_ARM_CALL. The difference is that
650b57cec5SDimitry Andric   // R_ARM_CALL is allowed to change the instruction to a BLX inline, which has
660b57cec5SDimitry Andric   // no conditional version; R_ARM_JUMP24 would have to insert a veneer.
670b57cec5SDimitry Andric   //
680b57cec5SDimitry Andric   // MachO does not draw a distinction between the two cases, so it will treat
690b57cec5SDimitry Andric   // fixup_arm_uncondbl and fixup_arm_condbl as identical fixups.
700b57cec5SDimitry Andric 
710b57cec5SDimitry Andric   // Fixup for unconditional ARM BL instructions.
720b57cec5SDimitry Andric   fixup_arm_uncondbl,
730b57cec5SDimitry Andric 
740b57cec5SDimitry Andric   // Fixup for ARM BL instructions with nontrivial conditionalisation.
750b57cec5SDimitry Andric   fixup_arm_condbl,
760b57cec5SDimitry Andric 
770b57cec5SDimitry Andric   // Fixup for ARM BLX instructions.
780b57cec5SDimitry Andric   fixup_arm_blx,
790b57cec5SDimitry Andric 
800b57cec5SDimitry Andric   // Fixup for Thumb BL instructions.
810b57cec5SDimitry Andric   fixup_arm_thumb_bl,
820b57cec5SDimitry Andric 
830b57cec5SDimitry Andric   // Fixup for Thumb BLX instructions.
840b57cec5SDimitry Andric   fixup_arm_thumb_blx,
850b57cec5SDimitry Andric 
860b57cec5SDimitry Andric   // Fixup for Thumb branch instructions.
870b57cec5SDimitry Andric   fixup_arm_thumb_cb,
880b57cec5SDimitry Andric 
890b57cec5SDimitry Andric   // Fixup for Thumb load/store from constant pool instrs.
900b57cec5SDimitry Andric   fixup_arm_thumb_cp,
910b57cec5SDimitry Andric 
920b57cec5SDimitry Andric   // Fixup for Thumb conditional branching instructions.
930b57cec5SDimitry Andric   fixup_arm_thumb_bcc,
940b57cec5SDimitry Andric 
950b57cec5SDimitry Andric   // The next two are for the movt/movw pair
960b57cec5SDimitry Andric   // the 16bit imm field are split into imm{15-12} and imm{11-0}
970b57cec5SDimitry Andric   fixup_arm_movt_hi16, // :upper16:
980b57cec5SDimitry Andric   fixup_arm_movw_lo16, // :lower16:
990b57cec5SDimitry Andric   fixup_t2_movt_hi16,  // :upper16:
1000b57cec5SDimitry Andric   fixup_t2_movw_lo16,  // :lower16:
1010b57cec5SDimitry Andric 
10206c3fb27SDimitry Andric   // Fixup for Thumb movs (enc T1) and adds (enc T2) 8-bit immediate field (7-0)
10306c3fb27SDimitry Andric   fixup_arm_thumb_upper_8_15, // :upper8_15:
10406c3fb27SDimitry Andric   fixup_arm_thumb_upper_0_7,  // :upper0_7:
10506c3fb27SDimitry Andric   fixup_arm_thumb_lower_8_15, // :lower8_15:
10606c3fb27SDimitry Andric   fixup_arm_thumb_lower_0_7,  // :lower0_7:
10706c3fb27SDimitry Andric 
1080b57cec5SDimitry Andric   // Fixup for mod_imm
1090b57cec5SDimitry Andric   fixup_arm_mod_imm,
1100b57cec5SDimitry Andric 
1110b57cec5SDimitry Andric   // Fixup for Thumb2 8-bit rotated operand
1120b57cec5SDimitry Andric   fixup_t2_so_imm,
1130b57cec5SDimitry Andric 
1140b57cec5SDimitry Andric   // Fixups for Branch Future.
1150b57cec5SDimitry Andric   fixup_bf_branch,
1160b57cec5SDimitry Andric   fixup_bf_target,
1170b57cec5SDimitry Andric   fixup_bfl_target,
1180b57cec5SDimitry Andric   fixup_bfc_target,
1190b57cec5SDimitry Andric   fixup_bfcsel_else_target,
1200b57cec5SDimitry Andric   fixup_wls,
1210b57cec5SDimitry Andric   fixup_le,
1220b57cec5SDimitry Andric 
1230b57cec5SDimitry Andric   // Marker
1240b57cec5SDimitry Andric   LastTargetFixupKind,
1250b57cec5SDimitry Andric   NumTargetFixupKinds = LastTargetFixupKind - FirstTargetFixupKind
1260b57cec5SDimitry Andric };
1270b57cec5SDimitry Andric }
1280b57cec5SDimitry Andric } // namespace llvm
1290b57cec5SDimitry Andric 
1300b57cec5SDimitry Andric #endif
131