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