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/Optional.h"
27 #include "llvm/ADT/SmallSet.h"
28 #include "llvm/ADT/StringMap.h"
29 #include "llvm/ADT/StringRef.h"
30 #include "llvm/ADT/Triple.h"
31 #include "llvm/IR/DataLayout.h"
32 #include "llvm/Support/DataTypes.h"
42 class DiagnosticsEngine;
50 namespace Builtin {
struct Info; }
55 std::shared_ptr<TargetOptions> TargetOpts;
116 const std::shared_ptr<TargetOptions> &Opts);
122 assert(TargetOpts &&
"Missing target options");
240 llvm_unreachable(
"Invalid SizeType");
278 llvm_unreachable(
"Unexpected signed integer type");
292 bool IsSigned)
const;
453 uint64_t AlignmentInBits)
const {
454 return AtomicSizeInBits <= AlignmentInBits &&
457 llvm::isPowerOf2_64(AtomicSizeInBits /
getCharWidth()));
627 bool ReturnCanonical =
false)
const;
630 const StringRef &Expression)
const {
688 ImmSet.count(Value.getZExtValue()) != 0;
703 for (
int Exact : Exacts)
736 bool &HasSizeMismatch)
const {
737 HasSizeMismatch =
false;
746 ConstraintInfo &info)
const;
761 std::string &)
const {
770 unsigned &Index)
const;
777 if (*Constraint ==
'p')
778 return std::string(
"r");
779 return std::string(1, *Constraint);
797 assert(
DataLayout &&
"Uninitialized DataLayout!");
855 const std::vector<std::string> &FeatureVec)
const;
858 virtual StringRef
getABI()
const {
return StringRef(); }
890 bool Enabled)
const {
891 Features[
Name] = Enabled;
921 assert(
RegParmMax < 7 &&
"RegParmMax value is larger than AST can handle");
941 (
getTriple().getArch() == llvm::Triple::x86 ||
942 getTriple().getArch() == llvm::Triple::x86_64);
1039 for (
const auto &Ext :
getTargetOpts().OpenCLExtensionsAsWritten) {
bool useObjCFP2RetForComplexLongDouble() const
Check whether _Complex long double should use the "fp2ret" flavor of Objective-C message passing on t...
void support(llvm::StringRef Ext, bool V=true)
Enable or disable support for OpenCL extensions.
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]]].
virtual void adjust(LangOptions &Opts)
Set forced language options.
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
virtual uint64_t getNullPointerValue(unsigned AddrSpace) const
Get integer value for null pointer.
unsigned getChar16Align() const
unsigned getLargeArrayAlign() const
IntType getWIntType() const
bool validateOutputConstraint(ConstraintInfo &Info) const
bool isLittleEndian() 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://refspecs.linuxbase.org/elf/x86_64-abi-0.21.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 defined 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
virtual void adjustTargetOptions(const CodeGenOptions &CGOpts, TargetOptions &TargetOpts) const
Adjust target options based on codegen options.
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
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'.
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 void setOpenCLExtensionOpts()
Set supported OpenCL extensions as written on command line.
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
unsigned getNewAlign() const
Return the largest alignment for which a suitably-sized allocation with '::operator new(size_t)' is g...
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
virtual uint64_t getMaxPointerWidth() const
Return the maximum width of pointers on this target.
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
ID
Defines the address space values used by the address space qualifier of QualType. ...
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
virtual StringRef getConstraintRegister(const StringRef &Constraint, const StringRef &Expression) const
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
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?
unsigned Map[FirstTargetAddressSpace]
The type of a lookup table which maps from language-specific address spaces to target-specific ones...
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
bool isRenderScriptTarget() const
Returns true for RenderScript.
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
unsigned IsRenderScriptTarget
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 preferred 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 LangAS::ID getOpenCLImageAddrSpace() const
Get OpenCL image type address space.
virtual ArrayRef< GCCRegAlias > getGCCRegAliases() const =0
virtual Optional< unsigned > getDWARFAddressSpace(unsigned AddressSpace) const
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.
IntType getSignedSizeType() const
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()
const llvm::fltSemantics * FloatFormat
virtual llvm::Optional< unsigned > getConstantAddressSpace() const
Return an AST address space which can be used opportunistically for constant global memory...
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 --------------------——===//
StringRef getNormalizedGCCRegisterName(StringRef Name, bool ReturnCanonical=false) const
Returns the "normalized" GCC register name.
bool isValidAsmImmediate(const llvm::APInt &Value) const
bool allowsRegister() const
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
struct clang::TargetInfo::ConstraintInfo::@155 ImmRange
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.
char __ovld __cnfn max(char x, char y)
Returns y if x < y, otherwise it returns x.
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
unsigned getLongWidth() const
getLongWidth/Align - Return the size of 'signed long' and 'unsigned long' for this target...
virtual unsigned getVtblPtrAddressSpace() const
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.