[cfe-commits] r50890 - in /cfe/trunk: include/clang/Basic/TargetInfo.h lib/Basic/TargetInfo.cpp lib/Basic/Targets.cpp

Chris Lattner sabre at nondot.org
Thu May 8 23:08:39 PDT 2008


Author: lattner
Date: Fri May  9 01:08:39 2008
New Revision: 50890

URL: http://llvm.org/viewvc/llvm-project?rev=50890&view=rev
Log:
parameterize pointer size/align better without doing virtual method calls in normal case.

Modified:
    cfe/trunk/include/clang/Basic/TargetInfo.h
    cfe/trunk/lib/Basic/TargetInfo.cpp
    cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=50890&r1=50889&r2=50890&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Fri May  9 01:08:39 2008
@@ -35,11 +35,12 @@
   // 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 @@
   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.

Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=50890&r1=50889&r2=50890&view=diff

==============================================================================
--- cfe/trunk/lib/Basic/TargetInfo.cpp (original)
+++ cfe/trunk/lib/Basic/TargetInfo.cpp Fri May  9 01:08:39 2008
@@ -23,6 +23,7 @@
 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;

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=50890&r1=50889&r2=50890&view=diff

==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri May  9 01:08:39 2008
@@ -869,10 +869,8 @@
     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");
     }





More information about the cfe-commits mailing list