clang  16.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 
20 namespace clang {
21 namespace targets {
22 
23 class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
24  virtual void setDataLayout() = 0;
25  static const TargetInfo::GCCRegAlias GCCRegAliases[];
26  static const char *const GCCRegNames[];
27 
28  enum FPUModeEnum { FPUMode, NeonMode = (1 << 0), SveMode = (1 << 1) };
29 
30  unsigned FPU;
31  bool HasCRC;
32  bool HasAES;
33  bool HasSHA2;
34  bool HasSHA3;
35  bool HasSM4;
36  bool HasUnaligned;
37  bool HasFullFP16;
38  bool HasDotProd;
39  bool HasFP16FML;
40  bool HasMTE;
41  bool HasTME;
42  bool HasPAuth;
43  bool HasLS64;
44  bool HasRandGen;
45  bool HasMatMul;
46  bool HasSVE2;
47  bool HasSVE2AES;
48  bool HasSVE2SHA3;
49  bool HasSVE2SM4;
50  bool HasSVE2BitPerm;
51  bool HasMatmulFP64;
52  bool HasMatmulFP32;
53  bool HasLSE;
54  bool HasFlagM;
55  bool HasMOPS;
56  bool HasD128;
57  bool HasRCPC;
58 
59  llvm::AArch64::ArchKind ArchKind;
60 
61  static const Builtin::Info BuiltinInfo[];
62 
63  std::string ABI;
64  StringRef getArchProfile() const;
65 
66 public:
67  AArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
68 
69  StringRef getABI() const override;
70  bool setABI(const std::string &Name) override;
71 
72  bool validateBranchProtection(StringRef Spec, StringRef Arch,
74  StringRef &Err) 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 getTargetDefinesARMV89A(const LangOptions &Opts,
101  MacroBuilder &Builder) const;
102  void getTargetDefinesARMV9A(const LangOptions &Opts,
103  MacroBuilder &Builder) const;
104  void getTargetDefinesARMV91A(const LangOptions &Opts,
105  MacroBuilder &Builder) const;
106  void getTargetDefinesARMV92A(const LangOptions &Opts,
107  MacroBuilder &Builder) const;
108  void getTargetDefinesARMV93A(const LangOptions &Opts,
109  MacroBuilder &Builder) const;
110  void getTargetDefinesARMV94A(const LangOptions &Opts,
111  MacroBuilder &Builder) const;
112  void getTargetDefines(const LangOptions &Opts,
113  MacroBuilder &Builder) const override;
114 
115  ArrayRef<Builtin::Info> getTargetBuiltins() const override;
116 
118  getVScaleRange(const LangOptions &LangOpts) const override;
119 
120  bool hasFeature(StringRef Feature) const override;
121  void setFeatureEnabled(llvm::StringMap<bool> &Features, StringRef Name,
122  bool Enabled) const override;
123  bool handleTargetFeatures(std::vector<std::string> &Features,
124  DiagnosticsEngine &Diags) override;
125  bool
126  initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags,
127  StringRef CPU,
128  const std::vector<std::string> &FeaturesVec) const override;
129  ParsedTargetAttr parseTargetAttr(StringRef Str) const override;
130  bool supportsTargetAttributeTune() const override { return true; }
131 
132  bool hasBFloat16Type() const override;
133 
134  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
135 
136  bool isCLZForZeroUndef() const override;
137 
138  BuiltinVaListKind getBuiltinVaListKind() const override;
139 
140  ArrayRef<const char *> getGCCRegNames() const override;
141  ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;
142 
143  std::string convertConstraint(const char *&Constraint) const override {
144  std::string R;
145  switch (*Constraint) {
146  case 'U': // Three-character constraint; add "@3" hint for later parsing.
147  R = std::string("@3") + std::string(Constraint, 3);
148  Constraint += 2;
149  break;
150  default:
151  R = TargetInfo::convertConstraint(Constraint);
152  break;
153  }
154  return R;
155  }
156 
157  bool validateAsmConstraint(const char *&Name,
158  TargetInfo::ConstraintInfo &Info) const override;
159  bool
160  validateConstraintModifier(StringRef Constraint, char Modifier, unsigned Size,
161  std::string &SuggestedModifier) const override;
162  const char *getClobbers() const override;
163 
164  StringRef getConstraintRegister(StringRef Constraint,
165  StringRef Expression) const override {
166  return Expression;
167  }
168 
169  int getEHDataRegisterNumber(unsigned RegNo) const override;
170 
171  const char *getBFloat16Mangling() const override { return "u6__bf16"; };
172  bool hasInt128Type() const override;
173 
174  bool hasBitIntType() const override { return true; }
175 };
176 
177 class LLVM_LIBRARY_VISIBILITY AArch64leTargetInfo : public AArch64TargetInfo {
178 public:
179  AArch64leTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
180 
181  void getTargetDefines(const LangOptions &Opts,
182  MacroBuilder &Builder) const override;
183 private:
184  void setDataLayout() override;
185 };
186 
187 class LLVM_LIBRARY_VISIBILITY WindowsARM64TargetInfo
188  : public WindowsTargetInfo<AArch64leTargetInfo> {
189  const llvm::Triple Triple;
190 
191 public:
192  WindowsARM64TargetInfo(const llvm::Triple &Triple,
193  const TargetOptions &Opts);
194 
195  void setDataLayout() override;
196 
197  BuiltinVaListKind getBuiltinVaListKind() const override;
198 
199  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
200 };
201 
202 // Windows ARM, MS (C++) ABI
203 class LLVM_LIBRARY_VISIBILITY MicrosoftARM64TargetInfo
204  : public WindowsARM64TargetInfo {
205 public:
206  MicrosoftARM64TargetInfo(const llvm::Triple &Triple,
207  const TargetOptions &Opts);
208 
209  void getTargetDefines(const LangOptions &Opts,
210  MacroBuilder &Builder) const override;
212  getCallingConvKind(bool ClangABICompat4) const override;
213 
214  unsigned getMinGlobalAlign(uint64_t TypeSize) const override;
215 };
216 
217 // ARM64 MinGW target
218 class LLVM_LIBRARY_VISIBILITY MinGWARM64TargetInfo
219  : public WindowsARM64TargetInfo {
220 public:
221  MinGWARM64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
222 };
223 
224 class LLVM_LIBRARY_VISIBILITY AArch64beTargetInfo : public AArch64TargetInfo {
225 public:
226  AArch64beTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
227  void getTargetDefines(const LangOptions &Opts,
228  MacroBuilder &Builder) const override;
229 
230 private:
231  void setDataLayout() override;
232 };
233 
234 class LLVM_LIBRARY_VISIBILITY DarwinAArch64TargetInfo
235  : public DarwinTargetInfo<AArch64leTargetInfo> {
236 public:
237  DarwinAArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
238 
239  BuiltinVaListKind getBuiltinVaListKind() const override;
240 
241  protected:
242  void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
243  MacroBuilder &Builder) const override;
244 };
245 
246 // 64-bit RenderScript is aarch64
247 class LLVM_LIBRARY_VISIBILITY RenderScript64TargetInfo
248  : public AArch64leTargetInfo {
249 public:
250  RenderScript64TargetInfo(const llvm::Triple &Triple,
251  const TargetOptions &Opts);
252 
253  void getTargetDefines(const LangOptions &Opts,
254  MacroBuilder &Builder) const override;
255 };
256 
257 } // namespace targets
258 } // namespace clang
259 
260 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_AARCH64_H
clang::targets::AArch64beTargetInfo
Definition: AArch64.h:224
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::ParsedTargetAttr
Contains information gathered from parsing the contents of TargetAttr.
Definition: TargetInfo.h:55
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:206
llvm::Optional
Definition: LLVM.h:40
Expression
clang::targets::MinGWARM64TargetInfo
Definition: AArch64.h:218
clang::TargetInfo::BuiltinVaListKind
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
Definition: TargetInfo.h:289
BuiltinInfo
static const Builtin::Info BuiltinInfo[]
Definition: Builtins.cpp:21
clang::targets::WindowsTargetInfo
Definition: OSTargets.h:841
clang::targets::DarwinTargetInfo
Definition: OSTargets.h:76
hlsl::uint64_t
unsigned long uint64_t
Definition: hlsl_basic_types.h:25
clang::targets::AArch64TargetInfo
Definition: AArch64.h:23
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:164
clang::CallingConv
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition: Specifiers.h:266
clang::TargetInfo::GCCRegAlias
Definition: TargetInfo.h:1212
clang::targets::AArch64TargetInfo::getBFloat16Mangling
const char * getBFloat16Mangling() const override
Return the mangled code of bfloat.
Definition: AArch64.h:171
clang::targets::AArch64leTargetInfo
Definition: AArch64.h:177
clang::targets::AArch64TargetInfo::convertConstraint
std::string convertConstraint(const char *&Constraint) const override
Definition: AArch64.h:143
clang::targets::RenderScript64TargetInfo
Definition: AArch64.h:247
clang::TargetInfo::BranchProtectionInfo
Definition: TargetInfo.h:1343
clang::targets::AArch64TargetInfo::hasBitIntType
bool hasBitIntType() const override
Determine whether the _BitInt type is supported on this target.
Definition: AArch64.h:174
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
clang::targets::AArch64TargetInfo::supportsTargetAttributeTune
bool supportsTargetAttributeTune() const override
brief Determine whether this TargetInfo supports tune in target attribute.
Definition: AArch64.h:130
TargetBuiltins.h
clang::TargetInfo::ConstraintInfo
Definition: TargetInfo.h:1029
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:81
clang
Definition: CalledOnceCheck.h:17
clang::Builtin::Info
Definition: Builtins.h:59
OSTargets.h
clang::targets::DarwinAArch64TargetInfo
Definition: AArch64.h:234
clang::TargetInfo::convertConstraint
virtual std::string convertConstraint(const char *&Constraint) const
Definition: TargetInfo.h:1175
clang::targets::MicrosoftARM64TargetInfo
Definition: AArch64.h:203
clang::TargetOptions
Options for controlling the target.
Definition: TargetOptions.h:26
llvm::SmallVectorImpl
Definition: Randstruct.h:18
clang::TargetInfo::CallingConvCheckResult
CallingConvCheckResult
Definition: TargetInfo.h:1553
clang::MacroBuilder
Definition: MacroBuilder.h:23
clang::TargetInfo::CallingConvKind
CallingConvKind
Definition: TargetInfo.h:1573
clang::targets::WindowsARM64TargetInfo
Definition: AArch64.h:187
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