finegrainify namespacification
authorChris Lattner <sabre@nondot.org>
Mon, 22 Dec 2003 05:01:15 +0000 (05:01 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 22 Dec 2003 05:01:15 +0000 (05:01 +0000)
add new getIntPtrType() method

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

lib/Target/TargetData.cpp

index ed6936dd1223c75313227feb656fb5f15e055997..91c9d01198cae207992d4f021297f44226426fe8 100644 (file)
@@ -21,8 +21,7 @@
 #include "llvm/Module.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Constants.h"
-
-namespace llvm {
+using namespace llvm;
 
 // Handle the Pass registration stuff necessary to use TargetData's.
 namespace {
@@ -189,6 +188,18 @@ unsigned char TargetData::getTypeAlignment(const Type *Ty) const {
   return Align;
 }
 
+/// getIntPtrType - Return an unsigned integer type that is the same size or
+/// greater to the host pointer size.
+const Type *TargetData::getIntPtrType() const {
+  switch (getPointerSize()) {
+  default: assert(0 && "Unknown pointer size!");
+  case 2: return Type::UShortTy;
+  case 4: return Type::UIntTy;
+  case 8: return Type::ULongTy;
+  }
+}
+
+
 uint64_t TargetData::getIndexedOffset(const Type *ptrTy,
                                      const std::vector<Value*> &Idx) const {
   const Type *Ty = ptrTy;
@@ -223,4 +234,3 @@ uint64_t TargetData::getIndexedOffset(const Type *ptrTy,
   return Result;
 }
 
-} // End llvm namespace