1//===-- llvm/MC/MCFixup.h - Instruction Relocation and Patching -*- C++ -*-===//
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
7//===----------------------------------------------------------------------===//
9#ifndef LLVM_MC_MCFIXUP_H
10#define LLVM_MC_MCFIXUP_H
21/// Extensible enumeration to represent the type of a fixup.
24 // [0, FirstLiteralRelocationKind) encodes raw relocation types.
26 // [FirstLiteralRelocationKind, FK_NONE) encodes raw relocation types coming
27 // from .reloc directives. Fixup kind
28 // FirstLiteralRelocationKind+t encodes relocation type t.
31 // Other kinds indicate the fixup may resolve to a constant, allowing the
32 // assembler to update the instruction or data directly without a relocation.
47/// Encode information on a single operation to perform on a byte
48/// sequence (e.g., an encoded instruction) which requires assemble- or run-
51/// Fixups are used any time the target instruction encoder needs to represent
52/// some value in an instruction which is not yet concrete. The encoder will
53/// encode the instruction assuming the value is 0, and emit a fixup which
54/// communicates to the assembler backend how it should rewrite the encoded
57/// During the process of relaxation, the assembler will apply fixups as
58/// symbolic values become concrete. When relaxation is complete, any remaining
59/// fixups become relocations in the object file (or errors, if the fixup cannot
60/// be encoded on the target).
62 /// The value to put into the fixup location. The exact interpretation of the
63 /// expression is target dependent, usually it will be one of the operands to
64 /// an instruction or an assembler directive.
65 const MCExpr *Value =
nullptr;
67 /// The byte index of start of the relocation inside the MCFragment.
70 /// The target dependent kind of fixup item this is. The kind is used to
71 /// determine how the operand value should be encoded into the instruction.
74 /// True if this is a PC-relative fixup. The relocatable expression is
75 /// typically resolved When SymB is nullptr and SymA is a local symbol defined
76 /// within the current section.
79 /// Used by RISC-V style linker relaxation. Whether the fixup is
81 bool LinkerRelaxable =
false;
83 /// Consider bit fields if we need more flags.
108 /// Return the generic fixup kind for a value with the given size. It
109 /// is an error to pass an unsupported size.
128// Check if the fixup kind is a relocation type. Return false if the fixup can
129// be resolved without a relocation.
132// Check if the fixup kind represents a relocation type from a .reloc directive.
133// In ELF, this skips STT_SECTION adjustment and STT_TLS symbol type setting for
140}
// End llvm namespace
Base class for the full range of assembler expressions which are needed for parsing.
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
static MCFixupKind getDataKindForSize(unsigned Size)
Return the generic fixup kind for a value with the given size.
const MCExpr * getValue() const
void setLinkerRelaxable()
LLVM_ABI SMLoc getLoc() const
uint32_t getOffset() const
bool isLinkerRelaxable() const
void setOffset(uint32_t Value)
static MCFixup create(uint32_t Offset, const MCExpr *Value, MCFixupKind Kind, bool PCRel=false)
Consider bit fields if we need more flags.
MCFixupKind getKind() const
Represents a location in source code.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool isRelocRelocation(MCFixupKind FixupKind)
bool isRelocation(MCFixupKind FixupKind)
This is an optimization pass for GlobalISel generic memory operations.
uint16_t MCFixupKind
Extensible enumeration to represent the type of a fixup.
static Lanai::Fixups FixupKind(const MCExpr *Expr)
@ FK_SecRel_2
A two-byte section relative fixup.
@ FirstLiteralRelocationKind
@ FK_Data_8
A eight-byte fixup.
@ FK_Data_1
A one-byte fixup.
@ FK_Data_4
A four-byte fixup.
@ FK_SecRel_8
A eight-byte section relative fixup.
@ FK_SecRel_4
A four-byte section relative fixup.
@ FK_SecRel_1
A one-byte section relative fixup.
@ FK_Data_leb128
A leb128 fixup.
@ FK_Data_2
A two-byte fixup.