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