19 #include "llvm/ADT/APFloat.h" 20 #include "llvm/ADT/STLExtras.h" 21 #include "llvm/Support/ErrorHandling.h" 22 #include "llvm/Support/TargetParser.h" 24 using namespace clang;
69 if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment() || T.isAndroid())
70 NewAlign = Triple.isArch64Bit() ? 128 : Triple.isArch32Bit() ? 64 : 0;
141 Diags.
Report(diag::err_opt_not_valid_on_target) <<
"cf-protection=branch";
147 Diags.
Report(diag::err_opt_not_valid_on_target) <<
"cf-protection=return";
155 default: llvm_unreachable(
"not an integer!");
173 default: llvm_unreachable(
"not an integer!");
198 default: llvm_unreachable(
"not an integer!");
216 default: llvm_unreachable(
"not an integer!");
231 unsigned BitWidth,
bool IsSigned)
const {
246 bool IsSigned)
const {
287 default: llvm_unreachable(
"not an integer!");
305 default: llvm_unreachable(
"not an integer!");
326 if (Opts.NoBitFieldTypeAlign)
329 switch (Opts.WCharSize) {
330 default: llvm_unreachable(
"invalid wchar_t width");
337 if (Opts.AlignDouble) {
363 assert(MaxPointerWidth == 32 || MaxPointerWidth == 64);
364 bool Is32BitArch = MaxPointerWidth == 32;
377 if (Opts.NewAlignOverride)
383 CheckFixedPointBits();
388 const std::vector<std::string> &FeatureVec)
const {
389 for (
const auto &F : FeatureVec) {
392 bool Enabled = Name[0] ==
'+';
401 (ClangABICompat4 ||
getTriple().getOS() == llvm::Triple::PS4))
424 if (Name[0] ==
'%' || Name[0] ==
'#')
425 Name = Name.substr(1);
435 Name ==
"memory" || Name ==
"cc");
455 if (!Name.getAsInteger(0, n))
456 return n < Names.size();
460 if (std::find(Names.begin(), Names.end(), Name) != Names.end())
465 for (
const char *AN : ARN.Names) {
470 if (AN == Name && ARN.RegNum < Names.size())
476 for (
const char *A : GRA.Aliases) {
487 bool ReturnCanonical)
const {
498 if (!Name.getAsInteger(0, n)) {
499 assert(n < Names.size() &&
"Out of bounds register number!");
506 for (
const char *AN : ARN.Names) {
511 if (AN == Name && ARN.RegNum < Names.size())
512 return ReturnCanonical ? Names[ARN.RegNum] : Name;
517 for (
const char *A : RA.Aliases) {
530 if (*Name !=
'=' && *Name !=
'+')
570 if (Name[1] ==
'=' || Name[1] ==
'+')
574 while (Name[1] && Name[1] !=
',')
603 unsigned &Index)
const {
604 assert(*Name ==
'[' &&
"Symbolic name did not start with '['");
606 const char *Start = Name;
607 while (*Name && *Name !=
']')
615 std::string SymbolicName(Start, Name - Start);
617 for (Index = 0; Index != OutputConstraints.size(); ++Index)
618 if (SymbolicName == OutputConstraints[Index].
getName())
636 if (*Name >=
'0' && *Name <=
'9') {
637 const char *DigitStart = Name;
638 while (Name[1] >=
'0' && Name[1] <=
'9')
640 const char *DigitEnd = Name;
642 if (StringRef(DigitStart, DigitEnd - DigitStart + 1)
643 .getAsInteger(10, i))
647 if (i >= OutputConstraints.size())
return false;
650 if (OutputConstraints[i].isReadWrite())
679 if (OutputConstraints[Index].isReadWrite())
726 while (Name[1] && Name[1] !=
',')
741 void TargetInfo::CheckFixedPointBits()
const {
virtual bool checkCFProtectionReturnSupported(DiagnosticsEngine &Diags) const
Check if the target supports CFProtection branch.
unsigned getTypeWidth(IntType T) const
Return the width (in bits) of the specified integer type enum.
unsigned getFloatWidth() const
getFloatWidth/Align/Format - Return the size/align/format of 'float'.
unsigned getLongAccumIBits() const
virtual void adjust(LangOptions &Opts)
Set forced language options.
unsigned getLongWidth() const
getLongWidth/Align - Return the size of 'signed long' and 'unsigned long' for this target...
virtual bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &info) const =0
const llvm::fltSemantics * DoubleFormat
unsigned short MaxVectorAlign
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
unsigned getLongAlign() const
virtual IntType getLeastIntTypeByWidth(unsigned BitWidth, bool IsSigned) const
Return the smallest integer type with at least the specified width.
unsigned char LongLongWidth
virtual LangAS getOpenCLTypeAddrSpace(OpenCLTypeKind TK) const
Get address space for OpenCL type.
bool validateInputConstraint(MutableArrayRef< ConstraintInfo > OutputConstraints, ConstraintInfo &info) const
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
unsigned getAccumIBits() const
TargetInfo(const llvm::Triple &T)
unsigned getCharWidth() const
unsigned char ShortFractWidth
unsigned char LongDoubleAlign
unsigned short SimdDefaultAlign
unsigned getShortAccumIBits() const
void setRequiresImmediate(int Min, int Max)
static const LangASMap DefaultAddrSpaceMap
unsigned getCharAlign() const
LangAS
Defines the address space values used by the address space qualifier of QualType. ...
unsigned char LongDoubleWidth
unsigned char LargeArrayMinWidth
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 ZeroLengthBitfieldBoundary
If non-zero, specifies a fixed alignment value for bitfields that follow zero length bitfield...
std::string getName(ArrayRef< StringRef > Parts) const
Get the platform-specific name separator.
unsigned char MinGlobalAlign
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
unsigned getIntAlign() const
const char * getTypeConstantSuffix(IntType T) const
Return the constant suffix for the specified integer type enum.
StringRef getNormalizedGCCRegisterName(StringRef Name, bool ReturnCanonical=false) const
Returns the "normalized" GCC register name.
const llvm::fltSemantics * Float128Format
unsigned char LongAccumAlign
unsigned getUnsignedLongAccumIBits() const
unsigned char LargeArrayAlign
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
static bool isTypeSigned(IntType T)
Returns true if the type is signed; false otherwise.
unsigned char MaxAtomicPromoteWidth
unsigned char DefaultAlignForAttributeAligned
unsigned char PointerWidth
unsigned char SSERegParmMax
The Microsoft ABI is the ABI used by Microsoft Visual Studio (and compatible compilers).
Concrete class used by the front-end to report problems and issues.
unsigned getShortWidth() const
Return the size of 'signed short' and 'unsigned short' for this target, in bits.
Defines the Diagnostic-related interfaces.
unsigned char DoubleWidth
unsigned char LongFractAlign
VersionTuple PlatformMinVersion
unsigned char ShortAccumScale
unsigned ComplexLongDoubleUsesFP2Ret
unsigned getLongLongAlign() const
virtual bool isValidGCCRegisterName(StringRef Name) const
Returns whether the passed in string is a valid register name according to GCC.
unsigned char ShortAccumAlign
unsigned RealTypeUsesObjCFPRet
Provides definitions for the various language-specific address spaces.
virtual bool checkCFProtectionBranchSupported(DiagnosticsEngine &Diags) const
Check if the target supports CFProtection branch.
unsigned char LongAccumWidth
virtual CallingConvKind getCallingConvKind(bool ClangABICompat4) const
bool isValidClobber(StringRef Name) const
Returns whether the passed in string is a valid clobber in an inline asm statement.
const llvm::fltSemantics & getLongDoubleFormat() const
unsigned HasBuiltinMSVaList
unsigned HasAlignMac68kSupport
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 ...
Defines the clang::LangOptions interface.
unsigned getIntWidth() const
getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for this target, in bits.
unsigned char LongFractWidth
std::string ConstraintStr
static StringRef removeGCCRegisterPrefix(StringRef Name)
unsigned getShortAlign() const
Return the alignment of 'signed short' and 'unsigned short' for this target.
unsigned getDoubleWidth() const
getDoubleWidth/Align/Format - Return the size/align/format of 'double'.
unsigned getTypeAlign(IntType T) const
Return the alignment (in bits) of the specified integer type enum.
static const char * getTypeName(IntType T)
Return the user string for the specified integer type enum.
unsigned UseExplicitBitFieldAlignment
Whether explicit bit field alignment attributes are honored.
const LangASMap * AddrSpaceMap
unsigned IsRenderScriptTarget
unsigned char ShortFractAlign
unsigned getLongLongWidth() const
getLongLongWidth/Align - Return the size of 'signed long long' and 'unsigned long long' for this targ...
unsigned getUnsignedAccumScale() const
getUnsignedAccumScale/IBits - Return the number of fractional/integral bits in a 'unsigned _Accum' ty...
unsigned char DoubleAlign
bool validateOutputConstraint(ConstraintInfo &Info) const
bool PaddingOnUnsignedFixedPoint
virtual ArrayRef< AddlRegName > getGCCAddlRegNames() const
The generic Itanium ABI is the standard ABI of most open-source and Unix-like platforms.
virtual ArrayRef< GCCRegAlias > getGCCRegAliases() const =0
unsigned UseZeroLengthBitfieldAlignment
Whether zero length bitfields (e.g., int : 0;) force alignment of the next bitfield.
unsigned char PointerAlign
unsigned getUnsignedAccumIBits() const
unsigned char SuitableAlign
unsigned getUnsignedLongAccumScale() const
getUnsignedLongAccumScale/IBits - Return the number of fractional/integral bits in a 'unsigned long _...
IntType
===-— Target Data Type Query Methods ----------------------------—===//
RealType getRealTypeByWidth(unsigned BitWidth) const
Return floating point type with specified width.
unsigned getUnsignedShortAccumIBits() const
Dataflow Directional Tag Classes.
static const char * getTypeFormatModifier(IntType T)
Return the printf format modifier for the specified integer type enum.
bool allowsMemory() const
unsigned[(unsigned) LangAS::FirstTargetAddressSpace] LangASMap
The type of a lookup table which maps from language-specific address spaces to target-specific ones...
unsigned getLongFractScale() const
getLongFractScale - Return the number of fractional bits in a 'signed long _Fract' type...
unsigned char LongAccumScale
unsigned getUnsignedFractScale() const
getUnsignedFractScale - Return the number of fractional bits in a 'unsigned _Fract' type...
unsigned UseSignedCharForObjCBool
Whether Objective-C's built-in boolean type should be signed char.
bool hasTiedOperand() const
Return true if this input operand is a matching constraint that ties it to an output operand...
bool allowsRegister() const
const std::string & getConstraintStr() const
unsigned getUnsignedShortAccumScale() const
getUnsignedShortAccumScale/IBits - Return the number of fractional/integral bits in a 'unsigned short...
virtual IntType getIntTypeByWidth(unsigned BitWidth, bool IsSigned) const
Return integer type with specified width.
LLVM_READONLY bool isDigit(unsigned char c)
Return true if this character is an ASCII digit: [0-9].
bool resolveSymbolicName(const char *&Name, ArrayRef< ConstraintInfo > OutputConstraints, unsigned &Index) const
const llvm::fltSemantics * FloatFormat
unsigned char ShortAccumWidth
unsigned char LongLongAlign
const llvm::fltSemantics * HalfFormat
unsigned getTiedOperand() const
virtual uint64_t getMaxPointerWidth() const
Return the maximum width of pointers on this target.
unsigned getShortFractScale() const
getShortFractScale - Return the number of fractional bits in a 'signed short _Fract' type...
virtual bool hasFloat128Type() const
Determine whether the __float128 type is supported on this target.
unsigned getUnsignedLongFractScale() const
getUnsignedLongFractScale - Return the number of fractional bits in a 'unsigned long _Fract' type...
unsigned getFractScale() const
getFractScale - Return the number of fractional bits in a 'signed _Fract' type.
unsigned getUnsignedShortFractScale() const
getUnsignedShortFractScale - Return the number of fractional bits in a 'unsigned short _Fract' type...
Defines the clang::TargetInfo interface.
const llvm::fltSemantics * LongDoubleFormat
unsigned char Float128Align
unsigned char MaxAtomicInlineWidth
void setTiedOperand(unsigned N, ConstraintInfo &Output)
Indicate that this is an input operand that is tied to the specified output operand.
unsigned short MaxTLSAlign
unsigned UseBitFieldTypeAlignment
Control whether the alignment of bit-field types is respected when laying out structures.
virtual ArrayRef< const char * > getGCCRegNames() const =0
bool UseAddrSpaceMapMangling
Specify if mangling based on address space map should be used or not for language specific address sp...