clang 23.0.0git
AArch64.h
Go to the documentation of this file.
1//===--- AArch64.h - Declare AArch64 target feature support -----*- 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 declares AArch64 TargetInfo objects.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_AARCH64_H
14#define LLVM_CLANG_LIB_BASIC_TARGETS_AARCH64_H
15
16#include "OSTargets.h"
18#include "llvm/TargetParser/AArch64TargetParser.h"
19#include <optional>
20
21namespace clang {
22namespace targets {
23
24enum AArch64AddrSpace { ptr32_sptr = 270, ptr32_uptr = 271, ptr64 = 272 };
25
26static const unsigned ARM64AddrSpaceMap[] = {
27 0, // Default
28 0, // opencl_global
29 0, // opencl_local
30 0, // opencl_constant
31 0, // opencl_private
32 0, // opencl_generic
33 0, // opencl_global_device
34 0, // opencl_global_host
35 0, // cuda_device
36 0, // cuda_constant
37 0, // cuda_shared
38 0, // sycl_global
39 0, // sycl_global_device
40 0, // sycl_global_host
41 0, // sycl_local
42 0, // sycl_private
43 static_cast<unsigned>(AArch64AddrSpace::ptr32_sptr),
44 static_cast<unsigned>(AArch64AddrSpace::ptr32_uptr),
45 static_cast<unsigned>(AArch64AddrSpace::ptr64),
46 0, // hlsl_groupshared
47 0, // hlsl_constant
48 0, // hlsl_private
49 0, // hlsl_device
50 0, // hlsl_input
51 0, // hlsl_push_constant
52 // Wasm address space values for this target are dummy values,
53 // as it is only enabled for Wasm targets.
54 20, // wasm_funcref
55};
56
57class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
58 static const TargetInfo::GCCRegAlias GCCRegAliases[];
59 static const char *const GCCRegNames[];
60
61 enum FPUModeEnum {
62 FPUMode = (1 << 0),
63 NeonMode = (1 << 1),
64 SveMode = (1 << 2),
65 };
66
67 unsigned FPU = FPUMode;
68 bool HasCRC = false;
69 bool HasCSSC = false;
70 bool HasAES = false;
71 bool HasSHA2 = false;
72 bool HasSHA3 = false;
73 bool HasSM4 = false;
74 bool HasFullFP16 = false;
75 bool HasDotProd = false;
76 bool HasFP16FML = false;
77 bool HasMTE = false;
78 bool HasPAuth = false;
79 bool HasLS64 = false;
80 bool HasRandGen = false;
81 bool HasMatMul = false;
82 bool HasBFloat16 = false;
83 bool HasSVE2 = false;
84 bool HasSVE2p1 = false;
85 bool HasSVEAES = false;
86 bool HasSVE2SHA3 = false;
87 bool HasSVE2SM4 = false;
88 bool HasSVEB16B16 = false;
89 bool HasSVEBitPerm = false;
90 bool HasMatmulFP64 = false;
91 bool HasMatmulFP32 = false;
92 bool HasLSE = false;
93 bool HasFlagM = false;
94 bool HasAlternativeNZCV = false;
95 bool HasMOPS = false;
96 bool HasD128 = false;
97 bool HasRCPC = false;
98 bool HasRDM = false;
99 bool HasDIT = false;
100 bool HasCCPP = false;
101 bool HasCCDP = false;
102 bool HasFRInt3264 = false;
103 bool HasSME = false;
104 bool HasSME2 = false;
105 bool HasSMEF64F64 = false;
106 bool HasSMEI16I64 = false;
107 bool HasSMEF16F16 = false;
108 bool HasSMEB16B16 = false;
109 bool HasSME2p1 = false;
110 bool HasFP8 = false;
111 bool HasFP8FMA = false;
112 bool HasFP8DOT2 = false;
113 bool HasFP8DOT4 = false;
114 bool HasSSVE_FP8DOT2 = false;
115 bool HasSSVE_FP8DOT4 = false;
116 bool HasSSVE_FP8FMA = false;
117 bool HasSME_F8F32 = false;
118 bool HasSME_F8F16 = false;
119 bool HasSB = false;
120 bool HasPredRes = false;
121 bool HasSSBS = false;
122 bool HasBTI = false;
123 bool HasWFxT = false;
124 bool HasJSCVT = false;
125 bool HasFCMA = false;
126 bool HasNoFP = false;
127 bool HasNoNeon = false;
128 bool HasNoSVE = false;
129 bool HasFMV = true;
130 bool HasGCS = false;
131 bool HasRCPC3 = false;
132 bool HasSMEFA64 = false;
133 bool HasPAuthLR = false;
134 bool HasFPRCVT = false;
135 bool HasF8F16MM = false;
136 bool HasF8F32MM = false;
137 bool HasSVE_F16F32MM = false;
138 bool HasSVE_BFSCALE = false;
139 bool HasSVE_AES2 = false;
140 bool HasSSVE_AES = false;
141 bool HasSVE2p2 = false;
142 bool HasSME2p2 = false;
143
144 const llvm::AArch64::ArchInfo *ArchInfo = &llvm::AArch64::ARMV8A;
145
146protected:
147 std::string ABI;
148
149public:
150 AArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
151
152 StringRef getABI() const override;
153 bool setABI(const std::string &Name) override;
154
155 bool validateBranchProtection(StringRef Spec, StringRef Arch,
157 const LangOptions &LO,
158 StringRef &Err) const override;
159
160 bool isValidCPUName(StringRef Name) const override;
161 void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
162 bool setCPU(const std::string &Name) override;
163
164 llvm::APInt getFMVPriority(ArrayRef<StringRef> Features) const override;
165
166 bool useFP16ConversionIntrinsics() const override {
167 return false;
168 }
169
170 void getTargetDefinesARMV81A(const LangOptions &Opts,
171 MacroBuilder &Builder) const;
172 void getTargetDefinesARMV82A(const LangOptions &Opts,
173 MacroBuilder &Builder) const;
174 void getTargetDefinesARMV83A(const LangOptions &Opts,
175 MacroBuilder &Builder) const;
176 void getTargetDefinesARMV84A(const LangOptions &Opts,
177 MacroBuilder &Builder) const;
178 void getTargetDefinesARMV85A(const LangOptions &Opts,
179 MacroBuilder &Builder) const;
180 void getTargetDefinesARMV86A(const LangOptions &Opts,
181 MacroBuilder &Builder) const;
182 void getTargetDefinesARMV87A(const LangOptions &Opts,
183 MacroBuilder &Builder) const;
184 void getTargetDefinesARMV88A(const LangOptions &Opts,
185 MacroBuilder &Builder) const;
186 void getTargetDefinesARMV89A(const LangOptions &Opts,
187 MacroBuilder &Builder) const;
188 void getTargetDefinesARMV9A(const LangOptions &Opts,
189 MacroBuilder &Builder) const;
190 void getTargetDefinesARMV91A(const LangOptions &Opts,
191 MacroBuilder &Builder) const;
192 void getTargetDefinesARMV92A(const LangOptions &Opts,
193 MacroBuilder &Builder) const;
194 void getTargetDefinesARMV93A(const LangOptions &Opts,
195 MacroBuilder &Builder) const;
196 void getTargetDefinesARMV94A(const LangOptions &Opts,
197 MacroBuilder &Builder) const;
198 void getTargetDefinesARMV95A(const LangOptions &Opts,
199 MacroBuilder &Builder) const;
200 void getTargetDefinesARMV96A(const LangOptions &Opts,
201 MacroBuilder &Builder) const;
202 void getTargetDefinesARMV97A(const LangOptions &Opts,
203 MacroBuilder &Builder) const;
204 void getTargetDefines(const LangOptions &Opts,
205 MacroBuilder &Builder) const override;
206
207 llvm::SmallVector<Builtin::InfosShard> getTargetBuiltins() const override;
208
209 std::optional<std::pair<unsigned, unsigned>>
210 getVScaleRange(const LangOptions &LangOpts, ArmStreamingKind Mode,
211 llvm::StringMap<bool> *FeatureMap = nullptr) const override;
212 bool doesFeatureAffectCodeGen(StringRef Name) const override;
213 bool validateCpuSupports(StringRef FeatureStr) const override;
214 bool hasFeature(StringRef Feature) const override;
215 void setFeatureEnabled(llvm::StringMap<bool> &Features, StringRef Name,
216 bool Enabled) const override;
217 bool handleTargetFeatures(std::vector<std::string> &Features,
218 DiagnosticsEngine &Diags) override;
219 ParsedTargetAttr parseTargetAttr(StringRef Str) const override;
220 bool supportsTargetAttributeTune() const override { return true; }
221 bool supportsCpuSupports() const override { return true; }
222 bool checkArithmeticFenceSupported() const override { return true; }
223
224 bool hasBFloat16Type() const override;
225
226 CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
227
228 bool isCLZForZeroUndef() const override;
229
230 BuiltinVaListKind getBuiltinVaListKind() const override;
231
232 ArrayRef<const char *> getGCCRegNames() const override;
233 ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;
234
235 std::string convertConstraint(const char *&Constraint) const override;
236
237 bool validateAsmConstraint(const char *&Name,
238 TargetInfo::ConstraintInfo &Info) const override;
239 bool
240 validateConstraintModifier(StringRef Constraint, char Modifier, unsigned Size,
241 std::string &SuggestedModifier) const override;
242 std::string_view getClobbers() const override;
243
244 StringRef getConstraintRegister(StringRef Constraint,
245 StringRef Expression) const override {
246 return Expression;
247 }
248
249 int getEHDataRegisterNumber(unsigned RegNo) const override;
250
251 bool validatePointerAuthKey(const llvm::APSInt &value) const override;
252
253 const char *getBFloat16Mangling() const override { return "u6__bf16"; };
254
255 std::pair<unsigned, unsigned> hardwareInterferenceSizes() const override {
256 return std::make_pair(256, 64);
257 }
258
259 bool hasInt128Type() const override;
260
261 bool hasBitIntType() const override { return true; }
262
263 bool validateTarget(DiagnosticsEngine &Diags) const override;
264
265 bool validateGlobalRegisterVariable(StringRef RegName, unsigned RegSize,
266 bool &HasSizeMismatch) const override;
267
268 uint64_t getPointerWidthV(LangAS AddrSpace) const override {
269 if (AddrSpace == LangAS::ptr32_sptr || AddrSpace == LangAS::ptr32_uptr)
270 return 32;
271 if (AddrSpace == LangAS::ptr64)
272 return 64;
273 return PointerWidth;
274 }
275
276 uint64_t getPointerAlignV(LangAS AddrSpace) const override {
277 return getPointerWidthV(AddrSpace);
278 }
279};
280
281class LLVM_LIBRARY_VISIBILITY AArch64leTargetInfo : public AArch64TargetInfo {
282public:
283 AArch64leTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
284
285 void getTargetDefines(const LangOptions &Opts,
286 MacroBuilder &Builder) const override;
287};
288
289template <>
290inline bool
292 if (Name == "pauthtest") {
293 ABI = Name;
294 return true;
295 }
296 return AArch64leTargetInfo::setABI(Name);
297}
298
299class LLVM_LIBRARY_VISIBILITY WindowsARM64TargetInfo
300 : public WindowsTargetInfo<AArch64leTargetInfo> {
301 const llvm::Triple Triple;
302
303public:
304 WindowsARM64TargetInfo(const llvm::Triple &Triple,
305 const TargetOptions &Opts);
306
308
310};
311
312// Windows ARM, MS (C++) ABI
313class LLVM_LIBRARY_VISIBILITY MicrosoftARM64TargetInfo
314 : public WindowsARM64TargetInfo {
315public:
316 MicrosoftARM64TargetInfo(const llvm::Triple &Triple,
317 const TargetOptions &Opts);
318
319 void getTargetDefines(const LangOptions &Opts,
320 MacroBuilder &Builder) const override;
322 getCallingConvKind(bool ClangABICompat4) const override;
323
324 unsigned getMinGlobalAlign(uint64_t TypeSize,
325 bool HasNonWeakDef) const override;
326};
327
328// ARM64 MinGW target
329class LLVM_LIBRARY_VISIBILITY MinGWARM64TargetInfo
330 : public WindowsARM64TargetInfo {
331public:
332 MinGWARM64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
333};
334
335class LLVM_LIBRARY_VISIBILITY AArch64beTargetInfo : public AArch64TargetInfo {
336public:
337 AArch64beTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
338 void getTargetDefines(const LangOptions &Opts,
339 MacroBuilder &Builder) const override;
340};
341
342void getAppleMachOAArch64Defines(MacroBuilder &Builder, const LangOptions &Opts,
343 const llvm::Triple &Triple);
344
345class LLVM_LIBRARY_VISIBILITY AppleMachOAArch64TargetInfo
346 : public AppleMachOTargetInfo<AArch64leTargetInfo> {
347public:
348 AppleMachOAArch64TargetInfo(const llvm::Triple &Triple,
349 const TargetOptions &Opts);
350
351protected:
352 void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
353 MacroBuilder &Builder) const override;
354};
355
356class LLVM_LIBRARY_VISIBILITY DarwinAArch64TargetInfo
357 : public DarwinTargetInfo<AArch64leTargetInfo> {
358public:
359 DarwinAArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
360
362
363 protected:
364 void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
365 MacroBuilder &Builder) const override;
366};
367
368} // namespace targets
369} // namespace clang
370
371#endif // LLVM_CLANG_LIB_BASIC_TARGETS_AARCH64_H
static llvm::APInt getFMVPriority(const TargetInfo &TI, const CodeGenFunction::FMVResolverOption &RO)
static bool hasFeature(StringRef Feature, const LangOptions &LangOpts, const TargetInfo &Target)
Determine whether a translation unit built using the current language options has the given feature.
Definition Module.cpp:95
Enumerates target-specific builtins in their own namespaces within namespace clang.
Concrete class used by the front-end to report problems and issues.
Definition Diagnostic.h:232
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
TargetInfo(const llvm::Triple &T)
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
Definition TargetInfo.h:333
virtual bool setABI(const std::string &Name)
Use the specified ABI.
Options for controlling the target.
StringRef getConstraintRegister(StringRef Constraint, StringRef Expression) const override
Extracts a register from the passed constraint (if it is a single-register constraint) and the asm la...
Definition AArch64.h:244
bool useFP16ConversionIntrinsics() const override
Check whether conversions to and from __fp16 should go through an integer bitcast with i16.
Definition AArch64.h:166
std::pair< unsigned, unsigned > hardwareInterferenceSizes() const override
The first value in the pair is the minimum offset between two objects to avoid false sharing (destruc...
Definition AArch64.h:255
uint64_t getPointerWidthV(LangAS AddrSpace) const override
Definition AArch64.h:268
bool supportsTargetAttributeTune() const override
Determine whether this TargetInfo supports tune in target attribute.
Definition AArch64.h:220
AArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition AArch64.cpp:128
const char * getBFloat16Mangling() const override
Return the mangled code of bfloat.
Definition AArch64.h:253
bool checkArithmeticFenceSupported() const override
Controls if __arithmetic_fence is supported in the targeted backend.
Definition AArch64.h:222
bool setABI(const std::string &Name) override
Use the specified ABI.
Definition AArch64.cpp:208
bool isValidCPUName(StringRef Name) const override
Determine whether this TargetInfo supports the given CPU name.
Definition AArch64.cpp:279
void fillValidCPUList(SmallVectorImpl< StringRef > &Values) const override
Fill a SmallVectorImpl with the valid values to setCPU.
Definition AArch64.cpp:287
StringRef getABI() const override
Get the ABI currently in use.
Definition AArch64.cpp:206
bool hasBitIntType() const override
Determine whether the _BitInt type is supported on this target.
Definition AArch64.h:261
bool supportsCpuSupports() const override
Definition AArch64.h:221
bool validateBranchProtection(StringRef Spec, StringRef Arch, BranchProtectionInfo &BPI, const LangOptions &LO, StringRef &Err) const override
Determine if this TargetInfo supports the given branch protection specification.
Definition AArch64.cpp:247
uint64_t getPointerAlignV(LangAS AddrSpace) const override
Definition AArch64.h:276
bool setCPU(const std::string &Name) override
Target the specified CPU.
Definition AArch64.cpp:283
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods -----------------------—===//
Definition AArch64.cpp:1701
AArch64beTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition AArch64.cpp:1697
AArch64leTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition AArch64.cpp:1687
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods -----------------------—===//
Definition AArch64.cpp:1691
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, MacroBuilder &Builder) const override
Definition AArch64.cpp:1850
AppleMachOAArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition AArch64.cpp:1805
AppleMachOTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition OSTargets.h:54
DarwinAArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition AArch64.cpp:1809
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, MacroBuilder &Builder) const override
Definition AArch64.cpp:1858
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
Definition AArch64.cpp:1866
DarwinTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition OSTargets.h:78
bool setABI(const std::string &Name) override
Definition OSTargets.h:414
unsigned getMinGlobalAlign(uint64_t TypeSize, bool HasNonWeakDef) const override
getMinGlobalAlign - Return the minimum alignment of a global variable, unless its alignment is explic...
Definition AArch64.cpp:1780
MicrosoftARM64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition AArch64.cpp:1757
TargetInfo::CallingConvKind getCallingConvKind(bool ClangABICompat4) const override
Definition AArch64.cpp:1776
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods -----------------------—===//
Definition AArch64.cpp:1763
MinGWARM64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition AArch64.cpp:1799
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
Definition AArch64.cpp:1728
WindowsARM64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition AArch64.cpp:1709
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Determines whether a given calling convention is valid for the target.
Definition AArch64.cpp:1733
WindowsTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition OSTargets.h:882
void getAppleMachOAArch64Defines(MacroBuilder &Builder, const LangOptions &Opts, const llvm::Triple &Triple)
Definition AArch64.cpp:1833
static const unsigned ARM64AddrSpaceMap[]
Definition AArch64.h:26
The JSON file list parser is used to communicate input to InstallAPI.
LangAS
Defines the address space values used by the address space qualifier of QualType.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition Specifiers.h:278
Contains information gathered from parsing the contents of TargetAttr.
Definition TargetInfo.h:60