LLVM 24.0.0git
HexagonRelocation.h
Go to the documentation of this file.
1//===- HexagonRelocation.h - Hexagon relocation application API -*- 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// Public API for applying relocations to Hexagon instruction encodings.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_TARGET_HEXAGON_HEXAGONRELOCATION_H
14#define LLVM_TARGET_HEXAGON_HEXAGONRELOCATION_H
15
17#include <stdbool.h>
18#include <stdint.h>
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24/// ABI properties of a Hexagon ELF relocation type, as listed in the Hexagon
25/// ABI document.
26typedef struct LLVMHexagonRelocInfo {
27 const char *Name;
30 uint32_t BitMask; ///< 0 if the mask depends on the instruction encoding.
37
38/// Fill \p Info with the properties of \p RelocType. Returns false, leaving
39/// \p Info untouched, if \p RelocType is not a known Hexagon relocation.
42
43/// Return true if \p Value fits the range the ABI specifies for \p RelocType.
44/// \p Value must already be shifted right by LLVMHexagonRelocInfo::Shift.
45/// Returns false for an unknown \p RelocType. The result is meaningful only
46/// for relocations whose LLVMHexagonRelocInfo::VerifyRange is set.
48
49/// Return true if \p Value satisfies the alignment required by \p RelocType.
50/// \p Value is the raw, unshifted relocation value.
51/// Returns false for an unknown \p RelocType. The result is meaningful only
52/// for relocations whose LLVMHexagonRelocInfo::VerifyAlignment is set.
54
55/// Return true if applying the unsigned relocation \p RelocType to \p Value
56/// would lose set bits. \p Value must already be shifted right by
57/// LLVMHexagonRelocInfo::Shift, as for LLVMHexagonVerifyRange. Returns false
58/// for signed or unknown relocations.
60
61/// Apply the ELF relocation \p RelocType with value \p Value to \p Instruction.
62///
63/// Hexagon instruction operands may be stored in non-contiguous bit positions.
64/// This function locates the operand field for relocations whose mask depends
65/// on the instruction encoding, then inserts the relocated value into that
66/// field. \p Value is the raw, unshifted relocation value; the shift specified
67/// by LLVMHexagonRelocInfo::Shift is applied internally. The caller is
68/// responsible for validating the relocation value (see LLVMHexagonVerifyRange
69/// and friends; note VerifyRange and IsTruncated expect a shifted value) and
70/// for computing any PC-relative adjustment before calling this function.
71/// \p Instruction is returned unchanged if \p RelocType is unknown.
73 uint32_t Instruction,
74 uint32_t Value);
75
76#ifdef __cplusplus
77} // extern "C"
78#endif
79
80#endif // LLVM_TARGET_HEXAGON_HEXAGONRELOCATION_H
#define LLVM_ABI
Definition Compiler.h:211
LLVM_ABI bool LLVMHexagonVerifyAlignment(uint32_t RelocType, uint32_t Value)
Return true if Value satisfies the alignment required by RelocType.
LLVM_ABI bool LLVMHexagonIsTruncated(uint32_t RelocType, uint32_t Value)
Return true if applying the unsigned relocation RelocType to Value would lose set bits.
LLVM_ABI uint32_t LLVMHexagonApplyRelocation(uint32_t RelocType, uint32_t Instruction, uint32_t Value)
Apply the ELF relocation RelocType with value Value to Instruction.
LLVM_ABI bool LLVMHexagonVerifyRange(uint32_t RelocType, uint32_t Value)
Return true if Value fits the range the ABI specifies for RelocType.
LLVM_ABI bool LLVMHexagonGetRelocationInfo(uint32_t RelocType, LLVMHexagonRelocInfo *Info)
Fill Info with the properties of RelocType.
ABI properties of a Hexagon ELF relocation type, as listed in the Hexagon ABI document.
uint32_t BitMask
0 if the mask depends on the instruction encoding.