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