LLVM 22.0.0git
AArch64MCAsmInfo.h
Go to the documentation of this file.
1//=====-- AArch64MCAsmInfo.h - AArch64 asm properties ---------*- 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// This file contains the declaration of the AArch64MCAsmInfo class.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_TARGET_AARCH64_MCTARGETDESC_AARCH64MCASMINFO_H
14#define LLVM_LIB_TARGET_AARCH64_MCTARGETDESC_AARCH64MCASMINFO_H
15
20#include "llvm/MC/MCExpr.h"
22
23namespace llvm {
24class MCStreamer;
25class MCValue;
26class Triple;
27
29 explicit AArch64MCAsmInfoDarwin(bool IsILP32);
30 const MCExpr *
31 getExprForPersonalitySymbol(const MCSymbol *Sym, unsigned Encoding,
32 MCStreamer &Streamer) const override;
34 const MCSpecifierExpr &Expr) const override;
36 const MCAssembler *Asm) const override;
37};
38
40 explicit AArch64MCAsmInfoELF(const Triple &T);
42 const MCSpecifierExpr &Expr) const override;
44 const MCAssembler *Asm) const override;
45};
46
50 const MCSpecifierExpr &Expr) const override;
52 const MCAssembler *Asm) const override;
53};
54
56 explicit AArch64MCAsmInfoGNUCOFF();
58 const MCSpecifierExpr &Expr) const override;
60 const MCAssembler *Asm) const override;
61};
62
63namespace AArch64 {
65
66enum {
67 // clang-format off
68 S_None = 0,
69 // Symbol locations specifying (roughly speaking) what calculation should be
70 // performed to construct the final address for the relocated
71 // symbol. E.g. direct, via the GOT, ...
72 S_ABS = 0x001,
73 S_SABS = 0x002,
74 S_PREL = 0x003,
75 S_GOT = 0x004,
76 S_DTPREL = 0x005,
77 S_GOTTPREL = 0x006,
78 S_TPREL = 0x007,
79 S_TLSDESC = 0x008,
80 S_SECREL = 0x009,
81 S_AUTH = 0x00a,
82 S_AUTHADDR = 0x00b,
83 S_GOT_AUTH = 0x00c,
85 S_SymLocBits = 0x00f,
86
87 // Variants specifying which part of the final address calculation is
88 // used. E.g. the low 12 bits for an ADD/LDR, the middle 16 bits for a
89 // MOVZ/MOVK.
90 S_PAGE = 0x010,
91 S_PAGEOFF = 0x020,
92 S_HI12 = 0x030,
93 S_G0 = 0x040,
94 S_G1 = 0x050,
95 S_G2 = 0x060,
96 S_G3 = 0x070,
97 S_LO15 = 0x080,
99
100 // Whether the final relocation is a checked one (where a linker should
101 // perform a range-check on the final address) or not. Note that this field
102 // is unfortunately sometimes omitted from the assembly syntax. E.g. :lo12:
103 // on its own is a non-checked relocation. We side with ELF on being
104 // explicit about this!
105 S_NC = 0x100,
106
107 // Convenience definitions for referring to specific textual representations
108 // of relocation specifiers. Note that this means the "_NC" is sometimes
109 // omitted in line with assembly syntax here (S_LO12 rather than VK_LO12_NC
110 // since a user would write ":lo12:").
163
164 // ELF relocation specifiers in data directives:
165 S_PLT = 0x400,
167
168 // Mach-O @ relocation specifiers:
177
178 S_INVALID = 0xfff
179 // clang-format on
181
182/// Return the string representation of the ELF relocation specifier
183/// (e.g. ":got:", ":lo12:").
185
187 return static_cast<Specifier>(S & AArch64::S_SymLocBits);
188}
189
191 return static_cast<Specifier>(S & AArch64::S_AddressFragBits);
192}
193
194inline bool isNotChecked(Specifier S) { return S & AArch64::S_NC; }
195} // namespace AArch64
196
197class AArch64AuthMCExpr final : public MCSpecifierExpr {
198 uint16_t Discriminator;
200
201 explicit AArch64AuthMCExpr(const MCExpr *Expr, uint16_t Discriminator,
202 AArch64PACKey::ID Key, bool HasAddressDiversity,
203 SMLoc Loc)
205 Expr, HasAddressDiversity ? AArch64::S_AUTHADDR : AArch64::S_AUTH,
206 Loc),
207 Discriminator(Discriminator), Key(Key) {}
208
209public:
210 static const AArch64AuthMCExpr *
211 create(const MCExpr *Expr, uint16_t Discriminator, AArch64PACKey::ID Key,
212 bool HasAddressDiversity, MCContext &Ctx, SMLoc Loc = SMLoc());
213
214 AArch64PACKey::ID getKey() const { return Key; }
215 uint16_t getDiscriminator() const { return Discriminator; }
216 bool hasAddressDiversity() const {
218 }
219
220 void print(raw_ostream &OS, const MCAsmInfo *MAI) const;
221
222 static bool classof(const MCExpr *E) {
223 auto *SE = dyn_cast<MCSpecifierExpr>(E);
224 return SE && (SE->getSpecifier() == AArch64::S_AUTH ||
225 SE->getSpecifier() == AArch64::S_AUTHADDR);
226 }
227};
228
229} // namespace llvm
230
231#endif
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Symbol * Sym
Definition: ELF_riscv.cpp:479
raw_pwrite_stream & OS
void print(raw_ostream &OS, const MCAsmInfo *MAI) const
bool hasAddressDiversity() const
uint16_t getDiscriminator() const
AArch64PACKey::ID getKey() const
static bool classof(const MCExpr *E)
static const AArch64AuthMCExpr * create(const MCExpr *Expr, uint16_t Discriminator, AArch64PACKey::ID Key, bool HasAddressDiversity, MCContext &Ctx, SMLoc Loc=SMLoc())
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:64
Context object for machine code objects.
Definition: MCContext.h:83
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:34
Extension point for target-specific MCExpr subclasses with a relocation specifier,...
Definition: MCExpr.h:495
const MCExpr * Expr
Definition: MCExpr.h:497
Spec getSpecifier() const
Definition: MCExpr.h:508
Streaming machine code generation interface.
Definition: MCStreamer.h:220
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:42
Represents a location in source code.
Definition: SMLoc.h:23
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:47
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
uint16_t Specifier
Specifier getSymbolLoc(Specifier S)
StringRef getSpecifierName(Specifier S)
Return the string representation of the ELF relocation specifier (e.g.
bool isNotChecked(Specifier S)
Specifier getAddressFrag(Specifier S)
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
bool evaluateAsRelocatableImpl(const MCSpecifierExpr &Expr, MCValue &Res, const MCAssembler *Asm) const override
const MCExpr * getExprForPersonalitySymbol(const MCSymbol *Sym, unsigned Encoding, MCStreamer &Streamer) const override
void printSpecifierExpr(raw_ostream &OS, const MCSpecifierExpr &Expr) const override
void printSpecifierExpr(raw_ostream &OS, const MCSpecifierExpr &Expr) const override
bool evaluateAsRelocatableImpl(const MCSpecifierExpr &Expr, MCValue &Res, const MCAssembler *Asm) const override
bool evaluateAsRelocatableImpl(const MCSpecifierExpr &Expr, MCValue &Res, const MCAssembler *Asm) const override
void printSpecifierExpr(raw_ostream &OS, const MCSpecifierExpr &Expr) const override
bool evaluateAsRelocatableImpl(const MCSpecifierExpr &Expr, MCValue &Res, const MCAssembler *Asm) const override
void printSpecifierExpr(raw_ostream &OS, const MCSpecifierExpr &Expr) const override