ROSE  0.11.52.0
ConstrGraphAnalysis.h
1 #include <featureTests.h>
2 #ifdef ROSE_ENABLE_SOURCE_ANALYSIS
3 
4 #ifndef SCALAR_FW_DATAFLOW_H
5 #define SCALAR_FW_DATAFLOW_H
6 
7 #include <sstream>
8 #include <iostream>
9 #include <string>
10 #include <functional>
11 #include <queue>
12 
13 #include "genericDataflowCommon.h"
14 #include "VirtualCFGIterator.h"
15 #include "cfgUtils.h"
16 #include "CallGraphTraverse.h"
17 #include "rwAccessLabeler.h"
18 #include "analysisCommon.h"
19 #include "analysis.h"
20 #include "dataflow.h"
21 #include "latticeFull.h"
22 #include "liveDeadVarAnalysis.h"
23 #include "divAnalysis.h"
24 // GB : 2011-03-05 (Removing Sign Lattice Dependence) #include "sgnAnalysis.h"
25 #include "affineInequality.h"
26 
27 #include "ConstrGraph.h"
28 
30 {
31  protected:
32  static map<varID, Lattice*> constVars;
33  DivAnalysis* divAnalysis;
34  // GB : 2011-03-05 (Removing Sign Lattice Dependence) SgnAnalysis* sgnAnalysis;
35  //affineInequalitiesPlacer* affIneqPlacer;
36 
37  // The LiveDeadVarsAnalysis that identifies the live/dead state of all application variables.
38  // Needed to create a FiniteVarsExprsProductLattice.
39  LiveDeadVarsAnalysis* ldva;
40 
41  public:
42  ConstrGraphAnalysis(LiveDeadVarsAnalysis* ldva, DivAnalysis* divAnalysis/* GB : 2011-03-05 (Removing Sign Lattice Dependence) , SgnAnalysis* sgnAnalysis*/ /*, affineInequalitiesPlacer* affIneqPlacer*/): IntraFWDataflow()
43  {
44  this->divAnalysis = divAnalysis;
45  // GB : 2011-03-05 (Removing Sign Lattice Dependence) this->sgnAnalysis = sgnAnalysis;
46  this->ldva = ldva;
47  //this->affIneqPlacer = affIneqPlacer;
48  //rwAccessLabeler::addRWAnnotations(cfgUtils::getProject());
49  }
50 
51  // generates the initial lattice state for the given dataflow node, in the given function, with the given NodeState
52  //vector<Lattice*> genInitState(const Function& func, const DataflowNode& n, const NodeState& state);
53  void genInitState(const Function& func, const DataflowNode& n, const NodeState& state,
54  vector<Lattice*>& initLattices, vector<NodeFact*>& initFacts);
55 
56  // Returns a map of special constant variables (such as zeroVar) and the lattices that correspond to them
57  // These lattices are assumed to be constants: it is assumed that they are never modified and it is legal to
58  // maintain only one copy of each lattice may for the duration of the analysis.
59  //map<varID, Lattice*>& genConstVarLattices() const;
60 
61  bool transfer(const Function& func, const DataflowNode& n, NodeState& state, const vector<Lattice*>& dfInfo);
62 
63  // incorporates the current node's inequality information from conditionals (ifs, fors, etc.) into the current node's
64  // constraint graph
65  // returns true if this causes the constraint graph to change and false otherwise
66  bool incorporateConditionalsInfo(const Function& func, const DataflowNode& n,
67  NodeState& state, const vector<Lattice*>& dfInfo);
68 
69  // incorporates the current node's divisibility information into the current node's constraint graph
70  // returns true if this causes the constraint graph to change and false otherwise
71  //bool incorporateDivInfo(const Function& func, const DataflowNode& n, NodeState& state, const vector<Lattice*>& dfInfo, string indent="");
72 
73  // For any variable for which we have divisibility info, remove its constraints to other variables (other than its
74  // divisibility variable)
75  bool removeConstrDivVars(const Function& func, const DataflowNode& n, NodeState& state, const vector<Lattice*>& dfInfo, string indent="");
76 };
77 
78 // Prints the Lattices set by the given ConstrGraphAnalysis
79 void printConstrGraphAnalysisStates(ConstrGraphAnalysis* cga, string indent="");
80 
81 #endif
82 #endif