SystemZ.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. //===--- SystemZ.h - Declare SystemZ 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 SystemZ TargetInfo objects.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_SYSTEMZ_H
  13. #define LLVM_CLANG_LIB_BASIC_TARGETS_SYSTEMZ_H
  14. #include "clang/Basic/TargetInfo.h"
  15. #include "clang/Basic/TargetOptions.h"
  16. #include "llvm/ADT/Triple.h"
  17. #include "llvm/Support/Compiler.h"
  18. namespace clang {
  19. namespace targets {
  20. class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo {
  21. static const Builtin::Info BuiltinInfo[];
  22. static const char *const GCCRegNames[];
  23. std::string CPU;
  24. int ISARevision;
  25. bool HasTransactionalExecution;
  26. bool HasVector;
  27. public:
  28. SystemZTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
  29. : TargetInfo(Triple), CPU("z10"), ISARevision(8),
  30. HasTransactionalExecution(false), HasVector(false) {
  31. IntMaxType = SignedLong;
  32. Int64Type = SignedLong;
  33. TLSSupported = true;
  34. IntWidth = IntAlign = 32;
  35. LongWidth = LongLongWidth = LongAlign = LongLongAlign = 64;
  36. PointerWidth = PointerAlign = 64;
  37. LongDoubleWidth = 128;
  38. LongDoubleAlign = 64;
  39. LongDoubleFormat = &llvm::APFloat::IEEEquad();
  40. DefaultAlignForAttributeAligned = 64;
  41. MinGlobalAlign = 16;
  42. resetDataLayout("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64");
  43. MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
  44. }
  45. void getTargetDefines(const LangOptions &Opts,
  46. MacroBuilder &Builder) const override;
  47. ArrayRef<Builtin::Info> getTargetBuiltins() const override;
  48. ArrayRef<const char *> getGCCRegNames() const override;
  49. ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
  50. // No aliases.
  51. return None;
  52. }
  53. ArrayRef<TargetInfo::AddlRegName> getGCCAddlRegNames() const override;
  54. bool validateAsmConstraint(const char *&Name,
  55. TargetInfo::ConstraintInfo &info) const override;
  56. const char *getClobbers() const override {
  57. // FIXME: Is this really right?
  58. return "";
  59. }
  60. BuiltinVaListKind getBuiltinVaListKind() const override {
  61. return TargetInfo::SystemZBuiltinVaList;
  62. }
  63. int getISARevision(StringRef Name) const;
  64. bool isValidCPUName(StringRef Name) const override {
  65. return getISARevision(Name) != -1;
  66. }
  67. void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
  68. bool setCPU(const std::string &Name) override {
  69. CPU = Name;
  70. ISARevision = getISARevision(CPU);
  71. return ISARevision != -1;
  72. }
  73. bool
  74. initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags,
  75. StringRef CPU,
  76. const std::vector<std::string> &FeaturesVec) const override {
  77. int ISARevision = getISARevision(CPU);
  78. if (ISARevision >= 10)
  79. Features["transactional-execution"] = true;
  80. if (ISARevision >= 11)
  81. Features["vector"] = true;
  82. if (ISARevision >= 12)
  83. Features["vector-enhancements-1"] = true;
  84. if (ISARevision >= 13)
  85. Features["vector-enhancements-2"] = true;
  86. return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
  87. }
  88. bool handleTargetFeatures(std::vector<std::string> &Features,
  89. DiagnosticsEngine &Diags) override {
  90. HasTransactionalExecution = false;
  91. HasVector = false;
  92. for (const auto &Feature : Features) {
  93. if (Feature == "+transactional-execution")
  94. HasTransactionalExecution = true;
  95. else if (Feature == "+vector")
  96. HasVector = true;
  97. }
  98. // If we use the vector ABI, vector types are 64-bit aligned.
  99. if (HasVector) {
  100. MaxVectorAlign = 64;
  101. resetDataLayout("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64"
  102. "-v128:64-a:8:16-n32:64");
  103. }
  104. return true;
  105. }
  106. bool hasFeature(StringRef Feature) const override;
  107. CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
  108. switch (CC) {
  109. case CC_C:
  110. case CC_Swift:
  111. case CC_OpenCLKernel:
  112. return CCCR_OK;
  113. default:
  114. return CCCR_Warning;
  115. }
  116. }
  117. StringRef getABI() const override {
  118. if (HasVector)
  119. return "vector";
  120. return "";
  121. }
  122. const char *getLongDoubleMangling() const override { return "g"; }
  123. };
  124. } // namespace targets
  125. } // namespace clang
  126. #endif // LLVM_CLANG_LIB_BASIC_TARGETS_SYSTEMZ_H