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