Fixed a strange construct. Please review.
[oota-llvm.git] / include / llvm / ADT / APInt.h
index 9a5643bfc5e1bf4b5b50d59f7a215d4c371550a9..dc5d34f3b1f34850035081ff4dda029aea72b90d 100644 (file)
@@ -1,4 +1,4 @@
-//===-- llvm/Support/APInt.h - For Arbitrary Precision Integer -*- C++ -*--===//
+//===-- llvm/ADT/APInt.h - For Arbitrary Precision Integer -----*- C++ -*--===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -16,6 +16,7 @@
 #define LLVM_APINT_H
 
 #include "llvm/Support/DataTypes.h"
+#include "llvm/Bitcode/SerializationFwd.h"
 #include <cassert>
 #include <string>
 
@@ -153,11 +154,6 @@ class APInt {
                      const APInt &RHS, uint32_t rhsWords,
                      APInt *Quotient, APInt *Remainder);
 
-#ifndef NDEBUG
-  /// @brief debug method
-  void dump() const;
-#endif
-
 public:
   /// @name Constructors
   /// @{
@@ -177,7 +173,7 @@ public:
   /// @param numWords the number of words in bigVal
   /// @param bigVal a sequence of words to form the initial value of the APInt
   /// @brief Construct an APInt of numBits width, initialized as bigVal[].
-  APInt(uint32_t numBits, uint32_t numWords, uint64_t bigVal[]);
+  APInt(uint32_t numBits, uint32_t numWords, const uint64_t bigVal[]);
 
   /// This constructor interprets Val as a string in the given radix. The 
   /// interpretation stops when the first charater that is not suitable for the
@@ -208,6 +204,16 @@ public:
 
   /// @brief Destructor.
   ~APInt();
+  
+  /// Default constructor that creates an uninitialized APInt.  This is useful
+  ///  for object deserialization (pair this with the static method Read).
+  explicit APInt() : BitWidth(1) {}
+  
+  /// @brief Used by the Bitcode serializer to emit APInts to Bitcode.
+  void Emit(Serializer& S) const;
+  
+  /// @brief Used by the Bitcode deserializer to deserialize APInts.
+  void Read(Deserializer& D);
 
   /// @}
   /// @name Value Tests
@@ -1074,6 +1080,13 @@ public:
   /// Extract the given bit of a bignum; returns 0 or 1.  Zero-based.
   static int tcExtractBit(const integerPart *, unsigned int bit);
 
+  /// Copy the bit vector of width srcBITS from SRC, starting at bit
+  /// srcLSB, to DST, of dstCOUNT parts, such that the bit srcLSB
+  /// becomes the least significant bit of DST.  All high bits above
+  /// srcBITS in DST are zero-filled.
+  static void tcExtract(integerPart *, unsigned int dstCount, const integerPart *,
+                        unsigned int srcBits, unsigned int srcLSB);
+
   /// Set the given bit of a bignum.  Zero-based.
   static void tcSetBit(integerPart *, unsigned int bit);
 
@@ -1119,10 +1132,12 @@ public:
   static int tcMultiply(integerPart *, const integerPart *,
                        const integerPart *, unsigned);
 
-  /// DST = LHS * RHS, where DST has twice the width as the operands.
-  /// No overflow occurs.  DST must be disjoint from both operands.
-  static void tcFullMultiply(integerPart *, const integerPart *,
-                            const integerPart *, unsigned);
+  /// DST = LHS * RHS, where DST has width the sum of the widths of
+  /// the operands.  No overflow occurs.  DST must be disjoint from
+  /// both operands. Returns the number of parts required to hold the
+  /// result.
+  static unsigned int tcFullMultiply(integerPart *, const integerPart *,
+                                    const integerPart *, unsigned, unsigned);
 
   /// If RHS is zero LHS and REMAINDER are left unchanged, return one.
   /// Otherwise set LHS to LHS / RHS with the fractional part
@@ -1165,6 +1180,9 @@ public:
   static void tcSetLeastSignificantBits(integerPart *, unsigned int,
                                        unsigned int bits);
 
+  /// @brief debug method
+  void dump() const;
+
   /// @}
 };