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
[];
35 unsigned FPU
= FPUMode
;
41 bool HasUnaligned
= true;
42 bool HasFullFP16
= false;
43 bool HasDotProd
= false;
44 bool HasFP16FML
= false;
47 bool HasPAuth
= false;
49 bool HasRandGen
= false;
50 bool HasMatMul
= false;
51 bool HasBFloat16
= 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;
60 bool HasFlagM
= false;
61 bool HasAlternativeNZCV
= false;
69 bool HasFRInt3264
= false;
71 bool HasSMEF64F64
= false;
72 bool HasSMEI16I64
= false;
74 bool HasPredRes
= false;
78 bool HasJSCVT
= false;
81 bool HasNoNeon
= false;
82 bool HasNoSVE
= false;
86 const llvm::AArch64::ArchInfo
*ArchInfo
= &llvm::AArch64::ARMV8A
;
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
;
108 initFeatureMap(llvm::StringMap
<bool> &Features
, DiagnosticsEngine
&Diags
,
110 const std::vector
<std::string
> &FeaturesVec
) const override
;
111 bool useFP16ConversionIntrinsics() const override
{
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
;
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
{
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
{
200 AArch64leTargetInfo(const llvm::Triple
&Triple
, const TargetOptions
&Opts
);
202 void getTargetDefines(const LangOptions
&Opts
,
203 MacroBuilder
&Builder
) const override
;
205 void setDataLayout() override
;
208 class LLVM_LIBRARY_VISIBILITY WindowsARM64TargetInfo
209 : public WindowsTargetInfo
<AArch64leTargetInfo
> {
210 const llvm::Triple Triple
;
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
{
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
{
242 MinGWARM64TargetInfo(const llvm::Triple
&Triple
, const TargetOptions
&Opts
);
245 class LLVM_LIBRARY_VISIBILITY AArch64beTargetInfo
: public AArch64TargetInfo
{
247 AArch64beTargetInfo(const llvm::Triple
&Triple
, const TargetOptions
&Opts
);
248 void getTargetDefines(const LangOptions
&Opts
,
249 MacroBuilder
&Builder
) const override
;
252 void setDataLayout() override
;
255 class LLVM_LIBRARY_VISIBILITY DarwinAArch64TargetInfo
256 : public DarwinTargetInfo
<AArch64leTargetInfo
> {
258 DarwinAArch64TargetInfo(const llvm::Triple
&Triple
, const TargetOptions
&Opts
);
260 BuiltinVaListKind
getBuiltinVaListKind() const override
;
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
{
271 RenderScript64TargetInfo(const llvm::Triple
&Triple
,
272 const TargetOptions
&Opts
);
274 void getTargetDefines(const LangOptions
&Opts
,
275 MacroBuilder
&Builder
) const override
;
278 } // namespace targets
281 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_AARCH64_H