9#ifndef LLVM_CLANG_AST_INTERP_FIXED_POINT_H
10#define LLVM_CLANG_AST_INTERP_FIXED_POINT_H
14#include "llvm/ADT/APFixedPoint.h"
42 return FixedPoint(llvm::APFixedPoint::getFromIntValue(I, Sem, Overflow));
44 static FixedPoint from(
const llvm::APFloat &I, llvm::FixedPointSemantics Sem,
46 return FixedPoint(llvm::APFixedPoint::getFromFloatValue(I, Sem, Overflow));
49 operator bool()
const {
return V.getBoolValue(); }
50 void print(llvm::raw_ostream &OS)
const { OS <<
V; }
57 bool isZero()
const {
return V.getValue().isZero(); }
59 bool isPositive()
const {
return V.getValue().isNonNegative(); }
61 return V == llvm::APFixedPoint::getMin(
V.getSemantics());
63 bool isMinusOne()
const {
return V.isSigned() &&
V.getValue() == -1; }
68 bool *Overflow)
const {
71 llvm::FixedPointSemantics
getSemantics()
const {
return V.getSemantics(); }
73 llvm::APFloat
toFloat(
const llvm::fltSemantics *Sem)
const {
74 return V.convertToFloat(*Sem);
77 llvm::APSInt
toInt(
unsigned BitWidth,
bool Signed,
bool *Overflow)
const {
78 return V.convertToInt(BitWidth,
Signed, Overflow);
95 bool Overflow =
false;
102 bool Overflow =
false;
108 bool Overflow =
false;
114 bool Overflow =
false;
120 bool Overflow =
false;
127 unsigned Amt = B.V.getValue().getLimitedValue(OpBits);
134 unsigned Amt = B.V.getValue().getLimitedValue(OpBits);
142 llvm_unreachable(
"Rem doesn't exist for fixed point values");
__device__ __2f16 float c
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 ...
Wrapper around fixed point types.
static bool sub(const FixedPoint A, const FixedPoint B, unsigned Bits, FixedPoint *R)
static bool add(const FixedPoint A, const FixedPoint B, unsigned Bits, FixedPoint *R)
FixedPoint(llvm::APFixedPoint &V)
llvm::FixedPointSemantics getSemantics() const
FixedPoint toSemantics(const llvm::FixedPointSemantics &Sem, bool *Overflow) const
static bool shiftRight(const FixedPoint A, const FixedPoint B, unsigned OpBits, FixedPoint *R)
llvm::APSInt toInt(unsigned BitWidth, bool Signed, bool *Overflow) const
static bool shiftLeft(const FixedPoint A, const FixedPoint B, unsigned OpBits, FixedPoint *R)
llvm::APFloat toFloat(const llvm::fltSemantics *Sem) const
static bool rem(const FixedPoint A, const FixedPoint B, unsigned Bits, FixedPoint *R)
static FixedPoint from(const APSInt &I, llvm::FixedPointSemantics Sem, bool *Overflow)
static bool neg(const FixedPoint &A, FixedPoint *R)
FixedPoint truncate(unsigned BitWidth) const
ComparisonCategoryResult compare(const FixedPoint &Other) const
static bool increment(const FixedPoint &A, FixedPoint *R)
static FixedPoint from(const llvm::APFloat &I, llvm::FixedPointSemantics Sem, bool *Overflow)
static bool bitOr(const FixedPoint A, const FixedPoint B, unsigned Bits, FixedPoint *R)
static bool div(const FixedPoint A, const FixedPoint B, unsigned Bits, FixedPoint *R)
static bool mul(const FixedPoint A, const FixedPoint B, unsigned Bits, FixedPoint *R)
APSInt toAPSInt(unsigned BitWidth=0) const
FixedPoint(APInt V, llvm::FixedPointSemantics Sem)
std::string toDiagnosticString(const ASTContext &Ctx) const
static bool bitAnd(const FixedPoint A, const FixedPoint B, unsigned Bits, FixedPoint *R)
static bool decrement(const FixedPoint &A, FixedPoint *R)
FixedPoint(llvm::APFixedPoint &&V)
static bool bitXor(const FixedPoint A, const FixedPoint B, unsigned Bits, FixedPoint *R)
void print(llvm::raw_ostream &OS) const
static FixedPoint zero(llvm::FixedPointSemantics Sem)
APValue toAPValue(const ASTContext &) const
unsigned bitWidth() const
FixedPoint getSwappedBytes(FixedPoint F)
llvm::FixedPointSemantics FixedPointSemantics
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.
@ Other
Other implicit parameter.
Diagnostic wrappers for TextAPI types for error reporting.