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