clang  14.0.0git
AArch64.h
Go to the documentation of this file.
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"
18 #include "llvm/Support/AArch64TargetParser.h"
19 #include "llvm/Support/TargetParser.h"
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 { FPUMode, NeonMode = (1 << 0), SveMode = (1 << 1) };
30 
31  unsigned FPU;
32  bool HasCRC;
33  bool HasCrypto;
34  bool HasAES;
35  bool HasSHA2;
36  bool HasSHA3;
37  bool HasSM4;
38  bool HasUnaligned;
39  bool HasFullFP16;
40  bool HasDotProd;
41  bool HasFP16FML;
42  bool HasMTE;
43  bool HasTME;
44  bool HasPAuth;
45  bool HasLS64;
46  bool HasRandGen;
47  bool HasMatMul;
48  bool HasSVE2;
49  bool HasSVE2AES;
50  bool HasSVE2SHA3;
51  bool HasSVE2SM4;
52  bool HasSVE2BitPerm;
53  bool HasMatmulFP64;
54  bool HasMatmulFP32;
55  bool HasLSE;
56  bool HasFlagM;
57  bool HasHBC;
58  bool HasMOPS;
59 
60  llvm::AArch64::ArchKind ArchKind;
61 
62  static const Builtin::Info BuiltinInfo[];
63 
64  std::string ABI;
65  StringRef getArchProfile() const;
66 
67 public:
68  AArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
69 
70  StringRef getABI() const override;
71  bool setABI(const std::string &Name) override;
72 
73  bool validateBranchProtection(StringRef, BranchProtectionInfo &,
74  StringRef &) const override;
75 
76  bool isValidCPUName(StringRef Name) const override;
77  void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
78  bool setCPU(const std::string &Name) override;
79 
80  bool useFP16ConversionIntrinsics() const override {
81  return false;
82  }
83 
84  void getTargetDefinesARMV81A(const LangOptions &Opts,
85  MacroBuilder &Builder) const;
86  void getTargetDefinesARMV82A(const LangOptions &Opts,
87  MacroBuilder &Builder) const;
88  void getTargetDefinesARMV83A(const LangOptions &Opts,
89  MacroBuilder &Builder) const;
90  void getTargetDefinesARMV84A(const LangOptions &Opts,
91  MacroBuilder &Builder) const;
92  void getTargetDefinesARMV85A(const LangOptions &Opts,
93  MacroBuilder &Builder) const;
94  void getTargetDefinesARMV86A(const LangOptions &Opts,
95  MacroBuilder &Builder) const;
96  void getTargetDefinesARMV87A(const LangOptions &Opts,
97  MacroBuilder &Builder) const;
98  void getTargetDefinesARMV88A(const LangOptions &Opts,
99  MacroBuilder &Builder) const;
100  void getTargetDefinesARMV9A(const LangOptions &Opts,
101  MacroBuilder &Builder) const;
102  void getTargetDefinesARMV91A(const LangOptions &Opts,
103  MacroBuilder &Builder) const;
104  void getTargetDefinesARMV92A(const LangOptions &Opts,
105  MacroBuilder &Builder) const;
106  void getTargetDefinesARMV93A(const LangOptions &Opts,
107  MacroBuilder &Builder) const;
108  void getTargetDefines(const LangOptions &Opts,
109  MacroBuilder &Builder) const override;
110 
111  ArrayRef<Builtin::Info> getTargetBuiltins() const override;
112 
114  getVScaleRange(const LangOptions &LangOpts) const override;
115 
116  bool hasFeature(StringRef Feature) const override;
117  bool handleTargetFeatures(std::vector<std::string> &Features,
118  DiagnosticsEngine &Diags) override;
119 
120  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
121 
122  bool isCLZForZeroUndef() const override;
123 
124  BuiltinVaListKind getBuiltinVaListKind() const override;
125 
126  ArrayRef<const char *> getGCCRegNames() const override;
127  ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;
128 
129  std::string convertConstraint(const char *&Constraint) const override {
130  std::string R;
131  switch (*Constraint) {
132  case 'U': // Three-character constraint; add "@3" hint for later parsing.
133  R = std::string("@3") + std::string(Constraint, 3);
134  Constraint += 2;
135  break;
136  default:
137  R = TargetInfo::convertConstraint(Constraint);
138  break;
139  }
140  return R;
141  }
142 
143  bool validateAsmConstraint(const char *&Name,
144  TargetInfo::ConstraintInfo &Info) const override;
145  bool
146  validateConstraintModifier(StringRef Constraint, char Modifier, unsigned Size,
147  std::string &SuggestedModifier) const override;
148  const char *getClobbers() const override;
149 
150  StringRef getConstraintRegister(StringRef Constraint,
151  StringRef Expression) const override {
152  return Expression;
153  }
154 
155  int getEHDataRegisterNumber(unsigned RegNo) const override;
156 
157  const char *getBFloat16Mangling() const override { return "u6__bf16"; };
158  bool hasInt128Type() const override;
159 
160  bool hasBitIntType() const override { return true; }
161 };
162 
163 class LLVM_LIBRARY_VISIBILITY AArch64leTargetInfo : public AArch64TargetInfo {
164 public:
165  AArch64leTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
166 
167  void getTargetDefines(const LangOptions &Opts,
168  MacroBuilder &Builder) const override;
169 private:
170  void setDataLayout() override;
171 };
172 
173 class LLVM_LIBRARY_VISIBILITY WindowsARM64TargetInfo
174  : public WindowsTargetInfo<AArch64leTargetInfo> {
175  const llvm::Triple Triple;
176 
177 public:
178  WindowsARM64TargetInfo(const llvm::Triple &Triple,
179  const TargetOptions &Opts);
180 
181  void setDataLayout() override;
182 
183  BuiltinVaListKind getBuiltinVaListKind() const override;
184 
185  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
186 };
187 
188 // Windows ARM, MS (C++) ABI
189 class LLVM_LIBRARY_VISIBILITY MicrosoftARM64TargetInfo
190  : public WindowsARM64TargetInfo {
191 public:
192  MicrosoftARM64TargetInfo(const llvm::Triple &Triple,
193  const TargetOptions &Opts);
194 
195  void getTargetDefines(const LangOptions &Opts,
196  MacroBuilder &Builder) const override;
198  getCallingConvKind(bool ClangABICompat4) const override;
199 
200  unsigned getMinGlobalAlign(uint64_t TypeSize) const override;
201 };
202 
203 // ARM64 MinGW target
204 class LLVM_LIBRARY_VISIBILITY MinGWARM64TargetInfo
205  : public WindowsARM64TargetInfo {
206 public:
207  MinGWARM64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
208 };
209 
210 class LLVM_LIBRARY_VISIBILITY AArch64beTargetInfo : public AArch64TargetInfo {
211 public:
212  AArch64beTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
213  void getTargetDefines(const LangOptions &Opts,
214  MacroBuilder &Builder) const override;
215 
216 private:
217  void setDataLayout() override;
218 };
219 
220 class LLVM_LIBRARY_VISIBILITY DarwinAArch64TargetInfo
221  : public DarwinTargetInfo<AArch64leTargetInfo> {
222 public:
223  DarwinAArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
224 
225  BuiltinVaListKind getBuiltinVaListKind() const override;
226 
227  protected:
228  void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
229  MacroBuilder &Builder) const override;
230 };
231 
232 // 64-bit RenderScript is aarch64
233 class LLVM_LIBRARY_VISIBILITY RenderScript64TargetInfo
234  : public AArch64leTargetInfo {
235 public:
236  RenderScript64TargetInfo(const llvm::Triple &Triple,
237  const TargetOptions &Opts);
238 
239  void getTargetDefines(const LangOptions &Opts,
240  MacroBuilder &Builder) const override;
241 };
242 
243 } // namespace targets
244 } // namespace clang
245 
246 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_AARCH64_H
clang::targets::AArch64beTargetInfo
Definition: AArch64.h:210
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::DiagnosticsEngine
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:191
clang::TargetInfo
Exposes information about the current target.
Definition: TargetInfo.h:186
llvm::Optional
Definition: LLVM.h:40
Expression
clang::targets::MinGWARM64TargetInfo
Definition: AArch64.h:204
clang::TargetInfo::BuiltinVaListKind
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
Definition: TargetInfo.h:265
BuiltinInfo
static const Builtin::Info BuiltinInfo[]
Definition: Builtins.cpp:20
clang::targets::WindowsTargetInfo
Definition: OSTargets.h:820
clang::targets::DarwinTargetInfo
Definition: OSTargets.h:78
clang::targets::AArch64TargetInfo
Definition: AArch64.h:24
clang::targets::GCCRegNames
static const char *const GCCRegNames[]
Definition: X86.cpp:43
clang::targets::AArch64TargetInfo::getConstraintRegister
StringRef getConstraintRegister(StringRef Constraint, StringRef Expression) const override
Extracts a register from the passed constraint (if it is a single-register constraint) and the asm la...
Definition: AArch64.h:150
clang::CallingConv
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition: Specifiers.h:263
clang::TargetInfo::GCCRegAlias
Definition: TargetInfo.h:1155
clang::targets::AArch64TargetInfo::getBFloat16Mangling
const char * getBFloat16Mangling() const override
Return the mangled code of bfloat.
Definition: AArch64.h:157
clang::targets::AArch64leTargetInfo
Definition: AArch64.h:163
clang::targets::AArch64TargetInfo::convertConstraint
std::string convertConstraint(const char *&Constraint) const override
Definition: AArch64.h:129
clang::targets::RenderScript64TargetInfo
Definition: AArch64.h:233
clang::TargetInfo::BranchProtectionInfo
Definition: TargetInfo.h:1284
clang::targets::AArch64TargetInfo::hasBitIntType
bool hasBitIntType() const override
Determine whether the _BitInt type is supported on this target.
Definition: AArch64.h:160
clang::targets::AArch64TargetInfo::useFP16ConversionIntrinsics
bool useFP16ConversionIntrinsics() const override
Check whether llvm intrinsics such as llvm.convert.to.fp16 should be used to convert to and from __fp...
Definition: AArch64.h:80
llvm::ArrayRef
Definition: LLVM.h:34
TargetBuiltins.h
clang::TargetInfo::ConstraintInfo
Definition: TargetInfo.h:974
clang::LangOptions
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:58
clang
Definition: CalledOnceCheck.h:17
clang::Builtin::Info
Definition: Builtins.h:55
OSTargets.h
clang::targets::DarwinAArch64TargetInfo
Definition: AArch64.h:220
clang::TargetInfo::convertConstraint
virtual std::string convertConstraint(const char *&Constraint) const
Definition: TargetInfo.h:1120
clang::targets::MicrosoftARM64TargetInfo
Definition: AArch64.h:189
clang::TargetOptions
Options for controlling the target.
Definition: TargetOptions.h:26
llvm::SmallVectorImpl
Definition: LLVM.h:39
clang::TargetInfo::CallingConvCheckResult
CallingConvCheckResult
Definition: TargetInfo.h:1472
clang::MacroBuilder
Definition: MacroBuilder.h:23
clang::TargetInfo::CallingConvKind
CallingConvKind
Definition: TargetInfo.h:1492
clang::targets::WindowsARM64TargetInfo
Definition: AArch64.h:173
hasFeature
static bool hasFeature(StringRef Feature, const LangOptions &LangOpts, const TargetInfo &Target)
Determine whether a translation unit built using the current language options has the given feature.
Definition: Module.cpp:101