LLVM  3.7.0
Macros | Functions
APInt.cpp File Reference
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringRef.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 <cstdlib>
#include <cstring>
#include <limits>
Include dependency graph for APInt.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "apint"
 

Functions

static uint64_t * getClearedMemory (unsigned numWords)
 A utility function for allocating memory, checking for allocation failures, and ensuring the contents are zeroed. More...
 
static uint64_t * getMemory (unsigned numWords)
 A utility function for allocating memory and checking for allocation failure. More...
 
static unsigned getDigit (char cdigit, uint8_t radix)
 A utility function that converts a character to a digit. More...
 
static bool add_1 (uint64_t dest[], uint64_t x[], unsigned len, uint64_t y)
 This function adds a single "digit" integer, y, to the multiple "digit" integer array, x[]. More...
 
static bool sub_1 (uint64_t x[], unsigned len, uint64_t y)
 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. More...
 
static bool add (uint64_t *dest, const uint64_t *x, const uint64_t *y, unsigned len)
 This function adds the integer array x to the integer array Y and places the result in dest. More...
 
static bool sub (uint64_t *dest, const uint64_t *x, const uint64_t *y, unsigned len)
 Subtracts the integer array y from the integer array x. More...
 
static uint64_t mul_1 (uint64_t dest[], uint64_t x[], unsigned len, uint64_t y)
 Multiplies an integer array, x, by a uint64_t integer and places the result into dest. More...
 
static void mul (uint64_t dest[], uint64_t x[], unsigned xlen, uint64_t y[], unsigned ylen)
 Multiplies integer array x by integer array y and stores the result into the integer array dest. More...
 
static void lshrNear (uint64_t *Dst, uint64_t *Src, unsigned Words, unsigned Shift)
 Perform a logical right-shift from Src to Dst, which must be equal or non-overlapping, of Words words, by Shift, which must be less than 64. More...
 
static void KnuthDiv (unsigned *u, unsigned *v, unsigned *q, unsigned *r, unsigned m, unsigned n)
 Implementation of Knuth's Algorithm D (Division of nonnegative integers) from "Art of Computer Programming, Volume 2", section 4.3.1, p. More...
 

Macro Definition Documentation

#define DEBUG_TYPE   "apint"

Definition at line 30 of file APInt.cpp.

Function Documentation

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

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 General addition of 64-bit integer arrays

Definition at line 238 of file APInt.cpp.

References fuzzer::min().

Referenced by DecodeAddrModeImm12Operand(), DecodePostIdxReg(), DecodeT2LoadImm8(), llvm::APInt::operator+(), and llvm::APInt::operator+=().

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

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 183 of file APInt.cpp.

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

static uint64_t* getClearedMemory ( unsigned  numWords)
inlinestatic

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

Definition at line 34 of file APInt.cpp.

static unsigned getDigit ( char  cdigit,
uint8_t  radix 
)
inlinestatic

A utility function that converts a character to a digit.

Definition at line 50 of file APInt.cpp.

static uint64_t* getMemory ( unsigned  numWords)
inlinestatic

A utility function for allocating memory and checking for allocation failure.

The content is not zeroed.

Definition at line 43 of file APInt.cpp.

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

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.

  1. The variables here have the same names as in the algorithm. Comments explain the algorithm and any deviation from it.

Definition at line 1509 of file APInt.cpp.

References llvm::countLeadingZeros(), llvm::dbgs(), DEBUG, LLVM_CONSTEXPR, and fuzzer::min().

static void lshrNear ( uint64_t *  Dst,
uint64_t *  Src,
unsigned  Words,
unsigned  Shift 
)
static

Perform a logical right-shift from Src to Dst, which must be equal or non-overlapping, of Words words, by Shift, which must be less than 64.

Definition at line 780 of file APInt.cpp.

References I.

Referenced by llvm::APInt::byteSwap(), and llvm::APInt::lshr().

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

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. Generalized multiplicate of integer arrays.

Definition at line 326 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

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

Returns
the carry out of the multiplication. Multiply a multi-digit APInt by a single digit (64-bit) integer.

Definition at line 292 of file APInt.cpp.

Referenced by mul().

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

Subtracts the integer array y from the integer array x.

Returns
returns the borrow out. Generalized subtraction of 64-bit integer arrays.

Definition at line 265 of file APInt.cpp.

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

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

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 211 of file APInt.cpp.

References X.

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