LLVM API Documentation

APInt.cpp File Reference

#include "llvm/ADT/APInt.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include <cmath>
#include <limits>
#include <cstring>
#include <cstdlib>

Include dependency graph for APInt.cpp:

Go to the source code of this file.

Defines

#define DEBUG_TYPE   "apint"
#define rot(x, k)   (((x)<<(k)) | ((x)>>(32-(k))))
#define mix(a, b, c)
#define final(a, b, c)
#define COMPILE_TIME_ASSERT(cond)   extern int CTAssert[(cond) ? 1 : -1]

Functions

static uint64_t * getClearedMemory (unsigned numWords)
static uint64_t * getMemory (unsigned numWords)
static unsigned getDigit (char cdigit, uint8_t radix)
 A utility function that converts a character to a digit.
static bool add_1 (uint64_t dest[], uint64_t x[], unsigned len, uint64_t y)
static bool sub_1 (uint64_t x[], unsigned len, uint64_t y)
static bool add (uint64_t *dest, const uint64_t *x, const uint64_t *y, unsigned len)
 General addition of 64-bit integer arrays.
static bool sub (uint64_t *dest, const uint64_t *x, const uint64_t *y, unsigned len)
 Generalized subtraction of 64-bit integer arrays.
static uint64_t mul_1 (uint64_t dest[], uint64_t x[], unsigned len, uint64_t y)
 Multiply a multi-digit APInt by a single digit (64-bit) integer.
static void mul (uint64_t dest[], uint64_t x[], unsigned xlen, uint64_t y[], unsigned ylen)
 Generalized multiplicate of integer arrays.
static uint32_t hashword (const uint64_t *k64, size_t length)
static uint32_t hashword8 (const uint64_t k64)
static unsigned countLeadingOnes_64 (uint64_t V, unsigned skip)
APInt llvm::APIntOps::GreatestCommonDivisor (const APInt &Val1, const APInt &Val2)
 Compute GCD of two APInt values.
APInt llvm::APIntOps::RoundDoubleToAPInt (double Double, unsigned width)
 Converts the given double value into a APInt.
static void KnuthDiv (unsigned *u, unsigned *v, unsigned *q, unsigned *r, unsigned m, unsigned n)
std::ostream & llvm::operator<< (std::ostream &o, const APInt &I)
 COMPILE_TIME_ASSERT (integerPartWidth%2==0)
static integerPart lowBitMask (unsigned int bits)
static integerPart lowHalf (integerPart part)
static integerPart highHalf (integerPart part)
static unsigned int partMSB (integerPart value)
static unsigned int partLSB (integerPart value)


Define Documentation

#define COMPILE_TIME_ASSERT ( cond   )     extern int CTAssert[(cond) ? 1 : -1]

Definition at line 2217 of file APInt.cpp.

#define DEBUG_TYPE   "apint"

Definition at line 15 of file APInt.cpp.

#define final ( a,
b,
c   ) 

Value:

{ \
    c ^= b; c -= rot(b,14); \
    a ^= c; a -= rot(c,11); \
    b ^= a; b -= rot(a,25); \
    c ^= b; c -= rot(b,16); \
    a ^= c; a -= rot(c,4);  \
    b ^= a; b -= rot(a,14); \
    c ^= b; c -= rot(b,24); \
  }

Definition at line 681 of file APInt.cpp.

#define mix ( a,
b,
c   ) 

Value:

{ \
    a -= c;  a ^= rot(c, 4);  c += b; \
    b -= a;  b ^= rot(a, 6);  a += c; \
    c -= b;  c ^= rot(b, 8);  b += a; \
    a -= c;  a ^= rot(c,16);  c += b; \
    b -= a;  b ^= rot(a,19);  a += c; \
    c -= b;  c ^= rot(b, 4);  b += a; \
  }

Definition at line 670 of file APInt.cpp.

Referenced by hashword().

#define rot ( x,
k   )     (((x)<<(k)) | ((x)>>(32-(k))))

Definition at line 667 of file APInt.cpp.


Function Documentation

static bool add ( uint64_t *  dest,
const uint64_t *  x,
const uint64_t *  y,
unsigned  len 
) [static]

General addition of 64-bit integer arrays.

add - This function adds the integer array x to the integer array Y and places the result in dest.

Returns:
the carry out from the addition

Definition at line 226 of file APInt.cpp.

Referenced by InsertLDR_STR().

static bool add_1 ( uint64_t  dest[],
uint64_t  x[],
unsigned  len,
uint64_t  y 
) [static]

add_1 - This function adds a single "digit" integer, y, to the multiple "digit" integer array, x[]. x[] is modified to reflect the addition and 1 is returned if there is a carry out, otherwise 0 is returned.

Returns:
the carry of the addition.

Definition at line 171 of file APInt.cpp.

Referenced by llvm::APInt::operator++().

COMPILE_TIME_ASSERT ( integerPartWidth%  2 = =0  ) 

static unsigned countLeadingOnes_64 ( uint64_t  V,
unsigned  skip 
) [static]

Definition at line 785 of file APInt.cpp.

Referenced by llvm::APInt::countLeadingOnes().

static uint64_t* getClearedMemory ( unsigned  numWords  )  [inline, static]

A utility function for allocating memory, checking for allocation failures, and ensuring the contents are zeroed.

Definition at line 32 of file APInt.cpp.

References llvm::Intrinsic::memset.

Referenced by llvm::APInt::APInt(), llvm::APInt::trunc(), and llvm::APInt::zext().

static unsigned getDigit ( char  cdigit,
uint8_t  radix 
) [inline, static]

A utility function that converts a character to a digit.

Definition at line 48 of file APInt.cpp.

static uint64_t* getMemory ( unsigned  numWords  )  [inline, static]

A utility function for allocating memory and checking for allocation failure. The content is not zeroed.

Definition at line 41 of file APInt.cpp.

Referenced by llvm::APInt::operator*=(), and llvm::APInt::sext().

static uint32_t hashword ( const uint64_t *  k64,
size_t  length 
) [inline, static]

Definition at line 696 of file APInt.cpp.

References c, and mix.

Referenced by llvm::APInt::getHashValue().

static uint32_t hashword8 ( const uint64_t  k64  )  [inline, static]

Definition at line 732 of file APInt.cpp.

References c.

Referenced by llvm::APInt::getHashValue().

static integerPart @795::highHalf ( integerPart  part  )  [inline, static]

Definition at line 2242 of file APInt.cpp.

References llvm::integerPartWidth.

Referenced by llvm::APInt::tcMultiplyPart().

static void KnuthDiv ( unsigned *  u,
unsigned *  v,
unsigned *  q,
unsigned *  r,
unsigned  m,
unsigned  n 
) [static]

Implementation of Knuth's Algorithm D (Division of nonnegative integers) from "Art of Computer Programming, Volume 2", section 4.3.1, p. 272. The variables here have the same names as in the algorithm. Comments explain the algorithm and any deviation from it.

Definition at line 1572 of file APInt.cpp.

References llvm::CountLeadingZeros_32(), DEBUG, and llvm::errs().

static integerPart @795::lowBitMask ( unsigned int  bits  )  [inline, static]

Definition at line 2226 of file APInt.cpp.

References llvm::integerPartWidth.

Referenced by lowHalf(), and llvm::APInt::tcExtract().

static integerPart @795::lowHalf ( integerPart  part  )  [inline, static]

Definition at line 2235 of file APInt.cpp.

References llvm::integerPartWidth, and lowBitMask().

Referenced by llvm::APInt::tcMultiplyPart().

static void mul ( uint64_t  dest[],
uint64_t  x[],
unsigned  xlen,
uint64_t  y[],
unsigned  ylen 
) [static]

Generalized multiplicate of integer arrays.

Multiplies integer array x by integer array y and stores the result into the integer array dest. Note that dest's size must be >= xlen + ylen.

Definition at line 314 of file APInt.cpp.

References mul_1().

Referenced by llvm::APInt::operator*=().

static uint64_t mul_1 ( uint64_t  dest[],
uint64_t  x[],
unsigned  len,
uint64_t  y 
) [static]

Multiply a multi-digit APInt by a single digit (64-bit) integer.

Multiplies an integer array, x by a a uint64_t integer and places the result into dest.

Returns:
the carry out of the multiplication.

Definition at line 280 of file APInt.cpp.

Referenced by mul().

static unsigned int @795::partLSB ( integerPart  value  )  [static]

Definition at line 2275 of file APInt.cpp.

References llvm::integerPartWidth.

Referenced by llvm::APInt::tcLSB().

static unsigned int @795::partMSB ( integerPart  value  )  [static]

Definition at line 2250 of file APInt.cpp.

References llvm::integerPartWidth.

Referenced by llvm::APInt::tcMSB().

static bool sub ( uint64_t *  dest,
const uint64_t *  x,
const uint64_t *  y,
unsigned  len 
) [static]

Generalized subtraction of 64-bit integer arrays.

Subtracts the integer array y from the integer array x

Returns:
returns the borrow out.

Definition at line 253 of file APInt.cpp.

Referenced by getMemoryOpOffset(), InsertLDR_STR(), llvm::APInt::operator-(), and llvm::APInt::operator-=().

static bool sub_1 ( uint64_t  x[],
unsigned  len,
uint64_t  y 
) [static]

sub_1 - This function subtracts a single "digit" (64-bit word), y, from the multi-digit integer array, x[], propagating the borrowed 1 value until no further borrowing is neeeded or it runs out of "digits" in x. The result is 1 if "borrowing" exhausted the digits in x, or 0 if x was not exhausted. In other words, if y > x then this function returns 1, otherwise 0.

Returns:
the borrow out of the subtraction

Definition at line 199 of file APInt.cpp.

References llvm::X.

Referenced by llvm::APInt::operator--().