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"
17#include "clang/Basic/TargetBuiltins.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 HasSVE2AES = false;
53 bool HasSVE2SHA3 = false;
54 bool HasSVE2SM4 = false;
55 bool HasSVE2BitPerm = false;
56 bool HasMatmulFP64 = false;
57 bool HasMatmulFP32 = false;
58 bool HasLSE = false;
59 bool HasFlagM = false;
60 bool HasAlternativeNZCV = false;
61 bool HasMOPS = false;
62 bool HasD128 = false;
63 bool HasRCPC = false;
64 bool HasRDM = false;
65 bool HasDIT = false;
66 bool HasCCPP = false;
67 bool HasCCDP = false;
68 bool HasFRInt3264 = false;
69 bool HasSME = false;
70 bool HasSME2 = false;
71 bool HasSMEF64F64 = false;
72 bool HasSMEI16I64 = false;
73 bool HasSB = false;
74 bool HasPredRes = false;
75 bool HasSSBS = false;
76 bool HasBTI = false;
77 bool HasWFxT = false;
78 bool HasJSCVT = false;
79 bool HasFCMA = false;
80 bool HasNoFP = false;
81 bool HasNoNeon = false;
82 bool HasNoSVE = false;
83 bool HasFMV = true;
84 bool HasGCS = false;
85 bool HasRCPC3 = false;
86 bool HasSMEFA64 = false;
87 bool HasPAuthLR = false;
88
89 const llvm::AArch64::ArchInfo *ArchInfo = &llvm::AArch64::ARMV8A;
90
91 std::string ABI;
92
93public:
94 AArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
95
96 StringRef getABI() const override;
97 bool setABI(const std::string &Name) override;
98
99 bool validateBranchProtection(StringRef Spec, StringRef Arch,
100 BranchProtectionInfo &BPI,
101 StringRef &Err) const override;
102
103 bool isValidCPUName(StringRef Name) const override;
104 void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
105 bool setCPU(const std::string &Name) override;
106
107 unsigned multiVersionSortPriority(StringRef Name) const override;
108 unsigned multiVersionFeatureCost() const override;
109
110 bool
111 initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags,
112 StringRef CPU,
113 const std::vector<std::string> &FeaturesVec) const override;
114 bool useFP16ConversionIntrinsics() const override {
115 return false;
116 }
117
118 void setArchFeatures();
119
120 void getTargetDefinesARMV81A(const LangOptions &Opts,
121 MacroBuilder &Builder) const;
122 void getTargetDefinesARMV82A(const LangOptions &Opts,
123 MacroBuilder &Builder) const;
124 void getTargetDefinesARMV83A(const LangOptions &Opts,
125 MacroBuilder &Builder) const;
126 void getTargetDefinesARMV84A(const LangOptions &Opts,
127 MacroBuilder &Builder) const;
128 void getTargetDefinesARMV85A(const LangOptions &Opts,
129 MacroBuilder &Builder) const;
130 void getTargetDefinesARMV86A(const LangOptions &Opts,
131 MacroBuilder &Builder) const;
132 void getTargetDefinesARMV87A(const LangOptions &Opts,
133 MacroBuilder &Builder) const;
134 void getTargetDefinesARMV88A(const LangOptions &Opts,
135 MacroBuilder &Builder) const;
136 void getTargetDefinesARMV89A(const LangOptions &Opts,
137 MacroBuilder &Builder) const;
138 void getTargetDefinesARMV9A(const LangOptions &Opts,
139 MacroBuilder &Builder) const;
140 void getTargetDefinesARMV91A(const LangOptions &Opts,
141 MacroBuilder &Builder) const;
142 void getTargetDefinesARMV92A(const LangOptions &Opts,
143 MacroBuilder &Builder) const;
144 void getTargetDefinesARMV93A(const LangOptions &Opts,
145 MacroBuilder &Builder) const;
146 void getTargetDefinesARMV94A(const LangOptions &Opts,
147 MacroBuilder &Builder) const;
148 void getTargetDefinesARMV95A(const LangOptions &Opts,
149 MacroBuilder &Builder) const;
150 void getTargetDefines(const LangOptions &Opts,
151 MacroBuilder &Builder) const override;
152
153 ArrayRef<Builtin::Info> getTargetBuiltins() const override;
154
155 std::optional<std::pair<unsigned, unsigned>>
156 getVScaleRange(const LangOptions &LangOpts) const override;
157 bool doesFeatureAffectCodeGen(StringRef Name) const override;
158 StringRef getFeatureDependencies(StringRef Name) const override;
159 bool validateCpuSupports(StringRef FeatureStr) const override;
160 bool hasFeature(StringRef Feature) const override;
161 void setFeatureEnabled(llvm::StringMap<bool> &Features, StringRef Name,
162 bool Enabled) const override;
163 bool handleTargetFeatures(std::vector<std::string> &Features,
164 DiagnosticsEngine &Diags) override;
165 ParsedTargetAttr parseTargetAttr(StringRef Str) const override;
166 bool supportsTargetAttributeTune() const override { return true; }
167 bool supportsCpuSupports() const override { return true; }
168 bool checkArithmeticFenceSupported() const override { return true; }
169
170 bool hasBFloat16Type() const override;
171
172 CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
173
174 bool isCLZForZeroUndef() const override;
175
176 BuiltinVaListKind getBuiltinVaListKind() const override;
177
178 ArrayRef<const char *> getGCCRegNames() const override;
179 ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;
180
181 std::string convertConstraint(const char *&Constraint) const override;
182
183 bool validateAsmConstraint(const char *&Name,
184 TargetInfo::ConstraintInfo &Info) const override;
185 bool
186 validateConstraintModifier(StringRef Constraint, char Modifier, unsigned Size,
187 std::string &SuggestedModifier) const override;
188 std::string_view getClobbers() const override;
189
190 StringRef getConstraintRegister(StringRef Constraint,
191 StringRef Expression) const override {
192 return Expression;
193 }
194
195 int getEHDataRegisterNumber(unsigned RegNo) const override;
196
197 bool validatePointerAuthKey(const llvm::APSInt &value) const override;
198
199 const char *getBFloat16Mangling() const override { return "u6__bf16"; };
200 bool hasInt128Type() const override;
201
202 bool hasBitIntType() const override { return true; }
203
204 bool validateTarget(DiagnosticsEngine &Diags) 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;
241 TargetInfo::CallingConvKind
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
292

source code of clang/lib/Basic/Targets/AArch64.h