clang 22.0.0git
TargetInfo.h
Go to the documentation of this file.
1//===--- TargetInfo.h - Expose information about the target -----*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file
10/// Defines the clang::TargetInfo interface.
11///
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_BASIC_TARGETINFO_H
15#define LLVM_CLANG_BASIC_TARGETINFO_H
16
22#include "clang/Basic/LLVM.h"
27#include "llvm/ADT/APFloat.h"
28#include "llvm/ADT/APInt.h"
29#include "llvm/ADT/APSInt.h"
30#include "llvm/ADT/ArrayRef.h"
31#include "llvm/ADT/IntrusiveRefCntPtr.h"
32#include "llvm/ADT/SmallSet.h"
33#include "llvm/ADT/StringMap.h"
34#include "llvm/ADT/StringRef.h"
35#include "llvm/ADT/StringSet.h"
36#include "llvm/ADT/StringTable.h"
37#include "llvm/Frontend/OpenMP/OMPGridValues.h"
38#include "llvm/IR/DerivedTypes.h"
39#include "llvm/Support/DataTypes.h"
40#include "llvm/Support/Error.h"
41#include "llvm/Support/VersionTuple.h"
42#include "llvm/TargetParser/Triple.h"
43#include <cassert>
44#include <optional>
45#include <string>
46#include <utility>
47#include <vector>
48
49namespace llvm {
50struct fltSemantics;
51}
52
53namespace clang {
55class LangOptions;
56class CodeGenOptions;
57class MacroBuilder;
58
59/// Contains information gathered from parsing the contents of TargetAttr.
61 std::vector<std::string> Features;
62 StringRef CPU;
63 StringRef Tune;
65 StringRef Duplicate;
66 bool operator ==(const ParsedTargetAttr &Other) const {
67 return Duplicate == Other.Duplicate && CPU == Other.CPU &&
68 Tune == Other.Tune && BranchProtection == Other.BranchProtection &&
69 Features == Other.Features;
70 }
71};
72
73namespace Builtin { struct Info; }
74
75enum class FloatModeKind {
77 Half = 1 << 0,
78 Float = 1 << 1,
79 Double = 1 << 2,
80 LongDouble = 1 << 3,
81 Float128 = 1 << 4,
82 Ibm128 = 1 << 5,
84};
85
86/// Fields controlling how types are laid out in memory; these may need to
87/// be copied for targets like AMDGPU that base their ABIs on an auxiliary
88/// CPU target.
90 unsigned char PointerWidth, PointerAlign;
91 unsigned char BoolWidth, BoolAlign;
92 unsigned char ShortWidth, ShortAlign;
93 unsigned char IntWidth, IntAlign;
94 unsigned char HalfWidth, HalfAlign;
96 unsigned char FloatWidth, FloatAlign;
97 unsigned char DoubleWidth, DoubleAlign;
100 unsigned char LongWidth, LongAlign;
102 unsigned char Int128Align;
103
104 // This is an optional parameter for targets that
105 // don't use 'LongLongAlign' for '_BitInt' max alignment
106 std::optional<unsigned> BitIntMaxAlign;
107
108 // Fixed point bit widths
110 unsigned char AccumWidth, AccumAlign;
113 unsigned char FractWidth, FractAlign;
115
116 // If true, unsigned fixed point types have the same number of fractional bits
117 // as their signed counterparts, forcing the unsigned types to have one extra
118 // bit of padding. Otherwise, unsigned fixed point types have
119 // one more fractional bit than its corresponding signed type. This is false
120 // by default.
122
123 // Fixed point integral and fractional bit sizes
124 // Saturated types share the same integral/fractional bits as their
125 // corresponding unsaturated types.
126 // For simplicity, the fractional bits in a _Fract type will be one less the
127 // width of that _Fract type. This leaves all signed _Fract types having no
128 // padding and unsigned _Fract types will only have 1 bit of padding after the
129 // sign if PaddingOnUnsignedFixedPoint is set.
130 unsigned char ShortAccumScale;
131 unsigned char AccumScale;
132 unsigned char LongAccumScale;
133
135 unsigned char MinGlobalAlign;
136
137 unsigned short SuitableAlign;
138 unsigned short NewAlign;
140 unsigned MaxTLSAlign;
141
142 const llvm::fltSemantics *HalfFormat, *BFloat16Format, *FloatFormat,
144
145 ///===---- Target Data Type Query Methods -------------------------------===//
159
160protected:
164
165 /// Whether Objective-C's built-in boolean type should be signed char.
166 ///
167 /// Otherwise, when this flag is not set, the normal built-in boolean type is
168 /// used.
169 LLVM_PREFERRED_TYPE(bool)
171
172 /// Control whether the alignment of bit-field types is respected when laying
173 /// out structures. If true, then the alignment of the bit-field type will be
174 /// used to (a) impact the alignment of the containing structure, and (b)
175 /// ensure that the individual bit-field will not straddle an alignment
176 /// boundary.
177 LLVM_PREFERRED_TYPE(bool)
179
180 /// Whether zero length bitfields (e.g., int : 0;) force alignment of
181 /// the next bitfield.
182 ///
183 /// If the alignment of the zero length bitfield is greater than the member
184 /// that follows it, `bar', `bar' will be aligned as the type of the
185 /// zero-length bitfield.
186 LLVM_PREFERRED_TYPE(bool)
188
189 /// Whether zero length bitfield alignment is respected if they are the
190 /// leading members.
191 LLVM_PREFERRED_TYPE(bool)
193
194 /// Whether explicit bit field alignment attributes are honored.
195 LLVM_PREFERRED_TYPE(bool)
197
198 /// If non-zero, specifies a fixed alignment value for bitfields that follow
199 /// zero length bitfield, regardless of the zero length bitfield type.
201
202 /// The largest container size which should be used for an over-sized
203 /// bitfield, in bits.
205
206 /// If non-zero, specifies a maximum alignment to truncate alignment
207 /// specified in the aligned attribute of a static variable to this value.
209};
210
211/// OpenCL type kinds.
222
223/// Exposes information about the current target.
224///
226 public RefCountedBase<TargetInfo> {
227 TargetOptions *TargetOpts;
228 llvm::Triple Triple;
229protected:
230 // Target values set by the ctor of the actual target implementation. Default
231 // values are specified by the TargetInfo constructor.
236 bool NoAsmVariants; // True if {|} are normal characters.
237 bool HasFastHalfType; // True if the backend has native half float support,
238 // and performing calculations in float instead does
239 // not have a performance advantage.
240 bool HalfArgsAndReturns; // OpenCL 6.1.1.1, NEON (IEEE 754-2008 half) type.
244 bool HasFullBFloat16; // True if the backend supports native bfloat16
245 // arithmetic. Used to determine excess precision
246 // support in the frontend.
251
253 std::string DataLayoutString;
254 const char *UserLabelPrefix;
255 const char *MCountName;
256 unsigned char RegParmMax, SSERegParmMax;
260
261 mutable StringRef PlatformName;
262 mutable VersionTuple PlatformMinVersion;
263
264 LLVM_PREFERRED_TYPE(bool)
266 LLVM_PREFERRED_TYPE(FloatModeKind)
268 LLVM_PREFERRED_TYPE(bool)
270
271 LLVM_PREFERRED_TYPE(bool)
272 unsigned HasBuiltinMSVaList : 1;
273
274 LLVM_PREFERRED_TYPE(bool)
276
277 LLVM_PREFERRED_TYPE(bool)
278 unsigned HasRISCVVTypes : 1;
279
280 LLVM_PREFERRED_TYPE(bool)
282
283 LLVM_PREFERRED_TYPE(bool)
284 unsigned HasUnalignedAccess : 1;
285
286 unsigned ARMCDECoprocMask : 8;
287
289
290 std::optional<unsigned> MaxBitIntWidth;
291
293
295
296 // TargetInfo Constructor. Default initializes all fields.
297 TargetInfo(const llvm::Triple &T);
298
299 /// 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 llvm intrinsics such as llvm.convert.to.fp16 should be used
1017 /// to convert to and from __fp16.
1018 /// FIXME: This function should be removed once all targets stop using the
1019 /// conversion intrinsics.
1020 virtual bool useFP16ConversionIntrinsics() const {
1021 return true;
1022 }
1023
1024 /// Specify if mangling based on address space map should be used or
1025 /// not for language specific address spaces
1028 }
1029
1030 ///===---- Other target property query methods --------------------------===//
1031
1032 /// Appends the target-specific \#define values for this
1033 /// target set to the specified buffer.
1034 virtual void getTargetDefines(const LangOptions &Opts,
1035 MacroBuilder &Builder) const = 0;
1036
1037 /// Return information about target-specific builtins for the current primary
1038 /// target, and info about which builtins are non-portable across the current
1039 /// set of primary and secondary targets.
1041
1047
1048 /// Returns target-specific min and max values VScale_Range.
1049 virtual std::optional<std::pair<unsigned, unsigned>>
1051 llvm::StringMap<bool> *FeatureMap = nullptr) const {
1052 return std::nullopt;
1053 }
1054 /// The __builtin_clz* and __builtin_ctz* built-in
1055 /// functions are specified to have undefined results for zero inputs, but
1056 /// on targets that support these operations in a way that provides
1057 /// well-defined results for zero without loss of performance, it is a good
1058 /// idea to avoid optimizing based on that undef behavior.
1059 virtual bool isCLZForZeroUndef() const { return true; }
1060
1061 /// Returns the kind of __builtin_va_list type that should be used
1062 /// with this target.
1064
1065 /// Returns whether or not type \c __builtin_ms_va_list type is
1066 /// available on this target.
1068
1069 /// Returns whether or not the AArch64 ACLE built-in types are
1070 /// available on this target.
1072
1073 /// Returns whether or not the RISC-V V built-in types are
1074 /// available on this target.
1075 bool hasRISCVVTypes() const { return HasRISCVVTypes; }
1076
1077 /// For ARM targets returns a mask defining which coprocessors are configured
1078 /// as Custom Datapath.
1079 uint32_t getARMCDECoprocMask() const { return ARMCDECoprocMask; }
1080
1081 /// For ARM targets returns a mask defining which data sizes are suitable for
1082 /// __builtin_arm_ldrex and __builtin_arm_strex.
1083 enum {
1084 ARM_LDREX_B = (1 << 0), /// byte (8-bit)
1085 ARM_LDREX_H = (1 << 1), /// half (16-bit)
1086 ARM_LDREX_W = (1 << 2), /// word (32-bit)
1087 ARM_LDREX_D = (1 << 3), /// double (64-bit)
1088 };
1089
1090 virtual unsigned getARMLDREXMask() const { return 0; }
1091
1092 /// Returns whether the passed in string is a valid clobber in an
1093 /// inline asm statement.
1094 ///
1095 /// This is used by Sema.
1096 bool isValidClobber(StringRef Name) const;
1097
1098 /// Returns whether the passed in string is a valid register name
1099 /// according to GCC.
1100 ///
1101 /// This is used by Sema for inline asm statements.
1102 virtual bool isValidGCCRegisterName(StringRef Name) const;
1103
1104 /// Returns the "normalized" GCC register name.
1105 ///
1106 /// ReturnCannonical true will return the register name without any additions
1107 /// such as "{}" or "%" in it's canonical form, for example:
1108 /// ReturnCanonical = true and Name = "rax", will return "ax".
1109 StringRef getNormalizedGCCRegisterName(StringRef Name,
1110 bool ReturnCanonical = false) const;
1111
1112 virtual bool isSPRegName(StringRef) const { return false; }
1113
1114 /// Extracts a register from the passed constraint (if it is a
1115 /// single-register constraint) and the asm label expression related to a
1116 /// variable in the input or output list of an inline asm statement.
1117 ///
1118 /// This function is used by Sema in order to diagnose conflicts between
1119 /// the clobber list and the input/output lists.
1120 virtual StringRef getConstraintRegister(StringRef Constraint,
1121 StringRef Expression) const {
1122 return "";
1123 }
1124
1126 enum {
1127 CI_None = 0x00,
1130 CI_ReadWrite = 0x04, // "+r" output constraint (read and write).
1131 CI_HasMatchingInput = 0x08, // This output operand has a matching input.
1132 CI_ImmediateConstant = 0x10, // This operand must be an immediate constant
1133 CI_EarlyClobber = 0x20, // "&" output constraint (early clobber).
1134 };
1135 unsigned Flags;
1137 struct {
1138 int Min;
1139 int Max;
1141 } ImmRange;
1142 llvm::SmallSet<int, 4> ImmSet;
1143
1144 std::string ConstraintStr; // constraint: "=rm"
1145 std::string Name; // Operand name: [foo] with no []'s.
1146 public:
1147 ConstraintInfo(StringRef ConstraintStr, StringRef Name)
1148 : Flags(0), TiedOperand(-1), ConstraintStr(ConstraintStr.str()),
1149 Name(Name.str()) {
1150 ImmRange.Min = ImmRange.Max = 0;
1151 ImmRange.isConstrained = false;
1152 }
1153
1154 const std::string &getConstraintStr() const { return ConstraintStr; }
1155 const std::string &getName() const { return Name; }
1156 bool isReadWrite() const { return (Flags & CI_ReadWrite) != 0; }
1157 bool earlyClobber() { return (Flags & CI_EarlyClobber) != 0; }
1158 bool allowsRegister() const { return (Flags & CI_AllowsRegister) != 0; }
1159 bool allowsMemory() const { return (Flags & CI_AllowsMemory) != 0; }
1160
1161 /// Return true if this output operand has a matching
1162 /// (tied) input operand.
1163 bool hasMatchingInput() const { return (Flags & CI_HasMatchingInput) != 0; }
1164
1165 /// Return true if this input operand is a matching
1166 /// constraint that ties it to an output operand.
1167 ///
1168 /// If this returns true then getTiedOperand will indicate which output
1169 /// operand this is tied to.
1170 bool hasTiedOperand() const { return TiedOperand != -1; }
1171 unsigned getTiedOperand() const {
1172 assert(hasTiedOperand() && "Has no tied operand!");
1173 return (unsigned)TiedOperand;
1174 }
1175
1177 return (Flags & CI_ImmediateConstant) != 0;
1178 }
1179 bool isValidAsmImmediate(const llvm::APInt &Value) const {
1180 if (!ImmSet.empty())
1181 return Value.isSignedIntN(32) && ImmSet.contains(Value.getZExtValue());
1182 return !ImmRange.isConstrained ||
1183 (Value.sge(ImmRange.Min) && Value.sle(ImmRange.Max));
1184 }
1185
1193 ImmRange.Min = Min;
1194 ImmRange.Max = Max;
1195 ImmRange.isConstrained = true;
1196 }
1199 ImmSet.insert_range(Exacts);
1200 }
1201 void setRequiresImmediate(int Exact) {
1203 ImmSet.insert(Exact);
1204 }
1208
1209 /// Indicate that this is an input operand that is tied to
1210 /// the specified output operand.
1211 ///
1212 /// Copy over the various constraint information from the output.
1213 void setTiedOperand(unsigned N, ConstraintInfo &Output) {
1214 Output.setHasMatchingInput();
1215 Flags = Output.Flags;
1216 TiedOperand = N;
1217 // Don't copy Name or constraint string.
1218 }
1219
1220 // For output operand constraints, the target can set bounds to indicate
1221 // that the result value is guaranteed to fall within a certain range.
1222 // This will cause corresponding assertions to be emitted that will allow
1223 // for potential optimization based of that guarantee.
1224 //
1225 // NOTE: This re-uses the `ImmRange` fields to store the range, which are
1226 // otherwise unused for constraint types used for output operands.
1227 void setOutputOperandBounds(unsigned Min, unsigned Max) {
1228 ImmRange.Min = Min;
1229 ImmRange.Max = Max;
1230 ImmRange.isConstrained = true;
1231 }
1232 std::optional<std::pair<unsigned, unsigned>>
1234 return ImmRange.isConstrained
1235 ? std::make_pair(ImmRange.Min, ImmRange.Max)
1236 : std::optional<std::pair<unsigned, unsigned>>();
1237 }
1238 };
1239
1240 /// Validate register name used for global register variables.
1241 ///
1242 /// This function returns true if the register passed in RegName can be used
1243 /// for global register variables on this target. In addition, it returns
1244 /// true in HasSizeMismatch if the size of the register doesn't match the
1245 /// variable size passed in RegSize.
1246 virtual bool validateGlobalRegisterVariable(StringRef RegName,
1247 unsigned RegSize,
1248 bool &HasSizeMismatch) const {
1249 HasSizeMismatch = false;
1250 return true;
1251 }
1252
1253 // validateOutputConstraint, validateInputConstraint - Checks that
1254 // a constraint is valid and provides information about it.
1255 // FIXME: These should return a real error instead of just true/false.
1256 bool validateOutputConstraint(ConstraintInfo &Info) const;
1257 bool validateInputConstraint(MutableArrayRef<ConstraintInfo> OutputConstraints,
1258 ConstraintInfo &info) const;
1259
1260 virtual bool validateOutputSize(const llvm::StringMap<bool> &FeatureMap,
1261 StringRef /*Constraint*/,
1262 unsigned /*Size*/) const {
1263 return true;
1264 }
1265
1266 virtual bool validateInputSize(const llvm::StringMap<bool> &FeatureMap,
1267 StringRef /*Constraint*/,
1268 unsigned /*Size*/) const {
1269 return true;
1270 }
1271 virtual bool
1272 validateConstraintModifier(StringRef /*Constraint*/,
1273 char /*Modifier*/,
1274 unsigned /*Size*/,
1275 std::string &/*SuggestedModifier*/) const {
1276 return true;
1277 }
1278 virtual bool
1279 validateAsmConstraint(const char *&Name,
1280 TargetInfo::ConstraintInfo &info) const = 0;
1281
1282 bool resolveSymbolicName(const char *&Name,
1283 ArrayRef<ConstraintInfo> OutputConstraints,
1284 unsigned &Index) const;
1285
1286 std::string
1287 simplifyConstraint(StringRef Constraint,
1288 SmallVectorImpl<ConstraintInfo> *OutCons = nullptr) const;
1289
1290 // Constraint parm will be left pointing at the last character of
1291 // the constraint. In practice, it won't be changed unless the
1292 // constraint is longer than one character.
1293 virtual std::string convertConstraint(const char *&Constraint) const {
1294 // 'p' defaults to 'r', but can be overridden by targets.
1295 if (*Constraint == 'p')
1296 return std::string("r");
1297 return std::string(1, *Constraint);
1298 }
1299
1300 /// Replace some escaped characters with another string based on
1301 /// target-specific rules
1302 virtual std::optional<std::string> handleAsmEscapedChar(char C) const {
1303 return std::nullopt;
1304 }
1305
1306 /// Returns a string of target-specific clobbers, in LLVM format.
1307 virtual std::string_view getClobbers() const = 0;
1308
1309 /// Returns true if NaN encoding is IEEE 754-2008.
1310 /// Only MIPS allows a different encoding.
1311 virtual bool isNan2008() const {
1312 return true;
1313 }
1314
1315 /// Returns the target triple of the primary target.
1316 const llvm::Triple &getTriple() const {
1317 return Triple;
1318 }
1319
1320 /// Returns the target ID if supported.
1321 virtual std::optional<std::string> getTargetID() const {
1322 return std::nullopt;
1323 }
1324
1325 const char *getDataLayoutString() const {
1326 assert(!DataLayoutString.empty() && "Uninitialized DataLayout!");
1327 return DataLayoutString.c_str();
1328 }
1329
1331 const char * const Aliases[5];
1332 const char * const Register;
1333 };
1334
1336 const char * const Names[5];
1337 const unsigned RegNum;
1338 };
1339
1340 /// Does this target support "protected" visibility?
1341 ///
1342 /// Any target which dynamic libraries will naturally support
1343 /// something like "default" (meaning that the symbol is visible
1344 /// outside this shared object) and "hidden" (meaning that it isn't)
1345 /// visibilities, but "protected" is really an ELF-specific concept
1346 /// with weird semantics designed around the convenience of dynamic
1347 /// linker implementations. Which is not to suggest that there's
1348 /// consistent target-independent semantics for "default" visibility
1349 /// either; the entire thing is pretty badly mangled.
1350 virtual bool hasProtectedVisibility() const { return true; }
1351
1352 /// Does this target aim for semantic compatibility with
1353 /// Microsoft C++ code using dllimport/export attributes?
1354 virtual bool shouldDLLImportComdatSymbols() const {
1355 return getTriple().isWindowsMSVCEnvironment() ||
1356 getTriple().isWindowsItaniumEnvironment() || getTriple().isPS();
1357 }
1358
1359 // Does this target have PS4 specific dllimport/export handling?
1360 virtual bool hasPS4DLLImportExport() const {
1361 return getTriple().isPS() ||
1362 // Windows Itanium support allows for testing the SCEI flavour of
1363 // dllimport/export handling on a Windows system.
1364 (getTriple().isWindowsItaniumEnvironment() &&
1365 getTriple().getVendor() == llvm::Triple::SCEI);
1366 }
1367
1368 /// Set forced language options.
1369 ///
1370 /// Apply changes to the target information with respect to certain
1371 /// language options which change the target configuration and adjust
1372 /// the language based on the target options where applicable.
1373 virtual void adjust(DiagnosticsEngine &Diags, LangOptions &Opts,
1374 const TargetInfo *Aux);
1375
1376 /// Initialize the map with the default set of target features for the
1377 /// CPU this should include all legal feature strings on the target.
1378 ///
1379 /// \return False on error (invalid features).
1380 virtual bool initFeatureMap(llvm::StringMap<bool> &Features,
1381 DiagnosticsEngine &Diags, StringRef CPU,
1382 const std::vector<std::string> &FeatureVec) const;
1383
1384 /// Get the ABI currently in use.
1385 virtual StringRef getABI() const { return StringRef(); }
1386
1387 /// Get the C++ ABI currently in use.
1389 return TheCXXABI;
1390 }
1391
1392 /// Should the Microsoft mangling scheme be used for C Calling Convention.
1396
1397 /// Target the specified CPU.
1398 ///
1399 /// \return False on error (invalid CPU name).
1400 virtual bool setCPU(const std::string &Name) {
1401 return false;
1402 }
1403
1404 /// Fill a SmallVectorImpl with the valid values to setCPU.
1405 virtual void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const {}
1406
1407 /// Fill a SmallVectorImpl with the valid values for tuning CPU.
1409 fillValidCPUList(Values);
1410 }
1411
1412 /// Determine whether this TargetInfo supports the given CPU name.
1413 virtual bool isValidCPUName(StringRef Name) const {
1414 return true;
1415 }
1416
1417 /// Determine whether this TargetInfo supports the given CPU name for
1418 /// tuning.
1419 virtual bool isValidTuneCPUName(StringRef Name) const {
1420 return isValidCPUName(Name);
1421 }
1422
1423 virtual ParsedTargetAttr parseTargetAttr(StringRef Str) const;
1424
1425 /// Determine whether this TargetInfo supports tune in target attribute.
1426 virtual bool supportsTargetAttributeTune() const {
1427 return false;
1428 }
1429
1430 /// Use the specified ABI.
1431 ///
1432 /// \return False on error (invalid ABI name).
1433 virtual bool setABI(const std::string &Name) {
1434 return false;
1435 }
1436
1437 /// Use the specified unit for FP math.
1438 ///
1439 /// \return False on error (invalid unit name).
1440 virtual bool setFPMath(StringRef Name) {
1441 return false;
1442 }
1443
1444 /// Check if target has a given feature enabled
1445 virtual bool hasFeatureEnabled(const llvm::StringMap<bool> &Features,
1446 StringRef Name) const {
1447 return Features.lookup(Name);
1448 }
1449
1450 /// Enable or disable a specific target feature;
1451 /// the feature name must be valid.
1452 virtual void setFeatureEnabled(llvm::StringMap<bool> &Features,
1453 StringRef Name,
1454 bool Enabled) const {
1455 Features[Name] = Enabled;
1456 }
1457
1458 /// Determine whether this TargetInfo supports the given feature.
1459 virtual bool isValidFeatureName(StringRef Feature) const {
1460 return true;
1461 }
1462
1463 /// Returns true if feature has an impact on target code
1464 /// generation.
1465 virtual bool doesFeatureAffectCodeGen(StringRef Feature) const {
1466 return true;
1467 }
1468
1470 public:
1476
1477 const char *getSignReturnAddrStr() const {
1478 switch (SignReturnAddr) {
1480 return "none";
1482 return "non-leaf";
1484 return "all";
1485 }
1486 llvm_unreachable("Unexpected SignReturnAddressScopeKind");
1487 }
1488
1489 const char *getSignKeyStr() const {
1490 switch (SignKey) {
1492 return "a_key";
1494 return "b_key";
1495 }
1496 llvm_unreachable("Unexpected SignReturnAddressKeyKind");
1497 }
1498
1500 : SignReturnAddr(LangOptions::SignReturnAddressScopeKind::None),
1501 SignKey(LangOptions::SignReturnAddressKeyKind::AKey),
1504
1519 };
1520
1521 /// Determine if the Architecture in this TargetInfo supports branch
1522 /// protection
1523 virtual bool isBranchProtectionSupportedArch(StringRef Arch) const {
1524 return false;
1525 }
1526
1527 /// Determine if this TargetInfo supports the given branch protection
1528 /// specification
1529 virtual bool validateBranchProtection(StringRef Spec, StringRef Arch,
1531 const LangOptions &LO,
1532 StringRef &Err) const {
1533 Err = "";
1534 return false;
1535 }
1536
1537 /// Perform initialization based on the user configured
1538 /// set of features (e.g., +sse4).
1539 ///
1540 /// The list is guaranteed to have at most one entry per feature.
1541 ///
1542 /// The target may modify the features list, to change which options are
1543 /// passed onwards to the backend.
1544 /// FIXME: This part should be fixed so that we can change handleTargetFeatures
1545 /// to merely a TargetInfo initialization routine.
1546 ///
1547 /// \return False on error.
1548 virtual bool handleTargetFeatures(std::vector<std::string> &Features,
1549 DiagnosticsEngine &Diags) {
1550 return true;
1551 }
1552
1553 /// Determine whether the given target has the given feature.
1554 virtual bool hasFeature(StringRef Feature) const {
1555 return false;
1556 }
1557
1558 /// Determine whether the given target feature is read only.
1559 bool isReadOnlyFeature(StringRef Feature) const {
1560 return ReadOnlyFeatures.count(Feature);
1561 }
1562
1563 /// Identify whether this target supports multiversioning of functions,
1564 /// which requires support for cpu_supports and cpu_is functionality.
1566 return getTriple().isX86() || getTriple().isAArch64() ||
1567 getTriple().isRISCV();
1568 }
1569
1570 /// Identify whether this target supports IFuncs.
1571 bool supportsIFunc() const {
1572 if (getTriple().isOSBinFormatMachO())
1573 return true;
1574 if (getTriple().isOSWindows() && getTriple().isAArch64())
1575 return true;
1576 if (getTriple().getArch() == llvm::Triple::ArchType::avr)
1577 return true;
1578 return getTriple().isOSBinFormatELF() &&
1579 ((getTriple().isOSLinux() && !getTriple().isMusl()) ||
1580 getTriple().isOSFreeBSD());
1581 }
1582
1583 // Identify whether this target supports __builtin_cpu_supports and
1584 // __builtin_cpu_is.
1585 virtual bool supportsCpuSupports() const { return false; }
1586 virtual bool supportsCpuIs() const { return false; }
1587 virtual bool supportsCpuInit() const { return false; }
1588
1589 // Validate the contents of the __builtin_cpu_supports(const char*)
1590 // argument.
1591 virtual bool validateCpuSupports(StringRef Name) const { return false; }
1592
1593 // Return the target-specific priority for features/cpus/vendors so
1594 // that they can be properly sorted for checking.
1595 virtual llvm::APInt getFMVPriority(ArrayRef<StringRef> Features) const {
1596 return llvm::APInt::getZero(32);
1597 }
1598
1599 // Validate the contents of the __builtin_cpu_is(const char*)
1600 // argument.
1601 virtual bool validateCpuIs(StringRef Name) const { return false; }
1602
1603 // Validate a cpu_dispatch/cpu_specific CPU option, which is a different list
1604 // from cpu_is, since it checks via features rather than CPUs directly.
1605 virtual bool validateCPUSpecificCPUDispatch(StringRef Name) const {
1606 return false;
1607 }
1608
1609 // Get the character to be added for mangling purposes for cpu_specific.
1610 virtual char CPUSpecificManglingCharacter(StringRef Name) const {
1611 llvm_unreachable(
1612 "cpu_specific Multiversioning not implemented on this target");
1613 }
1614
1615 // Get the value for the 'tune-cpu' flag for a cpu_specific variant with the
1616 // programmer-specified 'Name'.
1617 virtual StringRef getCPUSpecificTuneName(StringRef Name) const {
1618 llvm_unreachable(
1619 "cpu_specific Multiversioning not implemented on this target");
1620 }
1621
1622 // Get a list of the features that make up the CPU option for
1623 // cpu_specific/cpu_dispatch so that it can be passed to llvm as optimization
1624 // options.
1626 StringRef Name, llvm::SmallVectorImpl<StringRef> &Features) const {
1627 llvm_unreachable(
1628 "cpu_specific Multiversioning not implemented on this target");
1629 }
1630
1631 // Get the cache line size of a given cpu. This method switches over
1632 // the given cpu and returns "std::nullopt" if the CPU is not found.
1633 virtual std::optional<unsigned> getCPUCacheLineSize() const {
1634 return std::nullopt;
1635 }
1636
1637 // Returns maximal number of args passed in registers.
1638 unsigned getRegParmMax() const {
1639 assert(RegParmMax < 7 && "RegParmMax value is larger than AST can handle");
1640 return RegParmMax;
1641 }
1642
1643 /// Whether the target supports thread-local storage.
1644 bool isTLSSupported() const {
1645 return TLSSupported;
1646 }
1647
1648 /// Return the maximum alignment (in bits) of a TLS variable
1649 ///
1650 /// Gets the maximum alignment (in bits) of a TLS variable on this target.
1651 /// Returns zero if there is no such constraint.
1652 unsigned getMaxTLSAlign() const { return MaxTLSAlign; }
1653
1654 /// Whether target supports variable-length arrays.
1655 bool isVLASupported() const { return VLASupported; }
1656
1657 /// Whether the target supports SEH __try.
1658 bool isSEHTrySupported() const {
1659 return getTriple().isOSWindows() &&
1660 (getTriple().isX86() ||
1661 getTriple().getArch() == llvm::Triple::aarch64);
1662 }
1663
1664 /// Return true if {|} are normal characters in the asm string.
1665 ///
1666 /// If this returns false (the default), then {abc|xyz} is syntax
1667 /// that says that when compiling for asm variant #0, "abc" should be
1668 /// generated, but when compiling for asm variant #1, "xyz" should be
1669 /// generated.
1670 bool hasNoAsmVariants() const {
1671 return NoAsmVariants;
1672 }
1673
1674 /// Return the register number that __builtin_eh_return_regno would
1675 /// return with the specified argument.
1676 /// This corresponds with TargetLowering's getExceptionPointerRegister
1677 /// and getExceptionSelectorRegister in the backend.
1678 virtual int getEHDataRegisterNumber(unsigned RegNo) const {
1679 return -1;
1680 }
1681
1682 /// Return the section to use for C++ static initialization functions.
1683 virtual const char *getStaticInitSectionSpecifier() const {
1684 return nullptr;
1685 }
1686
1687 const LangASMap &getAddressSpaceMap() const { return *AddrSpaceMap; }
1688 unsigned getTargetAddressSpace(LangAS AS) const {
1689 if (isTargetAddressSpace(AS))
1690 return toTargetAddressSpace(AS);
1691 return getAddressSpaceMap()[(unsigned)AS];
1692 }
1693
1694 /// Determine whether the given pointer-authentication key is valid.
1695 ///
1696 /// The value has been coerced to type 'int'.
1697 virtual bool validatePointerAuthKey(const llvm::APSInt &value) const;
1698
1699 /// Map from the address space field in builtin description strings to the
1700 /// language address space.
1701 virtual LangAS getOpenCLBuiltinAddressSpace(unsigned AS) const {
1702 return getLangASFromTargetAS(AS);
1703 }
1704
1705 /// Map from the address space field in builtin description strings to the
1706 /// language address space.
1707 virtual LangAS getCUDABuiltinAddressSpace(unsigned AS) const {
1708 return getLangASFromTargetAS(AS);
1709 }
1710
1711 /// Return an AST address space which can be used opportunistically
1712 /// for constant global memory. It must be possible to convert pointers into
1713 /// this address space to LangAS::Default. If no such address space exists,
1714 /// this may return std::nullopt, and such optimizations will be disabled.
1715 virtual std::optional<LangAS> getConstantAddressSpace() const {
1716 return LangAS::Default;
1717 }
1718
1719 // access target-specific GPU grid values that must be consistent between
1720 // host RTL (plugin), deviceRTL and clang.
1721 virtual const llvm::omp::GV &getGridValue() const {
1722 llvm_unreachable("getGridValue not implemented on this target");
1723 }
1724
1725 /// Retrieve the name of the platform as it is used in the
1726 /// availability attribute.
1727 StringRef getPlatformName() const { return PlatformName; }
1728
1729 /// Retrieve the minimum desired version of the platform, to
1730 /// which the program should be compiled.
1731 VersionTuple getPlatformMinVersion() const { return PlatformMinVersion; }
1732
1733 bool isBigEndian() const { return BigEndian; }
1734 bool isLittleEndian() const { return !BigEndian; }
1735
1736 /// Whether the option -fextend-arguments={32,64} is supported on the target.
1737 virtual bool supportsExtendIntArgs() const { return false; }
1738
1739 /// Controls if __arithmetic_fence is supported in the targeted backend.
1740 virtual bool checkArithmeticFenceSupported() const { return false; }
1741
1742 /// Gets the default calling convention for the given target.
1743 ///
1744 /// This function does not take into account any user options to override the
1745 /// default calling convention. For that, see
1746 /// ASTContext::getDefaultCallingConvention().
1748 // Not all targets will specify an explicit calling convention that we can
1749 // express. This will always do the right thing, even though it's not
1750 // an explicit calling convention.
1751 return CC_C;
1752 }
1753
1754 /// Get the default atomic options.
1756
1763
1764 /// Determines whether a given calling convention is valid for the
1765 /// target. A calling convention can either be accepted, produce a warning
1766 /// and be substituted with the default calling convention, or (someday)
1767 /// produce an error (such as using thiscall on a non-instance function).
1769 switch (CC) {
1770 default:
1771 return CCCR_Warning;
1772 case CC_C:
1773 return CCCR_OK;
1774 }
1775 }
1776
1782
1783 virtual CallingConvKind getCallingConvKind(bool ClangABICompat4) const;
1784
1785 /// Controls whether explicitly defaulted (`= default`) special member
1786 /// functions disqualify something from being POD-for-the-purposes-of-layout.
1787 /// Historically, Clang didn't consider these acceptable for POD, but GCC
1788 /// does. So in newer Clang ABIs they are acceptable for POD to be compatible
1789 /// with GCC/Itanium ABI, and remains disqualifying for targets that need
1790 /// Clang backwards compatibility rather than GCC/Itanium ABI compatibility.
1791 virtual bool areDefaultedSMFStillPOD(const LangOptions&) const;
1792
1793 /// Controls whether global operator delete is called by the deleting
1794 /// destructor or at the point where ::delete was called. Historically Clang
1795 /// called global operator delete outside of the deleting destructor for both
1796 /// Microsoft and Itanium ABI. In Clang 21 support for ::delete was aligned
1797 /// with Microsoft ABI, so it will call global operator delete in the deleting
1798 /// destructor body.
1799 virtual bool callGlobalDeleteInDeletingDtor(const LangOptions &) const;
1800
1801 /// Controls whether to emit MSVC vector deleting destructors. The support for
1802 /// vector deleting affects vtable layout and therefore is an ABI breaking
1803 /// change. The support was only implemented at Clang 22 timeframe.
1804 virtual bool emitVectorDeletingDtors(const LangOptions &) const;
1805
1806 /// Controls if __builtin_longjmp / __builtin_setjmp can be lowered to
1807 /// llvm.eh.sjlj.longjmp / llvm.eh.sjlj.setjmp.
1808 virtual bool hasSjLjLowering() const {
1809 return false;
1810 }
1811
1812 /// Check if the target supports CFProtection branch.
1813 virtual bool
1814 checkCFProtectionBranchSupported(DiagnosticsEngine &Diags) const;
1815
1816 /// Get the target default CFBranchLabelScheme scheme
1817 virtual CFBranchLabelSchemeKind getDefaultCFBranchLabelScheme() const;
1818
1819 virtual bool
1820 checkCFBranchLabelSchemeSupported(const CFBranchLabelSchemeKind Scheme,
1821 DiagnosticsEngine &Diags) const;
1822
1823 /// Check if the target supports CFProtection return.
1824 virtual bool
1825 checkCFProtectionReturnSupported(DiagnosticsEngine &Diags) const;
1826
1827 /// Whether target allows to overalign ABI-specified preferred alignment
1828 virtual bool allowsLargerPreferedTypeAlignment() const { return true; }
1829
1830 /// Whether target defaults to the `power` alignment rules of AIX.
1831 virtual bool defaultsToAIXPowerAlignment() const { return false; }
1832
1833 /// Set supported OpenCL extensions and optional core features.
1834 virtual void setSupportedOpenCLOpts() {}
1835
1836 virtual void supportAllOpenCLOpts(bool V = true) {
1837#define OPENCLEXTNAME(Ext) \
1838 setFeatureEnabled(getTargetOpts().OpenCLFeaturesMap, #Ext, V);
1839#include "clang/Basic/OpenCLExtensions.def"
1840 }
1841
1842 /// Set supported OpenCL extensions as written on command line
1844 for (const auto &Ext : getTargetOpts().OpenCLExtensionsAsWritten) {
1845 bool IsPrefixed = (Ext[0] == '+' || Ext[0] == '-');
1846 std::string Name = IsPrefixed ? Ext.substr(1) : Ext;
1847 bool V = IsPrefixed ? Ext[0] == '+' : true;
1848
1849 if (Name == "all") {
1851 continue;
1852 }
1853
1854 getTargetOpts().OpenCLFeaturesMap[Name] = V;
1855 }
1856 }
1857
1858 /// Set features that depend on other features.
1859 virtual void setDependentOpenCLOpts();
1860
1861 /// Get supported OpenCL extensions and optional core features.
1862 llvm::StringMap<bool> &getSupportedOpenCLOpts() {
1863 return getTargetOpts().OpenCLFeaturesMap;
1864 }
1865
1866 /// Get const supported OpenCL extensions and optional core features.
1867 const llvm::StringMap<bool> &getSupportedOpenCLOpts() const {
1868 return getTargetOpts().OpenCLFeaturesMap;
1869 }
1870
1871 /// Get address space for OpenCL type.
1872 virtual LangAS getOpenCLTypeAddrSpace(OpenCLTypeKind TK) const;
1873
1874 /// \returns Target specific vtbl ptr address space.
1875 virtual unsigned getVtblPtrAddressSpace() const {
1876 return 0;
1877 }
1878
1879 /// \returns If a target requires an address within a target specific address
1880 /// space \p AddressSpace to be converted in order to be used, then return the
1881 /// corresponding target specific DWARF address space.
1882 ///
1883 /// \returns Otherwise return std::nullopt and no conversion will be emitted
1884 /// in the DWARF.
1885 virtual std::optional<unsigned> getDWARFAddressSpace(unsigned AddressSpace)
1886 const {
1887 return std::nullopt;
1888 }
1889
1890 /// \returns The version of the SDK which was used during the compilation if
1891 /// one was specified, or an empty version otherwise.
1892 const llvm::VersionTuple &getSDKVersion() const {
1893 return getTargetOpts().SDKVersion;
1894 }
1895
1896 /// Check the target is valid after it is fully initialized.
1897 virtual bool validateTarget(DiagnosticsEngine &Diags) const {
1898 return true;
1899 }
1900
1901 /// Check that OpenCL target has valid options setting based on OpenCL
1902 /// version.
1903 virtual bool validateOpenCLTarget(const LangOptions &Opts,
1904 DiagnosticsEngine &Diags) const;
1905
1906 virtual void setAuxTarget(const TargetInfo *Aux) {}
1907
1909
1910 /// Whether target allows debuginfo types for decl only variables/functions.
1911 virtual bool allowDebugInfoForExternalRef() const { return false; }
1912
1913 /// Returns the darwin target variant triple, the variant of the deployment
1914 /// target for which the code is being compiled.
1915 const llvm::Triple *getDarwinTargetVariantTriple() const {
1917 }
1918
1919 /// Returns the version of the darwin target variant SDK which was used during
1920 /// the compilation if one was specified, or an empty version otherwise.
1921 std::optional<VersionTuple> getDarwinTargetVariantSDKVersion() const {
1922 return !getTargetOpts().DarwinTargetVariantSDKVersion.empty()
1923 ? getTargetOpts().DarwinTargetVariantSDKVersion
1924 : std::optional<VersionTuple>();
1925 }
1926
1927 /// Whether to support HIP image/texture API's.
1928 virtual bool hasHIPImageSupport() const { return true; }
1929
1930 /// The first value in the pair is the minimum offset between two objects to
1931 /// avoid false sharing (destructive interference). The second value in the
1932 /// pair is maximum size of contiguous memory to promote true sharing
1933 /// (constructive interference). Neither of these values are considered part
1934 /// of the ABI and can be changed by targets at any time.
1935 virtual std::pair<unsigned, unsigned> hardwareInterferenceSizes() const {
1936 return std::make_pair(64, 64);
1937 }
1938
1939protected:
1940 /// Copy type and layout related info.
1941 void copyAuxTarget(const TargetInfo *Aux);
1942 virtual uint64_t getPointerWidthV(LangAS AddrSpace) const {
1943 return PointerWidth;
1944 }
1945 virtual uint64_t getPointerAlignV(LangAS AddrSpace) const {
1946 return PointerAlign;
1947 }
1948 virtual enum IntType getPtrDiffTypeV(LangAS AddrSpace) const {
1949 return PtrDiffType;
1950 }
1953 virtual ArrayRef<AddlRegName> getGCCAddlRegNames() const { return {}; }
1954
1955private:
1956 // Assert the values for the fractional and integral bits for each fixed point
1957 // type follow the restrictions given in clause 6.2.6.3 of N1169.
1958 void CheckFixedPointBits() const;
1959};
1960
1961namespace targets {
1962std::unique_ptr<clang::TargetInfo>
1963AllocateTarget(const llvm::Triple &Triple, const clang::TargetOptions &Opts);
1964} // namespace targets
1965
1966} // end namespace clang
1967
1968#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:792
virtual std::optional< std::string > getTargetID() const
Returns the target ID if supported.
unsigned getShortWidth() const
getShortWidth/Align - Return the size of 'signed short' and 'unsigned short' for this target,...
Definition TargetInfo.h: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 llvm intrinsics such as llvm.convert.to.fp16 should be used to convert to and from __fp...
virtual std::optional< std::pair< unsigned, unsigned > > getVScaleRange(const LangOptions &LangOpts, ArmStreamingKind Mode, llvm::StringMap< bool > *FeatureMap=nullptr) const
Returns target-specific min and max values VScale_Range.
const llvm::Triple * getDarwinTargetVariantTriple() const
Returns the darwin target variant triple, the variant of the deployment target for which the code is ...
virtual uint64_t getNullPointerValue(LangAS AddrSpace) const
Get integer value for null pointer.
Definition TargetInfo.h: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