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
00038 #ifndef CBZ_UDDUCHAINS_H
00039 #define CBZ_UDDUCHAINS_H
00040
00041 #include "c_breeze.h"
00042
00057 class udduChains {
00058 public:
00059 typedef list<threeAddrNode*> threeAddr_list;
00060
00061 private:
00062 map<exprNode*,threeAddr_list> ud_chain;
00063 map<threeAddrNode*,expr_list> du_chain;
00064 map<threeAddrNode*,stmt_list> du_site_chain;
00065
00066 public:
00067 udduChains(void) {}
00068
00069 #define contain(L,x) (find(L.begin(),L.end(),x) != L.end())
00070
00072 inline void add(exprNode *use, threeAddrNode *def, stmtNode *useSite=NULL) {
00073 if(!use) return;
00074 if(! contain(ud_chain[use], def))
00075 ud_chain[use].push_back(def);
00076 if(! contain(du_chain[def], use))
00077 du_chain[def].push_back(use);
00078 if(useSite && ! contain(du_site_chain[def], useSite))
00079 du_site_chain[def].push_back(useSite);
00080 }
00081
00083 inline threeAddr_list defs(exprNode *use) const {
00084 if(use && ud_chain.find(use)!=ud_chain.end())
00085 return ud_chain.find(use)->second;
00086 return threeAddr_list();
00087 }
00088
00090 inline expr_list uses(threeAddrNode *def) const {
00091 if(def && du_chain.find(def)!=du_chain.end())
00092 return du_chain.find(def)->second;
00093 return expr_list();
00094 }
00095
00097 inline stmt_list useSites(threeAddrNode *def) const {
00098 if(def && du_site_chain.find(def)!=du_site_chain.end())
00099 return du_site_chain.find(def)->second;
00100 return stmt_list();
00101 }
00102
00104 void reset() { ud_chain.clear(); du_chain.clear(); du_site_chain.clear(); }
00105 };
00106
00107 #endif