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;
86 // All vector types are default aligned on an 8-byte boundary, even if the
87 // vector facility is not available. That is different from Linux.
88 MaxVectorAlign = 64;
89 } else {
90 // Support _Float16.
91 HasFloat16 = true;
92 TLSSupported = true;
93 }
96
97 // True if the backend supports operations on the half LLVM IR type.
98 // By setting this to false, conversions will happen for _Float16 around
99 // a statement by default, with operations done in float. However, if
100 // -ffloat16-excess-precision=none is given, no conversions will be made
101 // and instead the backend will promote each half operation to float
102 // individually.
103 HasFastHalfType = false;
104
105 HasStrictFP = true;
106 }
107
108 unsigned getMinGlobalAlign(uint64_t Size, bool HasNonWeakDef) const override;
109
110 bool useFP16ConversionIntrinsics() const override { return false; }
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
171
172 int getISARevision(StringRef Name) const;
173
174 bool isValidCPUName(StringRef Name) const override {
175 return getISARevision(Name) != -1;
176 }
177
178 void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
179
180 bool isValidTuneCPUName(StringRef Name) const override {
181 return isValidCPUName(Name);
182 }
183
185 fillValidCPUList(Values);
186 }
187
188 bool setCPU(const std::string &Name) override {
189 ISARevision = getISARevision(Name);
190 return ISARevision != -1;
191 }
192
193 bool
194 initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags,
195 StringRef CPU,
196 const std::vector<std::string> &FeaturesVec) const override {
197 int ISARevision = getISARevision(CPU);
198 if (ISARevision >= 10)
199 Features["transactional-execution"] = true;
200 if (ISARevision >= 11)
201 Features["vector"] = true;
202 if (ISARevision >= 12)
203 Features["vector-enhancements-1"] = true;
204 if (ISARevision >= 13)
205 Features["vector-enhancements-2"] = true;
206 if (ISARevision >= 14)
207 Features["nnp-assist"] = true;
208 if (ISARevision >= 15) {
209 Features["miscellaneous-extensions-4"] = true;
210 Features["vector-enhancements-3"] = true;
211 }
212 return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
213 }
214
215 bool handleTargetFeatures(std::vector<std::string> &Features,
216 DiagnosticsEngine &Diags) override {
217 HasTransactionalExecution = false;
218 HasVector = false;
219 SoftFloat = false;
220 UnalignedSymbols = false;
221 for (const auto &Feature : Features) {
222 if (Feature == "+transactional-execution")
223 HasTransactionalExecution = true;
224 else if (Feature == "+vector")
225 HasVector = true;
226 else if (Feature == "+soft-float")
227 SoftFloat = true;
228 else if (Feature == "+unaligned-symbols")
229 UnalignedSymbols = true;
230 }
231 HasVector &= !SoftFloat;
232
233 // If we use the vector ABI, vector types are 64-bit aligned. The
234 // DataLayout string is always set to this alignment as it is not a
235 // requirement that it follows the alignment emitted by the front end. It
236 // is assumed generally that the Datalayout should reflect only the
237 // target triple and not any specific feature.
238 if (HasVector && !getTriple().isOSzOS())
239 MaxVectorAlign = 64;
240
241 return true;
242 }
243
244 bool hasFeature(StringRef Feature) const override;
245
247 switch (CC) {
248 case CC_C:
249 case CC_Swift:
250 case CC_DeviceKernel:
251 return CCCR_OK;
252 case CC_SwiftAsync:
253 return CCCR_Error;
254 default:
255 return CCCR_Warning;
256 }
257 }
258
259 StringRef getABI() const override {
260 if (HasVector)
261 return "vector";
262 return "";
263 }
264
265 const char *getLongDoubleMangling() const override { return "g"; }
266
267 bool hasBitIntType() const override { return true; }
268
269 int getEHDataRegisterNumber(unsigned RegNo) const override {
270 return RegNo < 4 ? 6 + RegNo : -1;
271 }
272
273 bool hasSjLjLowering() const override { return true; }
274
275 std::pair<unsigned, unsigned> hardwareInterferenceSizes() const override {
276 return std::make_pair(256, 256);
277 }
278 uint64_t getPointerWidthV(LangAS AddrSpace) const override {
279 return (getTriple().isOSzOS() && getTriple().isArch64Bit() &&
280 getTargetAddressSpace(AddrSpace) == ptr32)
281 ? 32
282 : PointerWidth;
283 }
284
285 uint64_t getPointerAlignV(LangAS AddrSpace) const override {
286 return getPointerWidthV(AddrSpace);
287 }
288};
289} // namespace targets
290} // namespace clang
291#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:114
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: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 LangASMap * AddrSpaceMap
Definition TargetInfo.h:260
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
Definition TargetInfo.h:334
unsigned HasUnalignedAccess
Definition TargetInfo.h:285
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:267
const char * getLongDoubleMangling() const override
Return the mangled code of long double.
Definition SystemZ.h:265
uint64_t getPointerAlignV(LangAS AddrSpace) const override
Definition SystemZ.h:285
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:174
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:215
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Determines whether a given calling convention is valid for the target.
Definition SystemZ.h:246
bool hasSjLjLowering() const override
Controls if __builtin_longjmp / __builtin_setjmp can be lowered to llvm.eh.sjlj.longjmp / llvm....
Definition SystemZ.h:273
bool setCPU(const std::string &Name) override
Target the specified CPU.
Definition SystemZ.h:188
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:275
void fillValidTuneCPUList(SmallVectorImpl< StringRef > &Values) const override
Fill a SmallVectorImpl with the valid values for tuning CPU.
Definition SystemZ.h:184
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:278
int getEHDataRegisterNumber(unsigned RegNo) const override
Return the register number that __builtin_eh_return_regno would return with the specified argument.
Definition SystemZ.h:269
bool useFP16ConversionIntrinsics() const override
Check whether conversions to and from __fp16 should go through an integer bitcast with i16.
Definition SystemZ.h:110
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:163
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:194
StringRef getABI() const override
Get the ABI currently in use.
Definition SystemZ.h:259
bool isValidTuneCPUName(StringRef Name) const override
Determine whether this TargetInfo supports the given CPU name for tuning.
Definition SystemZ.h:180
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: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: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:144
unsigned char DefaultAlignForAttributeAligned
Definition TargetInfo.h:134