00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __RoseBin_DefUseAnalysis__
00009 #define __RoseBin_DefUseAnalysis__
00010
00011 #include "RoseBin_DataFlowAbstract.h"
00012
00013 class RoseBin_DefUseAnalysis : public RoseBin_DataFlowAbstract {
00014 private:
00015
00016 SgGraphNode* nodeBefore;
00017
00018
00019 void addDefElement(SgGraphNode* sgNode,
00020 std::pair<X86RegisterClass, int> initName,
00021 SgGraphNode* defNode);
00022
00023 void addUseElement(SgGraphNode* sgNode,
00024 std::pair<X86RegisterClass, int> initName,
00025 SgGraphNode* defNode);
00026
00027 void addAnyElement(tabletype* tabl, SgGraphNode* sgNode,
00028 std::pair<X86RegisterClass, int> initName,
00029 SgGraphNode* defNode);
00030
00031
00032
00033
00034
00035 bool searchDefMap(SgGraphNode* node);
00036 bool searchMap(const tabletype* ltable, SgGraphNode* node);
00037
00038
00039
00040
00041
00042
00043
00044 void mapDefUnion(SgGraphNode* before, SgGraphNode* other, SgGraphNode* sgNode);
00045 void mapUseUnion(SgGraphNode* before, SgGraphNode* other, SgGraphNode* sgNode);
00046 void mapAnyUnion(tabletype* tabl, SgGraphNode* before, SgGraphNode* other, SgGraphNode* sgNode);
00047
00048 bool checkElementsForEquality(const multitype* t1, const multitype* t2);
00049 void getOtherInNode(std::vector<SgGraphNode*>& vec,
00050 SgGraphNode* cfgNode, SgGraphNode* oneNode);
00051
00052 void printDefMap();
00053 void printUseMap();
00054 void printAnyMap(tabletype* tabl);
00055 void printMultiMap(const multitype* multi);
00056
00057 bool searchMulti(const multitype* multi, std::pair<X86RegisterClass, int> initName);
00058 bool searchMulti(const multitype* multi, std::pair<X86RegisterClass, int> initName,
00059 SgGraphNode* val);
00060
00061 void replaceElement(SgGraphNode* sgNode,
00062 std::pair<X86RegisterClass, int> initName);
00063 void clearRegisters();
00064
00065 void handleCopy(bool def,SgGraphNode* sgNode, SgGraphNode* sgNodeBefore);
00066
00067
00068 public:
00069
00070 RoseBin_DefUseAnalysis(GraphAlgorithms* algo):RoseBin_DataFlowAbstract(algo) {
00071 ROSE_ASSERT(algo);
00072 }
00073 ~RoseBin_DefUseAnalysis() {}
00074
00075 bool run(std::string& name, SgGraphNode* node,SgGraphNode* nodeBefore);
00076
00077
00078 int getNrOfMemoryWrites() {return nrOfMemoryWrites;}
00079 int getNrOfRegisterWrites() {return nrOfRegisterWrites;}
00080
00081 void init(RoseBin_Graph* vg) {
00082 vizzGraph = vg;
00083 nrOfMemoryWrites=0;
00084 nrOfRegisterWrites=0;
00085 nodeBefore=NULL;
00086
00087 deftable.clear();
00088
00089 }
00090
00091 std::string getElementsAsStringForNode(bool def,SgGraphNode* node);
00092
00093 bool runEdge( SgGraphNode* node, SgGraphNode* next);
00094
00095
00096
00097 };
00098
00099 #endif
00100