19#include "llvm/ADT/APFloat.h"
20#include "llvm/ADT/STLExtras.h"
21#include "llvm/Support/ErrorHandling.h"
22#include "llvm/TargetParser/TargetParser.h"
103 if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment() || T.isAndroid() ||
105 NewAlign = Triple.isArch64Bit() ? 128 : Triple.isArch32Bit() ? 64 : 0;
106 else if (T.isOSDarwin() || T.isOSOpenBSD())
170 ? TargetCXXABI::Microsoft
171 : TargetCXXABI::GenericItanium);
196 Diags.
Report(diag::err_opt_not_valid_on_target) <<
"cf-protection=branch";
202 Diags.
Report(diag::err_opt_not_valid_on_target) <<
"cf-protection=return";
210 default: llvm_unreachable(
"not an integer!");
228 default: llvm_unreachable(
"not an integer!");
253 default: llvm_unreachable(
"not an integer!");
271 default: llvm_unreachable(
"not an integer!");
286 unsigned BitWidth,
bool IsSigned)
const {
301 bool IsSigned)
const {
353 default: llvm_unreachable(
"not an integer!");
371 default: llvm_unreachable(
"not an integer!");
392 if (Opts.NoBitFieldTypeAlign)
395 switch (Opts.WCharSize) {
396 default: llvm_unreachable(
"invalid wchar_t width");
403 if (Opts.AlignDouble) {
429 assert(MaxPointerWidth == 32 || MaxPointerWidth == 64);
430 bool Is32BitArch = MaxPointerWidth == 32;
454 OpenCLFeaturesMap,
"__opencl_c_generic_address_space");
462 if (Opts.DoubleSize) {
463 if (Opts.DoubleSize == 32) {
468 }
else if (Opts.DoubleSize == 64) {
476 if (Opts.LongDoubleSize) {
481 }
else if (Opts.LongDoubleSize == 128) {
484 }
else if (Opts.LongDoubleSize == 80) {
486 if (
getTriple().isWindowsMSVCEnvironment()) {
490 if (
getTriple().getArch() == llvm::Triple::x86) {
501 if (Opts.NewAlignOverride)
507 CheckFixedPointBits();
510 Diags.
Report(diag::err_opt_not_valid_on_target) <<
"-fprotect-parens";
511 Opts.ProtectParens =
false;
514 if (Opts.MaxBitIntWidth)
517 if (Opts.FakeAddressSpaceMap)
523 const std::vector<std::string> &FeatureVec)
const {
524 for (
const auto &F : FeatureVec) {
529 if (Name[0] !=
'+' && Name[0] !=
'-')
530 Diags.
Report(diag::warn_fe_backend_invalid_feature_flag) << Name;
539 if (Features ==
"default")
542 Features.split(AttrFeatures,
",");
546 for (
auto &Feature : AttrFeatures) {
549 Feature = Feature.trim();
554 if (Feature.startswith(
"fpmath="))
557 if (Feature.startswith(
"branch-protection=")) {
558 Ret.BranchProtection = Feature.split(
'=').second.trim();
563 if (Feature.startswith(
"arch=")) {
564 if (!Ret.CPU.empty())
565 Ret.Duplicate =
"arch=";
567 Ret.CPU = Feature.split(
"=").second.trim();
568 }
else if (Feature.startswith(
"tune=")) {
569 if (!Ret.Tune.empty())
570 Ret.Duplicate =
"tune=";
572 Ret.Tune = Feature.split(
"=").second.trim();
573 }
else if (Feature.startswith(
"no-"))
574 Ret.Features.push_back(
"-" + Feature.split(
"-").second.str());
576 Ret.Features.push_back(
"+" + Feature.str());
583 if (
getCXXABI() != TargetCXXABI::Microsoft &&
584 (ClangABICompat4 ||
getTriple().isPS4()))
611 if (Name[0] ==
'%' || Name[0] ==
'#')
612 Name = Name.substr(1);
642 if (!Name.getAsInteger(0, n))
643 return n < Names.size();
647 if (llvm::is_contained(Names, Name))
652 for (
const char *AN : ARN.Names) {
657 if (AN == Name && ARN.RegNum < Names.size())
663 for (
const char *A : GRA.Aliases) {
674 bool ReturnCanonical)
const {
685 if (!Name.getAsInteger(0, n)) {
686 assert(n < Names.size() &&
"Out of bounds register number!");
693 for (
const char *AN : ARN.Names) {
698 if (AN == Name && ARN.RegNum < Names.size())
699 return ReturnCanonical ? Names[ARN.RegNum] : Name;
704 for (
const char *A : RA.Aliases) {
717 if (*Name !=
'=' && *Name !=
'+')
757 if (Name[1] ==
'=' || Name[1] ==
'+')
761 while (Name[1] && Name[1] !=
',')
790 unsigned &Index)
const {
791 assert(*Name ==
'[' &&
"Symbolic name did not start with '['");
793 const char *Start = Name;
794 while (*Name && *Name !=
']')
802 std::string SymbolicName(Start, Name - Start);
804 for (Index = 0; Index != OutputConstraints.size(); ++Index)
805 if (SymbolicName == OutputConstraints[Index].
getName())
823 if (*Name >=
'0' && *Name <=
'9') {
824 const char *DigitStart = Name;
825 while (Name[1] >=
'0' && Name[1] <=
'9')
827 const char *DigitEnd = Name;
829 if (StringRef(DigitStart, DigitEnd - DigitStart + 1)
830 .getAsInteger(10, i))
834 if (i >= OutputConstraints.size())
return false;
837 if (OutputConstraints[i].isReadWrite())
866 if (OutputConstraints[Index].isReadWrite())
913 while (Name[1] && Name[1] !=
',')
928void TargetInfo::CheckFixedPointBits()
const {
Provides definitions for the various language-specific address spaces.
Defines the Diagnostic-related interfaces.
static const LangASMap DefaultAddrSpaceMap
static StringRef removeGCCRegisterPrefix(StringRef Name)
static const LangASMap FakeAddrSpaceMap
Defines the clang::LangOptions interface.
static std::string getName(const CallEvent &Call)
Concrete class used by the front-end to report problems and issues.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
@ Ver15
Attempt to be ABI-compatible with code generated by Clang 15.0.x.
unsigned getOpenCLCompatibleVersion() const
Return the OpenCL version that kernel language is compatible with.
Exposes information about the current target.
unsigned getUnsignedLongFractScale() const
getUnsignedLongFractScale - Return the number of fractional bits in a 'unsigned long _Fract' type.
bool validateInputConstraint(MutableArrayRef< ConstraintInfo > OutputConstraints, ConstraintInfo &info) const
bool resolveSymbolicName(const char *&Name, ArrayRef< ConstraintInfo > OutputConstraints, unsigned &Index) const
void copyAuxTarget(const TargetInfo *Aux)
Copy type and layout related info.
TargetInfo(const llvm::Triple &T)
virtual bool checkCFProtectionReturnSupported(DiagnosticsEngine &Diags) const
Check if the target supports CFProtection return.
unsigned getShortWidth() const
Return the size of 'signed short' and 'unsigned short' for this target, in bits.
unsigned getUnsignedAccumScale() const
getUnsignedAccumScale/IBits - Return the number of fractional/integral bits in a 'unsigned _Accum' ty...
unsigned getIntAlign() const
virtual ArrayRef< AddlRegName > getGCCAddlRegNames() const
unsigned getUnsignedAccumIBits() const
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
const LangASMap * AddrSpaceMap
const char * UserLabelPrefix
unsigned getUnsignedFractScale() const
getUnsignedFractScale - Return the number of fractional bits in a 'unsigned _Fract' type.
unsigned getLongAlign() const
virtual IntType getLeastIntTypeByWidth(unsigned BitWidth, bool IsSigned) const
Return the smallest integer type with at least the specified width.
unsigned getLongLongAlign() const
virtual bool hasFeatureEnabled(const llvm::StringMap< bool > &Features, StringRef Name) const
Check if target has a given feature enabled.
unsigned HasAArch64SVETypes
void resetDataLayout(StringRef DL, const char *UserLabelPrefix="")
virtual ArrayRef< const char * > getGCCRegNames() const =0
unsigned getTypeWidth(IntType T) const
Return the width (in bits) of the specified integer type enum.
unsigned getLongFractScale() const
getLongFractScale - Return the number of fractional bits in a 'signed long _Fract' type.
static bool isTypeSigned(IntType T)
Returns true if the type is signed; false otherwise.
std::optional< unsigned > MaxBitIntWidth
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.
unsigned getAccumIBits() const
virtual CallingConvKind getCallingConvKind(bool ClangABICompat4) const
VersionTuple PlatformMinVersion
unsigned getIntWidth() const
getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for this target,...
unsigned getShortAccumIBits() const
unsigned getFloatWidth() const
getFloatWidth/Align/Format - Return the size/align/format of 'float'.
unsigned IsRenderScriptTarget
virtual ArrayRef< GCCRegAlias > getGCCRegAliases() const =0
StringRef getNormalizedGCCRegisterName(StringRef Name, bool ReturnCanonical=false) const
Returns the "normalized" GCC register name.
unsigned getLongAccumIBits() const
FloatModeKind getRealTypeByWidth(unsigned BitWidth, FloatModeKind ExplicitType) const
Return floating point type with specified width.
virtual IntType getIntTypeByWidth(unsigned BitWidth, bool IsSigned) const
Return integer type with specified width.
unsigned getHalfWidth() const
getHalfWidth/Align/Format - Return the size/align/format of 'half'.
unsigned char SSERegParmMax
unsigned char MaxAtomicPromoteWidth
virtual LangAS getOpenCLTypeAddrSpace(OpenCLTypeKind TK) const
Get address space for OpenCL type.
static const char * getTypeName(IntType T)
Return the user string for the specified integer type enum.
unsigned getCharAlign() const
unsigned RealTypeUsesObjCFPRetMask
unsigned MaxOpenCLWorkGroupSize
unsigned getLongLongWidth() const
getLongLongWidth/Align - Return the size of 'signed long long' and 'unsigned long long' for this targ...
virtual bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &info) const =0
llvm::StringMap< bool > & getSupportedOpenCLOpts()
Get supported OpenCL extensions and optional core features.
bool UseAddrSpaceMapMangling
Specify if mangling based on address space map should be used or not for language specific address sp...
unsigned ComplexLongDoubleUsesFP2Ret
virtual bool hasIbm128Type() const
Determine whether the __ibm128 type is supported on this target.
virtual void adjust(DiagnosticsEngine &Diags, LangOptions &Opts)
Set forced language options.
unsigned getUnsignedShortAccumIBits() const
std::string DataLayoutString
unsigned getUnsignedLongAccumScale() const
getUnsignedLongAccumScale/IBits - Return the number of fractional/integral bits in a 'unsigned long _...
virtual bool hasFloat128Type() const
Determine whether the __float128 type is supported on this target.
unsigned getUnsignedLongAccumIBits() const
unsigned getUnsignedShortFractScale() const
getUnsignedShortFractScale - Return the number of fractional bits in a 'unsigned short _Fract' type.
unsigned HasAlignMac68kSupport
const llvm::fltSemantics & getLongDoubleFormat() const
bool validateOutputConstraint(ConstraintInfo &Info) const
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
const char * getTypeConstantSuffix(IntType T) const
Return the constant suffix for the specified integer type enum.
unsigned getDoubleWidth() const
getDoubleWidth/Align/Format - Return the size/align/format of 'double'.
virtual bool checkArithmeticFenceSupported() const
Controls if __arithmetic_fence is supported in the targeted backend.
bool isValidClobber(StringRef Name) const
Returns whether the passed in string is a valid clobber in an inline asm statement.
virtual bool areDefaultedSMFStillPOD(const LangOptions &) const
Controls whether explicitly defaulted (= default) special member functions disqualify something from ...
unsigned getCharWidth() const
virtual ParsedTargetAttr parseTargetAttr(StringRef Str) const
unsigned getLongWidth() const
getLongWidth/Align - Return the size of 'signed long' and 'unsigned long' for this target,...
unsigned getFractScale() const
getFractScale - Return the number of fractional bits in a 'signed _Fract' type.
virtual bool initFeatureMap(llvm::StringMap< bool > &Features, DiagnosticsEngine &Diags, StringRef CPU, const std::vector< std::string > &FeatureVec) const
Initialize the map with the default set of target features for the CPU this should include all legal ...
virtual bool checkCFProtectionBranchSupported(DiagnosticsEngine &Diags) const
Check if the target supports CFProtection branch.
unsigned char MaxAtomicInlineWidth
unsigned AllowAMDGPUUnsafeFPAtomics
unsigned getShortFractScale() const
getShortFractScale - Return the number of fractional bits in a 'signed short _Fract' type.
virtual uint64_t getMaxPointerWidth() const
Return the maximum width of pointers on this target.
unsigned ARMCDECoprocMask
static const char * getTypeFormatModifier(IntType T)
Return the printf format modifier for the specified integer type enum.
unsigned getUnsignedShortAccumScale() const
getUnsignedShortAccumScale/IBits - Return the number of fractional/integral bits in a 'unsigned short...
unsigned HasBuiltinMSVaList
unsigned getTypeAlign(IntType T) const
Return the alignment (in bits) of the specified integer type enum.
unsigned getShortAlign() const
Return the alignment of 'signed short' and 'unsigned short' for this target.
virtual bool isValidGCCRegisterName(StringRef Name) const
Returns whether the passed in string is a valid register name according to GCC.
Defines the clang::TargetInfo interface.
unsigned[(unsigned) LangAS::FirstTargetAddressSpace] LangASMap
The type of a lookup table which maps from language-specific address spaces to target-specific ones.
OpenCLTypeKind
OpenCL type kinds.
LLVM_READONLY bool isDigit(unsigned char c)
Return true if this character is an ASCII digit: [0-9].
LangAS
Defines the address space values used by the address space qualifier of QualType.
Contains information gathered from parsing the contents of TargetAttr.
const std::string & getConstraintStr() const
std::string ConstraintStr
unsigned getTiedOperand() const
bool allowsMemory() const
void setTiedOperand(unsigned N, ConstraintInfo &Output)
Indicate that this is an input operand that is tied to the specified output operand.
bool hasTiedOperand() const
Return true if this input operand is a matching constraint that ties it to an output operand.
bool allowsRegister() const
void setRequiresImmediate(int Min, int Max)
Fields controlling how types are laid out in memory; these may need to be copied for targets like AMD...
const llvm::fltSemantics * DoubleFormat
unsigned UseZeroLengthBitfieldAlignment
Whether zero length bitfields (e.g., int : 0;) force alignment of the next bitfield.
unsigned short SuitableAlign
unsigned char PointerWidth
unsigned UseExplicitBitFieldAlignment
Whether explicit bit field alignment attributes are honored.
IntType
===-— Target Data Type Query Methods ----------------------------—===//
const llvm::fltSemantics * LongDoubleFormat
unsigned char LargeArrayAlign
unsigned char ShortAccumWidth
unsigned ZeroLengthBitfieldBoundary
If non-zero, specifies a fixed alignment value for bitfields that follow zero length bitfield,...
const llvm::fltSemantics * Float128Format
unsigned char DoubleWidth
unsigned UseLeadingZeroLengthBitfield
Whether zero length bitfield alignment is respected if they are the leading members.
unsigned char LongLongAlign
unsigned char LongAccumAlign
unsigned UseBitFieldTypeAlignment
Control whether the alignment of bit-field types is respected when laying out structures.
unsigned char LargeArrayMinWidth
unsigned char PointerAlign
unsigned char LongDoubleAlign
unsigned char LongDoubleWidth
unsigned char Int128Align
unsigned char ShortAccumScale
unsigned MaxAlignedAttribute
If non-zero, specifies a maximum alignment to truncate alignment specified in the aligned attribute o...
unsigned char DoubleAlign
bool PaddingOnUnsignedFixedPoint
const llvm::fltSemantics * Ibm128Format
unsigned char LongFractWidth
unsigned char Ibm128Align
unsigned char ShortFractAlign
unsigned char ShortAccumAlign
unsigned char LongFractAlign
const llvm::fltSemantics * FloatFormat
const llvm::fltSemantics * HalfFormat
unsigned char LongLongWidth
unsigned char LongAccumScale
unsigned char MinGlobalAlign
unsigned UseSignedCharForObjCBool
Whether Objective-C's built-in boolean type should be signed char.
unsigned char Float128Align
unsigned char LongAccumWidth
unsigned char DefaultAlignForAttributeAligned
unsigned char ShortFractWidth