LLVM  13.0.0git
Public Member Functions | Static Public Member Functions | List of all members
llvm::FixedPointSemantics Class Reference

The fixed point semantics work similarly to fltSemantics. More...

#include "llvm/ADT/APFixedPoint.h"

Public Member Functions

 FixedPointSemantics (unsigned Width, unsigned Scale, bool IsSigned, bool IsSaturated, bool HasUnsignedPadding)
 
unsigned getWidth () const
 
unsigned getScale () const
 
bool isSigned () const
 
bool isSaturated () const
 
bool hasUnsignedPadding () const
 
void setSaturated (bool Saturated)
 
unsigned getIntegralBits () const
 Return the number of integral bits represented by these semantics. More...
 
FixedPointSemantics getCommonSemantics (const FixedPointSemantics &Other) const
 Return the FixedPointSemantics that allows for calculating the full precision semantic that can precisely represent the precision and ranges of both input values. More...
 
bool fitsInFloatSemantics (const fltSemantics &FloatSema) const
 Returns true if this fixed-point semantic with its value bits interpreted as an integer can fit in the given floating point semantic without overflowing to infinity. More...
 

Static Public Member Functions

static FixedPointSemantics GetIntegerSemantics (unsigned Width, bool IsSigned)
 Return the FixedPointSemantics for an integer type. More...
 

Detailed Description

The fixed point semantics work similarly to fltSemantics.

The width specifies the whole bit width of the underlying scaled integer (with padding if any). The scale represents the number of fractional bits in this type. When HasUnsignedPadding is true and this type is unsigned, the first bit in the value this represents is treated as padding.

Definition at line 33 of file APFixedPoint.h.

Constructor & Destructor Documentation

◆ FixedPointSemantics()

llvm::FixedPointSemantics::FixedPointSemantics ( unsigned  Width,
unsigned  Scale,
bool  IsSigned,
bool  IsSaturated,
bool  HasUnsignedPadding 
)
inline

Definition at line 35 of file APFixedPoint.h.

References assert().

Referenced by getCommonSemantics(), and GetIntegerSemantics().

Member Function Documentation

◆ fitsInFloatSemantics()

bool llvm::FixedPointSemantics::fitsInFloatSemantics ( const fltSemantics FloatSema) const

Returns true if this fixed-point semantic with its value bits interpreted as an integer can fit in the given floating point semantic without overflowing to infinity.

For example, a signed 8-bit fixed-point semantic has a maximum and minimum integer representation of 127 and -128, respectively. If both of these values can be represented (possibly inexactly) in the floating point semantic without overflowing, this returns true.

Definition at line 128 of file APFixedPoint.cpp.

References F, llvm::APFixedPoint::getMax(), llvm::APFixedPoint::getMin(), llvm::APFixedPoint::getValue(), isSigned(), llvm::APSInt::isSigned(), llvm::APFloatBase::opOverflow, and llvm::APFloatBase::rmNearestTiesToAway.

Referenced by llvm::APFixedPoint::convertToFloat(), and llvm::APFixedPoint::getFromFloatValue().

◆ getCommonSemantics()

FixedPointSemantics llvm::FixedPointSemantics::getCommonSemantics ( const FixedPointSemantics Other) const

Return the FixedPointSemantics that allows for calculating the full precision semantic that can precisely represent the precision and ranges of both input values.

This does not compute the resulting semantics for a given binary operation.

Definition at line 151 of file APFixedPoint.cpp.

References FixedPointSemantics(), getIntegralBits(), getScale(), hasUnsignedPadding(), isSaturated(), isSigned(), llvm::max(), and Other.

Referenced by llvm::APFixedPoint::add(), llvm::FixedPointBuilder< IRBuilderTy >::CreateAdd(), llvm::FixedPointBuilder< IRBuilderTy >::CreateDiv(), llvm::FixedPointBuilder< IRBuilderTy >::CreateMul(), llvm::FixedPointBuilder< IRBuilderTy >::CreateSub(), llvm::APFixedPoint::div(), llvm::APFixedPoint::mul(), and llvm::APFixedPoint::sub().

◆ GetIntegerSemantics()

static FixedPointSemantics llvm::FixedPointSemantics::GetIntegerSemantics ( unsigned  Width,
bool  IsSigned 
)
inlinestatic

◆ getIntegralBits()

unsigned llvm::FixedPointSemantics::getIntegralBits ( ) const
inline

Return the number of integral bits represented by these semantics.

These are separate from the fractional bits and do not include the sign or padding bit.

Definition at line 55 of file APFixedPoint.h.

Referenced by llvm::APFixedPoint::convert(), and getCommonSemantics().

◆ getScale()

unsigned llvm::FixedPointSemantics::getScale ( ) const
inline

◆ getWidth()

unsigned llvm::FixedPointSemantics::getWidth ( ) const
inline

◆ hasUnsignedPadding()

bool llvm::FixedPointSemantics::hasUnsignedPadding ( ) const
inline

◆ isSaturated()

bool llvm::FixedPointSemantics::isSaturated ( ) const
inline

◆ isSigned()

bool llvm::FixedPointSemantics::isSigned ( ) const
inline

◆ setSaturated()

void llvm::FixedPointSemantics::setSaturated ( bool  Saturated)
inline

Definition at line 50 of file APFixedPoint.h.


The documentation for this class was generated from the following files: