clang  6.0.0svn
ARM.h
Go to the documentation of this file.
1 //===--- ARM.h - Declare ARM 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 ARM TargetInfo objects.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_ARM_H
15 #define LLVM_CLANG_LIB_BASIC_TARGETS_ARM_H
16 
17 #include "OSTargets.h"
18 #include "clang/Basic/TargetInfo.h"
20 #include "llvm/ADT/Triple.h"
21 #include "llvm/Support/Compiler.h"
22 #include "llvm/Support/TargetParser.h"
23 
24 namespace clang {
25 namespace targets {
26 
27 class LLVM_LIBRARY_VISIBILITY ARMTargetInfo : public TargetInfo {
28  // Possible FPU choices.
29  enum FPUMode {
30  VFP2FPU = (1 << 0),
31  VFP3FPU = (1 << 1),
32  VFP4FPU = (1 << 2),
33  NeonFPU = (1 << 3),
34  FPARMV8 = (1 << 4)
35  };
36 
37  // Possible HWDiv features.
38  enum HWDivMode { HWDivThumb = (1 << 0), HWDivARM = (1 << 1) };
39 
40  static bool FPUModeIsVFP(FPUMode Mode) {
41  return Mode & (VFP2FPU | VFP3FPU | VFP4FPU | NeonFPU | FPARMV8);
42  }
43 
44  static const TargetInfo::GCCRegAlias GCCRegAliases[];
45  static const char *const GCCRegNames[];
46 
47  std::string ABI, CPU;
48 
49  StringRef CPUProfile;
50  StringRef CPUAttr;
51 
52  enum { FP_Default, FP_VFP, FP_Neon } FPMath;
53 
54  llvm::ARM::ISAKind ArchISA;
55  llvm::ARM::ArchKind ArchKind = llvm::ARM::ArchKind::ARMV4T;
56  llvm::ARM::ProfileKind ArchProfile;
57  unsigned ArchVersion;
58 
59  unsigned FPU : 5;
60 
61  unsigned IsAAPCS : 1;
62  unsigned HWDiv : 2;
63 
64  // Initialized via features.
65  unsigned SoftFloat : 1;
66  unsigned SoftFloatABI : 1;
67 
68  unsigned CRC : 1;
69  unsigned Crypto : 1;
70  unsigned DSP : 1;
71  unsigned Unaligned : 1;
72 
73  enum {
74  LDREX_B = (1 << 0), /// byte (8-bit)
75  LDREX_H = (1 << 1), /// half (16-bit)
76  LDREX_W = (1 << 2), /// word (32-bit)
77  LDREX_D = (1 << 3), /// double (64-bit)
78  };
79 
80  uint32_t LDREX;
81 
82  // ACLE 6.5.1 Hardware floating point
83  enum {
84  HW_FP_HP = (1 << 1), /// half (16-bit)
85  HW_FP_SP = (1 << 2), /// single (32-bit)
86  HW_FP_DP = (1 << 3), /// double (64-bit)
87  };
88  uint32_t HW_FP;
89 
90  static const Builtin::Info BuiltinInfo[];
91 
92  void setABIAAPCS();
93  void setABIAPCS(bool IsAAPCS16);
94 
95  void setArchInfo();
96  void setArchInfo(llvm::ARM::ArchKind Kind);
97 
98  void setAtomic();
99 
100  bool isThumb() const;
101  bool supportsThumb() const;
102  bool supportsThumb2() const;
103 
104  StringRef getCPUAttr() const;
105  StringRef getCPUProfile() const;
106 
107 public:
108  ARMTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
109 
110  StringRef getABI() const override;
111  bool setABI(const std::string &Name) override;
112 
113  // FIXME: This should be based on Arch attributes, not CPU names.
114  bool
115  initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags,
116  StringRef CPU,
117  const std::vector<std::string> &FeaturesVec) const override;
118 
119  bool handleTargetFeatures(std::vector<std::string> &Features,
120  DiagnosticsEngine &Diags) override;
121 
122  bool hasFeature(StringRef Feature) const override;
123 
124  bool isValidCPUName(StringRef Name) const override;
125  bool setCPU(const std::string &Name) override;
126 
127  bool setFPMath(StringRef Name) override;
128 
129  bool useFP16ConversionIntrinsics() const override {
130  return false;
131  }
132 
133  void getTargetDefinesARMV81A(const LangOptions &Opts,
134  MacroBuilder &Builder) const;
135 
136  void getTargetDefinesARMV82A(const LangOptions &Opts,
137  MacroBuilder &Builder) const;
138  void getTargetDefines(const LangOptions &Opts,
139  MacroBuilder &Builder) const override;
140 
141  ArrayRef<Builtin::Info> getTargetBuiltins() const override;
142 
143  bool isCLZForZeroUndef() const override;
144  BuiltinVaListKind getBuiltinVaListKind() const override;
145 
146  ArrayRef<const char *> getGCCRegNames() const override;
147  ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;
148  bool validateAsmConstraint(const char *&Name,
149  TargetInfo::ConstraintInfo &Info) const override;
150  std::string convertConstraint(const char *&Constraint) const override;
151  bool
152  validateConstraintModifier(StringRef Constraint, char Modifier, unsigned Size,
153  std::string &SuggestedModifier) const override;
154  const char *getClobbers() const override;
155 
156  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
157 
158  int getEHDataRegisterNumber(unsigned RegNo) const override;
159 
160  bool hasSjLjLowering() const override;
161 };
162 
163 class LLVM_LIBRARY_VISIBILITY ARMleTargetInfo : public ARMTargetInfo {
164 public:
165  ARMleTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
166  void getTargetDefines(const LangOptions &Opts,
167  MacroBuilder &Builder) const override;
168 };
169 
170 class LLVM_LIBRARY_VISIBILITY ARMbeTargetInfo : public ARMTargetInfo {
171 public:
172  ARMbeTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
173  void getTargetDefines(const LangOptions &Opts,
174  MacroBuilder &Builder) const override;
175 };
176 
177 class LLVM_LIBRARY_VISIBILITY WindowsARMTargetInfo
178  : public WindowsTargetInfo<ARMleTargetInfo> {
179  const llvm::Triple Triple;
180 
181 public:
182  WindowsARMTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
183 
184  void getVisualStudioDefines(const LangOptions &Opts,
185  MacroBuilder &Builder) const;
186 
187  BuiltinVaListKind getBuiltinVaListKind() const override;
188 
189  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
190 };
191 
192 // Windows ARM + Itanium C++ ABI Target
193 class LLVM_LIBRARY_VISIBILITY ItaniumWindowsARMleTargetInfo
194  : public WindowsARMTargetInfo {
195 public:
196  ItaniumWindowsARMleTargetInfo(const llvm::Triple &Triple,
197  const TargetOptions &Opts);
198 
199  void getTargetDefines(const LangOptions &Opts,
200  MacroBuilder &Builder) const override;
201 };
202 
203 // Windows ARM, MS (C++) ABI
204 class LLVM_LIBRARY_VISIBILITY MicrosoftARMleTargetInfo
205  : public WindowsARMTargetInfo {
206 public:
207  MicrosoftARMleTargetInfo(const llvm::Triple &Triple,
208  const TargetOptions &Opts);
209 
210  void getTargetDefines(const LangOptions &Opts,
211  MacroBuilder &Builder) const override;
212 };
213 
214 // ARM MinGW target
215 class LLVM_LIBRARY_VISIBILITY MinGWARMTargetInfo : public WindowsARMTargetInfo {
216 public:
217  MinGWARMTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
218 
219  void getTargetDefines(const LangOptions &Opts,
220  MacroBuilder &Builder) const override;
221 };
222 
223 // ARM Cygwin target
224 class LLVM_LIBRARY_VISIBILITY CygwinARMTargetInfo : public ARMleTargetInfo {
225 public:
226  CygwinARMTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
227 
228  void getTargetDefines(const LangOptions &Opts,
229  MacroBuilder &Builder) const override;
230 };
231 
232 class LLVM_LIBRARY_VISIBILITY DarwinARMTargetInfo
233  : public DarwinTargetInfo<ARMleTargetInfo> {
234 protected:
235  void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
236  MacroBuilder &Builder) const override;
237 
238 public:
239  DarwinARMTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);
240 };
241 
242 // 32-bit RenderScript is armv7 with width and align of 'long' set to 8-bytes
243 class LLVM_LIBRARY_VISIBILITY RenderScript32TargetInfo
244  : public ARMleTargetInfo {
245 public:
246  RenderScript32TargetInfo(const llvm::Triple &Triple,
247  const TargetOptions &Opts);
248 
249  void getTargetDefines(const LangOptions &Opts,
250  MacroBuilder &Builder) const override;
251 };
252 
253 } // namespace targets
254 } // namespace clang
255 
256 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_ARM_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
Options for controlling the target.
Definition: TargetOptions.h:26
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
Exposes information about the current target.
Definition: TargetInfo.h:54
bool useFP16ConversionIntrinsics() const override
Check whether llvm intrinsics such as llvm.convert.to.fp16 should be used to convert to and from __fp...
Definition: ARM.h:129
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition: Specifiers.h:233
Kind
OpenMPLinearClauseKind Modifier
Modifier of &#39;linear&#39; clause.
Definition: OpenMPClause.h:87
Defines the clang::TargetOptions class.
Dataflow Directional Tag Classes.
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
Definition: TargetInfo.h:152
Defines the clang::TargetInfo interface.