clang  10.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 
16 #include "clang/Basic/TargetInfo.h"
18 #include "llvm/ADT/Triple.h"
19 #include "llvm/Support/Compiler.h"
20 
21 namespace clang {
22 namespace targets {
23 
24 class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo {
25 
26  static const Builtin::Info BuiltinInfo[];
27  static const char *const GCCRegNames[];
28  std::string CPU;
29  int ISARevision;
30  bool HasTransactionalExecution;
31  bool HasVector;
32 
33 public:
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;
39  TLSSupported = true;
40  IntWidth = IntAlign = 32;
41  LongWidth = LongLongWidth = LongAlign = LongLongAlign = 64;
42  PointerWidth = PointerAlign = 64;
43  LongDoubleWidth = 128;
44  LongDoubleAlign = 64;
45  LongDoubleFormat = &llvm::APFloat::IEEEquad();
46  DefaultAlignForAttributeAligned = 64;
47  MinGlobalAlign = 16;
48  resetDataLayout("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64");
49  MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
50  }
51 
52  void getTargetDefines(const LangOptions &Opts,
53  MacroBuilder &Builder) const override;
54 
55  ArrayRef<Builtin::Info> getTargetBuiltins() const override;
56 
57  ArrayRef<const char *> getGCCRegNames() const override;
58 
60  // No aliases.
61  return None;
62  }
63 
64  ArrayRef<TargetInfo::AddlRegName> getGCCAddlRegNames() const override;
65 
66  bool validateAsmConstraint(const char *&Name,
67  TargetInfo::ConstraintInfo &info) const override;
68 
69  const char *getClobbers() const override {
70  // FIXME: Is this really right?
71  return "";
72  }
73 
76  }
77 
78  int getISARevision(StringRef Name) const;
79 
80  bool isValidCPUName(StringRef Name) const override {
81  return getISARevision(Name) != -1;
82  }
83 
84  void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
85 
86  bool setCPU(const std::string &Name) override {
87  CPU = Name;
88  ISARevision = getISARevision(CPU);
89  return ISARevision != -1;
90  }
91 
92  bool
93  initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags,
94  StringRef CPU,
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);
106  }
107 
108  bool handleTargetFeatures(std::vector<std::string> &Features,
109  DiagnosticsEngine &Diags) override {
110  HasTransactionalExecution = false;
111  HasVector = false;
112  for (const auto &Feature : Features) {
113  if (Feature == "+transactional-execution")
114  HasTransactionalExecution = true;
115  else if (Feature == "+vector")
116  HasVector = true;
117  }
118  // If we use the vector ABI, vector types are 64-bit aligned.
119  if (HasVector) {
120  MaxVectorAlign = 64;
121  resetDataLayout("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64"
122  "-v128:64-a:8:16-n32:64");
123  }
124  return true;
125  }
126 
127  bool hasFeature(StringRef Feature) const override;
128 
130  switch (CC) {
131  case CC_C:
132  case CC_Swift:
133  case CC_OpenCLKernel:
134  return CCCR_OK;
135  default:
136  return CCCR_Warning;
137  }
138  }
139 
140  StringRef getABI() const override {
141  if (HasVector)
142  return "vector";
143  return "";
144  }
145 
146  const char *getLongDoubleMangling() const override { return "g"; }
147 };
148 } // namespace targets
149 } // namespace clang
150 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_SYSTEMZ_H
static const Builtin::Info BuiltinInfo[]
Definition: Builtins.cpp:20
bool setCPU(const std::string &Name) override
Target the specified CPU.
Definition: SystemZ.h:86
Options for controlling the target.
Definition: TargetOptions.h:26
StringRef getABI() const override
Get the ABI currently in use.
Definition: SystemZ.h:140
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:53
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:149
static const char *const GCCRegNames[]
Definition: X86.cpp:43
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override
Determines whether a given calling convention is valid for the target.
Definition: SystemZ.h:129
Exposes information about the current target.
Definition: TargetInfo.h:164
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 ...
Definition: TargetInfo.cpp:402
const char * getClobbers() const override
Returns a string of target-specific clobbers, in LLVM format.
Definition: SystemZ.h:69
ArrayRef< TargetInfo::GCCRegAlias > getGCCRegAliases() const override
Definition: SystemZ.h:59
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition: Specifiers.h:265
#define false
Definition: stdbool.h:17
const char * getLongDoubleMangling() const override
Return the mangled code of long double.
Definition: SystemZ.h:146
Defines the clang::TargetOptions class.
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
Definition: SystemZ.h:74
Dataflow Directional Tag Classes.
bool isValidCPUName(StringRef Name) const override
brief Determine whether this TargetInfo supports the given CPU name.
Definition: SystemZ.h:80
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
Definition: TargetInfo.h:226
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:106
Defines the clang::TargetInfo interface.
SystemZTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
Definition: SystemZ.h:34
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:108
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:93