15 #ifndef LLVM_CLANG_BASIC_TARGETINFO_H
16 #define LLVM_CLANG_BASIC_TARGETINFO_H
24 #include "llvm/ADT/IntrusiveRefCntPtr.h"
25 #include "llvm/ADT/StringMap.h"
26 #include "llvm/ADT/StringRef.h"
27 #include "llvm/ADT/StringSwitch.h"
28 #include "llvm/ADT/Triple.h"
29 #include "llvm/Support/DataTypes.h"
39 class DiagnosticsEngine;
45 namespace Builtin {
struct Info; }
50 std::shared_ptr<TargetOptions> TargetOpts;
102 const std::shared_ptr<TargetOptions> &Opts);
108 assert(TargetOpts &&
"Missing target options");
246 llvm_unreachable(
"Unexpected signed integer type");
389 uint64_t AlignmentInBits)
const {
390 return AtomicSizeInBits <= AlignmentInBits &&
393 llvm::isPowerOf2_64(AtomicSizeInBits /
getCharWidth()));
513 unsigned &NumRecords)
const = 0;
629 ConstraintInfo &info)
const;
644 std::string &)
const {
648 ConstraintInfo *OutputConstraints,
649 unsigned NumOutputs,
unsigned &Index)
const;
656 if (*Constraint ==
'p')
657 return std::string(
"r");
658 return std::string(1, *Constraint);
730 virtual StringRef
getABI()
const {
return StringRef(); }
740 virtual bool setCPU(
const std::string &Name) {
747 virtual bool setABI(
const std::string &Name) {
763 if (!ABI.
tryParse(name))
return false;
779 bool Enabled)
const {
780 Features[Name] = Enabled;
804 assert(
RegParmMax < 7 &&
"RegParmMax value is larger than AST can handle");
824 (
getTriple().getArch() == llvm::Triple::x86 ||
825 getTriple().getArch() == llvm::Triple::x86_64);
914 unsigned &NumNames)
const = 0;
916 unsigned &NumAliases)
const = 0;
918 unsigned &NumAddl)
const {
bool useObjCFP2RetForComplexLongDouble() const
Check whether _Complex long double should use the "fp2ret" flavor of Objective-C message passing on t...
RealType getRealTypeByWidth(unsigned BitWidth) const
Return floating point type with specified width.
unsigned getSimdDefaultAlign() const
Return default simd alignment for the given target. Generally, this value is type-specific, but this alignment can be used for most of the types for the given target.
unsigned getZeroLengthBitfieldBoundary() const
Get the fixed alignment value in bits for a member that follows a zero length bitfield.
bool useObjCFPRetForRealType(RealType T) const
Check whether the given real type should use the "fpret" flavor of Objective-C message passing on thi...
Represents a version number in the form major[.minor[.subminor[.build]]].
bool resolveSymbolicName(const char *&Name, ConstraintInfo *OutputConstraints, unsigned NumOutputs, unsigned &Index) const
The basic abstraction for the target C++ ABI.
bool hasMatchingInput() const
Return true if this output operand has a matching (tied) input operand.
unsigned getDefaultAlignForAttributeAligned() const
Return the default alignment for attribute((aligned)) on this target, to be used if no alignment valu...
virtual bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &info) const =0
unsigned getRegisterWidth() const
Return the "preferred" register width on this target.
const llvm::fltSemantics * DoubleFormat
unsigned short MaxVectorAlign
unsigned getChar16Width() const
virtual void getTargetBuiltins(const Builtin::Info *&Records, unsigned &NumRecords) const =0
IntType getSizeType() const
unsigned char LongLongWidth
unsigned getChar16Align() const
unsigned getLargeArrayAlign() const
IntType getWIntType() const
bool validateOutputConstraint(ConstraintInfo &Info) const
unsigned getRegParmMax() const
virtual bool setCXXABI(TargetCXXABI ABI)
Set the C++ ABI to be used by this implementation.
TargetInfo(const llvm::Triple &T)
unsigned getBoolAlign() const
Return the alignment of '_Bool' and C++ 'bool' for this target.
unsigned char LongDoubleAlign
unsigned short SimdDefaultAlign
unsigned getChar32Width() const
void setRequiresImmediate(int Min, int Max)
virtual enum IntType getPtrDiffTypeV(unsigned AddrSpace) const
VersionTuple getPlatformMinVersion() const
Retrieve the minimum desired version of the platform, to which the program should be compiled...
const char *const Register
Options for controlling the target.
unsigned getLongDoubleWidth() const
unsigned char LongDoubleWidth
unsigned char LargeArrayMinWidth
virtual bool validateConstraintModifier(StringRef, char, unsigned, std::string &) const
unsigned ZeroLengthBitfieldBoundary
unsigned getFloatAlign() const
const std::string & getConstraintStr() const
virtual void adjust(const LangOptions &Opts)
Set forced language options.
unsigned getFloatWidth() const
getFloatWidth/Align/Format - Return the size/align/format of 'float'.
unsigned getLargeArrayMinWidth() const
unsigned char MinGlobalAlign
bool hasAlignMac68kSupport() const
Check whether this target support '#pragma options align=mac68k'.
virtual bool validateCpuSupports(StringRef Name) const
unsigned getDoubleWidth() const
getDoubleWidth/Align/Format - Return the size/align/format of 'double'.
const char *const Names[5]
const char * getTypeConstantSuffix(IntType T) const
Return the constant suffix for the specified integer type enum.
const char * DescriptionString
virtual bool validateOutputSize(StringRef, unsigned) const
unsigned char LargeArrayAlign
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
const char *const Aliases[5]
virtual int getEHDataRegisterNumber(unsigned RegNo) const
Return the register number that __builtin_eh_return_regno would return with the specified argument...
virtual bool validateInputSize(StringRef, unsigned) const
virtual CallingConv getDefaultCallingConv(CallingConvMethodType MT) const
Gets the default calling convention for the given target and declaration context. ...
static bool isTypeSigned(IntType T)
Returns true if the type is signed; false otherwise.
unsigned char MaxAtomicPromoteWidth
virtual unsigned getFloatEvalMethod() const
Return the value for the C99 FLT_EVAL_METHOD macro.
unsigned char DefaultAlignForAttributeAligned
const char * getMCountName() const
Returns the name of the mcount instrumentation function.
unsigned char PointerWidth
virtual bool isNan2008() const
Returns true if NaN encoding is IEEE 754-2008. Only MIPS allows a different encoding.
unsigned char SSERegParmMax
const llvm::fltSemantics & getDoubleFormat() const
bool isValidGCCRegisterName(StringRef Name) const
Returns whether the passed in string is a valid register name according to GCC.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
unsigned getLongDoubleAlign() const
IntType getIntMaxType() const
Concrete class used by the front-end to report problems and issues.
virtual const char * getStaticInitSectionSpecifier() const
Return the section to use for C++ static initialization functions.
virtual bool hasBuiltinAtomic(uint64_t AtomicSizeInBits, uint64_t AlignmentInBits) const
Returns true if the given target supports lock-free atomic operations at the specified width and alig...
virtual void getDefaultFeatures(llvm::StringMap< bool > &Features) const
Get the default set of target features for the CPU; this should include all legal feature strings on ...
unsigned getDoubleAlign() const
unsigned char DoubleWidth
VersionTuple PlatformMinVersion
unsigned ComplexLongDoubleUsesFP2Ret
virtual StringRef getABI() const
Get the ABI currently in use.
unsigned getWCharWidth() const
unsigned getHalfAlign() const
unsigned getHalfWidth() const
getHalfWidth/Align/Format - Return the size/align/format of 'half'.
unsigned RealTypeUsesObjCFPRet
Provides definitions for the various language-specific address spaces.
int getImmConstantMax() const
bool hasNoAsmVariants() const
Return true if {|} are normal characters in the asm string.
virtual std::string convertConstraint(const char *&Constraint) const
int getImmConstantMin() const
unsigned getCharAlign() const
unsigned getTypeWidth(IntType T) const
Return the width (in bits) of the specified integer type enum.
typedef void* __builtin_va_list;
Exposes information about the current target.
Defines the TargetCXXABI class, which abstracts details of the C++ ABI that we're targeting...
unsigned HasAlignMac68kSupport
const char * getUserLabelPrefix() const
Returns the default value of the USER_LABEL_PREFIX macro, which is the prefix given to user symbols b...
const char * UserLabelPrefix
IntType getIntPtrType() const
const llvm::fltSemantics & getFloatFormat() const
virtual std::string isValidSectionSpecifier(StringRef SR) const
An optional hook that targets can implement to perform semantic checking on attribute((section("foo")...
bool isValidClobber(StringRef Name) const
Returns whether the passed in string is a valid clobber in an inline asm statement.
std::string ConstraintStr
IntType getUInt64Type() const
bool useZeroLengthBitfieldAlignment() const
Check whether zero length bitfields should force alignment of the next member.
unsigned getUnwindWordWidth() const
unsigned getIntMaxTWidth() const
Return the size of intmax_t and uintmax_t for this target, in bits.
IntType getProcessIDType() const
bool setCXXABI(llvm::StringRef name)
Use this specified C++ ABI.
virtual bool handleTargetFeatures(std::vector< std::string > &Features, DiagnosticsEngine &Diags)
Perform initialization based on the user configured set of features (e.g., +sse4).
virtual bool hasProtectedVisibility() const
Does this target support "protected" visibility?
static TargetInfo * CreateTargetInfo(DiagnosticsEngine &Diags, const std::shared_ptr< TargetOptions > &Opts)
Construct a target for the given options.
bool useBitFieldTypeAlignment() const
Check whether the alignment of bit-field types is respected when laying out structures.
unsigned getChar32Align() const
unsigned getTiedOperand() const
unsigned getWCharAlign() const
const LangAS::Map & getAddressSpaceMap() const
IntType getChar32Type() const
unsigned getIntAlign() const
CallingConv
CallingConv - Specifies the calling convention that a function uses.
static const char * getTypeName(IntType T)
Return the user string for the specified integer type enum.
unsigned getLongAlign() const
unsigned getTypeAlign(IntType T) const
Return the alignment (in bits) of the specified integer type enum.
IntType getUIntPtrType() const
unsigned getMaxVectorAlign() const
Return the maximum vector alignment supported for the given target.
virtual uint64_t getPointerAlignV(unsigned AddrSpace) const
virtual bool useFloat128ManglingForLongDouble() const
Return true if the 'long double' type should be mangled like __float128.
virtual bool setABI(const std::string &Name)
Use the specified ABI.
uint64_t getPointerAlign(unsigned AddrSpace) const
unsigned getMinGlobalAlign() const
IntType getSigAtomicType() const
bool isSEHTrySupported() const
Whether the target supports SEH __try.
const LangAS::Map * AddrSpaceMap
bool allowsMemory() const
unsigned char DoubleAlign
const char * getTargetDescription() const
Defines the clang::TargetOptions class.
virtual bool hasSjLjLowering() const
struct clang::TargetInfo::ConstraintInfo::@150 ImmRange
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.
bool tryParse(llvm::StringRef name)
Try to parse an ABI name, returning false on error.
virtual BuiltinVaListKind getBuiltinVaListKind() const =0
Returns the kind of __builtin_va_list type that should be used with this target.
IntType getUIntMaxType() const
IntType getIntTypeByWidth(unsigned BitWidth, bool IsSigned) const
Return integer type with specified width.
unsigned UseZeroLengthBitfieldAlignment
Whether zero length bitfields (e.g., int : 0;) force alignment of the next bitfield.
unsigned char PointerAlign
virtual bool isCLZForZeroUndef() const
unsigned char SuitableAlign
IntType getWCharType() const
Defines various enumerations that describe declaration and type specifiers.
IntType
===-— Target Data Type Query Methods ----------------------------—===//
const llvm::fltSemantics & getLongDoubleFormat() const
static const char * getTypeFormatModifier(IntType T)
Return the printf format modifier for the specified integer type enum.
typedef char* __builtin_va_list;
ConstraintInfo(StringRef ConstraintStr, StringRef Name)
unsigned getCharWidth() const
const std::string & getName() const
bool hasTiedOperand() const
Return true if this input operand is a matching constraint that ties it to an output operand...
unsigned getShortWidth() const
Return the size of 'signed short' and 'unsigned short' for this target, in bits.
IntType getLeastIntTypeByWidth(unsigned BitWidth, bool IsSigned) const
Return the smallest integer type with at least the specified width.
unsigned short getMaxTLSAlign() const
Return the maximum alignment (in bits) of a TLS variable.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
unsigned UseSignedCharForObjCBool
Whether Objective-C's built-in boolean type should be signed char.
virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, unsigned &NumAliases) const =0
const llvm::fltSemantics & getHalfFormat() const
virtual bool hasInt128Type() const
Determine whether the __int128 type is supported on this target.
unsigned getMaxAtomicInlineWidth() const
Return the maximum width lock-free atomic operation which can be inlined given the supported features...
void setHasMatchingInput()
const llvm::fltSemantics * FloatFormat
TargetOptions & getTargetOpts() const
Retrieve the target options.
unsigned char LongLongAlign
const llvm::fltSemantics * HalfFormat
virtual void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const =0
===-— Other target property query methods --------------------——===//
bool allowsRegister() const
unsigned getIntWidth() const
unsigned getLongLongWidth() const
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
bool isTLSSupported() const
Whether the target supports thread-local storage.
uint64_t getPointerWidth(unsigned AddrSpace) const
Return the width of pointers on this target, for the specified address space.
bool useSignedCharForObjCBool() const
Check if the Objective-C built-in boolean type should be signed char.
static IntType getCorrespondingUnsignedType(IntType T)
virtual void getGCCAddlRegNames(const AddlRegName *&Addl, unsigned &NumAddl) const
virtual bool setCPU(const std::string &Name)
Target the specified CPU.
virtual CallingConvCheckResult checkCallingConvention(CallingConv CC) const
Determines whether a given calling convention is valid for the target. A calling convention can eithe...
BoundNodesTreeBuilder *const Builder
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
bool useAddressSpaceMapMangling() const
Specify if mangling based on address space map should be used or not for language specific address sp...
virtual void getGCCRegNames(const char *const *&Names, unsigned &NumNames) const =0
unsigned getBoolWidth() const
Return the size of '_Bool' and C++ 'bool' for this target, in bits.
unsigned getMaxAtomicPromoteWidth() const
Return the maximum width lock-free atomic operation which will ever be supported for the given target...
IntType getInt64Type() const
IntType getChar16Type() const
StringRef getNormalizedGCCRegisterName(StringRef Name) const
Returns the "normalized" GCC register name.
unsigned getLongWidth() const
Defines the clang::VersionTuple class, which represents a version in the form major[.minor[.subminor]].
const llvm::fltSemantics * LongDoubleFormat
bool validateInputConstraint(ConstraintInfo *OutputConstraints, unsigned NumOutputs, ConstraintInfo &info) const
unsigned char MaxAtomicInlineWidth
virtual bool hasFeature(StringRef Feature) const
Determine whether the given target has the given feature.
unsigned getSuitableAlign() const
Return the alignment that is suitable for storing any object with a fundamental alignment requirement...
void setTiedOperand(unsigned N, ConstraintInfo &Output)
Indicate that this is an input operand that is tied to the specified output operand.
unsigned short MaxTLSAlign
virtual bool setFPMath(StringRef Name)
Use the specified unit for FP math.
unsigned UseBitFieldTypeAlignment
IntType getPtrDiffType(unsigned AddrSpace) const
unsigned getShortAlign() const
Return the alignment of 'signed short' and 'unsigned short' for this target.
StringRef getPlatformName() const
Retrieve the name of the platform as it is used in the availability attribute.
void noSignedCharForObjCBool()
bool requiresImmediateConstant() const
unsigned getLongLongAlign() const
bool UseAddrSpaceMapMangling
Specify if mangling based on address space map should be used or not for language specific address sp...
virtual uint64_t getPointerWidthV(unsigned AddrSpace) const
virtual const char * getClobbers() const =0
Returns a string of target-specific clobbers, in LLVM format.