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