clang 22.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 // wasm_funcref
50};
51
52class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo {
53
54 static const char *const GCCRegNames[];
55 int ISARevision;
56 bool HasTransactionalExecution;
57 bool HasVector;
58 bool SoftFloat;
59 bool UnalignedSymbols;
60 enum AddrSpace { ptr32 = 1 };
61
62public:
63 SystemZTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
64 : TargetInfo(Triple), ISARevision(getISARevision("z10")),
65 HasTransactionalExecution(false), HasVector(false), SoftFloat(false),
66 UnalignedSymbols(false) {
69 IntWidth = IntAlign = 32;
71 Int128Align = 64;
73 LongDoubleWidth = 128;
74 LongDoubleAlign = 64;
75 LongDoubleFormat = &llvm::APFloat::IEEEquad();
77 MinGlobalAlign = 16;
78 HasUnalignedAccess = true;
79 if (Triple.isOSzOS()) {
80 if (Triple.isArch64Bit()) {
82 }
83 TLSSupported = false;
84 // All vector types are default aligned on an 8-byte boundary, even if the
85 // vector facility is not available. That is different from Linux.
86 MaxVectorAlign = 64;
87 // Compared to Linux/ELF, the data layout differs only in some details:
88 // - name mangling is GOFF.
89 // - 32 bit pointers, either as default or special address space
90 resetDataLayout("E-m:l-p1:32:32-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-"
91 "a:8:16-n32:64");
92 } else {
93 // Support _Float16.
94 HasFloat16 = true;
95 TLSSupported = true;
96 resetDataLayout("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64"
97 "-v128:64-a:8:16-n32:64");
98 }
100
101 // True if the backend supports operations on the half LLVM IR type.
102 // By setting this to false, conversions will happen for _Float16 around
103 // a statement by default, with operations done in float. However, if
104 // -ffloat16-excess-precision=none is given, no conversions will be made
105 // and instead the backend will promote each half operation to float
106 // individually.
107 HasFastHalfType = false;
108
109 HasStrictFP = true;
110 }
111
112 unsigned getMinGlobalAlign(uint64_t Size, bool HasNonWeakDef) const override;
113
114 bool useFP16ConversionIntrinsics() const override { return false; }
115
116 void getTargetDefines(const LangOptions &Opts,
117 MacroBuilder &Builder) const override;
118
119 llvm::SmallVector<Builtin::InfosShard> getTargetBuiltins() const override;
120
121 ArrayRef<const char *> getGCCRegNames() const override;
122
124 // No aliases.
125 return {};
126 }
127
128 ArrayRef<TargetInfo::AddlRegName> getGCCAddlRegNames() const override;
129
130 bool isSPRegName(StringRef RegName) const override {
131 return RegName == "r15";
132 }
133
134 bool validateAsmConstraint(const char *&Name,
135 TargetInfo::ConstraintInfo &info) const override;
136
137 std::string convertConstraint(const char *&Constraint) const override {
138 switch (Constraint[0]) {
139 case 'p': // Keep 'p' constraint.
140 return std::string("p");
141 case 'Z':
142 switch (Constraint[1]) {
143 case 'Q': // Address with base and unsigned 12-bit displacement
144 case 'R': // Likewise, plus an index
145 case 'S': // Address with base and signed 20-bit displacement
146 case 'T': // Likewise, plus an index
147 // "^" hints llvm that this is a 2 letter constraint.
148 // "Constraint++" is used to promote the string iterator
149 // to the next constraint.
150 return std::string("^") + std::string(Constraint++, 2);
151 default:
152 break;
153 }
154 break;
155 default:
156 break;
157 }
158 return TargetInfo::convertConstraint(Constraint);
159 }
160
161 std::string_view getClobbers() const override {
162 // FIXME: Is this really right?
163 return "";
164 }
165
169
170 int getISARevision(StringRef Name) const;
171
172 bool isValidCPUName(StringRef Name) const override {
173 return getISARevision(Name) != -1;
174 }
175
176 void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
177
178 bool isValidTuneCPUName(StringRef Name) const override {
179 return isValidCPUName(Name);
180 }
181
183 fillValidCPUList(Values);
184 }
185
186 bool setCPU(const std::string &Name) override {
187 ISARevision = getISARevision(Name);
188 return ISARevision != -1;
189 }
190
191 bool
192 initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags,
193 StringRef CPU,
194 const std::vector<std::string> &FeaturesVec) const override {
195 int ISARevision = getISARevision(CPU);
196 if (ISARevision >= 10)
197 Features["transactional-execution"] = true;
198 if (ISARevision >= 11)
199 Features["vector"] = true;
200 if (ISARevision >= 12)
201 Features["vector-enhancements-1"] = true;
202 if (ISARevision >= 13)
203 Features["vector-enhancements-2"] = true;
204 if (ISARevision >= 14)
205 Features["nnp-assist"] = true;
206 if (ISARevision >= 15) {
207 Features["miscellaneous-extensions-4"] = true;
208 Features["vector-enhancements-3"] = true;
209 }
210 return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
211 }
212
213 bool handleTargetFeatures(std::vector<std::string> &Features,
214 DiagnosticsEngine &Diags) override {
215 HasTransactionalExecution = false;
216 HasVector = false;
217 SoftFloat = false;
218 UnalignedSymbols = false;
219 for (const auto &Feature : Features) {
220 if (Feature == "+transactional-execution")
221 HasTransactionalExecution = true;
222 else if (Feature == "+vector")
223 HasVector = true;
224 else if (Feature == "+soft-float")
225 SoftFloat = true;
226 else if (Feature == "+unaligned-symbols")
227 UnalignedSymbols = true;
228 }
229 HasVector &= !SoftFloat;
230
231 // If we use the vector ABI, vector types are 64-bit aligned. The
232 // DataLayout string is always set to this alignment as it is not a
233 // requirement that it follows the alignment emitted by the front end. It
234 // is assumed generally that the Datalayout should reflect only the
235 // target triple and not any specific feature.
236 if (HasVector && !getTriple().isOSzOS())
237 MaxVectorAlign = 64;
238
239 return true;
240 }
241
242 bool hasFeature(StringRef Feature) const override;
243
245 switch (CC) {
246 case CC_C:
247 case CC_Swift:
248 case CC_DeviceKernel:
249 return CCCR_OK;
250 case CC_SwiftAsync:
251 return CCCR_Error;
252 default:
253 return CCCR_Warning;
254 }
255 }
256
257 StringRef getABI() const override {
258 if (HasVector)
259 return "vector";
260 return "";
261 }
262
263 const char *getLongDoubleMangling() const override { return "g"; }
264
265 bool hasBitIntType() const override { return true; }
266
267 int getEHDataRegisterNumber(unsigned RegNo) const override {
268 return RegNo < 4 ? 6 + RegNo : -1;
269 }
270
271 bool hasSjLjLowering() const override { return true; }
272
273 std::pair<unsigned, unsigned> hardwareInterferenceSizes() const override {
274 return std::make_pair(256, 256);
275 }
276 uint64_t getPointerWidthV(LangAS AddrSpace) const override {
277 return (getTriple().isOSzOS() && getTriple().isArch64Bit() &&
278 getTargetAddressSpace(AddrSpace) == ptr32)
279 ? 32
280 : PointerWidth;
281 }
282
283 uint64_t getPointerAlignV(LangAS AddrSpace) const override {
284 return getPointerWidthV(AddrSpace);
285 }
286};
287} // namespace targets
288} // namespace clang
289#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
Defines the clang::TargetOptions class.
Concrete class used by the front-end to report problems and issues.
Definition Diagnostic.h:231
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 llvm::Triple & getTriple() const
Returns the target triple of the primary target.
const LangASMap * AddrSpaceMap
Definition TargetInfo.h:258
void resetDataLayout(StringRef DL, const char *UserLabelPrefix="")
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
Definition TargetInfo.h:330
unsigned HasUnalignedAccess
Definition TargetInfo.h:283
unsigned char MaxAtomicPromoteWidth
Definition TargetInfo.h:251
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:251
Options for controlling the target.
bool hasBitIntType() const override
Determine whether the _BitInt type is supported on this target.
Definition SystemZ.h:265
const char * getLongDoubleMangling() const override
Return the mangled code of long double.
Definition SystemZ.h:263
uint64_t getPointerAlignV(LangAS AddrSpace) const override
Definition SystemZ.h:283
bool isSPRegName(StringRef RegName) const override
Definition SystemZ.h:130
std::string convertConstraint(const char *&Constraint) const override
Definition SystemZ.h:137
bool isValidCPUName(StringRef Name) const override
Determine whether this TargetInfo supports the given CPU name.
Definition SystemZ.h:172
ArrayRef< TargetInfo::GCCRegAlias > getGCCRegAliases() const override
Definition SystemZ.h:123
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:213
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Determines whether a given calling convention is valid for the target.
Definition SystemZ.h:244
bool hasSjLjLowering() const override
Controls if __builtin_longjmp / __builtin_setjmp can be lowered to llvm.eh.sjlj.longjmp / llvm....
Definition SystemZ.h:271
bool setCPU(const std::string &Name) override
Target the specified CPU.
Definition SystemZ.h:186
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:273
void fillValidTuneCPUList(SmallVectorImpl< StringRef > &Values) const override
Fill a SmallVectorImpl with the valid values for tuning CPU.
Definition SystemZ.h:182
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
Definition SystemZ.h:166
uint64_t getPointerWidthV(LangAS AddrSpace) const override
Definition SystemZ.h:276
int getEHDataRegisterNumber(unsigned RegNo) const override
Return the register number that __builtin_eh_return_regno would return with the specified argument.
Definition SystemZ.h:267
bool useFP16ConversionIntrinsics() const override
Check whether llvm intrinsics such as llvm.convert.to.fp16 should be used to convert to and from __fp...
Definition SystemZ.h:114
int getISARevision(StringRef Name) const
Definition SystemZ.cpp:120
std::string_view getClobbers() const override
Returns a string of target-specific clobbers, in LLVM format.
Definition SystemZ.h:161
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:192
StringRef getABI() const override
Get the ABI currently in use.
Definition SystemZ.h:257
bool isValidTuneCPUName(StringRef Name) const override
Determine whether this TargetInfo supports the given CPU name for tuning.
Definition SystemZ.h:178
void fillValidCPUList(SmallVectorImpl< StringRef > &Values) const override
Fill a SmallVectorImpl with the valid values to setCPU.
Definition SystemZ.cpp:130
SystemZTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
Definition SystemZ.h:63
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:278
@ CC_Swift
Definition Specifiers.h:293
@ CC_DeviceKernel
Definition Specifiers.h:292
@ CC_SwiftAsync
Definition Specifiers.h:294
#define false
Definition stdbool.h:26
const llvm::fltSemantics * LongDoubleFormat
Definition TargetInfo.h:143
unsigned char DefaultAlignForAttributeAligned
Definition TargetInfo.h:134