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