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