ROSE
0.9.6a
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
constantprop.h
Go to the documentation of this file.
1
2
typedef
map< memoryDef *, ipConstant >
constant_map
;
3
typedef
constant_map::iterator
constant_map_p
;
4
5
// ------------------------------------------------------------
6
// ipConstant
7
// ------------------------------------------------------------
8
9
// This class represents a single constant value associated with one
10
// def of a variable. It can hold either a constant value, or have the
11
// special lattice TOP value. The lattice BOTTOM is represented by a
12
// constant no_val (which is built into the constant class).
13
14
class
ipConstant
15
{
16
private
:
17
18
constant
_value
;
19
bool
_top
;
20
bool
_internal
;
21
22
ipConstant
(constant &
value
);
23
ipConstant
();
24
ipConstant
(
const
ipConstant
& other);
25
~ipConstant
();
26
27
// -- Fields
28
29
void
to_bottom
();
30
bool
is_top
()
const
;
31
bool
is_bottom
()
const
;
32
33
inline
const
constant &
value
()
const
{
return
_value
; }
34
inline
constant &
value
() {
return
_value
; }
35
36
public
:
37
38
inline
void
intern
() {
_internal
=
true
; }
39
40
void
assign
(
const
ipConstant
& other);
41
42
// -- Comparison
43
44
bool
diff
(
ipConstant
& other)
const
;
45
46
// -- Meet "^" operator
47
// Must satisfy the following:
48
// Associative: x ^ (y ^ z) = (x ^ y) ^ z
49
// Commutative: x ^ y = y ^ x
50
// Idempotent: x ^ x = x
51
52
void
meet_with
(
const
ipConstant
& other);
53
54
// -- Computational functions
55
56
void
binary_operator
(
const
Operator * op,
57
const
ipConstant
& right_operand);
58
59
void
unary_operator
(
const
Operator * op);
60
61
void
cast_operator
(
const
typeNode * type);
62
63
// -- Output
64
65
void
print
(ostream & o);
66
67
};
68
69
class
constantProp
70
{
71
private
:
72
73
Pointers *
_pointers
;
74
constant_map
_constants
;
75
bool
_debug
;
76
77
public
:
78
79
constantProp
(Pointers * pointers);
80
81
void
analyze
();
82
83
void
eval
(stmtLocation * current,
84
exprNode * expr, constant & val);
85
86
private
:
87
88
bool
merge_constants
(memorydef_set & defs,
89
memoryuse_set & uses);
90
91
void
rebuild_constant
(memoryuse_set & uses,
92
ipConstant
& value);
93
94
void
rebuild_constant
(stmtLocation * where,
95
pointerValue & pointer,
96
ipConstant
& value);
97
}
rose-edg4x
src
midend
programAnalysis
annotationLanguageParser
constantprop.h
Generated on Mon May 5 2014 17:28:52 for ROSE by
1.8.4