15 #ifndef LLVM_CLANG_BASIC_TARGETINFO_H
16 #define LLVM_CLANG_BASIC_TARGETINFO_H
24 #include "llvm/ADT/APInt.h"
25 #include "llvm/ADT/IntrusiveRefCntPtr.h"
26 #include "llvm/ADT/SmallSet.h"
27 #include "llvm/ADT/StringMap.h"
28 #include "llvm/ADT/StringRef.h"
29 #include "llvm/ADT/StringSwitch.h"
30 #include "llvm/ADT/Triple.h"
31 #include "llvm/IR/DataLayout.h"
32 #include "llvm/Support/DataTypes.h"
42 class DiagnosticsEngine;
48 namespace Builtin {
struct Info; }
53 std::shared_ptr<TargetOptions> TargetOpts;
111 const std::shared_ptr<TargetOptions> &Opts);
117 assert(TargetOpts &&
"Missing target options");
259 llvm_unreachable(
"Unexpected signed integer type");
273 bool IsSigned)
const;
416 uint64_t AlignmentInBits)
const {
417 return AtomicSizeInBits <= AlignmentInBits &&
420 llvm::isPowerOf2_64(AtomicSizeInBits /
getCharWidth()));
640 ImmSet.count(Value.getZExtValue()) != 0;
655 for (
int Exact : Exacts)
688 bool &HasSizeMismatch)
const {
689 HasSizeMismatch =
false;
698 ConstraintInfo &info)
const;
713 std::string &)
const {
722 unsigned &Index)
const;
729 if (*Constraint ==
'p')
730 return std::string(
"r");
731 return std::string(1, *Constraint);
749 assert(
DataLayout &&
"Uninitialized DataLayout!");
802 const std::vector<std::string> &FeatureVec)
const;
805 virtual StringRef
getABI()
const {
return StringRef(); }
837 bool Enabled)
const {
838 Features[
Name] = Enabled;
868 assert(
RegParmMax < 7 &&
"RegParmMax value is larger than AST can handle");
888 (
getTriple().getArch() == llvm::Triple::x86 ||
889 getTriple().getArch() == llvm::Triple::x86_64);
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.
virtual bool hasFloat128Type() const
Determine whether the __float128 type is supported on this 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]]].
The basic abstraction for the target C++ ABI.
bool hasMatchingInput() const
Return true if this output operand has a matching (tied) input operand.
OpenCL supported extensions and optional core features.
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
const llvm::fltSemantics * DoubleFormat
unsigned short MaxVectorAlign
unsigned getChar16Width() const
getChar16Width/Align - Return the size of 'char16_t' for this target, in bits.
__builtin_va_list as defined by the PNaCl ABI: http://www.chromium.org/nativeclient/pnacl/bitcode-abi...
IntType getSizeType() const
unsigned char LongLongWidth
unsigned getChar16Align() const
unsigned getLargeArrayAlign() const
IntType getWIntType() const
bool validateOutputConstraint(ConstraintInfo &Info) const
virtual ArrayRef< AddlRegName > getGCCAddlRegNames() const
bool validateInputConstraint(MutableArrayRef< ConstraintInfo > OutputConstraints, ConstraintInfo &info) const
unsigned getRegParmMax() const
__builtin_va_list as defined by the x86-64 ABI: http://www.x86-64.org/documentation/abi.pdf
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 getFloat128Align() const
llvm::SmallSet< int, 4 > ImmSet
unsigned getChar32Width() const
getChar32Width/Align - Return the size of 'char32_t' for this target, in bits.
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.
__builtin_va_list as defind by the AArch64 ABI http://infocenter.arm.com/help/topic/com.arm.doc.ihi0055a/IHI0055A_aapcs64.pdf
unsigned getFloat128Width() const
getFloat128Width/Align/Format - Return the size/align/format of '__float128'.
unsigned getLongDoubleWidth() const
getLongDoubleWidth/Align/Format - Return the size/align/format of 'long double'.
unsigned char LongDoubleWidth
unsigned char LargeArrayMinWidth
virtual bool validateConstraintModifier(StringRef, char, unsigned, std::string &) const
unsigned ZeroLengthBitfieldBoundary
If non-zero, specifies a fixed alignment value for bitfields that follow zero length bitfield...
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
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
bool hasAlignMac68kSupport() const
Check whether this target support '#pragma options align=mac68k'.
const llvm::fltSemantics * Float128Format
void setRequiresImmediate()
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.
virtual bool validateOutputSize(StringRef, unsigned) const
OpenCLOptions SupportedOpenCLOptions
Supported OpenCL extensions and optional core features.
unsigned char LargeArrayAlign
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 ...
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.
bool resolveSymbolicName(const char *&Name, ArrayRef< ConstraintInfo > OutputConstraints, unsigned &Index) const
virtual unsigned getExnObjectAlignment() const
Return the alignment (in bits) of the thrown exception object.
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.
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...
unsigned getDoubleAlign() const
unsigned char DoubleWidth
VersionTuple PlatformMinVersion
unsigned ComplexLongDoubleUsesFP2Ret
virtual StringRef getABI() const
Get the ABI currently in use.
unsigned getWCharWidth() const
getWCharWidth/Align - Return the size of 'wchar_t' for this target, in bits.
unsigned getHalfAlign() const
virtual unsigned getUnwindWordWidth() 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.
bool hasNoAsmVariants() const
Return true if {|} are normal characters in the asm string.
virtual std::string convertConstraint(const char *&Constraint) 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;
unsigned HasBuiltinMSVaList
void setRequiresImmediate(int Exact)
Exposes information about the current target.
Defines the TargetCXXABI class, which abstracts details of the C++ ABI that we're targeting...
unsigned HasAlignMac68kSupport
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 getIntMaxTWidth() const
Return the size of intmax_t and uintmax_t for this target, in bits.
IntType getProcessIDType() const
struct clang::TargetInfo::ConstraintInfo::@148 ImmRange
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.
virtual bool validateTarget(DiagnosticsEngine &Diags) const
Check the target is valid after it is fully initialized.
unsigned getChar32Align() const
unsigned getTiedOperand() const
void resetDataLayout(StringRef DL)
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 UseExplicitBitFieldAlignment
Whether explicit bit field alignment attributes are honored.
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
getMinGlobalAlign - Return the minimum alignment of a global variable, unless its alignment is explic...
virtual bool validateGlobalRegisterVariable(StringRef RegName, unsigned RegSize, bool &HasSizeMismatch) const
Validate register name used for global register variables.
IntType getSigAtomicType() const
bool isSEHTrySupported() const
Whether the target supports SEH __try.
const LangAS::Map * AddrSpaceMap
bool allowsMemory() const
unsigned char DoubleAlign
virtual unsigned getRegisterWidth() const
Return the "preferred" register width on this target.
Defines the clang::TargetOptions class.
virtual bool allowsLargerPreferedTypeAlignment() const
Whether target allows to overalign ABI-specified prefered alignment.
virtual bool hasSjLjLowering() const
Controls if __builtin_longjmp / __builtin_setjmp can be lowered to llvm.eh.sjlj.longjmp / llvm...
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.
virtual BuiltinVaListKind getBuiltinVaListKind() const =0
Returns the kind of __builtin_va_list type that should be used with this target.
IntType getUIntMaxType() const
bool hasBuiltinMSVaList() const
Returns whether or not type __builtin_ms_va_list type is available on this target.
__builtin_va_list as defined by the Power ABI: https://www.power.org /resources/downloads/Power-Arch-...
virtual ArrayRef< GCCRegAlias > getGCCRegAliases() const =0
virtual 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.
virtual ArrayRef< Builtin::Info > getTargetBuiltins() const =0
Return information about target-specific builtins for the current primary target, and info about whic...
unsigned char PointerAlign
virtual bool isCLZForZeroUndef() const
The __builtin_clz* and __builtin_ctz* built-in functions are specified to have undefined results for ...
__builtin_va_list as defined by ARM AAPCS ABI http://infocenter.arm.com
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.
virtual 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.
bool useExplicitBitFieldAlignment() const
Check whether explicit bitfield alignment attributes should be.
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.
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()
unsigned Map[Count]
The type of a lookup table which maps from language-specific address spaces to target-specific ones...
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 isValidAsmImmediate(const llvm::APInt &Value) const
bool allowsRegister() const
void setRequiresImmediate(llvm::ArrayRef< int > Exacts)
unsigned getIntWidth() const
getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for this target, in bits.
unsigned getLongLongWidth() const
getLongLongWidth/Align - Return the size of 'signed long long' and 'unsigned long long' for this targ...
const llvm::fltSemantics & getFloat128Format() 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)
const OpenCLOptions & getSupportedOpenCLOpts() const
Get const supported OpenCL extensions and optional core features.
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.
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...
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
getLongWidth/Align - Return the size of 'signed long' and 'unsigned long' for this target...
Defines the clang::VersionTuple class, which represents a version in the form major[.minor[.subminor]].
const llvm::fltSemantics * LongDoubleFormat
virtual void setSupportedOpenCLOpts()
Set supported OpenCL extensions and optional core features.
unsigned char Float128Align
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
Control whether the alignment of bit-field types is respected when laying out structures.
const llvm::DataLayout & getDataLayout() const
IntType getPtrDiffType(unsigned AddrSpace) const
unsigned getShortAlign() const
Return the alignment of 'signed short' and 'unsigned short' for this target.
std::unique_ptr< llvm::DataLayout > DataLayout
StringRef getPlatformName() const
Retrieve the name of the platform as it is used in the availability attribute.
OpenCLOptions & getSupportedOpenCLOpts()
Get supported OpenCL extensions and optional core features.
void noSignedCharForObjCBool()
bool requiresImmediateConstant() const
virtual ArrayRef< const char * > getGCCRegNames() const =0
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.