Add a method to get the bit width of a packed type.
authorReid Spencer <rspencer@reidspencer.com>
Wed, 15 Nov 2006 03:02:41 +0000 (03:02 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Wed, 15 Nov 2006 03:02:41 +0000 (03:02 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31750 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/DerivedTypes.h

index e83679d04685e705690e04327c0e3b4240282f90..13344ba5a34ccb1399d6ac27613ee8594650fed9 100644 (file)
@@ -299,8 +299,14 @@ public:
   ///
   static PackedType *get(const Type *ElementType, unsigned NumElements);
 
+  /// @brief Return the number of elements in the Packed type.
   inline unsigned getNumElements() const { return NumElements; }
 
+  /// @brief Return the number of bits in the Packed type.
+  inline unsigned getBitWidth() const { 
+    return NumElements *getElementType()->getPrimitiveSizeInBits();
+  }
+
   // Implement the AbstractTypeUser interface.
   virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
   virtual void typeBecameConcrete(const DerivedType *AbsTy);