clang  15.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 HasAES;
34  bool HasSHA2;
35  bool HasSHA3;
36  bool HasSM4;
37  bool HasUnaligned;
38  bool HasFullFP16;
39  bool HasDotProd;
40  bool HasFP16FML;
41  bool HasMTE;
42  bool HasTME;
43  bool HasPAuth;
44  bool HasLS64;
45  bool HasRandGen;
46  bool HasMatMul;
47  bool HasSVE2;
48  bool HasSVE2AES;
49  bool HasSVE2SHA3;
50  bool HasSVE2SM4;
51  bool HasSVE2BitPerm;
52  bool HasMatmulFP64;
53  bool HasMatmulFP32;
54  bool HasLSE;
55  bool HasFlagM;
56  bool HasMOPS;
57 
58  llvm::AArch64::ArchKind ArchKind;
59 
60  static const Builtin::Info BuiltinInfo[];
61 
62  std::string ABI;
63  StringRef getArchProfile() const;
64 
65 public:
66  AArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
67 
68  StringRef getABI() const override;
69  bool setABI(const std::string &Name) override;
70 
71  bool validateBranchProtection(StringRef Spec, StringRef Arch,
73  StringRef &Err) const override;
74 
75  bool isValidCPUName(StringRef Name) const override;
76  void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
77  bool setCPU(const std::string &Name) override;
78 
79  bool useFP16ConversionIntrinsics() const override {
80  return false;
81  }
82 
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;
109 
110  ArrayRef<Builtin::Info> getTargetBuiltins() const override;
111 
113  getVScaleRange(const LangOptions &LangOpts) const override;
114 
115  bool hasFeature(StringRef Feature) const override;
116  bool handleTargetFeatures(std::vector<std::string> &Features,
117  DiagnosticsEngine &Diags) override;
118 
119  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
120 
121  bool isCLZForZeroUndef() const override;
122 
123  BuiltinVaListKind getBuiltinVaListKind() const override;
124 
125  ArrayRef<const char *> getGCCRegNames() const override;
126  ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;
127 
128  std::string convertConstraint(const char *&Constraint) const override {
129  std::string R;
130  switch (*Constraint) {
131  case 'U': // Three-character constraint; add "@3" hint for later parsing.
132  R = std::string("@3") + std::string(Constraint, 3);
133  Constraint += 2;
134  break;
135  default:
136  R = TargetInfo::convertConstraint(Constraint);
137  break;
138  }
139  return R;
140  }
141 
142  bool validateAsmConstraint(const char *&Name,
143  TargetInfo::ConstraintInfo &Info) const override;
144  bool
145  validateConstraintModifier(StringRef Constraint, char Modifier, unsigned Size,
146  std::string &SuggestedModifier) const override;
147  const char *getClobbers() const override;
148 
149  StringRef getConstraintRegister(StringRef Constraint,
150  StringRef Expression) const override {
151  return Expression;
152  }
153 
154  int getEHDataRegisterNumber(unsigned RegNo) const override;
155 
156  const char *getBFloat16Mangling() const override { return "u6__bf16"; };
157  bool hasInt128Type() const override;
158 
159  bool hasBitIntType() const override { return true; }
160 };
161 
162 class LLVM_LIBRARY_VISIBILITY AArch64leTargetInfo : public AArch64TargetInfo {
163 public:
164  AArch64leTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
165 
166  void getTargetDefines(const LangOptions &Opts,
167  MacroBuilder &Builder) const override;
168 private:
169  void setDataLayout() override;
170 };
171 
172 class LLVM_LIBRARY_VISIBILITY WindowsARM64TargetInfo
173  : public WindowsTargetInfo<AArch64leTargetInfo> {
174  const llvm::Triple Triple;
175 
176 public:
177  WindowsARM64TargetInfo(const llvm::Triple &Triple,
178  const TargetOptions &Opts);
179 
180  void setDataLayout() override;
181 
182  BuiltinVaListKind getBuiltinVaListKind() const override;
183 
184  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
185 };
186 
187 // Windows ARM, MS (C++) ABI
188 class LLVM_LIBRARY_VISIBILITY MicrosoftARM64TargetInfo
189  : public WindowsARM64TargetInfo {
190 public:
191  MicrosoftARM64TargetInfo(const llvm::Triple &Triple,
192  const TargetOptions &Opts);
193 
194  void getTargetDefines(const LangOptions &Opts,
195  MacroBuilder &Builder) const override;
197  getCallingConvKind(bool ClangABICompat4) const override;
198 
199  unsigned getMinGlobalAlign(uint64_t TypeSize) const override;
200 };
201 
202 // ARM64 MinGW target
203 class LLVM_LIBRARY_VISIBILITY MinGWARM64TargetInfo
204  : public WindowsARM64TargetInfo {
205 public:
206  MinGWARM64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
207 };
208 
209 class LLVM_LIBRARY_VISIBILITY AArch64beTargetInfo : public AArch64TargetInfo {
210 public:
211  AArch64beTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
212  void getTargetDefines(const LangOptions &Opts,
213  MacroBuilder &Builder) const override;
214 
215 private:
216  void setDataLayout() override;
217 };
218 
219 class LLVM_LIBRARY_VISIBILITY DarwinAArch64TargetInfo
220  : public DarwinTargetInfo<AArch64leTargetInfo> {
221 public:
222  DarwinAArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
223 
224  BuiltinVaListKind getBuiltinVaListKind() const override;
225 
226  protected:
227  void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
228  MacroBuilder &Builder) const override;
229 };
230 
231 // 64-bit RenderScript is aarch64
232 class LLVM_LIBRARY_VISIBILITY RenderScript64TargetInfo
233  : public AArch64leTargetInfo {
234 public:
235  RenderScript64TargetInfo(const llvm::Triple &Triple,
236  const TargetOptions &Opts);
237 
238  void getTargetDefines(const LangOptions &Opts,
239  MacroBuilder &Builder) const override;
240 };
241 
242 } // namespace targets
243 } // namespace clang
244 
245 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_AARCH64_H
clang::targets::AArch64beTargetInfo
Definition: AArch64.h:209
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:192
clang::TargetInfo
Exposes information about the current target.
Definition: TargetInfo.h:189
llvm::Optional
Definition: LLVM.h:40
Expression
clang::targets::MinGWARM64TargetInfo
Definition: AArch64.h:203
clang::TargetInfo::BuiltinVaListKind
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
Definition: TargetInfo.h:272
uint64_t
unsigned long uint64_t
Definition: hlsl_basic_types.h:24
BuiltinInfo
static const Builtin::Info BuiltinInfo[]
Definition: Builtins.cpp:21
clang::targets::WindowsTargetInfo
Definition: OSTargets.h:856
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:149
clang::CallingConv
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition: Specifiers.h:263
clang::TargetInfo::GCCRegAlias
Definition: TargetInfo.h:1184
clang::targets::AArch64TargetInfo::getBFloat16Mangling
const char * getBFloat16Mangling() const override
Return the mangled code of bfloat.
Definition: AArch64.h:156
clang::targets::AArch64leTargetInfo
Definition: AArch64.h:162
clang::targets::AArch64TargetInfo::convertConstraint
std::string convertConstraint(const char *&Constraint) const override
Definition: AArch64.h:128
clang::targets::RenderScript64TargetInfo
Definition: AArch64.h:232
clang::TargetInfo::BranchProtectionInfo
Definition: TargetInfo.h:1313
clang::targets::AArch64TargetInfo::hasBitIntType
bool hasBitIntType() const override
Determine whether the _BitInt type is supported on this target.
Definition: AArch64.h:159
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:79
llvm::ArrayRef
Definition: LLVM.h:34
TargetBuiltins.h
clang::TargetInfo::ConstraintInfo
Definition: TargetInfo.h:1003
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:78
clang
Definition: CalledOnceCheck.h:17
clang::Builtin::Info
Definition: Builtins.h:59
OSTargets.h
clang::targets::DarwinAArch64TargetInfo
Definition: AArch64.h:219
clang::TargetInfo::convertConstraint
virtual std::string convertConstraint(const char *&Constraint) const
Definition: TargetInfo.h:1149
clang::targets::MicrosoftARM64TargetInfo
Definition: AArch64.h:188
clang::TargetOptions
Options for controlling the target.
Definition: TargetOptions.h:26
llvm::SmallVectorImpl
Definition: Randstruct.h:18
clang::TargetInfo::CallingConvCheckResult
CallingConvCheckResult
Definition: TargetInfo.h:1516
clang::MacroBuilder
Definition: MacroBuilder.h:23
clang::TargetInfo::CallingConvKind
CallingConvKind
Definition: TargetInfo.h:1536
clang::targets::WindowsARM64TargetInfo
Definition: AArch64.h:172
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