18 #include "llvm/ADT/APFloat.h" 19 #include "llvm/ADT/STLExtras.h" 20 #include "llvm/IR/DataLayout.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;
146 Diags.
Report(diag::err_opt_not_valid_on_target) <<
"cf-protection=branch";
152 Diags.
Report(diag::err_opt_not_valid_on_target) <<
"cf-protection=return";
160 default: llvm_unreachable(
"not an integer!");
178 default: llvm_unreachable(
"not an integer!");
203 default: llvm_unreachable(
"not an integer!");
221 default: llvm_unreachable(
"not an integer!");
236 unsigned BitWidth,
bool IsSigned)
const {
251 bool IsSigned)
const {
292 default: llvm_unreachable(
"not an integer!");
310 default: llvm_unreachable(
"not an integer!");
331 if (Opts.NoBitFieldTypeAlign)
334 switch (Opts.WCharSize) {
335 default: llvm_unreachable(
"invalid wchar_t width");
342 if (Opts.AlignDouble) {
368 assert(MaxPointerWidth == 32 || MaxPointerWidth == 64);
369 bool Is32BitArch = MaxPointerWidth == 32;
382 if (Opts.LongDoubleSize) {
387 }
else if (Opts.LongDoubleSize == 128) {
393 if (Opts.NewAlignOverride)
399 CheckFixedPointBits();
404 const std::vector<std::string> &FeatureVec)
const {
405 for (
const auto &F : FeatureVec) {
408 bool Enabled = Name[0] ==
'+';
417 (ClangABICompat4 ||
getTriple().getOS() == llvm::Triple::PS4))
440 if (Name[0] ==
'%' || Name[0] ==
'#')
441 Name = Name.substr(1);
451 Name ==
"memory" || Name ==
"cc");
471 if (!Name.getAsInteger(0, n))
472 return n < Names.size();
476 if (llvm::is_contained(Names, Name))
481 for (
const char *AN : ARN.Names) {
486 if (AN == Name && ARN.RegNum < Names.size())
492 for (
const char *A : GRA.Aliases) {
503 bool ReturnCanonical)
const {
514 if (!Name.getAsInteger(0, n)) {
515 assert(n < Names.size() &&
"Out of bounds register number!");
522 for (
const char *AN : ARN.Names) {
527 if (AN == Name && ARN.RegNum < Names.size())
528 return ReturnCanonical ? Names[ARN.RegNum] : Name;
533 for (
const char *A : RA.Aliases) {
546 if (*Name !=
'=' && *Name !=
'+')
586 if (Name[1] ==
'=' || Name[1] ==
'+')
590 while (Name[1] && Name[1] !=
',')
619 unsigned &Index)
const {
620 assert(*Name ==
'[' &&
"Symbolic name did not start with '['");
622 const char *Start = Name;
623 while (*Name && *Name !=
']')
631 std::string SymbolicName(Start, Name - Start);
633 for (Index = 0; Index != OutputConstraints.size(); ++Index)
634 if (SymbolicName == OutputConstraints[Index].
getName())
652 if (*Name >=
'0' && *Name <=
'9') {
653 const char *DigitStart = Name;
654 while (Name[1] >=
'0' && Name[1] <=
'9')
656 const char *DigitEnd = Name;
658 if (StringRef(DigitStart, DigitEnd - DigitStart + 1)
659 .getAsInteger(10, i))
663 if (i >= OutputConstraints.size())
return false;
666 if (OutputConstraints[i].isReadWrite())
695 if (OutputConstraints[Index].isReadWrite())
742 while (Name[1] && Name[1] !=
',')
757 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.
unsigned HasAArch64SVETypes
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
std::unique_ptr< llvm::DataLayout > DataLayout
void resetDataLayout(StringRef DL)
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