clang 22.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 // Wasm address space values for this target are dummy values,
52 // as it is only enabled for Wasm targets.
53 20, // wasm_funcref
54};
55
56class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
57 static const TargetInfo::GCCRegAlias GCCRegAliases[];
58 static const char *const GCCRegNames[];
59
60 enum FPUModeEnum {
61 FPUMode = (1 << 0),
62 NeonMode = (1 << 1),
63 SveMode = (1 << 2),
64 };
65
66 unsigned FPU = FPUMode;
67 bool HasCRC = false;
68 bool HasCSSC = false;
69 bool HasAES = false;
70 bool HasSHA2 = false;
71 bool HasSHA3 = false;
72 bool HasSM4 = false;
73 bool HasFullFP16 = false;
74 bool HasDotProd = false;
75 bool HasFP16FML = false;
76 bool HasMTE = false;
77 bool HasPAuth = false;
78 bool HasLS64 = false;
79 bool HasRandGen = false;
80 bool HasMatMul = false;
81 bool HasBFloat16 = false;
82 bool HasSVE2 = false;
83 bool HasSVE2p1 = false;
84 bool HasSVEAES = false;
85 bool HasSVE2SHA3 = false;
86 bool HasSVE2SM4 = false;
87 bool HasSVEB16B16 = false;
88 bool HasSVEBitPerm = false;
89 bool HasMatmulFP64 = false;
90 bool HasMatmulFP32 = false;
91 bool HasLSE = false;
92 bool HasFlagM = false;
93 bool HasAlternativeNZCV = false;
94 bool HasMOPS = false;
95 bool HasD128 = false;
96 bool HasRCPC = false;
97 bool HasRDM = false;
98 bool HasDIT = false;
99 bool HasCCPP = false;
100 bool HasCCDP = false;
101 bool HasFRInt3264 = false;
102 bool HasSME = false;
103 bool HasSME2 = false;
104 bool HasSMEF64F64 = false;
105 bool HasSMEI16I64 = false;
106 bool HasSMEF16F16 = false;
107 bool HasSMEB16B16 = false;
108 bool HasSME2p1 = false;
109 bool HasFP8 = false;
110 bool HasFP8FMA = false;
111 bool HasFP8DOT2 = false;
112 bool HasFP8DOT4 = false;
113 bool HasSSVE_FP8DOT2 = false;
114 bool HasSSVE_FP8DOT4 = false;
115 bool HasSSVE_FP8FMA = false;
116 bool HasSME_F8F32 = false;
117 bool HasSME_F8F16 = false;
118 bool HasSB = false;
119 bool HasPredRes = false;
120 bool HasSSBS = false;
121 bool HasBTI = false;
122 bool HasWFxT = false;
123 bool HasJSCVT = false;
124 bool HasFCMA = false;
125 bool HasNoFP = false;
126 bool HasNoNeon = false;
127 bool HasNoSVE = false;
128 bool HasFMV = true;
129 bool HasGCS = false;
130 bool HasRCPC3 = false;
131 bool HasSMEFA64 = false;
132 bool HasPAuthLR = false;
133
134 const llvm::AArch64::ArchInfo *ArchInfo = &llvm::AArch64::ARMV8A;
135
136protected:
137 std::string ABI;
138
139public:
140 AArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
141
142 StringRef getABI() const override;
143 bool setABI(const std::string &Name) override;
144
145 bool validateBranchProtection(StringRef Spec, StringRef Arch,
147 const LangOptions &LO,
148 StringRef &Err) const override;
149
150 bool isValidCPUName(StringRef Name) const override;
151 void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
152 bool setCPU(const std::string &Name) override;
153
154 llvm::APInt getFMVPriority(ArrayRef<StringRef> Features) const override;
155
156 bool useFP16ConversionIntrinsics() const override {
157 return false;
158 }
159
160 void getTargetDefinesARMV81A(const LangOptions &Opts,
161 MacroBuilder &Builder) const;
162 void getTargetDefinesARMV82A(const LangOptions &Opts,
163 MacroBuilder &Builder) const;
164 void getTargetDefinesARMV83A(const LangOptions &Opts,
165 MacroBuilder &Builder) const;
166 void getTargetDefinesARMV84A(const LangOptions &Opts,
167 MacroBuilder &Builder) const;
168 void getTargetDefinesARMV85A(const LangOptions &Opts,
169 MacroBuilder &Builder) const;
170 void getTargetDefinesARMV86A(const LangOptions &Opts,
171 MacroBuilder &Builder) const;
172 void getTargetDefinesARMV87A(const LangOptions &Opts,
173 MacroBuilder &Builder) const;
174 void getTargetDefinesARMV88A(const LangOptions &Opts,
175 MacroBuilder &Builder) const;
176 void getTargetDefinesARMV89A(const LangOptions &Opts,
177 MacroBuilder &Builder) const;
178 void getTargetDefinesARMV9A(const LangOptions &Opts,
179 MacroBuilder &Builder) const;
180 void getTargetDefinesARMV91A(const LangOptions &Opts,
181 MacroBuilder &Builder) const;
182 void getTargetDefinesARMV92A(const LangOptions &Opts,
183 MacroBuilder &Builder) const;
184 void getTargetDefinesARMV93A(const LangOptions &Opts,
185 MacroBuilder &Builder) const;
186 void getTargetDefinesARMV94A(const LangOptions &Opts,
187 MacroBuilder &Builder) const;
188 void getTargetDefinesARMV95A(const LangOptions &Opts,
189 MacroBuilder &Builder) const;
190 void getTargetDefinesARMV96A(const LangOptions &Opts,
191 MacroBuilder &Builder) const;
192 void getTargetDefinesARMV97A(const LangOptions &Opts,
193 MacroBuilder &Builder) const;
194 void getTargetDefines(const LangOptions &Opts,
195 MacroBuilder &Builder) const override;
196
197 llvm::SmallVector<Builtin::InfosShard> getTargetBuiltins() const override;
198
199 std::optional<std::pair<unsigned, unsigned>>
200 getVScaleRange(const LangOptions &LangOpts, ArmStreamingKind Mode,
201 llvm::StringMap<bool> *FeatureMap = nullptr) const override;
202 bool doesFeatureAffectCodeGen(StringRef Name) const override;
203 bool validateCpuSupports(StringRef FeatureStr) const override;
204 bool hasFeature(StringRef Feature) const override;
205 void setFeatureEnabled(llvm::StringMap<bool> &Features, StringRef Name,
206 bool Enabled) const override;
207 bool handleTargetFeatures(std::vector<std::string> &Features,
208 DiagnosticsEngine &Diags) override;
209 ParsedTargetAttr parseTargetAttr(StringRef Str) const override;
210 bool supportsTargetAttributeTune() const override { return true; }
211 bool supportsCpuSupports() const override { return true; }
212 bool checkArithmeticFenceSupported() const override { return true; }
213
214 bool hasBFloat16Type() const override;
215
216 CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
217
218 bool isCLZForZeroUndef() const override;
219
220 BuiltinVaListKind getBuiltinVaListKind() const override;
221
222 ArrayRef<const char *> getGCCRegNames() const override;
223 ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;
224
225 std::string convertConstraint(const char *&Constraint) const override;
226
227 bool validateAsmConstraint(const char *&Name,
228 TargetInfo::ConstraintInfo &Info) const override;
229 bool
230 validateConstraintModifier(StringRef Constraint, char Modifier, unsigned Size,
231 std::string &SuggestedModifier) const override;
232 std::string_view getClobbers() const override;
233
234 StringRef getConstraintRegister(StringRef Constraint,
235 StringRef Expression) const override {
236 return Expression;
237 }
238
239 int getEHDataRegisterNumber(unsigned RegNo) const override;
240
241 bool validatePointerAuthKey(const llvm::APSInt &value) const override;
242
243 const char *getBFloat16Mangling() const override { return "u6__bf16"; };
244
245 std::pair<unsigned, unsigned> hardwareInterferenceSizes() const override {
246 return std::make_pair(256, 64);
247 }
248
249 bool hasInt128Type() const override;
250
251 bool hasBitIntType() const override { return true; }
252
253 bool validateTarget(DiagnosticsEngine &Diags) const override;
254
255 bool validateGlobalRegisterVariable(StringRef RegName, unsigned RegSize,
256 bool &HasSizeMismatch) const override;
257
258 uint64_t getPointerWidthV(LangAS AddrSpace) const override {
259 if (AddrSpace == LangAS::ptr32_sptr || AddrSpace == LangAS::ptr32_uptr)
260 return 32;
261 if (AddrSpace == LangAS::ptr64)
262 return 64;
263 return PointerWidth;
264 }
265
266 uint64_t getPointerAlignV(LangAS AddrSpace) const override {
267 return getPointerWidthV(AddrSpace);
268 }
269};
270
271class LLVM_LIBRARY_VISIBILITY AArch64leTargetInfo : public AArch64TargetInfo {
272public:
273 AArch64leTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
274
275 void getTargetDefines(const LangOptions &Opts,
276 MacroBuilder &Builder) const override;
277};
278
279template <>
280inline bool
282 if (Name == "pauthtest") {
283 ABI = Name;
284 return true;
285 }
286 return AArch64leTargetInfo::setABI(Name);
287}
288
289class LLVM_LIBRARY_VISIBILITY WindowsARM64TargetInfo
290 : public WindowsTargetInfo<AArch64leTargetInfo> {
291 const llvm::Triple Triple;
292
293public:
294 WindowsARM64TargetInfo(const llvm::Triple &Triple,
295 const TargetOptions &Opts);
296
298
300};
301
302// Windows ARM, MS (C++) ABI
303class LLVM_LIBRARY_VISIBILITY MicrosoftARM64TargetInfo
304 : public WindowsARM64TargetInfo {
305public:
306 MicrosoftARM64TargetInfo(const llvm::Triple &Triple,
307 const TargetOptions &Opts);
308
309 void getTargetDefines(const LangOptions &Opts,
310 MacroBuilder &Builder) const override;
312 getCallingConvKind(bool ClangABICompat4) const override;
313
314 unsigned getMinGlobalAlign(uint64_t TypeSize,
315 bool HasNonWeakDef) const override;
316};
317
318// ARM64 MinGW target
319class LLVM_LIBRARY_VISIBILITY MinGWARM64TargetInfo
320 : public WindowsARM64TargetInfo {
321public:
322 MinGWARM64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
323};
324
325class LLVM_LIBRARY_VISIBILITY AArch64beTargetInfo : public AArch64TargetInfo {
326public:
327 AArch64beTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
328 void getTargetDefines(const LangOptions &Opts,
329 MacroBuilder &Builder) const override;
330};
331
332void getAppleMachOAArch64Defines(MacroBuilder &Builder, const LangOptions &Opts,
333 const llvm::Triple &Triple);
334
335class LLVM_LIBRARY_VISIBILITY AppleMachOAArch64TargetInfo
336 : public AppleMachOTargetInfo<AArch64leTargetInfo> {
337public:
338 AppleMachOAArch64TargetInfo(const llvm::Triple &Triple,
339 const TargetOptions &Opts);
340
341protected:
342 void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
343 MacroBuilder &Builder) const override;
344};
345
346class LLVM_LIBRARY_VISIBILITY DarwinAArch64TargetInfo
347 : public DarwinTargetInfo<AArch64leTargetInfo> {
348public:
349 DarwinAArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
350
352
353 protected:
354 void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
355 MacroBuilder &Builder) const override;
356};
357
358} // namespace targets
359} // namespace clang
360
361#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:234
bool useFP16ConversionIntrinsics() const override
Check whether llvm intrinsics such as llvm.convert.to.fp16 should be used to convert to and from __fp...
Definition AArch64.h:156
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:245
uint64_t getPointerWidthV(LangAS AddrSpace) const override
Definition AArch64.h:258
bool supportsTargetAttributeTune() const override
Determine whether this TargetInfo supports tune in target attribute.
Definition AArch64.h:210
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:243
bool checkArithmeticFenceSupported() const override
Controls if __arithmetic_fence is supported in the targeted backend.
Definition AArch64.h:212
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:251
bool supportsCpuSupports() const override
Definition AArch64.h:211
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:266
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:1641
AArch64beTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition AArch64.cpp:1637
AArch64leTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition AArch64.cpp:1627
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods -----------------------—===//
Definition AArch64.cpp:1631
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, MacroBuilder &Builder) const override
Definition AArch64.cpp:1790
AppleMachOAArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition AArch64.cpp:1745
AppleMachOTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition OSTargets.h:54
DarwinAArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition AArch64.cpp:1749
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, MacroBuilder &Builder) const override
Definition AArch64.cpp:1798
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
Definition AArch64.cpp:1806
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:1720
MicrosoftARM64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition AArch64.cpp:1697
TargetInfo::CallingConvKind getCallingConvKind(bool ClangABICompat4) const override
Definition AArch64.cpp:1716
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods -----------------------—===//
Definition AArch64.cpp:1703
MinGWARM64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition AArch64.cpp:1739
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
Definition AArch64.cpp:1668
WindowsARM64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition AArch64.cpp:1649
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Determines whether a given calling convention is valid for the target.
Definition AArch64.cpp:1673
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:1773
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