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