]> granicus.if.org Git - clang/commitdiff
Fix a fixme by allowing pointers in different address spaces to have
authorChris Lattner <sabre@nondot.org>
Sat, 8 Mar 2008 08:34:58 +0000 (08:34 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 8 Mar 2008 08:34:58 +0000 (08:34 +0000)
different widths.  Start simplifying TargetInfo accessor methods.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48050 91177308-0d34-0410-b5e6-96231b3b80d8

AST/ASTContext.cpp
CodeGen/CodeGenModule.cpp
include/clang/Basic/TargetInfo.h

index b5b28bc390bee8c34afbc06c203d35fa36f0f6b1..5dd7d9aeebe0adc83b54e0bc79646eddd9d5d3c1 100644 (file)
@@ -260,9 +260,15 @@ ASTContext::getTypeInfo(QualType T) {
     // alignment requirements: getPointerInfo should take an AddrSpace.
     return getTypeInfo(QualType(cast<ASQualType>(T)->getBaseType(), 0));
   case Type::ObjCQualifiedId:
-  case Type::Pointer:
-    Target.getPointerInfo(Size, Align);
+    Size  = Target.getPointerWidth(0);
+    Align = Target.getPointerAlign(0);
+    break;
+  case Type::Pointer: {
+    unsigned AS = cast<PointerType>(T)->getPointeeType().getAddressSpace();
+    Size  = Target.getPointerWidth(AS);
+    Align = Target.getPointerAlign(AS);
     break;
+  }
   case Type::Reference:
     // "When applied to a reference or a reference type, the result is the size
     // of the referenced type." C++98 5.3.3p2: expr.sizeof.
index 554fc3fbebe99434258335e7b415de202ce80e2e..d2b60475250bf7a7c65115284f8c236029f8f937 100644 (file)
@@ -339,9 +339,7 @@ llvm::Function *CodeGenModule::getIntrinsic(unsigned IID,const llvm::Type **Tys,
 llvm::Function *CodeGenModule::getMemCpyFn() {
   if (MemCpyFn) return MemCpyFn;
   llvm::Intrinsic::ID IID;
-  uint64_t Size; unsigned Align;
-  Context.Target.getPointerInfo(Size, Align);
-  switch (Size) {
+  switch (Context.Target.getPointerWidth(0)) {
   default: assert(0 && "Unknown ptr width");
   case 32: IID = llvm::Intrinsic::memcpy_i32; break;
   case 64: IID = llvm::Intrinsic::memcpy_i64; break;
@@ -352,9 +350,7 @@ llvm::Function *CodeGenModule::getMemCpyFn() {
 llvm::Function *CodeGenModule::getMemSetFn() {
   if (MemSetFn) return MemSetFn;
   llvm::Intrinsic::ID IID;
-  uint64_t Size; unsigned Align;
-  Context.Target.getPointerInfo(Size, Align);
-  switch (Size) {
+  switch (Context.Target.getPointerWidth(0)) {
   default: assert(0 && "Unknown ptr width");
   case 32: IID = llvm::Intrinsic::memset_i32; break;
   case 64: IID = llvm::Intrinsic::memset_i64; break;
index ec6030135a0f734ea31faeb3d0d807ac9e36088e..4fb50bca91925d58bd5e3c2f47b1da41c3835df0 100644 (file)
@@ -64,12 +64,10 @@ public:
     return true;
   }
   
-  /// getPointerWidth - Return the width of pointers on this target, we
-  /// currently assume one pointer type.
-  void getPointerInfo(uint64_t &Size, unsigned &Align) const {
-    Size = 32;  // FIXME: implement correctly.
-    Align = 32;
-  }
+  /// 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.  
@@ -119,13 +117,9 @@ public:
   void getLongDoubleInfo(uint64_t &Size, unsigned &Align,
                          const llvm::fltSemantics *&Format) const;
   
-  /// getWCharInfo - Return the size of wchar_t in bits.
-  ///
-  void getWCharInfo(uint64_t &Size, unsigned &Align) const {
-    Size = WCharWidth;
-    Align = WCharAlign;
-  }
-  
+  unsigned getWCharWidth() const { return WCharWidth; }
+  unsigned getWCharAlign() const { return WCharAlign; }
+
   /// getIntMaxTWidth - Return the size of intmax_t and uintmax_t for this
   /// target, in bits.  
   unsigned getIntMaxTWidth() const {
@@ -182,20 +176,14 @@ public:
   }
   
   unsigned getCharWidth(bool isWide = false) const {
-    uint64_t Size; unsigned Align;
     if (isWide)
-      getWCharInfo(Size, Align);
-    else
-      getCharInfo(Size, Align);
-    return static_cast<unsigned>(Size);
-  }
-  
-  unsigned getWCharWidth() const {
+      return WCharWidth;
     uint64_t Size; unsigned Align;
-    getWCharInfo(Size, Align);
+    getCharInfo(Size, Align);
     return static_cast<unsigned>(Size);
   }
   
+
   unsigned getIntWidth() const {
     uint64_t Size; unsigned Align;
     getIntInfo(Size, Align);