16 #ifndef LLVM_CLANG_BASIC_FIXEDPOINT_H 17 #define LLVM_CLANG_BASIC_FIXEDPOINT_H 19 #include "llvm/ADT/APSInt.h" 20 #include "llvm/ADT/SmallString.h" 21 #include "llvm/Support/raw_ostream.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;
82 bool HasUnsignedPadding;
98 : Val(Val, !Sema.
isSigned()), Sema(Sema) {
99 assert(Val.getBitWidth() == Sema.
getWidth() &&
100 "The value should have a bit width that matches the Sema width");
110 llvm::APSInt
getValue()
const {
return llvm::APSInt(Val, !
Sema.isSigned()); }
124 bool *Overflow =
nullptr)
const;
147 if (Val < 0 && Val != -Val)
161 llvm::APSInt convertToInt(
unsigned DstWidth,
bool DstSign,
162 bool *Overflow =
nullptr)
const;
197 bool *Overflow =
nullptr);
bool getBoolValue() const
llvm::APSInt getValue() const
Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion...
The fixed point semantics work similarly to llvm::fltSemantics.
unsigned getScale() const
const DiagnosticBuilder & operator<<(const DiagnosticBuilder &DB, const Attr *At)
unsigned getWidth() const
bool operator!=(const APFixedPoint &Other) const
llvm::APSInt getIntPart() const
Return the integral part of this fixed point number, rounded towards zero.
void setSaturated(bool Saturated)
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
unsigned getIntegralBits() const
Return the number of integral bits represented by these semantics.
bool operator>(const APFixedPoint &Other) const
unsigned getScale() const
std::string toString() const
The APFixedPoint class works similarly to APInt/APSInt in that it is a functional replacement for a s...
Sema - This implements semantic analysis and AST building for C.
static bool compare(const PathDiagnostic &X, const PathDiagnostic &Y)
APFixedPoint(const FixedPointSemantics &Sema)
APFixedPoint shl(unsigned Amt) const
bool operator<(const APFixedPoint &Other) const
APFixedPoint(uint64_t Val, const FixedPointSemantics &Sema)
bool hasUnsignedPadding() const
FixedPointSemantics getCommonSemantics(const FixedPointSemantics &Other) const
Return the FixedPointSemantics that allows for calculating the full precision semantic that can preci...
bool operator<=(const APFixedPoint &Other) const
void toString(llvm::SmallVectorImpl< char > &Str) const
FixedPointSemantics getSemantics() const
FixedPointSemantics(unsigned Width, unsigned Scale, bool IsSigned, bool IsSaturated, bool HasUnsignedPadding)
bool operator==(const APFixedPoint &Other) const
Dataflow Directional Tag Classes.
APFixedPoint shr(unsigned Amt) const
static FixedPointSemantics GetIntegerSemantics(unsigned Width, bool IsSigned)
Return the FixedPointSemantics for an integer type.
unsigned getWidth() const
APFixedPoint(const llvm::APInt &Val, const FixedPointSemantics &Sema)
bool operator>=(const APFixedPoint &Other) const