13#ifndef LLVM_CLANG_AST_INTERP_FLOATING_H
14#define LLVM_CLANG_AST_INTERP_FLOATING_H
18#include "llvm/ADT/APFloat.h"
38 return Floating(APFloat::getInf(Sem));
52 return F.convertToInteger(
Result, llvm::APFloat::rmTowardZero, &IsExact);
56 llvm::RoundingMode RM)
const {
59 Copy.convert(*Sem, RM, &LosesInfo);
70 return APSInt(F.bitcastToAPInt());
73 void print(llvm::raw_ostream &OS)
const {
81 llvm::raw_string_ostream OS(NameStr);
86 unsigned bitWidth()
const {
return F.semanticsSizeInBits(F.getSemantics()); }
91 bool isZero()
const {
return F.isZero(); }
93 bool isMin()
const {
return F.isSmallest(); }
94 bool isMinusOne()
const {
return F.isExactlyValue(-1.0); }
95 bool isNan()
const {
return F.isNaN(); }
97 bool isInf()
const {
return F.isInfinity(); }
101 llvm::FPClassTest
classify()
const {
return F.classify(); }
102 APFloat::fltCategory
getCategory()
const {
return F.getCategory(); }
105 llvm::APFloatBase::cmpResult CmpRes = F.compare(RHS.F);
107 case llvm::APFloatBase::cmpLessThan:
109 case llvm::APFloatBase::cmpEqual:
111 case llvm::APFloatBase::cmpGreaterThan:
113 case llvm::APFloatBase::cmpUnordered:
116 llvm_unreachable(
"Inavlid cmpResult value");
120 const llvm::fltSemantics &Sem,
121 llvm::RoundingMode RM,
124 APFloat::opStatus Status = F.convertFromAPInt(Val, Val.isSigned(), RM);
130 const llvm::fltSemantics &Sem) {
131 size_t Size = APFloat::semanticsSizeInBits(Sem);
132 llvm::APInt API(Size,
true);
133 llvm::LoadIntFromMemory(API, (
const uint8_t *)Buff, Size / 8);
140 return sizeof(llvm::fltSemantics *) +
141 (APFloat::semanticsSizeInBits(F.getSemantics()) / 8);
146 *
reinterpret_cast<const llvm::fltSemantics **
>(Buff) = &F.getSemantics();
148 llvm::APInt API = F.bitcastToAPInt();
149 llvm::StoreIntToMemory(API, (uint8_t *)(Buff +
sizeof(
void *)),
154 const llvm::fltSemantics *Sem;
155 std::memcpy((
void *)&Sem, Buff,
sizeof(
void *));
169 llvm::RoundingMode RM,
Floating *R) {
171 return R->F.add(B.F, RM);
176 APFloat One(A.F.getSemantics(), 1);
178 return R->F.add(One, RM);
182 llvm::RoundingMode RM,
Floating *R) {
184 return R->F.subtract(B.F, RM);
189 APFloat One(A.F.getSemantics(), 1);
191 return R->F.subtract(One, RM);
195 llvm::RoundingMode RM,
Floating *R) {
197 return R->F.multiply(B.F, RM);
201 llvm::RoundingMode RM,
Floating *R) {
203 return R->F.divide(B.F, RM);
212llvm::raw_ostream &
operator<<(llvm::raw_ostream &OS, Floating F);
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
bool operator<(Floating RHS) const
static APFloat::opStatus div(const Floating &A, const Floating &B, llvm::RoundingMode RM, Floating *R)
Floating operator-() const
static Floating bitcastFromMemory(const std::byte *Buff, const llvm::fltSemantics &Sem)
void print(llvm::raw_ostream &OS) const
APSInt toAPSInt(unsigned NumBits=0) const
static Floating deserialize(const std::byte *Buff)
void serialize(std::byte *Buff) const
static APFloat::opStatus sub(const Floating &A, const Floating &B, llvm::RoundingMode RM, Floating *R)
const APFloat & getAPFloat() const
llvm::FPClassTest classify() const
Floating toSemantics(const Floating &Other, llvm::RoundingMode RM) const
Convert this Floating to one with the same semantics as \Other.
bool operator>(Floating RHS) const
Floating()
Zero-initializes a Floating.
unsigned bitWidth() const
ComparisonCategoryResult compare(const Floating &RHS) const
static APFloat::opStatus increment(const Floating &A, llvm::RoundingMode RM, Floating *R)
bool operator>=(Floating RHS) const
bool operator<=(Floating RHS) const
static APFloat::opStatus fromIntegral(APSInt Val, const llvm::fltSemantics &Sem, llvm::RoundingMode RM, Floating &Result)
Floating toSemantics(const llvm::fltSemantics *Sem, llvm::RoundingMode RM) const
size_t bytesToSerialize() const
static APFloat::opStatus add(const Floating &A, const Floating &B, llvm::RoundingMode RM, Floating *R)
static APFloat::opStatus mul(const Floating &A, const Floating &B, llvm::RoundingMode RM, Floating *R)
std::string toDiagnosticString(const ASTContext &Ctx) const
bool operator!=(Floating RHS) const
static Floating getInf(const llvm::fltSemantics &Sem)
bool operator==(Floating RHS) const
static bool neg(const Floating &A, Floating *R)
static APFloat::opStatus decrement(const Floating &A, llvm::RoundingMode RM, Floating *R)
Floating(const APFloat &F)
static Floating abs(const Floating &F)
APFloat::opStatus convertToInteger(APSInt &Result) const
APValue toAPValue(const ASTContext &) const
APFloat::fltCategory getCategory() const
Floating getSwappedBytes(Floating F)
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const Boolean &B)
The JSON file list parser is used to communicate input to InstallAPI.
ComparisonCategoryResult
An enumeration representing the possible results of a three-way comparison.
@ Result
The result type of a method or function.
@ Other
Other implicit parameter.