1 //===--- AArch64.h - Declare AArch64 target feature support -----*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
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"
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
{ FPUMode
, NeonMode
= (1 << 0), SveMode
= (1 << 1) };
31 unsigned FPU
= FPUMode
;
37 bool HasUnaligned
= true;
38 bool HasFullFP16
= false;
39 bool HasDotProd
= false;
40 bool HasFP16FML
= false;
43 bool HasPAuth
= false;
45 bool HasRandGen
= false;
46 bool HasMatMul
= false;
47 bool HasBFloat16
= false;
49 bool HasSVE2AES
= false;
50 bool HasSVE2SHA3
= false;
51 bool HasSVE2SM4
= false;
52 bool HasSVE2BitPerm
= false;
53 bool HasMatmulFP64
= false;
54 bool HasMatmulFP32
= false;
56 bool HasFlagM
= false;
57 bool HasAlternativeNZCV
= false;
65 bool HasFRInt3264
= false;
67 bool HasSMEF64
= false;
68 bool HasSMEI64
= false;
70 bool HasPredRes
= false;
74 bool HasJSCVT
= false;
76 bool HasNoNeon
= false;
77 bool HasNoSVE
= false;
80 const llvm::AArch64::ArchInfo
*ArchInfo
= &llvm::AArch64::ARMV8A
;
85 AArch64TargetInfo(const llvm::Triple
&Triple
, const TargetOptions
&Opts
);
87 StringRef
getABI() const override
;
88 bool setABI(const std::string
&Name
) override
;
90 bool validateBranchProtection(StringRef Spec
, StringRef Arch
,
91 BranchProtectionInfo
&BPI
,
92 StringRef
&Err
) const override
;
94 bool isValidCPUName(StringRef Name
) const override
;
95 void fillValidCPUList(SmallVectorImpl
<StringRef
> &Values
) const override
;
96 bool setCPU(const std::string
&Name
) override
;
98 unsigned multiVersionSortPriority(StringRef Name
) const override
;
99 unsigned multiVersionFeatureCost() const override
;
102 initFeatureMap(llvm::StringMap
<bool> &Features
, DiagnosticsEngine
&Diags
,
104 const std::vector
<std::string
> &FeaturesVec
) const override
;
105 bool useFP16ConversionIntrinsics() const override
{
109 void setArchFeatures();
111 void getTargetDefinesARMV81A(const LangOptions
&Opts
,
112 MacroBuilder
&Builder
) const;
113 void getTargetDefinesARMV82A(const LangOptions
&Opts
,
114 MacroBuilder
&Builder
) const;
115 void getTargetDefinesARMV83A(const LangOptions
&Opts
,
116 MacroBuilder
&Builder
) const;
117 void getTargetDefinesARMV84A(const LangOptions
&Opts
,
118 MacroBuilder
&Builder
) const;
119 void getTargetDefinesARMV85A(const LangOptions
&Opts
,
120 MacroBuilder
&Builder
) const;
121 void getTargetDefinesARMV86A(const LangOptions
&Opts
,
122 MacroBuilder
&Builder
) const;
123 void getTargetDefinesARMV87A(const LangOptions
&Opts
,
124 MacroBuilder
&Builder
) const;
125 void getTargetDefinesARMV88A(const LangOptions
&Opts
,
126 MacroBuilder
&Builder
) const;
127 void getTargetDefinesARMV89A(const LangOptions
&Opts
,
128 MacroBuilder
&Builder
) const;
129 void getTargetDefinesARMV9A(const LangOptions
&Opts
,
130 MacroBuilder
&Builder
) const;
131 void getTargetDefinesARMV91A(const LangOptions
&Opts
,
132 MacroBuilder
&Builder
) const;
133 void getTargetDefinesARMV92A(const LangOptions
&Opts
,
134 MacroBuilder
&Builder
) const;
135 void getTargetDefinesARMV93A(const LangOptions
&Opts
,
136 MacroBuilder
&Builder
) const;
137 void getTargetDefinesARMV94A(const LangOptions
&Opts
,
138 MacroBuilder
&Builder
) const;
139 void getTargetDefines(const LangOptions
&Opts
,
140 MacroBuilder
&Builder
) const override
;
142 ArrayRef
<Builtin::Info
> getTargetBuiltins() const override
;
144 std::optional
<std::pair
<unsigned, unsigned>>
145 getVScaleRange(const LangOptions
&LangOpts
) const override
;
147 bool getFeatureDepOptions(StringRef Feature
,
148 std::string
&Options
) const override
;
149 bool validateCpuSupports(StringRef FeatureStr
) const override
;
150 bool hasFeature(StringRef Feature
) const override
;
151 void setFeatureEnabled(llvm::StringMap
<bool> &Features
, StringRef Name
,
152 bool Enabled
) const override
;
153 bool handleTargetFeatures(std::vector
<std::string
> &Features
,
154 DiagnosticsEngine
&Diags
) override
;
155 ParsedTargetAttr
parseTargetAttr(StringRef Str
) const override
;
156 bool supportsTargetAttributeTune() const override
{ return true; }
158 bool hasBFloat16Type() const override
;
160 CallingConvCheckResult
checkCallingConvention(CallingConv CC
) const override
;
162 bool isCLZForZeroUndef() const override
;
164 BuiltinVaListKind
getBuiltinVaListKind() const override
;
166 ArrayRef
<const char *> getGCCRegNames() const override
;
167 ArrayRef
<TargetInfo::GCCRegAlias
> getGCCRegAliases() const override
;
169 std::string
convertConstraint(const char *&Constraint
) const override
{
171 switch (*Constraint
) {
172 case 'U': // Three-character constraint; add "@3" hint for later parsing.
173 R
= std::string("@3") + std::string(Constraint
, 3);
177 R
= TargetInfo::convertConstraint(Constraint
);
183 bool validateAsmConstraint(const char *&Name
,
184 TargetInfo::ConstraintInfo
&Info
) const override
;
186 validateConstraintModifier(StringRef Constraint
, char Modifier
, unsigned Size
,
187 std::string
&SuggestedModifier
) const override
;
188 const char *getClobbers() const override
;
190 StringRef
getConstraintRegister(StringRef Constraint
,
191 StringRef Expression
) const override
{
195 int getEHDataRegisterNumber(unsigned RegNo
) const override
;
197 const char *getBFloat16Mangling() const override
{ return "u6__bf16"; };
198 bool hasInt128Type() const override
;
200 bool hasBitIntType() const override
{ return true; }
203 class LLVM_LIBRARY_VISIBILITY AArch64leTargetInfo
: public AArch64TargetInfo
{
205 AArch64leTargetInfo(const llvm::Triple
&Triple
, const TargetOptions
&Opts
);
207 void getTargetDefines(const LangOptions
&Opts
,
208 MacroBuilder
&Builder
) const override
;
210 void setDataLayout() override
;
213 class LLVM_LIBRARY_VISIBILITY WindowsARM64TargetInfo
214 : public WindowsTargetInfo
<AArch64leTargetInfo
> {
215 const llvm::Triple Triple
;
218 WindowsARM64TargetInfo(const llvm::Triple
&Triple
,
219 const TargetOptions
&Opts
);
221 void setDataLayout() override
;
223 BuiltinVaListKind
getBuiltinVaListKind() const override
;
225 CallingConvCheckResult
checkCallingConvention(CallingConv CC
) const override
;
228 // Windows ARM, MS (C++) ABI
229 class LLVM_LIBRARY_VISIBILITY MicrosoftARM64TargetInfo
230 : public WindowsARM64TargetInfo
{
232 MicrosoftARM64TargetInfo(const llvm::Triple
&Triple
,
233 const TargetOptions
&Opts
);
235 void getTargetDefines(const LangOptions
&Opts
,
236 MacroBuilder
&Builder
) const override
;
237 TargetInfo::CallingConvKind
238 getCallingConvKind(bool ClangABICompat4
) const override
;
240 unsigned getMinGlobalAlign(uint64_t TypeSize
) const override
;
243 // ARM64 MinGW target
244 class LLVM_LIBRARY_VISIBILITY MinGWARM64TargetInfo
245 : public WindowsARM64TargetInfo
{
247 MinGWARM64TargetInfo(const llvm::Triple
&Triple
, const TargetOptions
&Opts
);
250 class LLVM_LIBRARY_VISIBILITY AArch64beTargetInfo
: public AArch64TargetInfo
{
252 AArch64beTargetInfo(const llvm::Triple
&Triple
, const TargetOptions
&Opts
);
253 void getTargetDefines(const LangOptions
&Opts
,
254 MacroBuilder
&Builder
) const override
;
257 void setDataLayout() override
;
260 class LLVM_LIBRARY_VISIBILITY DarwinAArch64TargetInfo
261 : public DarwinTargetInfo
<AArch64leTargetInfo
> {
263 DarwinAArch64TargetInfo(const llvm::Triple
&Triple
, const TargetOptions
&Opts
);
265 BuiltinVaListKind
getBuiltinVaListKind() const override
;
268 void getOSDefines(const LangOptions
&Opts
, const llvm::Triple
&Triple
,
269 MacroBuilder
&Builder
) const override
;
272 // 64-bit RenderScript is aarch64
273 class LLVM_LIBRARY_VISIBILITY RenderScript64TargetInfo
274 : public AArch64leTargetInfo
{
276 RenderScript64TargetInfo(const llvm::Triple
&Triple
,
277 const TargetOptions
&Opts
);
279 void getTargetDefines(const LangOptions
&Opts
,
280 MacroBuilder
&Builder
) const override
;
283 } // namespace targets
286 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_AARCH64_H