12#ifndef KLEE_FLOATEVALUATION_H
13#define KLEE_FLOATEVALUATION_H
19#include "llvm/Support/ErrorHandling.h"
20#include "llvm/Support/MathExtras.h"
34 assert(
sizeof(bits) ==
sizeof(ret) );
35 memcpy( &ret, &bits,
sizeof bits );
43 assert(
sizeof(tmp) ==
sizeof(ret) );
44 memcpy( &ret, &tmp,
sizeof tmp );
56 assert(
sizeof(d) ==
sizeof(ret) );
57 memcpy( &ret, &d,
sizeof d );
64 assert(
sizeof(tmp) ==
sizeof(f) );
65 memcpy( &tmp, &f,
sizeof f );
84inline uint64_t
add(uint64_t l, uint64_t r,
unsigned inWidth) {
88 default: llvm::report_fatal_error(
"unsupported floating point width");
93inline uint64_t
sub(uint64_t l, uint64_t r,
unsigned inWidth) {
97 default: llvm::report_fatal_error(
"unsupported floating point width");
102inline uint64_t
mul(uint64_t l, uint64_t r,
unsigned inWidth) {
106 default: llvm::report_fatal_error(
"unsupported floating point width");
111inline uint64_t
div(uint64_t l, uint64_t r,
unsigned inWidth) {
115 default: llvm::report_fatal_error(
"unsupported floating point width");
120inline uint64_t
mod(uint64_t l, uint64_t r,
unsigned inWidth) {
124 default: llvm::report_fatal_error(
"unsupported floating point width");
134inline bool isNaN(uint64_t l,
unsigned inWidth) {
140 default: llvm::report_fatal_error(
"unsupported floating point width");
144inline uint64_t
eq(uint64_t l, uint64_t r,
unsigned inWidth) {
148 default: llvm::report_fatal_error(
"unsupported floating point width");
152inline uint64_t
ne(uint64_t l, uint64_t r,
unsigned inWidth) {
156 default: llvm::report_fatal_error(
"unsupported floating point width");
160inline uint64_t
lt(uint64_t l, uint64_t r,
unsigned inWidth) {
164 default: llvm::report_fatal_error(
"unsupported floating point width");
168inline uint64_t
le(uint64_t l, uint64_t r,
unsigned inWidth) {
172 default: llvm::report_fatal_error(
"unsupported floating point width");
176inline uint64_t
gt(uint64_t l, uint64_t r,
unsigned inWidth) {
180 default: llvm::report_fatal_error(
"unsupported floating point width");
184inline uint64_t
ge(uint64_t l, uint64_t r,
unsigned inWidth) {
188 default: llvm::report_fatal_error(
"unsupported floating point width");
198inline uint64_t
trunc(uint64_t l,
unsigned outWidth,
unsigned inWidth) {
201 if (inWidth==64 && outWidth==64) {
204 assert(inWidth==64 &&
"can only truncate from a 64-bit double");
205 assert(outWidth==32 &&
"can only truncate to a 32-bit float");
212inline uint64_t
ext(uint64_t l,
unsigned outWidth,
unsigned inWidth) {
215 if (inWidth==64 && outWidth==64) {
218 assert(inWidth==32 &&
"can only extend from a 32-bit float");
219 assert(outWidth==64 &&
"can only extend to a 64-bit double");
226inline uint64_t
toUnsignedInt( uint64_t l,
unsigned outWidth,
unsigned inWidth ) {
230 default: llvm::report_fatal_error(
"unsupported floating point width");
235inline uint64_t
toSignedInt( uint64_t l,
unsigned outWidth,
unsigned inWidth ) {
239 default: llvm::report_fatal_error(
"unsupported floating point width");
248 default: llvm::report_fatal_error(
"unsupported floating point width");
253inline uint64_t
SignedIntToFP( uint64_t l,
unsigned outWidth,
unsigned inWidth ) {
257 default: llvm::report_fatal_error(
"unsupported floating point width");
uint64_t truncateToNBits(uint64_t x, unsigned N)
uint64_t toSignedInt(uint64_t l, unsigned outWidth, unsigned inWidth)
uint64_t sub(uint64_t l, uint64_t r, unsigned inWidth)
uint64_t lt(uint64_t l, uint64_t r, unsigned inWidth)
uint64_t add(uint64_t l, uint64_t r, unsigned inWidth)
uint64_t le(uint64_t l, uint64_t r, unsigned inWidth)
uint64_t ne(uint64_t l, uint64_t r, unsigned inWidth)
bool isNaN(uint64_t l, unsigned inWidth)
uint64_t mod(uint64_t l, uint64_t r, unsigned inWidth)
uint64_t eq(uint64_t l, uint64_t r, unsigned inWidth)
uint64_t gt(uint64_t l, uint64_t r, unsigned inWidth)
uint64_t mul(uint64_t l, uint64_t r, unsigned inWidth)
uint64_t DoubleAsUInt64(double d)
uint64_t trunc(uint64_t l, unsigned outWidth, unsigned inWidth)
uint64_t ext(uint64_t l, unsigned outWidth, unsigned inWidth)
uint64_t FloatAsUInt64(float f)
uint64_t div(uint64_t l, uint64_t r, unsigned inWidth)
uint64_t toUnsignedInt(uint64_t l, unsigned outWidth, unsigned inWidth)
uint64_t SignedIntToFP(uint64_t l, unsigned outWidth, unsigned inWidth)
uint64_t UnsignedIntToFP(uint64_t l, unsigned outWidth)
uint64_t ge(uint64_t l, uint64_t r, unsigned inWidth)
double UInt64AsDouble(uint64_t bits)
float UInt64AsFloat(uint64_t bits)
uint64_t sext(uint64_t l, unsigned outWidth, unsigned inWidth)