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
00039 #ifndef CBZ_LIVE_H
00040 #define CBZ_LIVE_H
00041
00043
00044
00045
00046 #include "c_breeze.h"
00047 #include "bits.h"
00048
00049 typedef set< declNode * > decl_set;
00050 typedef decl_set::iterator decl_set_p;
00051
00068 class LivenessWalker: public Walker {
00069 public:
00070 LivenessWalker();
00071
00072 static LivenessWalker * walk(procNode *);
00073
00074 virtual void at_proc (procNode *, Order);
00075 virtual void at_basicblock(basicblockNode *, Order);
00076 virtual void at_threeAddr(threeAddrNode *, Order);
00077 virtual void at_return(returnNode *, Order);
00078 virtual void at_conditiongoto(conditiongotoNode *, Order);
00079 virtual void at_stmt(stmtNode *, Order);
00080
00083 decl_set * defs(stmtNode *);
00084
00087 decl_set * uses(stmtNode *);
00088
00091 decl_set * live_in(stmtNode *);
00092
00095 decl_set * live_out(stmtNode *);
00096
00097 private:
00098 void defUseOperand(threeAddrNode *, operandNode *, bool, bool);
00099 decl_set * bits2decls(Bits *);
00100
00101 int _num_decls;
00102 map<declNode *, int> _decl2num;
00103
00104 vector<declNode *> _num2decl;
00105 map<stmtNode *, Bits *> _live_in;
00106 map<stmtNode *, Bits *> _live_out;
00107 map<stmtNode *, Bits *> _def;
00108 map<stmtNode *, Bits *> _use;
00109 };
00110
00114 class LivenessComments : public Walker {
00115 public:
00116 LivenessComments(void);
00117
00118 virtual void at_proc(procNode *, Order);
00119 virtual void at_threeAddr(threeAddrNode *, Order);
00120 virtual void at_basicblock(basicblockNode *, Order);
00121 virtual void at_return(returnNode *, Order);
00122 virtual void at_conditiongoto(conditiongotoNode *, Order);
00123
00124 private:
00125 void comment_stmt(stmtNode *);
00126
00127 LivenessWalker * _lw;
00128 };
00129
00130 #endif // CBZ_LIVE_H