blob: 3023c1d2ea2625e3e6a82be6ccd887756bd59a36 [file] [log] [blame]
Erich Keaneebba5922017-07-21 22:37:03 +00001//===--- 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
22namespace clang {
23namespace targets {
24
25class 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
34public:
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
65 bool validateAsmConstraint(const char *&Name,
66 TargetInfo::ConstraintInfo &info) const override;
67
68 const char *getClobbers() const override {
69 // FIXME: Is this really right?
70 return "";
71 }
72
73 BuiltinVaListKind getBuiltinVaListKind() const override {
74 return TargetInfo::SystemZBuiltinVaList;
75 }
76
77 int getISARevision(const StringRef &Name) const;
78
79 bool isValidCPUName(StringRef Name) const override {
80 return getISARevision(Name) != -1;
81 }
82
83 bool setCPU(const std::string &Name) override {
84 CPU = Name;
85 ISARevision = getISARevision(CPU);
86 return ISARevision != -1;
87 }
88
89 bool
90 initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags,
91 StringRef CPU,
92 const std::vector<std::string> &FeaturesVec) const override {
93 int ISARevision = getISARevision(CPU);
94 if (ISARevision >= 10)
95 Features["transactional-execution"] = true;
96 if (ISARevision >= 11)
97 Features["vector"] = true;
98 if (ISARevision >= 12)
99 Features["vector-enhancements-1"] = true;
100 return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
101 }
102
103 bool handleTargetFeatures(std::vector<std::string> &Features,
104 DiagnosticsEngine &Diags) override {
105 HasTransactionalExecution = false;
106 HasVector = false;
107 for (const auto &Feature : Features) {
108 if (Feature == "+transactional-execution")
109 HasTransactionalExecution = true;
110 else if (Feature == "+vector")
111 HasVector = true;
112 }
113 // If we use the vector ABI, vector types are 64-bit aligned.
114 if (HasVector) {
115 MaxVectorAlign = 64;
116 resetDataLayout("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64"
117 "-v128:64-a:8:16-n32:64");
118 }
119 return true;
120 }
121
122 bool hasFeature(StringRef Feature) const override;
123
124 CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
125 switch (CC) {
126 case CC_C:
127 case CC_Swift:
128 case CC_OpenCLKernel:
129 return CCCR_OK;
130 default:
131 return CCCR_Warning;
132 }
133 }
134
135 StringRef getABI() const override {
136 if (HasVector)
137 return "vector";
138 return "";
139 }
140
141 bool useFloat128ManglingForLongDouble() const override { return true; }
142};
143} // namespace targets
144} // namespace clang
145#endif // LLVM_CLANG_LIB_BASIC_TARGETS_SYSTEMZ_H