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;
47 if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment())
48 NewAlign = Triple.isArch64Bit() ? 128 : Triple.isArch32Bit() ? 64 : 0;
121 default: llvm_unreachable(
"not an integer!");
139 default: llvm_unreachable(
"not an integer!");
164 default: llvm_unreachable(
"not an integer!");
182 default: llvm_unreachable(
"not an integer!");
197 unsigned BitWidth,
bool IsSigned)
const {
212 bool IsSigned)
const {
253 default: llvm_unreachable(
"not an integer!");
271 default: llvm_unreachable(
"not an integer!");
292 if (Opts.NoBitFieldTypeAlign)
295 switch (Opts.WCharSize) {
296 default: llvm_unreachable(
"invalid wchar_t width");
303 if (Opts.AlignDouble) {
329 assert(MaxPointerWidth == 32 || MaxPointerWidth == 64);
330 bool Is32BitArch = MaxPointerWidth == 32;
343 if (Opts.NewAlignOverride)
349 const std::vector<std::string> &FeatureVec)
const {
350 for (
const auto &F : FeatureVec) {
353 bool Enabled = Name[0] ==
'+';
377 if (Name[0] ==
'%' || Name[0] ==
'#')
378 Name = Name.substr(1);
388 Name ==
"memory" || Name ==
"cc");
408 if (!Name.getAsInteger(0, n))
409 return n < Names.size();
413 if (std::find(Names.begin(), Names.end(), Name) != Names.end())
418 for (
const char *AN : ARN.Names) {
423 if (AN == Name && ARN.RegNum < Names.size())
429 for (
const char *A : GRA.Aliases) {
440 bool ReturnCanonical)
const {
451 if (!Name.getAsInteger(0, n)) {
452 assert(n < Names.size() &&
"Out of bounds register number!");
459 for (
const char *AN : ARN.Names) {
464 if (AN == Name && ARN.RegNum < Names.size())
465 return ReturnCanonical ? Names[ARN.RegNum] : Name;
470 for (
const char *A : RA.Aliases) {
483 if (*Name !=
'=' && *Name !=
'+')
523 if (Name[1] ==
'=' || Name[1] ==
'+')
527 while (Name[1] && Name[1] !=
',')
556 unsigned &Index)
const {
557 assert(*Name ==
'[' &&
"Symbolic name did not start with '['");
559 const char *Start = Name;
560 while (*Name && *Name !=
']')
568 std::string SymbolicName(Start, Name - Start);
570 for (Index = 0; Index != OutputConstraints.size(); ++Index)
571 if (SymbolicName == OutputConstraints[Index].getName())
589 if (*Name >=
'0' && *Name <=
'9') {
590 const char *DigitStart = Name;
591 while (Name[1] >=
'0' && Name[1] <=
'9')
593 const char *DigitEnd = Name;
595 if (StringRef(DigitStart, DigitEnd - DigitStart + 1)
596 .getAsInteger(10, i))
600 if (i >= OutputConstraints.size())
return false;
603 if (OutputConstraints[i].isReadWrite())
632 if (OutputConstraints[Index].isReadWrite())
677 while (Name[1] && Name[1] !=
',')
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'.
Represents a version number in the form major[.minor[.subminor[.build]]].
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
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
TargetInfo(const llvm::Triple &T)
unsigned getCharWidth() const
unsigned char LongDoubleAlign
unsigned short SimdDefaultAlign
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...
unsigned char MinGlobalAlign
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 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.
unsigned LangASMap[(unsigned) LangAS::FirstTargetAddressSpace]
The type of a lookup table which maps from language-specific address spaces to target-specific ones...
unsigned char DoubleWidth
VersionTuple PlatformMinVersion
unsigned ComplexLongDoubleUsesFP2Ret
unsigned getLongLongAlign() const
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.
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.
const FunctionProtoType * T
unsigned getIntWidth() const
getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for this target, in bits.
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 getLongLongWidth() const
getLongLongWidth/Align - Return the size of 'signed long long' and 'unsigned long long' for this targ...
unsigned char DoubleAlign
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 UseZeroLengthBitfieldAlignment
Whether zero length bitfields (e.g., int : 0;) force alignment of the next bitfield.
unsigned char PointerAlign
unsigned char SuitableAlign
IntType
===-— Target Data Type Query Methods ----------------------------—===//
RealType getRealTypeByWidth(unsigned BitWidth) const
Return floating point type with specified width.
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 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
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 LongLongAlign
const llvm::fltSemantics * HalfFormat
unsigned getTiedOperand() const
virtual uint64_t getMaxPointerWidth() const
Return the maximum width of pointers on this target.
virtual bool hasFloat128Type() const
Determine whether the __float128 type is supported on this target.
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...