Go to the documentation of this file.
16 #ifndef LLVM_ADT_APFIXEDPOINT_H
17 #define LLVM_ADT_APFIXEDPOINT_H
36 bool IsSaturated,
bool HasUnsignedPadding)
37 : Width(Width), Scale(Scale), IsSigned(IsSigned),
38 IsSaturated(IsSaturated), HasUnsignedPadding(HasUnsignedPadding) {
39 assert(Width >= Scale &&
"Not enough room for the scale");
40 assert(!(IsSigned && HasUnsignedPadding) &&
41 "Cannot have unsigned padding on a signed type.");
56 if (IsSigned || (!IsSigned && HasUnsignedPadding))
57 return Width - Scale - 1;
89 unsigned IsSigned : 1;
90 unsigned IsSaturated : 1;
91 unsigned HasUnsignedPadding : 1;
103 : Val(Val, !Sema.
isSigned()), Sema(Sema) {
105 "The value should have a bit width that matches the Sema width");
128 bool *Overflow =
nullptr)
const;
157 if (Val < 0 && Val != -Val)
169 bool *Overflow =
nullptr)
const;
179 return std::string(
S.str());
212 bool *Overflow =
nullptr);
223 bool *Overflow =
nullptr);
int compare(const APFixedPoint &Other) const
static APFixedPoint getFromFloatValue(const APFloat &Value, const FixedPointSemantics &DstFXSema, bool *Overflow=nullptr)
Create an APFixedPoint with a value equal to that of the provided floating point value,...
This is an optimization pass for GlobalISel generic memory operations.
The APFixedPoint class works similarly to APInt/APSInt in that it is a functional replacement for a s...
APFixedPoint(const FixedPointSemantics &Sema)
bool operator>(const APFixedPoint &Other) const
unsigned getScale() const
unsigned getIntegralBits() const
Return the number of integral bits represented by these semantics.
bool operator!=(const APFixedPoint &Other) const
APFixedPoint negate(bool *Overflow=nullptr) const
Perform a unary negation (-X) on this fixed point type, taking into account saturation if applicable.
unsigned getBitWidth() const
Return the number of bits in the APInt.
APSInt getIntPart() const
Return the integral part of this fixed point number, rounded towards zero.
FixedPointSemantics getCommonSemantics(const FixedPointSemantics &Other) const
Return the FixedPointSemantics that allows for calculating the full precision semantic that can preci...
bool hasUnsignedPadding() const
void setSaturated(bool Saturated)
APFixedPoint shr(unsigned Amt, bool *Overflow=nullptr) const
bool operator<=(const APFixedPoint &Other) const
bool operator>=(const APFixedPoint &Other) const
FixedPointSemantics(unsigned Width, unsigned Scale, bool IsSigned, bool IsSaturated, bool HasUnsignedPadding)
APFixedPoint(uint64_t Val, const FixedPointSemantics &Sema)
unsigned getWidth() const
The fixed point semantics work similarly to fltSemantics.
static APFixedPoint getMax(const FixedPointSemantics &Sema)
An arbitrary precision integer that knows its signedness.
This class implements an extremely fast bulk output stream that can only output to a stream.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
static APFixedPoint getMin(const FixedPointSemantics &Sema)
bool operator<(const APFixedPoint &Other) const
bool getBoolValue() const
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
unsigned getWidth() const
APFixedPoint shl(unsigned Amt, bool *Overflow=nullptr) const
APFixedPoint div(const APFixedPoint &Other, bool *Overflow=nullptr) const
static FixedPointSemantics GetIntegerSemantics(unsigned Width, bool IsSigned)
Return the FixedPointSemantics for an integer type.
APFloat convertToFloat(const fltSemantics &FloatSema) const
Convert this fixed point number to a floating point value with the provided semantics.
FixedPointSemantics getSemantics() const
APSInt convertToInt(unsigned DstWidth, bool DstSign, bool *Overflow=nullptr) const
Return the integral part of this fixed point number, rounded towards zero.
bool getBoolValue() const
Convert APInt to a boolean value.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
APFixedPoint add(const APFixedPoint &Other, bool *Overflow=nullptr) const
Class for arbitrary precision integers.
bool fitsInFloatSemantics(const fltSemantics &FloatSema) const
Returns true if this fixed-point semantic with its value bits interpreted as an integer can fit in th...
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
APFixedPoint(const APInt &Val, const FixedPointSemantics &Sema)
APFixedPoint mul(const APFixedPoint &Other, bool *Overflow=nullptr) const
bool operator==(const APFixedPoint &Other) const
void toString(SmallVectorImpl< char > &Str) const
static const fltSemantics * promoteFloatSemantics(const fltSemantics *S)
Given a floating point semantic, return the next floating point semantic with a larger exponent and l...
std::string toString() const
APFixedPoint convert(const FixedPointSemantics &DstSema, bool *Overflow=nullptr) const
static APFixedPoint getFromIntValue(const APSInt &Value, const FixedPointSemantics &DstFXSema, bool *Overflow=nullptr)
Create an APFixedPoint with a value equal to that of the provided integer, and in the same semantics ...
APFixedPoint sub(const APFixedPoint &Other, bool *Overflow=nullptr) const
LLVM Value Representation.
Optional< std::vector< StOtherPiece > > Other
unsigned getScale() const