clang 20.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 // Wasm address space values for this target are dummy values,
48 // as it is only enabled for Wasm targets.
49 20, // wasm_funcref
50};
51
52class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
53 virtual void setDataLayout() = 0;
54 static const TargetInfo::GCCRegAlias GCCRegAliases[];
55 static const char *const GCCRegNames[];
56
57 enum FPUModeEnum {
58 FPUMode = (1 << 0),
59 NeonMode = (1 << 1),
60 SveMode = (1 << 2),
61 };
62
63 unsigned FPU = FPUMode;
64 bool HasCRC = false;
65 bool HasAES = false;
66 bool HasSHA2 = false;
67 bool HasSHA3 = false;
68 bool HasSM4 = false;
69 bool HasFullFP16 = false;
70 bool HasDotProd = false;
71 bool HasFP16FML = false;
72 bool HasMTE = false;
73 bool HasTME = false;
74 bool HasPAuth = false;
75 bool HasLS64 = false;
76 bool HasRandGen = false;
77 bool HasMatMul = false;
78 bool HasBFloat16 = false;
79 bool HasSVE2 = false;
80 bool HasSVE2p1 = false;
81 bool HasSVEAES = false;
82 bool HasSVE2SHA3 = false;
83 bool HasSVE2SM4 = false;
84 bool HasSVEB16B16 = false;
85 bool HasSVE2BitPerm = false;
86 bool HasMatmulFP64 = false;
87 bool HasMatmulFP32 = false;
88 bool HasLSE = false;
89 bool HasFlagM = false;
90 bool HasAlternativeNZCV = false;
91 bool HasMOPS = false;
92 bool HasD128 = false;
93 bool HasRCPC = false;
94 bool HasRDM = false;
95 bool HasDIT = false;
96 bool HasCCPP = false;
97 bool HasCCDP = false;
98 bool HasFRInt3264 = false;
99 bool HasSME = false;
100 bool HasSME2 = false;
101 bool HasSMEF64F64 = false;
102 bool HasSMEI16I64 = false;
103 bool HasSMEF16F16 = false;
104 bool HasSMEB16B16 = false;
105 bool HasSME2p1 = false;
106 bool HasSB = false;
107 bool HasPredRes = false;
108 bool HasSSBS = false;
109 bool HasBTI = false;
110 bool HasWFxT = false;
111 bool HasJSCVT = false;
112 bool HasFCMA = false;
113 bool HasNoFP = false;
114 bool HasNoNeon = false;
115 bool HasNoSVE = false;
116 bool HasFMV = true;
117 bool HasGCS = false;
118 bool HasRCPC3 = false;
119 bool HasSMEFA64 = false;
120 bool HasPAuthLR = false;
121
122 const llvm::AArch64::ArchInfo *ArchInfo = &llvm::AArch64::ARMV8A;
123
124 std::string ABI;
125
126public:
127 AArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
128
129 StringRef getABI() const override;
130 bool setABI(const std::string &Name) override;
131
132 bool validateBranchProtection(StringRef Spec, StringRef Arch,
134 StringRef &Err) const override;
135
136 bool isValidCPUName(StringRef Name) const override;
137 void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
138 bool setCPU(const std::string &Name) override;
139
140 unsigned getFMVPriority(ArrayRef<StringRef> Features) const override;
141
142 bool useFP16ConversionIntrinsics() const override {
143 return false;
144 }
145
146 void setArchFeatures();
147
148 void getTargetDefinesARMV81A(const LangOptions &Opts,
149 MacroBuilder &Builder) const;
150 void getTargetDefinesARMV82A(const LangOptions &Opts,
151 MacroBuilder &Builder) const;
152 void getTargetDefinesARMV83A(const LangOptions &Opts,
153 MacroBuilder &Builder) const;
154 void getTargetDefinesARMV84A(const LangOptions &Opts,
155 MacroBuilder &Builder) const;
156 void getTargetDefinesARMV85A(const LangOptions &Opts,
157 MacroBuilder &Builder) const;
158 void getTargetDefinesARMV86A(const LangOptions &Opts,
159 MacroBuilder &Builder) const;
160 void getTargetDefinesARMV87A(const LangOptions &Opts,
161 MacroBuilder &Builder) const;
162 void getTargetDefinesARMV88A(const LangOptions &Opts,
163 MacroBuilder &Builder) const;
164 void getTargetDefinesARMV89A(const LangOptions &Opts,
165 MacroBuilder &Builder) const;
166 void getTargetDefinesARMV9A(const LangOptions &Opts,
167 MacroBuilder &Builder) const;
168 void getTargetDefinesARMV91A(const LangOptions &Opts,
169 MacroBuilder &Builder) const;
170 void getTargetDefinesARMV92A(const LangOptions &Opts,
171 MacroBuilder &Builder) const;
172 void getTargetDefinesARMV93A(const LangOptions &Opts,
173 MacroBuilder &Builder) const;
174 void getTargetDefinesARMV94A(const LangOptions &Opts,
175 MacroBuilder &Builder) const;
176 void getTargetDefinesARMV95A(const LangOptions &Opts,
177 MacroBuilder &Builder) const;
178 void getTargetDefinesARMV96A(const LangOptions &Opts,
179 MacroBuilder &Builder) const;
180 void getTargetDefines(const LangOptions &Opts,
181 MacroBuilder &Builder) const override;
182
183 ArrayRef<Builtin::Info> getTargetBuiltins() const override;
184
185 std::optional<std::pair<unsigned, unsigned>>
186 getVScaleRange(const LangOptions &LangOpts) const override;
187 bool doesFeatureAffectCodeGen(StringRef Name) const override;
188 bool validateCpuSupports(StringRef FeatureStr) const override;
189 bool hasFeature(StringRef Feature) const override;
190 void setFeatureEnabled(llvm::StringMap<bool> &Features, StringRef Name,
191 bool Enabled) const override;
192 bool handleTargetFeatures(std::vector<std::string> &Features,
193 DiagnosticsEngine &Diags) override;
194 ParsedTargetAttr parseTargetAttr(StringRef Str) const override;
195 bool supportsTargetAttributeTune() const override { return true; }
196 bool supportsCpuSupports() const override { return true; }
197 bool checkArithmeticFenceSupported() const override { return true; }
198
199 bool hasBFloat16Type() const override;
200
201 CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
202
203 bool isCLZForZeroUndef() const override;
204
205 BuiltinVaListKind getBuiltinVaListKind() const override;
206
207 ArrayRef<const char *> getGCCRegNames() const override;
208 ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;
209
210 std::string convertConstraint(const char *&Constraint) const override;
211
212 bool validateAsmConstraint(const char *&Name,
213 TargetInfo::ConstraintInfo &Info) const override;
214 bool
215 validateConstraintModifier(StringRef Constraint, char Modifier, unsigned Size,
216 std::string &SuggestedModifier) const override;
217 std::string_view getClobbers() const override;
218
219 StringRef getConstraintRegister(StringRef Constraint,
220 StringRef Expression) const override {
221 return Expression;
222 }
223
224 int getEHDataRegisterNumber(unsigned RegNo) const override;
225
226 bool validatePointerAuthKey(const llvm::APSInt &value) const override;
227
228 const char *getBFloat16Mangling() const override { return "u6__bf16"; };
229 bool hasInt128Type() const override;
230
231 bool hasBitIntType() const override { return true; }
232
233 bool validateTarget(DiagnosticsEngine &Diags) const override;
234
235 bool validateGlobalRegisterVariable(StringRef RegName, unsigned RegSize,
236 bool &HasSizeMismatch) const override;
237
238 uint64_t getPointerWidthV(LangAS AddrSpace) const override {
239 if (AddrSpace == LangAS::ptr32_sptr || AddrSpace == LangAS::ptr32_uptr)
240 return 32;
241 if (AddrSpace == LangAS::ptr64)
242 return 64;
243 return PointerWidth;
244 }
245
246 uint64_t getPointerAlignV(LangAS AddrSpace) const override {
247 return getPointerWidthV(AddrSpace);
248 }
249};
250
251class LLVM_LIBRARY_VISIBILITY AArch64leTargetInfo : public AArch64TargetInfo {
252public:
253 AArch64leTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
254
255 void getTargetDefines(const LangOptions &Opts,
256 MacroBuilder &Builder) const override;
257private:
258 void setDataLayout() override;
259};
260
261class LLVM_LIBRARY_VISIBILITY WindowsARM64TargetInfo
262 : public WindowsTargetInfo<AArch64leTargetInfo> {
263 const llvm::Triple Triple;
264
265public:
266 WindowsARM64TargetInfo(const llvm::Triple &Triple,
267 const TargetOptions &Opts);
268
269 void setDataLayout() override;
270
271 BuiltinVaListKind getBuiltinVaListKind() const override;
272
273 CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
274};
275
276// Windows ARM, MS (C++) ABI
277class LLVM_LIBRARY_VISIBILITY MicrosoftARM64TargetInfo
278 : public WindowsARM64TargetInfo {
279public:
280 MicrosoftARM64TargetInfo(const llvm::Triple &Triple,
281 const TargetOptions &Opts);
282
283 void getTargetDefines(const LangOptions &Opts,
284 MacroBuilder &Builder) const override;
286 getCallingConvKind(bool ClangABICompat4) const override;
287
288 unsigned getMinGlobalAlign(uint64_t TypeSize,
289 bool HasNonWeakDef) const override;
290};
291
292// ARM64 MinGW target
293class LLVM_LIBRARY_VISIBILITY MinGWARM64TargetInfo
294 : public WindowsARM64TargetInfo {
295public:
296 MinGWARM64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
297};
298
299class LLVM_LIBRARY_VISIBILITY AArch64beTargetInfo : public AArch64TargetInfo {
300public:
301 AArch64beTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
302 void getTargetDefines(const LangOptions &Opts,
303 MacroBuilder &Builder) const override;
304
305private:
306 void setDataLayout() override;
307};
308
309class LLVM_LIBRARY_VISIBILITY DarwinAArch64TargetInfo
310 : public DarwinTargetInfo<AArch64leTargetInfo> {
311public:
312 DarwinAArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
313
314 BuiltinVaListKind getBuiltinVaListKind() const override;
315
316 protected:
317 void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
318 MacroBuilder &Builder) const override;
319};
320
321} // namespace targets
322} // namespace clang
323
324#endif // LLVM_CLANG_LIB_BASIC_TARGETS_AARCH64_H
static unsigned 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:96
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:231
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:499
Exposes information about the current target.
Definition: TargetInfo.h:220
Options for controlling the target.
Definition: TargetOptions.h:26
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:219
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:142
uint64_t getPointerWidthV(LangAS AddrSpace) const override
Definition: AArch64.h:238
bool supportsTargetAttributeTune() const override
Determine whether this TargetInfo supports tune in target attribute.
Definition: AArch64.h:195
const char * getBFloat16Mangling() const override
Return the mangled code of bfloat.
Definition: AArch64.h:228
bool checkArithmeticFenceSupported() const override
Controls if __arithmetic_fence is supported in the targeted backend.
Definition: AArch64.h:197
bool hasBitIntType() const override
Determine whether the _BitInt type is supported on this target.
Definition: AArch64.h:231
bool supportsCpuSupports() const override
Definition: AArch64.h:196
uint64_t getPointerAlignV(LangAS AddrSpace) const override
Definition: AArch64.h:246
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.
Definition: AddressSpaces.h:25
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:58