clang 23.0.0git
SystemZ.h
Go to the documentation of this file.
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
13#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_SYSTEMZ_H
14#define LLVM_CLANG_LIB_BASIC_TARGETS_SYSTEMZ_H
15
18#include "llvm/Support/Compiler.h"
19#include "llvm/TargetParser/Triple.h"
20
21namespace clang {
22namespace targets {
23
24static const unsigned ZOSAddressMap[] = {
25 0, // Default
26 0, // opencl_global
27 0, // opencl_local
28 0, // opencl_constant
29 0, // opencl_private
30 0, // opencl_generic
31 0, // opencl_global_device
32 0, // opencl_global_host
33 0, // cuda_device
34 0, // cuda_constant
35 0, // cuda_shared
36 0, // sycl_global
37 0, // sycl_global_device
38 0, // sycl_global_host
39 0, // sycl_local
40 0, // sycl_private
41 0, // ptr32_sptr
42 1, // ptr32_uptr
43 0, // ptr64
44 0, // hlsl_groupshared
45 0, // hlsl_constant
46 0, // hlsl_private
47 0, // hlsl_device
48 0, // hlsl_input
49 0, // hlsl_output
50 0, // hlsl_push_constant
51 0 // wasm_funcref
52};
53
54class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo {
55
56 static const char *const GCCRegNames[];
57 int ISARevision;
58 bool HasTransactionalExecution;
59 bool HasVector;
60 bool SoftFloat;
61 bool UnalignedSymbols;
62 enum AddrSpace { ptr32 = 1 };
63
64public:
65 SystemZTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
66 : TargetInfo(Triple), ISARevision(getISARevision("z10")),
67 HasTransactionalExecution(false), HasVector(false), SoftFloat(false),
68 UnalignedSymbols(false) {
71 IntWidth = IntAlign = 32;
73 Int128Align = 64;
75 LongDoubleWidth = 128;
76 LongDoubleAlign = 64;
77 LongDoubleFormat = &llvm::APFloat::IEEEquad();
79 MinGlobalAlign = 16;
80 HasUnalignedAccess = true;
81 if (Triple.isOSzOS()) {
82 if (Triple.isArch64Bit()) {
84 }
85 TLSSupported = false;
87
88 // All vector types are default aligned on an 8-byte boundary, even if the
89 // vector facility is not available. That is different from Linux.
90 MaxVectorAlign = 64;
91 } else {
92 // Support _Float16.
93 HasFloat16 = true;
94 TLSSupported = true;
95 }
98
99 // True if the backend supports operations on the half LLVM IR type.
100 // By setting this to false, conversions will happen for _Float16 around
101 // a statement by default, with operations done in float. However, if
102 // -ffloat16-excess-precision=none is given, no conversions will be made
103 // and instead the backend will promote each half operation to float
104 // individually.
105 HasFastHalfType = false;
106
107 HasStrictFP = true;
108 }
109
110 unsigned getMinGlobalAlign(uint64_t Size, bool HasNonWeakDef) const override;
111
112 void getTargetDefines(const LangOptions &Opts,
113 MacroBuilder &Builder) const override;
114
115 llvm::SmallVector<Builtin::InfosShard> getTargetBuiltins() const override;
116
117 ArrayRef<const char *> getGCCRegNames() const override;
118
120 // No aliases.
121 return {};
122 }
123
124 ArrayRef<TargetInfo::AddlRegName> getGCCAddlRegNames() const override;
125
126 bool isSPRegName(StringRef RegName) const override {
127 return RegName == "r15";
128 }
129
130 bool validateAsmConstraint(const char *&Name,
131 TargetInfo::ConstraintInfo &info) const override;
132
133 std::string convertConstraint(const char *&Constraint) const override {
134 switch (Constraint[0]) {
135 case '@': // Flag output operand.
136 if (llvm::StringRef(Constraint) == "@cc") {
137 Constraint += 2;
138 return std::string("{@cc}");
139 }
140 break;
141 case 'p': // Keep 'p' constraint.
142 return std::string("p");
143 case 'Z':
144 switch (Constraint[1]) {
145 case 'Q': // Address with base and unsigned 12-bit displacement
146 case 'R': // Likewise, plus an index
147 case 'S': // Address with base and signed 20-bit displacement
148 case 'T': // Likewise, plus an index
149 // "^" hints llvm that this is a 2 letter constraint.
150 // "Constraint++" is used to promote the string iterator
151 // to the next constraint.
152 return std::string("^") + std::string(Constraint++, 2);
153 default:
154 break;
155 }
156 break;
157 default:
158 break;
159 }
160 return TargetInfo::convertConstraint(Constraint);
161 }
162
163 std::string_view getClobbers() const override {
164 // FIXME: Is this really right?
165 return "";
166 }
167
169 if (getTriple().isOSzOS())
172 }
173
174 int getISARevision(StringRef Name) const;
175
176 bool isValidCPUName(StringRef Name) const override {
177 return getISARevision(Name) != -1;
178 }
179
180 void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
181
182 bool isValidTuneCPUName(StringRef Name) const override {
183 return isValidCPUName(Name);
184 }
185
187 fillValidCPUList(Values);
188 }
189
190 bool setCPU(StringRef Name) override {
191 ISARevision = getISARevision(Name);
192 return ISARevision != -1;
193 }
194
195 bool
196 initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags,
197 StringRef CPU,
198 const std::vector<std::string> &FeaturesVec) const override {
199 int ISARevision = getISARevision(CPU);
200 if (ISARevision >= 10)
201 Features["transactional-execution"] = true;
202 if (ISARevision >= 11)
203 Features["vector"] = true;
204 if (ISARevision >= 12)
205 Features["vector-enhancements-1"] = true;
206 if (ISARevision >= 13)
207 Features["vector-enhancements-2"] = true;
208 if (ISARevision >= 14)
209 Features["nnp-assist"] = true;
210 if (ISARevision >= 15) {
211 Features["miscellaneous-extensions-4"] = true;
212 Features["vector-enhancements-3"] = true;
213 }
214 return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
215 }
216
217 bool handleTargetFeatures(std::vector<std::string> &Features,
218 DiagnosticsEngine &Diags) override {
219 HasTransactionalExecution = false;
220 HasVector = false;
221 SoftFloat = false;
222 UnalignedSymbols = false;
223 for (const auto &Feature : Features) {
224 if (Feature == "+transactional-execution")
225 HasTransactionalExecution = true;
226 else if (Feature == "+vector")
227 HasVector = true;
228 else if (Feature == "+soft-float")
229 SoftFloat = true;
230 else if (Feature == "+unaligned-symbols")
231 UnalignedSymbols = true;
232 }
233 HasVector &= !SoftFloat;
234
235 // If we use the vector ABI, vector types are 64-bit aligned. The
236 // DataLayout string is always set to this alignment as it is not a
237 // requirement that it follows the alignment emitted by the front end. It
238 // is assumed generally that the Datalayout should reflect only the
239 // target triple and not any specific feature.
240 if (HasVector && !getTriple().isOSzOS())
241 MaxVectorAlign = 64;
242
243 return true;
244 }
245
246 bool hasFeature(StringRef Feature) const override;
247
249 switch (CC) {
250 case CC_C:
251 case CC_Swift:
252 case CC_DeviceKernel:
253 return CCCR_OK;
254 case CC_SwiftAsync:
255 return CCCR_Error;
256 default:
257 return CCCR_Warning;
258 }
259 }
260
261 StringRef getABI() const override {
262 if (HasVector)
263 return "vector";
264 return "";
265 }
266
267 const char *getLongDoubleMangling() const override { return "g"; }
268
269 bool hasBitIntType() const override { return true; }
270
271 int getEHDataRegisterNumber(unsigned RegNo) const override {
272 return RegNo < 4 ? 6 + RegNo : -1;
273 }
274
275 bool hasSjLjLowering() const override { return true; }
276
277 std::pair<unsigned, unsigned> hardwareInterferenceSizes() const override {
278 return std::make_pair(256, 256);
279 }
280 uint64_t getPointerWidthV(LangAS AddrSpace) const override {
281 return (getTriple().isOSzOS() && getTriple().isArch64Bit() &&
282 getTargetAddressSpace(AddrSpace) == ptr32)
283 ? 32
284 : PointerWidth;
285 }
286
287 uint64_t getPointerAlignV(LangAS AddrSpace) const override {
288 return getPointerWidthV(AddrSpace);
289 }
290};
291} // namespace targets
292} // namespace clang
293#endif // LLVM_CLANG_LIB_BASIC_TARGETS_SYSTEMZ_H
static bool hasFeature(StringRef Feature, const LangOptions &LangOpts, const TargetInfo &Target)
Determine whether a translation unit built using the current language options has the given feature.
Definition Module.cpp:95
static StringRef getTriple(const Command &Job)
Defines the clang::TargetOptions class.
Concrete class used by the front-end to report problems and issues.
Definition Diagnostic.h:234
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
TargetInfo(const llvm::Triple &T)
const LangASMap * AddrSpaceMap
Definition TargetInfo.h:260
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
Definition TargetInfo.h:337
@ CharPtrBuiltinVaList
typedef char* __builtin_va_list;
Definition TargetInfo.h:339
unsigned HasBuiltinZOSVaList
Definition TargetInfo.h:276
unsigned HasUnalignedAccess
Definition TargetInfo.h:288
unsigned char MaxAtomicPromoteWidth
Definition TargetInfo.h:253
void resetDataLayout(StringRef DL)
Set the data layout to the given string.
unsigned getTargetAddressSpace(LangAS AS) const
virtual bool initFeatureMap(llvm::StringMap< bool > &Features, DiagnosticsEngine &Diags, StringRef CPU, const std::vector< std::string > &FeatureVec) const
Initialize the map with the default set of target features for the CPU this should include all legal ...
virtual std::string convertConstraint(const char *&Constraint) const
unsigned char MaxAtomicInlineWidth
Definition TargetInfo.h:253
Options for controlling the target.
bool hasBitIntType() const override
Determine whether the _BitInt type is supported on this target.
Definition SystemZ.h:269
const char * getLongDoubleMangling() const override
Return the mangled code of long double.
Definition SystemZ.h:267
uint64_t getPointerAlignV(LangAS AddrSpace) const override
Definition SystemZ.h:287
bool isSPRegName(StringRef RegName) const override
Definition SystemZ.h:126
std::string convertConstraint(const char *&Constraint) const override
Definition SystemZ.h:133
bool isValidCPUName(StringRef Name) const override
Determine whether this TargetInfo supports the given CPU name.
Definition SystemZ.h:176
ArrayRef< TargetInfo::GCCRegAlias > getGCCRegAliases() const override
Definition SystemZ.h:119
bool handleTargetFeatures(std::vector< std::string > &Features, DiagnosticsEngine &Diags) override
Perform initialization based on the user configured set of features (e.g., +sse4).
Definition SystemZ.h:217
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Determines whether a given calling convention is valid for the target.
Definition SystemZ.h:248
bool hasSjLjLowering() const override
Controls if __builtin_longjmp / __builtin_setjmp can be lowered to llvm.eh.sjlj.longjmp / llvm....
Definition SystemZ.h:275
std::pair< unsigned, unsigned > hardwareInterferenceSizes() const override
The first value in the pair is the minimum offset between two objects to avoid false sharing (destruc...
Definition SystemZ.h:277
void fillValidTuneCPUList(SmallVectorImpl< StringRef > &Values) const override
Fill a SmallVectorImpl with the valid values for tuning CPU.
Definition SystemZ.h:186
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
Definition SystemZ.h:168
uint64_t getPointerWidthV(LangAS AddrSpace) const override
Definition SystemZ.h:280
int getEHDataRegisterNumber(unsigned RegNo) const override
Return the register number that __builtin_eh_return_regno would return with the specified argument.
Definition SystemZ.h:271
int getISARevision(StringRef Name) const
Definition SystemZ.cpp:151
std::string_view getClobbers() const override
Returns a string of target-specific clobbers, in LLVM format.
Definition SystemZ.h:163
bool setCPU(StringRef Name) override
Target the specified CPU.
Definition SystemZ.h:190
bool initFeatureMap(llvm::StringMap< bool > &Features, DiagnosticsEngine &Diags, StringRef CPU, const std::vector< std::string > &FeaturesVec) const override
Initialize the map with the default set of target features for the CPU this should include all legal ...
Definition SystemZ.h:196
StringRef getABI() const override
Get the ABI currently in use.
Definition SystemZ.h:261
bool isValidTuneCPUName(StringRef Name) const override
Determine whether this TargetInfo supports the given CPU name for tuning.
Definition SystemZ.h:182
void fillValidCPUList(SmallVectorImpl< StringRef > &Values) const override
Fill a SmallVectorImpl with the valid values to setCPU.
Definition SystemZ.cpp:161
SystemZTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
Definition SystemZ.h:65
Defines the clang::TargetInfo interface.
static const unsigned ZOSAddressMap[]
Definition SystemZ.h:24
The JSON file list parser is used to communicate input to InstallAPI.
LangAS
Defines the address space values used by the address space qualifier of QualType.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition Specifiers.h:279
@ CC_Swift
Definition Specifiers.h:294
@ CC_DeviceKernel
Definition Specifiers.h:293
@ CC_SwiftAsync
Definition Specifiers.h:295
#define false
Definition stdbool.h:26
const llvm::fltSemantics * LongDoubleFormat
Definition TargetInfo.h:144
unsigned char DefaultAlignForAttributeAligned
Definition TargetInfo.h:134