class APFixedPoint

Declaration

class APFixedPoint { /* full declaration omitted */ };

Description

The APFixedPoint class works similarly to APInt/APSInt in that it is a functional replacement for a scaled integer. It is meant to replicate the fixed point types proposed in ISO/IEC JTC1 SC22 WG14 N1169. The class carries info about the fixed point type's width, sign, scale, and saturation, and provides different operations that would normally be performed on fixed point types.

Declared at: llvm/include/llvm/ADT/APFixedPoint.h:100

Member Variables

private llvm::APSInt Val
private llvm::FixedPointSemantics Sema

Method Overview

  • public APFixedPoint(uint64_t Val, const llvm::FixedPointSemantics & Sema)
  • public APFixedPoint(const llvm::FixedPointSemantics & Sema)
  • public APFixedPoint(const llvm::APInt & Val, const llvm::FixedPointSemantics & Sema)
  • public llvm::APFixedPoint add(const llvm::APFixedPoint & Other, bool * Overflow = nullptr) const
  • public int compare(const llvm::APFixedPoint & Other) const
  • public llvm::APFixedPoint convert(const llvm::FixedPointSemantics & DstSema, bool * Overflow = nullptr) const
  • public llvm::APFloat convertToFloat(const llvm::fltSemantics & FloatSema) const
  • public llvm::APSInt convertToInt(unsigned int DstWidth, bool DstSign, bool * Overflow = nullptr) const
  • public llvm::APFixedPoint div(const llvm::APFixedPoint & Other, bool * Overflow = nullptr) const
  • public bool getBoolValue() const
  • public static llvm::APFixedPoint getFromFloatValue(const llvm::APFloat & Value, const llvm::FixedPointSemantics & DstFXSema, bool * Overflow = nullptr)
  • public static llvm::APFixedPoint getFromIntValue(const llvm::APSInt & Value, const llvm::FixedPointSemantics & DstFXSema, bool * Overflow = nullptr)
  • public llvm::APSInt getIntPart() const
  • public static llvm::APFixedPoint getMax(const llvm::FixedPointSemantics & Sema)
  • public static llvm::APFixedPoint getMin(const llvm::FixedPointSemantics & Sema)
  • public inline unsigned int getScale() const
  • public llvm::FixedPointSemantics getSemantics() const
  • public llvm::APSInt getValue() const
  • public inline unsigned int getWidth() const
  • public inline bool hasPadding() const
  • public inline bool isSaturated() const
  • public inline bool isSigned() const
  • public llvm::APFixedPoint mul(const llvm::APFixedPoint & Other, bool * Overflow = nullptr) const
  • public llvm::APFixedPoint negate(bool * Overflow = nullptr) const
  • public static const llvm::fltSemantics * promoteFloatSemantics(const llvm::fltSemantics * S)
  • public llvm::APFixedPoint shl(unsigned int Amt, bool * Overflow = nullptr) const
  • public llvm::APFixedPoint shr(unsigned int Amt, bool * Overflow = nullptr) const
  • public llvm::APFixedPoint sub(const llvm::APFixedPoint & Other, bool * Overflow = nullptr) const
  • public void toString(SmallVectorImpl<char> & Str) const
  • public std::string toString() const

Methods

APFixedPoint(
    uint64_t Val,
    const llvm::FixedPointSemantics& Sema)

Declared at: llvm/include/llvm/ADT/APFixedPoint.h:108

Parameters

uint64_t Val
const llvm::FixedPointSemantics& Sema

APFixedPoint(
    const llvm::FixedPointSemantics& Sema)

Declared at: llvm/include/llvm/ADT/APFixedPoint.h:112

Parameters

const llvm::FixedPointSemantics& Sema

APFixedPoint(
    const llvm::APInt& Val,
    const llvm::FixedPointSemantics& Sema)

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

Parameters

const llvm::APInt& Val
const llvm::FixedPointSemantics& Sema

llvm::APFixedPoint add(
    const llvm::APFixedPoint& Other,
    bool* Overflow = nullptr) const

Declared at: llvm/include/llvm/ADT/APFixedPoint.h:134

Parameters

const llvm::APFixedPoint& Other
bool* Overflow = nullptr

int compare(const llvm::APFixedPoint& Other) const

Declared at: llvm/include/llvm/ADT/APFixedPoint.h:183

Parameters

const llvm::APFixedPoint& Other

llvm::APFixedPoint convert(
    const llvm::FixedPointSemantics& DstSema,
    bool* Overflow = nullptr) const

Declared at: llvm/include/llvm/ADT/APFixedPoint.h:127

Parameters

const llvm::FixedPointSemantics& DstSema
bool* Overflow = nullptr

llvm::APFloat convertToFloat(
    const llvm::fltSemantics& FloatSema) const

Description

Convert this fixed point number to a floating point value with the provided semantics.

Declared at: llvm/include/llvm/ADT/APFixedPoint.h:173

Parameters

const llvm::fltSemantics& FloatSema

llvm::APSInt convertToInt(
    unsigned int DstWidth,
    bool DstSign,
    bool* Overflow = nullptr) const

Description

Return the integral part of this fixed point number, rounded towards zero. The value is stored into an APSInt with the provided width and sign. If the overflow parameter is provided, and the integral value is not able to be fully stored in the provided width and sign, the overflow parameter is set to true.

Declared at: llvm/include/llvm/ADT/APFixedPoint.h:168

Parameters

unsigned int DstWidth
bool DstSign
bool* Overflow = nullptr

llvm::APFixedPoint div(
    const llvm::APFixedPoint& Other,
    bool* Overflow = nullptr) const

Declared at: llvm/include/llvm/ADT/APFixedPoint.h:137

Parameters

const llvm::APFixedPoint& Other
bool* Overflow = nullptr

bool getBoolValue() const

Declared at: llvm/include/llvm/ADT/APFixedPoint.h:122

static llvm::APFixedPoint getFromFloatValue(
    const llvm::APFloat& Value,
    const llvm::FixedPointSemantics& DstFXSema,
    bool* Overflow = nullptr)

Description

Create an APFixedPoint with a value equal to that of the provided floating point value, in the provided target semantics. If the value is not able to fit in the specified fixed point semantics and the overflow parameter is specified, it is set to true. For NaN, the Overflow flag is always set. For +inf and -inf, if the semantic is saturating, the value saturates. Otherwise, the Overflow flag is set.

Declared at: llvm/include/llvm/ADT/APFixedPoint.h:221

Parameters

const llvm::APFloat& Value
const llvm::FixedPointSemantics& DstFXSema
bool* Overflow = nullptr

static llvm::APFixedPoint getFromIntValue(
    const llvm::APSInt& Value,
    const llvm::FixedPointSemantics& DstFXSema,
    bool* Overflow = nullptr)

Description

Create an APFixedPoint with a value equal to that of the provided integer, and in the same semantics as the provided target semantics. If the value is not able to fit in the specified fixed point semantics, and the overflow parameter is provided, it is set to true.

Declared at: llvm/include/llvm/ADT/APFixedPoint.h:210

Parameters

const llvm::APSInt& Value
const llvm::FixedPointSemantics& DstFXSema
bool* Overflow = nullptr

llvm::APSInt getIntPart() const

Description

Return the integral part of this fixed point number, rounded towards zero. (-2.5k -> -2)

Declared at: llvm/include/llvm/ADT/APFixedPoint.h:156

static llvm::APFixedPoint getMax(
    const llvm::FixedPointSemantics& Sema)

Declared at: llvm/include/llvm/ADT/APFixedPoint.h:199

Parameters

const llvm::FixedPointSemantics& Sema

static llvm::APFixedPoint getMin(
    const llvm::FixedPointSemantics& Sema)

Declared at: llvm/include/llvm/ADT/APFixedPoint.h:200

Parameters

const llvm::FixedPointSemantics& Sema

inline unsigned int getScale() const

Declared at: llvm/include/llvm/ADT/APFixedPoint.h:116

llvm::FixedPointSemantics getSemantics() const

Declared at: llvm/include/llvm/ADT/APFixedPoint.h:120

llvm::APSInt getValue() const

Declared at: llvm/include/llvm/ADT/APFixedPoint.h:114

inline unsigned int getWidth() const

Declared at: llvm/include/llvm/ADT/APFixedPoint.h:115

inline bool hasPadding() const

Declared at: llvm/include/llvm/ADT/APFixedPoint.h:119

inline bool isSaturated() const

Declared at: llvm/include/llvm/ADT/APFixedPoint.h:117

inline bool isSigned() const

Declared at: llvm/include/llvm/ADT/APFixedPoint.h:118

llvm::APFixedPoint mul(
    const llvm::APFixedPoint& Other,
    bool* Overflow = nullptr) const

Declared at: llvm/include/llvm/ADT/APFixedPoint.h:136

Parameters

const llvm::APFixedPoint& Other
bool* Overflow = nullptr

llvm::APFixedPoint negate(
    bool* Overflow = nullptr) const

Description

Perform a unary negation (-X) on this fixed point type, taking into account saturation if applicable.

Declared at: llvm/include/llvm/ADT/APFixedPoint.h:152

Parameters

bool* Overflow = nullptr

static const llvm::fltSemantics*
promoteFloatSemantics(const llvm::fltSemantics* S)

Description

Given a floating point semantic, return the next floating point semantic with a larger exponent and larger or equal mantissa.

Declared at: llvm/include/llvm/ADT/APFixedPoint.h:204

Parameters

const llvm::fltSemantics* S

llvm::APFixedPoint shl(
    unsigned int Amt,
    bool* Overflow = nullptr) const

Declared at: llvm/include/llvm/ADT/APFixedPoint.h:142

Parameters

unsigned int Amt
bool* Overflow = nullptr

llvm::APFixedPoint shr(
    unsigned int Amt,
    bool* Overflow = nullptr) const

Declared at: llvm/include/llvm/ADT/APFixedPoint.h:143

Parameters

unsigned int Amt
bool* Overflow = nullptr

llvm::APFixedPoint sub(
    const llvm::APFixedPoint& Other,
    bool* Overflow = nullptr) const

Declared at: llvm/include/llvm/ADT/APFixedPoint.h:135

Parameters

const llvm::APFixedPoint& Other
bool* Overflow = nullptr

void toString(SmallVectorImpl<char>& Str) const

Declared at: llvm/include/llvm/ADT/APFixedPoint.h:175

Parameters

SmallVectorImpl<char>& Str

std::string toString() const

Declared at: llvm/include/llvm/ADT/APFixedPoint.h:176