summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-05-06 16:14:39 +0000
committerChris Lattner <sabre@nondot.org>2002-05-06 16:14:39 +0000
commit398a86f14e7535eb9e12bc2caba8d91c04d74a75 (patch)
tree4b4a4d8de83f57c2f233d8b43c5fb965de50b13b /llvm/lib
parentf4cdbf34e5c9d15f024dcef99f804fec3ebdd733 (diff)
downloadbcm5719-llvm-398a86f14e7535eb9e12bc2caba8d91c04d74a75.tar.gz
bcm5719-llvm-398a86f14e7535eb9e12bc2caba8d91c04d74a75.zip
Implement getPrimitiveSize()
don't use isPointerType() llvm-svn: 2485
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/VMCore/Type.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/llvm/lib/VMCore/Type.cpp b/llvm/lib/VMCore/Type.cpp
index 3ea928e4eb0..d193a38ed6f 100644
--- a/llvm/lib/VMCore/Type.cpp
+++ b/llvm/lib/VMCore/Type.cpp
@@ -87,8 +87,8 @@ const Type *Type::getPrimitiveType(PrimitiveID IDNumber) {
//
bool Type::isLosslesslyConvertableTo(const Type *Ty) const {
if (this == Ty) return true;
- if ((!isPrimitiveType() && !isPointerType()) ||
- (!Ty->isPointerType() && !Ty->isPrimitiveType())) return false;
+ if ((!isPrimitiveType() && !isa<PointerType>(this)) ||
+ (!isa<PointerType>(Ty) && !Ty->isPrimitiveType())) return false;
if (getPrimitiveID() == Ty->getPrimitiveID())
return true; // Handles identity cast, and cast of differing pointer types
@@ -110,6 +110,18 @@ bool Type::isLosslesslyConvertableTo(const Type *Ty) const {
}
}
+// getPrimitiveSize - Return the basic size of this type if it is a primative
+// type. These are fixed by LLVM and are not target dependant. This will
+// return zero if the type does not have a size or is not a primitive type.
+//
+unsigned Type::getPrimitiveSize() const {
+ switch (getPrimitiveID()) {
+#define HANDLE_PRIM_TYPE(TY,SIZE) case TY##TyID: return SIZE;
+#include "llvm/Type.def"
+ default: return 0;
+ }
+}
+
bool StructType::indexValid(const Value *V) const {
if (!isa<Constant>(V)) return false;
OpenPOWER on IntegriCloud