CBMC
boolbv_floatbv_mod_rem.cpp
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module:
4
5
Author: Daniel Kroening, kroening@kroening.com
6
7
\*******************************************************************/
8
9
#include "
boolbv.h
"
10
11
#include <
util/bitvector_types.h
>
12
13
#include <
solvers/floatbv/float_utils.h
>
14
15
bvt
boolbvt::convert_floatbv_mod_rem
(
const
binary_exprt
&expr)
16
{
17
// Note that the expressions do not have rounding modes
18
// but float_utils requires one.
19
20
float_utilst
float_utils(
prop
);
21
22
auto
rm =
bv_utils
.
build_constant
(
ieee_floatt::ROUND_TO_EVEN
, 32);
23
float_utils.
set_rounding_mode
(rm);
24
25
float_utils.
spec
=
ieee_float_spect
(
to_floatbv_type
(expr.
type
()));
26
27
bvt
lhs_as_bv =
convert_bv
(expr.
lhs
());
28
bvt
rhs_as_bv =
convert_bv
(expr.
rhs
());
29
30
// float_utilst::rem implements lhs-(lhs/rhs)*rhs, which matches
31
// neither fmod() nor IEEE
32
return
float_utils.
rem
(lhs_as_bv, rhs_as_bv);
33
}
binary_exprt::rhs
exprt & rhs()
Definition:
std_expr.h:623
float_utilst
Definition:
float_utils.h:17
float_utils.h
bvt
std::vector< literalt > bvt
Definition:
literal.h:201
to_floatbv_type
const floatbv_typet & to_floatbv_type(const typet &type)
Cast a typet to a floatbv_typet.
Definition:
bitvector_types.h:367
binary_exprt::lhs
exprt & lhs()
Definition:
std_expr.h:613
binary_exprt
A base class for binary expressions.
Definition:
std_expr.h:582
float_utilst::set_rounding_mode
void set_rounding_mode(const bvt &)
Definition:
float_utils.cpp:15
ieee_float_spect
Definition:
ieee_float.h:22
exprt::type
typet & type()
Return the type of the expression.
Definition:
expr.h:84
float_utilst::rem
virtual bvt rem(const bvt &src1, const bvt &src2)
Definition:
float_utils.cpp:539
boolbvt::convert_bv
virtual const bvt & convert_bv(const exprt &expr, const optionalt< std::size_t > expected_width={})
Convert expression to vector of literalts, using an internal cache to speed up conversion if availabl...
Definition:
boolbv.cpp:39
bitvector_types.h
bv_utilst::build_constant
static bvt build_constant(const mp_integer &i, std::size_t width)
Definition:
bv_utils.cpp:11
ieee_floatt::ROUND_TO_EVEN
@ ROUND_TO_EVEN
Definition:
ieee_float.h:125
boolbvt::bv_utils
bv_utilst bv_utils
Definition:
boolbv.h:117
boolbv.h
boolbvt::convert_floatbv_mod_rem
virtual bvt convert_floatbv_mod_rem(const binary_exprt &)
Definition:
boolbv_floatbv_mod_rem.cpp:15
float_utilst::spec
ieee_float_spect spec
Definition:
float_utils.h:88
prop_conv_solvert::prop
propt & prop
Definition:
prop_conv_solver.h:130
src
solvers
flattening
boolbv_floatbv_mod_rem.cpp
Generated by
1.8.17