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