aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Basic
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-03-08 08:52:55 +0000
committerChris Lattner <sabre@nondot.org>2008-03-08 08:52:55 +0000
commit9e9b6dc3fd413f5341fab54b681420eeb21cd169 (patch)
treebb692e630a57cfa84a91fca635cad0150dfee1be /include/clang/Basic
parentf72a44330b9d9a4b2d93e9b91cfb8ab7bd4a0643 (diff)
simplify all the type info accessors in TargeTInfo to return scalars,
which is simpler to use and provide. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48051 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic')
-rw-r--r--include/clang/Basic/TargetInfo.h134
1 files changed, 50 insertions, 84 deletions
diff --git a/include/clang/Basic/TargetInfo.h b/include/clang/Basic/TargetInfo.h
index 4fb50bca91..2d2aca5698 100644
--- a/include/clang/Basic/TargetInfo.h
+++ b/include/clang/Basic/TargetInfo.h
@@ -33,13 +33,13 @@ class TargetInfo {
std::string Triple;
protected:
/// These are all caches for target values.
+ bool CharIsSigned;
unsigned WCharWidth, WCharAlign;
- //==----------------------------------------------------------------==/
- // TargetInfo Construction.
- //==----------------------------------------------------------------==/
+ // TargetInfo Constructor.
TargetInfo(const std::string &T) : Triple(T) {
- // Set defaults.
+ // Set defaults. These should be overridden by concrete targets as needed.
+ CharIsSigned = true;
WCharWidth = WCharAlign = 32;
}
@@ -59,67 +59,67 @@ public:
/// isCharSigned - Return true if 'char' is 'signed char' or false if it is
/// treated as 'unsigned char'. This is implementation defined according to
/// C99 6.2.5p15. In our implementation, this is target-specific.
- bool isCharSigned() const {
- // FIXME: implement correctly.
- return true;
- }
+ bool isCharSigned() const { return CharIsSigned; }
/// getPointerWidth - Return the width of pointers on this target, for the
/// specified address space. FIXME: implement correctly.
uint64_t getPointerWidth(unsigned AddrSpace) const { return 32; }
uint64_t getPointerAlign(unsigned AddrSpace) const { return 32; }
- /// getBoolInfo - Return the size of '_Bool' and C++ 'bool' for this target,
- /// in bits.
- void getBoolInfo(uint64_t &Size, unsigned &Align) const {
- Size = Align = 8; // FIXME: implement correctly: wrong for ppc32.
- }
+ /// getBoolWidth/Align - Return the size of '_Bool' and C++ 'bool' for this
+ /// target, in bits.
+ unsigned getBoolWidth(bool isWide = false) const { return 8; } // FIXME
+ unsigned getBoolAlign(bool isWide = false) const { return 8; } // FIXME
- /// getCharInfo - Return the size of 'char', 'signed char' and
- /// 'unsigned char' for this target, in bits.
- void getCharInfo(uint64_t &Size, unsigned &Align) const {
- Size = Align = 8; // FIXME: implement correctly.
+ unsigned getCharWidth(bool isWide = false) const {
+ return isWide ? getWCharWidth() : 8; // FIXME
}
-
- /// getShortInfo - Return the size of 'signed short' and 'unsigned short' for
- /// this target, in bits.
- void getShortInfo(uint64_t &Size, unsigned &Align) const {
- Size = Align = 16; // FIXME: implement correctly.
+ unsigned getCharAlign(bool isWide = false) const {
+ return isWide ? getWCharAlign() : 8; // FIXME
}
- /// getIntInfo - Return the size of 'signed int' and 'unsigned int' for this
- /// target, in bits.
- void getIntInfo(uint64_t &Size, unsigned &Align) const {
- Size = Align = 32; // FIXME: implement correctly.
- }
+ /// getShortWidth/Align - Return the size of 'signed short' and
+ /// 'unsigned short' for this target, in bits.
+ unsigned getShortWidth() const { return 16; } // FIXME
+ unsigned getShortAlign() const { return 16; } // FIXME
- /// getLongInfo - Return the size of 'signed long' and 'unsigned long' for
- /// this target, in bits.
- void getLongInfo(uint64_t &Size, unsigned &Align) const {
- Size = Align = 32; // FIXME: implement correctly: wrong for ppc64/x86-64
- }
-
- /// getLongLongInfo - Return the size of 'signed long long' and
- /// 'unsigned long long' for this target, in bits.
- void getLongLongInfo(uint64_t &Size, unsigned &Align) const {
- Size = Align = 64; // FIXME: implement correctly.
- }
+ /// getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for
+ /// this target, in bits.
+ unsigned getIntWidth() const { return 32; } // FIXME
+ unsigned getIntAlign() const { return 32; } // FIXME
- /// getFloatInfo - Characterize 'float' for this target.
- void getFloatInfo(uint64_t &Size, unsigned &Align,
- const llvm::fltSemantics *&Format) const;
-
- /// getDoubleInfo - Characterize 'double' for this target.
- void getDoubleInfo(uint64_t &Size, unsigned &Align,
- const llvm::fltSemantics *&Format) const;
-
- /// getLongDoubleInfo - Characterize 'long double' for this target.
- void getLongDoubleInfo(uint64_t &Size, unsigned &Align,
- const llvm::fltSemantics *&Format) const;
+ /// getLongWidth/Align - Return the size of 'signed long' and 'unsigned long'
+ /// for this target, in bits.
+ unsigned getLongWidth() const { return 32; } // FIXME
+ unsigned getLongAlign() const { return 32; } // FIXME
+ /// getLongLongWidth/Align - Return the size of 'signed long long' and
+ /// 'unsigned long long' for this target, in bits.
+ unsigned getLongLongWidth() const { return 64; } // FIXME
+ unsigned getLongLongAlign() const { return 64; } // FIXME
+
+ /// getWcharWidth/Align - Return the size of 'wchar_t' for this target, in
+ /// bits.
unsigned getWCharWidth() const { return WCharWidth; }
unsigned getWCharAlign() const { return WCharAlign; }
+ /// getFloatWidth/Align/Format - Return the size/align/format of 'float'.
+ unsigned getFloatWidth() const { return 32; } // FIXME
+ unsigned getFloatAlign() const { return 32; } // FIXME
+ const llvm::fltSemantics *getFloatFormat() const;
+
+ /// getDoubleWidth/Align/Format - Return the size/align/format of 'double'.
+ unsigned getDoubleWidth() const { return 64; } // FIXME
+ unsigned getDoubleAlign() const { return 32; } // FIXME
+ const llvm::fltSemantics *getDoubleFormat() const;
+
+ /// getLongDoubleWidth/Align/Format - Return the size/align/format of 'long
+ /// double'.
+ unsigned getLongDoubleWidth() const { return 64; } // FIXME
+ unsigned getLongDoubleAlign() const { return 64; } // FIXME
+ const llvm::fltSemantics *getLongDoubleFormat() const;
+
+
/// getIntMaxTWidth - Return the size of intmax_t and uintmax_t for this
/// target, in bits.
unsigned getIntMaxTWidth() const {
@@ -167,47 +167,13 @@ public:
// Returns a string of target-specific clobbers, in LLVM format.
virtual const char *getClobbers() const = 0;
- ///===---- Some helper methods ------------------------------------------===//
-
- unsigned getBoolWidth() const {
- uint64_t Size; unsigned Align;
- getBoolInfo(Size, Align);
- return static_cast<unsigned>(Size);
- }
-
- unsigned getCharWidth(bool isWide = false) const {
- if (isWide)
- return WCharWidth;
- uint64_t Size; unsigned Align;
- getCharInfo(Size, Align);
- return static_cast<unsigned>(Size);
- }
-
-
- unsigned getIntWidth() const {
- uint64_t Size; unsigned Align;
- getIntInfo(Size, Align);
- return static_cast<unsigned>(Size);
- }
-
- unsigned getLongWidth() const {
- uint64_t Size; unsigned Align;
- getLongInfo(Size, Align);
- return static_cast<unsigned>(Size);
- }
-
- unsigned getLongLongWidth() const {
- uint64_t Size; unsigned Align;
- getLongLongInfo(Size, Align);
- return static_cast<unsigned>(Size);
- }
/// getTargetPrefix - Return the target prefix used for identifying
/// llvm intrinsics.
virtual const char *getTargetPrefix() const = 0;
/// getTargetTriple - Return the target triple of the primary target.
- virtual const char *getTargetTriple() const {
+ const char *getTargetTriple() const {
return Triple.c_str();
}