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