cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
boolbv_mod.cpp
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module:
4
5
Author: Daniel Kroening, kroening@kroening.com
6
7
\*******************************************************************/
8
9
10
#include "
boolbv.h
"
11
12
bvt
boolbvt::convert_mod
(
const
mod_exprt
&expr)
13
{
14
#if 0
15
// TODO
16
if
(expr.
type
().
id
()==ID_floatbv)
17
{
18
}
19
#endif
20
21
if
(expr.
type
().
id
()!=ID_unsignedbv &&
22
expr.
type
().
id
()!=ID_signedbv)
23
return
conversion_failed
(expr);
24
25
std::size_t width=
boolbv_width
(expr.
type
());
26
27
DATA_INVARIANT
(
28
expr.
dividend
().
type
().
id
() == expr.
type
().
id
(),
29
"type of the dividend of a modulo operation shall equal the "
30
"expression type"
);
31
32
DATA_INVARIANT
(
33
expr.
divisor
().
type
().
id
() == expr.
type
().
id
(),
34
"type of the divisor of a modulo operation shall equal the "
35
"expression type"
);
36
37
bv_utilst::representationt
rep=
38
expr.
type
().
id
()==ID_signedbv?
bv_utilst::representationt::SIGNED
:
39
bv_utilst::representationt::UNSIGNED
;
40
41
const
bvt
÷nd_bv =
convert_bv
(expr.
dividend
(), width);
42
const
bvt
&divisor_bv =
convert_bv
(expr.
divisor
(), width);
43
44
bvt
res, rem;
45
46
bv_utils
.divider(dividend_bv, divisor_bv, res, rem, rep);
47
48
return
rem;
49
}
boolbv.h
boolbvt::convert_bv
virtual const bvt & convert_bv(const exprt &expr, const std::optional< std::size_t > expected_width={})
Convert expression to vector of literalts, using an internal cache to speed up conversion if availabl...
Definition
boolbv.cpp:40
boolbvt::convert_mod
virtual bvt convert_mod(const mod_exprt &expr)
Definition
boolbv_mod.cpp:12
boolbvt::bv_utils
bv_utilst bv_utils
Definition
boolbv.h:121
boolbvt::conversion_failed
bvt conversion_failed(const exprt &expr)
Print that the expression of x has failed conversion, then return a vector of x's width.
Definition
boolbv.cpp:95
boolbvt::boolbv_width
virtual std::size_t boolbv_width(const typet &type) const
Definition
boolbv.h:106
bv_utilst::representationt
representationt
Definition
bv_utils.h:28
bv_utilst::representationt::SIGNED
@ SIGNED
Definition
bv_utils.h:28
bv_utilst::representationt::UNSIGNED
@ UNSIGNED
Definition
bv_utils.h:28
exprt::type
typet & type()
Return the type of the expression.
Definition
expr.h:85
irept::id
const irep_idt & id() const
Definition
irep.h:388
mod_exprt
Modulo defined as lhs-(rhs * truncate(lhs/rhs)).
Definition
std_expr.h:1206
mod_exprt::dividend
exprt & dividend()
The dividend of a division is the number that is being divided.
Definition
std_expr.h:1214
mod_exprt::divisor
exprt & divisor()
The divisor of a division is the number the dividend is being divided by.
Definition
std_expr.h:1226
bvt
std::vector< literalt > bvt
Definition
literal.h:201
DATA_INVARIANT
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
Definition
invariant.h:534
solvers
flattening
boolbv_mod.cpp
Generated by
1.17.0