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 | |
21 | namespace clang { |
22 | namespace targets { |
23 | |
24 | class 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 HasSVEB16B16 = false; |
57 | bool HasSVE2BitPerm = false; |
58 | bool HasMatmulFP64 = false; |
59 | bool HasMatmulFP32 = false; |
60 | bool HasLSE = false; |
61 | bool HasFlagM = false; |
62 | bool HasAlternativeNZCV = false; |
63 | bool HasMOPS = false; |
64 | bool HasD128 = false; |
65 | bool HasRCPC = false; |
66 | bool HasRDM = false; |
67 | bool HasDIT = false; |
68 | bool HasCCPP = false; |
69 | bool HasCCDP = false; |
70 | bool HasFRInt3264 = false; |
71 | bool HasSME = false; |
72 | bool HasSME2 = false; |
73 | bool HasSMEF64F64 = false; |
74 | bool HasSMEI16I64 = false; |
75 | bool HasSMEF16F16 = false; |
76 | bool HasSMEB16B16 = false; |
77 | bool HasSME2p1 = false; |
78 | bool HasSB = false; |
79 | bool HasPredRes = false; |
80 | bool HasSSBS = false; |
81 | bool HasBTI = false; |
82 | bool HasWFxT = false; |
83 | bool HasJSCVT = false; |
84 | bool HasFCMA = false; |
85 | bool HasNoFP = false; |
86 | bool HasNoNeon = false; |
87 | bool HasNoSVE = false; |
88 | bool HasFMV = true; |
89 | bool HasGCS = false; |
90 | bool HasRCPC3 = false; |
91 | bool HasSMEFA64 = false; |
92 | bool HasPAuthLR = false; |
93 | |
94 | const llvm::AArch64::ArchInfo *ArchInfo = &llvm::AArch64::ARMV8A; |
95 | |
96 | std::string ABI; |
97 | |
98 | public: |
99 | AArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts); |
100 | |
101 | StringRef getABI() const override; |
102 | bool setABI(const std::string &Name) override; |
103 | |
104 | bool validateBranchProtection(StringRef Spec, StringRef Arch, |
105 | BranchProtectionInfo &BPI, |
106 | StringRef &Err) const override; |
107 | |
108 | bool isValidCPUName(StringRef Name) const override; |
109 | void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override; |
110 | bool setCPU(const std::string &Name) override; |
111 | |
112 | unsigned multiVersionSortPriority(StringRef Name) const override; |
113 | unsigned multiVersionFeatureCost() const override; |
114 | |
115 | bool useFP16ConversionIntrinsics() const override { |
116 | return false; |
117 | } |
118 | |
119 | void setArchFeatures(); |
120 | |
121 | void getTargetDefinesARMV81A(const LangOptions &Opts, |
122 | MacroBuilder &Builder) const; |
123 | void getTargetDefinesARMV82A(const LangOptions &Opts, |
124 | MacroBuilder &Builder) const; |
125 | void getTargetDefinesARMV83A(const LangOptions &Opts, |
126 | MacroBuilder &Builder) const; |
127 | void getTargetDefinesARMV84A(const LangOptions &Opts, |
128 | MacroBuilder &Builder) const; |
129 | void getTargetDefinesARMV85A(const LangOptions &Opts, |
130 | MacroBuilder &Builder) const; |
131 | void getTargetDefinesARMV86A(const LangOptions &Opts, |
132 | MacroBuilder &Builder) const; |
133 | void getTargetDefinesARMV87A(const LangOptions &Opts, |
134 | MacroBuilder &Builder) const; |
135 | void getTargetDefinesARMV88A(const LangOptions &Opts, |
136 | MacroBuilder &Builder) const; |
137 | void getTargetDefinesARMV89A(const LangOptions &Opts, |
138 | MacroBuilder &Builder) const; |
139 | void getTargetDefinesARMV9A(const LangOptions &Opts, |
140 | MacroBuilder &Builder) const; |
141 | void getTargetDefinesARMV91A(const LangOptions &Opts, |
142 | MacroBuilder &Builder) const; |
143 | void getTargetDefinesARMV92A(const LangOptions &Opts, |
144 | MacroBuilder &Builder) const; |
145 | void getTargetDefinesARMV93A(const LangOptions &Opts, |
146 | MacroBuilder &Builder) const; |
147 | void getTargetDefinesARMV94A(const LangOptions &Opts, |
148 | MacroBuilder &Builder) const; |
149 | void getTargetDefinesARMV95A(const LangOptions &Opts, |
150 | MacroBuilder &Builder) const; |
151 | void getTargetDefines(const LangOptions &Opts, |
152 | MacroBuilder &Builder) const override; |
153 | |
154 | ArrayRef<Builtin::Info> getTargetBuiltins() const override; |
155 | |
156 | std::optional<std::pair<unsigned, unsigned>> |
157 | getVScaleRange(const LangOptions &LangOpts) const override; |
158 | bool doesFeatureAffectCodeGen(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 | bool validateGlobalRegisterVariable(StringRef RegName, unsigned RegSize, |
207 | bool &HasSizeMismatch) const override; |
208 | }; |
209 | |
210 | class LLVM_LIBRARY_VISIBILITY AArch64leTargetInfo : public AArch64TargetInfo { |
211 | public: |
212 | AArch64leTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts); |
213 | |
214 | void getTargetDefines(const LangOptions &Opts, |
215 | MacroBuilder &Builder) const override; |
216 | private: |
217 | void setDataLayout() override; |
218 | }; |
219 | |
220 | class LLVM_LIBRARY_VISIBILITY WindowsARM64TargetInfo |
221 | : public WindowsTargetInfo<AArch64leTargetInfo> { |
222 | const llvm::Triple Triple; |
223 | |
224 | public: |
225 | WindowsARM64TargetInfo(const llvm::Triple &Triple, |
226 | const TargetOptions &Opts); |
227 | |
228 | void setDataLayout() override; |
229 | |
230 | BuiltinVaListKind getBuiltinVaListKind() const override; |
231 | |
232 | CallingConvCheckResult checkCallingConvention(CallingConv CC) const override; |
233 | }; |
234 | |
235 | // Windows ARM, MS (C++) ABI |
236 | class LLVM_LIBRARY_VISIBILITY MicrosoftARM64TargetInfo |
237 | : public WindowsARM64TargetInfo { |
238 | public: |
239 | MicrosoftARM64TargetInfo(const llvm::Triple &Triple, |
240 | const TargetOptions &Opts); |
241 | |
242 | void getTargetDefines(const LangOptions &Opts, |
243 | MacroBuilder &Builder) const override; |
244 | TargetInfo::CallingConvKind |
245 | getCallingConvKind(bool ClangABICompat4) const override; |
246 | |
247 | unsigned getMinGlobalAlign(uint64_t TypeSize, |
248 | bool HasNonWeakDef) const override; |
249 | }; |
250 | |
251 | // ARM64 MinGW target |
252 | class LLVM_LIBRARY_VISIBILITY MinGWARM64TargetInfo |
253 | : public WindowsARM64TargetInfo { |
254 | public: |
255 | MinGWARM64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts); |
256 | }; |
257 | |
258 | class LLVM_LIBRARY_VISIBILITY AArch64beTargetInfo : public AArch64TargetInfo { |
259 | public: |
260 | AArch64beTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts); |
261 | void getTargetDefines(const LangOptions &Opts, |
262 | MacroBuilder &Builder) const override; |
263 | |
264 | private: |
265 | void setDataLayout() override; |
266 | }; |
267 | |
268 | class LLVM_LIBRARY_VISIBILITY DarwinAArch64TargetInfo |
269 | : public DarwinTargetInfo<AArch64leTargetInfo> { |
270 | public: |
271 | DarwinAArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts); |
272 | |
273 | BuiltinVaListKind getBuiltinVaListKind() const override; |
274 | |
275 | protected: |
276 | void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple, |
277 | MacroBuilder &Builder) const override; |
278 | }; |
279 | |
280 | // 64-bit RenderScript is aarch64 |
281 | class LLVM_LIBRARY_VISIBILITY RenderScript64TargetInfo |
282 | : public AArch64leTargetInfo { |
283 | public: |
284 | RenderScript64TargetInfo(const llvm::Triple &Triple, |
285 | const TargetOptions &Opts); |
286 | |
287 | void getTargetDefines(const LangOptions &Opts, |
288 | MacroBuilder &Builder) const override; |
289 | }; |
290 | |
291 | } // namespace targets |
292 | } // namespace clang |
293 | |
294 | #endif // LLVM_CLANG_LIB_BASIC_TARGETS_AARCH64_H |
295 | |