LLVM 24.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, const MCTargetOptions &Options);
30};
31
33 explicit AArch64MCAsmInfoELF(const Triple &T, const MCTargetOptions &Options);
34};
35
39
43
44namespace AArch64 {
46
47enum {
48 // clang-format off
49 S_None = 0,
50 // Symbol locations specifying (roughly speaking) what calculation should be
51 // performed to construct the final address for the relocated
52 // symbol. E.g. direct, via the GOT, ...
53 S_ABS = 0x001,
54 S_SABS = 0x002,
55 S_PREL = 0x003,
56 S_GOT = 0x004,
57 S_DTPREL = 0x005,
58 S_GOTTPREL = 0x006,
59 S_TPREL = 0x007,
60 S_TLSDESC = 0x008,
61 S_SECREL = 0x009,
62 S_AUTH = 0x00a,
63 S_AUTHADDR = 0x00b,
64 S_GOT_AUTH = 0x00c,
66 S_SymLocBits = 0x00f,
67
68 // Variants specifying which part of the final address calculation is
69 // used. E.g. the low 12 bits for an ADD/LDR, the middle 16 bits for a
70 // MOVZ/MOVK.
71 S_PAGE = 0x010,
72 S_PAGEOFF = 0x020,
73 S_HI12 = 0x030,
74 S_G0 = 0x040,
75 S_G1 = 0x050,
76 S_G2 = 0x060,
77 S_G3 = 0x070,
78 S_LO15 = 0x080,
80
81 // Whether the final relocation is a checked one (where a linker should
82 // perform a range-check on the final address) or not. Note that this field
83 // is unfortunately sometimes omitted from the assembly syntax. E.g. :lo12:
84 // on its own is a non-checked relocation. We side with ELF on being
85 // explicit about this!
86 S_NC = 0x100,
87
88 // Convenience definitions for referring to specific textual representations
89 // of relocation specifiers. Note that this means the "_NC" is sometimes
90 // omitted in line with assembly syntax here (S_LO12 rather than VK_LO12_NC
91 // since a user would write ":lo12:").
144
145 // ELF relocation specifiers in data directives:
146 S_PLT = 0x400,
149
150 // Mach-O @ relocation specifiers:
159
160 S_INVALID = 0xfff
161 // clang-format on
162};
163
164/// Return the string representation of the ELF relocation specifier
165/// (e.g. ":got:", ":lo12:").
167
169
171 return static_cast<Specifier>(S & AArch64::S_SymLocBits);
172}
173
175 return static_cast<Specifier>(S & AArch64::S_AddressFragBits);
176}
177
178inline bool isNotChecked(Specifier S) { return S & AArch64::S_NC; }
179} // namespace AArch64
180
181class AArch64AuthMCExpr final : public MCSpecifierExpr {
182 uint16_t Discriminator;
184
185 explicit AArch64AuthMCExpr(const MCExpr *Expr, uint16_t Discriminator,
186 AArch64PACKey::ID Key, bool HasAddressDiversity,
187 SMLoc Loc)
189 Expr, HasAddressDiversity ? AArch64::S_AUTHADDR : AArch64::S_AUTH,
190 Loc),
191 Discriminator(Discriminator), Key(Key) {}
192
193public:
194 static const AArch64AuthMCExpr *
195 create(const MCExpr *Expr, uint16_t Discriminator, AArch64PACKey::ID Key,
196 bool HasAddressDiversity, MCContext &Ctx, SMLoc Loc = SMLoc());
197
198 AArch64PACKey::ID getKey() const { return Key; }
199 uint16_t getDiscriminator() const { return Discriminator; }
200 bool hasAddressDiversity() const {
202 }
203
204 void print(raw_ostream &OS, const MCAsmInfo *MAI) const;
205
206 static bool classof(const MCExpr *E) {
207 auto *SE = dyn_cast<MCSpecifierExpr>(E);
208 return SE && (SE->getSpecifier() == AArch64::S_AUTH ||
209 SE->getSpecifier() == AArch64::S_AUTHADDR);
210 }
211};
212
213} // namespace llvm
214
215#endif
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static LVOptions Options
Definition LVOptions.cpp:25
#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())
MCAsmInfoDarwin(const MCTargetOptions &Options)
MCAsmInfoELF(const Triple &TT, const MCTargetOptions &Options)
MCAsmInfoGNUCOFF(const MCTargetOptions &Options)
MCAsmInfoMicrosoft(const MCTargetOptions &Options)
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition MCAsmInfo.h:69
Context object for machine code objects.
Definition MCContext.h:84
Base class for the full range of assembler expressions which are needed for parsing.
Definition MCExpr.h:31
const MCExpr * Expr
Definition MCExpr.h:493
MCSpecifierExpr(const MCExpr *Expr, Spec S, SMLoc Loc=SMLoc())
Definition MCExpr.h:495
Spec getSpecifier() const
Definition MCExpr.h:504
Streaming machine code generation interface.
Definition MCStreamer.h:221
Represents a location in source code.
Definition SMLoc.h:22
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:48
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.
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
AArch64MCAsmInfoDarwin(bool IsILP32, const MCTargetOptions &Options)
AArch64MCAsmInfoELF(const Triple &T, const MCTargetOptions &Options)
AArch64MCAsmInfoGNUCOFF(const MCTargetOptions &Options)
AArch64MCAsmInfoMicrosoftCOFF(const MCTargetOptions &Options)