clang 24.0.0git
TargetInfo.h
Go to the documentation of this file.
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
22#include "clang/Basic/LLVM.h"
27#include "llvm/ADT/APFloat.h"
28#include "llvm/ADT/APInt.h"
29#include "llvm/ADT/APSInt.h"
30#include "llvm/ADT/ArrayRef.h"
31#include "llvm/ADT/IntrusiveRefCntPtr.h"
32#include "llvm/ADT/SmallSet.h"
33#include "llvm/ADT/StringMap.h"
34#include "llvm/ADT/StringRef.h"
35#include "llvm/ADT/StringSet.h"
36#include "llvm/ADT/StringTable.h"
37#include "llvm/Frontend/OpenMP/OMPGridValues.h"
38#include "llvm/IR/DerivedTypes.h"
39#include "llvm/Support/DataTypes.h"
40#include "llvm/Support/Error.h"
41#include "llvm/Support/VersionTuple.h"
42#include "llvm/TargetParser/Triple.h"
43#include <cassert>
44#include <optional>
45#include <string>
46#include <utility>
47#include <vector>
48
49namespace llvm {
50struct fltSemantics;
51}
52
53namespace clang {
55class LangOptions;
56class CodeGenOptions;
57class MacroBuilder;
58
59/// Contains information gathered from parsing the contents of TargetAttr.
61 std::vector<std::string> Features;
62 StringRef CPU;
63 StringRef Tune;
65 StringRef Duplicate;
66 bool operator ==(const ParsedTargetAttr &Other) const {
67 return Duplicate == Other.Duplicate && CPU == Other.CPU &&
68 Tune == Other.Tune && BranchProtection == Other.BranchProtection &&
69 Features == Other.Features;
70 }
71};
72
73namespace Builtin { struct Info; }
74
75enum class FloatModeKind {
77 Half = 1 << 0,
78 Float = 1 << 1,
79 Double = 1 << 2,
80 LongDouble = 1 << 3,
81 Float128 = 1 << 4,
82 Ibm128 = 1 << 5,
84};
85
86/// Fields controlling how types are laid out in memory; these may need to
87/// be copied for targets like AMDGPU that base their ABIs on an auxiliary
88/// CPU target.
90 unsigned char PointerWidth, PointerAlign;
91 unsigned char BoolWidth, BoolAlign;
92 unsigned char ShortWidth, ShortAlign;
93 unsigned char IntWidth, IntAlign;
94 unsigned char HalfWidth, HalfAlign;
96 unsigned char FloatWidth, FloatAlign;
97 unsigned char DoubleWidth, DoubleAlign;
100 unsigned char LongWidth, LongAlign;
102 unsigned char Int128Align;
103
104 // This is an optional parameter for targets that
105 // don't use 'LongLongAlign' for '_BitInt' max alignment
106 std::optional<unsigned> BitIntMaxAlign;
107
108 // Fixed point bit widths
110 unsigned char AccumWidth, AccumAlign;
113 unsigned char FractWidth, FractAlign;
115
116 // If true, unsigned fixed point types have the same number of fractional bits
117 // as their signed counterparts, forcing the unsigned types to have one extra
118 // bit of padding. Otherwise, unsigned fixed point types have
119 // one more fractional bit than its corresponding signed type. This is false
120 // by default.
122
123 // Fixed point integral and fractional bit sizes
124 // Saturated types share the same integral/fractional bits as their
125 // corresponding unsaturated types.
126 // For simplicity, the fractional bits in a _Fract type will be one less the
127 // width of that _Fract type. This leaves all signed _Fract types having no
128 // padding and unsigned _Fract types will only have 1 bit of padding after the
129 // sign if PaddingOnUnsignedFixedPoint is set.
130 unsigned char ShortAccumScale;
131 unsigned char AccumScale;
132 unsigned char LongAccumScale;
133
135 unsigned char MinGlobalAlign;
136
137 unsigned short SuitableAlign;
138 unsigned short NewAlign;
140 unsigned MaxTLSAlign;
142
143 const llvm::fltSemantics *HalfFormat, *BFloat16Format, *FloatFormat,
145
146 ///===---- Target Data Type Query Methods -------------------------------===//
160
161protected:
165
166 /// Whether Objective-C's built-in boolean type should be signed char.
167 ///
168 /// Otherwise, when this flag is not set, the normal built-in boolean type is
169 /// used.
170 LLVM_PREFERRED_TYPE(bool)
172
173 /// Control whether the alignment of bit-field types is respected when laying
174 /// out structures. If true, then the alignment of the bit-field type will be
175 /// used to (a) impact the alignment of the containing structure, and (b)
176 /// ensure that the individual bit-field will not straddle an alignment
177 /// boundary.
178 LLVM_PREFERRED_TYPE(bool)
180
181 /// Whether zero length bitfields (e.g., int : 0;) force alignment of
182 /// the next bitfield.
183 ///
184 /// If the alignment of the zero length bitfield is greater than the member
185 /// that follows it, `bar', `bar' will be aligned as the type of the
186 /// zero-length bitfield.
187 LLVM_PREFERRED_TYPE(bool)
189
190 /// Whether zero length bitfield alignment is respected if they are the
191 /// leading members.
192 LLVM_PREFERRED_TYPE(bool)
194
195 /// Whether explicit bit field alignment attributes are honored.
196 LLVM_PREFERRED_TYPE(bool)
198
199 /// If non-zero, specifies a fixed alignment value for bitfields that follow
200 /// zero length bitfield, regardless of the zero length bitfield type.
202
203 /// The largest container size which should be used for an over-sized
204 /// bitfield, in bits.
206
207 /// If non-zero, specifies a maximum alignment to truncate alignment
208 /// specified in the aligned attribute of a static variable to this value.
210};
211
212/// OpenCL type kinds.
223
224/// Exposes information about the current target.
225///
227 public RefCountedBase<TargetInfo> {
228 TargetOptions *TargetOpts;
229 llvm::Triple Triple;
230protected:
231 // Target values set by the ctor of the actual target implementation. Default
232 // values are specified by the TargetInfo constructor.
237 bool NoAsmVariants; // True if {|} are normal characters.
238 bool HasFastHalfType; // True if the backend has native half float support,
239 // and performing calculations in float instead does
240 // not have a performance advantage.
241 bool HalfArgsAndReturns; // OpenCL 6.1.1.1, NEON (IEEE 754-2008 half) type.
245 bool HasFullBFloat16; // True if the backend supports native bfloat16
246 // arithmetic. Used to determine excess precision
247 // support in the frontend.
252
254 std::string DataLayoutString;
255 const char *UserLabelPrefix;
256 const char *MCountName;
257 unsigned char RegParmMax, SSERegParmMax;
261
262 mutable StringRef PlatformName;
263 mutable VersionTuple PlatformMinVersion;
264
265 LLVM_PREFERRED_TYPE(bool)
267 LLVM_PREFERRED_TYPE(FloatModeKind)
269 LLVM_PREFERRED_TYPE(bool)
271
272 LLVM_PREFERRED_TYPE(bool)
273 unsigned HasBuiltinMSVaList : 1;
274
275 LLVM_PREFERRED_TYPE(bool)
277
278 LLVM_PREFERRED_TYPE(bool)
280
281 LLVM_PREFERRED_TYPE(bool)
282 unsigned HasRISCVVTypes : 1;
283
284 LLVM_PREFERRED_TYPE(bool)
286
287 LLVM_PREFERRED_TYPE(bool)
288 unsigned HasUnalignedAccess : 1;
289
290 LLVM_PREFERRED_TYPE(bool)
291 unsigned HasAMDGPUTypes : 1;
292
293 unsigned ARMCDECoprocMask : 8;
294
296
297 std::optional<unsigned> MaxBitIntWidth;
298
300
302
303 // TargetInfo Constructor. Default initializes all fields.
304 TargetInfo(const llvm::Triple &T);
305
306 /// Set the data layout to the given string.
307 void resetDataLayout(StringRef DL);
308
309 /// Set the data layout based on current triple and ABI.
310 void resetDataLayout();
311
312 // Target features that are read-only and should not be disabled/enabled
313 // by command line options. Such features are for emitting predefined
314 // macros or checking availability of builtin functions and can be omitted
315 // in function attributes in IR.
316 llvm::StringSet<> ReadOnlyFeatures;
317
318 // Default atomic options
320
321public:
322 /// Construct a target for the given options.
323 ///
324 /// \param Opts - The options to use to initialize the target. The target may
325 /// modify the options to canonicalize the target feature information to match
326 /// what the backend expects. These must outlive the returned TargetInfo.
328 TargetOptions &Opts);
329
330 virtual ~TargetInfo();
331
332 /// Retrieve the target options.
334 assert(TargetOpts && "Missing target options");
335 return *TargetOpts;
336 }
337
338 /// The different kinds of __builtin_va_list types defined by
339 /// the target implementation.
341 /// typedef char* __builtin_va_list;
343
344 /// typedef void* __builtin_va_list;
346
347 /// __builtin_va_list as defined by the AArch64 ABI
348 /// http://infocenter.arm.com/help/topic/com.arm.doc.ihi0055a/IHI0055A_aapcs64.pdf
350
351 /// __builtin_va_list as defined by the Power ABI:
352 /// https://www.power.org
353 /// /resources/downloads/Power-Arch-32-bit-ABI-supp-1.0-Embedded.pdf
355
356 /// __builtin_va_list as defined by the x86-64 ABI:
357 /// http://refspecs.linuxbase.org/elf/x86_64-abi-0.21.pdf
359
360 /// __builtin_va_list as defined by ARM AAPCS ABI
361 /// http://infocenter.arm.com
362 // /help/topic/com.arm.doc.ihi0042d/IHI0042D_aapcs.pdf
364
365 // typedef struct __va_list_tag
366 // {
367 // long __gpr;
368 // long __fpr;
369 // void *__overflow_arg_area;
370 // void *__reg_save_area;
371 // } va_list[1];
373
374 // typedef struct __va_list_tag {
375 // void *__current_saved_reg_area_pointer;
376 // void *__saved_reg_area_end_pointer;
377 // void *__overflow_area_pointer;
378 //} va_list;
380
381 // typedef struct __va_list_tag {
382 // int* __va_stk;
383 // int* __va_reg;
384 // int __va_ndx;
385 //} va_list;
387 };
388
389protected:
390 /// Specify if mangling based on address space map should be used or
391 /// not for language specific address spaces
393
394public:
395 IntType getSizeType() const { return SizeType; }
397 switch (SizeType) {
398 case UnsignedShort:
399 return SignedShort;
400 case UnsignedInt:
401 return SignedInt;
402 case UnsignedLong:
403 return SignedLong;
404 case UnsignedLongLong:
405 return SignedLongLong;
406 default:
407 llvm_unreachable("Invalid SizeType");
408 }
409 }
410 IntType getIntMaxType() const { return IntMaxType; }
414 IntType getPtrDiffType(LangAS AddrSpace) const {
415 return AddrSpace == LangAS::Default ? PtrDiffType
416 : getPtrDiffTypeV(AddrSpace);
417 }
420 }
421 IntType getIntPtrType() const { return IntPtrType; }
425 IntType getWCharType() const { return WCharType; }
426 IntType getWIntType() const { return WIntType; }
427 IntType getChar16Type() const { return Char16Type; }
428 IntType getChar32Type() const { return Char32Type; }
429 IntType getInt64Type() const { return Int64Type; }
433 IntType getInt16Type() const { return Int16Type; }
439
441 switch (T) {
442 case SignedChar:
443 return UnsignedChar;
444 case SignedShort:
445 return UnsignedShort;
446 case SignedInt:
447 return UnsignedInt;
448 case SignedLong:
449 return UnsignedLong;
450 case SignedLongLong:
451 return UnsignedLongLong;
452 default:
453 llvm_unreachable("Unexpected signed integer type");
454 }
455 }
456
457 /// In the event this target uses the same number of fractional bits for its
458 /// unsigned types as it does with its signed counterparts, there will be
459 /// exactly one bit of padding.
460 /// Return true if unsigned fixed point types have padding for this target.
464
465 /// Return the width (in bits) of the specified integer type enum.
466 ///
467 /// For example, SignedInt -> getIntWidth().
468 unsigned getTypeWidth(IntType T) const;
469
470 /// Return integer type with specified width.
471 virtual IntType getIntTypeByWidth(unsigned BitWidth, bool IsSigned) const;
472
473 /// Return the smallest integer type with at least the specified width.
474 virtual IntType getLeastIntTypeByWidth(unsigned BitWidth,
475 bool IsSigned) const;
476
477 /// Return floating point type with specified width. On PPC, there are
478 /// three possible types for 128-bit floating point: "PPC double-double",
479 /// IEEE 754R quad precision, and "long double" (which under the covers
480 /// is represented as one of those two). At this time, there is no support
481 /// for an explicit "PPC double-double" type (i.e. __ibm128) so we only
482 /// need to differentiate between "long double" and IEEE quad precision.
483 FloatModeKind getRealTypeByWidth(unsigned BitWidth,
484 FloatModeKind ExplicitType) const;
485
486 /// Return the alignment (in bits) of the specified integer type enum.
487 ///
488 /// For example, SignedInt -> getIntAlign().
489 unsigned getTypeAlign(IntType T) const;
490
491 /// Returns true if the type is signed; false otherwise.
492 static bool isTypeSigned(IntType T);
493
494 /// Return the width of pointers on this target, for the
495 /// specified address space.
496 uint64_t getPointerWidth(LangAS AddrSpace) const {
497 return AddrSpace == LangAS::Default ? PointerWidth
498 : getPointerWidthV(AddrSpace);
499 }
500 uint64_t getPointerAlign(LangAS AddrSpace) const {
501 return AddrSpace == LangAS::Default ? PointerAlign
502 : getPointerAlignV(AddrSpace);
503 }
504
505 /// Return the maximum width of pointers on this target.
506 virtual uint64_t getMaxPointerWidth() const {
507 return PointerWidth;
508 }
509
510 /// Get integer value for null pointer.
511 /// \param AddrSpace address space of pointee in source language.
512 virtual uint64_t getNullPointerValue(LangAS AddrSpace) const { return 0; }
513
514 /// Returns true if an address space can be safely converted to another.
515 /// \param A address space of target in source language.
516 /// \param B address space of source in source language.
517 virtual bool isAddressSpaceSupersetOf(LangAS A, LangAS B) const {
518 return A == B;
519 }
520
521 /// Return the size of '_Bool' and C++ 'bool' for this target, in bits.
522 unsigned getBoolWidth() const { return BoolWidth; }
523
524 /// Return the alignment of '_Bool' and C++ 'bool' for this target.
525 unsigned getBoolAlign() const { return BoolAlign; }
526
527 unsigned getCharWidth() const { return 8; } // FIXME
528 unsigned getCharAlign() const { return 8; } // FIXME
529
530 /// getShortWidth/Align - Return the size of 'signed short' and
531 /// 'unsigned short' for this target, in bits.
532 unsigned getShortWidth() const { return ShortWidth; }
533 unsigned getShortAlign() const { return ShortAlign; }
534
535 /// getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for
536 /// this target, in bits.
537 unsigned getIntWidth() const { return IntWidth; }
538 unsigned getIntAlign() const { return IntAlign; }
539
540 /// getLongWidth/Align - Return the size of 'signed long' and 'unsigned long'
541 /// for this target, in bits.
542 unsigned getLongWidth() const { return LongWidth; }
543 unsigned getLongAlign() const { return LongAlign; }
544
545 /// getLongLongWidth/Align - Return the size of 'signed long long' and
546 /// 'unsigned long long' for this target, in bits.
547 unsigned getLongLongWidth() const { return LongLongWidth; }
548 unsigned getLongLongAlign() const { return LongLongAlign; }
549
550 /// getInt128Align() - Returns the alignment of Int128.
551 unsigned getInt128Align() const { return Int128Align; }
552
553 /// getBitIntMaxAlign() - Returns the maximum possible alignment of
554 /// '_BitInt' and 'unsigned _BitInt'.
555 unsigned getBitIntMaxAlign() const {
556 return BitIntMaxAlign.value_or(LongLongAlign);
557 }
558
559 /// getBitIntAlign/Width - Return aligned size of '_BitInt' and
560 /// 'unsigned _BitInt' for this target, in bits.
561 unsigned getBitIntWidth(unsigned NumBits) const {
562 return llvm::alignTo(NumBits, getBitIntAlign(NumBits));
563 }
564 unsigned getBitIntAlign(unsigned NumBits) const {
565 return std::clamp<unsigned>(llvm::PowerOf2Ceil(NumBits), getCharWidth(),
567 }
568
569 /// getShortAccumWidth/Align - Return the size of 'signed short _Accum' and
570 /// 'unsigned short _Accum' for this target, in bits.
571 unsigned getShortAccumWidth() const { return ShortAccumWidth; }
572 unsigned getShortAccumAlign() const { return ShortAccumAlign; }
573
574 /// getAccumWidth/Align - Return the size of 'signed _Accum' and
575 /// 'unsigned _Accum' for this target, in bits.
576 unsigned getAccumWidth() const { return AccumWidth; }
577 unsigned getAccumAlign() const { return AccumAlign; }
578
579 /// getLongAccumWidth/Align - Return the size of 'signed long _Accum' and
580 /// 'unsigned long _Accum' for this target, in bits.
581 unsigned getLongAccumWidth() const { return LongAccumWidth; }
582 unsigned getLongAccumAlign() const { return LongAccumAlign; }
583
584 /// getShortFractWidth/Align - Return the size of 'signed short _Fract' and
585 /// 'unsigned short _Fract' for this target, in bits.
586 unsigned getShortFractWidth() const { return ShortFractWidth; }
587 unsigned getShortFractAlign() const { return ShortFractAlign; }
588
589 /// getFractWidth/Align - Return the size of 'signed _Fract' and
590 /// 'unsigned _Fract' for this target, in bits.
591 unsigned getFractWidth() const { return FractWidth; }
592 unsigned getFractAlign() const { return FractAlign; }
593
594 /// getLongFractWidth/Align - Return the size of 'signed long _Fract' and
595 /// 'unsigned long _Fract' for this target, in bits.
596 unsigned getLongFractWidth() const { return LongFractWidth; }
597 unsigned getLongFractAlign() const { return LongFractAlign; }
598
599 /// getShortAccumScale/IBits - Return the number of fractional/integral bits
600 /// in a 'signed short _Accum' type.
601 unsigned getShortAccumScale() const { return ShortAccumScale; }
602 unsigned getShortAccumIBits() const {
603 return ShortAccumWidth - ShortAccumScale - 1;
604 }
605
606 /// getAccumScale/IBits - Return the number of fractional/integral bits
607 /// in a 'signed _Accum' type.
608 unsigned getAccumScale() const { return AccumScale; }
609 unsigned getAccumIBits() const { return AccumWidth - AccumScale - 1; }
610
611 /// getLongAccumScale/IBits - Return the number of fractional/integral bits
612 /// in a 'signed long _Accum' type.
613 unsigned getLongAccumScale() const { return LongAccumScale; }
614 unsigned getLongAccumIBits() const {
615 return LongAccumWidth - LongAccumScale - 1;
616 }
617
618 /// getUnsignedShortAccumScale/IBits - Return the number of
619 /// fractional/integral bits in a 'unsigned short _Accum' type.
628
629 /// getUnsignedAccumScale/IBits - Return the number of fractional/integral
630 /// bits in a 'unsigned _Accum' type.
631 unsigned getUnsignedAccumScale() const {
633 }
638
639 /// getUnsignedLongAccumScale/IBits - Return the number of fractional/integral
640 /// bits in a 'unsigned long _Accum' type.
649
650 /// getShortFractScale - Return the number of fractional bits
651 /// in a 'signed short _Fract' type.
652 unsigned getShortFractScale() const { return ShortFractWidth - 1; }
653
654 /// getFractScale - Return the number of fractional bits
655 /// in a 'signed _Fract' type.
656 unsigned getFractScale() const { return FractWidth - 1; }
657
658 /// getLongFractScale - Return the number of fractional bits
659 /// in a 'signed long _Fract' type.
660 unsigned getLongFractScale() const { return LongFractWidth - 1; }
661
662 /// getUnsignedShortFractScale - Return the number of fractional bits
663 /// in a 'unsigned short _Fract' type.
668
669 /// getUnsignedFractScale - Return the number of fractional bits
670 /// in a 'unsigned _Fract' type.
671 unsigned getUnsignedFractScale() const {
673 }
674
675 /// getUnsignedLongFractScale - Return the number of fractional bits
676 /// in a 'unsigned long _Fract' type.
681
682 virtual bool hasMustTail() const { return HasMustTail; }
683
684 /// Determine whether the __int128 type is supported on this target.
685 virtual bool hasInt128Type() const {
686 return (getPointerWidth(LangAS::Default) >= 64) ||
687 getTargetOpts().ForceEnableInt128;
688 } // FIXME
689
690 /// Determine whether the _BitInt type is supported on this target. This
691 /// limitation is put into place for ABI reasons.
692 /// FIXME: _BitInt is a required type in C23, so there's not much utility in
693 /// asking whether the target supported it or not; I think this should be
694 /// removed once backends have been alerted to the type and have had the
695 /// chance to do implementation work if needed.
696 virtual bool hasBitIntType() const {
697 return false;
698 }
699
700 // Different targets may support a different maximum width for the _BitInt
701 // type, depending on what operations are supported.
702 virtual size_t getMaxBitIntWidth() const {
703 // Consider -fexperimental-max-bitint-width= first.
704 if (MaxBitIntWidth)
705 return std::min<size_t>(*MaxBitIntWidth, llvm::IntegerType::MAX_INT_BITS);
706
707 // FIXME: this value should be llvm::IntegerType::MAX_INT_BITS, which is
708 // maximum bit width that LLVM claims its IR can support. However, most
709 // backends currently have a bug where they only support float to int
710 // conversion (and vice versa) on types that are <= 128 bits and crash
711 // otherwise. We're setting the max supported value to 128 to be
712 // conservative.
713 return 128;
714 }
715
716 /// Determine whether the target has fast native support for operations
717 /// on half types.
718 virtual bool hasFastHalfType() const { return HasFastHalfType; }
719
720 /// Whether half args and returns are supported.
721 virtual bool allowHalfArgsAndReturns() const { return HalfArgsAndReturns; }
722
723 /// Determine whether the __float128 type is supported on this target.
724 virtual bool hasFloat128Type() const { return HasFloat128; }
725
726 /// Determine whether the _Float16 type is supported on this target.
727 virtual bool hasFloat16Type() const { return HasFloat16; }
728
729 /// Determine whether the _BFloat16 type is supported on this target.
730 virtual bool hasBFloat16Type() const {
732 }
733
734 /// Determine whether the BFloat type is fully supported on this target, i.e
735 /// arithemtic operations.
736 virtual bool hasFullBFloat16Type() const { return HasFullBFloat16; }
737
738 /// Determine whether the __ibm128 type is supported on this target.
739 virtual bool hasIbm128Type() const { return HasIbm128; }
740
741 /// Determine whether the long double type is supported on this target.
742 virtual bool hasLongDoubleType() const { return HasLongDouble; }
743
744 /// Determine whether return of a floating point value is supported
745 /// on this target.
746 virtual bool hasFPReturn() const { return HasFPReturn; }
747
748 /// Determine whether constrained floating point is supported on this target.
749 virtual bool hasStrictFP() const { return HasStrictFP; }
750
751 /// Return the alignment that is the largest alignment ever used for any
752 /// scalar/SIMD data type on the target machine you are compiling for
753 /// (including types with an extended alignment requirement).
754 unsigned getSuitableAlign() const { return SuitableAlign; }
755
756 /// Return the default alignment for __attribute__((aligned)) on
757 /// this target, to be used if no alignment value is specified.
761
762 /// getMinGlobalAlign - Return the minimum alignment of a global variable,
763 /// unless its alignment is explicitly reduced via attributes. If \param
764 /// HasNonWeakDef is true, this concerns a VarDecl which has a definition
765 /// in current translation unit and that is not weak.
766 virtual unsigned getMinGlobalAlign(uint64_t Size, bool HasNonWeakDef) const {
767 return MinGlobalAlign;
768 }
769
770 /// Return the largest alignment for which a suitably-sized allocation with
771 /// '::operator new(size_t)' is guaranteed to produce a correctly-aligned
772 /// pointer.
773 unsigned getNewAlign() const {
774 return NewAlign ? NewAlign : std::max(LongDoubleAlign, LongLongAlign);
775 }
776
777 /// getWCharWidth/Align - Return the size of 'wchar_t' for this target, in
778 /// bits.
779 unsigned getWCharWidth() const { return getTypeWidth(WCharType); }
780 unsigned getWCharAlign() const { return getTypeAlign(WCharType); }
781
782 /// getChar16Width/Align - Return the size of 'char16_t' for this target, in
783 /// bits.
784 unsigned getChar16Width() const { return getTypeWidth(Char16Type); }
785 unsigned getChar16Align() const { return getTypeAlign(Char16Type); }
786
787 /// getChar32Width/Align - Return the size of 'char32_t' for this target, in
788 /// bits.
789 unsigned getChar32Width() const { return getTypeWidth(Char32Type); }
790 unsigned getChar32Align() const { return getTypeAlign(Char32Type); }
791
792 /// getHalfWidth/Align/Format - Return the size/align/format of 'half'.
793 unsigned getHalfWidth() const { return HalfWidth; }
794 unsigned getHalfAlign() const { return HalfAlign; }
795 const llvm::fltSemantics &getHalfFormat() const { return *HalfFormat; }
796
797 /// getFloatWidth/Align/Format - Return the size/align/format of 'float'.
798 unsigned getFloatWidth() const { return FloatWidth; }
799 unsigned getFloatAlign() const { return FloatAlign; }
800 const llvm::fltSemantics &getFloatFormat() const { return *FloatFormat; }
801
802 /// getBFloat16Width/Align/Format - Return the size/align/format of '__bf16'.
803 unsigned getBFloat16Width() const { return BFloat16Width; }
804 unsigned getBFloat16Align() const { return BFloat16Align; }
805 const llvm::fltSemantics &getBFloat16Format() const { return *BFloat16Format; }
806
807 /// getDoubleWidth/Align/Format - Return the size/align/format of 'double'.
808 unsigned getDoubleWidth() const { return DoubleWidth; }
809 unsigned getDoubleAlign() const { return DoubleAlign; }
810 const llvm::fltSemantics &getDoubleFormat() const { return *DoubleFormat; }
811
812 /// getLongDoubleWidth/Align/Format - Return the size/align/format of 'long
813 /// double'.
814 unsigned getLongDoubleWidth() const { return LongDoubleWidth; }
815 unsigned getLongDoubleAlign() const { return LongDoubleAlign; }
816 const llvm::fltSemantics &getLongDoubleFormat() const {
817 return *LongDoubleFormat;
818 }
819
820 /// getFloat128Width/Align/Format - Return the size/align/format of
821 /// '__float128'.
822 unsigned getFloat128Width() const { return 128; }
823 unsigned getFloat128Align() const { return Float128Align; }
824 const llvm::fltSemantics &getFloat128Format() const {
825 return *Float128Format;
826 }
827
828 /// getIbm128Width/Align/Format - Return the size/align/format of
829 /// '__ibm128'.
830 unsigned getIbm128Width() const { return 128; }
831 unsigned getIbm128Align() const { return Ibm128Align; }
832 const llvm::fltSemantics &getIbm128Format() const { return *Ibm128Format; }
833
834 /// Return the mangled code of long double.
835 virtual const char *getLongDoubleMangling() const { return "e"; }
836
837 /// Return the mangled code of __float128.
838 virtual const char *getFloat128Mangling() const { return "g"; }
839
840 /// Return the mangled code of __ibm128.
841 virtual const char *getIbm128Mangling() const {
842 llvm_unreachable("ibm128 not implemented on this target");
843 }
844
845 /// Return the mangled code of bfloat.
846 virtual const char *getBFloat16Mangling() const { return "DF16b"; }
847
848 /// Return the value for the C99 FLT_EVAL_METHOD macro.
852
853 virtual bool supportSourceEvalMethod() const { return true; }
854
855 // getLargeArrayMinWidth/Align - Return the minimum array size that is
856 // 'large' and its alignment.
857 unsigned getLargeArrayMinWidth() const { return LargeArrayMinWidth; }
858 unsigned getLargeArrayAlign() const { return LargeArrayAlign; }
859
860 /// Return the maximum width lock-free atomic operation which will
861 /// ever be supported for the given target
863 /// Return the maximum width lock-free atomic operation which can be
864 /// inlined given the supported features of the given target.
866 /// Set the maximum inline or promote width lock-free atomic operation
867 /// for the given target.
868 virtual void setMaxAtomicWidth() {}
869 /// Returns true if the given target supports lock-free atomic
870 /// operations at the specified width and alignment.
871 virtual bool hasBuiltinAtomic(uint64_t AtomicSizeInBits,
872 uint64_t AlignmentInBits) const {
873 return AtomicSizeInBits <= AlignmentInBits &&
874 AtomicSizeInBits <= getMaxAtomicInlineWidth() &&
875 (AtomicSizeInBits <= getCharWidth() ||
876 llvm::isPowerOf2_64(AtomicSizeInBits / getCharWidth()));
877 }
878
879 /// True if vectors are element-aligned for this target.
881
882 /// Return the maximum vector alignment supported for the given target.
883 unsigned getMaxVectorAlign() const { return MaxVectorAlign; }
884
886
887 /// Return the alignment (in bits) of the thrown exception object. This is
888 /// only meaningful for targets that allocate C++ exceptions in a system
889 /// runtime, such as those using the Itanium C++ ABI.
890 virtual unsigned getExnObjectAlignment() const {
891 // Itanium says that an _Unwind_Exception has to be "double-word"
892 // aligned (and thus the end of it is also so-aligned), meaning 16
893 // bytes. Of course, that was written for the actual Itanium,
894 // which is a 64-bit platform. Classically, the ABI doesn't really
895 // specify the alignment on other platforms, but in practice
896 // libUnwind declares the struct with __attribute__((aligned)), so
897 // we assume that alignment here. (It's generally 16 bytes, but
898 // some targets overwrite it.)
900 }
901
902 /// Return the size of intmax_t and uintmax_t for this target, in bits.
903 unsigned getIntMaxTWidth() const {
904 return getTypeWidth(IntMaxType);
905 }
906
907 // Return the size of unwind_word for this target.
908 virtual unsigned getUnwindWordWidth() const {
910 }
911
912 /// Return the "preferred" register width on this target.
913 virtual unsigned getRegisterWidth() const {
914 // Currently we assume the register width on the target matches the pointer
915 // width, we can introduce a new variable for this if/when some target wants
916 // it.
917 return PointerWidth;
918 }
919
920 /// Return true iff unaligned accesses are a single instruction (rather than
921 /// a synthesized sequence).
922 bool hasUnalignedAccess() const { return HasUnalignedAccess; }
923
924 /// Return true iff unaligned accesses are cheap. This affects placement and
925 /// size of bitfield loads/stores. (Not the ABI-mandated placement of
926 /// the bitfields themselves.)
928 // Simply forward to the unaligned access getter.
929 return hasUnalignedAccess();
930 }
931
932 /// \brief Returns the default value of the __USER_LABEL_PREFIX__ macro,
933 /// which is the prefix given to user symbols by default.
934 ///
935 /// On most platforms this is "", but it is "_" on some.
936 const char *getUserLabelPrefix() const { return UserLabelPrefix; }
937
938 /// Returns the name of the mcount instrumentation function.
939 const char *getMCountName() const {
940 return MCountName;
941 }
942
943 /// Check if the Objective-C built-in boolean type should be signed
944 /// char.
945 ///
946 /// Otherwise, if this returns false, the normal built-in boolean type
947 /// should also be used for Objective-C.
950 }
954
955 /// Check whether the alignment of bit-field types is respected
956 /// when laying out structures.
959 }
960
961 /// Check whether zero length bitfields should force alignment of
962 /// the next member.
966
967 /// Check whether zero length bitfield alignment is respected if they are
968 /// leading members.
972
973 /// Get the fixed alignment value in bits for a member that follows
974 /// a zero length bitfield.
977 }
978
982
983 /// Get the maximum alignment in bits for a static variable with
984 /// aligned attribute.
985 unsigned getMaxAlignedAttribute() const { return MaxAlignedAttribute; }
986
987 /// Check whether explicit bitfield alignment attributes should be
988 // honored, as in "__attribute__((aligned(2))) int b : 1;".
992
993 /// Check whether this target support '\#pragma options align=mac68k'.
996 }
997
998 /// Return the user string for the specified integer type enum.
999 ///
1000 /// For example, SignedShort -> "short".
1001 static const char *getTypeName(IntType T);
1002
1003 /// Return the constant suffix for the specified integer type enum.
1004 ///
1005 /// For example, SignedLong -> "L".
1006 const char *getTypeConstantSuffix(IntType T) const;
1007
1008 /// Return the printf format modifier for the specified
1009 /// integer type enum.
1010 ///
1011 /// For example, SignedLong -> "l".
1012 static const char *getTypeFormatModifier(IntType T);
1013
1014 /// Check whether the given real type should use the "fpret" flavor of
1015 /// Objective-C message passing on this target.
1019
1020 /// Check whether _Complex long double should use the "fp2ret" flavor
1021 /// of Objective-C message passing on this target.
1025
1026 /// Specify if mangling based on address space map should be used or
1027 /// not for language specific address spaces
1030 }
1031
1032 ///===---- Other target property query methods --------------------------===//
1033
1034 /// Appends the target-specific \#define values for this
1035 /// target set to the specified buffer.
1036 virtual void getTargetDefines(const LangOptions &Opts,
1037 MacroBuilder &Builder) const = 0;
1038
1039 /// Return information about target-specific builtins for the current primary
1040 /// target, and info about which builtins are non-portable across the current
1041 /// set of primary and secondary targets.
1043
1049
1050 /// Returns target-specific min and max values VScale_Range.
1051 virtual std::optional<std::pair<unsigned, unsigned>>
1053 llvm::StringMap<bool> *FeatureMap = nullptr) const {
1054 return std::nullopt;
1055 }
1056 /// The __builtin_clz* and __builtin_ctz* built-in
1057 /// functions are specified to have undefined results for zero inputs, but
1058 /// on targets that support these operations in a way that provides
1059 /// well-defined results for zero without loss of performance, it is a good
1060 /// idea to avoid optimizing based on that undef behavior.
1061 virtual bool isCLZForZeroUndef() const { return true; }
1062
1063 /// Returns the kind of __builtin_va_list type that should be used
1064 /// with this target.
1066
1067 /// Returns whether or not type \c __builtin_ms_va_list type is
1068 /// available on this target.
1070
1071 /// Returns whether or not type \c __builtin_zos_va_list type is
1072 /// available on this target.
1074
1075 /// Returns whether or not the AArch64 ACLE built-in types are
1076 /// available on this target.
1078
1079 /// Returns whether or not the AMDGPU built-in types are
1080 /// available on this target.
1081 bool hasAMDGPUTypes() const { return HasAMDGPUTypes; }
1082
1083 /// Returns whether or not the RISC-V V built-in types are
1084 /// available on this target.
1085 bool hasRISCVVTypes() const { return HasRISCVVTypes; }
1086
1087 /// For ARM targets returns a mask defining which coprocessors are configured
1088 /// as Custom Datapath.
1090
1091 /// For ARM targets returns a mask defining which data sizes are suitable for
1092 /// __builtin_arm_ldrex and __builtin_arm_strex.
1093 enum {
1094 ARM_LDREX_B = (1 << 0), /// byte (8-bit)
1095 ARM_LDREX_H = (1 << 1), /// half (16-bit)
1096 ARM_LDREX_W = (1 << 2), /// word (32-bit)
1097 ARM_LDREX_D = (1 << 3), /// double (64-bit)
1098 };
1099
1100 virtual unsigned getARMLDREXMask() const { return 0; }
1101
1102 /// Returns whether the passed in string is a valid clobber in an
1103 /// inline asm statement.
1104 ///
1105 /// This is used by Sema.
1106 bool isValidClobber(StringRef Name) const;
1107
1108 /// Returns whether the passed in string is a valid register name
1109 /// according to GCC.
1110 ///
1111 /// This is used by Sema for inline asm statements.
1112 virtual bool isValidGCCRegisterName(StringRef Name) const;
1113
1114 /// Returns the "normalized" GCC register name.
1115 ///
1116 /// ReturnCannonical true will return the register name without any additions
1117 /// such as "{}" or "%" in it's canonical form, for example:
1118 /// ReturnCanonical = true and Name = "rax", will return "ax".
1119 StringRef getNormalizedGCCRegisterName(StringRef Name,
1120 bool ReturnCanonical = false) const;
1121
1122 virtual bool isSPRegName(StringRef) const { return false; }
1123
1124 /// Extracts a register from the passed constraint (if it is a
1125 /// single-register constraint) and the asm label expression related to a
1126 /// variable in the input or output list of an inline asm statement.
1127 ///
1128 /// This function is used by Sema in order to diagnose conflicts between
1129 /// the clobber list and the input/output lists.
1130 virtual StringRef getConstraintRegister(StringRef Constraint,
1131 StringRef Expression) const {
1132 return "";
1133 }
1134
1136 enum {
1137 CI_None = 0x00,
1140 CI_ReadWrite = 0x04, // "+r" output constraint (read and write).
1141 CI_HasMatchingInput = 0x08, // This output operand has a matching input.
1142 CI_ImmediateConstant = 0x10, // This operand must be an immediate constant
1143 CI_EarlyClobber = 0x20, // "&" output constraint (early clobber).
1144 CI_OutputOperandBounds = 0x40, // Output operand bounds.
1145 };
1146 unsigned Flags;
1148 struct {
1149 int Min;
1150 int Max;
1152 } ImmRange;
1153 llvm::SmallSet<int, 4> ImmSet;
1154
1155 std::string ConstraintStr; // constraint: "=rm"
1156 std::string Name; // Operand name: [foo] with no []'s.
1157 public:
1158 ConstraintInfo(StringRef ConstraintStr, StringRef Name)
1159 : Flags(0), TiedOperand(-1), ConstraintStr(ConstraintStr.str()),
1160 Name(Name.str()) {
1161 ImmRange.Min = ImmRange.Max = 0;
1162 ImmRange.isConstrained = false;
1163 }
1164
1165 const std::string &getConstraintStr() const { return ConstraintStr; }
1166 const std::string &getName() const { return Name; }
1167 bool isReadWrite() const { return (Flags & CI_ReadWrite) != 0; }
1168 bool earlyClobber() { return (Flags & CI_EarlyClobber) != 0; }
1169 bool allowsRegister() const { return (Flags & CI_AllowsRegister) != 0; }
1170 bool allowsMemory() const { return (Flags & CI_AllowsMemory) != 0; }
1171
1172 /// Return true if this output operand has a matching
1173 /// (tied) input operand.
1174 bool hasMatchingInput() const { return (Flags & CI_HasMatchingInput) != 0; }
1175
1176 /// Return true if this input operand is a matching
1177 /// constraint that ties it to an output operand.
1178 ///
1179 /// If this returns true then getTiedOperand will indicate which output
1180 /// operand this is tied to.
1181 bool hasTiedOperand() const { return TiedOperand != -1; }
1182 unsigned getTiedOperand() const {
1183 assert(hasTiedOperand() && "Has no tied operand!");
1184 return (unsigned)TiedOperand;
1185 }
1186
1188 return (Flags & CI_ImmediateConstant) != 0;
1189 }
1190 bool isValidAsmImmediate(const llvm::APInt &Value) const {
1191 if (!ImmSet.empty())
1192 return Value.isSignedIntN(32) && ImmSet.contains(Value.getZExtValue());
1193 return !ImmRange.isConstrained ||
1194 (Value.sge(ImmRange.Min) && Value.sle(ImmRange.Max));
1195 }
1196
1204 ImmRange.Min = Min;
1205 ImmRange.Max = Max;
1206 ImmRange.isConstrained = true;
1207 }
1210 ImmSet.insert_range(Exacts);
1211 }
1212 void setRequiresImmediate(int Exact) {
1214 ImmSet.insert(Exact);
1215 }
1219
1220 /// Indicate that this is an input operand that is tied to
1221 /// the specified output operand.
1222 ///
1223 /// Copy over the various constraint information from the output.
1224 void setTiedOperand(unsigned N, ConstraintInfo &Output) {
1225 Output.setHasMatchingInput();
1226 Flags = Output.Flags;
1227 TiedOperand = N;
1228 // Don't copy Name or constraint string.
1229 }
1230
1231 // For output operand constraints, the target can set bounds to indicate
1232 // that the result value is guaranteed to fall within a certain range.
1233 // This will cause corresponding assertions to be emitted that will allow
1234 // for potential optimization based of that guarantee.
1235 //
1236 // NOTE: This re-uses the `ImmRange` fields to store the range, which are
1237 // otherwise unused for constraint types used for output operands.
1238 void setOutputOperandBounds(unsigned Min, unsigned Max) {
1239 ImmRange.Min = Min;
1240 ImmRange.Max = Max;
1242 }
1243 std::optional<std::pair<unsigned, unsigned>>
1245 return (Flags & CI_OutputOperandBounds) != 0
1246 ? std::make_pair(ImmRange.Min, ImmRange.Max)
1247 : std::optional<std::pair<unsigned, unsigned>>();
1248 }
1249 };
1250
1251 /// Validate register name used for global register variables.
1252 ///
1253 /// This function returns true if the register passed in RegName can be used
1254 /// for global register variables on this target. In addition, it returns
1255 /// true in HasSizeMismatch if the size of the register doesn't match the
1256 /// variable size passed in RegSize.
1257 virtual bool validateGlobalRegisterVariable(StringRef RegName,
1258 unsigned RegSize,
1259 bool &HasSizeMismatch) const {
1260 HasSizeMismatch = false;
1261 return true;
1262 }
1263
1264 // validateOutputConstraint, validateInputConstraint - Checks that
1265 // a constraint is valid and provides information about it.
1266 // FIXME: These should return a real error instead of just true/false.
1267 bool validateOutputConstraint(ConstraintInfo &Info) const;
1268 bool validateInputConstraint(MutableArrayRef<ConstraintInfo> OutputConstraints,
1269 ConstraintInfo &info) const;
1270
1271 virtual bool validateOutputSize(const llvm::StringMap<bool> &FeatureMap,
1272 StringRef /*Constraint*/,
1273 unsigned /*Size*/) const {
1274 return true;
1275 }
1276
1277 virtual bool validateInputSize(const llvm::StringMap<bool> &FeatureMap,
1278 StringRef /*Constraint*/,
1279 unsigned /*Size*/) const {
1280 return true;
1281 }
1282 virtual bool
1283 validateConstraintModifier(StringRef /*Constraint*/,
1284 char /*Modifier*/,
1285 unsigned /*Size*/,
1286 std::string &/*SuggestedModifier*/) const {
1287 return true;
1288 }
1289 virtual bool
1290 validateAsmConstraint(const char *&Name,
1291 TargetInfo::ConstraintInfo &info) const = 0;
1292
1293 bool resolveSymbolicName(const char *&Name,
1294 ArrayRef<ConstraintInfo> OutputConstraints,
1295 unsigned &Index) const;
1296
1297 std::string
1298 simplifyConstraint(StringRef Constraint,
1299 SmallVectorImpl<ConstraintInfo> *OutCons = nullptr) const;
1300
1301 // Constraint parm will be left pointing at the last character of
1302 // the constraint. In practice, it won't be changed unless the
1303 // constraint is longer than one character.
1304 virtual std::string convertConstraint(const char *&Constraint) const {
1305 // 'p' defaults to 'r', but can be overridden by targets.
1306 if (*Constraint == 'p')
1307 return std::string("r");
1308 return std::string(1, *Constraint);
1309 }
1310
1311 /// Replace some escaped characters with another string based on
1312 /// target-specific rules
1313 virtual std::optional<std::string> handleAsmEscapedChar(char C) const {
1314 return std::nullopt;
1315 }
1316
1317 /// Returns a string of target-specific clobbers, in LLVM format.
1318 virtual std::string_view getClobbers() const = 0;
1319
1320 /// Returns true if NaN encoding is IEEE 754-2008.
1321 /// Only MIPS allows a different encoding.
1322 virtual bool isNan2008() const {
1323 return true;
1324 }
1325
1326 /// Returns the target triple of the primary target.
1327 const llvm::Triple &getTriple() const {
1328 return Triple;
1329 }
1330
1331 /// Returns true if the target's processor is compatible with the processor
1332 /// named by \p Name, i.e. \p Name names this target's processor or a
1333 /// compatible processor.
1334 virtual bool isProcessorName(StringRef Name) const { return false; }
1335
1336 const char *getDataLayoutString() const {
1337 assert(!DataLayoutString.empty() && "Uninitialized DataLayout!");
1338 return DataLayoutString.c_str();
1339 }
1340
1342 const char * const Aliases[5];
1343 const char * const Register;
1344 };
1345
1347 const char * const Names[5];
1348 const unsigned RegNum;
1349 };
1350
1351 /// Does this target support "protected" visibility?
1352 ///
1353 /// Any target which dynamic libraries will naturally support
1354 /// something like "default" (meaning that the symbol is visible
1355 /// outside this shared object) and "hidden" (meaning that it isn't)
1356 /// visibilities, but "protected" is really an ELF-specific concept
1357 /// with weird semantics designed around the convenience of dynamic
1358 /// linker implementations. Which is not to suggest that there's
1359 /// consistent target-independent semantics for "default" visibility
1360 /// either; the entire thing is pretty badly mangled.
1361 virtual bool hasProtectedVisibility() const { return true; }
1362
1363 /// Does this target aim for semantic compatibility with
1364 /// Microsoft C++ code using dllimport/export attributes?
1365 virtual bool shouldDLLImportComdatSymbols() const {
1366 return getTriple().isWindowsMSVCEnvironment() ||
1367 getTriple().isWindowsItaniumEnvironment() || getTriple().isPS();
1368 }
1369
1370 // Does this target have PS4 specific dllimport/export handling?
1371 virtual bool hasPS4DLLImportExport() const {
1372 return getTriple().isPS() ||
1373 // Windows Itanium support allows for testing the SCEI flavour of
1374 // dllimport/export handling on a Windows system.
1375 (getTriple().isWindowsItaniumEnvironment() &&
1376 getTriple().getVendor() == llvm::Triple::SCEI);
1377 }
1378
1379 /// Set forced language options.
1380 ///
1381 /// Apply changes to the target information with respect to certain
1382 /// language options which change the target configuration and adjust
1383 /// the language based on the target options where applicable.
1384 virtual void adjust(DiagnosticsEngine &Diags, LangOptions &Opts,
1385 const TargetInfo *Aux);
1386
1387 /// Initialize the map with the default set of target features for the
1388 /// CPU this should include all legal feature strings on the target.
1389 ///
1390 /// \return False on error (invalid features).
1391 virtual bool initFeatureMap(llvm::StringMap<bool> &Features,
1392 DiagnosticsEngine &Diags, StringRef CPU,
1393 const std::vector<std::string> &FeatureVec) const;
1394
1395 /// Get the ABI currently in use.
1396 virtual StringRef getABI() const { return StringRef(); }
1397
1398 /// Get the C++ ABI currently in use.
1400 return TheCXXABI;
1401 }
1402
1403 /// Should the Microsoft mangling scheme be used for C Calling Convention.
1407
1408 /// Target the specified CPU.
1409 ///
1410 /// \return False on error (invalid CPU name).
1411 virtual bool setCPU(StringRef Name) { return false; }
1412
1413 /// Fill a SmallVectorImpl with the valid values to setCPU.
1414 virtual void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const {}
1415
1416 /// Fill a SmallVectorImpl with the valid values for tuning CPU.
1418 fillValidCPUList(Values);
1419 }
1420
1421 /// Determine whether this TargetInfo supports the given CPU name.
1422 virtual bool isValidCPUName(StringRef Name) const {
1423 return true;
1424 }
1425
1426 /// Determine whether this TargetInfo supports the given CPU name for
1427 /// tuning.
1428 virtual bool isValidTuneCPUName(StringRef Name) const {
1429 return isValidCPUName(Name);
1430 }
1431
1432 virtual ParsedTargetAttr parseTargetAttr(StringRef Str) const;
1433
1434 /// Determine whether this TargetInfo supports tune in target attribute.
1435 virtual bool supportsTargetAttributeTune() const {
1436 return false;
1437 }
1438
1439 /// Use the specified ABI.
1440 ///
1441 /// \return False on error (invalid ABI name).
1442 virtual bool setABI(const std::string &Name) {
1443 return false;
1444 }
1445
1446 /// Use the specified unit for FP math.
1447 ///
1448 /// \return False on error (invalid unit name).
1449 virtual bool setFPMath(StringRef Name) {
1450 return false;
1451 }
1452
1453 /// Check if target has a given feature enabled
1454 virtual bool hasFeatureEnabled(const llvm::StringMap<bool> &Features,
1455 StringRef Name) const {
1456 return Features.lookup(Name);
1457 }
1458
1459 /// Enable or disable a specific target feature;
1460 /// the feature name must be valid.
1461 virtual void setFeatureEnabled(llvm::StringMap<bool> &Features,
1462 StringRef Name,
1463 bool Enabled) const {
1464 Features[Name] = Enabled;
1465 }
1466
1467 /// Determine whether this TargetInfo supports the given feature.
1468 virtual bool isValidFeatureName(StringRef Feature) const {
1469 return true;
1470 }
1471
1472 /// Returns true if feature has an impact on target code
1473 /// generation.
1474 virtual bool doesFeatureAffectCodeGen(StringRef Feature) const {
1475 return true;
1476 }
1477
1479 public:
1485
1486 const char *getSignReturnAddrStr() const {
1487 switch (SignReturnAddr) {
1489 return "none";
1491 return "non-leaf";
1493 return "all";
1494 }
1495 llvm_unreachable("Unexpected SignReturnAddressScopeKind");
1496 }
1497
1498 const char *getSignKeyStr() const {
1499 switch (SignKey) {
1501 return "a_key";
1503 return "b_key";
1504 }
1505 llvm_unreachable("Unexpected SignReturnAddressKeyKind");
1506 }
1507
1509 : SignReturnAddr(LangOptions::SignReturnAddressScopeKind::None),
1510 SignKey(LangOptions::SignReturnAddressKeyKind::AKey),
1513
1528 };
1529
1530 /// Determine if the Architecture in this TargetInfo supports branch
1531 /// protection
1532 virtual bool isBranchProtectionSupportedArch(StringRef Arch) const {
1533 return false;
1534 }
1535
1536 /// Determine if this TargetInfo supports the given branch protection
1537 /// specification
1538 virtual bool validateBranchProtection(StringRef Spec, StringRef Arch,
1540 const LangOptions &LO,
1541 StringRef &Err) const {
1542 Err = "";
1543 return false;
1544 }
1545
1546 /// Perform initialization based on the user configured
1547 /// set of features (e.g., +sse4).
1548 ///
1549 /// The list is guaranteed to have at most one entry per feature.
1550 ///
1551 /// The target may modify the features list, to change which options are
1552 /// passed onwards to the backend.
1553 /// FIXME: This part should be fixed so that we can change handleTargetFeatures
1554 /// to merely a TargetInfo initialization routine.
1555 ///
1556 /// \return False on error.
1557 virtual bool handleTargetFeatures(std::vector<std::string> &Features,
1558 DiagnosticsEngine &Diags) {
1559 return true;
1560 }
1561
1562 /// Determine whether the given target has the given feature.
1563 virtual bool hasFeature(StringRef Feature) const {
1564 return false;
1565 }
1566
1567 /// Determine whether the given target feature is read only.
1568 bool isReadOnlyFeature(StringRef Feature) const {
1569 return ReadOnlyFeatures.count(Feature);
1570 }
1571
1572 /// Identify whether this target supports multiversioning of functions,
1573 /// which requires support for cpu_supports and cpu_is functionality.
1575 return getTriple().isX86() || getTriple().isAArch64() ||
1576 getTriple().isRISCV() || getTriple().isOSAIX();
1577 }
1578
1579 /// Identify whether this target supports IFuncs.
1580 bool supportsIFunc() const {
1581 if (getTriple().isOSBinFormatMachO())
1582 return true;
1583 if (getTriple().isOSWindows() && getTriple().isAArch64())
1584 return true;
1585 if (getTriple().getArch() == llvm::Triple::ArchType::avr)
1586 return true;
1587 if (getTriple().isOSAIX())
1588 return getTriple().getOSMajorVersion() == 0 ||
1589 getTriple().getOSVersion() >= VersionTuple(7, 2);
1590 return getTriple().isOSBinFormatELF() &&
1591 ((getTriple().isOSLinux() && !getTriple().isMusl()) ||
1592 getTriple().isOSFreeBSD());
1593 }
1594
1595 // Default encoding on z/OS is IBM-1047 and UTF-8 otherwise
1597 if (getTriple().getOS() == llvm::Triple::ZOS)
1598 return "IBM-1047";
1599 return "UTF-8";
1600 }
1601
1602 // Identify whether this target supports __builtin_cpu_supports and
1603 // __builtin_cpu_is.
1604 virtual bool supportsCpuSupports() const { return false; }
1605 virtual bool supportsCpuIs() const { return false; }
1606 virtual bool supportsCpuInit() const { return false; }
1607
1608 // Validate the contents of the __builtin_cpu_supports(const char*)
1609 // argument.
1610 virtual bool validateCpuSupports(StringRef Name) const { return false; }
1611
1612 // Return the target-specific priority for features/cpus/vendors so
1613 // that they can be properly sorted for checking.
1614 virtual llvm::APInt getFMVPriority(ArrayRef<StringRef> Features) const {
1615 return llvm::APInt::getZero(32);
1616 }
1617
1618 // Validate the contents of the __builtin_cpu_is(const char*)
1619 // argument.
1620 virtual bool validateCpuIs(StringRef Name) const { return false; }
1621
1622 // Validate a cpu_dispatch/cpu_specific CPU option, which is a different list
1623 // from cpu_is, since it checks via features rather than CPUs directly.
1624 virtual bool validateCPUSpecificCPUDispatch(StringRef Name) const {
1625 return false;
1626 }
1627
1628 // Get the character to be added for mangling purposes for cpu_specific.
1629 virtual char CPUSpecificManglingCharacter(StringRef Name) const {
1630 llvm_unreachable(
1631 "cpu_specific Multiversioning not implemented on this target");
1632 }
1633
1634 // Get the value for the 'tune-cpu' flag for a cpu_specific variant with the
1635 // programmer-specified 'Name'.
1636 virtual StringRef getCPUSpecificTuneName(StringRef Name) const {
1637 llvm_unreachable(
1638 "cpu_specific Multiversioning not implemented on this target");
1639 }
1640
1641 // Get a list of the features that make up the CPU option for
1642 // cpu_specific/cpu_dispatch so that it can be passed to llvm as optimization
1643 // options.
1645 StringRef Name, llvm::SmallVectorImpl<StringRef> &Features) const {
1646 llvm_unreachable(
1647 "cpu_specific Multiversioning not implemented on this target");
1648 }
1649
1650 // Get the cache line size of a given cpu. This method switches over
1651 // the given cpu and returns "std::nullopt" if the CPU is not found.
1652 virtual std::optional<unsigned> getCPUCacheLineSize() const {
1653 return std::nullopt;
1654 }
1655
1656 // Returns maximal number of args passed in registers.
1657 unsigned getRegParmMax() const {
1658 assert(RegParmMax < 7 && "RegParmMax value is larger than AST can handle");
1659 return RegParmMax;
1660 }
1661
1662 /// Whether the target supports thread-local storage.
1663 bool isTLSSupported() const {
1664 return TLSSupported;
1665 }
1666
1667 /// Return the maximum alignment (in bits) of a TLS variable
1668 ///
1669 /// Gets the maximum alignment (in bits) of a TLS variable on this target.
1670 /// Returns zero if there is no such constraint.
1671 unsigned getMaxTLSAlign() const { return MaxTLSAlign; }
1672
1673 /// Whether target supports variable-length arrays.
1674 bool isVLASupported() const { return VLASupported; }
1675
1676 /// Whether the target supports SEH __try.
1677 bool isSEHTrySupported() const {
1678 return getTriple().isOSWindows() &&
1679 (getTriple().isX86() ||
1680 getTriple().getArch() == llvm::Triple::aarch64 ||
1681 getTriple().isThumb());
1682 }
1683
1684 /// Return true if {|} are normal characters in the asm string.
1685 ///
1686 /// If this returns false (the default), then {abc|xyz} is syntax
1687 /// that says that when compiling for asm variant #0, "abc" should be
1688 /// generated, but when compiling for asm variant #1, "xyz" should be
1689 /// generated.
1690 bool hasNoAsmVariants() const {
1691 return NoAsmVariants;
1692 }
1693
1694 /// Return the register number that __builtin_eh_return_regno would
1695 /// return with the specified argument.
1696 /// This corresponds with TargetLowering's getExceptionPointerRegister
1697 /// and getExceptionSelectorRegister in the backend.
1698 virtual int getEHDataRegisterNumber(unsigned RegNo) const {
1699 return -1;
1700 }
1701
1702 /// Return the section to use for C++ static initialization functions.
1703 virtual const char *getStaticInitSectionSpecifier() const {
1704 return nullptr;
1705 }
1706
1707 const LangASMap &getAddressSpaceMap() const { return *AddrSpaceMap; }
1708 unsigned getTargetAddressSpace(LangAS AS) const {
1709 if (isTargetAddressSpace(AS))
1710 return toTargetAddressSpace(AS);
1711 return getAddressSpaceMap()[AS];
1712 }
1713
1714 /// Determine whether the given pointer-authentication key is valid.
1715 ///
1716 /// The value has been coerced to type 'int'.
1717 virtual bool validatePointerAuthKey(const llvm::APSInt &value) const;
1718
1719 /// Map from the address space field in builtin description strings to the
1720 /// language address space.
1721 virtual LangAS getOpenCLBuiltinAddressSpace(unsigned AS) const {
1722 return getLangASFromTargetAS(AS);
1723 }
1724
1725 /// Map from the address space field in builtin description strings to the
1726 /// language address space.
1727 virtual LangAS getCUDABuiltinAddressSpace(unsigned AS) const {
1728 return getLangASFromTargetAS(AS);
1729 }
1730
1731 /// Return an AST address space which can be used opportunistically
1732 /// for constant global memory. It must be possible to convert pointers into
1733 /// this address space to LangAS::Default. If no such address space exists,
1734 /// this may return std::nullopt, and such optimizations will be disabled.
1735 virtual std::optional<LangAS> getConstantAddressSpace() const {
1736 return LangAS::Default;
1737 }
1738
1739 // access target-specific GPU grid values that must be consistent between
1740 // host RTL (plugin), deviceRTL and clang.
1741 virtual const llvm::omp::GV &getGridValue() const {
1742 llvm_unreachable("getGridValue not implemented on this target");
1743 }
1744
1745 /// Retrieve the name of the platform as it is used in the
1746 /// availability attribute.
1747 StringRef getPlatformName() const { return PlatformName; }
1748
1749 /// Retrieve the minimum desired version of the platform, to
1750 /// which the program should be compiled.
1751 VersionTuple getPlatformMinVersion() const { return PlatformMinVersion; }
1752
1753 bool isBigEndian() const { return BigEndian; }
1754 bool isLittleEndian() const { return !BigEndian; }
1755
1756 /// Whether the option -fextend-arguments={32,64} is supported on the target.
1757 virtual bool supportsExtendIntArgs() const { return false; }
1758
1759 /// Controls if __arithmetic_fence is supported in the targeted backend.
1760 virtual bool checkArithmeticFenceSupported() const { return false; }
1761
1762 /// Gets the default calling convention for the given target.
1763 ///
1764 /// This function does not take into account any user options to override the
1765 /// default calling convention. For that, see
1766 /// ASTContext::getDefaultCallingConvention().
1768 // Not all targets will specify an explicit calling convention that we can
1769 // express. This will always do the right thing, even though it's not
1770 // an explicit calling convention.
1771 return CC_C;
1772 }
1773
1774 /// Get the default atomic options.
1776
1783
1784 /// Determines whether a given calling convention is valid for the
1785 /// target. A calling convention can either be accepted, produce a warning
1786 /// and be substituted with the default calling convention, or (someday)
1787 /// produce an error (such as using thiscall on a non-instance function).
1789 switch (CC) {
1790 default:
1791 return CCCR_Warning;
1792 case CC_C:
1793 return CCCR_OK;
1794 }
1795 }
1796
1802
1803 virtual CallingConvKind getCallingConvKind(bool ClangABICompat4) const;
1804
1805 /// Controls whether explicitly defaulted (`= default`) special member
1806 /// functions disqualify something from being POD-for-the-purposes-of-layout.
1807 /// Historically, Clang didn't consider these acceptable for POD, but GCC
1808 /// does. So in newer Clang ABIs they are acceptable for POD to be compatible
1809 /// with GCC/Itanium ABI, and remains disqualifying for targets that need
1810 /// Clang backwards compatibility rather than GCC/Itanium ABI compatibility.
1811 virtual bool areDefaultedSMFStillPOD(const LangOptions&) const;
1812
1813 /// Returns whether the target's ABI guarantees that a class's vtable has a
1814 /// unique address program-wide.
1815 virtual VTableUniquenessKind getVTableUniqueness() const;
1816
1817 /// Controls whether global operator delete is called by the deleting
1818 /// destructor or at the point where ::delete was called. Historically Clang
1819 /// called global operator delete outside of the deleting destructor for both
1820 /// Microsoft and Itanium ABI. In Clang 21 support for ::delete was aligned
1821 /// with Microsoft ABI, so it will call global operator delete in the deleting
1822 /// destructor body.
1823 virtual bool callGlobalDeleteInDeletingDtor(const LangOptions &) const;
1824
1825 /// Controls whether to emit MSVC vector deleting destructors. The support for
1826 /// vector deleting affects vtable layout and therefore is an ABI breaking
1827 /// change. The support was only implemented at Clang 22 timeframe.
1828 virtual bool emitVectorDeletingDtors(const LangOptions &) const;
1829
1830 /// Controls if __builtin_longjmp / __builtin_setjmp can be lowered to
1831 /// llvm.eh.sjlj.longjmp / llvm.eh.sjlj.setjmp.
1832 virtual bool hasSjLjLowering() const {
1833 return false;
1834 }
1835
1836 /// Check if the target supports CFProtection branch.
1837 virtual bool
1838 checkCFProtectionBranchSupported(DiagnosticsEngine &Diags) const;
1839
1840 /// Get the target default CFBranchLabelScheme scheme
1841 virtual CFBranchLabelSchemeKind getDefaultCFBranchLabelScheme() const;
1842
1843 virtual bool
1844 checkCFBranchLabelSchemeSupported(const CFBranchLabelSchemeKind Scheme,
1845 DiagnosticsEngine &Diags) const;
1846
1847 /// Check if the target supports CFProtection return.
1848 virtual bool
1849 checkCFProtectionReturnSupported(DiagnosticsEngine &Diags) const;
1850
1851 /// Whether target allows to overalign ABI-specified preferred alignment
1852 virtual bool allowsLargerPreferedTypeAlignment() const { return true; }
1853
1854 /// Whether target defaults to the `power` alignment rules of AIX.
1855 virtual bool defaultsToAIXPowerAlignment() const { return false; }
1856
1857 /// Set supported OpenCL extensions and optional core features.
1858 virtual void setSupportedOpenCLOpts() {}
1859
1860 virtual void supportAllOpenCLOpts(bool V = true) {
1861#define OPENCLEXTNAME(Ext) \
1862 setFeatureEnabled(getTargetOpts().OpenCLFeaturesMap, #Ext, V);
1863#include "clang/Basic/OpenCLExtensions.def"
1864 }
1865
1866 /// Set supported OpenCL extensions as written on command line
1868 for (const auto &Ext : getTargetOpts().OpenCLExtensionsAsWritten) {
1869 bool IsPrefixed = (Ext[0] == '+' || Ext[0] == '-');
1870 std::string Name = IsPrefixed ? Ext.substr(1) : Ext;
1871 bool V = IsPrefixed ? Ext[0] == '+' : true;
1872
1873 if (Name == "all") {
1875 continue;
1876 }
1877
1878 getTargetOpts().OpenCLFeaturesMap[Name] = V;
1879 }
1880 }
1881
1882 /// Set features that depend on other features.
1883 virtual void setDependentOpenCLOpts();
1884
1885 /// Get supported OpenCL extensions and optional core features.
1886 llvm::StringMap<bool> &getSupportedOpenCLOpts() {
1887 return getTargetOpts().OpenCLFeaturesMap;
1888 }
1889
1890 /// Get const supported OpenCL extensions and optional core features.
1891 const llvm::StringMap<bool> &getSupportedOpenCLOpts() const {
1892 return getTargetOpts().OpenCLFeaturesMap;
1893 }
1894
1895 /// Get address space for OpenCL type.
1896 virtual LangAS getOpenCLTypeAddrSpace(OpenCLTypeKind TK) const;
1897
1898 /// \returns Target specific vtbl ptr address space.
1899 virtual unsigned getVtblPtrAddressSpace() const {
1900 return 0;
1901 }
1902
1903 /// \returns If a target requires an address within a target specific address
1904 /// space \p AddressSpace to be converted in order to be used, then return the
1905 /// corresponding target specific DWARF address space.
1906 ///
1907 /// \returns Otherwise return std::nullopt and no conversion will be emitted
1908 /// in the DWARF.
1909 virtual std::optional<unsigned> getDWARFAddressSpace(unsigned AddressSpace)
1910 const {
1911 return std::nullopt;
1912 }
1913
1914 /// \returns The version of the SDK which was used during the compilation if
1915 /// one was specified, or an empty version otherwise.
1916 const llvm::VersionTuple &getSDKVersion() const {
1917 return getTargetOpts().SDKVersion;
1918 }
1919
1920 /// Check the target is valid after it is fully initialized.
1921 virtual bool validateTarget(DiagnosticsEngine &Diags) const {
1922 return true;
1923 }
1924
1925 /// Check that OpenCL target has valid options setting based on OpenCL
1926 /// version.
1927 virtual bool validateOpenCLTarget(const LangOptions &Opts,
1928 DiagnosticsEngine &Diags) const;
1929
1930 virtual void setAuxTarget(const TargetInfo *Aux) {}
1931
1933
1934 /// Whether target allows debuginfo types for decl only variables/functions.
1935 virtual bool allowDebugInfoForExternalRef() const { return false; }
1936
1937 /// Returns the darwin target variant triple, the variant of the deployment
1938 /// target for which the code is being compiled.
1939 const llvm::Triple *getDarwinTargetVariantTriple() const {
1941 }
1942
1943 /// Returns the version of the darwin target variant SDK which was used during
1944 /// the compilation if one was specified, or an empty version otherwise.
1945 std::optional<VersionTuple> getDarwinTargetVariantSDKVersion() const {
1946 return !getTargetOpts().DarwinTargetVariantSDKVersion.empty()
1947 ? getTargetOpts().DarwinTargetVariantSDKVersion
1948 : std::optional<VersionTuple>();
1949 }
1950
1951 /// Whether to support HIP image/texture API's.
1952 virtual bool hasHIPImageSupport() const { return true; }
1953
1954 /// The first value in the pair is the minimum offset between two objects to
1955 /// avoid false sharing (destructive interference). The second value in the
1956 /// pair is maximum size of contiguous memory to promote true sharing
1957 /// (constructive interference). Neither of these values are considered part
1958 /// of the ABI and can be changed by targets at any time.
1959 virtual std::pair<unsigned, unsigned> hardwareInterferenceSizes() const {
1960 return std::make_pair(64, 64);
1961 }
1962
1963protected:
1964 /// Copy type and layout related info.
1965 void copyAuxTarget(const TargetInfo *Aux);
1966 virtual uint64_t getPointerWidthV(LangAS AddrSpace) const {
1967 return PointerWidth;
1968 }
1969 virtual uint64_t getPointerAlignV(LangAS AddrSpace) const {
1970 return PointerAlign;
1971 }
1972 virtual enum IntType getPtrDiffTypeV(LangAS AddrSpace) const {
1973 return PtrDiffType;
1974 }
1977 virtual ArrayRef<AddlRegName> getGCCAddlRegNames() const { return {}; }
1978
1979private:
1980 // Assert the values for the fractional and integral bits for each fixed point
1981 // type follow the restrictions given in clause 6.2.6.3 of N1169.
1982 void CheckFixedPointBits() const;
1983};
1984
1985unsigned Microsoft64BitMinGlobalAlign(uint64_t TypeSize);
1986
1987namespace targets {
1988std::unique_ptr<clang::TargetInfo>
1989AllocateTarget(const llvm::Triple &Triple, const clang::TargetOptions &Opts);
1990} // namespace targets
1991
1992} // end namespace clang
1993
1994#endif
#define V(N, I)
Provides definitions for the various language-specific address spaces.
Provides LLVM's BitmaskEnum facility to enumeration types declared in namespace clang.
Defines enum values for all the target-independent builtin functions.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::LangOptions interface.
static unsigned getCharWidth(tok::TokenKind kind, const TargetInfo &Target)
static StringRef getTriple(const Command &Job)
Defines various enumerations that describe declaration and type specifiers.
Defines the TargetCXXABI class, which abstracts details of the C++ ABI that we're targeting.
Defines the clang::TargetOptions class.
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
Concrete class used by the front-end to report problems and issues.
Definition Diagnostic.h:234
The type of a lookup table which maps from language-specific address spaces to target-specific ones.
FPEvalMethodKind
Possible float expression evaluation method choices.
@ FEM_Source
Use the declared type for fp arithmetic.
@ NonLeaf
Sign the return address of functions that spill LR.
@ All
Sign the return address of all functions,.
@ BKey
Return address signing uses APIB key.
@ AKey
Return address signing uses APIA key.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
bool isSignReturnAddressWithAKey() const
Check if return address signing uses AKey.
bool hasSignReturnAddress() const
Check if return address signing is enabled.
bool isSignReturnAddressScopeAll() const
Check if leaf functions are also signed.
The basic abstraction for the target C++ ABI.
LangOptions::SignReturnAddressScopeKind SignReturnAddr
BranchProtectionInfo(const LangOptions &LangOpts)
LangOptions::SignReturnAddressKeyKind SignKey
const char * getSignReturnAddrStr() const
Exposes information about the current target.
Definition TargetInfo.h:227
const LangASMap & getAddressSpaceMap() const
bool vectorsAreElementAligned() const
True if vectors are element-aligned for this target.
Definition TargetInfo.h:880
unsigned getNewAlign() const
Return the largest alignment for which a suitably-sized allocation with 'operator new(size_t)' is gua...
Definition TargetInfo.h:773
virtual bool supportsCpuSupports() const
unsigned getUnsignedLongFractScale() const
getUnsignedLongFractScale - Return the number of fractional bits in a 'unsigned long _Fract' type.
Definition TargetInfo.h:677
IntType getUnsignedPtrDiffType(LangAS AddrSpace) const
Definition TargetInfo.h:418
virtual std::optional< unsigned > getDWARFAddressSpace(unsigned AddressSpace) const
TargetOptions & getTargetOpts() const
Retrieve the target options.
Definition TargetInfo.h:333
virtual std::optional< std::string > handleAsmEscapedChar(char C) const
Replace some escaped characters with another string based on target-specific rules.
unsigned getLongFractAlign() const
Definition TargetInfo.h:597
virtual bool validateCpuIs(StringRef Name) const
virtual bool hasLongDoubleType() const
Determine whether the long double type is supported on this target.
Definition TargetInfo.h:742
unsigned getShortAccumAlign() const
Definition TargetInfo.h:572
virtual bool supportsCpuInit() const
virtual unsigned getExnObjectAlignment() const
Return the alignment (in bits) of the thrown exception object.
Definition TargetInfo.h:890
virtual bool hasBitIntType() const
Determine whether the _BitInt type is supported on this target.
Definition TargetInfo.h:696
bool resolveSymbolicName(const char *&Name, ArrayRef< ConstraintInfo > OutputConstraints, unsigned &Index) const
virtual bool hasFullBFloat16Type() const
Determine whether the BFloat type is fully supported on this target, i.e arithemtic operations.
Definition TargetInfo.h:736
unsigned getLargeArrayAlign() const
Definition TargetInfo.h:858
unsigned getIbm128Align() const
Definition TargetInfo.h:831
const char * getMCountName() const
Returns the name of the mcount instrumentation function.
Definition TargetInfo.h:939
TargetInfo(const llvm::Triple &T)
static TargetInfo * CreateTargetInfo(DiagnosticsEngine &Diags, TargetOptions &Opts)
Construct a target for the given options.
Definition Targets.cpp:840
unsigned getShortWidth() const
getShortWidth/Align - Return the size of 'signed short' and 'unsigned short' for this target,...
Definition TargetInfo.h:532
unsigned getUnsignedAccumScale() const
getUnsignedAccumScale/IBits - Return the number of fractional/integral bits in a 'unsigned _Accum' ty...
Definition TargetInfo.h:631
unsigned getIntAlign() const
Definition TargetInfo.h:538
virtual ArrayRef< AddlRegName > getGCCAddlRegNames() const
unsigned getUnsignedAccumIBits() const
Definition TargetInfo.h:634
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
virtual const char * getFloat128Mangling() const
Return the mangled code of __float128.
Definition TargetInfo.h:838
unsigned getAccumWidth() const
getAccumWidth/Align - Return the size of 'signed _Accum' and 'unsigned _Accum' for this target,...
Definition TargetInfo.h:576
IntType getUIntPtrType() const
Definition TargetInfo.h:422
bool useLeadingZeroLengthBitfield() const
Check whether zero length bitfield alignment is respected if they are leading members.
Definition TargetInfo.h:969
const LangASMap * AddrSpaceMap
Definition TargetInfo.h:260
const char * UserLabelPrefix
Definition TargetInfo.h:255
IntType getInt64Type() const
Definition TargetInfo.h:429
unsigned getMaxAtomicInlineWidth() const
Return the maximum width lock-free atomic operation which can be inlined given the supported features...
Definition TargetInfo.h:865
bool HasMicrosoftRecordLayout
Definition TargetInfo.h:301
virtual bool supportSourceEvalMethod() const
Definition TargetInfo.h:853
unsigned getUnsignedFractScale() const
getUnsignedFractScale - Return the number of fractional bits in a 'unsigned _Fract' type.
Definition TargetInfo.h:671
bool hasAlignMac68kSupport() const
Check whether this target support '#pragma options align=mac68k'.
Definition TargetInfo.h:994
StringRef getDefaultOrdinaryLiteralEncoding() const
virtual void getCPUSpecificCPUDispatchFeatures(StringRef Name, llvm::SmallVectorImpl< StringRef > &Features) const
unsigned getWCharAlign() const
Definition TargetInfo.h:780
virtual enum IntType getPtrDiffTypeV(LangAS AddrSpace) const
unsigned getLongAlign() const
Definition TargetInfo.h:543
virtual bool isCLZForZeroUndef() const
The __builtin_clz* and __builtin_ctz* built-in functions are specified to have undefined results for ...
unsigned HasAMDGPUTypes
Definition TargetInfo.h:291
virtual LangAS getCUDABuiltinAddressSpace(unsigned AS) const
Map from the address space field in builtin description strings to the language address space.
virtual bool setCPU(StringRef Name)
Target the specified CPU.
virtual LangAS getOpenCLBuiltinAddressSpace(unsigned AS) const
Map from the address space field in builtin description strings to the language address space.
virtual std::optional< LangAS > getConstantAddressSpace() const
Return an AST address space which can be used opportunistically for constant global memory.
const char * getDataLayoutString() const
unsigned getBitIntAlign(unsigned NumBits) const
Definition TargetInfo.h:564
std::optional< llvm::Triple > DarwinTargetVariantTriple
Definition TargetInfo.h:299
bool isReadOnlyFeature(StringRef Feature) const
Determine whether the given target feature is read only.
StringRef getPlatformName() const
Retrieve the name of the platform as it is used in the availability attribute.
virtual bool isBranchProtectionSupportedArch(StringRef Arch) const
Determine if the Architecture in this TargetInfo supports branch protection.
unsigned getLongLongAlign() const
Definition TargetInfo.h:548
virtual bool hasFeatureEnabled(const llvm::StringMap< bool > &Features, StringRef Name) const
Check if target has a given feature enabled.
virtual const char * getStaticInitSectionSpecifier() const
Return the section to use for C++ static initialization functions.
unsigned getDefaultAlignForAttributeAligned() const
Return the default alignment for attribute((aligned)) on this target, to be used if no alignment valu...
Definition TargetInfo.h:758
unsigned getBFloat16Width() const
getBFloat16Width/Align/Format - Return the size/align/format of '__bf16'.
Definition TargetInfo.h:803
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
Definition TargetInfo.h:340
@ AArch64ABIBuiltinVaList
__builtin_va_list as defined by the AArch64 ABI http://infocenter.arm.com/help/topic/com....
Definition TargetInfo.h:349
@ PowerABIBuiltinVaList
__builtin_va_list as defined by the Power ABI: https://www.power.org /resources/downloads/Power-Arch-...
Definition TargetInfo.h:354
@ AAPCSABIBuiltinVaList
__builtin_va_list as defined by ARM AAPCS ABI http://infocenter.arm.com
Definition TargetInfo.h:363
@ CharPtrBuiltinVaList
typedef char* __builtin_va_list;
Definition TargetInfo.h:342
@ VoidPtrBuiltinVaList
typedef void* __builtin_va_list;
Definition TargetInfo.h:345
@ X86_64ABIBuiltinVaList
__builtin_va_list as defined by the x86-64 ABI: http://refspecs.linuxbase.org/elf/x86_64-abi-0....
Definition TargetInfo.h:358
virtual size_t getMaxBitIntWidth() const
Definition TargetInfo.h:702
virtual bool setFPMath(StringRef Name)
Use the specified unit for FP math.
bool isSEHTrySupported() const
Whether the target supports SEH __try.
unsigned getChar32Width() const
getChar32Width/Align - Return the size of 'char32_t' for this target, in bits.
Definition TargetInfo.h:789
unsigned char RegParmMax
Definition TargetInfo.h:257
virtual std::optional< std::pair< unsigned, unsigned > > getVScaleRange(const LangOptions &LangOpts, ArmStreamingKind Mode, llvm::StringMap< bool > *FeatureMap=nullptr) const
Returns target-specific min and max values VScale_Range.
const llvm::Triple * getDarwinTargetVariantTriple() const
Returns the darwin target variant triple, the variant of the deployment target for which the code is ...
virtual uint64_t getNullPointerValue(LangAS AddrSpace) const
Get integer value for null pointer.
Definition TargetInfo.h:512
virtual ArrayRef< const char * > getGCCRegNames() const =0
unsigned getTypeWidth(IntType T) const
Return the width (in bits) of the specified integer type enum.
virtual std::optional< unsigned > getCPUCacheLineSize() const
unsigned getLongAccumScale() const
getLongAccumScale/IBits - Return the number of fractional/integral bits in a 'signed long _Accum' typ...
Definition TargetInfo.h:613
unsigned getLongFractScale() const
getLongFractScale - Return the number of fractional bits in a 'signed long _Fract' type.
Definition TargetInfo.h:660
unsigned getIbm128Width() const
getIbm128Width/Align/Format - Return the size/align/format of '__ibm128'.
Definition TargetInfo.h:830
uint64_t getPointerWidth(LangAS AddrSpace) const
Return the width of pointers on this target, for the specified address space.
Definition TargetInfo.h:496
virtual bool allowHalfArgsAndReturns() const
Whether half args and returns are supported.
Definition TargetInfo.h:721
unsigned getShortFractAlign() const
Definition TargetInfo.h:587
@ ARM_LDREX_W
half (16-bit)
@ ARM_LDREX_H
byte (8-bit)
@ ARM_LDREX_D
word (32-bit)
virtual unsigned getARMLDREXMask() const
unsigned getFractAlign() const
Definition TargetInfo.h:592
std::optional< unsigned > MaxBitIntWidth
Definition TargetInfo.h:297
const llvm::StringMap< bool > & getSupportedOpenCLOpts() const
Get const supported OpenCL extensions and optional core features.
virtual void setFeatureEnabled(llvm::StringMap< bool > &Features, StringRef Name, bool Enabled) const
Enable or disable a specific target feature; the feature name must be valid.
virtual std::pair< unsigned, unsigned > hardwareInterferenceSizes() const
The first value in the pair is the minimum offset between two objects to avoid false sharing (destruc...
virtual CallingConv getDefaultCallingConv() const
Gets the default calling convention for the given target.
bool useSignedCharForObjCBool() const
Check if the Objective-C built-in boolean type should be signed char.
Definition TargetInfo.h:948
virtual bool hasPS4DLLImportExport() const
AtomicOptions AtomicOpts
Definition TargetInfo.h:319
virtual bool hasInt128Type() const
Determine whether the __int128 type is supported on this target.
Definition TargetInfo.h:685
unsigned getAccumIBits() const
Definition TargetInfo.h:609
bool useObjCFPRetForRealType(FloatModeKind T) const
Check whether the given real type should use the "fpret" flavor of Objective-C message passing on thi...
virtual bool hasFastHalfType() const
Determine whether the target has fast native support for operations on half types.
Definition TargetInfo.h:718
virtual LangOptions::FPEvalMethodKind getFPEvalMethod() const
Return the value for the C99 FLT_EVAL_METHOD macro.
Definition TargetInfo.h:849
unsigned getHalfAlign() const
Definition TargetInfo.h:794
IntType getSigAtomicType() const
Definition TargetInfo.h:437
virtual bool validateOutputSize(const llvm::StringMap< bool > &FeatureMap, StringRef, unsigned) const
unsigned getAccumScale() const
getAccumScale/IBits - Return the number of fractional/integral bits in a 'signed _Accum' type.
Definition TargetInfo.h:608
virtual bool hasFloat16Type() const
Determine whether the _Float16 type is supported on this target.
Definition TargetInfo.h:727
unsigned getBFloat16Align() const
Definition TargetInfo.h:804
virtual CallingConvCheckResult checkCallingConvention(CallingConv CC) const
Determines whether a given calling convention is valid for the target.
std::string simplifyConstraint(StringRef Constraint, SmallVectorImpl< ConstraintInfo > *OutCons=nullptr) const
unsigned getMaxVectorAlign() const
Return the maximum vector alignment supported for the given target.
Definition TargetInfo.h:883
VersionTuple PlatformMinVersion
Definition TargetInfo.h:263
unsigned getChar16Width() const
getChar16Width/Align - Return the size of 'char16_t' for this target, in bits.
Definition TargetInfo.h:784
virtual unsigned getVtblPtrAddressSpace() const
virtual void setAuxTarget(const TargetInfo *Aux)
unsigned getLongAccumAlign() const
Definition TargetInfo.h:582
unsigned getIntWidth() const
getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for this target,...
Definition TargetInfo.h:537
unsigned getLargestOverSizedBitfieldContainer() const
Definition TargetInfo.h:979
IntType getPtrDiffType(LangAS AddrSpace) const
Definition TargetInfo.h:414
const char * MCountName
Definition TargetInfo.h:256
virtual llvm::SmallVector< Builtin::InfosShard > getTargetBuiltins() const =0
Return information about target-specific builtins for the current primary target, and info about whic...
virtual bool handleTargetFeatures(std::vector< std::string > &Features, DiagnosticsEngine &Diags)
Perform initialization based on the user configured set of features (e.g., +sse4).
bool isLittleEndian() const
unsigned getShortAccumIBits() const
Definition TargetInfo.h:602
bool hasUnalignedAccess() const
Return true iff unaligned accesses are a single instruction (rather than a synthesized sequence).
Definition TargetInfo.h:922
virtual const char * getIbm128Mangling() const
Return the mangled code of __ibm128.
Definition TargetInfo.h:841
unsigned HasBuiltinZOSVaList
Definition TargetInfo.h:276
unsigned getFloatWidth() const
getFloatWidth/Align/Format - Return the size/align/format of 'float'.
Definition TargetInfo.h:798
virtual ArrayRef< GCCRegAlias > getGCCRegAliases() const =0
std::optional< VersionTuple > getDarwinTargetVariantSDKVersion() const
Returns the version of the darwin target variant SDK which was used during the compilation if one was...
bool UseMicrosoftManglingForC
Definition TargetInfo.h:259
unsigned getLongAccumIBits() const
Definition TargetInfo.h:614
IntType getSizeType() const
Definition TargetInfo.h:395
IntType getWIntType() const
Definition TargetInfo.h:426
virtual void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const =0
===-— Other target property query methods -----------------------—===//
static IntType getCorrespondingUnsignedType(IntType T)
Definition TargetInfo.h:440
unsigned getLongAccumWidth() const
getLongAccumWidth/Align - Return the size of 'signed long _Accum' and 'unsigned long _Accum' for this...
Definition TargetInfo.h:581
virtual bool setABI(const std::string &Name)
Use the specified ABI.
void noSignedCharForObjCBool()
Definition TargetInfo.h:951
AtomicOptions getAtomicOpts() const
Get the default atomic options.
unsigned getHalfWidth() const
getHalfWidth/Align/Format - Return the size/align/format of 'half'.
Definition TargetInfo.h:793
virtual bool validateInputSize(const llvm::StringMap< bool > &FeatureMap, StringRef, unsigned) const
unsigned getShortAccumScale() const
getShortAccumScale/IBits - Return the number of fractional/integral bits in a 'signed short _Accum' t...
Definition TargetInfo.h:601
unsigned getBitIntWidth(unsigned NumBits) const
getBitIntAlign/Width - Return aligned size of '_BitInt' and 'unsigned _BitInt' for this target,...
Definition TargetInfo.h:561
unsigned getBoolAlign() const
Return the alignment of '_Bool' and C++ 'bool' for this target.
Definition TargetInfo.h:525
virtual bool defaultsToAIXPowerAlignment() const
Whether target defaults to the power alignment rules of AIX.
const llvm::fltSemantics & getDoubleFormat() const
Definition TargetInfo.h:810
virtual bool hasStrictFP() const
Determine whether constrained floating point is supported on this target.
Definition TargetInfo.h:749
unsigned char SSERegParmMax
Definition TargetInfo.h:257
unsigned HasUnalignedAccess
Definition TargetInfo.h:288
virtual char CPUSpecificManglingCharacter(StringRef Name) const
bool hasAMDGPUTypes() const
Returns whether or not the AMDGPU built-in types are available on this target.
virtual void fillValidTuneCPUList(SmallVectorImpl< StringRef > &Values) const
Fill a SmallVectorImpl with the valid values for tuning CPU.
unsigned char MaxAtomicPromoteWidth
Definition TargetInfo.h:253
virtual bool allowDebugInfoForExternalRef() const
Whether target allows debuginfo types for decl only variables/functions.
unsigned getCharAlign() const
Definition TargetInfo.h:528
VersionTuple getPlatformMinVersion() const
Retrieve the minimum desired version of the platform, to which the program should be compiled.
unsigned RealTypeUsesObjCFPRetMask
Definition TargetInfo.h:268
unsigned MaxOpenCLWorkGroupSize
Definition TargetInfo.h:295
unsigned getLongLongWidth() const
getLongLongWidth/Align - Return the size of 'signed long long' and 'unsigned long long' for this targ...
Definition TargetInfo.h:547
void resetDataLayout(StringRef DL)
Set the data layout to the given string.
unsigned getMaxOpenCLWorkGroupSize() const
Definition TargetInfo.h:885
virtual bool hasBuiltinAtomic(uint64_t AtomicSizeInBits, uint64_t AlignmentInBits) const
Returns true if the given target supports lock-free atomic operations at the specified width and alig...
Definition TargetInfo.h:871
bool isTLSSupported() const
Whether the target supports thread-local storage.
unsigned getZeroLengthBitfieldBoundary() const
Get the fixed alignment value in bits for a member that follows a zero length bitfield.
Definition TargetInfo.h:975
IntType getIntPtrType() const
Definition TargetInfo.h:421
uint32_t getARMCDECoprocMask() const
For ARM targets returns a mask defining which coprocessors are configured as Custom Datapath.
unsigned getMaxAlignedAttribute() const
Get the maximum alignment in bits for a static variable with aligned attribute.
Definition TargetInfo.h:985
IntType getInt16Type() const
Definition TargetInfo.h:433
virtual llvm::APInt getFMVPriority(ArrayRef< StringRef > Features) const
const llvm::fltSemantics & getHalfFormat() const
Definition TargetInfo.h:795
virtual bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &info) const =0
virtual void supportAllOpenCLOpts(bool V=true)
llvm::StringMap< bool > & getSupportedOpenCLOpts()
Get supported OpenCL extensions and optional core features.
StringRef PlatformName
Definition TargetInfo.h:262
virtual uint64_t getPointerAlignV(LangAS AddrSpace) const
virtual const char * getLongDoubleMangling() const
Return the mangled code of long double.
Definition TargetInfo.h:835
bool UseAddrSpaceMapMangling
Specify if mangling based on address space map should be used or not for language specific address sp...
Definition TargetInfo.h:392
virtual bool supportsExtendIntArgs() const
Whether the option -fextend-arguments={32,64} is supported on the target.
unsigned getLargeArrayMinWidth() const
Definition TargetInfo.h:857
unsigned getMaxTLSAlign() const
Return the maximum alignment (in bits) of a TLS variable.
virtual unsigned getRegisterWidth() const
Return the "preferred" register width on this target.
Definition TargetInfo.h:913
bool supportsIFunc() const
Identify whether this target supports IFuncs.
virtual bool isValidTuneCPUName(StringRef Name) const
Determine whether this TargetInfo supports the given CPU name for tuning.
virtual bool validateCpuSupports(StringRef Name) const
IntType getWCharType() const
Definition TargetInfo.h:425
unsigned ComplexLongDoubleUsesFP2Ret
Definition TargetInfo.h:270
IntType getUInt16Type() const
Definition TargetInfo.h:434
unsigned getChar16Align() const
Definition TargetInfo.h:785
virtual bool validateBranchProtection(StringRef Spec, StringRef Arch, BranchProtectionInfo &BPI, const LangOptions &LO, StringRef &Err) const
Determine if this TargetInfo supports the given branch protection specification.
virtual unsigned getMinGlobalAlign(uint64_t Size, bool HasNonWeakDef) const
getMinGlobalAlign - Return the minimum alignment of a global variable, unless its alignment is explic...
Definition TargetInfo.h:766
virtual bool supportsCpuIs() const
bool isBigEndian() const
virtual BuiltinVaListKind getBuiltinVaListKind() const =0
Returns the kind of __builtin_va_list type that should be used with this target.
bool isVLASupported() const
Whether target supports variable-length arrays.
bool hasCheapUnalignedBitFieldAccess() const
Return true iff unaligned accesses are cheap.
Definition TargetInfo.h:927
unsigned getTargetAddressSpace(LangAS AS) const
const llvm::fltSemantics & getBFloat16Format() const
Definition TargetInfo.h:805
virtual bool isProcessorName(StringRef Name) const
Returns true if the target's processor is compatible with the processor named by Name,...
const char * getUserLabelPrefix() const
Returns the default value of the USER_LABEL_PREFIX macro, which is the prefix given to user symbols b...
Definition TargetInfo.h:936
unsigned getAccumAlign() const
Definition TargetInfo.h:577
unsigned getFloat128Width() const
getFloat128Width/Align/Format - Return the size/align/format of '__float128'.
Definition TargetInfo.h:822
virtual bool hasIbm128Type() const
Determine whether the __ibm128 type is supported on this target.
Definition TargetInfo.h:739
bool useExplicitBitFieldAlignment() const
Check whether explicit bitfield alignment attributes should be.
Definition TargetInfo.h:989
virtual bool doesFeatureAffectCodeGen(StringRef Feature) const
Returns true if feature has an impact on target code generation.
virtual bool validateConstraintModifier(StringRef, char, unsigned, std::string &) const
uint64_t getPointerAlign(LangAS AddrSpace) const
Definition TargetInfo.h:500
IntType getChar16Type() const
Definition TargetInfo.h:427
unsigned getUnsignedShortAccumIBits() const
Definition TargetInfo.h:623
IntType getChar32Type() const
Definition TargetInfo.h:428
unsigned getWCharWidth() const
getWCharWidth/Align - Return the size of 'wchar_t' for this target, in bits.
Definition TargetInfo.h:779
IntType getUInt64Type() const
Definition TargetInfo.h:430
virtual bool hasFPReturn() const
Determine whether return of a floating point value is supported on this target.
Definition TargetInfo.h:746
bool hasMicrosoftRecordLayout() const
llvm::StringSet ReadOnlyFeatures
Definition TargetInfo.h:316
std::string DataLayoutString
Definition TargetInfo.h:254
unsigned getUnsignedLongAccumScale() const
getUnsignedLongAccumScale/IBits - Return the number of fractional/integral bits in a 'unsigned long _...
Definition TargetInfo.h:641
virtual StringRef getConstraintRegister(StringRef Constraint, StringRef Expression) const
Extracts a register from the passed constraint (if it is a single-register constraint) and the asm la...
virtual void fillValidCPUList(SmallVectorImpl< StringRef > &Values) const
Fill a SmallVectorImpl with the valid values to setCPU.
IntType getSignedSizeType() const
Definition TargetInfo.h:396
bool hasBuiltinMSVaList() const
Returns whether or not type __builtin_ms_va_list type is available on this target.
virtual bool hasFloat128Type() const
Determine whether the __float128 type is supported on this target.
Definition TargetInfo.h:724
unsigned getUnsignedLongAccumIBits() const
Definition TargetInfo.h:644
virtual void setMaxAtomicWidth()
Set the maximum inline or promote width lock-free atomic operation for the given target.
Definition TargetInfo.h:868
unsigned getUnsignedShortFractScale() const
getUnsignedShortFractScale - Return the number of fractional bits in a 'unsigned short _Fract' type.
Definition TargetInfo.h:664
bool hasNoAsmVariants() const
Return true if {|} are normal characters in the asm string.
unsigned HasAlignMac68kSupport
Definition TargetInfo.h:266
virtual bool validateCPUSpecificCPUDispatch(StringRef Name) const
const llvm::fltSemantics & getLongDoubleFormat() const
Definition TargetInfo.h:816
virtual StringRef getCPUSpecificTuneName(StringRef Name) const
const llvm::fltSemantics & getFloatFormat() const
Definition TargetInfo.h:800
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
unsigned getBitIntMaxAlign() const
getBitIntMaxAlign() - Returns the maximum possible alignment of '_BitInt' and 'unsigned _BitInt'.
Definition TargetInfo.h:555
unsigned getDoubleAlign() const
Definition TargetInfo.h:809
bool shouldUseMicrosoftCCforMangling() const
Should the Microsoft mangling scheme be used for C Calling Convention.
virtual bool hasProtectedVisibility() const
Does this target support "protected" visibility?
unsigned getRegParmMax() const
bool hasAArch64ACLETypes() const
Returns whether or not the AArch64 ACLE built-in types are available on this target.
unsigned getDoubleWidth() const
getDoubleWidth/Align/Format - Return the size/align/format of 'double'.
Definition TargetInfo.h:808
virtual bool checkArithmeticFenceSupported() const
Controls if __arithmetic_fence is supported in the targeted backend.
unsigned getIntMaxTWidth() const
Return the size of intmax_t and uintmax_t for this target, in bits.
Definition TargetInfo.h:903
virtual int getEHDataRegisterNumber(unsigned RegNo) const
Return the register number that __builtin_eh_return_regno would return with the specified argument.
unsigned getShortAccumWidth() const
getShortAccumWidth/Align - Return the size of 'signed short _Accum' and 'unsigned short _Accum' for t...
Definition TargetInfo.h:571
virtual StringRef getABI() const
Get the ABI currently in use.
unsigned getSuitableAlign() const
Return the alignment that is the largest alignment ever used for any scalar/SIMD data type on the tar...
Definition TargetInfo.h:754
unsigned HasAArch64ACLETypes
Definition TargetInfo.h:279
virtual bool hasMustTail() const
Definition TargetInfo.h:682
bool useObjCFP2RetForComplexLongDouble() const
Check whether _Complex long double should use the "fp2ret" flavor of Objective-C message passing on t...
virtual const llvm::omp::GV & getGridValue() const
virtual uint64_t getPointerWidthV(LangAS AddrSpace) const
virtual bool allowsLargerPreferedTypeAlignment() const
Whether target allows to overalign ABI-specified preferred alignment.
virtual std::string_view getClobbers() const =0
Returns a string of target-specific clobbers, in LLVM format.
virtual unsigned getUnwindWordWidth() const
Definition TargetInfo.h:908
unsigned getBoolWidth() const
Return the size of '_Bool' and C++ 'bool' for this target, in bits.
Definition TargetInfo.h:522
virtual bool isValidFeatureName(StringRef Feature) const
Determine whether this TargetInfo supports the given feature.
bool useAddressSpaceMapMangling() const
Specify if mangling based on address space map should be used or not for language specific address sp...
unsigned getCharWidth() const
Definition TargetInfo.h:527
unsigned HasRISCVVTypes
Definition TargetInfo.h:282
bool useZeroLengthBitfieldAlignment() const
Check whether zero length bitfields should force alignment of the next member.
Definition TargetInfo.h:963
virtual bool validateTarget(DiagnosticsEngine &Diags) const
Check the target is valid after it is fully initialized.
bool hasBuiltinZOSVaList() const
Returns whether or not type __builtin_zos_va_list type is available on this target.
unsigned getLongWidth() const
getLongWidth/Align - Return the size of 'signed long' and 'unsigned long' for this target,...
Definition TargetInfo.h:542
unsigned getLongFractWidth() const
getLongFractWidth/Align - Return the size of 'signed long _Fract' and 'unsigned long _Fract' for this...
Definition TargetInfo.h:596
IntType getIntMaxType() const
Definition TargetInfo.h:410
virtual bool supportsTargetAttributeTune() const
Determine whether this TargetInfo supports tune in target attribute.
unsigned getFractScale() const
getFractScale - Return the number of fractional bits in a 'signed _Fract' type.
Definition TargetInfo.h:656
bool supportsMultiVersioning() const
Identify whether this target supports multiversioning of functions, which requires support for cpu_su...
virtual bool validateGlobalRegisterVariable(StringRef RegName, unsigned RegSize, bool &HasSizeMismatch) const
Validate register name used for global register variables.
virtual bool shouldDLLImportComdatSymbols() const
Does this target aim for semantic compatibility with Microsoft C++ code using dllimport/export attrib...
unsigned getFractWidth() const
getFractWidth/Align - Return the size of 'signed _Fract' and 'unsigned _Fract' for this target,...
Definition TargetInfo.h:591
virtual std::string convertConstraint(const char *&Constraint) const
unsigned char MaxAtomicInlineWidth
Definition TargetInfo.h:253
virtual void setCommandLineOpenCLOpts()
Set supported OpenCL extensions as written on command line.
unsigned AllowAMDGPUUnsafeFPAtomics
Definition TargetInfo.h:285
unsigned getFloat128Align() const
Definition TargetInfo.h:823
virtual bool hasBFloat16Type() const
Determine whether the _BFloat16 type is supported on this target.
Definition TargetInfo.h:730
unsigned getShortFractScale() const
getShortFractScale - Return the number of fractional bits in a 'signed short _Fract' type.
Definition TargetInfo.h:652
IntType getProcessIDType() const
Definition TargetInfo.h:438
unsigned getFloatAlign() const
Definition TargetInfo.h:799
virtual uint64_t getMaxPointerWidth() const
Return the maximum width of pointers on this target.
Definition TargetInfo.h:506
unsigned getShortFractWidth() const
getShortFractWidth/Align - Return the size of 'signed short _Fract' and 'unsigned short _Fract' for t...
Definition TargetInfo.h:586
virtual bool isAddressSpaceSupersetOf(LangAS A, LangAS B) const
Returns true if an address space can be safely converted to another.
Definition TargetInfo.h:517
TargetCXXABI TheCXXABI
Definition TargetInfo.h:258
virtual bool hasHIPImageSupport() const
Whether to support HIP image/texture API's.
unsigned ARMCDECoprocMask
Definition TargetInfo.h:293
virtual bool hasFeature(StringRef Feature) const
Determine whether the given target has the given feature.
unsigned getUnsignedShortAccumScale() const
getUnsignedShortAccumScale/IBits - Return the number of fractional/integral bits in a 'unsigned short...
Definition TargetInfo.h:620
virtual bool isValidCPUName(StringRef Name) const
Determine whether this TargetInfo supports the given CPU name.
unsigned getChar32Align() const
Definition TargetInfo.h:790
bool doUnsignedFixedPointTypesHavePadding() const
In the event this target uses the same number of fractional bits for its unsigned types as it does wi...
Definition TargetInfo.h:461
unsigned getMaxAtomicPromoteWidth() const
Return the maximum width lock-free atomic operation which will ever be supported for the given target...
Definition TargetInfo.h:862
virtual bool isSPRegName(StringRef) const
unsigned getInt128Align() const
getInt128Align() - Returns the alignment of Int128.
Definition TargetInfo.h:551
IntType getUIntMaxType() const
Definition TargetInfo.h:411
const llvm::fltSemantics & getFloat128Format() const
Definition TargetInfo.h:824
unsigned HasBuiltinMSVaList
Definition TargetInfo.h:273
virtual bool hasSjLjLowering() const
Controls if __builtin_longjmp / __builtin_setjmp can be lowered to llvm.eh.sjlj.longjmp / llvm....
const llvm::VersionTuple & getSDKVersion() const
unsigned getLongDoubleWidth() const
getLongDoubleWidth/Align/Format - Return the size/align/format of 'long double'.
Definition TargetInfo.h:814
unsigned getLongDoubleAlign() const
Definition TargetInfo.h:815
const llvm::fltSemantics & getIbm128Format() const
Definition TargetInfo.h:832
unsigned getTypeAlign(IntType T) const
Return the alignment (in bits) of the specified integer type enum.
bool useBitFieldTypeAlignment() const
Check whether the alignment of bit-field types is respected when laying out structures.
Definition TargetInfo.h:957
unsigned getShortAlign() const
Definition TargetInfo.h:533
virtual const char * getBFloat16Mangling() const
Return the mangled code of bfloat.
Definition TargetInfo.h:846
virtual bool isNan2008() const
Returns true if NaN encoding is IEEE 754-2008.
virtual void setSupportedOpenCLOpts()
Set supported OpenCL extensions and optional core features.
bool hasRISCVVTypes() const
Returns whether or not the RISC-V V built-in types are available on this target.
Options for controlling the target.
std::unique_ptr< clang::TargetInfo > AllocateTarget(const llvm::Triple &Triple, const clang::TargetOptions &Opts)
Definition Targets.cpp:111
Top level wrappers for InstallAPI frontend operations.
VTableUniquenessKind
A target's ABI policy for whether a class's vtable can be assumed to have a unique address program-wi...
bool isTargetAddressSpace(LangAS AS)
OpenCLTypeKind
OpenCL type kinds.
Definition TargetInfo.h:213
@ OCLTK_ReserveID
Definition TargetInfo.h:220
@ OCLTK_Image
Definition TargetInfo.h:217
@ OCLTK_Sampler
Definition TargetInfo.h:221
@ OCLTK_Pipe
Definition TargetInfo.h:218
@ OCLTK_ClkEvent
Definition TargetInfo.h:215
@ OCLTK_Event
Definition TargetInfo.h:216
@ OCLTK_Default
Definition TargetInfo.h:214
@ OCLTK_Queue
Definition TargetInfo.h:219
unsigned Microsoft64BitMinGlobalAlign(uint64_t TypeSize)
unsigned toTargetAddressSpace(LangAS AS)
const FunctionProtoType * T
LangAS
Defines the address space values used by the address space qualifier of QualType.
FloatModeKind
Definition TargetInfo.h:75
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition Specifiers.h:279
LangAS getLangASFromTargetAS(unsigned TargetAS)
@ None
The alignment was not explicit in code.
Definition ASTContext.h:176
@ Other
Other implicit parameter.
Definition Decl.h:1774
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30
__packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 __packed_splat2 uint8_t
__packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 __packed_splat2 __packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 uint32_t
#define false
Definition stdbool.h:26
Contains information gathered from parsing the contents of TargetAttr.
Definition TargetInfo.h:60
std::vector< std::string > Features
Definition TargetInfo.h:61
bool operator==(const ParsedTargetAttr &Other) const
Definition TargetInfo.h:66
const char *const Names[5]
llvm::SmallSet< int, 4 > ImmSet
const std::string & getConstraintStr() const
bool hasMatchingInput() const
Return true if this output operand has a matching (tied) input operand.
void setOutputOperandBounds(unsigned Min, unsigned Max)
const std::string & getName() const
std::optional< std::pair< unsigned, unsigned > > getOutputOperandBounds() const
ConstraintInfo(StringRef ConstraintStr, StringRef Name)
void setTiedOperand(unsigned N, ConstraintInfo &Output)
Indicate that this is an input operand that is tied to the specified output operand.
struct clang::TargetInfo::ConstraintInfo::@263264231172035111123222045331110346030050140010 ImmRange
bool isValidAsmImmediate(const llvm::APInt &Value) const
bool hasTiedOperand() const
Return true if this input operand is a matching constraint that ties it to an output operand.
void setRequiresImmediate(llvm::ArrayRef< int > Exacts)
void setRequiresImmediate(int Min, int Max)
const char *const Aliases[5]
Fields controlling how types are laid out in memory; these may need to be copied for targets like AMD...
Definition TargetInfo.h:89
const llvm::fltSemantics * DoubleFormat
Definition TargetInfo.h:144
unsigned UseZeroLengthBitfieldAlignment
Whether zero length bitfields (e.g., int : 0;) force alignment of the next bitfield.
Definition TargetInfo.h:188
unsigned UseExplicitBitFieldAlignment
Whether explicit bit field alignment attributes are honored.
Definition TargetInfo.h:197
IntType
===-— Target Data Type Query Methods ----------------------------—===//
Definition TargetInfo.h:147
const llvm::fltSemantics * LongDoubleFormat
Definition TargetInfo.h:144
unsigned ZeroLengthBitfieldBoundary
If non-zero, specifies a fixed alignment value for bitfields that follow zero length bitfield,...
Definition TargetInfo.h:201
const llvm::fltSemantics * Float128Format
Definition TargetInfo.h:144
std::optional< unsigned > BitIntMaxAlign
Definition TargetInfo.h:106
unsigned LargestOverSizedBitfieldContainer
The largest container size which should be used for an over-sized bitfield, in bits.
Definition TargetInfo.h:205
unsigned UseLeadingZeroLengthBitfield
Whether zero length bitfield alignment is respected if they are the leading members.
Definition TargetInfo.h:193
unsigned UseBitFieldTypeAlignment
Control whether the alignment of bit-field types is respected when laying out structures.
Definition TargetInfo.h:179
unsigned MaxAlignedAttribute
If non-zero, specifies a maximum alignment to truncate alignment specified in the aligned attribute o...
Definition TargetInfo.h:209
const llvm::fltSemantics * Ibm128Format
Definition TargetInfo.h:144
const llvm::fltSemantics * FloatFormat
Definition TargetInfo.h:143
const llvm::fltSemantics * HalfFormat
Definition TargetInfo.h:143
unsigned UseSignedCharForObjCBool
Whether Objective-C's built-in boolean type should be signed char.
Definition TargetInfo.h:171
const llvm::fltSemantics * BFloat16Format
Definition TargetInfo.h:143
unsigned char DefaultAlignForAttributeAligned
Definition TargetInfo.h:134