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