diff options
| author | Chris Lattner <sabre@nondot.org> | 2008-05-09 06:08:39 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2008-05-09 06:08:39 +0000 |
| commit | 5e2ef0c18ae9816da8a20fb034be7d517d20769a (patch) | |
| tree | 44cea0bfed806726a4833ba0871f9bf2e976fcdc | |
| parent | 55258cf27822b9ee51fc7aea3f4b636d51e72479 (diff) | |
| download | bcm5719-llvm-5e2ef0c18ae9816da8a20fb034be7d517d20769a.tar.gz bcm5719-llvm-5e2ef0c18ae9816da8a20fb034be7d517d20769a.zip | |
parameterize pointer size/align better without doing virtual method calls in normal case.
llvm-svn: 50890
| -rw-r--r-- | clang/include/clang/Basic/TargetInfo.h | 27 | ||||
| -rw-r--r-- | clang/lib/Basic/TargetInfo.cpp | 1 | ||||
| -rw-r--r-- | clang/lib/Basic/Targets.cpp | 6 |
3 files changed, 22 insertions, 12 deletions
diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h index d135fe00ab0..36fbb0d1c23 100644 --- a/clang/include/clang/Basic/TargetInfo.h +++ b/clang/include/clang/Basic/TargetInfo.h @@ -35,11 +35,12 @@ protected: // Target values set by the ctor of the actual target implementation. Default // values are specified by the TargetInfo constructor. bool CharIsSigned; - unsigned WCharWidth, WCharAlign; - unsigned IntWidth, IntAlign; - unsigned DoubleWidth, DoubleAlign; - unsigned LongWidth, LongAlign; - unsigned LongLongWidth, LongLongAlign; + unsigned char PointerWidth, PointerAlign; + unsigned char WCharWidth, WCharAlign; + unsigned char IntWidth, IntAlign; + unsigned char DoubleWidth, DoubleAlign; + unsigned char LongWidth, LongAlign; + unsigned char LongLongWidth, LongLongAlign; const llvm::fltSemantics *FloatFormat, *DoubleFormat, *LongDoubleFormat; @@ -61,9 +62,19 @@ public: bool isCharSigned() const { return CharIsSigned; } /// getPointerWidth - Return the width of pointers on this target, for the - /// specified address space. FIXME: implement correctly. - virtual uint64_t getPointerWidth(unsigned AddrSpace) const { return 32; } - virtual uint64_t getPointerAlign(unsigned AddrSpace) const { return 32; } + /// specified address space. + uint64_t getPointerWidth(unsigned AddrSpace) const { + return AddrSpace == 0 ? PointerWidth : getPointerWidthV(AddrSpace); + } + uint64_t getPointerAlign(unsigned AddrSpace) const { + return AddrSpace == 0 ? PointerAlign : getPointerAlignV(AddrSpace); + } + virtual uint64_t getPointerWidthV(unsigned AddrSpace) const { + return PointerWidth; + } + virtual uint64_t getPointerAlignV(unsigned AddrSpace) const { + return PointerAlign; + } /// getBoolWidth/Align - Return the size of '_Bool' and C++ 'bool' for this /// target, in bits. diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp index dd1fe648d42..e8fc9232e12 100644 --- a/clang/lib/Basic/TargetInfo.cpp +++ b/clang/lib/Basic/TargetInfo.cpp @@ -23,6 +23,7 @@ using namespace clang; TargetInfo::TargetInfo(const std::string &T) : Triple(T) { // Set defaults. These should be overridden by concrete targets as needed. CharIsSigned = true; + PointerWidth = PointerAlign = 32; WCharWidth = WCharAlign = 32; IntWidth = IntAlign = 32; LongWidth = LongAlign = 32; diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index 25bc6fbb4de..9c1675d6afa 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -869,10 +869,8 @@ namespace { PIC16TargetInfo(const std::string& triple) : TargetInfo(triple) { IntWidth = IntAlign = 16; } - virtual uint64_t getPointerWidth(unsigned AddrSpace) const { return 16; } - virtual uint64_t getPointerAlign(unsigned AddrSpace) const { return 8; } - virtual unsigned getIntWidth() const { return 16; } - virtual unsigned getIntAlign() const { return 8; } + virtual uint64_t getPointerWidthV(unsigned AddrSpace) const { return 16; } + virtual uint64_t getPointerAlignV(unsigned AddrSpace) const { return 8; } virtual void getTargetDefines(std::vector<char> &Defines) const { Define(Defines, "__pic16"); } |

