aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Basic/TargetInfo.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang/Basic/TargetInfo.h')
-rw-r--r--include/clang/Basic/TargetInfo.h84
1 files changed, 48 insertions, 36 deletions
diff --git a/include/clang/Basic/TargetInfo.h b/include/clang/Basic/TargetInfo.h
index 047872dd4017..edef7c0377f2 100644
--- a/include/clang/Basic/TargetInfo.h
+++ b/include/clang/Basic/TargetInfo.h
@@ -16,9 +16,9 @@
#define LLVM_CLANG_BASIC_TARGETINFO_H
#include "clang/Basic/AddressSpaces.h"
-#include "clang/Basic/TargetCXXABI.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/Specifiers.h"
+#include "clang/Basic/TargetCXXABI.h"
#include "clang/Basic/TargetOptions.h"
#include "clang/Basic/VersionTuple.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
@@ -47,7 +47,7 @@ namespace Builtin { struct Info; }
/// \brief Exposes information about the current target.
///
class TargetInfo : public RefCountedBase<TargetInfo> {
- IntrusiveRefCntPtr<TargetOptions> TargetOpts;
+ std::shared_ptr<TargetOptions> TargetOpts;
llvm::Triple Triple;
protected:
// Target values set by the ctor of the actual target implementation. Default
@@ -94,8 +94,9 @@ public:
/// \param Opts - The options to use to initialize the target. The target may
/// modify the options to canonicalize the target feature information to match
/// what the backend expects.
- static TargetInfo* CreateTargetInfo(DiagnosticsEngine &Diags,
- TargetOptions *Opts);
+ static TargetInfo *
+ CreateTargetInfo(DiagnosticsEngine &Diags,
+ const std::shared_ptr<TargetOptions> &Opts);
virtual ~TargetInfo();
@@ -105,10 +106,6 @@ public:
return *TargetOpts;
}
- void setTargetOpts(TargetOptions *TargetOpts) {
- this->TargetOpts = TargetOpts;
- }
-
///===---- Target Data Type Query Methods -------------------------------===//
enum IntType {
NoInt = 0,
@@ -173,7 +170,7 @@ public:
};
protected:
- IntType SizeType, IntMaxType, UIntMaxType, PtrDiffType, IntPtrType, WCharType,
+ IntType SizeType, IntMaxType, PtrDiffType, IntPtrType, WCharType,
WIntType, Char16Type, Char32Type, Int64Type, SigAtomicType,
ProcessIDType;
@@ -209,19 +206,44 @@ protected:
public:
IntType getSizeType() const { return SizeType; }
IntType getIntMaxType() const { return IntMaxType; }
- IntType getUIntMaxType() const { return UIntMaxType; }
+ IntType getUIntMaxType() const {
+ return getCorrespondingUnsignedType(IntMaxType);
+ }
IntType getPtrDiffType(unsigned AddrSpace) const {
return AddrSpace == 0 ? PtrDiffType : getPtrDiffTypeV(AddrSpace);
}
IntType getIntPtrType() const { return IntPtrType; }
+ IntType getUIntPtrType() const {
+ return getCorrespondingUnsignedType(IntPtrType);
+ }
IntType getWCharType() const { return WCharType; }
IntType getWIntType() const { return WIntType; }
IntType getChar16Type() const { return Char16Type; }
IntType getChar32Type() const { return Char32Type; }
IntType getInt64Type() const { return Int64Type; }
+ IntType getUInt64Type() const {
+ return getCorrespondingUnsignedType(Int64Type);
+ }
IntType getSigAtomicType() const { return SigAtomicType; }
IntType getProcessIDType() const { return ProcessIDType; }
+ static IntType getCorrespondingUnsignedType(IntType T) {
+ switch (T) {
+ case SignedChar:
+ return UnsignedChar;
+ case SignedShort:
+ return UnsignedShort;
+ case SignedInt:
+ return UnsignedInt;
+ case SignedLong:
+ return UnsignedLong;
+ case SignedLongLong:
+ return UnsignedLongLong;
+ default:
+ llvm_unreachable("Unexpected signed integer type");
+ }
+ }
+
/// \brief Return the width (in bits) of the specified integer type enum.
///
/// For example, SignedInt -> getIntWidth().
@@ -230,6 +252,9 @@ public:
/// \brief Return integer type with specified width.
IntType getIntTypeByWidth(unsigned BitWidth, bool IsSigned) const;
+ /// \brief Return the smallest integer type with at least the specified width.
+ IntType getLeastIntTypeByWidth(unsigned BitWidth, bool IsSigned) const;
+
/// \brief Return floating point type with specified width.
RealType getRealTypeByWidth(unsigned BitWidth) const;
@@ -283,7 +308,7 @@ public:
unsigned getLongLongAlign() const { return LongLongAlign; }
/// \brief Determine whether the __int128 type is supported on this target.
- bool hasInt128Type() const { return getPointerWidth(0) >= 64; } // FIXME
+ virtual bool hasInt128Type() const { return getPointerWidth(0) >= 64; } // FIXME
/// \brief Return the alignment that is suitable for storing any
/// object with a fundamental alignment requirement.
@@ -421,7 +446,13 @@ public:
/// \brief Return the constant suffix for the specified integer type enum.
///
/// For example, SignedLong -> "L".
- static const char *getTypeConstantSuffix(IntType T);
+ const char *getTypeConstantSuffix(IntType T) const;
+
+ /// \brief Return the printf format modifier for the specified
+ /// integer type enum.
+ ///
+ /// For example, SignedLong -> "l".
+ static const char *getTypeFormatModifier(IntType T);
/// \brief Check whether the given real type should use the "fpret" flavor of
/// Objective-C message passing on this target.
@@ -579,6 +610,7 @@ public:
}
const char *getTargetDescription() const {
+ assert(DescriptionString);
return DescriptionString;
}
@@ -604,24 +636,6 @@ public:
/// either; the entire thing is pretty badly mangled.
virtual bool hasProtectedVisibility() const { return true; }
- /// \brief Return the section to use for CFString literals, or 0 if no
- /// special section is used.
- virtual const char *getCFStringSection() const {
- return "__DATA,__cfstring";
- }
-
- /// \brief Return the section to use for NSString literals, or 0 if no
- /// special section is used.
- virtual const char *getNSStringSection() const {
- return "__OBJC,__cstring_object,regular,no_dead_strip";
- }
-
- /// \brief Return the section to use for NSString literals, or 0 if no
- /// special section is used (NonFragile ABI).
- virtual const char *getNSStringNonFragileABISection() const {
- return "__DATA, __objc_stringobj, regular, no_dead_strip";
- }
-
/// \brief An optional hook that targets can implement to perform semantic
/// checking on attribute((section("foo"))) specifiers.
///
@@ -641,7 +655,7 @@ public:
///
/// Apply changes to the target information with respect to certain
/// language options which change the target configuration.
- virtual void setForcedLangOptions(LangOptions &Opts);
+ virtual void adjust(const LangOptions &Opts);
/// \brief Get the default set of target features for the CPU;
/// this should include all legal feature strings on the target.
@@ -649,9 +663,7 @@ public:
}
/// \brief Get the ABI currently in use.
- virtual const char *getABI() const {
- return "";
- }
+ virtual StringRef getABI() const { return StringRef(); }
/// \brief Get the C++ ABI currently in use.
TargetCXXABI getCXXABI() const {
@@ -752,7 +764,7 @@ public:
/// \brief Return the section to use for C++ static initialization functions.
virtual const char *getStaticInitSectionSpecifier() const {
- return 0;
+ return nullptr;
}
const LangAS::Map &getAddressSpaceMap() const {
@@ -818,7 +830,7 @@ protected:
unsigned &NumAliases) const = 0;
virtual void getGCCAddlRegNames(const AddlRegName *&Addl,
unsigned &NumAddl) const {
- Addl = 0;
+ Addl = nullptr;
NumAddl = 0;
}
virtual bool validateAsmConstraint(const char *&Name,