ROSE
0.11.96.11
rexompiler
src
midend
programAnalysis
genericDataflow
analysis
analysis.h
1
#include <featureTests.h>
2
#ifdef ROSE_ENABLE_SOURCE_ANALYSIS
3
4
#ifndef ANALYSIS_H
5
#define ANALYSIS_H
6
7
#include "VirtualCFGIterator.h"
8
#include "cfgUtils.h"
9
#include "CallGraphTraverse.h"
10
#include "analysisCommon.h"
11
12
class
Analysis
;
13
14
#include "lattice.h"
15
#include "nodeState.h"
16
#include "variables.h"
17
#include "varSets.h"
18
#include <vector>
19
#include <set>
20
#include <map>
21
22
extern
int
analysisDebugLevel;
23
24
class
Analysis
25
{
26
public
:
27
// a filter function to decide which raw CFG node to show (if return true) or hide (otherwise)
28
// This is required to support custom filters of virtual CFG
29
// Custom filter is set inside the intra-procedural analysis.
30
// Inter-procedural analysis will copy the filter from its intra-procedural analysis during the call to its constructor.
31
bool (*filter) (
CFGNode
cfgn);
32
Analysis
(
bool
(*f)(
CFGNode
) = defaultFilter):filter(f) {}
33
};
34
35
class
InterProceduralAnalysis
;
36
37
class
IntraProceduralAnalysis
:
virtual
public
Analysis
38
{
39
protected
:
40
InterProceduralAnalysis
* interAnalysis;
41
42
public
:
43
void
setInterAnalysis(
InterProceduralAnalysis
* interAnalysis)
44
{ this->interAnalysis = interAnalysis; }
45
46
// runs the intra-procedural analysis on the given function, returns true if
47
// the function's NodeState gets modified as a result and false otherwise
48
// state - the function's NodeState
49
virtual
bool
runAnalysis(
const
Function
& func,
NodeState
* state)=0;
50
51
virtual
~
IntraProceduralAnalysis
();
52
};
53
54
class
InterProceduralAnalysis
:
virtual
public
Analysis
55
{
56
protected
:
57
IntraProceduralAnalysis
* intraAnalysis;
58
59
InterProceduralAnalysis
(
IntraProceduralAnalysis
* intraAnalysis)
60
{
61
this->intraAnalysis = intraAnalysis;
62
// inform the intra-procedural analysis that this inter-procedural analysis will be running it
63
intraAnalysis->setInterAnalysis(
this
);
64
}
65
66
virtual
void
runAnalysis()=0;
67
68
virtual
~
InterProceduralAnalysis
();
69
};
70
71
/********************************
72
*** UnstructuredPassAnalyses ***
73
********************************/
74
75
// A driver class which simply iterates through all CFG nodes of a specified function
76
class
UnstructuredPassIntraAnalysis
:
virtual
public
IntraProceduralAnalysis
77
{
78
public
:
79
// runs the intra-procedural analysis on the given function, returns true if
80
// the function's NodeState gets modified as a result and false otherwise
81
// state - the function's NodeState
82
bool
runAnalysis(
const
Function
& func,
NodeState
* state);
83
84
virtual
void
visit(
const
Function
& func,
const
DataflowNode
& n,
NodeState
& state)=0;
85
};
86
// A driver class which simply iterates all function definitions one by one and call intra-procedural analysis on each of them.
87
class
UnstructuredPassInterAnalysis
:
virtual
public
InterProceduralAnalysis
88
{
89
public
:
90
UnstructuredPassInterAnalysis
(
IntraProceduralAnalysis
& intraAnalysis) :
InterProceduralAnalysis
(&intraAnalysis)
91
{ }
92
93
void
runAnalysis();
94
};
95
96
#endif
97
#endif
NodeState
Definition:
nodeState.h:92
VirtualCFG::DataflowNode
Definition:
DataflowCFG.h:19
VirtualCFG::CFGNode
A node in the control flow graph.
Definition:
virtualCFG.h:70
UnstructuredPassIntraAnalysis
Definition:
analysis.h:76
UnstructuredPassInterAnalysis
Definition:
analysis.h:87
IntraProceduralAnalysis
Definition:
analysis.h:37
InterProceduralAnalysis
Definition:
analysis.h:54
Function
Definition:
CallGraphTraverse.h:20
Analysis
Definition:
analysis.h:24
Generated on Mon Dec 19 2022 23:39:36 for ROSE by
1.8.17