cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
boolbv_concatenation.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_expr.h
>
12
#include <
util/invariant.h
>
13
14
bvt
boolbvt::convert_concatenation
(
const
concatenation_exprt
&expr)
15
{
16
std::size_t width=
boolbv_width
(expr.
type
());
17
18
const
exprt::operandst
&operands=expr.
operands
();
19
20
DATA_INVARIANT
(
21
!operands.empty(),
"concatenation shall have at least one operand"
);
22
23
std::size_t offset=width;
24
bvt
bv;
25
bv.resize(width);
26
27
for
(
const
auto
&operand : operands)
28
{
29
const
bvt
&op =
convert_bv
(operand);
30
31
INVARIANT
(
32
op.size() <= offset,
33
"concatenation operand must fit into the result bitvector"
);
34
35
offset-=op.size();
36
37
for
(std::size_t i=0; i<op.size(); i++)
38
bv[offset+i]=op[i];
39
}
40
41
INVARIANT
(
42
offset == 0,
43
"all bits in the result bitvector must have been filled up by the "
44
"concatenation operands"
);
45
46
return
bv;
47
}
bitvector_expr.h
API to expression classes for bitvectors.
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::boolbv_width
virtual std::size_t boolbv_width(const typet &type) const
Definition
boolbv.h:106
boolbvt::convert_concatenation
virtual bvt convert_concatenation(const concatenation_exprt &expr)
Definition
boolbv_concatenation.cpp:14
concatenation_exprt
Concatenation of bit-vector operands.
Definition
bitvector_expr.h:958
exprt::operandst
std::vector< exprt > operandst
Definition
expr.h:59
exprt::type
typet & type()
Return the type of the expression.
Definition
expr.h:85
exprt::operands
operandst & operands()
Definition
expr.h:95
bvt
std::vector< literalt > bvt
Definition
literal.h:201
invariant.h
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
INVARIANT
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
Definition
invariant.h:423
solvers
flattening
boolbv_concatenation.cpp
Generated by
1.17.0