AArch64.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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. #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_AARCH64_H
  13. #define LLVM_CLANG_LIB_BASIC_TARGETS_AARCH64_H
  14. #include "OSTargets.h"
  15. #include "clang/Basic/TargetBuiltins.h"
  16. #include "llvm/Support/AArch64TargetParser.h"
  17. #include "llvm/Support/TargetParser.h"
  18. namespace clang {
  19. namespace targets {
  20. class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
  21. virtual void setDataLayout() = 0;
  22. static const TargetInfo::GCCRegAlias GCCRegAliases[];
  23. static const char *const GCCRegNames[];
  24. enum FPUModeEnum { FPUMode, NeonMode = (1 << 0), SveMode = (1 << 1) };
  25. unsigned FPU;
  26. bool HasCRC;
  27. bool HasCrypto;
  28. bool HasAES;
  29. bool HasSHA2;
  30. bool HasSHA3;
  31. bool HasSM4;
  32. bool HasUnaligned;
  33. bool HasFullFP16;
  34. bool HasDotProd;
  35. bool HasFP16FML;
  36. bool HasMTE;
  37. bool HasTME;
  38. bool HasPAuth;
  39. bool HasLS64;
  40. bool HasRandGen;
  41. bool HasMatMul;
  42. bool HasSVE2;
  43. bool HasSVE2AES;
  44. bool HasSVE2SHA3;
  45. bool HasSVE2SM4;
  46. bool HasSVE2BitPerm;
  47. bool HasMatmulFP64;
  48. bool HasMatmulFP32;
  49. bool HasLSE;
  50. bool HasFlagM;
  51. bool HasHBC;
  52. bool HasMOPS;
  53. llvm::AArch64::ArchKind ArchKind;
  54. static const Builtin::Info BuiltinInfo[];
  55. std::string ABI;
  56. StringRef getArchProfile() const;
  57. public:
  58. AArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
  59. StringRef getABI() const override;
  60. bool setABI(const std::string &Name) override;
  61. bool validateBranchProtection(StringRef Spec, StringRef Arch,
  62. BranchProtectionInfo &BPI,
  63. StringRef &Err) const override;
  64. bool isValidCPUName(StringRef Name) const override;
  65. void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
  66. bool setCPU(const std::string &Name) override;
  67. bool useFP16ConversionIntrinsics() const override {
  68. return false;
  69. }
  70. void getTargetDefinesARMV81A(const LangOptions &Opts,
  71. MacroBuilder &Builder) const;
  72. void getTargetDefinesARMV82A(const LangOptions &Opts,
  73. MacroBuilder &Builder) const;
  74. void getTargetDefinesARMV83A(const LangOptions &Opts,
  75. MacroBuilder &Builder) const;
  76. void getTargetDefinesARMV84A(const LangOptions &Opts,
  77. MacroBuilder &Builder) const;
  78. void getTargetDefinesARMV85A(const LangOptions &Opts,
  79. MacroBuilder &Builder) const;
  80. void getTargetDefinesARMV86A(const LangOptions &Opts,
  81. MacroBuilder &Builder) const;
  82. void getTargetDefinesARMV87A(const LangOptions &Opts,
  83. MacroBuilder &Builder) const;
  84. void getTargetDefinesARMV88A(const LangOptions &Opts,
  85. MacroBuilder &Builder) const;
  86. void getTargetDefinesARMV9A(const LangOptions &Opts,
  87. MacroBuilder &Builder) const;
  88. void getTargetDefinesARMV91A(const LangOptions &Opts,
  89. MacroBuilder &Builder) const;
  90. void getTargetDefinesARMV92A(const LangOptions &Opts,
  91. MacroBuilder &Builder) const;
  92. void getTargetDefinesARMV93A(const LangOptions &Opts,
  93. MacroBuilder &Builder) const;
  94. void getTargetDefines(const LangOptions &Opts,
  95. MacroBuilder &Builder) const override;
  96. ArrayRef<Builtin::Info> getTargetBuiltins() const override;
  97. Optional<std::pair<unsigned, unsigned>>
  98. getVScaleRange(const LangOptions &LangOpts) const override;
  99. bool hasFeature(StringRef Feature) const override;
  100. bool handleTargetFeatures(std::vector<std::string> &Features,
  101. DiagnosticsEngine &Diags) override;
  102. CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
  103. bool isCLZForZeroUndef() const override;
  104. BuiltinVaListKind getBuiltinVaListKind() const override;
  105. ArrayRef<const char *> getGCCRegNames() const override;
  106. ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;
  107. std::string convertConstraint(const char *&Constraint) const override {
  108. std::string R;
  109. switch (*Constraint) {
  110. case 'U': // Three-character constraint; add "@3" hint for later parsing.
  111. R = std::string("@3") + std::string(Constraint, 3);
  112. Constraint += 2;
  113. break;
  114. default:
  115. R = TargetInfo::convertConstraint(Constraint);
  116. break;
  117. }
  118. return R;
  119. }
  120. bool validateAsmConstraint(const char *&Name,
  121. TargetInfo::ConstraintInfo &Info) const override;
  122. bool
  123. validateConstraintModifier(StringRef Constraint, char Modifier, unsigned Size,
  124. std::string &SuggestedModifier) const override;
  125. const char *getClobbers() const override;
  126. StringRef getConstraintRegister(StringRef Constraint,
  127. StringRef Expression) const override {
  128. return Expression;
  129. }
  130. int getEHDataRegisterNumber(unsigned RegNo) const override;
  131. const char *getBFloat16Mangling() const override { return "u6__bf16"; };
  132. bool hasInt128Type() const override;
  133. bool hasBitIntType() const override { return true; }
  134. };
  135. class LLVM_LIBRARY_VISIBILITY AArch64leTargetInfo : public AArch64TargetInfo {
  136. public:
  137. AArch64leTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
  138. void getTargetDefines(const LangOptions &Opts,
  139. MacroBuilder &Builder) const override;
  140. private:
  141. void setDataLayout() override;
  142. };
  143. class LLVM_LIBRARY_VISIBILITY WindowsARM64TargetInfo
  144. : public WindowsTargetInfo<AArch64leTargetInfo> {
  145. const llvm::Triple Triple;
  146. public:
  147. WindowsARM64TargetInfo(const llvm::Triple &Triple,
  148. const TargetOptions &Opts);
  149. void setDataLayout() override;
  150. BuiltinVaListKind getBuiltinVaListKind() const override;
  151. CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
  152. };
  153. // Windows ARM, MS (C++) ABI
  154. class LLVM_LIBRARY_VISIBILITY MicrosoftARM64TargetInfo
  155. : public WindowsARM64TargetInfo {
  156. public:
  157. MicrosoftARM64TargetInfo(const llvm::Triple &Triple,
  158. const TargetOptions &Opts);
  159. void getTargetDefines(const LangOptions &Opts,
  160. MacroBuilder &Builder) const override;
  161. TargetInfo::CallingConvKind
  162. getCallingConvKind(bool ClangABICompat4) const override;
  163. unsigned getMinGlobalAlign(uint64_t TypeSize) const override;
  164. };
  165. // ARM64 MinGW target
  166. class LLVM_LIBRARY_VISIBILITY MinGWARM64TargetInfo
  167. : public WindowsARM64TargetInfo {
  168. public:
  169. MinGWARM64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
  170. };
  171. class LLVM_LIBRARY_VISIBILITY AArch64beTargetInfo : public AArch64TargetInfo {
  172. public:
  173. AArch64beTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
  174. void getTargetDefines(const LangOptions &Opts,
  175. MacroBuilder &Builder) const override;
  176. private:
  177. void setDataLayout() override;
  178. };
  179. class LLVM_LIBRARY_VISIBILITY DarwinAArch64TargetInfo
  180. : public DarwinTargetInfo<AArch64leTargetInfo> {
  181. public:
  182. DarwinAArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
  183. BuiltinVaListKind getBuiltinVaListKind() const override;
  184. protected:
  185. void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
  186. MacroBuilder &Builder) const override;
  187. };
  188. // 64-bit RenderScript is aarch64
  189. class LLVM_LIBRARY_VISIBILITY RenderScript64TargetInfo
  190. : public AArch64leTargetInfo {
  191. public:
  192. RenderScript64TargetInfo(const llvm::Triple &Triple,
  193. const TargetOptions &Opts);
  194. void getTargetDefines(const LangOptions &Opts,
  195. MacroBuilder &Builder) const override;
  196. };
  197. } // namespace targets
  198. } // namespace clang
  199. #endif // LLVM_CLANG_LIB_BASIC_TARGETS_AARCH64_H