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