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/Support/AArch64TargetParser.h"
19 #include "llvm/Support/TargetParser.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) };
58 llvm::AArch64::ArchKind ArchKind
;
60 static const Builtin::Info BuiltinInfo
[];
63 StringRef
getArchProfile() const;
66 AArch64TargetInfo(const llvm::Triple
&Triple
, const TargetOptions
&Opts
);
68 StringRef
getABI() const override
;
69 bool setABI(const std::string
&Name
) override
;
71 bool validateBranchProtection(StringRef Spec
, StringRef Arch
,
72 BranchProtectionInfo
&BPI
,
73 StringRef
&Err
) const override
;
75 bool isValidCPUName(StringRef Name
) const override
;
76 void fillValidCPUList(SmallVectorImpl
<StringRef
> &Values
) const override
;
77 bool setCPU(const std::string
&Name
) override
;
79 bool useFP16ConversionIntrinsics() const override
{
83 void getTargetDefinesARMV81A(const LangOptions
&Opts
,
84 MacroBuilder
&Builder
) const;
85 void getTargetDefinesARMV82A(const LangOptions
&Opts
,
86 MacroBuilder
&Builder
) const;
87 void getTargetDefinesARMV83A(const LangOptions
&Opts
,
88 MacroBuilder
&Builder
) const;
89 void getTargetDefinesARMV84A(const LangOptions
&Opts
,
90 MacroBuilder
&Builder
) const;
91 void getTargetDefinesARMV85A(const LangOptions
&Opts
,
92 MacroBuilder
&Builder
) const;
93 void getTargetDefinesARMV86A(const LangOptions
&Opts
,
94 MacroBuilder
&Builder
) const;
95 void getTargetDefinesARMV87A(const LangOptions
&Opts
,
96 MacroBuilder
&Builder
) const;
97 void getTargetDefinesARMV88A(const LangOptions
&Opts
,
98 MacroBuilder
&Builder
) const;
99 void getTargetDefinesARMV9A(const LangOptions
&Opts
,
100 MacroBuilder
&Builder
) const;
101 void getTargetDefinesARMV91A(const LangOptions
&Opts
,
102 MacroBuilder
&Builder
) const;
103 void getTargetDefinesARMV92A(const LangOptions
&Opts
,
104 MacroBuilder
&Builder
) const;
105 void getTargetDefinesARMV93A(const LangOptions
&Opts
,
106 MacroBuilder
&Builder
) const;
107 void getTargetDefines(const LangOptions
&Opts
,
108 MacroBuilder
&Builder
) const override
;
110 ArrayRef
<Builtin::Info
> getTargetBuiltins() const override
;
112 Optional
<std::pair
<unsigned, unsigned>>
113 getVScaleRange(const LangOptions
&LangOpts
) const override
;
115 bool hasFeature(StringRef Feature
) const override
;
116 bool handleTargetFeatures(std::vector
<std::string
> &Features
,
117 DiagnosticsEngine
&Diags
) override
;
119 bool hasBFloat16Type() const override
;
121 CallingConvCheckResult
checkCallingConvention(CallingConv CC
) const override
;
123 bool isCLZForZeroUndef() const override
;
125 BuiltinVaListKind
getBuiltinVaListKind() const override
;
127 ArrayRef
<const char *> getGCCRegNames() const override
;
128 ArrayRef
<TargetInfo::GCCRegAlias
> getGCCRegAliases() const override
;
130 std::string
convertConstraint(const char *&Constraint
) const override
{
132 switch (*Constraint
) {
133 case 'U': // Three-character constraint; add "@3" hint for later parsing.
134 R
= std::string("@3") + std::string(Constraint
, 3);
138 R
= TargetInfo::convertConstraint(Constraint
);
144 bool validateAsmConstraint(const char *&Name
,
145 TargetInfo::ConstraintInfo
&Info
) const override
;
147 validateConstraintModifier(StringRef Constraint
, char Modifier
, unsigned Size
,
148 std::string
&SuggestedModifier
) const override
;
149 const char *getClobbers() const override
;
151 StringRef
getConstraintRegister(StringRef Constraint
,
152 StringRef Expression
) const override
{
156 int getEHDataRegisterNumber(unsigned RegNo
) const override
;
158 const char *getBFloat16Mangling() const override
{ return "u6__bf16"; };
159 bool hasInt128Type() const override
;
161 bool hasBitIntType() const override
{ return true; }
164 class LLVM_LIBRARY_VISIBILITY AArch64leTargetInfo
: public AArch64TargetInfo
{
166 AArch64leTargetInfo(const llvm::Triple
&Triple
, const TargetOptions
&Opts
);
168 void getTargetDefines(const LangOptions
&Opts
,
169 MacroBuilder
&Builder
) const override
;
171 void setDataLayout() override
;
174 class LLVM_LIBRARY_VISIBILITY WindowsARM64TargetInfo
175 : public WindowsTargetInfo
<AArch64leTargetInfo
> {
176 const llvm::Triple Triple
;
179 WindowsARM64TargetInfo(const llvm::Triple
&Triple
,
180 const TargetOptions
&Opts
);
182 void setDataLayout() override
;
184 BuiltinVaListKind
getBuiltinVaListKind() const override
;
186 CallingConvCheckResult
checkCallingConvention(CallingConv CC
) const override
;
189 // Windows ARM, MS (C++) ABI
190 class LLVM_LIBRARY_VISIBILITY MicrosoftARM64TargetInfo
191 : public WindowsARM64TargetInfo
{
193 MicrosoftARM64TargetInfo(const llvm::Triple
&Triple
,
194 const TargetOptions
&Opts
);
196 void getTargetDefines(const LangOptions
&Opts
,
197 MacroBuilder
&Builder
) const override
;
198 TargetInfo::CallingConvKind
199 getCallingConvKind(bool ClangABICompat4
) const override
;
201 unsigned getMinGlobalAlign(uint64_t TypeSize
) const override
;
204 // ARM64 MinGW target
205 class LLVM_LIBRARY_VISIBILITY MinGWARM64TargetInfo
206 : public WindowsARM64TargetInfo
{
208 MinGWARM64TargetInfo(const llvm::Triple
&Triple
, const TargetOptions
&Opts
);
211 class LLVM_LIBRARY_VISIBILITY AArch64beTargetInfo
: public AArch64TargetInfo
{
213 AArch64beTargetInfo(const llvm::Triple
&Triple
, const TargetOptions
&Opts
);
214 void getTargetDefines(const LangOptions
&Opts
,
215 MacroBuilder
&Builder
) const override
;
218 void setDataLayout() override
;
221 class LLVM_LIBRARY_VISIBILITY DarwinAArch64TargetInfo
222 : public DarwinTargetInfo
<AArch64leTargetInfo
> {
224 DarwinAArch64TargetInfo(const llvm::Triple
&Triple
, const TargetOptions
&Opts
);
226 BuiltinVaListKind
getBuiltinVaListKind() const override
;
229 void getOSDefines(const LangOptions
&Opts
, const llvm::Triple
&Triple
,
230 MacroBuilder
&Builder
) const override
;
233 // 64-bit RenderScript is aarch64
234 class LLVM_LIBRARY_VISIBILITY RenderScript64TargetInfo
235 : public AArch64leTargetInfo
{
237 RenderScript64TargetInfo(const llvm::Triple
&Triple
,
238 const TargetOptions
&Opts
);
240 void getTargetDefines(const LangOptions
&Opts
,
241 MacroBuilder
&Builder
) const override
;
244 } // namespace targets
247 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_AARCH64_H