cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
byte_operators.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 "
byte_operators.h
"
10
11
#include "
config.h
"
12
13
static
irep_idt
byte_extract_id
()
14
{
15
switch
(
config
.ansi_c.endianness)
16
{
17
case
configt::ansi_ct::endiannesst::IS_LITTLE_ENDIAN
:
18
return
ID_byte_extract_little_endian;
19
20
case
configt::ansi_ct::endiannesst::IS_BIG_ENDIAN
:
21
return
ID_byte_extract_big_endian;
22
23
case
configt::ansi_ct::endiannesst::NO_ENDIANNESS
:
24
UNREACHABLE
;
25
}
26
27
UNREACHABLE
;
28
}
29
30
static
irep_idt
byte_update_id
()
31
{
32
switch
(
config
.ansi_c.endianness)
33
{
34
case
configt::ansi_ct::endiannesst::IS_LITTLE_ENDIAN
:
35
return
ID_byte_update_little_endian;
36
37
case
configt::ansi_ct::endiannesst::IS_BIG_ENDIAN
:
38
return
ID_byte_update_big_endian;
39
40
case
configt::ansi_ct::endiannesst::NO_ENDIANNESS
:
41
UNREACHABLE
;
42
}
43
44
UNREACHABLE
;
45
}
46
47
byte_extract_exprt
48
make_byte_extract
(
const
exprt
&_op,
const
exprt
&_offset,
const
typet
&_type)
49
{
50
return
byte_extract_exprt
{
51
byte_extract_id
(), _op, _offset,
config
.ansi_c.char_width, _type};
52
}
53
54
byte_update_exprt
55
make_byte_update
(
const
exprt
&_op,
const
exprt
&_offset,
const
exprt
&_value)
56
{
57
return
byte_update_exprt
{
58
byte_update_id
(), _op, _offset, _value,
config
.ansi_c.char_width};
59
}
60
61
bool
has_byte_operator
(
const
exprt
&src)
62
{
63
if
(
64
src.
id
() == ID_byte_update_little_endian ||
65
src.
id
() == ID_byte_update_big_endian ||
66
src.
id
() == ID_byte_extract_little_endian ||
67
src.
id
() == ID_byte_extract_big_endian)
68
{
69
return
true
;
70
}
71
72
for
(
const
auto
&op : src.
operands
())
73
{
74
if
(
has_byte_operator
(op))
75
return
true
;
76
}
77
78
return
false
;
79
}
config
configt config
Definition
config.cpp:25
byte_extract_id
static irep_idt byte_extract_id()
Definition
byte_operators.cpp:13
make_byte_update
byte_update_exprt make_byte_update(const exprt &_op, const exprt &_offset, const exprt &_value)
Construct a byte_update_exprt with endianness and byte width matching the current configuration.
Definition
byte_operators.cpp:55
byte_update_id
static irep_idt byte_update_id()
Definition
byte_operators.cpp:30
has_byte_operator
bool has_byte_operator(const exprt &src)
Return true iff src or one of its operands contain a byte extract or byte update expression.
Definition
byte_operators.cpp:61
make_byte_extract
byte_extract_exprt make_byte_extract(const exprt &_op, const exprt &_offset, const typet &_type)
Construct a byte_extract_exprt with endianness and byte width matching the current configuration.
Definition
byte_operators.cpp:48
byte_operators.h
Expression classes for byte-level operators.
byte_extract_exprt
Expression of type type extracted from some object op starting at position offset (given in number of...
Definition
byte_operators.h:29
byte_update_exprt
Expression corresponding to op() where the bytes starting at position offset (given in number of byte...
Definition
byte_operators.h:91
exprt
Base class for all expressions.
Definition
expr.h:57
exprt::operands
operandst & operands()
Definition
expr.h:95
irept::id
const irep_idt & id() const
Definition
irep.h:388
typet
The type of an expression, extends irept.
Definition
type.h:29
config.h
UNREACHABLE
#define UNREACHABLE
This should be used to mark dead code.
Definition
invariant.h:525
configt::ansi_ct::endiannesst::IS_BIG_ENDIAN
@ IS_BIG_ENDIAN
Definition
config.h:231
configt::ansi_ct::endiannesst::IS_LITTLE_ENDIAN
@ IS_LITTLE_ENDIAN
Definition
config.h:230
configt::ansi_ct::endiannesst::NO_ENDIANNESS
@ NO_ENDIANNESS
Definition
config.h:229
irep_idt
dstringt irep_idt
Definition
verification_result.h:16
util
byte_operators.cpp
Generated by
1.17.0