00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef CBZ_LIVE_H
00038 #define CBZ_LIVE_H
00039
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 typedef declSetFlowVal liveFlowVal;
00051
00052 class liveFlowProblem: public FlowProblem {
00053 private:
00054
00055 procNode *proc;
00056 declNode **decls;
00057 map <var_id, int> *name2num;
00058 int flowsize;
00059
00060 public:
00061 liveFlowProblem (int n, map<var_id,int> *m, declNode **vars) :
00062 decls(vars),
00063 name2num(m),
00064 flowsize(n),
00065 FlowProblem(false, new liveFlowVal (n, m, vars)) { }
00066
00067 ~liveFlowProblem (void) { }
00068 void flow_node (FlowVal *, Node *, Point);
00069 void flow_block (FlowVal *, blockNode *, Point);
00070 void dan_iterate (procNode *p);
00071 };
00072
00073 class liveAnnote: public Annote {
00074 decl_list _live_vars;
00075
00076 public:
00077
00078 static liveAnnote * getLiveAnnote(basicblockNode *b) {
00079 string live("liveness");
00080 for (annote_list_p i=b->annotations().begin();
00081 i!=b->annotations().end(); i++) {
00082 if ((*i)->is_annote_kind (live))
00083 return (liveAnnote *) *i;
00084 }
00085 return NULL;
00086 }
00087
00088 static void removeliveness (basicblockNode *b) {
00089 string live("liveness");
00090 for (annote_list_p i=b->annotations().begin();
00091 i!=b->annotations().end(); ) {
00092 if ((*i)->is_annote_kind (live)) {
00093
00094 delete *i;
00095 i = b->annotations().erase (i);
00096 }
00097 else
00098 i++;
00099 }
00100 }
00101
00102 liveAnnote (decl_list l) : _live_vars (l) { }
00103
00104 liveAnnote (void) { }
00105
00106 decl_list & live_vars (void) { return _live_vars; }
00107 void live_vars (decl_list l) { _live_vars = l; }
00108
00109 bool is_annote_kind (string & name) {
00110 return name == "liveness";
00111 }
00112 };
00113
00114 class livenessRemover : public Walker {
00115 public:
00116
00117 livenessRemover (void) : Walker (Preorder, Subtree) { }
00118
00119 void at_basicblock (basicblockNode *b, Order) {
00120 if (b->annotations().size())
00121 liveAnnote::removeliveness (b);
00122 }
00123 };
00124
00125 class livenessWalker: public Walker {
00126 public:
00127 livenessWalker(): Walker (Preorder, Subtree) {}
00128
00129 void at_proc (procNode *, Order);
00130 };
00131
00132
00133 #endif // CBZ_LIVE_H