LLVM 23.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,
168
169 // Mach-O @ relocation specifiers:
178
179 S_INVALID = 0xfff
180 // clang-format on
181};
182
183/// Return the string representation of the ELF relocation specifier
184/// (e.g. ":got:", ":lo12:").
186
188
190 return static_cast<Specifier>(S & AArch64::S_SymLocBits);
191}
192
194 return static_cast<Specifier>(S & AArch64::S_AddressFragBits);
195}
196
197inline bool isNotChecked(Specifier S) { return S & AArch64::S_NC; }
198} // namespace AArch64
199
200class AArch64AuthMCExpr final : public MCSpecifierExpr {
201 uint16_t Discriminator;
203
204 explicit AArch64AuthMCExpr(const MCExpr *Expr, uint16_t Discriminator,
205 AArch64PACKey::ID Key, bool HasAddressDiversity,
206 SMLoc Loc)
208 Expr, HasAddressDiversity ? AArch64::S_AUTHADDR : AArch64::S_AUTH,
209 Loc),
210 Discriminator(Discriminator), Key(Key) {}
211
212public:
213 static const AArch64AuthMCExpr *
214 create(const MCExpr *Expr, uint16_t Discriminator, AArch64PACKey::ID Key,
215 bool HasAddressDiversity, MCContext &Ctx, SMLoc Loc = SMLoc());
216
217 AArch64PACKey::ID getKey() const { return Key; }
218 uint16_t getDiscriminator() const { return Discriminator; }
219 bool hasAddressDiversity() const {
221 }
222
223 void print(raw_ostream &OS, const MCAsmInfo *MAI) const;
224
225 static bool classof(const MCExpr *E) {
226 auto *SE = dyn_cast<MCSpecifierExpr>(E);
227 return SE && (SE->getSpecifier() == AArch64::S_AUTH ||
228 SE->getSpecifier() == AArch64::S_AUTHADDR);
229 }
230};
231
232} // namespace llvm
233
234#endif
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define T
void print(raw_ostream &OS, const MCAsmInfo *MAI) 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
MCSpecifierExpr(const MCExpr *Expr, Spec S, SMLoc Loc=SMLoc())
Definition MCExpr.h:499
Spec getSpecifier() const
Definition MCExpr.h:508
Streaming machine code generation interface.
Definition MCStreamer.h:221
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:22
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
Specifier parsePercentSpecifierName(StringRef)
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 Types.h:26
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
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
AArch64MCAsmInfoELF(const Triple &T)
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