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