LLVM 19.0.0git
RISCVFixupKinds.h
Go to the documentation of this file.
1//===-- RISCVFixupKinds.h - RISC-V 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_RISCV_MCTARGETDESC_RISCVFIXUPKINDS_H
10#define LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVFIXUPKINDS_H
11
13#include "llvm/MC/MCFixup.h"
14#include <utility>
15
16#undef RISCV
17
18namespace llvm::RISCV {
19enum Fixups {
20 // 20-bit fixup corresponding to %hi(foo) for instructions like lui
22 // 12-bit fixup corresponding to %lo(foo) for instructions like addi
24 // 12-bit fixup corresponding to foo-bar for instructions like addi
26 // 12-bit fixup corresponding to %lo(foo) for the S-type store instructions
28 // 20-bit fixup corresponding to %pcrel_hi(foo) for instructions like auipc
30 // 12-bit fixup corresponding to %pcrel_lo(foo) for instructions like addi
32 // 12-bit fixup corresponding to %pcrel_lo(foo) for the S-type store
33 // instructions
35 // 20-bit fixup corresponding to %got_pcrel_hi(foo) for instructions like
36 // auipc
38 // 20-bit fixup corresponding to %tprel_hi(foo) for instructions like lui
40 // 12-bit fixup corresponding to %tprel_lo(foo) for instructions like addi
42 // 12-bit fixup corresponding to %tprel_lo(foo) for the S-type store
43 // instructions
45 // Fixup corresponding to %tprel_add(foo) for PseudoAddTPRel, used as a linker
46 // hint
48 // 20-bit fixup corresponding to %tls_ie_pcrel_hi(foo) for instructions like
49 // auipc
51 // 20-bit fixup corresponding to %tls_gd_pcrel_hi(foo) for instructions like
52 // auipc
54 // 20-bit fixup for symbol references in the jal instruction
56 // 12-bit fixup for symbol references in the branch instructions
58 // 11-bit fixup for symbol references in the compressed jump instruction
60 // 8-bit fixup for symbol references in the compressed branch instruction
62 // Fixup representing a legacy no-pic function call attached to the auipc
63 // instruction in a pair composed of adjacent auipc+jalr instructions.
65 // Fixup representing a function call attached to the auipc instruction in a
66 // pair composed of adjacent auipc+jalr instructions.
68 // Used to generate an R_RISCV_RELAX relocation, which indicates the linker
69 // may relax the instruction pair.
71 // Used to generate an R_RISCV_ALIGN relocation, which indicates the linker
72 // should fixup the alignment after linker relaxation.
74 // Fixups indicating a TLS descriptor code sequence, corresponding to auipc,
75 // lw/ld, addi, and jalr, respectively.
80
81 // Used as a sentinel, must be the last
84};
85
86static inline std::pair<MCFixupKind, MCFixupKind>
88 switch (Size) {
89 default:
90 llvm_unreachable("unsupported fixup size");
91 case 1:
92 return std::make_pair(
93 MCFixupKind(FirstLiteralRelocationKind + ELF::R_RISCV_ADD8),
94 MCFixupKind(FirstLiteralRelocationKind + ELF::R_RISCV_SUB8));
95 case 2:
96 return std::make_pair(
97 MCFixupKind(FirstLiteralRelocationKind + ELF::R_RISCV_ADD16),
98 MCFixupKind(FirstLiteralRelocationKind + ELF::R_RISCV_SUB16));
99 case 4:
100 return std::make_pair(
101 MCFixupKind(FirstLiteralRelocationKind + ELF::R_RISCV_ADD32),
102 MCFixupKind(FirstLiteralRelocationKind + ELF::R_RISCV_SUB32));
103 case 8:
104 return std::make_pair(
105 MCFixupKind(FirstLiteralRelocationKind + ELF::R_RISCV_ADD64),
106 MCFixupKind(FirstLiteralRelocationKind + ELF::R_RISCV_SUB64));
107 }
108}
109
110} // end namespace llvm::RISCV
111
112#endif
uint64_t Size
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static std::pair< MCFixupKind, MCFixupKind > getRelocPairForSize(unsigned Size)
@ fixup_riscv_tprel_lo12_s
@ fixup_riscv_tls_got_hi20
@ fixup_riscv_pcrel_lo12_i
@ fixup_riscv_tlsdesc_call
@ fixup_riscv_pcrel_lo12_s
@ fixup_riscv_tprel_lo12_i
@ fixup_riscv_tlsdesc_load_lo12
@ fixup_riscv_tlsdesc_hi20
@ fixup_riscv_tlsdesc_add_lo12
MCFixupKind
Extensible enumeration to represent the type of a fixup.
Definition: MCFixup.h:21
@ FirstTargetFixupKind
Definition: MCFixup.h:45
@ FirstLiteralRelocationKind
The range [FirstLiteralRelocationKind, MaxTargetFixupKind) is used for relocations coming from ....
Definition: MCFixup.h:50