Support vector casts in more places, fixing a variety of assertion
[oota-llvm.git] / include / llvm / Type.h
index c1732af09bdd414bd924a2124d3bf49f401da409..9a48731ede9b8254b31e94ec3f3bdc97df4f6072 100644 (file)
@@ -268,19 +268,16 @@ public:
   /// primitive type.
   ///
   unsigned getPrimitiveSizeInBits() const;
-  
+
+  /// getScalarSizeInBits - If this is a vector type, return the
+  /// getPrimitiveSizeInBits value for the element type. Otherwise return the
+  /// getPrimitiveSizeInBits value for this type.
+  unsigned getScalarSizeInBits() const;
+
   /// getFPMantissaWidth - Return the width of the mantissa of this type.  This
-  /// is only valid on scalar floating point types.  If the FP type does not
+  /// is only valid on floating point types.  If the FP type does not
   /// have a stable mantissa (e.g. ppc long double), this method returns -1.
-  int getFPMantissaWidth() const {
-    assert(isFloatingPoint() && "Not a floating point type!");
-    if (ID == FloatTyID) return 24;
-    if (ID == DoubleTyID) return 53;
-    if (ID == X86_FP80TyID) return 64;
-    if (ID == FP128TyID) return 113;
-    assert(ID == PPC_FP128TyID && "unknown fp type");
-    return -1;
-  }
+  int getFPMantissaWidth() const;
 
   /// getForwardedType - Return the type that this type has been resolved to if
   /// it has been resolved to anything.  This is used to implement the
@@ -296,6 +293,10 @@ public:
   /// function.
   const Type *getVAArgsPromotedType() const; 
 
+  /// getScalarType - If this is a vector type, return the element type,
+  /// otherwise return this.
+  const Type *getScalarType() const;
+
   //===--------------------------------------------------------------------===//
   // Type Iteration support
   //