Skip to content

Commit 989dca8

Browse files
author
kroening
committed
more float_bvt implementation
git-svn-id: svn+ssh://svn.cprover.org/srv/svn/cbmc/trunk@3248 6afb6bc1-c8e4-404c-8f48-9ae832c5b171
1 parent e479256 commit 989dca8

File tree

2 files changed

+100
-5
lines changed

2 files changed

+100
-5
lines changed

src/solvers/floatbv/float_bv.cpp

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,98 @@ Function: float_bvt::convert
2626

2727
exprt float_bvt::convert(const exprt &src)
2828
{
29+
if(src.id()==ID_abs)
30+
return convert_abs(to_abs_expr(src));
31+
else if(src.id()==ID_unary_minus)
32+
return convert_unary_minus(to_unary_minus_expr(src));
33+
// else if(src.id()==ID_ieee_float_equal)
34+
// return convert_ieee_float_equal(to_ieee_float_equal_expr(src));
35+
2936
return nil_exprt();
3037
}
38+
39+
/*******************************************************************\
40+
41+
Function: float_bvt::convert_abs
42+
43+
Inputs:
44+
45+
Outputs:
46+
47+
Purpose:
48+
49+
\*******************************************************************/
50+
51+
exprt float_bvt::convert_abs(const abs_exprt &src)
52+
{
53+
// we mask away the sign bit, which is the most significand bit
54+
const floatbv_typet &type=to_floatbv_type(src.type());
55+
unsigned width=type.get_width();
56+
57+
std::string mask_str;
58+
mask_str.resize(width, '1');
59+
mask_str[0]='0';
60+
61+
constant_exprt mask(mask_str, src.type());
62+
63+
// return bitand_exprt(src.op(), mask);
64+
}
65+
66+
/*******************************************************************\
67+
68+
Function: float_bvt::convert_unary_minus
69+
70+
Inputs:
71+
72+
Outputs:
73+
74+
Purpose:
75+
76+
\*******************************************************************/
77+
78+
exprt float_bvt::convert_unary_minus(const unary_minus_exprt &src)
79+
{
80+
// we flip the sign bit with an xor
81+
const floatbv_typet &type=to_floatbv_type(src.type());
82+
unsigned width=type.get_width();
83+
84+
std::string mask_str;
85+
mask_str.resize(width, '0');
86+
mask_str[0]='1';
87+
88+
constant_exprt mask(mask_str, src.type());
89+
90+
// return bitxor_exprt(src.op(), mask);
91+
}
92+
93+
/*******************************************************************\
94+
95+
Function: float_bvt::convert_ieee_float_equal
96+
97+
Inputs:
98+
99+
Outputs:
100+
101+
Purpose:
102+
103+
\*******************************************************************/
104+
105+
exprt float_bvt::convert_ieee_float_equal(const ieee_float_equal_exprt &src)
106+
{
107+
}
108+
109+
/*******************************************************************\
110+
111+
Function: float_bvt::convert_ieee_float_notequal
112+
113+
Inputs:
114+
115+
Outputs:
116+
117+
Purpose:
118+
119+
\*******************************************************************/
120+
121+
//exprt float_bvt::convert_ieee_float_notequal(const ieee_float_notequal_exprt &src)
122+
//{
123+
//}

src/solvers/floatbv/float_bv.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ Author: Daniel Kroening, [email protected]
99
#ifndef CPROVER_FLOAT_BV_H
1010
#define CPROVER_FLOAT_BV_H
1111

12-
//#include <util/ieee_float.h>
13-
14-
#include <solvers/prop/prop_conv.h>
12+
#include <util/std_expr.h>
1513

1614
class float_bvt
1715
{
@@ -20,7 +18,7 @@ class float_bvt
2018
{
2119
}
2220

23-
virtual ~float_bvt()
21+
~float_bvt()
2422
{
2523
}
2624

@@ -30,7 +28,11 @@ class float_bvt
3028
}
3129

3230
protected:
33-
exprt convert(const exprt &src);
31+
exprt convert(const exprt &);
32+
exprt convert_abs(const abs_exprt &);
33+
exprt convert_unary_minus(const unary_minus_exprt &);
34+
exprt convert_ieee_float_equal(const ieee_float_equal_exprt &);
35+
//exprt convert_ieee_float_notequal(const ieee_float_notequal_exprt &);
3436

3537
#if 0
3638
// extraction

0 commit comments

Comments
 (0)