18 #include "llvm/ADT/APFloat.h" 19 #include "llvm/ADT/STLExtras.h" 20 #include "llvm/Support/ErrorHandling.h" 21 #include "llvm/Support/TargetParser.h" 23 using namespace clang;
68 if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment() || T.isAndroid())
69 NewAlign = Triple.isArch64Bit() ? 128 : Triple.isArch32Bit() ? 64 : 0;
140 Diags.
Report(diag::err_opt_not_valid_on_target) <<
"cf-protection=branch";
146 Diags.
Report(diag::err_opt_not_valid_on_target) <<
"cf-protection=return";
154 default: llvm_unreachable(
"not an integer!");
172 default: llvm_unreachable(
"not an integer!");
197 default: llvm_unreachable(
"not an integer!");
215 default: llvm_unreachable(
"not an integer!");
230 unsigned BitWidth,
bool IsSigned)
const {
245 bool IsSigned)
const {
286 default: llvm_unreachable(
"not an integer!");
304 default: llvm_unreachable(
"not an integer!");
325 if (Opts.NoBitFieldTypeAlign)
328 switch (Opts.WCharSize) {
329 default: llvm_unreachable(
"invalid wchar_t width");
336 if (Opts.AlignDouble) {
362 assert(MaxPointerWidth == 32 || MaxPointerWidth == 64);
363 bool Is32BitArch = MaxPointerWidth == 32;
376 if (Opts.LongDoubleSize) {
381 }
else if (Opts.LongDoubleSize == 128) {
387 if (Opts.NewAlignOverride)
393 CheckFixedPointBits();
398 const std::vector<std::string> &FeatureVec)
const {
399 for (
const auto &F : FeatureVec) {
402 bool Enabled = Name[0] ==
'+';
411 (ClangABICompat4 ||
getTriple().getOS() == llvm::Triple::PS4))
434 if (Name[0] ==
'%' || Name[0] ==
'#')
435 Name = Name.substr(1);
445 Name ==
"memory" || Name ==
"cc");
465 if (!Name.getAsInteger(0, n))
466 return n < Names.size();
470 if (llvm::is_contained(Names, Name))
475 for (
const char *AN : ARN.Names) {
480 if (AN == Name && ARN.RegNum < Names.size())
486 for (
const char *A : GRA.Aliases) {
497 bool ReturnCanonical)
const {
508 if (!Name.getAsInteger(0, n)) {
509 assert(n < Names.size() &&
"Out of bounds register number!");
516 for (
const char *AN : ARN.Names) {
521 if (AN == Name && ARN.RegNum < Names.size())
522 return ReturnCanonical ? Names[ARN.RegNum] : Name;
527 for (
const char *A : RA.Aliases) {
540 if (*Name !=
'=' && *Name !=
'+')
580 if (Name[1] ==
'=' || Name[1] ==
'+')
584 while (Name[1] && Name[1] !=
',')
613 unsigned &Index)
const {
614 assert(*Name ==
'[' &&
"Symbolic name did not start with '['");
616 const char *Start = Name;
617 while (*Name && *Name !=
']')
625 std::string SymbolicName(Start, Name - Start);
627 for (Index = 0; Index != OutputConstraints.size(); ++Index)
628 if (SymbolicName == OutputConstraints[Index].
getName())
646 if (*Name >=
'0' && *Name <=
'9') {
647 const char *DigitStart = Name;
648 while (Name[1] >=
'0' && Name[1] <=
'9')
650 const char *DigitEnd = Name;
652 if (StringRef(DigitStart, DigitEnd - DigitStart + 1)
653 .getAsInteger(10, i))
657 if (i >= OutputConstraints.size())
return false;
660 if (OutputConstraints[i].isReadWrite())
689 if (OutputConstraints[Index].isReadWrite())
736 while (Name[1] && Name[1] !=
',')
751 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 char LongLongAlign
unsigned getFloatWidth() const
getFloatWidth/Align/Format - Return the size/align/format of 'float'.
bool PaddingOnUnsignedFixedPoint
unsigned getLongAccumIBits() const
unsigned char LargeArrayMinWidth
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...
const llvm::fltSemantics * FloatFormat
unsigned char DoubleAlign
virtual bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &info) const =0
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.
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 char LongFractAlign
unsigned getAccumIBits() const
TargetInfo(const llvm::Triple &T)
unsigned getCharWidth() const
unsigned char ShortFractWidth
unsigned short SimdDefaultAlign
unsigned getShortAccumIBits() const
void setRequiresImmediate(int Min, int Max)
static const LangASMap DefaultAddrSpaceMap
unsigned getCharAlign() const
unsigned UseSignedCharForObjCBool
Whether Objective-C's built-in boolean type should be signed char.
LangAS
Defines the address space values used by the address space qualifier of QualType. ...
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 char LargeArrayAlign
unsigned char LongDoubleAlign
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.
unsigned getUnsignedLongAccumIBits() const
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
const llvm::fltSemantics * HalfFormat
unsigned char SSERegParmMax
const llvm::fltSemantics * Float128Format
The Microsoft ABI is the ABI used by Microsoft Visual Studio (and compatible compilers).
unsigned char SuitableAlign
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.
VersionTuple PlatformMinVersion
unsigned ComplexLongDoubleUsesFP2Ret
unsigned getLongLongAlign() const
unsigned UseZeroLengthBitfieldAlignment
Whether zero length bitfields (e.g., int : 0;) force alignment of the next bitfield.
virtual bool isValidGCCRegisterName(StringRef Name) const
Returns whether the passed in string is a valid register name according to GCC.
unsigned RealTypeUsesObjCFPRet
Provides definitions for the various language-specific address spaces.
virtual bool checkCFProtectionBranchSupported(DiagnosticsEngine &Diags) const
Check if the target supports CFProtection branch.
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.
unsigned char DefaultAlignForAttributeAligned
const llvm::fltSemantics & getLongDoubleFormat() const
unsigned HasBuiltinMSVaList
Exposes information about the current target.
unsigned char ShortFractAlign
unsigned char LongFractWidth
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 UseBitFieldTypeAlignment
Control whether the alignment of bit-field types is respected when laying out structures.
std::string ConstraintStr
unsigned char ShortAccumScale
unsigned char LongAccumAlign
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.
const llvm::fltSemantics * LongDoubleFormat
const LangASMap * AddrSpaceMap
unsigned IsRenderScriptTarget
unsigned char LongDoubleWidth
unsigned UseExplicitBitFieldAlignment
Whether explicit bit field alignment attributes are honored.
unsigned getLongLongWidth() const
getLongLongWidth/Align - Return the size of 'signed long long' and 'unsigned long long' for this targ...
unsigned short MaxTLSAlign
unsigned getUnsignedAccumScale() const
getUnsignedAccumScale/IBits - Return the number of fractional/integral bits in a 'unsigned _Accum' ty...
unsigned char LongAccumScale
bool validateOutputConstraint(ConstraintInfo &Info) const
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 getUnsignedAccumIBits() const
unsigned getUnsignedLongAccumScale() const
getUnsignedLongAccumScale/IBits - Return the number of fractional/integral bits in a 'unsigned long _...
unsigned char PointerWidth
IntType
===-— Target Data Type Query Methods ----------------------------—===//
unsigned char LongLongWidth
unsigned char ShortAccumAlign
RealType getRealTypeByWidth(unsigned BitWidth) const
Return floating point type with specified width.
unsigned getUnsignedShortAccumIBits() const
Dataflow Directional Tag Classes.
unsigned ZeroLengthBitfieldBoundary
If non-zero, specifies a fixed alignment value for bitfields that follow zero length bitfield...
static const char * getTypeFormatModifier(IntType T)
Return the printf format modifier for the specified integer type enum.
static std::string getName(const CallEvent &Call)
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 getUnsignedFractScale() const
getUnsignedFractScale - Return the number of fractional bits in a 'unsigned _Fract' type...
bool hasTiedOperand() const
Return true if this input operand is a matching constraint that ties it to an output operand...
unsigned char MinGlobalAlign
Fields controlling how types are laid out in memory; these may need to be copied for targets like AMD...
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
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.
void copyAuxTarget(const TargetInfo *Aux)
Copy type and layout related info.
unsigned getUnsignedLongFractScale() const
getUnsignedLongFractScale - Return the number of fractional bits in a 'unsigned long _Fract' type...
unsigned char LongAccumWidth
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...
unsigned char Float128Align
const llvm::fltSemantics * DoubleFormat
unsigned char ShortAccumWidth
unsigned char DoubleWidth
Defines the clang::TargetInfo interface.
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 char PointerAlign
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...
unsigned short MaxVectorAlign