diff options
author | Chris Lattner <sabre@nondot.org> | 2002-05-06 16:12:53 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-05-06 16:12:53 +0000 |
commit | 4dedcb267039c3a8b0d611583a2d77321159f512 (patch) | |
tree | 7369742e572499e31457f62cc587b9a3c490188d | |
parent | 79a31b1782c0f9a3b84768d299232aa538a95bcd (diff) |
* Add getPrimitiveSize method
* Remove isPointerType, isMethodType, etc... methods. Use isa<> instead
* Added specialization of isa for pointer types so that DerivedTypes.h doesn't
have to be #included to use isa<PointerType>(..)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2483 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Type.h | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/include/llvm/Type.h b/include/llvm/Type.h index 60601002de..125fbc1d27 100644 --- a/include/llvm/Type.h +++ b/include/llvm/Type.h @@ -151,14 +151,34 @@ public: // bool isLosslesslyConvertableTo(const Type *Ty) const; + + // Here are some useful little methods to query what type derived types are + // Note that all other types can just compare to see if this == Type::xxxTy; + // + inline bool isPrimitiveType() const { return ID < FirstDerivedTyID; } + inline bool isDerivedType() const { return ID >= FirstDerivedTyID; } + + // isFirstClassType - Return true if the value is holdable in a register. + inline bool isFirstClassType() const { + return isPrimitiveType() || ID == PointerTyID; + } + // isSized - Return true if it makes sense to take the size of this type. To // get the actual size for a particular target, it is reasonable to use the // TargetData subsystem to do this. // bool isSized() const { - return ID != TypeTyID && ID != FunctionTyID && ID != OpaqueTyID; + return ID != VoidTyID && ID != TypeTyID && + ID != FunctionTyID && ID != LabelTyID && ID != OpaqueTyID; } + // 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 getPrimitiveSize() const; + + //===--------------------------------------------------------------------===// // Type Iteration support // @@ -199,29 +219,12 @@ public: static Type *TypeTy , *LabelTy; - // Here are some useful little methods to query what type derived types are - // Note that all other types can just compare to see if this == Type::xxxTy; - // - inline bool isPrimitiveType() const { return ID < FirstDerivedTyID; } - inline bool isDerivedType() const { return ID >= FirstDerivedTyID; } - - // isFirstClassType - Return true if the value is holdable in a register. - inline bool isFirstClassType() const { - return isPrimitiveType() || ID == PointerTyID; - } - // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const Type *T) { return true; } static inline bool classof(const Value *V) { return V->getValueType() == Value::TypeVal; } - // Methods for determining the subtype of this Type. This section defines a - // family of isArrayType(), isLabelType(), etc functions... - // -#define HANDLE_DERV_TYPE(NAME, CLASS) \ - inline bool is##NAME##Type() const { return ID == NAME##TyID; } - #include "llvm/Type.def" private: @@ -291,4 +294,11 @@ template <> struct GraphTraits<const Type*> { } }; +template <> inline bool isa<PointerType, const Type*>(const Type *Ty) { + return Ty->getPrimitiveID() == Type::PointerTyID; +} +template <> inline bool isa<PointerType, Type*>(Type *Ty) { + return Ty->getPrimitiveID() == Type::PointerTyID; +} + #endif |