Implement some nice functions useful for looking at types
authorChris Lattner <sabre@nondot.org>
Thu, 13 Dec 2001 00:40:16 +0000 (00:40 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 13 Dec 2001 00:40:16 +0000 (00:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1442 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Type.h

index 905aa2d11f5aa6c796825890290cd0babcda2d1d..3617aaed9e10d6ae7b5f408200bef73c748a8335 100644 (file)
@@ -146,6 +146,14 @@ public:
   //
   bool isLosslesslyConvertableTo(const Type *Ty) const;
 
+  // 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 != MethodTyID && ID != OpaqueTyID;
+  }
+
   //===--------------------------------------------------------------------===//
   // Type Iteration support
   //
@@ -190,9 +198,13 @@ public:
   // 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) {