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/TargetParser.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 HasCrypto;
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 
57  llvm::AArch64::ArchKind ArchKind;
58 
59  static const Builtin::Info BuiltinInfo[];
60 
61  std::string ABI;
62 
63 public:
64  AArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
65 
66  StringRef getABI() const override;
67  bool setABI(const std::string &Name) override;
68 
69  bool validateBranchProtection(StringRef, BranchProtectionInfo &,
70  StringRef &) const override;
71 
72  bool isValidCPUName(StringRef Name) const override;
73  void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
74  bool setCPU(const std::string &Name) override;
75 
76  bool useFP16ConversionIntrinsics() const override {
77  return false;
78  }
79 
80  void getTargetDefinesARMV81A(const LangOptions &Opts,
81  MacroBuilder &Builder) const;
82  void getTargetDefinesARMV82A(const LangOptions &Opts,
83  MacroBuilder &Builder) const;
84  void getTargetDefinesARMV83A(const LangOptions &Opts,
85  MacroBuilder &Builder) const;
86  void getTargetDefinesARMV84A(const LangOptions &Opts,
87  MacroBuilder &Builder) const;
88  void getTargetDefinesARMV85A(const LangOptions &Opts,
89  MacroBuilder &Builder) const;
90  void getTargetDefinesARMV86A(const LangOptions &Opts,
91  MacroBuilder &Builder) const;
92  void getTargetDefinesARMV87A(const LangOptions &Opts,
93  MacroBuilder &Builder) const;
94  void getTargetDefinesARMV9A(const LangOptions &Opts,
95  MacroBuilder &Builder) const;
96  void getTargetDefinesARMV91A(const LangOptions &Opts,
97  MacroBuilder &Builder) const;
98  void getTargetDefinesARMV92A(const LangOptions &Opts,
99  MacroBuilder &Builder) const;
100  void getTargetDefines(const LangOptions &Opts,
101  MacroBuilder &Builder) const override;
102 
103  ArrayRef<Builtin::Info> getTargetBuiltins() const override;
104 
106  getVScaleRange(const LangOptions &LangOpts) const override;
107 
108  bool hasFeature(StringRef Feature) const override;
109  bool handleTargetFeatures(std::vector<std::string> &Features,
110  DiagnosticsEngine &Diags) override;
111 
112  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
113 
114  bool isCLZForZeroUndef() const override;
115 
116  BuiltinVaListKind getBuiltinVaListKind() const override;
117 
118  ArrayRef<const char *> getGCCRegNames() const override;
119  ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;
120 
121  std::string convertConstraint(const char *&Constraint) const override {
122  std::string R;
123  switch (*Constraint) {
124  case 'U': // Three-character constraint; add "@3" hint for later parsing.
125  R = std::string("@3") + std::string(Constraint, 3);
126  Constraint += 2;
127  break;
128  default:
129  R = TargetInfo::convertConstraint(Constraint);
130  break;
131  }
132  return R;
133  }
134 
135  bool validateAsmConstraint(const char *&Name,
136  TargetInfo::ConstraintInfo &Info) const override;
137  bool
138  validateConstraintModifier(StringRef Constraint, char Modifier, unsigned Size,
139  std::string &SuggestedModifier) const override;
140  const char *getClobbers() const override;
141 
142  StringRef getConstraintRegister(StringRef Constraint,
143  StringRef Expression) const override {
144  return Expression;
145  }
146 
147  int getEHDataRegisterNumber(unsigned RegNo) const override;
148 
149  const char *getBFloat16Mangling() const override { return "u6__bf16"; };
150  bool hasInt128Type() const override;
151 
152  bool hasExtIntType() const override { return true; }
153 };
154 
155 class LLVM_LIBRARY_VISIBILITY AArch64leTargetInfo : public AArch64TargetInfo {
156 public:
157  AArch64leTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
158 
159  void getTargetDefines(const LangOptions &Opts,
160  MacroBuilder &Builder) const override;
161 private:
162  void setDataLayout() override;
163 };
164 
165 class LLVM_LIBRARY_VISIBILITY WindowsARM64TargetInfo
166  : public WindowsTargetInfo<AArch64leTargetInfo> {
167  const llvm::Triple Triple;
168 
169 public:
170  WindowsARM64TargetInfo(const llvm::Triple &Triple,
171  const TargetOptions &Opts);
172 
173  void setDataLayout() override;
174 
175  BuiltinVaListKind getBuiltinVaListKind() const override;
176 
177  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
178 };
179 
180 // Windows ARM, MS (C++) ABI
181 class LLVM_LIBRARY_VISIBILITY MicrosoftARM64TargetInfo
182  : public WindowsARM64TargetInfo {
183 public:
184  MicrosoftARM64TargetInfo(const llvm::Triple &Triple,
185  const TargetOptions &Opts);
186 
187  void getTargetDefines(const LangOptions &Opts,
188  MacroBuilder &Builder) const override;
190  getCallingConvKind(bool ClangABICompat4) const override;
191 
192  unsigned getMinGlobalAlign(uint64_t TypeSize) const override;
193 };
194 
195 // ARM64 MinGW target
196 class LLVM_LIBRARY_VISIBILITY MinGWARM64TargetInfo
197  : public WindowsARM64TargetInfo {
198 public:
199  MinGWARM64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
200 };
201 
202 class LLVM_LIBRARY_VISIBILITY AArch64beTargetInfo : public AArch64TargetInfo {
203 public:
204  AArch64beTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
205  void getTargetDefines(const LangOptions &Opts,
206  MacroBuilder &Builder) const override;
207 
208 private:
209  void setDataLayout() override;
210 };
211 
212 class LLVM_LIBRARY_VISIBILITY DarwinAArch64TargetInfo
213  : public DarwinTargetInfo<AArch64leTargetInfo> {
214 public:
215  DarwinAArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
216 
217  BuiltinVaListKind getBuiltinVaListKind() const override;
218 
219  protected:
220  void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
221  MacroBuilder &Builder) const override;
222 };
223 
224 // 64-bit RenderScript is aarch64
225 class LLVM_LIBRARY_VISIBILITY RenderScript64TargetInfo
226  : public AArch64leTargetInfo {
227 public:
228  RenderScript64TargetInfo(const llvm::Triple &Triple,
229  const TargetOptions &Opts);
230 
231  void getTargetDefines(const LangOptions &Opts,
232  MacroBuilder &Builder) const override;
233 };
234 
235 } // namespace targets
236 } // namespace clang
237 
238 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_AARCH64_H
clang::targets::AArch64beTargetInfo
Definition: AArch64.h:202
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:189
llvm::Optional
Definition: LLVM.h:40
Expression
clang::targets::MinGWARM64TargetInfo
Definition: AArch64.h:196
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::AArch64TargetInfo::hasExtIntType
bool hasExtIntType() const override
Determine whether the _ExtInt type is supported on this target.
Definition: AArch64.h:152
clang::targets::WindowsTargetInfo
Definition: OSTargets.h:813
clang::targets::DarwinTargetInfo
Definition: OSTargets.h:78
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:142
clang::CallingConv
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition: Specifiers.h:263
clang::TargetInfo::GCCRegAlias
Definition: TargetInfo.h:1142
clang::targets::AArch64TargetInfo::getBFloat16Mangling
const char * getBFloat16Mangling() const override
Return the mangled code of bfloat.
Definition: AArch64.h:149
clang::targets::AArch64leTargetInfo
Definition: AArch64.h:155
clang::targets::AArch64TargetInfo::convertConstraint
std::string convertConstraint(const char *&Constraint) const override
Definition: AArch64.h:121
clang::targets::RenderScript64TargetInfo
Definition: AArch64.h:225
clang::TargetInfo::BranchProtectionInfo
Definition: TargetInfo.h:1271
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:76
llvm::ArrayRef
Definition: LLVM.h:34
TargetBuiltins.h
clang::TargetInfo::ConstraintInfo
Definition: TargetInfo.h:960
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:212
clang::TargetInfo::convertConstraint
virtual std::string convertConstraint(const char *&Constraint) const
Definition: TargetInfo.h:1107
clang::targets::MicrosoftARM64TargetInfo
Definition: AArch64.h:181
clang::TargetOptions
Options for controlling the target.
Definition: TargetOptions.h:26
llvm::SmallVectorImpl
Definition: LLVM.h:39
clang::TargetInfo::CallingConvCheckResult
CallingConvCheckResult
Definition: TargetInfo.h:1459
clang::MacroBuilder
Definition: MacroBuilder.h:23
clang::TargetInfo::CallingConvKind
CallingConvKind
Definition: TargetInfo.h:1479
clang::targets::WindowsARM64TargetInfo
Definition: AArch64.h:165
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