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