File indexing completed on 2026-05-10 08:36:51
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef LLVM_CLANG_BASIC_TARGETINFO_H
0015 #define LLVM_CLANG_BASIC_TARGETINFO_H
0016
0017 #include "clang/Basic/AddressSpaces.h"
0018 #include "clang/Basic/BitmaskEnum.h"
0019 #include "clang/Basic/CFProtectionOptions.h"
0020 #include "clang/Basic/CodeGenOptions.h"
0021 #include "clang/Basic/LLVM.h"
0022 #include "clang/Basic/LangOptions.h"
0023 #include "clang/Basic/Specifiers.h"
0024 #include "clang/Basic/TargetCXXABI.h"
0025 #include "clang/Basic/TargetOptions.h"
0026 #include "llvm/ADT/APFloat.h"
0027 #include "llvm/ADT/APInt.h"
0028 #include "llvm/ADT/APSInt.h"
0029 #include "llvm/ADT/ArrayRef.h"
0030 #include "llvm/ADT/IntrusiveRefCntPtr.h"
0031 #include "llvm/ADT/SmallSet.h"
0032 #include "llvm/ADT/StringMap.h"
0033 #include "llvm/ADT/StringRef.h"
0034 #include "llvm/ADT/StringSet.h"
0035 #include "llvm/Frontend/OpenMP/OMPGridValues.h"
0036 #include "llvm/IR/DerivedTypes.h"
0037 #include "llvm/Support/DataTypes.h"
0038 #include "llvm/Support/Error.h"
0039 #include "llvm/Support/VersionTuple.h"
0040 #include "llvm/TargetParser/Triple.h"
0041 #include <cassert>
0042 #include <optional>
0043 #include <string>
0044 #include <utility>
0045 #include <vector>
0046
0047 namespace llvm {
0048 struct fltSemantics;
0049 }
0050
0051 namespace clang {
0052 class DiagnosticsEngine;
0053 class LangOptions;
0054 class CodeGenOptions;
0055 class MacroBuilder;
0056
0057
0058 struct ParsedTargetAttr {
0059 std::vector<std::string> Features;
0060 StringRef CPU;
0061 StringRef Tune;
0062 StringRef BranchProtection;
0063 StringRef Duplicate;
0064 bool operator ==(const ParsedTargetAttr &Other) const {
0065 return Duplicate == Other.Duplicate && CPU == Other.CPU &&
0066 Tune == Other.Tune && BranchProtection == Other.BranchProtection &&
0067 Features == Other.Features;
0068 }
0069 };
0070
0071 namespace Builtin { struct Info; }
0072
0073 enum class FloatModeKind {
0074 NoFloat = 0,
0075 Half = 1 << 0,
0076 Float = 1 << 1,
0077 Double = 1 << 2,
0078 LongDouble = 1 << 3,
0079 Float128 = 1 << 4,
0080 Ibm128 = 1 << 5,
0081 LLVM_MARK_AS_BITMASK_ENUM(Ibm128)
0082 };
0083
0084
0085
0086
0087 struct TransferrableTargetInfo {
0088 unsigned char PointerWidth, PointerAlign;
0089 unsigned char BoolWidth, BoolAlign;
0090 unsigned char ShortWidth, ShortAlign;
0091 unsigned char IntWidth, IntAlign;
0092 unsigned char HalfWidth, HalfAlign;
0093 unsigned char BFloat16Width, BFloat16Align;
0094 unsigned char FloatWidth, FloatAlign;
0095 unsigned char DoubleWidth, DoubleAlign;
0096 unsigned char LongDoubleWidth, LongDoubleAlign, Float128Align, Ibm128Align;
0097 unsigned char LargeArrayMinWidth, LargeArrayAlign;
0098 unsigned char LongWidth, LongAlign;
0099 unsigned char LongLongWidth, LongLongAlign;
0100 unsigned char Int128Align;
0101
0102
0103
0104 std::optional<unsigned> BitIntMaxAlign;
0105
0106
0107 unsigned char ShortAccumWidth, ShortAccumAlign;
0108 unsigned char AccumWidth, AccumAlign;
0109 unsigned char LongAccumWidth, LongAccumAlign;
0110 unsigned char ShortFractWidth, ShortFractAlign;
0111 unsigned char FractWidth, FractAlign;
0112 unsigned char LongFractWidth, LongFractAlign;
0113
0114
0115
0116
0117
0118
0119 bool PaddingOnUnsignedFixedPoint;
0120
0121
0122
0123
0124
0125
0126
0127
0128 unsigned char ShortAccumScale;
0129 unsigned char AccumScale;
0130 unsigned char LongAccumScale;
0131
0132 unsigned char DefaultAlignForAttributeAligned;
0133 unsigned char MinGlobalAlign;
0134
0135 unsigned short SuitableAlign;
0136 unsigned short NewAlign;
0137 unsigned MaxVectorAlign;
0138 unsigned MaxTLSAlign;
0139
0140 const llvm::fltSemantics *HalfFormat, *BFloat16Format, *FloatFormat,
0141 *DoubleFormat, *LongDoubleFormat, *Float128Format, *Ibm128Format;
0142
0143
0144 enum IntType {
0145 NoInt = 0,
0146 SignedChar,
0147 UnsignedChar,
0148 SignedShort,
0149 UnsignedShort,
0150 SignedInt,
0151 UnsignedInt,
0152 SignedLong,
0153 UnsignedLong,
0154 SignedLongLong,
0155 UnsignedLongLong
0156 };
0157
0158 protected:
0159 IntType SizeType, IntMaxType, PtrDiffType, IntPtrType, WCharType, WIntType,
0160 Char16Type, Char32Type, Int64Type, Int16Type, SigAtomicType,
0161 ProcessIDType;
0162
0163
0164
0165
0166
0167 LLVM_PREFERRED_TYPE(bool)
0168 unsigned UseSignedCharForObjCBool : 1;
0169
0170
0171
0172
0173
0174
0175 LLVM_PREFERRED_TYPE(bool)
0176 unsigned UseBitFieldTypeAlignment : 1;
0177
0178
0179
0180
0181
0182
0183
0184 LLVM_PREFERRED_TYPE(bool)
0185 unsigned UseZeroLengthBitfieldAlignment : 1;
0186
0187
0188
0189 LLVM_PREFERRED_TYPE(bool)
0190 unsigned UseLeadingZeroLengthBitfield : 1;
0191
0192
0193 LLVM_PREFERRED_TYPE(bool)
0194 unsigned UseExplicitBitFieldAlignment : 1;
0195
0196
0197
0198 unsigned ZeroLengthBitfieldBoundary;
0199
0200
0201
0202 unsigned MaxAlignedAttribute;
0203 };
0204
0205
0206 enum OpenCLTypeKind : uint8_t {
0207 OCLTK_Default,
0208 OCLTK_ClkEvent,
0209 OCLTK_Event,
0210 OCLTK_Image,
0211 OCLTK_Pipe,
0212 OCLTK_Queue,
0213 OCLTK_ReserveID,
0214 OCLTK_Sampler,
0215 };
0216
0217
0218
0219 class TargetInfo : public TransferrableTargetInfo,
0220 public RefCountedBase<TargetInfo> {
0221 std::shared_ptr<TargetOptions> TargetOpts;
0222 llvm::Triple Triple;
0223 protected:
0224
0225
0226 bool BigEndian;
0227 bool TLSSupported;
0228 bool VLASupported;
0229 bool NoAsmVariants;
0230 bool HasLegalHalfType;
0231
0232 bool HalfArgsAndReturns;
0233 bool HasFloat128;
0234 bool HasFloat16;
0235 bool HasBFloat16;
0236 bool HasFullBFloat16;
0237
0238
0239 bool HasIbm128;
0240 bool HasLongDouble;
0241 bool HasFPReturn;
0242 bool HasStrictFP;
0243
0244 unsigned char MaxAtomicPromoteWidth, MaxAtomicInlineWidth;
0245 std::string DataLayoutString;
0246 const char *UserLabelPrefix;
0247 const char *MCountName;
0248 unsigned char RegParmMax, SSERegParmMax;
0249 TargetCXXABI TheCXXABI;
0250 const LangASMap *AddrSpaceMap;
0251
0252 mutable StringRef PlatformName;
0253 mutable VersionTuple PlatformMinVersion;
0254
0255 LLVM_PREFERRED_TYPE(bool)
0256 unsigned HasAlignMac68kSupport : 1;
0257 LLVM_PREFERRED_TYPE(FloatModeKind)
0258 unsigned RealTypeUsesObjCFPRetMask : llvm::BitWidth<FloatModeKind>;
0259 LLVM_PREFERRED_TYPE(bool)
0260 unsigned ComplexLongDoubleUsesFP2Ret : 1;
0261
0262 LLVM_PREFERRED_TYPE(bool)
0263 unsigned HasBuiltinMSVaList : 1;
0264
0265 LLVM_PREFERRED_TYPE(bool)
0266 unsigned HasAArch64SVETypes : 1;
0267
0268 LLVM_PREFERRED_TYPE(bool)
0269 unsigned HasRISCVVTypes : 1;
0270
0271 LLVM_PREFERRED_TYPE(bool)
0272 unsigned AllowAMDGPUUnsafeFPAtomics : 1;
0273
0274 LLVM_PREFERRED_TYPE(bool)
0275 unsigned HasUnalignedAccess : 1;
0276
0277 unsigned ARMCDECoprocMask : 8;
0278
0279 unsigned MaxOpenCLWorkGroupSize;
0280
0281 std::optional<unsigned> MaxBitIntWidth;
0282
0283 std::optional<llvm::Triple> DarwinTargetVariantTriple;
0284
0285
0286 TargetInfo(const llvm::Triple &T);
0287
0288
0289
0290 void resetDataLayout(StringRef DL, const char *UserLabelPrefix = "");
0291
0292
0293
0294
0295
0296 llvm::StringSet<> ReadOnlyFeatures;
0297
0298 public:
0299
0300
0301
0302
0303
0304 static TargetInfo *
0305 CreateTargetInfo(DiagnosticsEngine &Diags,
0306 const std::shared_ptr<TargetOptions> &Opts);
0307
0308 virtual ~TargetInfo();
0309
0310
0311 TargetOptions &getTargetOpts() const {
0312 assert(TargetOpts && "Missing target options");
0313 return *TargetOpts;
0314 }
0315
0316
0317
0318 enum BuiltinVaListKind {
0319
0320 CharPtrBuiltinVaList = 0,
0321
0322
0323 VoidPtrBuiltinVaList,
0324
0325
0326
0327 AArch64ABIBuiltinVaList,
0328
0329
0330
0331 PNaClABIBuiltinVaList,
0332
0333
0334
0335
0336 PowerABIBuiltinVaList,
0337
0338
0339
0340 X86_64ABIBuiltinVaList,
0341
0342
0343
0344
0345 AAPCSABIBuiltinVaList,
0346
0347
0348
0349
0350
0351
0352
0353
0354 SystemZBuiltinVaList,
0355
0356
0357
0358
0359
0360
0361 HexagonBuiltinVaList,
0362
0363
0364
0365
0366
0367
0368 XtensaABIBuiltinVaList
0369 };
0370
0371 protected:
0372
0373
0374 bool UseAddrSpaceMapMangling;
0375
0376 public:
0377 IntType getSizeType() const { return SizeType; }
0378 IntType getSignedSizeType() const {
0379 switch (SizeType) {
0380 case UnsignedShort:
0381 return SignedShort;
0382 case UnsignedInt:
0383 return SignedInt;
0384 case UnsignedLong:
0385 return SignedLong;
0386 case UnsignedLongLong:
0387 return SignedLongLong;
0388 default:
0389 llvm_unreachable("Invalid SizeType");
0390 }
0391 }
0392 IntType getIntMaxType() const { return IntMaxType; }
0393 IntType getUIntMaxType() const {
0394 return getCorrespondingUnsignedType(IntMaxType);
0395 }
0396 IntType getPtrDiffType(LangAS AddrSpace) const {
0397 return AddrSpace == LangAS::Default ? PtrDiffType
0398 : getPtrDiffTypeV(AddrSpace);
0399 }
0400 IntType getUnsignedPtrDiffType(LangAS AddrSpace) const {
0401 return getCorrespondingUnsignedType(getPtrDiffType(AddrSpace));
0402 }
0403 IntType getIntPtrType() const { return IntPtrType; }
0404 IntType getUIntPtrType() const {
0405 return getCorrespondingUnsignedType(IntPtrType);
0406 }
0407 IntType getWCharType() const { return WCharType; }
0408 IntType getWIntType() const { return WIntType; }
0409 IntType getChar16Type() const { return Char16Type; }
0410 IntType getChar32Type() const { return Char32Type; }
0411 IntType getInt64Type() const { return Int64Type; }
0412 IntType getUInt64Type() const {
0413 return getCorrespondingUnsignedType(Int64Type);
0414 }
0415 IntType getInt16Type() const { return Int16Type; }
0416 IntType getUInt16Type() const {
0417 return getCorrespondingUnsignedType(Int16Type);
0418 }
0419 IntType getSigAtomicType() const { return SigAtomicType; }
0420 IntType getProcessIDType() const { return ProcessIDType; }
0421
0422 static IntType getCorrespondingUnsignedType(IntType T) {
0423 switch (T) {
0424 case SignedChar:
0425 return UnsignedChar;
0426 case SignedShort:
0427 return UnsignedShort;
0428 case SignedInt:
0429 return UnsignedInt;
0430 case SignedLong:
0431 return UnsignedLong;
0432 case SignedLongLong:
0433 return UnsignedLongLong;
0434 default:
0435 llvm_unreachable("Unexpected signed integer type");
0436 }
0437 }
0438
0439
0440
0441
0442
0443 bool doUnsignedFixedPointTypesHavePadding() const {
0444 return PaddingOnUnsignedFixedPoint;
0445 }
0446
0447
0448
0449
0450 unsigned getTypeWidth(IntType T) const;
0451
0452
0453 virtual IntType getIntTypeByWidth(unsigned BitWidth, bool IsSigned) const;
0454
0455
0456 virtual IntType getLeastIntTypeByWidth(unsigned BitWidth,
0457 bool IsSigned) const;
0458
0459
0460
0461
0462
0463
0464
0465 FloatModeKind getRealTypeByWidth(unsigned BitWidth,
0466 FloatModeKind ExplicitType) const;
0467
0468
0469
0470
0471 unsigned getTypeAlign(IntType T) const;
0472
0473
0474 static bool isTypeSigned(IntType T);
0475
0476
0477
0478 uint64_t getPointerWidth(LangAS AddrSpace) const {
0479 return AddrSpace == LangAS::Default ? PointerWidth
0480 : getPointerWidthV(AddrSpace);
0481 }
0482 uint64_t getPointerAlign(LangAS AddrSpace) const {
0483 return AddrSpace == LangAS::Default ? PointerAlign
0484 : getPointerAlignV(AddrSpace);
0485 }
0486
0487
0488 virtual uint64_t getMaxPointerWidth() const {
0489 return PointerWidth;
0490 }
0491
0492
0493
0494 virtual uint64_t getNullPointerValue(LangAS AddrSpace) const { return 0; }
0495
0496
0497
0498
0499 virtual bool isAddressSpaceSupersetOf(LangAS A, LangAS B) const {
0500 return A == B;
0501 }
0502
0503
0504 unsigned getBoolWidth() const { return BoolWidth; }
0505
0506
0507 unsigned getBoolAlign() const { return BoolAlign; }
0508
0509 unsigned getCharWidth() const { return 8; }
0510 unsigned getCharAlign() const { return 8; }
0511
0512
0513
0514 unsigned getShortWidth() const { return ShortWidth; }
0515 unsigned getShortAlign() const { return ShortAlign; }
0516
0517
0518
0519 unsigned getIntWidth() const { return IntWidth; }
0520 unsigned getIntAlign() const { return IntAlign; }
0521
0522
0523
0524 unsigned getLongWidth() const { return LongWidth; }
0525 unsigned getLongAlign() const { return LongAlign; }
0526
0527
0528
0529 unsigned getLongLongWidth() const { return LongLongWidth; }
0530 unsigned getLongLongAlign() const { return LongLongAlign; }
0531
0532
0533 unsigned getInt128Align() const { return Int128Align; }
0534
0535
0536
0537 unsigned getBitIntMaxAlign() const {
0538 return BitIntMaxAlign.value_or(LongLongAlign);
0539 }
0540
0541
0542
0543 unsigned getBitIntWidth(unsigned NumBits) const {
0544 return llvm::alignTo(NumBits, getBitIntAlign(NumBits));
0545 }
0546 unsigned getBitIntAlign(unsigned NumBits) const {
0547 return std::clamp<unsigned>(llvm::PowerOf2Ceil(NumBits), getCharWidth(),
0548 getBitIntMaxAlign());
0549 }
0550
0551
0552
0553 unsigned getShortAccumWidth() const { return ShortAccumWidth; }
0554 unsigned getShortAccumAlign() const { return ShortAccumAlign; }
0555
0556
0557
0558 unsigned getAccumWidth() const { return AccumWidth; }
0559 unsigned getAccumAlign() const { return AccumAlign; }
0560
0561
0562
0563 unsigned getLongAccumWidth() const { return LongAccumWidth; }
0564 unsigned getLongAccumAlign() const { return LongAccumAlign; }
0565
0566
0567
0568 unsigned getShortFractWidth() const { return ShortFractWidth; }
0569 unsigned getShortFractAlign() const { return ShortFractAlign; }
0570
0571
0572
0573 unsigned getFractWidth() const { return FractWidth; }
0574 unsigned getFractAlign() const { return FractAlign; }
0575
0576
0577
0578 unsigned getLongFractWidth() const { return LongFractWidth; }
0579 unsigned getLongFractAlign() const { return LongFractAlign; }
0580
0581
0582
0583 unsigned getShortAccumScale() const { return ShortAccumScale; }
0584 unsigned getShortAccumIBits() const {
0585 return ShortAccumWidth - ShortAccumScale - 1;
0586 }
0587
0588
0589
0590 unsigned getAccumScale() const { return AccumScale; }
0591 unsigned getAccumIBits() const { return AccumWidth - AccumScale - 1; }
0592
0593
0594
0595 unsigned getLongAccumScale() const { return LongAccumScale; }
0596 unsigned getLongAccumIBits() const {
0597 return LongAccumWidth - LongAccumScale - 1;
0598 }
0599
0600
0601
0602 unsigned getUnsignedShortAccumScale() const {
0603 return PaddingOnUnsignedFixedPoint ? ShortAccumScale : ShortAccumScale + 1;
0604 }
0605 unsigned getUnsignedShortAccumIBits() const {
0606 return PaddingOnUnsignedFixedPoint
0607 ? getShortAccumIBits()
0608 : ShortAccumWidth - getUnsignedShortAccumScale();
0609 }
0610
0611
0612
0613 unsigned getUnsignedAccumScale() const {
0614 return PaddingOnUnsignedFixedPoint ? AccumScale : AccumScale + 1;
0615 }
0616 unsigned getUnsignedAccumIBits() const {
0617 return PaddingOnUnsignedFixedPoint ? getAccumIBits()
0618 : AccumWidth - getUnsignedAccumScale();
0619 }
0620
0621
0622
0623 unsigned getUnsignedLongAccumScale() const {
0624 return PaddingOnUnsignedFixedPoint ? LongAccumScale : LongAccumScale + 1;
0625 }
0626 unsigned getUnsignedLongAccumIBits() const {
0627 return PaddingOnUnsignedFixedPoint
0628 ? getLongAccumIBits()
0629 : LongAccumWidth - getUnsignedLongAccumScale();
0630 }
0631
0632
0633
0634 unsigned getShortFractScale() const { return ShortFractWidth - 1; }
0635
0636
0637
0638 unsigned getFractScale() const { return FractWidth - 1; }
0639
0640
0641
0642 unsigned getLongFractScale() const { return LongFractWidth - 1; }
0643
0644
0645
0646 unsigned getUnsignedShortFractScale() const {
0647 return PaddingOnUnsignedFixedPoint ? getShortFractScale()
0648 : getShortFractScale() + 1;
0649 }
0650
0651
0652
0653 unsigned getUnsignedFractScale() const {
0654 return PaddingOnUnsignedFixedPoint ? getFractScale() : getFractScale() + 1;
0655 }
0656
0657
0658
0659 unsigned getUnsignedLongFractScale() const {
0660 return PaddingOnUnsignedFixedPoint ? getLongFractScale()
0661 : getLongFractScale() + 1;
0662 }
0663
0664
0665 virtual bool hasInt128Type() const {
0666 return (getPointerWidth(LangAS::Default) >= 64) ||
0667 getTargetOpts().ForceEnableInt128;
0668 }
0669
0670
0671
0672
0673
0674
0675
0676 virtual bool hasBitIntType() const {
0677 return false;
0678 }
0679
0680
0681
0682 virtual size_t getMaxBitIntWidth() const {
0683
0684 if (MaxBitIntWidth)
0685 return std::min<size_t>(*MaxBitIntWidth, llvm::IntegerType::MAX_INT_BITS);
0686
0687
0688
0689
0690
0691
0692
0693 return 128;
0694 }
0695
0696
0697 virtual bool hasLegalHalfType() const { return HasLegalHalfType; }
0698
0699
0700 virtual bool allowHalfArgsAndReturns() const { return HalfArgsAndReturns; }
0701
0702
0703 virtual bool hasFloat128Type() const { return HasFloat128; }
0704
0705
0706 virtual bool hasFloat16Type() const { return HasFloat16; }
0707
0708
0709 virtual bool hasBFloat16Type() const {
0710 return HasBFloat16 || HasFullBFloat16;
0711 }
0712
0713
0714
0715 virtual bool hasFullBFloat16Type() const { return HasFullBFloat16; }
0716
0717
0718 virtual bool hasIbm128Type() const { return HasIbm128; }
0719
0720
0721 virtual bool hasLongDoubleType() const { return HasLongDouble; }
0722
0723
0724
0725 virtual bool hasFPReturn() const { return HasFPReturn; }
0726
0727
0728 virtual bool hasStrictFP() const { return HasStrictFP; }
0729
0730
0731
0732
0733 unsigned getSuitableAlign() const { return SuitableAlign; }
0734
0735
0736
0737 unsigned getDefaultAlignForAttributeAligned() const {
0738 return DefaultAlignForAttributeAligned;
0739 }
0740
0741
0742
0743
0744
0745 virtual unsigned getMinGlobalAlign(uint64_t Size, bool HasNonWeakDef) const {
0746 return MinGlobalAlign;
0747 }
0748
0749
0750
0751
0752 unsigned getNewAlign() const {
0753 return NewAlign ? NewAlign : std::max(LongDoubleAlign, LongLongAlign);
0754 }
0755
0756
0757
0758 unsigned getWCharWidth() const { return getTypeWidth(WCharType); }
0759 unsigned getWCharAlign() const { return getTypeAlign(WCharType); }
0760
0761
0762
0763 unsigned getChar16Width() const { return getTypeWidth(Char16Type); }
0764 unsigned getChar16Align() const { return getTypeAlign(Char16Type); }
0765
0766
0767
0768 unsigned getChar32Width() const { return getTypeWidth(Char32Type); }
0769 unsigned getChar32Align() const { return getTypeAlign(Char32Type); }
0770
0771
0772 unsigned getHalfWidth() const { return HalfWidth; }
0773 unsigned getHalfAlign() const { return HalfAlign; }
0774 const llvm::fltSemantics &getHalfFormat() const { return *HalfFormat; }
0775
0776
0777 unsigned getFloatWidth() const { return FloatWidth; }
0778 unsigned getFloatAlign() const { return FloatAlign; }
0779 const llvm::fltSemantics &getFloatFormat() const { return *FloatFormat; }
0780
0781
0782 unsigned getBFloat16Width() const { return BFloat16Width; }
0783 unsigned getBFloat16Align() const { return BFloat16Align; }
0784 const llvm::fltSemantics &getBFloat16Format() const { return *BFloat16Format; }
0785
0786
0787 unsigned getDoubleWidth() const { return DoubleWidth; }
0788 unsigned getDoubleAlign() const { return DoubleAlign; }
0789 const llvm::fltSemantics &getDoubleFormat() const { return *DoubleFormat; }
0790
0791
0792
0793 unsigned getLongDoubleWidth() const { return LongDoubleWidth; }
0794 unsigned getLongDoubleAlign() const { return LongDoubleAlign; }
0795 const llvm::fltSemantics &getLongDoubleFormat() const {
0796 return *LongDoubleFormat;
0797 }
0798
0799
0800
0801 unsigned getFloat128Width() const { return 128; }
0802 unsigned getFloat128Align() const { return Float128Align; }
0803 const llvm::fltSemantics &getFloat128Format() const {
0804 return *Float128Format;
0805 }
0806
0807
0808
0809 unsigned getIbm128Width() const { return 128; }
0810 unsigned getIbm128Align() const { return Ibm128Align; }
0811 const llvm::fltSemantics &getIbm128Format() const { return *Ibm128Format; }
0812
0813
0814 virtual const char *getLongDoubleMangling() const { return "e"; }
0815
0816
0817 virtual const char *getFloat128Mangling() const { return "g"; }
0818
0819
0820 virtual const char *getIbm128Mangling() const {
0821 llvm_unreachable("ibm128 not implemented on this target");
0822 }
0823
0824
0825 virtual const char *getBFloat16Mangling() const { return "DF16b"; }
0826
0827
0828 virtual LangOptions::FPEvalMethodKind getFPEvalMethod() const {
0829 return LangOptions::FPEvalMethodKind::FEM_Source;
0830 }
0831
0832 virtual bool supportSourceEvalMethod() const { return true; }
0833
0834
0835
0836 unsigned getLargeArrayMinWidth() const { return LargeArrayMinWidth; }
0837 unsigned getLargeArrayAlign() const { return LargeArrayAlign; }
0838
0839
0840
0841 unsigned getMaxAtomicPromoteWidth() const { return MaxAtomicPromoteWidth; }
0842
0843
0844 unsigned getMaxAtomicInlineWidth() const { return MaxAtomicInlineWidth; }
0845
0846
0847 virtual void setMaxAtomicWidth() {}
0848
0849
0850 virtual bool hasBuiltinAtomic(uint64_t AtomicSizeInBits,
0851 uint64_t AlignmentInBits) const {
0852 return AtomicSizeInBits <= AlignmentInBits &&
0853 AtomicSizeInBits <= getMaxAtomicInlineWidth() &&
0854 (AtomicSizeInBits <= getCharWidth() ||
0855 llvm::isPowerOf2_64(AtomicSizeInBits / getCharWidth()));
0856 }
0857
0858
0859 unsigned getMaxVectorAlign() const { return MaxVectorAlign; }
0860
0861 unsigned getMaxOpenCLWorkGroupSize() const { return MaxOpenCLWorkGroupSize; }
0862
0863
0864
0865
0866 virtual unsigned getExnObjectAlignment() const {
0867
0868
0869
0870
0871
0872
0873
0874
0875 return getDefaultAlignForAttributeAligned();
0876 }
0877
0878
0879 unsigned getIntMaxTWidth() const {
0880 return getTypeWidth(IntMaxType);
0881 }
0882
0883
0884 virtual unsigned getUnwindWordWidth() const {
0885 return getPointerWidth(LangAS::Default);
0886 }
0887
0888
0889 virtual unsigned getRegisterWidth() const {
0890
0891
0892
0893 return PointerWidth;
0894 }
0895
0896
0897
0898 bool hasUnalignedAccess() const { return HasUnalignedAccess; }
0899
0900
0901
0902
0903 bool hasCheapUnalignedBitFieldAccess() const {
0904
0905 return hasUnalignedAccess();
0906 }
0907
0908
0909
0910
0911
0912 const char *getUserLabelPrefix() const { return UserLabelPrefix; }
0913
0914
0915 const char *getMCountName() const {
0916 return MCountName;
0917 }
0918
0919
0920
0921
0922
0923
0924 bool useSignedCharForObjCBool() const {
0925 return UseSignedCharForObjCBool;
0926 }
0927 void noSignedCharForObjCBool() {
0928 UseSignedCharForObjCBool = false;
0929 }
0930
0931
0932
0933 bool useBitFieldTypeAlignment() const {
0934 return UseBitFieldTypeAlignment;
0935 }
0936
0937
0938
0939 bool useZeroLengthBitfieldAlignment() const {
0940 return UseZeroLengthBitfieldAlignment;
0941 }
0942
0943
0944
0945 bool useLeadingZeroLengthBitfield() const {
0946 return UseLeadingZeroLengthBitfield;
0947 }
0948
0949
0950
0951 unsigned getZeroLengthBitfieldBoundary() const {
0952 return ZeroLengthBitfieldBoundary;
0953 }
0954
0955
0956
0957 unsigned getMaxAlignedAttribute() const { return MaxAlignedAttribute; }
0958
0959
0960
0961 bool useExplicitBitFieldAlignment() const {
0962 return UseExplicitBitFieldAlignment;
0963 }
0964
0965
0966 bool hasAlignMac68kSupport() const {
0967 return HasAlignMac68kSupport;
0968 }
0969
0970
0971
0972
0973 static const char *getTypeName(IntType T);
0974
0975
0976
0977
0978 const char *getTypeConstantSuffix(IntType T) const;
0979
0980
0981
0982
0983
0984 static const char *getTypeFormatModifier(IntType T);
0985
0986
0987
0988 bool useObjCFPRetForRealType(FloatModeKind T) const {
0989 return (int)((FloatModeKind)RealTypeUsesObjCFPRetMask & T);
0990 }
0991
0992
0993
0994 bool useObjCFP2RetForComplexLongDouble() const {
0995 return ComplexLongDoubleUsesFP2Ret;
0996 }
0997
0998
0999
1000
1001
1002 virtual bool useFP16ConversionIntrinsics() const {
1003 return true;
1004 }
1005
1006
1007
1008 bool useAddressSpaceMapMangling() const {
1009 return UseAddrSpaceMapMangling;
1010 }
1011
1012
1013
1014
1015
1016 virtual void getTargetDefines(const LangOptions &Opts,
1017 MacroBuilder &Builder) const = 0;
1018
1019
1020
1021
1022 virtual ArrayRef<Builtin::Info> getTargetBuiltins() const = 0;
1023
1024
1025 virtual std::optional<std::pair<unsigned, unsigned>>
1026 getVScaleRange(const LangOptions &LangOpts,
1027 bool IsArmStreamingFunction) const {
1028 return std::nullopt;
1029 }
1030
1031
1032
1033
1034
1035 virtual bool isCLZForZeroUndef() const { return true; }
1036
1037
1038
1039 virtual BuiltinVaListKind getBuiltinVaListKind() const = 0;
1040
1041
1042
1043 bool hasBuiltinMSVaList() const { return HasBuiltinMSVaList; }
1044
1045
1046
1047 bool hasAArch64SVETypes() const { return HasAArch64SVETypes; }
1048
1049
1050
1051 bool hasRISCVVTypes() const { return HasRISCVVTypes; }
1052
1053
1054
1055 bool allowAMDGPUUnsafeFPAtomics() const { return AllowAMDGPUUnsafeFPAtomics; }
1056
1057
1058
1059 uint32_t getARMCDECoprocMask() const { return ARMCDECoprocMask; }
1060
1061
1062
1063
1064
1065 bool isValidClobber(StringRef Name) const;
1066
1067
1068
1069
1070
1071 virtual bool isValidGCCRegisterName(StringRef Name) const;
1072
1073
1074
1075
1076
1077
1078 StringRef getNormalizedGCCRegisterName(StringRef Name,
1079 bool ReturnCanonical = false) const;
1080
1081 virtual bool isSPRegName(StringRef) const { return false; }
1082
1083
1084
1085
1086
1087
1088
1089 virtual StringRef getConstraintRegister(StringRef Constraint,
1090 StringRef Expression) const {
1091 return "";
1092 }
1093
1094 struct ConstraintInfo {
1095 enum {
1096 CI_None = 0x00,
1097 CI_AllowsMemory = 0x01,
1098 CI_AllowsRegister = 0x02,
1099 CI_ReadWrite = 0x04,
1100 CI_HasMatchingInput = 0x08,
1101 CI_ImmediateConstant = 0x10,
1102 CI_EarlyClobber = 0x20,
1103 };
1104 unsigned Flags;
1105 int TiedOperand;
1106 struct {
1107 int Min;
1108 int Max;
1109 bool isConstrained;
1110 } ImmRange;
1111 llvm::SmallSet<int, 4> ImmSet;
1112
1113 std::string ConstraintStr;
1114 std::string Name;
1115 public:
1116 ConstraintInfo(StringRef ConstraintStr, StringRef Name)
1117 : Flags(0), TiedOperand(-1), ConstraintStr(ConstraintStr.str()),
1118 Name(Name.str()) {
1119 ImmRange.Min = ImmRange.Max = 0;
1120 ImmRange.isConstrained = false;
1121 }
1122
1123 const std::string &getConstraintStr() const { return ConstraintStr; }
1124 const std::string &getName() const { return Name; }
1125 bool isReadWrite() const { return (Flags & CI_ReadWrite) != 0; }
1126 bool earlyClobber() { return (Flags & CI_EarlyClobber) != 0; }
1127 bool allowsRegister() const { return (Flags & CI_AllowsRegister) != 0; }
1128 bool allowsMemory() const { return (Flags & CI_AllowsMemory) != 0; }
1129
1130
1131
1132 bool hasMatchingInput() const { return (Flags & CI_HasMatchingInput) != 0; }
1133
1134
1135
1136
1137
1138
1139 bool hasTiedOperand() const { return TiedOperand != -1; }
1140 unsigned getTiedOperand() const {
1141 assert(hasTiedOperand() && "Has no tied operand!");
1142 return (unsigned)TiedOperand;
1143 }
1144
1145 bool requiresImmediateConstant() const {
1146 return (Flags & CI_ImmediateConstant) != 0;
1147 }
1148 bool isValidAsmImmediate(const llvm::APInt &Value) const {
1149 if (!ImmSet.empty())
1150 return Value.isSignedIntN(32) && ImmSet.contains(Value.getZExtValue());
1151 return !ImmRange.isConstrained ||
1152 (Value.sge(ImmRange.Min) && Value.sle(ImmRange.Max));
1153 }
1154
1155 void setIsReadWrite() { Flags |= CI_ReadWrite; }
1156 void setEarlyClobber() { Flags |= CI_EarlyClobber; }
1157 void setAllowsMemory() { Flags |= CI_AllowsMemory; }
1158 void setAllowsRegister() { Flags |= CI_AllowsRegister; }
1159 void setHasMatchingInput() { Flags |= CI_HasMatchingInput; }
1160 void setRequiresImmediate(int Min, int Max) {
1161 Flags |= CI_ImmediateConstant;
1162 ImmRange.Min = Min;
1163 ImmRange.Max = Max;
1164 ImmRange.isConstrained = true;
1165 }
1166 void setRequiresImmediate(llvm::ArrayRef<int> Exacts) {
1167 Flags |= CI_ImmediateConstant;
1168 for (int Exact : Exacts)
1169 ImmSet.insert(Exact);
1170 }
1171 void setRequiresImmediate(int Exact) {
1172 Flags |= CI_ImmediateConstant;
1173 ImmSet.insert(Exact);
1174 }
1175 void setRequiresImmediate() {
1176 Flags |= CI_ImmediateConstant;
1177 }
1178
1179
1180
1181
1182
1183 void setTiedOperand(unsigned N, ConstraintInfo &Output) {
1184 Output.setHasMatchingInput();
1185 Flags = Output.Flags;
1186 TiedOperand = N;
1187
1188 }
1189 };
1190
1191
1192
1193
1194
1195
1196
1197 virtual bool validateGlobalRegisterVariable(StringRef RegName,
1198 unsigned RegSize,
1199 bool &HasSizeMismatch) const {
1200 HasSizeMismatch = false;
1201 return true;
1202 }
1203
1204
1205
1206
1207 bool validateOutputConstraint(ConstraintInfo &Info) const;
1208 bool validateInputConstraint(MutableArrayRef<ConstraintInfo> OutputConstraints,
1209 ConstraintInfo &info) const;
1210
1211 virtual bool validateOutputSize(const llvm::StringMap<bool> &FeatureMap,
1212 StringRef ,
1213 unsigned ) const {
1214 return true;
1215 }
1216
1217 virtual bool validateInputSize(const llvm::StringMap<bool> &FeatureMap,
1218 StringRef ,
1219 unsigned ) const {
1220 return true;
1221 }
1222 virtual bool
1223 validateConstraintModifier(StringRef ,
1224 char ,
1225 unsigned ,
1226 std::string &) const {
1227 return true;
1228 }
1229 virtual bool
1230 validateAsmConstraint(const char *&Name,
1231 TargetInfo::ConstraintInfo &info) const = 0;
1232
1233 bool resolveSymbolicName(const char *&Name,
1234 ArrayRef<ConstraintInfo> OutputConstraints,
1235 unsigned &Index) const;
1236
1237
1238
1239
1240 virtual std::string convertConstraint(const char *&Constraint) const {
1241
1242 if (*Constraint == 'p')
1243 return std::string("r");
1244 return std::string(1, *Constraint);
1245 }
1246
1247
1248
1249 virtual std::optional<std::string> handleAsmEscapedChar(char C) const {
1250 return std::nullopt;
1251 }
1252
1253
1254 virtual std::string_view getClobbers() const = 0;
1255
1256
1257
1258 virtual bool isNan2008() const {
1259 return true;
1260 }
1261
1262
1263 const llvm::Triple &getTriple() const {
1264 return Triple;
1265 }
1266
1267
1268 virtual std::optional<std::string> getTargetID() const {
1269 return std::nullopt;
1270 }
1271
1272 const char *getDataLayoutString() const {
1273 assert(!DataLayoutString.empty() && "Uninitialized DataLayout!");
1274 return DataLayoutString.c_str();
1275 }
1276
1277 struct GCCRegAlias {
1278 const char * const Aliases[5];
1279 const char * const Register;
1280 };
1281
1282 struct AddlRegName {
1283 const char * const Names[5];
1284 const unsigned RegNum;
1285 };
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297 virtual bool hasProtectedVisibility() const { return true; }
1298
1299
1300
1301 virtual bool shouldDLLImportComdatSymbols() const {
1302 return getTriple().isWindowsMSVCEnvironment() ||
1303 getTriple().isWindowsItaniumEnvironment() || getTriple().isPS();
1304 }
1305
1306
1307 virtual bool hasPS4DLLImportExport() const {
1308 return getTriple().isPS() ||
1309
1310
1311 (getTriple().isWindowsItaniumEnvironment() &&
1312 getTriple().getVendor() == llvm::Triple::SCEI);
1313 }
1314
1315
1316
1317
1318
1319
1320 virtual void adjust(DiagnosticsEngine &Diags, LangOptions &Opts);
1321
1322
1323
1324
1325
1326 virtual bool initFeatureMap(llvm::StringMap<bool> &Features,
1327 DiagnosticsEngine &Diags, StringRef CPU,
1328 const std::vector<std::string> &FeatureVec) const;
1329
1330
1331 virtual StringRef getABI() const { return StringRef(); }
1332
1333
1334 TargetCXXABI getCXXABI() const {
1335 return TheCXXABI;
1336 }
1337
1338
1339
1340
1341 virtual bool setCPU(const std::string &Name) {
1342 return false;
1343 }
1344
1345
1346 virtual void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const {}
1347
1348
1349 virtual void fillValidTuneCPUList(SmallVectorImpl<StringRef> &Values) const {
1350 fillValidCPUList(Values);
1351 }
1352
1353
1354 virtual bool isValidCPUName(StringRef Name) const {
1355 return true;
1356 }
1357
1358
1359
1360 virtual bool isValidTuneCPUName(StringRef Name) const {
1361 return isValidCPUName(Name);
1362 }
1363
1364 virtual ParsedTargetAttr parseTargetAttr(StringRef Str) const;
1365
1366
1367 virtual bool supportsTargetAttributeTune() const {
1368 return false;
1369 }
1370
1371
1372
1373
1374 virtual bool setABI(const std::string &Name) {
1375 return false;
1376 }
1377
1378
1379
1380
1381 virtual bool setFPMath(StringRef Name) {
1382 return false;
1383 }
1384
1385
1386 virtual bool hasFeatureEnabled(const llvm::StringMap<bool> &Features,
1387 StringRef Name) const {
1388 return Features.lookup(Name);
1389 }
1390
1391
1392
1393 virtual void setFeatureEnabled(llvm::StringMap<bool> &Features,
1394 StringRef Name,
1395 bool Enabled) const {
1396 Features[Name] = Enabled;
1397 }
1398
1399
1400 virtual bool isValidFeatureName(StringRef Feature) const {
1401 return true;
1402 }
1403
1404
1405
1406 virtual bool doesFeatureAffectCodeGen(StringRef Feature) const {
1407 return true;
1408 }
1409
1410 class BranchProtectionInfo {
1411 public:
1412 LangOptions::SignReturnAddressScopeKind SignReturnAddr;
1413 LangOptions::SignReturnAddressKeyKind SignKey;
1414 bool BranchTargetEnforcement;
1415 bool BranchProtectionPAuthLR;
1416 bool GuardedControlStack;
1417
1418 const char *getSignReturnAddrStr() const {
1419 switch (SignReturnAddr) {
1420 case LangOptions::SignReturnAddressScopeKind::None:
1421 return "none";
1422 case LangOptions::SignReturnAddressScopeKind::NonLeaf:
1423 return "non-leaf";
1424 case LangOptions::SignReturnAddressScopeKind::All:
1425 return "all";
1426 }
1427 llvm_unreachable("Unexpected SignReturnAddressScopeKind");
1428 }
1429
1430 const char *getSignKeyStr() const {
1431 switch (SignKey) {
1432 case LangOptions::SignReturnAddressKeyKind::AKey:
1433 return "a_key";
1434 case LangOptions::SignReturnAddressKeyKind::BKey:
1435 return "b_key";
1436 }
1437 llvm_unreachable("Unexpected SignReturnAddressKeyKind");
1438 }
1439
1440 BranchProtectionInfo()
1441 : SignReturnAddr(LangOptions::SignReturnAddressScopeKind::None),
1442 SignKey(LangOptions::SignReturnAddressKeyKind::AKey),
1443 BranchTargetEnforcement(false), BranchProtectionPAuthLR(false),
1444 GuardedControlStack(false) {}
1445
1446 BranchProtectionInfo(const LangOptions &LangOpts) {
1447 SignReturnAddr =
1448 LangOpts.hasSignReturnAddress()
1449 ? (LangOpts.isSignReturnAddressScopeAll()
1450 ? LangOptions::SignReturnAddressScopeKind::All
1451 : LangOptions::SignReturnAddressScopeKind::NonLeaf)
1452 : LangOptions::SignReturnAddressScopeKind::None;
1453 SignKey = LangOpts.isSignReturnAddressWithAKey()
1454 ? LangOptions::SignReturnAddressKeyKind::AKey
1455 : LangOptions::SignReturnAddressKeyKind::BKey;
1456 BranchTargetEnforcement = LangOpts.BranchTargetEnforcement;
1457 BranchProtectionPAuthLR = LangOpts.BranchProtectionPAuthLR;
1458 GuardedControlStack = LangOpts.GuardedControlStack;
1459 }
1460 };
1461
1462
1463
1464 virtual bool isBranchProtectionSupportedArch(StringRef Arch) const {
1465 return false;
1466 }
1467
1468
1469
1470 virtual bool validateBranchProtection(StringRef Spec, StringRef Arch,
1471 BranchProtectionInfo &BPI,
1472 const LangOptions &LO,
1473 StringRef &Err) const {
1474 Err = "";
1475 return false;
1476 }
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489 virtual bool handleTargetFeatures(std::vector<std::string> &Features,
1490 DiagnosticsEngine &Diags) {
1491 return true;
1492 }
1493
1494
1495 virtual bool hasFeature(StringRef Feature) const {
1496 return false;
1497 }
1498
1499
1500 bool isReadOnlyFeature(StringRef Feature) const {
1501 return ReadOnlyFeatures.count(Feature);
1502 }
1503
1504
1505
1506 bool supportsMultiVersioning() const {
1507 return getTriple().isX86() || getTriple().isAArch64() ||
1508 getTriple().isRISCV();
1509 }
1510
1511
1512 bool supportsIFunc() const {
1513 if (getTriple().isOSBinFormatMachO())
1514 return true;
1515 if (getTriple().isOSWindows() && getTriple().isAArch64())
1516 return true;
1517 if (getTriple().getArch() == llvm::Triple::ArchType::avr)
1518 return true;
1519 return getTriple().isOSBinFormatELF() &&
1520 ((getTriple().isOSLinux() && !getTriple().isMusl()) ||
1521 getTriple().isOSFreeBSD());
1522 }
1523
1524
1525
1526 virtual bool supportsCpuSupports() const { return false; }
1527 virtual bool supportsCpuIs() const { return false; }
1528 virtual bool supportsCpuInit() const { return false; }
1529
1530
1531
1532 virtual bool validateCpuSupports(StringRef Name) const { return false; }
1533
1534
1535
1536 virtual uint64_t getFMVPriority(ArrayRef<StringRef> Features) const {
1537 return 0;
1538 }
1539
1540
1541
1542 virtual bool validateCpuIs(StringRef Name) const { return false; }
1543
1544
1545
1546 virtual bool validateCPUSpecificCPUDispatch(StringRef Name) const {
1547 return false;
1548 }
1549
1550
1551 virtual char CPUSpecificManglingCharacter(StringRef Name) const {
1552 llvm_unreachable(
1553 "cpu_specific Multiversioning not implemented on this target");
1554 }
1555
1556
1557
1558 virtual StringRef getCPUSpecificTuneName(StringRef Name) const {
1559 llvm_unreachable(
1560 "cpu_specific Multiversioning not implemented on this target");
1561 }
1562
1563
1564
1565
1566 virtual void getCPUSpecificCPUDispatchFeatures(
1567 StringRef Name, llvm::SmallVectorImpl<StringRef> &Features) const {
1568 llvm_unreachable(
1569 "cpu_specific Multiversioning not implemented on this target");
1570 }
1571
1572
1573
1574 virtual std::optional<unsigned> getCPUCacheLineSize() const {
1575 return std::nullopt;
1576 }
1577
1578
1579 unsigned getRegParmMax() const {
1580 assert(RegParmMax < 7 && "RegParmMax value is larger than AST can handle");
1581 return RegParmMax;
1582 }
1583
1584
1585 bool isTLSSupported() const {
1586 return TLSSupported;
1587 }
1588
1589
1590
1591
1592
1593 unsigned getMaxTLSAlign() const { return MaxTLSAlign; }
1594
1595
1596 bool isVLASupported() const { return VLASupported; }
1597
1598
1599 bool isSEHTrySupported() const {
1600 return getTriple().isOSWindows() &&
1601 (getTriple().isX86() ||
1602 getTriple().getArch() == llvm::Triple::aarch64);
1603 }
1604
1605
1606
1607
1608
1609
1610
1611 bool hasNoAsmVariants() const {
1612 return NoAsmVariants;
1613 }
1614
1615
1616
1617
1618
1619 virtual int getEHDataRegisterNumber(unsigned RegNo) const {
1620 return -1;
1621 }
1622
1623
1624 virtual const char *getStaticInitSectionSpecifier() const {
1625 return nullptr;
1626 }
1627
1628 const LangASMap &getAddressSpaceMap() const { return *AddrSpaceMap; }
1629 unsigned getTargetAddressSpace(LangAS AS) const {
1630 if (isTargetAddressSpace(AS))
1631 return toTargetAddressSpace(AS);
1632 return getAddressSpaceMap()[(unsigned)AS];
1633 }
1634
1635
1636
1637
1638 virtual bool validatePointerAuthKey(const llvm::APSInt &value) const;
1639
1640
1641
1642 virtual LangAS getOpenCLBuiltinAddressSpace(unsigned AS) const {
1643 return getLangASFromTargetAS(AS);
1644 }
1645
1646
1647
1648 virtual LangAS getCUDABuiltinAddressSpace(unsigned AS) const {
1649 return getLangASFromTargetAS(AS);
1650 }
1651
1652
1653
1654
1655
1656 virtual std::optional<LangAS> getConstantAddressSpace() const {
1657 return LangAS::Default;
1658 }
1659
1660
1661
1662 virtual const llvm::omp::GV &getGridValue() const {
1663 llvm_unreachable("getGridValue not implemented on this target");
1664 }
1665
1666
1667
1668 StringRef getPlatformName() const { return PlatformName; }
1669
1670
1671
1672 VersionTuple getPlatformMinVersion() const { return PlatformMinVersion; }
1673
1674 bool isBigEndian() const { return BigEndian; }
1675 bool isLittleEndian() const { return !BigEndian; }
1676
1677
1678 virtual bool supportsExtendIntArgs() const { return false; }
1679
1680
1681 virtual bool checkArithmeticFenceSupported() const { return false; }
1682
1683
1684
1685 virtual CallingConv getDefaultCallingConv() const {
1686
1687
1688
1689 return CC_C;
1690 }
1691
1692 enum CallingConvCheckResult {
1693 CCCR_OK,
1694 CCCR_Warning,
1695 CCCR_Ignore,
1696 CCCR_Error,
1697 };
1698
1699
1700
1701
1702
1703 virtual CallingConvCheckResult checkCallingConvention(CallingConv CC) const {
1704 switch (CC) {
1705 default:
1706 return CCCR_Warning;
1707 case CC_C:
1708 return CCCR_OK;
1709 }
1710 }
1711
1712 enum CallingConvKind {
1713 CCK_Default,
1714 CCK_ClangABI4OrPS4,
1715 CCK_MicrosoftWin64
1716 };
1717
1718 virtual CallingConvKind getCallingConvKind(bool ClangABICompat4) const;
1719
1720
1721
1722
1723
1724
1725
1726 virtual bool areDefaultedSMFStillPOD(const LangOptions&) const;
1727
1728
1729
1730 virtual bool hasSjLjLowering() const {
1731 return false;
1732 }
1733
1734
1735 virtual bool
1736 checkCFProtectionBranchSupported(DiagnosticsEngine &Diags) const;
1737
1738
1739 virtual CFBranchLabelSchemeKind getDefaultCFBranchLabelScheme() const;
1740
1741 virtual bool
1742 checkCFBranchLabelSchemeSupported(const CFBranchLabelSchemeKind Scheme,
1743 DiagnosticsEngine &Diags) const;
1744
1745
1746 virtual bool
1747 checkCFProtectionReturnSupported(DiagnosticsEngine &Diags) const;
1748
1749
1750 virtual bool allowsLargerPreferedTypeAlignment() const { return true; }
1751
1752
1753 virtual bool defaultsToAIXPowerAlignment() const { return false; }
1754
1755
1756 virtual void setSupportedOpenCLOpts() {}
1757
1758 virtual void supportAllOpenCLOpts(bool V = true) {
1759 #define OPENCLEXTNAME(Ext) \
1760 setFeatureEnabled(getTargetOpts().OpenCLFeaturesMap, #Ext, V);
1761 #include "clang/Basic/OpenCLExtensions.def"
1762 }
1763
1764
1765 virtual void setCommandLineOpenCLOpts() {
1766 for (const auto &Ext : getTargetOpts().OpenCLExtensionsAsWritten) {
1767 bool IsPrefixed = (Ext[0] == '+' || Ext[0] == '-');
1768 std::string Name = IsPrefixed ? Ext.substr(1) : Ext;
1769 bool V = IsPrefixed ? Ext[0] == '+' : true;
1770
1771 if (Name == "all") {
1772 supportAllOpenCLOpts(V);
1773 continue;
1774 }
1775
1776 getTargetOpts().OpenCLFeaturesMap[Name] = V;
1777 }
1778 }
1779
1780
1781 llvm::StringMap<bool> &getSupportedOpenCLOpts() {
1782 return getTargetOpts().OpenCLFeaturesMap;
1783 }
1784
1785
1786 const llvm::StringMap<bool> &getSupportedOpenCLOpts() const {
1787 return getTargetOpts().OpenCLFeaturesMap;
1788 }
1789
1790
1791 virtual LangAS getOpenCLTypeAddrSpace(OpenCLTypeKind TK) const;
1792
1793
1794 virtual unsigned getVtblPtrAddressSpace() const {
1795 return 0;
1796 }
1797
1798
1799
1800
1801
1802
1803
1804 virtual std::optional<unsigned> getDWARFAddressSpace(unsigned AddressSpace)
1805 const {
1806 return std::nullopt;
1807 }
1808
1809
1810
1811 const llvm::VersionTuple &getSDKVersion() const {
1812 return getTargetOpts().SDKVersion;
1813 }
1814
1815
1816 virtual bool validateTarget(DiagnosticsEngine &Diags) const {
1817 return true;
1818 }
1819
1820
1821
1822 virtual bool validateOpenCLTarget(const LangOptions &Opts,
1823 DiagnosticsEngine &Diags) const;
1824
1825 virtual void setAuxTarget(const TargetInfo *Aux) {}
1826
1827
1828 virtual bool allowDebugInfoForExternalRef() const { return false; }
1829
1830
1831
1832 const llvm::Triple *getDarwinTargetVariantTriple() const {
1833 return DarwinTargetVariantTriple ? &*DarwinTargetVariantTriple : nullptr;
1834 }
1835
1836
1837
1838 const std::optional<VersionTuple> getDarwinTargetVariantSDKVersion() const {
1839 return !getTargetOpts().DarwinTargetVariantSDKVersion.empty()
1840 ? getTargetOpts().DarwinTargetVariantSDKVersion
1841 : std::optional<VersionTuple>();
1842 }
1843
1844
1845 virtual bool hasHIPImageSupport() const { return true; }
1846
1847
1848
1849
1850
1851
1852 virtual std::pair<unsigned, unsigned> hardwareInterferenceSizes() const {
1853 return std::make_pair(64, 64);
1854 }
1855
1856 protected:
1857
1858 void copyAuxTarget(const TargetInfo *Aux);
1859 virtual uint64_t getPointerWidthV(LangAS AddrSpace) const {
1860 return PointerWidth;
1861 }
1862 virtual uint64_t getPointerAlignV(LangAS AddrSpace) const {
1863 return PointerAlign;
1864 }
1865 virtual enum IntType getPtrDiffTypeV(LangAS AddrSpace) const {
1866 return PtrDiffType;
1867 }
1868 virtual ArrayRef<const char *> getGCCRegNames() const = 0;
1869 virtual ArrayRef<GCCRegAlias> getGCCRegAliases() const = 0;
1870 virtual ArrayRef<AddlRegName> getGCCAddlRegNames() const { return {}; }
1871
1872 private:
1873
1874
1875 void CheckFixedPointBits() const;
1876 };
1877
1878 namespace targets {
1879 std::unique_ptr<clang::TargetInfo>
1880 AllocateTarget(const llvm::Triple &Triple, const clang::TargetOptions &Opts);
1881 }
1882
1883 }
1884
1885 #endif