class APSInt

Declaration

class APSInt : public APInt { /* full declaration omitted */ };

Description

Class for arbitrary precision integers. APInt is a functional replacement for common case unsigned integer type like "unsigned", "unsigned long" or "uint64_t", but also allows non-byte-width integer sizes and large integer value types such as 3-bits, 15-bits, or more than 64-bits of precision. APInt provides a variety of arithmetic operators and methods to manipulate integer values of any bit-width. It supports both the typical integer arithmetic and comparison operations as well as bitwise manipulation. The class has several invariants worth noting: * All bit, byte, and word positions are zero-based. * Once the bit width is set, it doesn't change except by the Truncate, SignExtend, or ZeroExtend operations. * All binary operators must be on APInt instances of the same bit width. Attempting to use these operators on instances with different bit widths will yield an assertion. * The value is stored canonically as an unsigned value. For operations where it makes a difference, there are both signed and unsigned variants of the operation. For example, sdiv and udiv. However, because the bit widths must be the same, operations such as Mul and Add produce the same results regardless of whether the values are interpreted as signed or not. * In general, the class tries to follow the style of computation that LLVM uses in its IR. This simplifies its use for LLVM.

Declared at: llvm/include/llvm/ADT/APSInt.h:21

Inherits from: APInt

Member Variables

Inherited from APInt:

public static WORDTYPE_MAX = ~unsigned long(0)

Method Overview

  • public APSInt(uint32_t BitWidth, bool isUnsigned = true)
  • public APSInt(llvm::APInt I, bool isUnsigned = true)
  • public APSInt(llvm::StringRef Str)
  • public APSInt()
  • public void Profile(llvm::FoldingSetNodeID & ID) const
  • public static int compareValues(const llvm::APSInt & I1, const llvm::APSInt & I2)
  • public llvm::APSInt extOrTrunc(uint32_t width) const
  • public llvm::APSInt extend(uint32_t width) const
  • public static llvm::APSInt get(int64_t X)
  • public int64_t getExtValue() const
  • public static llvm::APSInt getMaxValue(uint32_t numBits, bool Unsigned)
  • public static llvm::APSInt getMinValue(uint32_t numBits, bool Unsigned)
  • public static llvm::APSInt getUnsigned(uint64_t X)
  • public bool isNegative() const
  • public bool isNonNegative() const
  • public static bool isSameValue(const llvm::APSInt & I1, const llvm::APSInt & I2)
  • public bool isSigned() const
  • public bool isStrictlyPositive() const
  • public bool isUnsigned() const
  • public void setIsSigned(bool Val)
  • public void setIsUnsigned(bool Val)
  • public std::string toString(unsigned int Radix) const
  • public void toString(SmallVectorImpl<char> & Str, unsigned int Radix = 10) const
  • public llvm::APSInt trunc(uint32_t width) const

Inherited from APInt:

Methods

APSInt(uint32_t BitWidth, bool isUnsigned = true)

Description

APSInt ctor - Create an APSInt with the specified width, default to unsigned.

Declared at: llvm/include/llvm/ADT/APSInt.h:30

Parameters

uint32_t BitWidth
bool isUnsigned = true

APSInt(llvm::APInt I, bool isUnsigned = true)

Declared at: llvm/include/llvm/ADT/APSInt.h:33

Parameters

llvm::APInt I
bool isUnsigned = true

APSInt(llvm::StringRef Str)

Description

Construct an APSInt from a string representation. This constructor interprets the string \p Str using the radix of 10. The interpretation stops at the end of the string. The bit width of the constructed APSInt is determined automatically.

Declared at: llvm/include/llvm/ADT/APSInt.h:43

Parameters

llvm::StringRef Str
the string to be interpreted.

APSInt()

Description

Default constructor that creates an uninitialized APInt.

Declared at: llvm/include/llvm/ADT/APSInt.h:26

void Profile(llvm::FoldingSetNodeID& ID) const

Description

Profile - Used to insert APSInt objects, or objects that contain APSInt objects, into FoldingSets.

Declared at: llvm/include/llvm/ADT/APSInt.h:336

Parameters

llvm::FoldingSetNodeID& ID

static int compareValues(const llvm::APSInt& I1,
                         const llvm::APSInt& I2)

Description

Compare underlying values of two numbers.

Declared at: llvm/include/llvm/ADT/APSInt.h:306

Parameters

const llvm::APSInt& I1
const llvm::APSInt& I2

llvm::APSInt extOrTrunc(uint32_t width) const

Declared at: llvm/include/llvm/ADT/APSInt.h:109

Parameters

uint32_t width

llvm::APSInt extend(uint32_t width) const

Declared at: llvm/include/llvm/ADT/APSInt.h:102

Parameters

uint32_t width

static llvm::APSInt get(int64_t X)

Declared at: llvm/include/llvm/ADT/APSInt.h:331

Parameters

int64_t X

int64_t getExtValue() const

Description

Get the correctly-extended \c int64_t value.

Declared at: llvm/include/llvm/ADT/APSInt.h:93

static llvm::APSInt getMaxValue(uint32_t numBits,
                                bool Unsigned)

Description

getMaxValue - Return the APSInt representing the maximum integer value with the given bit width and signedness.

Declared at: llvm/include/llvm/ADT/APSInt.h:287

Parameters

uint32_t numBits
bool Unsigned

static llvm::APSInt getMinValue(uint32_t numBits,
                                bool Unsigned)

Description

getMinValue - Return the APSInt representing the minimum integer value with the given bit width and signedness.

Declared at: llvm/include/llvm/ADT/APSInt.h:294

Parameters

uint32_t numBits
bool Unsigned

static llvm::APSInt getUnsigned(uint64_t X)

Declared at: llvm/include/llvm/ADT/APSInt.h:332

Parameters

uint64_t X

bool isNegative() const

Description

Determine sign of this APSInt.

Declared at: llvm/include/llvm/ADT/APSInt.h:48

Returns

true if this APSInt is negative, false otherwise

bool isNonNegative() const

Description

Determine if this APSInt Value is non-negative (>= 0)

Declared at: llvm/include/llvm/ADT/APSInt.h:53

Returns

true if this APSInt is non-negative, false otherwise

static bool isSameValue(const llvm::APSInt& I1,
                        const llvm::APSInt& I2)

Description

Determine if two APSInts have the same value, zero- or sign-extending as needed.

Declared at: llvm/include/llvm/ADT/APSInt.h:301

Parameters

const llvm::APSInt& I1
const llvm::APSInt& I2

bool isSigned() const

Declared at: llvm/include/llvm/ADT/APSInt.h:76

bool isStrictlyPositive() const

Description

Determine if this APSInt Value is positive. This tests if the value of this APSInt is positive (> 0). Note that 0 is not a positive value.

Declared at: llvm/include/llvm/ADT/APSInt.h:61

Returns

true if this APSInt is positive.

bool isUnsigned() const

Declared at: llvm/include/llvm/ADT/APSInt.h:77

void setIsSigned(bool Val)

Declared at: llvm/include/llvm/ADT/APSInt.h:79

Parameters

bool Val

void setIsUnsigned(bool Val)

Declared at: llvm/include/llvm/ADT/APSInt.h:78

Parameters

bool Val

std::string toString(unsigned int Radix) const

Description

toString - Converts an APInt to a std::string. This is an inefficient method; you should prefer passing in a SmallString instead.

Declared at: llvm/include/llvm/ADT/APSInt.h:87

Parameters

unsigned int Radix

void toString(SmallVectorImpl<char>& Str,
              unsigned int Radix = 10) const

Description

toString - Append this APSInt to the specified SmallString.

Declared at: llvm/include/llvm/ADT/APSInt.h:82

Parameters

SmallVectorImpl<char>& Str
unsigned int Radix = 10

llvm::APSInt trunc(uint32_t width) const

Declared at: llvm/include/llvm/ADT/APSInt.h:98

Parameters

uint32_t width