-//===-- llvm/Support/APInt.h - For Arbitrary Precision Integer -*- C++ -*--===//
+//===-- llvm/ADT/APInt.h - For Arbitrary Precision Integer -----*- C++ -*--===//
//
// The LLVM Compiler Infrastructure
//
#define LLVM_APINT_H
#include "llvm/Support/DataTypes.h"
+#include "llvm/Bitcode/SerializationFwd.h"
#include <cassert>
#include <string>
const APInt &RHS, uint32_t rhsWords,
APInt *Quotient, APInt *Remainder);
-#ifndef NDEBUG
- /// @brief debug method
- void dump() const;
-#endif
-
public:
/// @name Constructors
/// @{
/// @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
/// @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
/// 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);
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
static void tcSetLeastSignificantBits(integerPart *, unsigned int,
unsigned int bits);
+ /// @brief debug method
+ void dump() const;
+
/// @}
};