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 virtual void setDataLayout() = 0;
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
135 const llvm::AArch64::ArchInfo *ArchInfo = &llvm::AArch64::ARMV8A;
136
137protected:
138 std::string ABI;
139
140public:
141 AArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
142
143 StringRef getABI() const override;
144 bool setABI(const std::string &Name) override;
145
146 bool validateBranchProtection(StringRef Spec, StringRef Arch,
148 const LangOptions &LO,
149 StringRef &Err) const override;
150
151 bool isValidCPUName(StringRef Name) const override;
152 void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
153 bool setCPU(const std::string &Name) override;
154
155 llvm::APInt getFMVPriority(ArrayRef<StringRef> Features) const override;
156
157 bool useFP16ConversionIntrinsics() const override {
158 return false;
159 }
160
161 void getTargetDefinesARMV81A(const LangOptions &Opts,
162 MacroBuilder &Builder) const;
163 void getTargetDefinesARMV82A(const LangOptions &Opts,
164 MacroBuilder &Builder) const;
165 void getTargetDefinesARMV83A(const LangOptions &Opts,
166 MacroBuilder &Builder) const;
167 void getTargetDefinesARMV84A(const LangOptions &Opts,
168 MacroBuilder &Builder) const;
169 void getTargetDefinesARMV85A(const LangOptions &Opts,
170 MacroBuilder &Builder) const;
171 void getTargetDefinesARMV86A(const LangOptions &Opts,
172 MacroBuilder &Builder) const;
173 void getTargetDefinesARMV87A(const LangOptions &Opts,
174 MacroBuilder &Builder) const;
175 void getTargetDefinesARMV88A(const LangOptions &Opts,
176 MacroBuilder &Builder) const;
177 void getTargetDefinesARMV89A(const LangOptions &Opts,
178 MacroBuilder &Builder) const;
179 void getTargetDefinesARMV9A(const LangOptions &Opts,
180 MacroBuilder &Builder) const;
181 void getTargetDefinesARMV91A(const LangOptions &Opts,
182 MacroBuilder &Builder) const;
183 void getTargetDefinesARMV92A(const LangOptions &Opts,
184 MacroBuilder &Builder) const;
185 void getTargetDefinesARMV93A(const LangOptions &Opts,
186 MacroBuilder &Builder) const;
187 void getTargetDefinesARMV94A(const LangOptions &Opts,
188 MacroBuilder &Builder) const;
189 void getTargetDefinesARMV95A(const LangOptions &Opts,
190 MacroBuilder &Builder) const;
191 void getTargetDefinesARMV96A(const LangOptions &Opts,
192 MacroBuilder &Builder) const;
193 void getTargetDefinesARMV97A(const LangOptions &Opts,
194 MacroBuilder &Builder) const;
195 void getTargetDefines(const LangOptions &Opts,
196 MacroBuilder &Builder) const override;
197
198 llvm::SmallVector<Builtin::InfosShard> getTargetBuiltins() const override;
199
200 std::optional<std::pair<unsigned, unsigned>>
201 getVScaleRange(const LangOptions &LangOpts, ArmStreamingKind Mode,
202 llvm::StringMap<bool> *FeatureMap = nullptr) const override;
203 bool doesFeatureAffectCodeGen(StringRef Name) const override;
204 bool validateCpuSupports(StringRef FeatureStr) const override;
205 bool hasFeature(StringRef Feature) const override;
206 void setFeatureEnabled(llvm::StringMap<bool> &Features, StringRef Name,
207 bool Enabled) const override;
208 bool handleTargetFeatures(std::vector<std::string> &Features,
209 DiagnosticsEngine &Diags) override;
210 ParsedTargetAttr parseTargetAttr(StringRef Str) const override;
211 bool supportsTargetAttributeTune() const override { return true; }
212 bool supportsCpuSupports() const override { return true; }
213 bool checkArithmeticFenceSupported() const override { return true; }
214
215 bool hasBFloat16Type() const override;
216
217 CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
218
219 bool isCLZForZeroUndef() const override;
220
221 BuiltinVaListKind getBuiltinVaListKind() const override;
222
223 ArrayRef<const char *> getGCCRegNames() const override;
224 ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;
225
226 std::string convertConstraint(const char *&Constraint) const override;
227
228 bool validateAsmConstraint(const char *&Name,
229 TargetInfo::ConstraintInfo &Info) const override;
230 bool
231 validateConstraintModifier(StringRef Constraint, char Modifier, unsigned Size,
232 std::string &SuggestedModifier) const override;
233 std::string_view getClobbers() const override;
234
235 StringRef getConstraintRegister(StringRef Constraint,
236 StringRef Expression) const override {
237 return Expression;
238 }
239
240 int getEHDataRegisterNumber(unsigned RegNo) const override;
241
242 bool validatePointerAuthKey(const llvm::APSInt &value) const override;
243
244 const char *getBFloat16Mangling() const override { return "u6__bf16"; };
245
246 std::pair<unsigned, unsigned> hardwareInterferenceSizes() const override {
247 return std::make_pair(256, 64);
248 }
249
250 bool hasInt128Type() const override;
251
252 bool hasBitIntType() const override { return true; }
253
254 bool validateTarget(DiagnosticsEngine &Diags) const override;
255
256 bool validateGlobalRegisterVariable(StringRef RegName, unsigned RegSize,
257 bool &HasSizeMismatch) const override;
258
259 uint64_t getPointerWidthV(LangAS AddrSpace) const override {
260 if (AddrSpace == LangAS::ptr32_sptr || AddrSpace == LangAS::ptr32_uptr)
261 return 32;
262 if (AddrSpace == LangAS::ptr64)
263 return 64;
264 return PointerWidth;
265 }
266
267 uint64_t getPointerAlignV(LangAS AddrSpace) const override {
268 return getPointerWidthV(AddrSpace);
269 }
270};
271
272class LLVM_LIBRARY_VISIBILITY AArch64leTargetInfo : public AArch64TargetInfo {
273public:
274 AArch64leTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
275
276 void getTargetDefines(const LangOptions &Opts,
277 MacroBuilder &Builder) const override;
278private:
279 void setDataLayout() override;
280};
281
282template <>
283inline bool
285 if (Name == "pauthtest") {
286 ABI = Name;
287 return true;
288 }
289 return AArch64leTargetInfo::setABI(Name);
290}
291
292class LLVM_LIBRARY_VISIBILITY WindowsARM64TargetInfo
293 : public WindowsTargetInfo<AArch64leTargetInfo> {
294 const llvm::Triple Triple;
295
296public:
297 WindowsARM64TargetInfo(const llvm::Triple &Triple,
298 const TargetOptions &Opts);
299
300 void setDataLayout() override;
301
303
305};
306
307// Windows ARM, MS (C++) ABI
308class LLVM_LIBRARY_VISIBILITY MicrosoftARM64TargetInfo
309 : public WindowsARM64TargetInfo {
310public:
311 MicrosoftARM64TargetInfo(const llvm::Triple &Triple,
312 const TargetOptions &Opts);
313
314 void getTargetDefines(const LangOptions &Opts,
315 MacroBuilder &Builder) const override;
317 getCallingConvKind(bool ClangABICompat4) const override;
318
319 unsigned getMinGlobalAlign(uint64_t TypeSize,
320 bool HasNonWeakDef) const override;
321};
322
323// ARM64 MinGW target
324class LLVM_LIBRARY_VISIBILITY MinGWARM64TargetInfo
325 : public WindowsARM64TargetInfo {
326public:
327 MinGWARM64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
328};
329
330class LLVM_LIBRARY_VISIBILITY AArch64beTargetInfo : public AArch64TargetInfo {
331public:
332 AArch64beTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
333 void getTargetDefines(const LangOptions &Opts,
334 MacroBuilder &Builder) const override;
335
336private:
337 void setDataLayout() override;
338};
339
340void getAppleMachOAArch64Defines(MacroBuilder &Builder, const LangOptions &Opts,
341 const llvm::Triple &Triple);
342
343class LLVM_LIBRARY_VISIBILITY AppleMachOAArch64TargetInfo
344 : public AppleMachOTargetInfo<AArch64leTargetInfo> {
345public:
346 AppleMachOAArch64TargetInfo(const llvm::Triple &Triple,
347 const TargetOptions &Opts);
348
349protected:
350 void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
351 MacroBuilder &Builder) const override;
352};
353
354class LLVM_LIBRARY_VISIBILITY DarwinAArch64TargetInfo
355 : public DarwinTargetInfo<AArch64leTargetInfo> {
356public:
357 DarwinAArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
358
360
361 protected:
362 void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
363 MacroBuilder &Builder) const override;
364};
365
366} // namespace targets
367} // namespace clang
368
369#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:331
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:235
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:157
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:246
uint64_t getPointerWidthV(LangAS AddrSpace) const override
Definition AArch64.h:259
bool supportsTargetAttributeTune() const override
Determine whether this TargetInfo supports tune in target attribute.
Definition AArch64.h:211
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:244
bool checkArithmeticFenceSupported() const override
Controls if __arithmetic_fence is supported in the targeted backend.
Definition AArch64.h:213
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:252
bool supportsCpuSupports() const override
Definition AArch64.h:212
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:267
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:1656
AArch64beTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition AArch64.cpp:1652
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:1646
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, MacroBuilder &Builder) const override
Definition AArch64.cpp:1820
AppleMachOAArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition AArch64.cpp:1775
AppleMachOTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition OSTargets.h:54
DarwinAArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition AArch64.cpp:1779
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, MacroBuilder &Builder) const override
Definition AArch64.cpp:1828
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
Definition AArch64.cpp:1836
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:1750
MicrosoftARM64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition AArch64.cpp:1727
TargetInfo::CallingConvKind getCallingConvKind(bool ClangABICompat4) const override
Definition AArch64.cpp:1746
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods -----------------------—===//
Definition AArch64.cpp:1733
MinGWARM64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition AArch64.cpp:1769
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
Definition AArch64.cpp:1698
WindowsARM64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition AArch64.cpp:1670
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Determines whether a given calling convention is valid for the target.
Definition AArch64.cpp:1703
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:1803
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