The APFixedPoint class works similarly to APInt/APSInt in that it is a functional replacement for a scaled integer. It supports a wide range of semantics including the one used by fixed point types proposed in ISO/IEC JTC1 SC22 WG14 N1169. The class carries the value and semantics of a fixed point, and provides different operations that would normally be performed on fixed point types.

Synopsis

Declared in <llvm/ADT/APFixedPoint.h>

class APFixedPoint;

Member Functions

Name

Description

APFixedPoint [constructor]

Constructors

add

Add Other in common full‐precision semantics.

compare

Compare against Other return 1 if greater, 0 if equal, ‐1 if less.

convert

Convert this number to match the semantics provided.

convertToFloat

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

convertToInt

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.

div

Divide by Other in common full‐precision semantics.

dump

Dump this value to stderr for debugging.

getBoolValue

Return true if the underlying scaled integer is non‐zero.

getIntPart

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

getLsbWeight

Return the LSB weight of this value's semantics.

getMsbWeight

Return the MSB weight of this value's semantics.

getScale

Return the fractional scale of this value's semantics.

getSemantics

Return a copy of this value's fixed‐point semantics.

getValue

Return the underlying scaled integer with matching signedness.

getWidth

Return the bit width of this value's semantics.

hasPadding

Return true if unsigned semantics reserve a padding bit.

isSaturated

Return true if this value's semantics saturate on overflow.

isSigned

Return true if this value uses a signed representation.

mul

Multiply by Other in common full‐precision semantics.

negate

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

print

Write a human‐readable representation to OS.

shl

Left‐shift the scaled integer by Amt bits, keeping these semantics.

shr

Right‐shift the scaled integer by Amt bits, keeping these semantics.

sub

Subtract Other in common full‐precision semantics.

toString

toString overloads

operator==

Return true if this value equals Other.

operator!=

Return true if this value differs from Other.

operator<

Return true if this value is less than Other.

operator<=

Return true if this value is less than or equal to Other.

operator>

Return true if this value is greater than Other.

operator>=

Return true if this value is greater than or equal to Other.

Static Member Functions

Name

Description

getEpsilon

Return the smallest positive quantum (epsilon) for semantics Sema.

getFromFloatValue

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.

getFromIntValue

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.

getMax

Return the maximum representable value for semantics Sema.

getMin

Return the minimum representable value for semantics Sema.

promoteFloatSemantics

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

Non-Member Functions

Name

Description

hash_value

Compute a hash code for fixed‐point value Val.

Created with MrDocs