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