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