LLVM  14.0.0git
Macros | Functions
APInt.cpp File Reference
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/bit.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include <climits>
#include <cmath>
#include <cstdlib>
#include <cstring>
Include dependency graph for APInt.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "apint"
 
#define DEBUG_KNUTH(X)   do {} while(false)
 

Functions

static uint64_tgetClearedMemory (unsigned numWords)
 A utility function for allocating memory, checking for allocation failures, and ensuring the contents are zeroed. More...
 
static uint64_tgetMemory (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 void tcComplement (APInt::WordType *dst, unsigned parts)
 
static unsigned rotateModulo (unsigned BitWidth, const APInt &rotateAmt)
 
static void KnuthDiv (uint32_t *u, uint32_t *v, uint32_t *q, uint32_t *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...
 
static APInt::WordType lowBitMask (unsigned bits)
 
static APInt::WordType lowHalf (APInt::WordType part)
 Returns the value of the lower half of PART. More...
 
static APInt::WordType highHalf (APInt::WordType part)
 Returns the value of the upper half of PART. More...
 
static unsigned partMSB (APInt::WordType value)
 Returns the bit number of the most significant set bit of a part. More...
 
static unsigned partLSB (APInt::WordType value)
 Returns the bit number of the least significant set bit of a part. More...
 

Macro Definition Documentation

◆ DEBUG_KNUTH

#define DEBUG_KNUTH (   X)    do {} while(false)

◆ DEBUG_TYPE

#define DEBUG_TYPE   "apint"

Definition at line 33 of file APInt.cpp.

Function Documentation

◆ getClearedMemory()

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

References result.

◆ getDigit()

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.

◆ getMemory()

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

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

◆ highHalf()

static APInt::WordType highHalf ( APInt::WordType  part)
inlinestatic

Returns the value of the upper half of PART.

Definition at line 2280 of file APInt.cpp.

References llvm::APInt::APINT_BITS_PER_WORD.

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

◆ KnuthDiv()

static void KnuthDiv ( uint32_t u,
uint32_t v,
uint32_t q,
uint32_t 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 1280 of file APInt.cpp.

References assert(), b, llvm::countLeadingZeros(), llvm::dbgs(), DEBUG_KNUTH, llvm::Hi_32(), i, j(), llvm::Lo_32(), llvm::Make_64(), llvm::min(), n, p, and shift.

◆ lowBitMask()

static APInt::WordType lowBitMask ( unsigned  bits)
inlinestatic

Definition at line 2269 of file APInt.cpp.

References llvm::APInt::APINT_BITS_PER_WORD, assert(), and bits.

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

◆ lowHalf()

static APInt::WordType lowHalf ( APInt::WordType  part)
inlinestatic

Returns the value of the lower half of PART.

Definition at line 2275 of file APInt.cpp.

References llvm::APInt::APINT_BITS_PER_WORD, and lowBitMask().

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

◆ partLSB()

static unsigned partLSB ( APInt::WordType  value)
static

Returns the bit number of the least significant set bit of a part.

If the input number has no bits set -1U is returned.

Definition at line 2292 of file APInt.cpp.

References llvm::findFirstSet(), and llvm::ZB_Max.

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

◆ partMSB()

static unsigned partMSB ( APInt::WordType  value)
static

Returns the bit number of the most significant set bit of a part.

If the input number has no bits set -1U is returned.

Definition at line 2286 of file APInt.cpp.

References llvm::findLastSet(), and llvm::ZB_Max.

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

◆ rotateModulo()

static unsigned rotateModulo ( unsigned  BitWidth,
const APInt rotateAmt 
)
static

◆ tcComplement()

static void tcComplement ( APInt::WordType dst,
unsigned  parts 
)
static

Definition at line 331 of file APInt.cpp.

References i.

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