/Users/buildslave/jenkins/workspace/coverage/llvm-project/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 | | // 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 | | /// \file |
10 | | /// Defines the clang::TargetInfo interface. |
11 | | /// |
12 | | //===----------------------------------------------------------------------===// |
13 | | |
14 | | #ifndef LLVM_CLANG_BASIC_TARGETINFO_H |
15 | | #define LLVM_CLANG_BASIC_TARGETINFO_H |
16 | | |
17 | | #include "clang/Basic/AddressSpaces.h" |
18 | | #include "clang/Basic/CodeGenOptions.h" |
19 | | #include "clang/Basic/LLVM.h" |
20 | | #include "clang/Basic/LangOptions.h" |
21 | | #include "clang/Basic/Specifiers.h" |
22 | | #include "clang/Basic/TargetCXXABI.h" |
23 | | #include "clang/Basic/TargetOptions.h" |
24 | | #include "llvm/ADT/APFloat.h" |
25 | | #include "llvm/ADT/APInt.h" |
26 | | #include "llvm/ADT/ArrayRef.h" |
27 | | #include "llvm/ADT/IntrusiveRefCntPtr.h" |
28 | | #include "llvm/ADT/Optional.h" |
29 | | #include "llvm/ADT/SmallSet.h" |
30 | | #include "llvm/ADT/StringMap.h" |
31 | | #include "llvm/ADT/StringRef.h" |
32 | | #include "llvm/ADT/Triple.h" |
33 | | #include "llvm/Frontend/OpenMP/OMPGridValues.h" |
34 | | #include "llvm/Support/DataTypes.h" |
35 | | #include "llvm/Support/VersionTuple.h" |
36 | | #include <cassert> |
37 | | #include <string> |
38 | | #include <vector> |
39 | | |
40 | | namespace llvm { |
41 | | struct fltSemantics; |
42 | | class DataLayout; |
43 | | } |
44 | | |
45 | | namespace clang { |
46 | | class DiagnosticsEngine; |
47 | | class LangOptions; |
48 | | class CodeGenOptions; |
49 | | class MacroBuilder; |
50 | | class QualType; |
51 | | class SourceLocation; |
52 | | class SourceManager; |
53 | | |
54 | | namespace Builtin { struct Info; } |
55 | | |
56 | | /// Fields controlling how types are laid out in memory; these may need to |
57 | | /// be copied for targets like AMDGPU that base their ABIs on an auxiliary |
58 | | /// CPU target. |
59 | | struct TransferrableTargetInfo { |
60 | | unsigned char PointerWidth, PointerAlign; |
61 | | unsigned char BoolWidth, BoolAlign; |
62 | | unsigned char IntWidth, IntAlign; |
63 | | unsigned char HalfWidth, HalfAlign; |
64 | | unsigned char BFloat16Width, BFloat16Align; |
65 | | unsigned char FloatWidth, FloatAlign; |
66 | | unsigned char DoubleWidth, DoubleAlign; |
67 | | unsigned char LongDoubleWidth, LongDoubleAlign, Float128Align; |
68 | | unsigned char LargeArrayMinWidth, LargeArrayAlign; |
69 | | unsigned char LongWidth, LongAlign; |
70 | | unsigned char LongLongWidth, LongLongAlign; |
71 | | |
72 | | // Fixed point bit widths |
73 | | unsigned char ShortAccumWidth, ShortAccumAlign; |
74 | | unsigned char AccumWidth, AccumAlign; |
75 | | unsigned char LongAccumWidth, LongAccumAlign; |
76 | | unsigned char ShortFractWidth, ShortFractAlign; |
77 | | unsigned char FractWidth, FractAlign; |
78 | | unsigned char LongFractWidth, LongFractAlign; |
79 | | |
80 | | // If true, unsigned fixed point types have the same number of fractional bits |
81 | | // as their signed counterparts, forcing the unsigned types to have one extra |
82 | | // bit of padding. Otherwise, unsigned fixed point types have |
83 | | // one more fractional bit than its corresponding signed type. This is false |
84 | | // by default. |
85 | | bool PaddingOnUnsignedFixedPoint; |
86 | | |
87 | | // Fixed point integral and fractional bit sizes |
88 | | // Saturated types share the same integral/fractional bits as their |
89 | | // corresponding unsaturated types. |
90 | | // For simplicity, the fractional bits in a _Fract type will be one less the |
91 | | // width of that _Fract type. This leaves all signed _Fract types having no |
92 | | // padding and unsigned _Fract types will only have 1 bit of padding after the |
93 | | // sign if PaddingOnUnsignedFixedPoint is set. |
94 | | unsigned char ShortAccumScale; |
95 | | unsigned char AccumScale; |
96 | | unsigned char LongAccumScale; |
97 | | |
98 | | unsigned char SuitableAlign; |
99 | | unsigned char DefaultAlignForAttributeAligned; |
100 | | unsigned char MinGlobalAlign; |
101 | | |
102 | | unsigned short NewAlign; |
103 | | unsigned MaxVectorAlign; |
104 | | unsigned MaxTLSAlign; |
105 | | |
106 | | const llvm::fltSemantics *HalfFormat, *BFloat16Format, *FloatFormat, |
107 | | *DoubleFormat, *LongDoubleFormat, *Float128Format; |
108 | | |
109 | | ///===---- Target Data Type Query Methods -------------------------------===// |
110 | | enum IntType { |
111 | | NoInt = 0, |
112 | | SignedChar, |
113 | | UnsignedChar, |
114 | | SignedShort, |
115 | | UnsignedShort, |
116 | | SignedInt, |
117 | | UnsignedInt, |
118 | | SignedLong, |
119 | | UnsignedLong, |
120 | | SignedLongLong, |
121 | | UnsignedLongLong |
122 | | }; |
123 | | |
124 | | enum RealType { |
125 | | NoFloat = 255, |
126 | | Float = 0, |
127 | | Double, |
128 | | LongDouble, |
129 | | Float128 |
130 | | }; |
131 | | protected: |
132 | | IntType SizeType, IntMaxType, PtrDiffType, IntPtrType, WCharType, |
133 | | WIntType, Char16Type, Char32Type, Int64Type, SigAtomicType, |
134 | | ProcessIDType; |
135 | | |
136 | | /// Whether Objective-C's built-in boolean type should be signed char. |
137 | | /// |
138 | | /// Otherwise, when this flag is not set, the normal built-in boolean type is |
139 | | /// used. |
140 | | unsigned UseSignedCharForObjCBool : 1; |
141 | | |
142 | | /// Control whether the alignment of bit-field types is respected when laying |
143 | | /// out structures. If true, then the alignment of the bit-field type will be |
144 | | /// used to (a) impact the alignment of the containing structure, and (b) |
145 | | /// ensure that the individual bit-field will not straddle an alignment |
146 | | /// boundary. |
147 | | unsigned UseBitFieldTypeAlignment : 1; |
148 | | |
149 | | /// Whether zero length bitfields (e.g., int : 0;) force alignment of |
150 | | /// the next bitfield. |
151 | | /// |
152 | | /// If the alignment of the zero length bitfield is greater than the member |
153 | | /// that follows it, `bar', `bar' will be aligned as the type of the |
154 | | /// zero-length bitfield. |
155 | | unsigned UseZeroLengthBitfieldAlignment : 1; |
156 | | |
157 | | /// Whether explicit bit field alignment attributes are honored. |
158 | | unsigned UseExplicitBitFieldAlignment : 1; |
159 | | |
160 | | /// If non-zero, specifies a fixed alignment value for bitfields that follow |
161 | | /// zero length bitfield, regardless of the zero length bitfield type. |
162 | | unsigned ZeroLengthBitfieldBoundary; |
163 | | }; |
164 | | |
165 | | /// OpenCL type kinds. |
166 | | enum OpenCLTypeKind : uint8_t { |
167 | | OCLTK_Default, |
168 | | OCLTK_ClkEvent, |
169 | | OCLTK_Event, |
170 | | OCLTK_Image, |
171 | | OCLTK_Pipe, |
172 | | OCLTK_Queue, |
173 | | OCLTK_ReserveID, |
174 | | OCLTK_Sampler, |
175 | | }; |
176 | | |
177 | | /// Exposes information about the current target. |
178 | | /// |
179 | | class TargetInfo : public virtual TransferrableTargetInfo, |
180 | | public RefCountedBase<TargetInfo> { |
181 | | std::shared_ptr<TargetOptions> TargetOpts; |
182 | | llvm::Triple Triple; |
183 | | protected: |
184 | | // Target values set by the ctor of the actual target implementation. Default |
185 | | // values are specified by the TargetInfo constructor. |
186 | | bool BigEndian; |
187 | | bool TLSSupported; |
188 | | bool VLASupported; |
189 | | bool NoAsmVariants; // True if {|} are normal characters. |
190 | | bool HasLegalHalfType; // True if the backend supports operations on the half |
191 | | // LLVM IR type. |
192 | | bool HasFloat128; |
193 | | bool HasFloat16; |
194 | | bool HasBFloat16; |
195 | | bool HasStrictFP; |
196 | | |
197 | | unsigned char MaxAtomicPromoteWidth, MaxAtomicInlineWidth; |
198 | | unsigned short SimdDefaultAlign; |
199 | | std::unique_ptr<llvm::DataLayout> DataLayout; |
200 | | const char *MCountName; |
201 | | unsigned char RegParmMax, SSERegParmMax; |
202 | | TargetCXXABI TheCXXABI; |
203 | | const LangASMap *AddrSpaceMap; |
204 | | const unsigned *GridValues = |
205 | | nullptr; // Array of target-specific GPU grid values that must be |
206 | | // consistent between host RTL (plugin), device RTL, and clang. |
207 | | |
208 | | mutable StringRef PlatformName; |
209 | | mutable VersionTuple PlatformMinVersion; |
210 | | |
211 | | unsigned HasAlignMac68kSupport : 1; |
212 | | unsigned RealTypeUsesObjCFPRet : 3; |
213 | | unsigned ComplexLongDoubleUsesFP2Ret : 1; |
214 | | |
215 | | unsigned HasBuiltinMSVaList : 1; |
216 | | |
217 | | unsigned IsRenderScriptTarget : 1; |
218 | | |
219 | | unsigned HasAArch64SVETypes : 1; |
220 | | |
221 | | unsigned AllowAMDGPUUnsafeFPAtomics : 1; |
222 | | |
223 | | unsigned ARMCDECoprocMask : 8; |
224 | | |
225 | | unsigned MaxOpenCLWorkGroupSize; |
226 | | |
227 | | // TargetInfo Constructor. Default initializes all fields. |
228 | | TargetInfo(const llvm::Triple &T); |
229 | | |
230 | | void resetDataLayout(StringRef DL); |
231 | | |
232 | | public: |
233 | | /// Construct a target for the given options. |
234 | | /// |
235 | | /// \param Opts - The options to use to initialize the target. The target may |
236 | | /// modify the options to canonicalize the target feature information to match |
237 | | /// what the backend expects. |
238 | | static TargetInfo * |
239 | | CreateTargetInfo(DiagnosticsEngine &Diags, |
240 | | const std::shared_ptr<TargetOptions> &Opts); |
241 | | |
242 | | virtual ~TargetInfo(); |
243 | | |
244 | | /// Retrieve the target options. |
245 | 2.43M | TargetOptions &getTargetOpts() const { |
246 | 2.43M | assert(TargetOpts && "Missing target options"); |
247 | 2.43M | return *TargetOpts; |
248 | 2.43M | } |
249 | | |
250 | | /// The different kinds of __builtin_va_list types defined by |
251 | | /// the target implementation. |
252 | | enum BuiltinVaListKind { |
253 | | /// typedef char* __builtin_va_list; |
254 | | CharPtrBuiltinVaList = 0, |
255 | | |
256 | | /// typedef void* __builtin_va_list; |
257 | | VoidPtrBuiltinVaList, |
258 | | |
259 | | /// __builtin_va_list as defined by the AArch64 ABI |
260 | | /// http://infocenter.arm.com/help/topic/com.arm.doc.ihi0055a/IHI0055A_aapcs64.pdf |
261 | | AArch64ABIBuiltinVaList, |
262 | | |
263 | | /// __builtin_va_list as defined by the PNaCl ABI: |
264 | | /// http://www.chromium.org/nativeclient/pnacl/bitcode-abi#TOC-Machine-Types |
265 | | PNaClABIBuiltinVaList, |
266 | | |
267 | | /// __builtin_va_list as defined by the Power ABI: |
268 | | /// https://www.power.org |
269 | | /// /resources/downloads/Power-Arch-32-bit-ABI-supp-1.0-Embedded.pdf |
270 | | PowerABIBuiltinVaList, |
271 | | |
272 | | /// __builtin_va_list as defined by the x86-64 ABI: |
273 | | /// http://refspecs.linuxbase.org/elf/x86_64-abi-0.21.pdf |
274 | | X86_64ABIBuiltinVaList, |
275 | | |
276 | | /// __builtin_va_list as defined by ARM AAPCS ABI |
277 | | /// http://infocenter.arm.com |
278 | | // /help/topic/com.arm.doc.ihi0042d/IHI0042D_aapcs.pdf |
279 | | AAPCSABIBuiltinVaList, |
280 | | |
281 | | // typedef struct __va_list_tag |
282 | | // { |
283 | | // long __gpr; |
284 | | // long __fpr; |
285 | | // void *__overflow_arg_area; |
286 | | // void *__reg_save_area; |
287 | | // } va_list[1]; |
288 | | SystemZBuiltinVaList, |
289 | | |
290 | | // typedef struct __va_list_tag { |
291 | | // void *__current_saved_reg_area_pointer; |
292 | | // void *__saved_reg_area_end_pointer; |
293 | | // void *__overflow_area_pointer; |
294 | | //} va_list; |
295 | | HexagonBuiltinVaList |
296 | | }; |
297 | | |
298 | | protected: |
299 | | /// Specify if mangling based on address space map should be used or |
300 | | /// not for language specific address spaces |
301 | | bool UseAddrSpaceMapMangling; |
302 | | |
303 | | public: |
304 | 3.13M | IntType getSizeType() const { return SizeType; } |
305 | 32 | IntType getSignedSizeType() const { |
306 | 32 | switch (SizeType) { |
307 | 0 | case UnsignedShort: |
308 | 0 | return SignedShort; |
309 | 0 | case UnsignedInt: |
310 | 0 | return SignedInt; |
311 | 32 | case UnsignedLong: |
312 | 32 | return SignedLong; |
313 | 0 | case UnsignedLongLong: |
314 | 0 | return SignedLongLong; |
315 | 0 | default: |
316 | 0 | llvm_unreachable("Invalid SizeType"); |
317 | 32 | } |
318 | 32 | } |
319 | 406k | IntType getIntMaxType() const { return IntMaxType; } |
320 | 406k | IntType getUIntMaxType() const { |
321 | 406k | return getCorrespondingUnsignedType(IntMaxType); |
322 | 406k | } |
323 | 510k | IntType getPtrDiffType(unsigned AddrSpace) const { |
324 | 510k | return AddrSpace == 0 ? PtrDiffType : getPtrDiffTypeV(AddrSpace)0 ; |
325 | 510k | } |
326 | 1.20k | IntType getUnsignedPtrDiffType(unsigned AddrSpace) const { |
327 | 1.20k | return getCorrespondingUnsignedType(getPtrDiffType(AddrSpace)); |
328 | 1.20k | } |
329 | 1.63M | IntType getIntPtrType() const { return IntPtrType; } |
330 | 325k | IntType getUIntPtrType() const { |
331 | 325k | return getCorrespondingUnsignedType(IntPtrType); |
332 | 325k | } |
333 | 510k | IntType getWCharType() const { return WCharType; } |
334 | 492k | IntType getWIntType() const { return WIntType; } |
335 | 99.3k | IntType getChar16Type() const { return Char16Type; } |
336 | 99.3k | IntType getChar32Type() const { return Char32Type; } |
337 | 420k | IntType getInt64Type() const { return Int64Type; } |
338 | 162k | IntType getUInt64Type() const { |
339 | 162k | return getCorrespondingUnsignedType(Int64Type); |
340 | 162k | } |
341 | 162k | IntType getSigAtomicType() const { return SigAtomicType; } |
342 | 172 | IntType getProcessIDType() const { return ProcessIDType; } |
343 | | |
344 | 895k | static IntType getCorrespondingUnsignedType(IntType T) { |
345 | 895k | switch (T) { |
346 | 0 | case SignedChar: |
347 | 0 | return UnsignedChar; |
348 | 0 | case SignedShort: |
349 | 0 | return UnsignedShort; |
350 | 61.1k | case SignedInt: |
351 | 61.1k | return UnsignedInt; |
352 | 540k | case SignedLong: |
353 | 540k | return UnsignedLong; |
354 | 293k | case SignedLongLong: |
355 | 293k | return UnsignedLongLong; |
356 | 0 | default: |
357 | 0 | llvm_unreachable("Unexpected signed integer type"); |
358 | 895k | } |
359 | 895k | } |
360 | | |
361 | | /// In the event this target uses the same number of fractional bits for its |
362 | | /// unsigned types as it does with its signed counterparts, there will be |
363 | | /// exactly one bit of padding. |
364 | | /// Return true if unsigned fixed point types have padding for this target. |
365 | 2.19k | bool doUnsignedFixedPointTypesHavePadding() const { |
366 | 2.19k | return PaddingOnUnsignedFixedPoint; |
367 | 2.19k | } |
368 | | |
369 | | /// Return the width (in bits) of the specified integer type enum. |
370 | | /// |
371 | | /// For example, SignedInt -> getIntWidth(). |
372 | | unsigned getTypeWidth(IntType T) const; |
373 | | |
374 | | /// Return integer type with specified width. |
375 | | virtual IntType getIntTypeByWidth(unsigned BitWidth, bool IsSigned) const; |
376 | | |
377 | | /// Return the smallest integer type with at least the specified width. |
378 | | virtual IntType getLeastIntTypeByWidth(unsigned BitWidth, |
379 | | bool IsSigned) const; |
380 | | |
381 | | /// Return floating point type with specified width. On PPC, there are |
382 | | /// three possible types for 128-bit floating point: "PPC double-double", |
383 | | /// IEEE 754R quad precision, and "long double" (which under the covers |
384 | | /// is represented as one of those two). At this time, there is no support |
385 | | /// for an explicit "PPC double-double" type (i.e. __ibm128) so we only |
386 | | /// need to differentiate between "long double" and IEEE quad precision. |
387 | | RealType getRealTypeByWidth(unsigned BitWidth, bool ExplicitIEEE) const; |
388 | | |
389 | | /// Return the alignment (in bits) of the specified integer type enum. |
390 | | /// |
391 | | /// For example, SignedInt -> getIntAlign(). |
392 | | unsigned getTypeAlign(IntType T) const; |
393 | | |
394 | | /// Returns true if the type is signed; false otherwise. |
395 | | static bool isTypeSigned(IntType T); |
396 | | |
397 | | /// Return the width of pointers on this target, for the |
398 | | /// specified address space. |
399 | 1.62M | uint64_t getPointerWidth(unsigned AddrSpace) const { |
400 | 1.62M | return AddrSpace == 0 ? PointerWidth : getPointerWidthV(AddrSpace)1.00k ; |
401 | 1.62M | } |
402 | 637k | uint64_t getPointerAlign(unsigned AddrSpace) const { |
403 | 636k | return AddrSpace == 0 ? PointerAlign : getPointerAlignV(AddrSpace)918 ; |
404 | 637k | } |
405 | | |
406 | | /// Return the maximum width of pointers on this target. |
407 | 4.74M | virtual uint64_t getMaxPointerWidth() const { |
408 | 4.74M | return PointerWidth; |
409 | 4.74M | } |
410 | | |
411 | | /// Get integer value for null pointer. |
412 | | /// \param AddrSpace address space of pointee in source language. |
413 | 98.2k | virtual uint64_t getNullPointerValue(LangAS AddrSpace) const { return 0; } |
414 | | |
415 | | /// Return the size of '_Bool' and C++ 'bool' for this target, in bits. |
416 | 113k | unsigned getBoolWidth() const { return BoolWidth; } |
417 | | |
418 | | /// Return the alignment of '_Bool' and C++ 'bool' for this target. |
419 | 113k | unsigned getBoolAlign() const { return BoolAlign; } |
420 | | |
421 | 18.1M | unsigned getCharWidth() const { return 8; } // FIXME |
422 | 376k | unsigned getCharAlign() const { return 8; } // FIXME |
423 | | |
424 | | /// Return the size of 'signed short' and 'unsigned short' for this |
425 | | /// target, in bits. |
426 | 4.02M | unsigned getShortWidth() const { return 16; } // FIXME |
427 | | |
428 | | /// Return the alignment of 'signed short' and 'unsigned short' for |
429 | | /// this target. |
430 | 249k | unsigned getShortAlign() const { return 16; } // FIXME |
431 | | |
432 | | /// getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for |
433 | | /// this target, in bits. |
434 | 22.5M | unsigned getIntWidth() const { return IntWidth; } |
435 | 432k | unsigned getIntAlign() const { return IntAlign; } |
436 | | |
437 | | /// getLongWidth/Align - Return the size of 'signed long' and 'unsigned long' |
438 | | /// for this target, in bits. |
439 | 10.2M | unsigned getLongWidth() const { return LongWidth; } |
440 | 186k | unsigned getLongAlign() const { return LongAlign; } |
441 | | |
442 | | /// getLongLongWidth/Align - Return the size of 'signed long long' and |
443 | | /// 'unsigned long long' for this target, in bits. |
444 | 1.68M | unsigned getLongLongWidth() const { return LongLongWidth; } |
445 | 118k | unsigned getLongLongAlign() const { return LongLongAlign; } |
446 | | |
447 | | /// getShortAccumWidth/Align - Return the size of 'signed short _Accum' and |
448 | | /// 'unsigned short _Accum' for this target, in bits. |
449 | 148 | unsigned getShortAccumWidth() const { return ShortAccumWidth; } |
450 | 148 | unsigned getShortAccumAlign() const { return ShortAccumAlign; } |
451 | | |
452 | | /// getAccumWidth/Align - Return the size of 'signed _Accum' and |
453 | | /// 'unsigned _Accum' for this target, in bits. |
454 | 131 | unsigned getAccumWidth() const { return AccumWidth; } |
455 | 131 | unsigned getAccumAlign() const { return AccumAlign; } |
456 | | |
457 | | /// getLongAccumWidth/Align - Return the size of 'signed long _Accum' and |
458 | | /// 'unsigned long _Accum' for this target, in bits. |
459 | 107 | unsigned getLongAccumWidth() const { return LongAccumWidth; } |
460 | 107 | unsigned getLongAccumAlign() const { return LongAccumAlign; } |
461 | | |
462 | | /// getShortFractWidth/Align - Return the size of 'signed short _Fract' and |
463 | | /// 'unsigned short _Fract' for this target, in bits. |
464 | 88 | unsigned getShortFractWidth() const { return ShortFractWidth; } |
465 | 88 | unsigned getShortFractAlign() const { return ShortFractAlign; } |
466 | | |
467 | | /// getFractWidth/Align - Return the size of 'signed _Fract' and |
468 | | /// 'unsigned _Fract' for this target, in bits. |
469 | 124 | unsigned getFractWidth() const { return FractWidth; } |
470 | 124 | unsigned getFractAlign() const { return FractAlign; } |
471 | | |
472 | | /// getLongFractWidth/Align - Return the size of 'signed long _Fract' and |
473 | | /// 'unsigned long _Fract' for this target, in bits. |
474 | 76 | unsigned getLongFractWidth() const { return LongFractWidth; } |
475 | 76 | unsigned getLongFractAlign() const { return LongFractAlign; } |
476 | | |
477 | | /// getShortAccumScale/IBits - Return the number of fractional/integral bits |
478 | | /// in a 'signed short _Accum' type. |
479 | 3.48k | unsigned getShortAccumScale() const { return ShortAccumScale; } |
480 | 754k | unsigned getShortAccumIBits() const { |
481 | 754k | return ShortAccumWidth - ShortAccumScale - 1; |
482 | 754k | } |
483 | | |
484 | | /// getAccumScale/IBits - Return the number of fractional/integral bits |
485 | | /// in a 'signed _Accum' type. |
486 | 1.13k | unsigned getAccumScale() const { return AccumScale; } |
487 | 1.00M | unsigned getAccumIBits() const { return AccumWidth - AccumScale - 1; } |
488 | | |
489 | | /// getLongAccumScale/IBits - Return the number of fractional/integral bits |
490 | | /// in a 'signed long _Accum' type. |
491 | 264 | unsigned getLongAccumScale() const { return LongAccumScale; } |
492 | 754k | unsigned getLongAccumIBits() const { |
493 | 754k | return LongAccumWidth - LongAccumScale - 1; |
494 | 754k | } |
495 | | |
496 | | /// getUnsignedShortAccumScale/IBits - Return the number of |
497 | | /// fractional/integral bits in a 'unsigned short _Accum' type. |
498 | 1.25M | unsigned getUnsignedShortAccumScale() const { |
499 | 1.25M | return PaddingOnUnsignedFixedPoint ? ShortAccumScale812 : ShortAccumScale + 1; |
500 | 1.25M | } |
501 | 754k | unsigned getUnsignedShortAccumIBits() const { |
502 | 754k | return PaddingOnUnsignedFixedPoint |
503 | 126 | ? getShortAccumIBits() |
504 | 754k | : ShortAccumWidth - getUnsignedShortAccumScale(); |
505 | 754k | } |
506 | | |
507 | | /// getUnsignedAccumScale/IBits - Return the number of fractional/integral |
508 | | /// bits in a 'unsigned _Accum' type. |
509 | 1.76M | unsigned getUnsignedAccumScale() const { |
510 | 1.75M | return PaddingOnUnsignedFixedPoint ? AccumScale243 : AccumScale + 1; |
511 | 1.76M | } |
512 | 1.00M | unsigned getUnsignedAccumIBits() const { |
513 | 168 | return PaddingOnUnsignedFixedPoint ? getAccumIBits() |
514 | 1.00M | : AccumWidth - getUnsignedAccumScale(); |
515 | 1.00M | } |
516 | | |
517 | | /// getUnsignedLongAccumScale/IBits - Return the number of fractional/integral |
518 | | /// bits in a 'unsigned long _Accum' type. |
519 | 1.25M | unsigned getUnsignedLongAccumScale() const { |
520 | 1.25M | return PaddingOnUnsignedFixedPoint ? LongAccumScale128 : LongAccumScale + 1; |
521 | 1.25M | } |
522 | 754k | unsigned getUnsignedLongAccumIBits() const { |
523 | 754k | return PaddingOnUnsignedFixedPoint |
524 | 126 | ? getLongAccumIBits() |
525 | 754k | : LongAccumWidth - getUnsignedLongAccumScale(); |
526 | 754k | } |
527 | | |
528 | | /// getShortFractScale - Return the number of fractional bits |
529 | | /// in a 'signed short _Fract' type. |
530 | 2.01M | unsigned getShortFractScale() const { return ShortFractWidth - 1; } |
531 | | |
532 | | /// getFractScale - Return the number of fractional bits |
533 | | /// in a 'signed _Fract' type. |
534 | 2.51M | unsigned getFractScale() const { return FractWidth - 1; } |
535 | | |
536 | | /// getLongFractScale - Return the number of fractional bits |
537 | | /// in a 'signed long _Fract' type. |
538 | 2.01M | unsigned getLongFractScale() const { return LongFractWidth - 1; } |
539 | | |
540 | | /// getUnsignedShortFractScale - Return the number of fractional bits |
541 | | /// in a 'unsigned short _Fract' type. |
542 | 1.00M | unsigned getUnsignedShortFractScale() const { |
543 | 148 | return PaddingOnUnsignedFixedPoint ? getShortFractScale() |
544 | 1.00M | : getShortFractScale() + 1; |
545 | 1.00M | } |
546 | | |
547 | | /// getUnsignedFractScale - Return the number of fractional bits |
548 | | /// in a 'unsigned _Fract' type. |
549 | 1.25M | unsigned getUnsignedFractScale() const { |
550 | 1.25M | return PaddingOnUnsignedFixedPoint ? getFractScale()299 : getFractScale() + 1; |
551 | 1.25M | } |
552 | | |
553 | | /// getUnsignedLongFractScale - Return the number of fractional bits |
554 | | /// in a 'unsigned long _Fract' type. |
555 | 1.00M | unsigned getUnsignedLongFractScale() const { |
556 | 142 | return PaddingOnUnsignedFixedPoint ? getLongFractScale() |
557 | 1.00M | : getLongFractScale() + 1; |
558 | 1.00M | } |
559 | | |
560 | | /// Determine whether the __int128 type is supported on this target. |
561 | 71.0k | virtual bool hasInt128Type() const { |
562 | 71.0k | return (getPointerWidth(0) >= 64) || getTargetOpts().ForceEnableInt12849.3k ; |
563 | 71.0k | } // FIXME |
564 | | |
565 | | /// Determine whether the _ExtInt type is supported on this target. This |
566 | | /// limitation is put into place for ABI reasons. |
567 | 0 | virtual bool hasExtIntType() const { |
568 | 0 | return false; |
569 | 0 | } |
570 | | |
571 | | /// Determine whether _Float16 is supported on this target. |
572 | 12.3k | virtual bool hasLegalHalfType() const { return HasLegalHalfType; } |
573 | | |
574 | | /// Determine whether the __float128 type is supported on this target. |
575 | 61.0k | virtual bool hasFloat128Type() const { return HasFloat128; } |
576 | | |
577 | | /// Determine whether the _Float16 type is supported on this target. |
578 | 90.7k | virtual bool hasFloat16Type() const { return HasFloat16; } |
579 | | |
580 | | /// Determine whether the _BFloat16 type is supported on this target. |
581 | 1.74k | virtual bool hasBFloat16Type() const { return HasBFloat16; } |
582 | | |
583 | | /// Determine whether constrained floating point is supported on this target. |
584 | 57.9k | virtual bool hasStrictFP() const { return HasStrictFP; } |
585 | | |
586 | | /// Return the alignment that is the largest alignment ever used for any |
587 | | /// scalar/SIMD data type on the target machine you are compiling for |
588 | | /// (including types with an extended alignment requirement). |
589 | 81.2k | unsigned getSuitableAlign() const { return SuitableAlign; } |
590 | | |
591 | | /// Return the default alignment for __attribute__((aligned)) on |
592 | | /// this target, to be used if no alignment value is specified. |
593 | 5.37k | unsigned getDefaultAlignForAttributeAligned() const { |
594 | 5.37k | return DefaultAlignForAttributeAligned; |
595 | 5.37k | } |
596 | | |
597 | | /// getMinGlobalAlign - Return the minimum alignment of a global variable, |
598 | | /// unless its alignment is explicitly reduced via attributes. |
599 | 290k | virtual unsigned getMinGlobalAlign (uint64_t) const { |
600 | 290k | return MinGlobalAlign; |
601 | 290k | } |
602 | | |
603 | | /// Return the largest alignment for which a suitably-sized allocation with |
604 | | /// '::operator new(size_t)' is guaranteed to produce a correctly-aligned |
605 | | /// pointer. |
606 | 90.0k | unsigned getNewAlign() const { |
607 | 79.5k | return NewAlign ? NewAlign10.5k : std::max(LongDoubleAlign, LongLongAlign); |
608 | 90.0k | } |
609 | | |
610 | | /// getWCharWidth/Align - Return the size of 'wchar_t' for this target, in |
611 | | /// bits. |
612 | 842k | unsigned getWCharWidth() const { return getTypeWidth(WCharType); } |
613 | 129k | unsigned getWCharAlign() const { return getTypeAlign(WCharType); } |
614 | | |
615 | | /// getChar16Width/Align - Return the size of 'char16_t' for this target, in |
616 | | /// bits. |
617 | 107k | unsigned getChar16Width() const { return getTypeWidth(Char16Type); } |
618 | 107k | unsigned getChar16Align() const { return getTypeAlign(Char16Type); } |
619 | | |
620 | | /// getChar32Width/Align - Return the size of 'char32_t' for this target, in |
621 | | /// bits. |
622 | 107k | unsigned getChar32Width() const { return getTypeWidth(Char32Type); } |
623 | 107k | unsigned getChar32Align() const { return getTypeAlign(Char32Type); } |
624 | | |
625 | | /// getHalfWidth/Align/Format - Return the size/align/format of 'half'. |
626 | 2.12k | unsigned getHalfWidth() const { return HalfWidth; } |
627 | 2.12k | unsigned getHalfAlign() const { return HalfAlign; } |
628 | 8.78k | const llvm::fltSemantics &getHalfFormat() const { return *HalfFormat; } |
629 | | |
630 | | /// getFloatWidth/Align/Format - Return the size/align/format of 'float'. |
631 | 90.0k | unsigned getFloatWidth() const { return FloatWidth; } |
632 | 8.75k | unsigned getFloatAlign() const { return FloatAlign; } |
633 | 185k | const llvm::fltSemantics &getFloatFormat() const { return *FloatFormat; } |
634 | | |
635 | | /// getBFloat16Width/Align/Format - Return the size/align/format of '__bf16'. |
636 | 205 | unsigned getBFloat16Width() const { return BFloat16Width; } |
637 | 205 | unsigned getBFloat16Align() const { return BFloat16Align; } |
638 | 197 | const llvm::fltSemantics &getBFloat16Format() const { return *BFloat16Format; } |
639 | | |
640 | | /// getDoubleWidth/Align/Format - Return the size/align/format of 'double'. |
641 | 89.9k | unsigned getDoubleWidth() const { return DoubleWidth; } |
642 | 8.62k | unsigned getDoubleAlign() const { return DoubleAlign; } |
643 | 190k | const llvm::fltSemantics &getDoubleFormat() const { return *DoubleFormat; } |
644 | | |
645 | | /// getLongDoubleWidth/Align/Format - Return the size/align/format of 'long |
646 | | /// double'. |
647 | 82.7k | unsigned getLongDoubleWidth() const { return LongDoubleWidth; } |
648 | 1.49k | unsigned getLongDoubleAlign() const { return LongDoubleAlign; } |
649 | 102k | const llvm::fltSemantics &getLongDoubleFormat() const { |
650 | 102k | return *LongDoubleFormat; |
651 | 102k | } |
652 | | |
653 | | /// getFloat128Width/Align/Format - Return the size/align/format of |
654 | | /// '__float128'. |
655 | 26 | unsigned getFloat128Width() const { return 128; } |
656 | 26 | unsigned getFloat128Align() const { return Float128Align; } |
657 | 1.28k | const llvm::fltSemantics &getFloat128Format() const { |
658 | 1.28k | return *Float128Format; |
659 | 1.28k | } |
660 | | |
661 | | /// Return the mangled code of long double. |
662 | 2 | virtual const char *getLongDoubleMangling() const { return "e"; } |
663 | | |
664 | | /// Return the mangled code of __float128. |
665 | 214 | virtual const char *getFloat128Mangling() const { return "g"; } |
666 | | |
667 | | /// Return the mangled code of bfloat. |
668 | 0 | virtual const char *getBFloat16Mangling() const { |
669 | 0 | llvm_unreachable("bfloat not implemented on this target"); |
670 | 0 | } |
671 | | |
672 | | /// Return the value for the C99 FLT_EVAL_METHOD macro. |
673 | 9.28k | virtual unsigned getFloatEvalMethod() const { return 0; } |
674 | | |
675 | | // getLargeArrayMinWidth/Align - Return the minimum array size that is |
676 | | // 'large' and its alignment. |
677 | 27.9k | unsigned getLargeArrayMinWidth() const { return LargeArrayMinWidth; } |
678 | 4.17k | unsigned getLargeArrayAlign() const { return LargeArrayAlign; } |
679 | | |
680 | | /// Return the maximum width lock-free atomic operation which will |
681 | | /// ever be supported for the given target |
682 | 1.25k | unsigned getMaxAtomicPromoteWidth() const { return MaxAtomicPromoteWidth; } |
683 | | /// Return the maximum width lock-free atomic operation which can be |
684 | | /// inlined given the supported features of the given target. |
685 | 110k | unsigned getMaxAtomicInlineWidth() const { return MaxAtomicInlineWidth; } |
686 | | /// Set the maximum inline or promote width lock-free atomic operation |
687 | | /// for the given target. |
688 | 9.33k | virtual void setMaxAtomicWidth() {} |
689 | | /// Returns true if the given target supports lock-free atomic |
690 | | /// operations at the specified width and alignment. |
691 | | virtual bool hasBuiltinAtomic(uint64_t AtomicSizeInBits, |
692 | 2.26k | uint64_t AlignmentInBits) const { |
693 | 2.26k | return AtomicSizeInBits <= AlignmentInBits && |
694 | 2.07k | AtomicSizeInBits <= getMaxAtomicInlineWidth() && |
695 | 1.87k | (AtomicSizeInBits <= getCharWidth() || |
696 | 1.69k | llvm::isPowerOf2_64(AtomicSizeInBits / getCharWidth())); |
697 | 2.26k | } |
698 | | |
699 | | /// Return the maximum vector alignment supported for the given target. |
700 | 24.6k | unsigned getMaxVectorAlign() const { return MaxVectorAlign; } |
701 | | /// Return default simd alignment for the given target. Generally, this |
702 | | /// value is type-specific, but this alignment can be used for most of the |
703 | | /// types for the given target. |
704 | 356 | unsigned getSimdDefaultAlign() const { return SimdDefaultAlign; } |
705 | | |
706 | 6 | unsigned getMaxOpenCLWorkGroupSize() const { return MaxOpenCLWorkGroupSize; } |
707 | | |
708 | | /// Return the alignment (in bits) of the thrown exception object. This is |
709 | | /// only meaningful for targets that allocate C++ exceptions in a system |
710 | | /// runtime, such as those using the Itanium C++ ABI. |
711 | 5.19k | virtual unsigned getExnObjectAlignment() const { |
712 | | // Itanium says that an _Unwind_Exception has to be "double-word" |
713 | | // aligned (and thus the end of it is also so-aligned), meaning 16 |
714 | | // bytes. Of course, that was written for the actual Itanium, |
715 | | // which is a 64-bit platform. Classically, the ABI doesn't really |
716 | | // specify the alignment on other platforms, but in practice |
717 | | // libUnwind declares the struct with __attribute__((aligned)), so |
718 | | // we assume that alignment here. (It's generally 16 bytes, but |
719 | | // some targets overwrite it.) |
720 | 5.19k | return getDefaultAlignForAttributeAligned(); |
721 | 5.19k | } |
722 | | |
723 | | /// Return the size of intmax_t and uintmax_t for this target, in bits. |
724 | 6.89M | unsigned getIntMaxTWidth() const { |
725 | 6.89M | return getTypeWidth(IntMaxType); |
726 | 6.89M | } |
727 | | |
728 | | // Return the size of unwind_word for this target. |
729 | 11 | virtual unsigned getUnwindWordWidth() const { return getPointerWidth(0); } |
730 | | |
731 | | /// Return the "preferred" register width on this target. |
732 | 0 | virtual unsigned getRegisterWidth() const { |
733 | | // Currently we assume the register width on the target matches the pointer |
734 | | // width, we can introduce a new variable for this if/when some target wants |
735 | | // it. |
736 | 0 | return PointerWidth; |
737 | 0 | } |
738 | | |
739 | | /// Returns the name of the mcount instrumentation function. |
740 | 92 | const char *getMCountName() const { |
741 | 92 | return MCountName; |
742 | 92 | } |
743 | | |
744 | | /// Check if the Objective-C built-in boolean type should be signed |
745 | | /// char. |
746 | | /// |
747 | | /// Otherwise, if this returns false, the normal built-in boolean type |
748 | | /// should also be used for Objective-C. |
749 | 167k | bool useSignedCharForObjCBool() const { |
750 | 167k | return UseSignedCharForObjCBool; |
751 | 167k | } |
752 | 164 | void noSignedCharForObjCBool() { |
753 | 164 | UseSignedCharForObjCBool = false; |
754 | 164 | } |
755 | | |
756 | | /// Check whether the alignment of bit-field types is respected |
757 | | /// when laying out structures. |
758 | 18.7k | bool useBitFieldTypeAlignment() const { |
759 | 18.7k | return UseBitFieldTypeAlignment; |
760 | 18.7k | } |
761 | | |
762 | | /// Check whether zero length bitfields should force alignment of |
763 | | /// the next member. |
764 | 18.8k | bool useZeroLengthBitfieldAlignment() const { |
765 | 18.8k | return UseZeroLengthBitfieldAlignment; |
766 | 18.8k | } |
767 | | |
768 | | /// Get the fixed alignment value in bits for a member that follows |
769 | | /// a zero length bitfield. |
770 | 170 | unsigned getZeroLengthBitfieldBoundary() const { |
771 | 170 | return ZeroLengthBitfieldBoundary; |
772 | 170 | } |
773 | | |
774 | | /// Check whether explicit bitfield alignment attributes should be |
775 | | // honored, as in "__attribute__((aligned(2))) int b : 1;". |
776 | 350 | bool useExplicitBitFieldAlignment() const { |
777 | 350 | return UseExplicitBitFieldAlignment; |
778 | 350 | } |
779 | | |
780 | | /// Check whether this target support '\#pragma options align=mac68k'. |
781 | 9 | bool hasAlignMac68kSupport() const { |
782 | 9 | return HasAlignMac68kSupport; |
783 | 9 | } |
784 | | |
785 | | /// Return the user string for the specified integer type enum. |
786 | | /// |
787 | | /// For example, SignedShort -> "short". |
788 | | static const char *getTypeName(IntType T); |
789 | | |
790 | | /// Return the constant suffix for the specified integer type enum. |
791 | | /// |
792 | | /// For example, SignedLong -> "L". |
793 | | const char *getTypeConstantSuffix(IntType T) const; |
794 | | |
795 | | /// Return the printf format modifier for the specified |
796 | | /// integer type enum. |
797 | | /// |
798 | | /// For example, SignedLong -> "l". |
799 | | static const char *getTypeFormatModifier(IntType T); |
800 | | |
801 | | /// Check whether the given real type should use the "fpret" flavor of |
802 | | /// Objective-C message passing on this target. |
803 | 68 | bool useObjCFPRetForRealType(RealType T) const { |
804 | 68 | return RealTypeUsesObjCFPRet & (1 << T); |
805 | 68 | } |
806 | | |
807 | | /// Check whether _Complex long double should use the "fp2ret" flavor |
808 | | /// of Objective-C message passing on this target. |
809 | 2 | bool useObjCFP2RetForComplexLongDouble() const { |
810 | 2 | return ComplexLongDoubleUsesFP2Ret; |
811 | 2 | } |
812 | | |
813 | | /// Check whether llvm intrinsics such as llvm.convert.to.fp16 should be used |
814 | | /// to convert to and from __fp16. |
815 | | /// FIXME: This function should be removed once all targets stop using the |
816 | | /// conversion intrinsics. |
817 | 233k | virtual bool useFP16ConversionIntrinsics() const { |
818 | 233k | return true; |
819 | 233k | } |
820 | | |
821 | | /// Specify if mangling based on address space map should be used or |
822 | | /// not for language specific address spaces |
823 | 86.5k | bool useAddressSpaceMapMangling() const { |
824 | 86.5k | return UseAddrSpaceMapMangling; |
825 | 86.5k | } |
826 | | |
827 | | ///===---- Other target property query methods --------------------------===// |
828 | | |
829 | | /// Appends the target-specific \#define values for this |
830 | | /// target set to the specified buffer. |
831 | | virtual void getTargetDefines(const LangOptions &Opts, |
832 | | MacroBuilder &Builder) const = 0; |
833 | | |
834 | | |
835 | | /// Return information about target-specific builtins for |
836 | | /// the current primary target, and info about which builtins are non-portable |
837 | | /// across the current set of primary and secondary targets. |
838 | | virtual ArrayRef<Builtin::Info> getTargetBuiltins() const = 0; |
839 | | |
840 | | /// The __builtin_clz* and __builtin_ctz* built-in |
841 | | /// functions are specified to have undefined results for zero inputs, but |
842 | | /// on targets that support these operations in a way that provides |
843 | | /// well-defined results for zero without loss of performance, it is a good |
844 | | /// idea to avoid optimizing based on that undef behavior. |
845 | 71 | virtual bool isCLZForZeroUndef() const { return true; } |
846 | | |
847 | | /// Returns the kind of __builtin_va_list type that should be used |
848 | | /// with this target. |
849 | | virtual BuiltinVaListKind getBuiltinVaListKind() const = 0; |
850 | | |
851 | | /// Returns whether or not type \c __builtin_ms_va_list type is |
852 | | /// available on this target. |
853 | 79.8k | bool hasBuiltinMSVaList() const { return HasBuiltinMSVaList; } |
854 | | |
855 | | /// Returns true for RenderScript. |
856 | 721 | bool isRenderScriptTarget() const { return IsRenderScriptTarget; } |
857 | | |
858 | | /// Returns whether or not the AArch64 SVE built-in types are |
859 | | /// available on this target. |
860 | 1.21M | bool hasAArch64SVETypes() const { return HasAArch64SVETypes; } |
861 | | |
862 | | /// Returns whether or not the AMDGPU unsafe floating point atomics are |
863 | | /// allowed. |
864 | 1.39k | bool allowAMDGPUUnsafeFPAtomics() const { return AllowAMDGPUUnsafeFPAtomics; } |
865 | | |
866 | | /// For ARM targets returns a mask defining which coprocessors are configured |
867 | | /// as Custom Datapath. |
868 | 1.34k | uint32_t getARMCDECoprocMask() const { return ARMCDECoprocMask; } |
869 | | |
870 | | /// Returns whether the passed in string is a valid clobber in an |
871 | | /// inline asm statement. |
872 | | /// |
873 | | /// This is used by Sema. |
874 | | bool isValidClobber(StringRef Name) const; |
875 | | |
876 | | /// Returns whether the passed in string is a valid register name |
877 | | /// according to GCC. |
878 | | /// |
879 | | /// This is used by Sema for inline asm statements. |
880 | | virtual bool isValidGCCRegisterName(StringRef Name) const; |
881 | | |
882 | | /// Returns the "normalized" GCC register name. |
883 | | /// |
884 | | /// ReturnCannonical true will return the register name without any additions |
885 | | /// such as "{}" or "%" in it's canonical form, for example: |
886 | | /// ReturnCanonical = true and Name = "rax", will return "ax". |
887 | | StringRef getNormalizedGCCRegisterName(StringRef Name, |
888 | | bool ReturnCanonical = false) const; |
889 | | |
890 | 0 | virtual bool isSPRegName(StringRef) const { return false; } |
891 | | |
892 | | /// Extracts a register from the passed constraint (if it is a |
893 | | /// single-register constraint) and the asm label expression related to a |
894 | | /// variable in the input or output list of an inline asm statement. |
895 | | /// |
896 | | /// This function is used by Sema in order to diagnose conflicts between |
897 | | /// the clobber list and the input/output lists. |
898 | | virtual StringRef getConstraintRegister(StringRef Constraint, |
899 | 7.69k | StringRef Expression) const { |
900 | 7.69k | return ""; |
901 | 7.69k | } |
902 | | |
903 | | struct ConstraintInfo { |
904 | | enum { |
905 | | CI_None = 0x00, |
906 | | CI_AllowsMemory = 0x01, |
907 | | CI_AllowsRegister = 0x02, |
908 | | CI_ReadWrite = 0x04, // "+r" output constraint (read and write). |
909 | | CI_HasMatchingInput = 0x08, // This output operand has a matching input. |
910 | | CI_ImmediateConstant = 0x10, // This operand must be an immediate constant |
911 | | CI_EarlyClobber = 0x20, // "&" output constraint (early clobber). |
912 | | }; |
913 | | unsigned Flags; |
914 | | int TiedOperand; |
915 | | struct { |
916 | | int Min; |
917 | | int Max; |
918 | | bool isConstrained; |
919 | | } ImmRange; |
920 | | llvm::SmallSet<int, 4> ImmSet; |
921 | | |
922 | | std::string ConstraintStr; // constraint: "=rm" |
923 | | std::string Name; // Operand name: [foo] with no []'s. |
924 | | public: |
925 | | ConstraintInfo(StringRef ConstraintStr, StringRef Name) |
926 | | : Flags(0), TiedOperand(-1), ConstraintStr(ConstraintStr.str()), |
927 | 22.5k | Name(Name.str()) { |
928 | 22.5k | ImmRange.Min = ImmRange.Max = 0; |
929 | 22.5k | ImmRange.isConstrained = false; |
930 | 22.5k | } |
931 | | |
932 | 28.5k | const std::string &getConstraintStr() const { return ConstraintStr; } |
933 | 182 | const std::string &getName() const { return Name; } |
934 | 1.42k | bool isReadWrite() const { return (Flags & CI_ReadWrite) != 0; } |
935 | 10.1k | bool earlyClobber() { return (Flags & CI_EarlyClobber) != 0; } |
936 | 25.5k | bool allowsRegister() const { return (Flags & CI_AllowsRegister) != 0; } |
937 | 43.7k | bool allowsMemory() const { return (Flags & CI_AllowsMemory) != 0; } |
938 | | |
939 | | /// Return true if this output operand has a matching |
940 | | /// (tied) input operand. |
941 | 975 | bool hasMatchingInput() const { return (Flags & CI_HasMatchingInput) != 0; } |
942 | | |
943 | | /// Return true if this input operand is a matching |
944 | | /// constraint that ties it to an output operand. |
945 | | /// |
946 | | /// If this returns true then getTiedOperand will indicate which output |
947 | | /// operand this is tied to. |
948 | 13.6k | bool hasTiedOperand() const { return TiedOperand != -1; } |
949 | 239 | unsigned getTiedOperand() const { |
950 | 239 | assert(hasTiedOperand() && "Has no tied operand!"); |
951 | 239 | return (unsigned)TiedOperand; |
952 | 239 | } |
953 | | |
954 | 11.7k | bool requiresImmediateConstant() const { |
955 | 11.7k | return (Flags & CI_ImmediateConstant) != 0; |
956 | 11.7k | } |
957 | 233 | bool isValidAsmImmediate(const llvm::APInt &Value) const { |
958 | 233 | if (!ImmSet.empty()) |
959 | 30 | return Value.isSignedIntN(32) && |
960 | 28 | ImmSet.count(Value.getZExtValue()) != 0; |
961 | 203 | return !ImmRange.isConstrained || |
962 | 134 | (Value.sge(ImmRange.Min) && Value.sle(ImmRange.Max)105 ); |
963 | 203 | } |
964 | | |
965 | 666 | void setIsReadWrite() { Flags |= CI_ReadWrite; } |
966 | 38 | void setEarlyClobber() { Flags |= CI_EarlyClobber; } |
967 | 1.74k | void setAllowsMemory() { Flags |= CI_AllowsMemory; } |
968 | 21.6k | void setAllowsRegister() { Flags |= CI_AllowsRegister; } |
969 | 229 | void setHasMatchingInput() { Flags |= CI_HasMatchingInput; } |
970 | 186 | void setRequiresImmediate(int Min, int Max) { |
971 | 186 | Flags |= CI_ImmediateConstant; |
972 | 186 | ImmRange.Min = Min; |
973 | 186 | ImmRange.Max = Max; |
974 | 186 | ImmRange.isConstrained = true; |
975 | 186 | } |
976 | 32 | void setRequiresImmediate(llvm::ArrayRef<int> Exacts) { |
977 | 32 | Flags |= CI_ImmediateConstant; |
978 | 32 | for (int Exact : Exacts) |
979 | 96 | ImmSet.insert(Exact); |
980 | 32 | } |
981 | 14 | void setRequiresImmediate(int Exact) { |
982 | 14 | Flags |= CI_ImmediateConstant; |
983 | 14 | ImmSet.insert(Exact); |
984 | 14 | } |
985 | 138 | void setRequiresImmediate() { |
986 | 138 | Flags |= CI_ImmediateConstant; |
987 | 138 | } |
988 | | |
989 | | /// Indicate that this is an input operand that is tied to |
990 | | /// the specified output operand. |
991 | | /// |
992 | | /// Copy over the various constraint information from the output. |
993 | 229 | void setTiedOperand(unsigned N, ConstraintInfo &Output) { |
994 | 229 | Output.setHasMatchingInput(); |
995 | 229 | Flags = Output.Flags; |
996 | 229 | TiedOperand = N; |
997 | | // Don't copy Name or constraint string. |
998 | 229 | } |
999 | | }; |
1000 | | |
1001 | | /// Validate register name used for global register variables. |
1002 | | /// |
1003 | | /// This function returns true if the register passed in RegName can be used |
1004 | | /// for global register variables on this target. In addition, it returns |
1005 | | /// true in HasSizeMismatch if the size of the register doesn't match the |
1006 | | /// variable size passed in RegSize. |
1007 | | virtual bool validateGlobalRegisterVariable(StringRef RegName, |
1008 | | unsigned RegSize, |
1009 | 5 | bool &HasSizeMismatch) const { |
1010 | 5 | HasSizeMismatch = false; |
1011 | 5 | return true; |
1012 | 5 | } |
1013 | | |
1014 | | // validateOutputConstraint, validateInputConstraint - Checks that |
1015 | | // a constraint is valid and provides information about it. |
1016 | | // FIXME: These should return a real error instead of just true/false. |
1017 | | bool validateOutputConstraint(ConstraintInfo &Info) const; |
1018 | | bool validateInputConstraint(MutableArrayRef<ConstraintInfo> OutputConstraints, |
1019 | | ConstraintInfo &info) const; |
1020 | | |
1021 | | virtual bool validateOutputSize(const llvm::StringMap<bool> &FeatureMap, |
1022 | | StringRef /*Constraint*/, |
1023 | 2.54k | unsigned /*Size*/) const { |
1024 | 2.54k | return true; |
1025 | 2.54k | } |
1026 | | |
1027 | | virtual bool validateInputSize(const llvm::StringMap<bool> &FeatureMap, |
1028 | | StringRef /*Constraint*/, |
1029 | 5.94k | unsigned /*Size*/) const { |
1030 | 5.94k | return true; |
1031 | 5.94k | } |
1032 | | virtual bool |
1033 | | validateConstraintModifier(StringRef /*Constraint*/, |
1034 | | char /*Modifier*/, |
1035 | | unsigned /*Size*/, |
1036 | 9.66k | std::string &/*SuggestedModifier*/) const { |
1037 | 9.66k | return true; |
1038 | 9.66k | } |
1039 | | virtual bool |
1040 | | validateAsmConstraint(const char *&Name, |
1041 | | TargetInfo::ConstraintInfo &info) const = 0; |
1042 | | |
1043 | | bool resolveSymbolicName(const char *&Name, |
1044 | | ArrayRef<ConstraintInfo> OutputConstraints, |
1045 | | unsigned &Index) const; |
1046 | | |
1047 | | // Constraint parm will be left pointing at the last character of |
1048 | | // the constraint. In practice, it won't be changed unless the |
1049 | | // constraint is longer than one character. |
1050 | 1.27k | virtual std::string convertConstraint(const char *&Constraint) const { |
1051 | | // 'p' defaults to 'r', but can be overridden by targets. |
1052 | 1.27k | if (*Constraint == 'p') |
1053 | 15 | return std::string("r"); |
1054 | 1.26k | return std::string(1, *Constraint); |
1055 | 1.26k | } |
1056 | | |
1057 | | /// Returns a string of target-specific clobbers, in LLVM format. |
1058 | | virtual const char *getClobbers() const = 0; |
1059 | | |
1060 | | /// Returns true if NaN encoding is IEEE 754-2008. |
1061 | | /// Only MIPS allows a different encoding. |
1062 | 2.76k | virtual bool isNan2008() const { |
1063 | 2.76k | return true; |
1064 | 2.76k | } |
1065 | | |
1066 | | /// Returns the target triple of the primary target. |
1067 | 190M | const llvm::Triple &getTriple() const { |
1068 | 190M | return Triple; |
1069 | 190M | } |
1070 | | |
1071 | | /// Returns the target ID if supported. |
1072 | 0 | virtual llvm::Optional<std::string> getTargetID() const { return llvm::None; } |
1073 | | |
1074 | 140k | const llvm::DataLayout &getDataLayout() const { |
1075 | 140k | assert(DataLayout && "Uninitialized DataLayout!"); |
1076 | 140k | return *DataLayout; |
1077 | 140k | } |
1078 | | |
1079 | | struct GCCRegAlias { |
1080 | | const char * const Aliases[5]; |
1081 | | const char * const Register; |
1082 | | }; |
1083 | | |
1084 | | struct AddlRegName { |
1085 | | const char * const Names[5]; |
1086 | | const unsigned RegNum; |
1087 | | }; |
1088 | | |
1089 | | /// Does this target support "protected" visibility? |
1090 | | /// |
1091 | | /// Any target which dynamic libraries will naturally support |
1092 | | /// something like "default" (meaning that the symbol is visible |
1093 | | /// outside this shared object) and "hidden" (meaning that it isn't) |
1094 | | /// visibilities, but "protected" is really an ELF-specific concept |
1095 | | /// with weird semantics designed around the convenience of dynamic |
1096 | | /// linker implementations. Which is not to suggest that there's |
1097 | | /// consistent target-independent semantics for "default" visibility |
1098 | | /// either; the entire thing is pretty badly mangled. |
1099 | 65 | virtual bool hasProtectedVisibility() const { return true; } |
1100 | | |
1101 | | /// Does this target aim for semantic compatibility with |
1102 | | /// Microsoft C++ code using dllimport/export attributes? |
1103 | 1.67M | virtual bool shouldDLLImportComdatSymbols() const { |
1104 | 1.67M | return getTriple().isWindowsMSVCEnvironment() || |
1105 | 1.64M | getTriple().isWindowsItaniumEnvironment() || getTriple().isPS4CPU()1.64M ; |
1106 | 1.67M | } |
1107 | | |
1108 | | /// An optional hook that targets can implement to perform semantic |
1109 | | /// checking on attribute((section("foo"))) specifiers. |
1110 | | /// |
1111 | | /// In this case, "foo" is passed in to be checked. If the section |
1112 | | /// specifier is invalid, the backend should return a non-empty string |
1113 | | /// that indicates the problem. |
1114 | | /// |
1115 | | /// This hook is a simple quality of implementation feature to catch errors |
1116 | | /// and give good diagnostics in cases when the assembler or code generator |
1117 | | /// would otherwise reject the section specifier. |
1118 | | /// |
1119 | 299 | virtual std::string isValidSectionSpecifier(StringRef SR) const { |
1120 | 299 | return ""; |
1121 | 299 | } |
1122 | | |
1123 | | /// Set forced language options. |
1124 | | /// |
1125 | | /// Apply changes to the target information with respect to certain |
1126 | | /// language options which change the target configuration and adjust |
1127 | | /// the language based on the target options where applicable. |
1128 | | virtual void adjust(LangOptions &Opts); |
1129 | | |
1130 | | /// Adjust target options based on codegen options. |
1131 | | virtual void adjustTargetOptions(const CodeGenOptions &CGOpts, |
1132 | 57.5k | TargetOptions &TargetOpts) const {} |
1133 | | |
1134 | | /// Initialize the map with the default set of target features for the |
1135 | | /// CPU this should include all legal feature strings on the target. |
1136 | | /// |
1137 | | /// \return False on error (invalid features). |
1138 | | virtual bool initFeatureMap(llvm::StringMap<bool> &Features, |
1139 | | DiagnosticsEngine &Diags, StringRef CPU, |
1140 | | const std::vector<std::string> &FeatureVec) const; |
1141 | | |
1142 | | /// Get the ABI currently in use. |
1143 | 1.06k | virtual StringRef getABI() const { return StringRef(); } |
1144 | | |
1145 | | /// Get the C++ ABI currently in use. |
1146 | 19.9M | TargetCXXABI getCXXABI() const { |
1147 | 19.9M | return TheCXXABI; |
1148 | 19.9M | } |
1149 | | |
1150 | | /// Target the specified CPU. |
1151 | | /// |
1152 | | /// \return False on error (invalid CPU name). |
1153 | 0 | virtual bool setCPU(const std::string &Name) { |
1154 | 0 | return false; |
1155 | 0 | } |
1156 | | |
1157 | | /// Fill a SmallVectorImpl with the valid values to setCPU. |
1158 | 0 | virtual void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const {} |
1159 | | |
1160 | | /// Fill a SmallVectorImpl with the valid values for tuning CPU. |
1161 | 1 | virtual void fillValidTuneCPUList(SmallVectorImpl<StringRef> &Values) const { |
1162 | 1 | fillValidCPUList(Values); |
1163 | 1 | } |
1164 | | |
1165 | | /// brief Determine whether this TargetInfo supports the given CPU name. |
1166 | 0 | virtual bool isValidCPUName(StringRef Name) const { |
1167 | 0 | return true; |
1168 | 0 | } |
1169 | | |
1170 | | /// brief Determine whether this TargetInfo supports the given CPU name for |
1171 | | // tuning. |
1172 | 1 | virtual bool isValidTuneCPUName(StringRef Name) const { |
1173 | 1 | return isValidCPUName(Name); |
1174 | 1 | } |
1175 | | |
1176 | | /// brief Determine whether this TargetInfo supports tune in target attribute. |
1177 | 725 | virtual bool supportsTargetAttributeTune() const { |
1178 | 725 | return false; |
1179 | 725 | } |
1180 | | |
1181 | | /// Use the specified ABI. |
1182 | | /// |
1183 | | /// \return False on error (invalid ABI name). |
1184 | 0 | virtual bool setABI(const std::string &Name) { |
1185 | 0 | return false; |
1186 | 0 | } |
1187 | | |
1188 | | /// Use the specified unit for FP math. |
1189 | | /// |
1190 | | /// \return False on error (invalid unit name). |
1191 | 0 | virtual bool setFPMath(StringRef Name) { |
1192 | 0 | return false; |
1193 | 0 | } |
1194 | | |
1195 | | /// Enable or disable a specific target feature; |
1196 | | /// the feature name must be valid. |
1197 | | virtual void setFeatureEnabled(llvm::StringMap<bool> &Features, |
1198 | | StringRef Name, |
1199 | 12.0k | bool Enabled) const { |
1200 | 12.0k | Features[Name] = Enabled; |
1201 | 12.0k | } |
1202 | | |
1203 | | /// Determine whether this TargetInfo supports the given feature. |
1204 | 682 | virtual bool isValidFeatureName(StringRef Feature) const { |
1205 | 682 | return true; |
1206 | 682 | } |
1207 | | |
1208 | | struct BranchProtectionInfo { |
1209 | | LangOptions::SignReturnAddressScopeKind SignReturnAddr = |
1210 | | LangOptions::SignReturnAddressScopeKind::None; |
1211 | | LangOptions::SignReturnAddressKeyKind SignKey = |
1212 | | LangOptions::SignReturnAddressKeyKind::AKey; |
1213 | | bool BranchTargetEnforcement = false; |
1214 | | }; |
1215 | | |
1216 | | /// Determine if this TargetInfo supports the given branch protection |
1217 | | /// specification |
1218 | | virtual bool validateBranchProtection(StringRef Spec, |
1219 | | BranchProtectionInfo &BPI, |
1220 | 1 | StringRef &Err) const { |
1221 | 1 | Err = ""; |
1222 | 1 | return false; |
1223 | 1 | } |
1224 | | |
1225 | | /// Perform initialization based on the user configured |
1226 | | /// set of features (e.g., +sse4). |
1227 | | /// |
1228 | | /// The list is guaranteed to have at most one entry per feature. |
1229 | | /// |
1230 | | /// The target may modify the features list, to change which options are |
1231 | | /// passed onwards to the backend. |
1232 | | /// FIXME: This part should be fixed so that we can change handleTargetFeatures |
1233 | | /// to merely a TargetInfo initialization routine. |
1234 | | /// |
1235 | | /// \return False on error. |
1236 | | virtual bool handleTargetFeatures(std::vector<std::string> &Features, |
1237 | 755 | DiagnosticsEngine &Diags) { |
1238 | 755 | return true; |
1239 | 755 | } |
1240 | | |
1241 | | /// Determine whether the given target has the given feature. |
1242 | 38 | virtual bool hasFeature(StringRef Feature) const { |
1243 | 38 | return false; |
1244 | 38 | } |
1245 | | |
1246 | | /// Identify whether this target supports multiversioning of functions, |
1247 | | /// which requires support for cpu_supports and cpu_is functionality. |
1248 | 419 | bool supportsMultiVersioning() const { return getTriple().isX86(); } |
1249 | | |
1250 | | /// Identify whether this target supports IFuncs. |
1251 | 344 | bool supportsIFunc() const { return getTriple().isOSBinFormatELF(); } |
1252 | | |
1253 | | // Validate the contents of the __builtin_cpu_supports(const char*) |
1254 | | // argument. |
1255 | 0 | virtual bool validateCpuSupports(StringRef Name) const { return false; } |
1256 | | |
1257 | | // Return the target-specific priority for features/cpus/vendors so |
1258 | | // that they can be properly sorted for checking. |
1259 | 0 | virtual unsigned multiVersionSortPriority(StringRef Name) const { |
1260 | 0 | return 0; |
1261 | 0 | } |
1262 | | |
1263 | | // Validate the contents of the __builtin_cpu_is(const char*) |
1264 | | // argument. |
1265 | 0 | virtual bool validateCpuIs(StringRef Name) const { return false; } |
1266 | | |
1267 | | // Validate a cpu_dispatch/cpu_specific CPU option, which is a different list |
1268 | | // from cpu_is, since it checks via features rather than CPUs directly. |
1269 | 0 | virtual bool validateCPUSpecificCPUDispatch(StringRef Name) const { |
1270 | 0 | return false; |
1271 | 0 | } |
1272 | | |
1273 | | // Get the character to be added for mangling purposes for cpu_specific. |
1274 | 0 | virtual char CPUSpecificManglingCharacter(StringRef Name) const { |
1275 | 0 | llvm_unreachable( |
1276 | 0 | "cpu_specific Multiversioning not implemented on this target"); |
1277 | 0 | } |
1278 | | |
1279 | | // Get a list of the features that make up the CPU option for |
1280 | | // cpu_specific/cpu_dispatch so that it can be passed to llvm as optimization |
1281 | | // options. |
1282 | | virtual void getCPUSpecificCPUDispatchFeatures( |
1283 | 0 | StringRef Name, llvm::SmallVectorImpl<StringRef> &Features) const { |
1284 | 0 | llvm_unreachable( |
1285 | 0 | "cpu_specific Multiversioning not implemented on this target"); |
1286 | 0 | } |
1287 | | |
1288 | | // Get the cache line size of a given cpu. This method switches over |
1289 | | // the given cpu and returns "None" if the CPU is not found. |
1290 | 0 | virtual Optional<unsigned> getCPUCacheLineSize() const { return None; } |
1291 | | |
1292 | | // Returns maximal number of args passed in registers. |
1293 | 150 | unsigned getRegParmMax() const { |
1294 | 150 | assert(RegParmMax < 7 && "RegParmMax value is larger than AST can handle"); |
1295 | 150 | return RegParmMax; |
1296 | 150 | } |
1297 | | |
1298 | | /// Whether the target supports thread-local storage. |
1299 | 3.64M | bool isTLSSupported() const { |
1300 | 3.64M | return TLSSupported; |
1301 | 3.64M | } |
1302 | | |
1303 | | /// Return the maximum alignment (in bits) of a TLS variable |
1304 | | /// |
1305 | | /// Gets the maximum alignment (in bits) of a TLS variable on this target. |
1306 | | /// Returns zero if there is no such constraint. |
1307 | 2.71M | unsigned getMaxTLSAlign() const { return MaxTLSAlign; } |
1308 | | |
1309 | | /// Whether target supports variable-length arrays. |
1310 | 5.85k | bool isVLASupported() const { return VLASupported; } |
1311 | | |
1312 | | /// Whether the target supports SEH __try. |
1313 | 267 | bool isSEHTrySupported() const { |
1314 | 267 | return getTriple().isOSWindows() && |
1315 | 267 | (getTriple().isX86() || |
1316 | 25 | getTriple().getArch() == llvm::Triple::aarch64); |
1317 | 267 | } |
1318 | | |
1319 | | /// Return true if {|} are normal characters in the asm string. |
1320 | | /// |
1321 | | /// If this returns false (the default), then {abc|xyz} is syntax |
1322 | | /// that says that when compiling for asm variant #0, "abc" should be |
1323 | | /// generated, but when compiling for asm variant #1, "xyz" should be |
1324 | | /// generated. |
1325 | 7.06k | bool hasNoAsmVariants() const { |
1326 | 7.06k | return NoAsmVariants; |
1327 | 7.06k | } |
1328 | | |
1329 | | /// Return the register number that __builtin_eh_return_regno would |
1330 | | /// return with the specified argument. |
1331 | | /// This corresponds with TargetLowering's getExceptionPointerRegister |
1332 | | /// and getExceptionSelectorRegister in the backend. |
1333 | 0 | virtual int getEHDataRegisterNumber(unsigned RegNo) const { |
1334 | 0 | return -1; |
1335 | 0 | } |
1336 | | |
1337 | | /// Return the section to use for C++ static initialization functions. |
1338 | 7.94k | virtual const char *getStaticInitSectionSpecifier() const { |
1339 | 7.94k | return nullptr; |
1340 | 7.94k | } |
1341 | | |
1342 | 86.5k | const LangASMap &getAddressSpaceMap() const { return *AddrSpaceMap; } |
1343 | | |
1344 | | /// Map from the address space field in builtin description strings to the |
1345 | | /// language address space. |
1346 | 0 | virtual LangAS getOpenCLBuiltinAddressSpace(unsigned AS) const { |
1347 | 0 | return getLangASFromTargetAS(AS); |
1348 | 0 | } |
1349 | | |
1350 | | /// Map from the address space field in builtin description strings to the |
1351 | | /// language address space. |
1352 | 0 | virtual LangAS getCUDABuiltinAddressSpace(unsigned AS) const { |
1353 | 0 | return getLangASFromTargetAS(AS); |
1354 | 0 | } |
1355 | | |
1356 | | /// Return an AST address space which can be used opportunistically |
1357 | | /// for constant global memory. It must be possible to convert pointers into |
1358 | | /// this address space to LangAS::Default. If no such address space exists, |
1359 | | /// this may return None, and such optimizations will be disabled. |
1360 | 102k | virtual llvm::Optional<LangAS> getConstantAddressSpace() const { |
1361 | 102k | return LangAS::Default; |
1362 | 102k | } |
1363 | | |
1364 | | /// Return a target-specific GPU grid value based on the GVIDX enum \p gv |
1365 | 1.39k | unsigned getGridValue(llvm::omp::GVIDX gv) const { |
1366 | 1.39k | assert(GridValues != nullptr && "GridValues not initialized"); |
1367 | 1.39k | return GridValues[gv]; |
1368 | 1.39k | } |
1369 | | |
1370 | | /// Retrieve the name of the platform as it is used in the |
1371 | | /// availability attribute. |
1372 | 6.13M | StringRef getPlatformName() const { return PlatformName; } |
1373 | | |
1374 | | /// Retrieve the minimum desired version of the platform, to |
1375 | | /// which the program should be compiled. |
1376 | 5.65M | VersionTuple getPlatformMinVersion() const { return PlatformMinVersion; } |
1377 | | |
1378 | 146k | bool isBigEndian() const { return BigEndian; } |
1379 | 1.06k | bool isLittleEndian() const { return !BigEndian; } |
1380 | | |
1381 | | /// Gets the default calling convention for the given target and |
1382 | | /// declaration context. |
1383 | 9.63M | virtual CallingConv getDefaultCallingConv() const { |
1384 | | // Not all targets will specify an explicit calling convention that we can |
1385 | | // express. This will always do the right thing, even though it's not |
1386 | | // an explicit calling convention. |
1387 | 9.63M | return CC_C; |
1388 | 9.63M | } |
1389 | | |
1390 | | enum CallingConvCheckResult { |
1391 | | CCCR_OK, |
1392 | | CCCR_Warning, |
1393 | | CCCR_Ignore, |
1394 | | CCCR_Error, |
1395 | | }; |
1396 | | |
1397 | | /// Determines whether a given calling convention is valid for the |
1398 | | /// target. A calling convention can either be accepted, produce a warning |
1399 | | /// and be substituted with the default calling convention, or (someday) |
1400 | | /// produce an error (such as using thiscall on a non-instance function). |
1401 | 0 | virtual CallingConvCheckResult checkCallingConvention(CallingConv CC) const { |
1402 | 0 | switch (CC) { |
1403 | 0 | default: |
1404 | 0 | return CCCR_Warning; |
1405 | 0 | case CC_C: |
1406 | 0 | return CCCR_OK; |
1407 | 0 | } |
1408 | 0 | } |
1409 | | |
1410 | | enum CallingConvKind { |
1411 | | CCK_Default, |
1412 | | CCK_ClangABI4OrPS4, |
1413 | | CCK_MicrosoftWin64 |
1414 | | }; |
1415 | | |
1416 | | virtual CallingConvKind getCallingConvKind(bool ClangABICompat4) const; |
1417 | | |
1418 | | /// Controls if __builtin_longjmp / __builtin_setjmp can be lowered to |
1419 | | /// llvm.eh.sjlj.longjmp / llvm.eh.sjlj.setjmp. |
1420 | 6 | virtual bool hasSjLjLowering() const { |
1421 | 6 | return false; |
1422 | 6 | } |
1423 | | |
1424 | | /// Check if the target supports CFProtection branch. |
1425 | | virtual bool |
1426 | | checkCFProtectionBranchSupported(DiagnosticsEngine &Diags) const; |
1427 | | |
1428 | | /// Check if the target supports CFProtection branch. |
1429 | | virtual bool |
1430 | | checkCFProtectionReturnSupported(DiagnosticsEngine &Diags) const; |
1431 | | |
1432 | | /// Whether target allows to overalign ABI-specified preferred alignment |
1433 | 1.56M | virtual bool allowsLargerPreferedTypeAlignment() const { return true; } |
1434 | | |
1435 | | /// Whether target defaults to the `power` alignment rules of AIX. |
1436 | 1.47M | virtual bool defaultsToAIXPowerAlignment() const { return false; } |
1437 | | |
1438 | | /// Set supported OpenCL extensions and optional core features. |
1439 | 8.44k | virtual void setSupportedOpenCLOpts() {} |
1440 | | |
1441 | | /// Set supported OpenCL extensions as written on command line |
1442 | 88.9k | virtual void setOpenCLExtensionOpts() { |
1443 | 28 | for (const auto &Ext : getTargetOpts().OpenCLExtensionsAsWritten) { |
1444 | 28 | getTargetOpts().SupportedOpenCLOptions.support(Ext); |
1445 | 28 | } |
1446 | 88.9k | } |
1447 | | |
1448 | | /// Get supported OpenCL extensions and optional core features. |
1449 | 80.5k | OpenCLOptions &getSupportedOpenCLOpts() { |
1450 | 80.5k | return getTargetOpts().SupportedOpenCLOptions; |
1451 | 80.5k | } |
1452 | | |
1453 | | /// Get const supported OpenCL extensions and optional core features. |
1454 | 20.6k | const OpenCLOptions &getSupportedOpenCLOpts() const { |
1455 | 20.6k | return getTargetOpts().SupportedOpenCLOptions; |
1456 | 20.6k | } |
1457 | | |
1458 | | /// Get address space for OpenCL type. |
1459 | | virtual LangAS getOpenCLTypeAddrSpace(OpenCLTypeKind TK) const; |
1460 | | |
1461 | | /// \returns Target specific vtbl ptr address space. |
1462 | 384 | virtual unsigned getVtblPtrAddressSpace() const { |
1463 | 384 | return 0; |
1464 | 384 | } |
1465 | | |
1466 | | /// \returns If a target requires an address within a target specific address |
1467 | | /// space \p AddressSpace to be converted in order to be used, then return the |
1468 | | /// corresponding target specific DWARF address space. |
1469 | | /// |
1470 | | /// \returns Otherwise return None and no conversion will be emitted in the |
1471 | | /// DWARF. |
1472 | 442k | virtual Optional<unsigned> getDWARFAddressSpace(unsigned AddressSpace) const { |
1473 | 442k | return None; |
1474 | 442k | } |
1475 | | |
1476 | | /// \returns The version of the SDK which was used during the compilation if |
1477 | | /// one was specified, or an empty version otherwise. |
1478 | 33.5k | const llvm::VersionTuple &getSDKVersion() const { |
1479 | 33.5k | return getTargetOpts().SDKVersion; |
1480 | 33.5k | } |
1481 | | |
1482 | | /// Check the target is valid after it is fully initialized. |
1483 | 88.7k | virtual bool validateTarget(DiagnosticsEngine &Diags) const { |
1484 | 88.7k | return true; |
1485 | 88.7k | } |
1486 | | |
1487 | 126 | virtual void setAuxTarget(const TargetInfo *Aux) {} |
1488 | | |
1489 | | /// Whether target allows debuginfo types for decl only variables. |
1490 | 1.28M | virtual bool allowDebugInfoForExternalVar() const { return false; } |
1491 | | |
1492 | | protected: |
1493 | | /// Copy type and layout related info. |
1494 | | void copyAuxTarget(const TargetInfo *Aux); |
1495 | 338 | virtual uint64_t getPointerWidthV(unsigned AddrSpace) const { |
1496 | 338 | return PointerWidth; |
1497 | 338 | } |
1498 | 271 | virtual uint64_t getPointerAlignV(unsigned AddrSpace) const { |
1499 | 271 | return PointerAlign; |
1500 | 271 | } |
1501 | 0 | virtual enum IntType getPtrDiffTypeV(unsigned AddrSpace) const { |
1502 | 0 | return PtrDiffType; |
1503 | 0 | } |
1504 | | virtual ArrayRef<const char *> getGCCRegNames() const = 0; |
1505 | | virtual ArrayRef<GCCRegAlias> getGCCRegAliases() const = 0; |
1506 | 2.18k | virtual ArrayRef<AddlRegName> getGCCAddlRegNames() const { |
1507 | 2.18k | return None; |
1508 | 2.18k | } |
1509 | | |
1510 | | private: |
1511 | | // Assert the values for the fractional and integral bits for each fixed point |
1512 | | // type follow the restrictions given in clause 6.2.6.3 of N1169. |
1513 | | void CheckFixedPointBits() const; |
1514 | | }; |
1515 | | |
1516 | | } // end namespace clang |
1517 | | |
1518 | | #endif |