1 //===--- SystemZ.h - Declare SystemZ target feature support -----*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 // This file declares SystemZ TargetInfo objects.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_SYSTEMZ_H
14 #define LLVM_CLANG_LIB_BASIC_TARGETS_SYSTEMZ_H
16 #include "clang/Basic/TargetInfo.h"
17 #include "clang/Basic/TargetOptions.h"
18 #include "llvm/ADT/Triple.h"
19 #include "llvm/Support/Compiler.h"
24 class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo {
26 static const Builtin::Info BuiltinInfo[];
27 static const char *const GCCRegNames[];
30 bool HasTransactionalExecution;
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;
40 IntWidth = IntAlign = 32;
41 LongWidth = LongLongWidth = LongAlign = LongLongAlign = 64;
42 PointerWidth = PointerAlign = 64;
43 LongDoubleWidth = 128;
45 LongDoubleFormat = &llvm::APFloat::IEEEquad();
46 DefaultAlignForAttributeAligned = 64;
48 resetDataLayout("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64");
49 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
52 void getTargetDefines(const LangOptions &Opts,
53 MacroBuilder &Builder) const override;
55 ArrayRef<Builtin::Info> getTargetBuiltins() const override;
57 ArrayRef<const char *> getGCCRegNames() const override;
59 ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
64 ArrayRef<TargetInfo::AddlRegName> getGCCAddlRegNames() const override;
66 bool validateAsmConstraint(const char *&Name,
67 TargetInfo::ConstraintInfo &info) const override;
69 const char *getClobbers() const override {
70 // FIXME: Is this really right?
74 BuiltinVaListKind getBuiltinVaListKind() const override {
75 return TargetInfo::SystemZBuiltinVaList;
78 int getISARevision(StringRef Name) const;
80 bool isValidCPUName(StringRef Name) const override {
81 return getISARevision(Name) != -1;
84 void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
86 bool setCPU(const std::string &Name) override {
88 ISARevision = getISARevision(CPU);
89 return ISARevision != -1;
93 initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags,
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 if (ISARevision >= 13)
104 Features["vector-enhancements-2"] = true;
105 return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
108 bool handleTargetFeatures(std::vector<std::string> &Features,
109 DiagnosticsEngine &Diags) override {
110 HasTransactionalExecution = false;
112 for (const auto &Feature : Features) {
113 if (Feature == "+transactional-execution")
114 HasTransactionalExecution = true;
115 else if (Feature == "+vector")
118 // If we use the vector ABI, vector types are 64-bit aligned.
121 resetDataLayout("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64"
122 "-v128:64-a:8:16-n32:64");
127 bool hasFeature(StringRef Feature) const override;
129 CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
133 case CC_OpenCLKernel:
140 StringRef getABI() const override {
146 const char *getLongDoubleMangling() const override { return "g"; }
148 } // namespace targets
150 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_SYSTEMZ_H