[AMDGPU][AsmParser][NFC] Get rid of custom default operand handlers.
[llvm-project.git] / clang / lib / Basic / Targets / AArch64.h
blobcce80e10f2bb1eba871eae100f66e350bbe1deeb
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.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_AARCH64_H
14 #define LLVM_CLANG_LIB_BASIC_TARGETS_AARCH64_H
16 #include "OSTargets.h"
17 #include "clang/Basic/TargetBuiltins.h"
18 #include "llvm/TargetParser/AArch64TargetParser.h"
19 #include <optional>
21 namespace clang {
22 namespace targets {
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[];
29 enum FPUModeEnum {
30 FPUMode = (1 << 0),
31 NeonMode = (1 << 1),
32 SveMode = (1 << 2),
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 HasUnaligned = true;
42 bool HasFullFP16 = false;
43 bool HasDotProd = false;
44 bool HasFP16FML = false;
45 bool HasMTE = false;
46 bool HasTME = false;
47 bool HasPAuth = false;
48 bool HasLS64 = false;
49 bool HasRandGen = false;
50 bool HasMatMul = false;
51 bool HasBFloat16 = false;
52 bool HasSVE2 = 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 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;
86 const llvm::AArch64::ArchInfo *ArchInfo = &llvm::AArch64::ARMV8A;
88 std::string ABI;
90 public:
91 AArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
93 StringRef getABI() const override;
94 bool setABI(const std::string &Name) override;
96 bool validateBranchProtection(StringRef Spec, StringRef Arch,
97 BranchProtectionInfo &BPI,
98 StringRef &Err) const override;
100 bool isValidCPUName(StringRef Name) const override;
101 void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
102 bool setCPU(const std::string &Name) override;
104 unsigned multiVersionSortPriority(StringRef Name) const override;
105 unsigned multiVersionFeatureCost() const override;
107 bool
108 initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags,
109 StringRef CPU,
110 const std::vector<std::string> &FeaturesVec) const override;
111 bool useFP16ConversionIntrinsics() const override {
112 return false;
115 void setArchFeatures();
117 void getTargetDefinesARMV81A(const LangOptions &Opts,
118 MacroBuilder &Builder) const;
119 void getTargetDefinesARMV82A(const LangOptions &Opts,
120 MacroBuilder &Builder) const;
121 void getTargetDefinesARMV83A(const LangOptions &Opts,
122 MacroBuilder &Builder) const;
123 void getTargetDefinesARMV84A(const LangOptions &Opts,
124 MacroBuilder &Builder) const;
125 void getTargetDefinesARMV85A(const LangOptions &Opts,
126 MacroBuilder &Builder) const;
127 void getTargetDefinesARMV86A(const LangOptions &Opts,
128 MacroBuilder &Builder) const;
129 void getTargetDefinesARMV87A(const LangOptions &Opts,
130 MacroBuilder &Builder) const;
131 void getTargetDefinesARMV88A(const LangOptions &Opts,
132 MacroBuilder &Builder) const;
133 void getTargetDefinesARMV89A(const LangOptions &Opts,
134 MacroBuilder &Builder) const;
135 void getTargetDefinesARMV9A(const LangOptions &Opts,
136 MacroBuilder &Builder) const;
137 void getTargetDefinesARMV91A(const LangOptions &Opts,
138 MacroBuilder &Builder) const;
139 void getTargetDefinesARMV92A(const LangOptions &Opts,
140 MacroBuilder &Builder) const;
141 void getTargetDefinesARMV93A(const LangOptions &Opts,
142 MacroBuilder &Builder) const;
143 void getTargetDefinesARMV94A(const LangOptions &Opts,
144 MacroBuilder &Builder) const;
145 void getTargetDefines(const LangOptions &Opts,
146 MacroBuilder &Builder) const override;
148 ArrayRef<Builtin::Info> getTargetBuiltins() const override;
150 std::optional<std::pair<unsigned, unsigned>>
151 getVScaleRange(const LangOptions &LangOpts) const override;
152 bool doesFeatureAffectCodeGen(StringRef Name) const override;
153 StringRef getFeatureDependencies(StringRef Name) const override;
154 bool validateCpuSupports(StringRef FeatureStr) const override;
155 bool hasFeature(StringRef Feature) const override;
156 void setFeatureEnabled(llvm::StringMap<bool> &Features, StringRef Name,
157 bool Enabled) const override;
158 bool handleTargetFeatures(std::vector<std::string> &Features,
159 DiagnosticsEngine &Diags) override;
160 ParsedTargetAttr parseTargetAttr(StringRef Str) const override;
161 bool supportsTargetAttributeTune() const override { return true; }
163 bool checkArithmeticFenceSupported() const override { return true; }
165 bool hasBFloat16Type() const override;
167 CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
169 bool isCLZForZeroUndef() const override;
171 BuiltinVaListKind getBuiltinVaListKind() const override;
173 ArrayRef<const char *> getGCCRegNames() const override;
174 ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;
176 std::string convertConstraint(const char *&Constraint) const override;
178 bool validateAsmConstraint(const char *&Name,
179 TargetInfo::ConstraintInfo &Info) const override;
180 bool
181 validateConstraintModifier(StringRef Constraint, char Modifier, unsigned Size,
182 std::string &SuggestedModifier) const override;
183 std::string_view getClobbers() const override;
185 StringRef getConstraintRegister(StringRef Constraint,
186 StringRef Expression) const override {
187 return Expression;
190 int getEHDataRegisterNumber(unsigned RegNo) const override;
192 const char *getBFloat16Mangling() const override { return "u6__bf16"; };
193 bool hasInt128Type() const override;
195 bool hasBitIntType() const override { return true; }
198 class LLVM_LIBRARY_VISIBILITY AArch64leTargetInfo : public AArch64TargetInfo {
199 public:
200 AArch64leTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
202 void getTargetDefines(const LangOptions &Opts,
203 MacroBuilder &Builder) const override;
204 private:
205 void setDataLayout() override;
208 class LLVM_LIBRARY_VISIBILITY WindowsARM64TargetInfo
209 : public WindowsTargetInfo<AArch64leTargetInfo> {
210 const llvm::Triple Triple;
212 public:
213 WindowsARM64TargetInfo(const llvm::Triple &Triple,
214 const TargetOptions &Opts);
216 void setDataLayout() override;
218 BuiltinVaListKind getBuiltinVaListKind() const override;
220 CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
223 // Windows ARM, MS (C++) ABI
224 class LLVM_LIBRARY_VISIBILITY MicrosoftARM64TargetInfo
225 : public WindowsARM64TargetInfo {
226 public:
227 MicrosoftARM64TargetInfo(const llvm::Triple &Triple,
228 const TargetOptions &Opts);
230 void getTargetDefines(const LangOptions &Opts,
231 MacroBuilder &Builder) const override;
232 TargetInfo::CallingConvKind
233 getCallingConvKind(bool ClangABICompat4) const override;
235 unsigned getMinGlobalAlign(uint64_t TypeSize) const override;
238 // ARM64 MinGW target
239 class LLVM_LIBRARY_VISIBILITY MinGWARM64TargetInfo
240 : public WindowsARM64TargetInfo {
241 public:
242 MinGWARM64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
245 class LLVM_LIBRARY_VISIBILITY AArch64beTargetInfo : public AArch64TargetInfo {
246 public:
247 AArch64beTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
248 void getTargetDefines(const LangOptions &Opts,
249 MacroBuilder &Builder) const override;
251 private:
252 void setDataLayout() override;
255 class LLVM_LIBRARY_VISIBILITY DarwinAArch64TargetInfo
256 : public DarwinTargetInfo<AArch64leTargetInfo> {
257 public:
258 DarwinAArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
260 BuiltinVaListKind getBuiltinVaListKind() const override;
262 protected:
263 void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
264 MacroBuilder &Builder) const override;
267 // 64-bit RenderScript is aarch64
268 class LLVM_LIBRARY_VISIBILITY RenderScript64TargetInfo
269 : public AArch64leTargetInfo {
270 public:
271 RenderScript64TargetInfo(const llvm::Triple &Triple,
272 const TargetOptions &Opts);
274 void getTargetDefines(const LangOptions &Opts,
275 MacroBuilder &Builder) const override;
278 } // namespace targets
279 } // namespace clang
281 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_AARCH64_H