C-Breeze
C Compiler Infrastructure

[ Project home page]

live.h

Go to the documentation of this file.
00001 // $Id: live.h,v 1.7 2003/08/07 23:14:17 pnav Exp $
00002 // ----------------------------------------------------------------------
00003 //
00004 //  C-Breeze
00005 //  C Compiler Framework
00006 // 
00007 //  Copyright (c) 2000 University of Texas at Austin
00008 // 
00009 //  Adam Brown
00010 //  Samuel Z. Guyer
00011 //  Daniel A. Jimenez
00012 //  Calvin Lin
00013 // 
00014 //  Permission is hereby granted, free of charge, to any person
00015 //  obtaining a copy of this software and associated documentation
00016 //  files (the "Software"), to deal in the Software without
00017 //  restriction, including without limitation the rights to use, copy,
00018 //  modify, merge, publish, distribute, sublicense, and/or sell copies
00019 //  of the Software, and to permit persons to whom the Software is
00020 //  furnished to do so, subject to the following conditions:
00021 //  
00022 //  The above copyright notice and this permission notice shall be
00023 //  included in all copies or substantial portions of the Software.
00024 //  
00025 //  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00026 //  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00027 //  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00028 //  NONINFRINGEMENT.  IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT
00029 //  AUSTIN BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
00030 //  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
00031 //  OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00032 //  THE SOFTWARE.
00033 //
00034 //  We acknowledge the C-to-C Translator from MIT Laboratory for
00035 //  Computer Science for inspiring parts of the C-Breeze design.
00036 //
00037 // ----------------------------------------------------------------------
00038 
00039 #ifndef CBZ_LIVE_H
00040 #define CBZ_LIVE_H
00041 
00043 // live.h
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   //  declNode ** _num2decl;
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

Generated on February 1, 2006
Back to the C-Breeze home page