ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BottomUpTraversalLiveness.h
Go to the documentation of this file.
1 /******************************************
2  * Category: DFA
3  * Liveness Analysis Declaration
4  * created by tps in Nov 2008
5  *****************************************/
6 
7 #ifndef __LivenessAnalysisBUP_HXX_LOADED__
8 #define __LivenessAnalysisBUP_HXX_LOADED__
9 #include <string>
10 #include "LivenessAnalysis.h"
11 
12 class BottomUpTraversalLivenessIN: public AstBottomUpProcessing<std::vector<SgInitializedName*> *> {
14  public:
17 
18  protected:
19  virtual std::vector<SgInitializedName*> *evaluateSynthesizedAttribute(SgNode *node,
20  SynthesizedAttributesList synAttributes) {
21  std::vector<SgInitializedName*> current_in = (live->getIn(node));
22 
23 // std::cout << ">>> visiting node : " << node->class_name() << " elements IN[]: " << current_in.size()
24 // <<" merging with nodes: " << synAttributes.size() << std::endl;
25  std::vector<SgInitializedName*>* newVec = defaultSynthesizedAttribute();
26 
27  std::vector< std::vector<SgInitializedName*>* >::const_iterator s;
28  for (s = synAttributes.begin(); s != synAttributes.end(); ++s) {
29  std::vector<SgInitializedName*>* vec = *s;
30  // merge vec and in
31  // std::cout << " >>> Merging *vec and newVec --- *vec size :" << (*vec).size() << std::endl;
32  if ((*vec).size()>0) {
33  *newVec = live->merge_no_dups(*vec,*newVec);
34  }
35  delete *s;
36  }
37  *newVec = live->merge_no_dups(*newVec,current_in);
38 
39  if (isSgStatement(node)) {
40  // replace the current in[SgNode] map
41  live->setIn(node,*newVec);
42  //std::cout << " --- replacing stmt : newVecElements : " << (*newVec).size() << std::endl;
43  }
44  return newVec;
45  }
46  virtual std::vector<SgInitializedName*> *defaultSynthesizedAttribute() {
47  // Create new value
48  std::vector<SgInitializedName*>* vec = new std::vector<SgInitializedName*> ;
49  return vec;
50  }
51 
52 
53 };
54 
55 class BottomUpTraversalLivenessOUT: public AstBottomUpProcessing<std::vector<SgInitializedName*> *> {
57  public:
60 
61  protected:
62  virtual std::vector<SgInitializedName*> *evaluateSynthesizedAttribute(SgNode *node,
63  SynthesizedAttributesList synAttributes) {
64  std::vector<SgInitializedName*> current_out = (live->getOut(node));
65 
66 // std::cout << ">>> visiting node : " << node->class_name() << " elements OUT[]: " << current_out.size()
67 // <<" merging with nodes: " << synAttributes.size() << std::endl;
68  std::vector<SgInitializedName*>* newVec = defaultSynthesizedAttribute();
69 
70  std::vector< std::vector<SgInitializedName*>* >::const_iterator s;
71  for (s = synAttributes.begin(); s != synAttributes.end(); ++s) {
72  std::vector<SgInitializedName*>* vec = *s;
73  // merge vec and out
74  //std::cout << " >>> Merging *vec and newVec --- *vec size :" << (*vec).size() << std::endl;
75  if ((*vec).size()>0) {
76  *newVec = live->merge_no_dups(*vec,*newVec);
77  }
78  delete *s;
79  }
80  *newVec = live->merge_no_dups(*newVec,current_out);
81 
82  if (isSgStatement(node)) {
83  // replace the current out[SgNode] map
84  live->setOut(node,*newVec);
85  //std::cout << " --- replacing stmt : newVecElements : " << (*newVec).size() << std::endl;
86  }
87  return newVec;
88  }
89  virtual std::vector<SgInitializedName*> *defaultSynthesizedAttribute() {
90  // Create new value
91  std::vector<SgInitializedName*>* vec = new std::vector<SgInitializedName*> ;
92  return vec;
93  }
94 
95 
96 };
97 
98 #endif