summaryrefslogtreecommitdiff
path: root/lib/Target/TargetData.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-12-22 05:01:15 +0000
committerChris Lattner <sabre@nondot.org>2003-12-22 05:01:15 +0000
commitf045328dd11ffcba04f437ed244e4cd2d352fe3d (patch)
tree32a8493066c0f0eb7474bc0edc01af71fb76e05a /lib/Target/TargetData.cpp
parentb0404c7a6c30fe347194b6c323bb283fcf708d49 (diff)
downloadllvm-f045328dd11ffcba04f437ed244e4cd2d352fe3d.tar.gz
llvm-f045328dd11ffcba04f437ed244e4cd2d352fe3d.tar.bz2
llvm-f045328dd11ffcba04f437ed244e4cd2d352fe3d.tar.xz
finegrainify namespacification
add new getIntPtrType() method git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10579 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/TargetData.cpp')
-rw-r--r--lib/Target/TargetData.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp
index ed6936dd12..91c9d01198 100644
--- a/lib/Target/TargetData.cpp
+++ b/lib/Target/TargetData.cpp
@@ -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