/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/tools/clang/include/clang/Basic/TargetInfo.h
Line | Count | Source (jump to first uncovered line) |
1 | | //===--- TargetInfo.h - Expose information about the target -----*- 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 | | /// \file |
11 | | /// \brief Defines the clang::TargetInfo interface. |
12 | | /// |
13 | | //===----------------------------------------------------------------------===// |
14 | | |
15 | | #ifndef LLVM_CLANG_BASIC_TARGETINFO_H |
16 | | #define LLVM_CLANG_BASIC_TARGETINFO_H |
17 | | |
18 | | #include "clang/Basic/AddressSpaces.h" |
19 | | #include "clang/Basic/LLVM.h" |
20 | | #include "clang/Basic/Specifiers.h" |
21 | | #include "clang/Basic/TargetCXXABI.h" |
22 | | #include "clang/Basic/TargetOptions.h" |
23 | | #include "clang/Basic/VersionTuple.h" |
24 | | #include "llvm/ADT/APInt.h" |
25 | | #include "llvm/ADT/IntrusiveRefCntPtr.h" |
26 | | #include "llvm/ADT/Optional.h" |
27 | | #include "llvm/ADT/SmallSet.h" |
28 | | #include "llvm/ADT/StringMap.h" |
29 | | #include "llvm/ADT/StringRef.h" |
30 | | #include "llvm/ADT/Triple.h" |
31 | | #include "llvm/IR/DataLayout.h" |
32 | | #include "llvm/Support/DataTypes.h" |
33 | | #include <cassert> |
34 | | #include <string> |
35 | | #include <vector> |
36 | | |
37 | | namespace llvm { |
38 | | struct fltSemantics; |
39 | | } |
40 | | |
41 | | namespace clang { |
42 | | class DiagnosticsEngine; |
43 | | class LangOptions; |
44 | | class CodeGenOptions; |
45 | | class MacroBuilder; |
46 | | class QualType; |
47 | | class SourceLocation; |
48 | | class SourceManager; |
49 | | class Type; |
50 | | |
51 | | namespace Builtin { struct Info; } |
52 | | |
53 | | /// \brief Exposes information about the current target. |
54 | | /// |
55 | | class TargetInfo : public RefCountedBase<TargetInfo> { |
56 | | std::shared_ptr<TargetOptions> TargetOpts; |
57 | | llvm::Triple Triple; |
58 | | protected: |
59 | | // Target values set by the ctor of the actual target implementation. Default |
60 | | // values are specified by the TargetInfo constructor. |
61 | | bool BigEndian; |
62 | | bool TLSSupported; |
63 | | bool NoAsmVariants; // True if {|} are normal characters. |
64 | | bool HasFloat128; |
65 | | unsigned char PointerWidth, PointerAlign; |
66 | | unsigned char BoolWidth, BoolAlign; |
67 | | unsigned char IntWidth, IntAlign; |
68 | | unsigned char HalfWidth, HalfAlign; |
69 | | unsigned char FloatWidth, FloatAlign; |
70 | | unsigned char DoubleWidth, DoubleAlign; |
71 | | unsigned char LongDoubleWidth, LongDoubleAlign, Float128Align; |
72 | | unsigned char LargeArrayMinWidth, LargeArrayAlign; |
73 | | unsigned char LongWidth, LongAlign; |
74 | | unsigned char LongLongWidth, LongLongAlign; |
75 | | unsigned char SuitableAlign; |
76 | | unsigned char DefaultAlignForAttributeAligned; |
77 | | unsigned char MinGlobalAlign; |
78 | | unsigned char MaxAtomicPromoteWidth, MaxAtomicInlineWidth; |
79 | | unsigned short MaxVectorAlign; |
80 | | unsigned short MaxTLSAlign; |
81 | | unsigned short SimdDefaultAlign; |
82 | | unsigned short NewAlign; |
83 | | std::unique_ptr<llvm::DataLayout> DataLayout; |
84 | | const char *MCountName; |
85 | | const llvm::fltSemantics *HalfFormat, *FloatFormat, *DoubleFormat, |
86 | | *LongDoubleFormat, *Float128Format; |
87 | | unsigned char RegParmMax, SSERegParmMax; |
88 | | TargetCXXABI TheCXXABI; |
89 | | const LangAS::Map *AddrSpaceMap; |
90 | | |
91 | | mutable StringRef PlatformName; |
92 | | mutable VersionTuple PlatformMinVersion; |
93 | | |
94 | | unsigned HasAlignMac68kSupport : 1; |
95 | | unsigned RealTypeUsesObjCFPRet : 3; |
96 | | unsigned ComplexLongDoubleUsesFP2Ret : 1; |
97 | | |
98 | | unsigned HasBuiltinMSVaList : 1; |
99 | | |
100 | | unsigned IsRenderScriptTarget : 1; |
101 | | |
102 | | // TargetInfo Constructor. Default initializes all fields. |
103 | | TargetInfo(const llvm::Triple &T); |
104 | | |
105 | 61.1k | void resetDataLayout(StringRef DL) { |
106 | 61.1k | DataLayout.reset(new llvm::DataLayout(DL)); |
107 | 61.1k | } |
108 | | |
109 | | public: |
110 | | /// \brief Construct a target for the given options. |
111 | | /// |
112 | | /// \param Opts - The options to use to initialize the target. The target may |
113 | | /// modify the options to canonicalize the target feature information to match |
114 | | /// what the backend expects. |
115 | | static TargetInfo * |
116 | | CreateTargetInfo(DiagnosticsEngine &Diags, |
117 | | const std::shared_ptr<TargetOptions> &Opts); |
118 | | |
119 | | virtual ~TargetInfo(); |
120 | | |
121 | | /// \brief Retrieve the target options. |
122 | 883k | TargetOptions &getTargetOpts() const { |
123 | 883k | assert(TargetOpts && "Missing target options"); |
124 | 883k | return *TargetOpts; |
125 | 883k | } |
126 | | |
127 | | ///===---- Target Data Type Query Methods -------------------------------===// |
128 | | enum IntType { |
129 | | NoInt = 0, |
130 | | SignedChar, |
131 | | UnsignedChar, |
132 | | SignedShort, |
133 | | UnsignedShort, |
134 | | SignedInt, |
135 | | UnsignedInt, |
136 | | SignedLong, |
137 | | UnsignedLong, |
138 | | SignedLongLong, |
139 | | UnsignedLongLong |
140 | | }; |
141 | | |
142 | | enum RealType { |
143 | | NoFloat = 255, |
144 | | Float = 0, |
145 | | Double, |
146 | | LongDouble, |
147 | | Float128 |
148 | | }; |
149 | | |
150 | | /// \brief The different kinds of __builtin_va_list types defined by |
151 | | /// the target implementation. |
152 | | enum BuiltinVaListKind { |
153 | | /// typedef char* __builtin_va_list; |
154 | | CharPtrBuiltinVaList = 0, |
155 | | |
156 | | /// typedef void* __builtin_va_list; |
157 | | VoidPtrBuiltinVaList, |
158 | | |
159 | | /// __builtin_va_list as defined by the AArch64 ABI |
160 | | /// http://infocenter.arm.com/help/topic/com.arm.doc.ihi0055a/IHI0055A_aapcs64.pdf |
161 | | AArch64ABIBuiltinVaList, |
162 | | |
163 | | /// __builtin_va_list as defined by the PNaCl ABI: |
164 | | /// http://www.chromium.org/nativeclient/pnacl/bitcode-abi#TOC-Machine-Types |
165 | | PNaClABIBuiltinVaList, |
166 | | |
167 | | /// __builtin_va_list as defined by the Power ABI: |
168 | | /// https://www.power.org |
169 | | /// /resources/downloads/Power-Arch-32-bit-ABI-supp-1.0-Embedded.pdf |
170 | | PowerABIBuiltinVaList, |
171 | | |
172 | | /// __builtin_va_list as defined by the x86-64 ABI: |
173 | | /// http://refspecs.linuxbase.org/elf/x86_64-abi-0.21.pdf |
174 | | X86_64ABIBuiltinVaList, |
175 | | |
176 | | /// __builtin_va_list as defined by ARM AAPCS ABI |
177 | | /// http://infocenter.arm.com |
178 | | // /help/topic/com.arm.doc.ihi0042d/IHI0042D_aapcs.pdf |
179 | | AAPCSABIBuiltinVaList, |
180 | | |
181 | | // typedef struct __va_list_tag |
182 | | // { |
183 | | // long __gpr; |
184 | | // long __fpr; |
185 | | // void *__overflow_arg_area; |
186 | | // void *__reg_save_area; |
187 | | // } va_list[1]; |
188 | | SystemZBuiltinVaList |
189 | | }; |
190 | | |
191 | | protected: |
192 | | IntType SizeType, IntMaxType, PtrDiffType, IntPtrType, WCharType, |
193 | | WIntType, Char16Type, Char32Type, Int64Type, SigAtomicType, |
194 | | ProcessIDType; |
195 | | |
196 | | /// \brief Whether Objective-C's built-in boolean type should be signed char. |
197 | | /// |
198 | | /// Otherwise, when this flag is not set, the normal built-in boolean type is |
199 | | /// used. |
200 | | unsigned UseSignedCharForObjCBool : 1; |
201 | | |
202 | | /// Control whether the alignment of bit-field types is respected when laying |
203 | | /// out structures. If true, then the alignment of the bit-field type will be |
204 | | /// used to (a) impact the alignment of the containing structure, and (b) |
205 | | /// ensure that the individual bit-field will not straddle an alignment |
206 | | /// boundary. |
207 | | unsigned UseBitFieldTypeAlignment : 1; |
208 | | |
209 | | /// \brief Whether zero length bitfields (e.g., int : 0;) force alignment of |
210 | | /// the next bitfield. |
211 | | /// |
212 | | /// If the alignment of the zero length bitfield is greater than the member |
213 | | /// that follows it, `bar', `bar' will be aligned as the type of the |
214 | | /// zero-length bitfield. |
215 | | unsigned UseZeroLengthBitfieldAlignment : 1; |
216 | | |
217 | | /// \brief Whether explicit bit field alignment attributes are honored. |
218 | | unsigned UseExplicitBitFieldAlignment : 1; |
219 | | |
220 | | /// If non-zero, specifies a fixed alignment value for bitfields that follow |
221 | | /// zero length bitfield, regardless of the zero length bitfield type. |
222 | | unsigned ZeroLengthBitfieldBoundary; |
223 | | |
224 | | /// \brief Specify if mangling based on address space map should be used or |
225 | | /// not for language specific address spaces |
226 | | bool UseAddrSpaceMapMangling; |
227 | | |
228 | | public: |
229 | 1.19M | IntType getSizeType() const { return SizeType; } |
230 | 39 | IntType getSignedSizeType() const { |
231 | 39 | switch (SizeType) { |
232 | 0 | case UnsignedShort: |
233 | 0 | return SignedShort; |
234 | 0 | case UnsignedInt: |
235 | 0 | return SignedInt; |
236 | 39 | case UnsignedLong: |
237 | 39 | return SignedLong; |
238 | 0 | case UnsignedLongLong: |
239 | 0 | return SignedLongLong; |
240 | 0 | default: |
241 | 0 | llvm_unreachable("Invalid SizeType"); |
242 | 39 | } |
243 | 39 | } |
244 | 158k | IntType getIntMaxType() const { return IntMaxType; } |
245 | 158k | IntType getUIntMaxType() const { |
246 | 158k | return getCorrespondingUnsignedType(IntMaxType); |
247 | 158k | } |
248 | 377k | IntType getPtrDiffType(unsigned AddrSpace) const { |
249 | 377k | return AddrSpace == 0 ? PtrDiffType377k : getPtrDiffTypeV(AddrSpace)0 ; |
250 | 377k | } |
251 | 328k | IntType getIntPtrType() const { return IntPtrType; } |
252 | 126k | IntType getUIntPtrType() const { |
253 | 126k | return getCorrespondingUnsignedType(IntPtrType); |
254 | 126k | } |
255 | 203k | IntType getWCharType() const { return WCharType; } |
256 | 156k | IntType getWIntType() const { return WIntType; } |
257 | 47.1k | IntType getChar16Type() const { return Char16Type; } |
258 | 47.1k | IntType getChar32Type() const { return Char32Type; } |
259 | 117k | IntType getInt64Type() const { return Int64Type; } |
260 | 63.2k | IntType getUInt64Type() const { |
261 | 63.2k | return getCorrespondingUnsignedType(Int64Type); |
262 | 63.2k | } |
263 | 63.2k | IntType getSigAtomicType() const { return SigAtomicType; } |
264 | 1.13k | IntType getProcessIDType() const { return ProcessIDType; } |
265 | | |
266 | 347k | static IntType getCorrespondingUnsignedType(IntType T) { |
267 | 347k | switch (T) { |
268 | 0 | case SignedChar: |
269 | 0 | return UnsignedChar; |
270 | 0 | case SignedShort: |
271 | 0 | return UnsignedShort; |
272 | 13.1k | case SignedInt: |
273 | 13.1k | return UnsignedInt; |
274 | 233k | case SignedLong: |
275 | 233k | return UnsignedLong; |
276 | 101k | case SignedLongLong: |
277 | 101k | return UnsignedLongLong; |
278 | 0 | default: |
279 | 0 | llvm_unreachable("Unexpected signed integer type"); |
280 | 347k | } |
281 | 347k | } |
282 | | |
283 | | /// \brief Return the width (in bits) of the specified integer type enum. |
284 | | /// |
285 | | /// For example, SignedInt -> getIntWidth(). |
286 | | unsigned getTypeWidth(IntType T) const; |
287 | | |
288 | | /// \brief Return integer type with specified width. |
289 | | virtual IntType getIntTypeByWidth(unsigned BitWidth, bool IsSigned) const; |
290 | | |
291 | | /// \brief Return the smallest integer type with at least the specified width. |
292 | | virtual IntType getLeastIntTypeByWidth(unsigned BitWidth, |
293 | | bool IsSigned) const; |
294 | | |
295 | | /// \brief Return floating point type with specified width. |
296 | | RealType getRealTypeByWidth(unsigned BitWidth) const; |
297 | | |
298 | | /// \brief Return the alignment (in bits) of the specified integer type enum. |
299 | | /// |
300 | | /// For example, SignedInt -> getIntAlign(). |
301 | | unsigned getTypeAlign(IntType T) const; |
302 | | |
303 | | /// \brief Returns true if the type is signed; false otherwise. |
304 | | static bool isTypeSigned(IntType T); |
305 | | |
306 | | /// \brief Return the width of pointers on this target, for the |
307 | | /// specified address space. |
308 | 455k | uint64_t getPointerWidth(unsigned AddrSpace) const { |
309 | 455k | return AddrSpace == 0 ? PointerWidth455k : getPointerWidthV(AddrSpace)518 ; |
310 | 455k | } |
311 | 243k | uint64_t getPointerAlign(unsigned AddrSpace) const { |
312 | 243k | return AddrSpace == 0 ? PointerAlign242k : getPointerAlignV(AddrSpace)492 ; |
313 | 243k | } |
314 | | |
315 | | /// \brief Return the maximum width of pointers on this target. |
316 | 1.58M | virtual uint64_t getMaxPointerWidth() const { |
317 | 1.58M | return PointerWidth; |
318 | 1.58M | } |
319 | | |
320 | | /// \brief Get integer value for null pointer. |
321 | | /// \param AddrSpace address space of pointee in source language. |
322 | 166k | virtual uint64_t getNullPointerValue(unsigned AddrSpace) const { |
323 | 166k | return 0; |
324 | 166k | } |
325 | | |
326 | | /// \brief Return the size of '_Bool' and C++ 'bool' for this target, in bits. |
327 | 66.1k | unsigned getBoolWidth() const { return BoolWidth; } |
328 | | |
329 | | /// \brief Return the alignment of '_Bool' and C++ 'bool' for this target. |
330 | 66.1k | unsigned getBoolAlign() const { return BoolAlign; } |
331 | | |
332 | 5.68M | unsigned getCharWidth() const { return 8; } // FIXME |
333 | 140k | unsigned getCharAlign() const { return 8; } // FIXME |
334 | | |
335 | | /// \brief Return the size of 'signed short' and 'unsigned short' for this |
336 | | /// target, in bits. |
337 | 1.30M | unsigned getShortWidth() const { return 16; } // FIXME |
338 | | |
339 | | /// \brief Return the alignment of 'signed short' and 'unsigned short' for |
340 | | /// this target. |
341 | 137k | unsigned getShortAlign() const { return 16; } // FIXME |
342 | | |
343 | | /// getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for |
344 | | /// this target, in bits. |
345 | 6.88M | unsigned getIntWidth() const { return IntWidth; } |
346 | 235k | unsigned getIntAlign() const { return IntAlign; } |
347 | | |
348 | | /// getLongWidth/Align - Return the size of 'signed long' and 'unsigned long' |
349 | | /// for this target, in bits. |
350 | 5.82M | unsigned getLongWidth() const { return LongWidth; } |
351 | 97.2k | unsigned getLongAlign() const { return LongAlign; } |
352 | | |
353 | | /// getLongLongWidth/Align - Return the size of 'signed long long' and |
354 | | /// 'unsigned long long' for this target, in bits. |
355 | 869k | unsigned getLongLongWidth() const { return LongLongWidth; } |
356 | 78.6k | unsigned getLongLongAlign() const { return LongLongAlign; } |
357 | | |
358 | | /// \brief Determine whether the __int128 type is supported on this target. |
359 | 41.5k | virtual bool hasInt128Type() const { |
360 | 41.5k | return getPointerWidth(0) >= 64; |
361 | 41.5k | } // FIXME |
362 | | |
363 | | /// \brief Determine whether the __float128 type is supported on this target. |
364 | 235 | virtual bool hasFloat128Type() const { return HasFloat128; } |
365 | | |
366 | | /// \brief Return the alignment that is suitable for storing any |
367 | | /// object with a fundamental alignment requirement. |
368 | 31.8k | unsigned getSuitableAlign() const { return SuitableAlign; } |
369 | | |
370 | | /// \brief Return the default alignment for __attribute__((aligned)) on |
371 | | /// this target, to be used if no alignment value is specified. |
372 | 486 | unsigned getDefaultAlignForAttributeAligned() const { |
373 | 486 | return DefaultAlignForAttributeAligned; |
374 | 486 | } |
375 | | |
376 | | /// getMinGlobalAlign - Return the minimum alignment of a global variable, |
377 | | /// unless its alignment is explicitly reduced via attributes. |
378 | 579k | unsigned getMinGlobalAlign() const { return MinGlobalAlign; } |
379 | | |
380 | | /// Return the largest alignment for which a suitably-sized allocation with |
381 | | /// '::operator new(size_t)' is guaranteed to produce a correctly-aligned |
382 | | /// pointer. |
383 | 23.9k | unsigned getNewAlign() const { |
384 | 23.9k | return NewAlign ? NewAlign990 : std::max(LongDoubleAlign, LongLongAlign)22.9k ; |
385 | 23.9k | } |
386 | | |
387 | | /// getWCharWidth/Align - Return the size of 'wchar_t' for this target, in |
388 | | /// bits. |
389 | 70.6k | unsigned getWCharWidth() const { return getTypeWidth(WCharType); } |
390 | 67.1k | unsigned getWCharAlign() const { return getTypeAlign(WCharType); } |
391 | | |
392 | | /// getChar16Width/Align - Return the size of 'char16_t' for this target, in |
393 | | /// bits. |
394 | 63.2k | unsigned getChar16Width() const { return getTypeWidth(Char16Type); } |
395 | 63.0k | unsigned getChar16Align() const { return getTypeAlign(Char16Type); } |
396 | | |
397 | | /// getChar32Width/Align - Return the size of 'char32_t' for this target, in |
398 | | /// bits. |
399 | 63.2k | unsigned getChar32Width() const { return getTypeWidth(Char32Type); } |
400 | 63.0k | unsigned getChar32Align() const { return getTypeAlign(Char32Type); } |
401 | | |
402 | | /// getHalfWidth/Align/Format - Return the size/align/format of 'half'. |
403 | 172 | unsigned getHalfWidth() const { return HalfWidth; } |
404 | 172 | unsigned getHalfAlign() const { return HalfAlign; } |
405 | 32.3k | const llvm::fltSemantics &getHalfFormat() const { return *HalfFormat; } |
406 | | |
407 | | /// getFloatWidth/Align/Format - Return the size/align/format of 'float'. |
408 | 36.3k | unsigned getFloatWidth() const { return FloatWidth; } |
409 | 4.69k | unsigned getFloatAlign() const { return FloatAlign; } |
410 | 585k | const llvm::fltSemantics &getFloatFormat() const { return *FloatFormat; } |
411 | | |
412 | | /// getDoubleWidth/Align/Format - Return the size/align/format of 'double'. |
413 | 36.2k | unsigned getDoubleWidth() const { return DoubleWidth; } |
414 | 4.58k | unsigned getDoubleAlign() const { return DoubleAlign; } |
415 | 259k | const llvm::fltSemantics &getDoubleFormat() const { return *DoubleFormat; } |
416 | | |
417 | | /// getLongDoubleWidth/Align/Format - Return the size/align/format of 'long |
418 | | /// double'. |
419 | 33.8k | unsigned getLongDoubleWidth() const { return LongDoubleWidth; } |
420 | 2.25k | unsigned getLongDoubleAlign() const { return LongDoubleAlign; } |
421 | 56.2k | const llvm::fltSemantics &getLongDoubleFormat() const { |
422 | 56.2k | return *LongDoubleFormat; |
423 | 56.2k | } |
424 | | |
425 | | /// getFloat128Width/Align/Format - Return the size/align/format of |
426 | | /// '__float128'. |
427 | 84 | unsigned getFloat128Width() const { return 128; } |
428 | 84 | unsigned getFloat128Align() const { return Float128Align; } |
429 | 13.9k | const llvm::fltSemantics &getFloat128Format() const { |
430 | 13.9k | return *Float128Format; |
431 | 13.9k | } |
432 | | |
433 | | /// \brief Return true if the 'long double' type should be mangled like |
434 | | /// __float128. |
435 | 161 | virtual bool useFloat128ManglingForLongDouble() const { return false; } |
436 | | |
437 | | /// \brief Return the value for the C99 FLT_EVAL_METHOD macro. |
438 | 9.90k | virtual unsigned getFloatEvalMethod() const { return 0; } |
439 | | |
440 | | // getLargeArrayMinWidth/Align - Return the minimum array size that is |
441 | | // 'large' and its alignment. |
442 | 70.0k | unsigned getLargeArrayMinWidth() const { return LargeArrayMinWidth; } |
443 | 1.71k | unsigned getLargeArrayAlign() const { return LargeArrayAlign; } |
444 | | |
445 | | /// \brief Return the maximum width lock-free atomic operation which will |
446 | | /// ever be supported for the given target |
447 | 575 | unsigned getMaxAtomicPromoteWidth() const { return MaxAtomicPromoteWidth; } |
448 | | /// \brief Return the maximum width lock-free atomic operation which can be |
449 | | /// inlined given the supported features of the given target. |
450 | 68.8k | unsigned getMaxAtomicInlineWidth() const { return MaxAtomicInlineWidth; } |
451 | | /// \brief Set the maximum inline or promote width lock-free atomic operation |
452 | | /// for the given target. |
453 | 22.2k | virtual void setMaxAtomicWidth() {} |
454 | | /// \brief Returns true if the given target supports lock-free atomic |
455 | | /// operations at the specified width and alignment. |
456 | | virtual bool hasBuiltinAtomic(uint64_t AtomicSizeInBits, |
457 | 2.27k | uint64_t AlignmentInBits) const { |
458 | 2.27k | return AtomicSizeInBits <= AlignmentInBits && |
459 | 2.10k | AtomicSizeInBits <= getMaxAtomicInlineWidth() && |
460 | 1.97k | (AtomicSizeInBits <= getCharWidth() || |
461 | 1.97k | llvm::isPowerOf2_64(AtomicSizeInBits / getCharWidth())); |
462 | 2.27k | } |
463 | | |
464 | | /// \brief Return the maximum vector alignment supported for the given target. |
465 | 9.18k | unsigned getMaxVectorAlign() const { return MaxVectorAlign; } |
466 | | /// \brief Return default simd alignment for the given target. Generally, this |
467 | | /// value is type-specific, but this alignment can be used for most of the |
468 | | /// types for the given target. |
469 | 119 | unsigned getSimdDefaultAlign() const { return SimdDefaultAlign; } |
470 | | |
471 | | /// \brief Return the size of intmax_t and uintmax_t for this target, in bits. |
472 | 5.11M | unsigned getIntMaxTWidth() const { |
473 | 5.11M | return getTypeWidth(IntMaxType); |
474 | 5.11M | } |
475 | | |
476 | | // Return the size of unwind_word for this target. |
477 | 2 | virtual unsigned getUnwindWordWidth() const { return getPointerWidth(0); } |
478 | | |
479 | | /// \brief Return the "preferred" register width on this target. |
480 | 12 | virtual unsigned getRegisterWidth() const { |
481 | 12 | // Currently we assume the register width on the target matches the pointer |
482 | 12 | // width, we can introduce a new variable for this if/when some target wants |
483 | 12 | // it. |
484 | 12 | return PointerWidth; |
485 | 12 | } |
486 | | |
487 | | /// \brief Returns the name of the mcount instrumentation function. |
488 | 89 | const char *getMCountName() const { |
489 | 89 | return MCountName; |
490 | 89 | } |
491 | | |
492 | | /// \brief Check if the Objective-C built-in boolean type should be signed |
493 | | /// char. |
494 | | /// |
495 | | /// Otherwise, if this returns false, the normal built-in boolean type |
496 | | /// should also be used for Objective-C. |
497 | 61.3k | bool useSignedCharForObjCBool() const { |
498 | 61.3k | return UseSignedCharForObjCBool; |
499 | 61.3k | } |
500 | 164 | void noSignedCharForObjCBool() { |
501 | 164 | UseSignedCharForObjCBool = false; |
502 | 164 | } |
503 | | |
504 | | /// \brief Check whether the alignment of bit-field types is respected |
505 | | /// when laying out structures. |
506 | 11.5k | bool useBitFieldTypeAlignment() const { |
507 | 11.5k | return UseBitFieldTypeAlignment; |
508 | 11.5k | } |
509 | | |
510 | | /// \brief Check whether zero length bitfields should force alignment of |
511 | | /// the next member. |
512 | 11.5k | bool useZeroLengthBitfieldAlignment() const { |
513 | 11.5k | return UseZeroLengthBitfieldAlignment; |
514 | 11.5k | } |
515 | | |
516 | | /// \brief Get the fixed alignment value in bits for a member that follows |
517 | | /// a zero length bitfield. |
518 | 80 | unsigned getZeroLengthBitfieldBoundary() const { |
519 | 80 | return ZeroLengthBitfieldBoundary; |
520 | 80 | } |
521 | | |
522 | | /// \brief Check whether explicit bitfield alignment attributes should be |
523 | | // honored, as in "__attribute__((aligned(2))) int b : 1;". |
524 | 263 | bool useExplicitBitFieldAlignment() const { |
525 | 263 | return UseExplicitBitFieldAlignment; |
526 | 263 | } |
527 | | |
528 | | /// \brief Check whether this target support '\#pragma options align=mac68k'. |
529 | 6 | bool hasAlignMac68kSupport() const { |
530 | 6 | return HasAlignMac68kSupport; |
531 | 6 | } |
532 | | |
533 | | /// \brief Return the user string for the specified integer type enum. |
534 | | /// |
535 | | /// For example, SignedShort -> "short". |
536 | | static const char *getTypeName(IntType T); |
537 | | |
538 | | /// \brief Return the constant suffix for the specified integer type enum. |
539 | | /// |
540 | | /// For example, SignedLong -> "L". |
541 | | const char *getTypeConstantSuffix(IntType T) const; |
542 | | |
543 | | /// \brief Return the printf format modifier for the specified |
544 | | /// integer type enum. |
545 | | /// |
546 | | /// For example, SignedLong -> "l". |
547 | | static const char *getTypeFormatModifier(IntType T); |
548 | | |
549 | | /// \brief Check whether the given real type should use the "fpret" flavor of |
550 | | /// Objective-C message passing on this target. |
551 | 55 | bool useObjCFPRetForRealType(RealType T) const { |
552 | 55 | return RealTypeUsesObjCFPRet & (1 << T); |
553 | 55 | } |
554 | | |
555 | | /// \brief Check whether _Complex long double should use the "fp2ret" flavor |
556 | | /// of Objective-C message passing on this target. |
557 | 2 | bool useObjCFP2RetForComplexLongDouble() const { |
558 | 2 | return ComplexLongDoubleUsesFP2Ret; |
559 | 2 | } |
560 | | |
561 | | /// \brief Specify if mangling based on address space map should be used or |
562 | | /// not for language specific address spaces |
563 | 29.6k | bool useAddressSpaceMapMangling() const { |
564 | 29.6k | return UseAddrSpaceMapMangling; |
565 | 29.6k | } |
566 | | |
567 | | ///===---- Other target property query methods --------------------------===// |
568 | | |
569 | | /// \brief Appends the target-specific \#define values for this |
570 | | /// target set to the specified buffer. |
571 | | virtual void getTargetDefines(const LangOptions &Opts, |
572 | | MacroBuilder &Builder) const = 0; |
573 | | |
574 | | |
575 | | /// Return information about target-specific builtins for |
576 | | /// the current primary target, and info about which builtins are non-portable |
577 | | /// across the current set of primary and secondary targets. |
578 | | virtual ArrayRef<Builtin::Info> getTargetBuiltins() const = 0; |
579 | | |
580 | | /// The __builtin_clz* and __builtin_ctz* built-in |
581 | | /// functions are specified to have undefined results for zero inputs, but |
582 | | /// on targets that support these operations in a way that provides |
583 | | /// well-defined results for zero without loss of performance, it is a good |
584 | | /// idea to avoid optimizing based on that undef behavior. |
585 | 527 | virtual bool isCLZForZeroUndef() const { return true; } |
586 | | |
587 | | /// \brief Returns the kind of __builtin_va_list type that should be used |
588 | | /// with this target. |
589 | | virtual BuiltinVaListKind getBuiltinVaListKind() const = 0; |
590 | | |
591 | | /// Returns whether or not type \c __builtin_ms_va_list type is |
592 | | /// available on this target. |
593 | 30.4k | bool hasBuiltinMSVaList() const { return HasBuiltinMSVaList; } |
594 | | |
595 | | /// Returns true for RenderScript. |
596 | 768 | bool isRenderScriptTarget() const { return IsRenderScriptTarget; } |
597 | | |
598 | | /// \brief Returns whether the passed in string is a valid clobber in an |
599 | | /// inline asm statement. |
600 | | /// |
601 | | /// This is used by Sema. |
602 | | bool isValidClobber(StringRef Name) const; |
603 | | |
604 | | /// \brief Returns whether the passed in string is a valid register name |
605 | | /// according to GCC. |
606 | | /// |
607 | | /// This is used by Sema for inline asm statements. |
608 | | bool isValidGCCRegisterName(StringRef Name) const; |
609 | | |
610 | | /// \brief Returns the "normalized" GCC register name. |
611 | | /// |
612 | | /// ReturnCannonical true will return the register name without any additions |
613 | | /// such as "{}" or "%" in it's canonical form, for example: |
614 | | /// ReturnCanonical = true and Name = "rax", will return "ax". |
615 | | StringRef getNormalizedGCCRegisterName(StringRef Name, |
616 | | bool ReturnCanonical = false) const; |
617 | | |
618 | | virtual StringRef getConstraintRegister(const StringRef &Constraint, |
619 | 1.20k | const StringRef &Expression) const { |
620 | 1.20k | return ""; |
621 | 1.20k | } |
622 | | |
623 | | struct ConstraintInfo { |
624 | | enum { |
625 | | CI_None = 0x00, |
626 | | CI_AllowsMemory = 0x01, |
627 | | CI_AllowsRegister = 0x02, |
628 | | CI_ReadWrite = 0x04, // "+r" output constraint (read and write). |
629 | | CI_HasMatchingInput = 0x08, // This output operand has a matching input. |
630 | | CI_ImmediateConstant = 0x10, // This operand must be an immediate constant |
631 | | CI_EarlyClobber = 0x20, // "&" output constraint (early clobber). |
632 | | }; |
633 | | unsigned Flags; |
634 | | int TiedOperand; |
635 | | struct { |
636 | | int Min; |
637 | | int Max; |
638 | | } ImmRange; |
639 | | llvm::SmallSet<int, 4> ImmSet; |
640 | | |
641 | | std::string ConstraintStr; // constraint: "=rm" |
642 | | std::string Name; // Operand name: [foo] with no []'s. |
643 | | public: |
644 | | ConstraintInfo(StringRef ConstraintStr, StringRef Name) |
645 | | : Flags(0), TiedOperand(-1), ConstraintStr(ConstraintStr.str()), |
646 | 9.27k | Name(Name.str()) { |
647 | 9.27k | ImmRange.Min = ImmRange.Max = 0; |
648 | 9.27k | } |
649 | | |
650 | 11.4k | const std::string &getConstraintStr() const { return ConstraintStr; } |
651 | 164 | const std::string &getName() const { return Name; } |
652 | 1.10k | bool isReadWrite() const { return (Flags & CI_ReadWrite) != 0; } |
653 | 5.08k | bool earlyClobber() { return (Flags & CI_EarlyClobber) != 0; } |
654 | 10.5k | bool allowsRegister() const { return (Flags & CI_AllowsRegister) != 0; } |
655 | 17.8k | bool allowsMemory() const { return (Flags & CI_AllowsMemory) != 0; } |
656 | | |
657 | | /// \brief Return true if this output operand has a matching |
658 | | /// (tied) input operand. |
659 | 759 | bool hasMatchingInput() const { return (Flags & CI_HasMatchingInput) != 0; } |
660 | | |
661 | | /// \brief Return true if this input operand is a matching |
662 | | /// constraint that ties it to an output operand. |
663 | | /// |
664 | | /// If this returns true then getTiedOperand will indicate which output |
665 | | /// operand this is tied to. |
666 | 5.06k | bool hasTiedOperand() const { return TiedOperand != -1; } |
667 | 165 | unsigned getTiedOperand() const { |
668 | 165 | assert(hasTiedOperand() && "Has no tied operand!"); |
669 | 165 | return (unsigned)TiedOperand; |
670 | 165 | } |
671 | | |
672 | 1.92k | bool requiresImmediateConstant() const { |
673 | 1.92k | return (Flags & CI_ImmediateConstant) != 0; |
674 | 1.92k | } |
675 | 74 | bool isValidAsmImmediate(const llvm::APInt &Value) const { |
676 | 58 | return (Value.sge(ImmRange.Min) && Value.sle(ImmRange.Max)) || |
677 | 44 | ImmSet.count(Value.getZExtValue()) != 0; |
678 | 74 | } |
679 | | |
680 | 97 | void setIsReadWrite() { Flags |= CI_ReadWrite; } |
681 | 35 | void setEarlyClobber() { Flags |= CI_EarlyClobber; } |
682 | 5.24k | void setAllowsMemory() { Flags |= CI_AllowsMemory; } |
683 | 5.21k | void setAllowsRegister() { Flags |= CI_AllowsRegister; } |
684 | 179 | void setHasMatchingInput() { Flags |= CI_HasMatchingInput; } |
685 | 104 | void setRequiresImmediate(int Min, int Max) { |
686 | 104 | Flags |= CI_ImmediateConstant; |
687 | 104 | ImmRange.Min = Min; |
688 | 104 | ImmRange.Max = Max; |
689 | 104 | } |
690 | 28 | void setRequiresImmediate(llvm::ArrayRef<int> Exacts) { |
691 | 28 | Flags |= CI_ImmediateConstant; |
692 | 28 | for (int Exact : Exacts) |
693 | 84 | ImmSet.insert(Exact); |
694 | 28 | } |
695 | 0 | void setRequiresImmediate(int Exact) { |
696 | 0 | Flags |= CI_ImmediateConstant; |
697 | 0 | ImmSet.insert(Exact); |
698 | 0 | } |
699 | 17 | void setRequiresImmediate() { |
700 | 17 | Flags |= CI_ImmediateConstant; |
701 | 17 | ImmRange.Min = INT_MIN; |
702 | 17 | ImmRange.Max = INT_MAX; |
703 | 17 | } |
704 | | |
705 | | /// \brief Indicate that this is an input operand that is tied to |
706 | | /// the specified output operand. |
707 | | /// |
708 | | /// Copy over the various constraint information from the output. |
709 | 179 | void setTiedOperand(unsigned N, ConstraintInfo &Output) { |
710 | 179 | Output.setHasMatchingInput(); |
711 | 179 | Flags = Output.Flags; |
712 | 179 | TiedOperand = N; |
713 | 179 | // Don't copy Name or constraint string. |
714 | 179 | } |
715 | | }; |
716 | | |
717 | | /// \brief Validate register name used for global register variables. |
718 | | /// |
719 | | /// This function returns true if the register passed in RegName can be used |
720 | | /// for global register variables on this target. In addition, it returns |
721 | | /// true in HasSizeMismatch if the size of the register doesn't match the |
722 | | /// variable size passed in RegSize. |
723 | | virtual bool validateGlobalRegisterVariable(StringRef RegName, |
724 | | unsigned RegSize, |
725 | 5 | bool &HasSizeMismatch) const { |
726 | 5 | HasSizeMismatch = false; |
727 | 5 | return true; |
728 | 5 | } |
729 | | |
730 | | // validateOutputConstraint, validateInputConstraint - Checks that |
731 | | // a constraint is valid and provides information about it. |
732 | | // FIXME: These should return a real error instead of just true/false. |
733 | | bool validateOutputConstraint(ConstraintInfo &Info) const; |
734 | | bool validateInputConstraint(MutableArrayRef<ConstraintInfo> OutputConstraints, |
735 | | ConstraintInfo &info) const; |
736 | | |
737 | | virtual bool validateOutputSize(StringRef /*Constraint*/, |
738 | 484 | unsigned /*Size*/) const { |
739 | 484 | return true; |
740 | 484 | } |
741 | | |
742 | | virtual bool validateInputSize(StringRef /*Constraint*/, |
743 | 736 | unsigned /*Size*/) const { |
744 | 736 | return true; |
745 | 736 | } |
746 | | virtual bool |
747 | | validateConstraintModifier(StringRef /*Constraint*/, |
748 | | char /*Modifier*/, |
749 | | unsigned /*Size*/, |
750 | 4.18k | std::string &/*SuggestedModifier*/) const { |
751 | 4.18k | return true; |
752 | 4.18k | } |
753 | | virtual bool |
754 | | validateAsmConstraint(const char *&Name, |
755 | | TargetInfo::ConstraintInfo &info) const = 0; |
756 | | |
757 | | bool resolveSymbolicName(const char *&Name, |
758 | | ArrayRef<ConstraintInfo> OutputConstraints, |
759 | | unsigned &Index) const; |
760 | | |
761 | | // Constraint parm will be left pointing at the last character of |
762 | | // the constraint. In practice, it won't be changed unless the |
763 | | // constraint is longer than one character. |
764 | 1.00k | virtual std::string convertConstraint(const char *&Constraint) const { |
765 | 1.00k | // 'p' defaults to 'r', but can be overridden by targets. |
766 | 1.00k | if (*Constraint == 'p') |
767 | 14 | return std::string("r"); |
768 | 991 | return std::string(1, *Constraint); |
769 | 1.00k | } |
770 | | |
771 | | /// \brief Returns a string of target-specific clobbers, in LLVM format. |
772 | | virtual const char *getClobbers() const = 0; |
773 | | |
774 | | /// \brief Returns true if NaN encoding is IEEE 754-2008. |
775 | | /// Only MIPS allows a different encoding. |
776 | 111 | virtual bool isNan2008() const { |
777 | 111 | return true; |
778 | 111 | } |
779 | | |
780 | | /// \brief Returns the target triple of the primary target. |
781 | 12.5M | const llvm::Triple &getTriple() const { |
782 | 12.5M | return Triple; |
783 | 12.5M | } |
784 | | |
785 | 70.1k | const llvm::DataLayout &getDataLayout() const { |
786 | 70.1k | assert(DataLayout && "Uninitialized DataLayout!"); |
787 | 70.1k | return *DataLayout; |
788 | 70.1k | } |
789 | | |
790 | | struct GCCRegAlias { |
791 | | const char * const Aliases[5]; |
792 | | const char * const Register; |
793 | | }; |
794 | | |
795 | | struct AddlRegName { |
796 | | const char * const Names[5]; |
797 | | const unsigned RegNum; |
798 | | }; |
799 | | |
800 | | /// \brief Does this target support "protected" visibility? |
801 | | /// |
802 | | /// Any target which dynamic libraries will naturally support |
803 | | /// something like "default" (meaning that the symbol is visible |
804 | | /// outside this shared object) and "hidden" (meaning that it isn't) |
805 | | /// visibilities, but "protected" is really an ELF-specific concept |
806 | | /// with weird semantics designed around the convenience of dynamic |
807 | | /// linker implementations. Which is not to suggest that there's |
808 | | /// consistent target-independent semantics for "default" visibility |
809 | | /// either; the entire thing is pretty badly mangled. |
810 | 4 | virtual bool hasProtectedVisibility() const { return true; } |
811 | | |
812 | | /// \brief An optional hook that targets can implement to perform semantic |
813 | | /// checking on attribute((section("foo"))) specifiers. |
814 | | /// |
815 | | /// In this case, "foo" is passed in to be checked. If the section |
816 | | /// specifier is invalid, the backend should return a non-empty string |
817 | | /// that indicates the problem. |
818 | | /// |
819 | | /// This hook is a simple quality of implementation feature to catch errors |
820 | | /// and give good diagnostics in cases when the assembler or code generator |
821 | | /// would otherwise reject the section specifier. |
822 | | /// |
823 | 84 | virtual std::string isValidSectionSpecifier(StringRef SR) const { |
824 | 84 | return ""; |
825 | 84 | } |
826 | | |
827 | | /// \brief Set forced language options. |
828 | | /// |
829 | | /// Apply changes to the target information with respect to certain |
830 | | /// language options which change the target configuration and adjust |
831 | | /// the language based on the target options where applicable. |
832 | | virtual void adjust(LangOptions &Opts); |
833 | | |
834 | | /// \brief Adjust target options based on codegen options. |
835 | | virtual void adjustTargetOptions(const CodeGenOptions &CGOpts, |
836 | 37.0k | TargetOptions &TargetOpts) const {} |
837 | | |
838 | | /// \brief Initialize the map with the default set of target features for the |
839 | | /// CPU this should include all legal feature strings on the target. |
840 | | /// |
841 | | /// \return False on error (invalid features). |
842 | | virtual bool initFeatureMap(llvm::StringMap<bool> &Features, |
843 | | DiagnosticsEngine &Diags, StringRef CPU, |
844 | | const std::vector<std::string> &FeatureVec) const; |
845 | | |
846 | | /// \brief Get the ABI currently in use. |
847 | 0 | virtual StringRef getABI() const { return StringRef(); } |
848 | | |
849 | | /// \brief Get the C++ ABI currently in use. |
850 | 36.4M | TargetCXXABI getCXXABI() const { |
851 | 36.4M | return TheCXXABI; |
852 | 36.4M | } |
853 | | |
854 | | /// \brief Target the specified CPU. |
855 | | /// |
856 | | /// \return False on error (invalid CPU name). |
857 | 0 | virtual bool setCPU(const std::string &Name) { |
858 | 0 | return false; |
859 | 0 | } |
860 | | |
861 | | /// brief Determine whether this TargetInfo supports the given CPU name. |
862 | 0 | virtual bool isValidCPUName(StringRef Name) const { |
863 | 0 | return false; |
864 | 0 | } |
865 | | |
866 | | /// \brief Use the specified ABI. |
867 | | /// |
868 | | /// \return False on error (invalid ABI name). |
869 | 0 | virtual bool setABI(const std::string &Name) { |
870 | 0 | return false; |
871 | 0 | } |
872 | | |
873 | | /// \brief Use the specified unit for FP math. |
874 | | /// |
875 | | /// \return False on error (invalid unit name). |
876 | 0 | virtual bool setFPMath(StringRef Name) { |
877 | 0 | return false; |
878 | 0 | } |
879 | | |
880 | | /// \brief Enable or disable a specific target feature; |
881 | | /// the feature name must be valid. |
882 | | virtual void setFeatureEnabled(llvm::StringMap<bool> &Features, |
883 | | StringRef Name, |
884 | 78.4k | bool Enabled) const { |
885 | 78.4k | Features[Name] = Enabled; |
886 | 78.4k | } |
887 | | |
888 | | /// \brief Determine whether this TargetInfo supports the given feature. |
889 | 19 | virtual bool isValidFeatureName(StringRef Feature) const { |
890 | 19 | return false; |
891 | 19 | } |
892 | | |
893 | | /// \brief Perform initialization based on the user configured |
894 | | /// set of features (e.g., +sse4). |
895 | | /// |
896 | | /// The list is guaranteed to have at most one entry per feature. |
897 | | /// |
898 | | /// The target may modify the features list, to change which options are |
899 | | /// passed onwards to the backend. |
900 | | /// FIXME: This part should be fixed so that we can change handleTargetFeatures |
901 | | /// to merely a TargetInfo initialization routine. |
902 | | /// |
903 | | /// \return False on error. |
904 | | virtual bool handleTargetFeatures(std::vector<std::string> &Features, |
905 | 456 | DiagnosticsEngine &Diags) { |
906 | 456 | return true; |
907 | 456 | } |
908 | | |
909 | | /// \brief Determine whether the given target has the given feature. |
910 | 35 | virtual bool hasFeature(StringRef Feature) const { |
911 | 35 | return false; |
912 | 35 | } |
913 | | |
914 | | // \brief Validate the contents of the __builtin_cpu_supports(const char*) |
915 | | // argument. |
916 | 0 | virtual bool validateCpuSupports(StringRef Name) const { return false; } |
917 | | |
918 | | // \brief Validate the contents of the __builtin_cpu_is(const char*) |
919 | | // argument. |
920 | 0 | virtual bool validateCpuIs(StringRef Name) const { return false; } |
921 | | |
922 | | // \brief Returns maximal number of args passed in registers. |
923 | 136 | unsigned getRegParmMax() const { |
924 | 136 | assert(RegParmMax < 7 && "RegParmMax value is larger than AST can handle"); |
925 | 136 | return RegParmMax; |
926 | 136 | } |
927 | | |
928 | | /// \brief Whether the target supports thread-local storage. |
929 | 3.75M | bool isTLSSupported() const { |
930 | 3.75M | return TLSSupported; |
931 | 3.75M | } |
932 | | |
933 | | /// \brief Return the maximum alignment (in bits) of a TLS variable |
934 | | /// |
935 | | /// Gets the maximum alignment (in bits) of a TLS variable on this target. |
936 | | /// Returns zero if there is no such constraint. |
937 | 1.14M | unsigned short getMaxTLSAlign() const { |
938 | 1.14M | return MaxTLSAlign; |
939 | 1.14M | } |
940 | | |
941 | | /// \brief Whether the target supports SEH __try. |
942 | 219 | bool isSEHTrySupported() const { |
943 | 219 | return getTriple().isOSWindows() && |
944 | 219 | (getTriple().getArch() == llvm::Triple::x86 || |
945 | 183 | getTriple().getArch() == llvm::Triple::x86_64); |
946 | 219 | } |
947 | | |
948 | | /// \brief Return true if {|} are normal characters in the asm string. |
949 | | /// |
950 | | /// If this returns false (the default), then {abc|xyz} is syntax |
951 | | /// that says that when compiling for asm variant #0, "abc" should be |
952 | | /// generated, but when compiling for asm variant #1, "xyz" should be |
953 | | /// generated. |
954 | 11.7k | bool hasNoAsmVariants() const { |
955 | 11.7k | return NoAsmVariants; |
956 | 11.7k | } |
957 | | |
958 | | /// \brief Return the register number that __builtin_eh_return_regno would |
959 | | /// return with the specified argument. |
960 | | /// This corresponds with TargetLowering's getExceptionPointerRegister |
961 | | /// and getExceptionSelectorRegister in the backend. |
962 | 0 | virtual int getEHDataRegisterNumber(unsigned RegNo) const { |
963 | 0 | return -1; |
964 | 0 | } |
965 | | |
966 | | /// \brief Return the section to use for C++ static initialization functions. |
967 | 1.60k | virtual const char *getStaticInitSectionSpecifier() const { |
968 | 1.60k | return nullptr; |
969 | 1.60k | } |
970 | | |
971 | 29.6k | const LangAS::Map &getAddressSpaceMap() const { |
972 | 29.6k | return *AddrSpaceMap; |
973 | 29.6k | } |
974 | | |
975 | | /// \brief Return an AST address space which can be used opportunistically |
976 | | /// for constant global memory. It must be possible to convert pointers into |
977 | | /// this address space to LangAS::Default. If no such address space exists, |
978 | | /// this may return None, and such optimizations will be disabled. |
979 | 7 | virtual llvm::Optional<unsigned> getConstantAddressSpace() const { |
980 | 7 | return LangAS::Default; |
981 | 7 | } |
982 | | |
983 | | /// \brief Retrieve the name of the platform as it is used in the |
984 | | /// availability attribute. |
985 | 218k | StringRef getPlatformName() const { return PlatformName; } |
986 | | |
987 | | /// \brief Retrieve the minimum desired version of the platform, to |
988 | | /// which the program should be compiled. |
989 | 191k | VersionTuple getPlatformMinVersion() const { return PlatformMinVersion; } |
990 | | |
991 | 59.4k | bool isBigEndian() const { return BigEndian; } |
992 | 449 | bool isLittleEndian() const { return !BigEndian; } |
993 | | |
994 | | enum CallingConvMethodType { |
995 | | CCMT_Unknown, |
996 | | CCMT_Member, |
997 | | CCMT_NonMember |
998 | | }; |
999 | | |
1000 | | /// \brief Gets the default calling convention for the given target and |
1001 | | /// declaration context. |
1002 | 2.87M | virtual CallingConv getDefaultCallingConv(CallingConvMethodType MT) const { |
1003 | 2.87M | // Not all targets will specify an explicit calling convention that we can |
1004 | 2.87M | // express. This will always do the right thing, even though it's not |
1005 | 2.87M | // an explicit calling convention. |
1006 | 2.87M | return CC_C; |
1007 | 2.87M | } |
1008 | | |
1009 | | enum CallingConvCheckResult { |
1010 | | CCCR_OK, |
1011 | | CCCR_Warning, |
1012 | | CCCR_Ignore, |
1013 | | }; |
1014 | | |
1015 | | /// \brief Determines whether a given calling convention is valid for the |
1016 | | /// target. A calling convention can either be accepted, produce a warning |
1017 | | /// and be substituted with the default calling convention, or (someday) |
1018 | | /// produce an error (such as using thiscall on a non-instance function). |
1019 | | virtual CallingConvCheckResult checkCallingConvention(CallingConv CC) const { |
1020 | | switch (CC) { |
1021 | | default: |
1022 | | return CCCR_Warning; |
1023 | | case CC_C: |
1024 | | return CCCR_OK; |
1025 | | } |
1026 | | } |
1027 | | |
1028 | | /// Controls if __builtin_longjmp / __builtin_setjmp can be lowered to |
1029 | | /// llvm.eh.sjlj.longjmp / llvm.eh.sjlj.setjmp. |
1030 | 6 | virtual bool hasSjLjLowering() const { |
1031 | 6 | return false; |
1032 | 6 | } |
1033 | | |
1034 | | /// \brief Whether target allows to overalign ABI-specified preferred alignment |
1035 | 1.09M | virtual bool allowsLargerPreferedTypeAlignment() const { return true; } |
1036 | | |
1037 | | /// \brief Set supported OpenCL extensions and optional core features. |
1038 | 17.8k | virtual void setSupportedOpenCLOpts() {} |
1039 | | |
1040 | | /// \brief Set supported OpenCL extensions as written on command line |
1041 | 40.1k | virtual void setOpenCLExtensionOpts() { |
1042 | 22 | for (const auto &Ext : getTargetOpts().OpenCLExtensionsAsWritten) { |
1043 | 22 | getTargetOpts().SupportedOpenCLOptions.support(Ext); |
1044 | 22 | } |
1045 | 40.1k | } |
1046 | | |
1047 | | /// \brief Get supported OpenCL extensions and optional core features. |
1048 | 22.3k | OpenCLOptions &getSupportedOpenCLOpts() { |
1049 | 22.3k | return getTargetOpts().SupportedOpenCLOptions; |
1050 | 22.3k | } |
1051 | | |
1052 | | /// \brief Get const supported OpenCL extensions and optional core features. |
1053 | 13.4k | const OpenCLOptions &getSupportedOpenCLOpts() const { |
1054 | 13.4k | return getTargetOpts().SupportedOpenCLOptions; |
1055 | 13.4k | } |
1056 | | |
1057 | | /// \brief Get address space for OpenCL type. |
1058 | | virtual LangAS::ID getOpenCLTypeAddrSpace(const Type *T) const; |
1059 | | |
1060 | | /// \returns Target specific vtbl ptr address space. |
1061 | 35 | virtual unsigned getVtblPtrAddressSpace() const { |
1062 | 35 | return 0; |
1063 | 35 | } |
1064 | | |
1065 | | /// \returns If a target requires an address within a target specific address |
1066 | | /// space \p AddressSpace to be converted in order to be used, then return the |
1067 | | /// corresponding target specific DWARF address space. |
1068 | | /// |
1069 | | /// \returns Otherwise return None and no conversion will be emitted in the |
1070 | | /// DWARF. |
1071 | 4.63k | virtual Optional<unsigned> getDWARFAddressSpace(unsigned AddressSpace) const { |
1072 | 4.63k | return None; |
1073 | 4.63k | } |
1074 | | |
1075 | | /// \brief Check the target is valid after it is fully initialized. |
1076 | 39.9k | virtual bool validateTarget(DiagnosticsEngine &Diags) const { |
1077 | 39.9k | return true; |
1078 | 39.9k | } |
1079 | | |
1080 | | protected: |
1081 | 188 | virtual uint64_t getPointerWidthV(unsigned AddrSpace) const { |
1082 | 188 | return PointerWidth; |
1083 | 188 | } |
1084 | 182 | virtual uint64_t getPointerAlignV(unsigned AddrSpace) const { |
1085 | 182 | return PointerAlign; |
1086 | 182 | } |
1087 | 0 | virtual enum IntType getPtrDiffTypeV(unsigned AddrSpace) const { |
1088 | 0 | return PtrDiffType; |
1089 | 0 | } |
1090 | | virtual ArrayRef<const char *> getGCCRegNames() const = 0; |
1091 | | virtual ArrayRef<GCCRegAlias> getGCCRegAliases() const = 0; |
1092 | 2.52k | virtual ArrayRef<AddlRegName> getGCCAddlRegNames() const { |
1093 | 2.52k | return None; |
1094 | 2.52k | } |
1095 | | }; |
1096 | | |
1097 | | } // end namespace clang |
1098 | | |
1099 | | #endif |