[llvm-commits] [llvm] r51274 - /llvm/trunk/include/llvm/Type.h

Chris Lattner sabre at nondot.org
Mon May 19 14:17:01 PDT 2008


Author: lattner
Date: Mon May 19 16:17:01 2008
New Revision: 51274

URL: http://llvm.org/viewvc/llvm-project?rev=51274&view=rev
Log:
add a helper method.

Modified:
    llvm/trunk/include/llvm/Type.h

Modified: llvm/trunk/include/llvm/Type.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Type.h?rev=51274&r1=51273&r2=51274&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Type.h (original)
+++ llvm/trunk/include/llvm/Type.h Mon May 19 16:17:01 2008
@@ -242,6 +242,19 @@
   /// primitive type.
   ///
   unsigned getPrimitiveSizeInBits() 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
+  /// 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;
+  }
 
   /// getForwardedType - Return the type that this type has been resolved to if
   /// it has been resolved to anything.  This is used to implement the





More information about the llvm-commits mailing list