C-Breeze
C Compiler Infrastructure

[ Project home page]
Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

constprop.h

Go to the documentation of this file.
00001 // $Id: constprop.h,v 1.7 2003/08/11 14:24:12 toktb Exp $
00002 // ----------------------------------------------------------------------
00003 //
00004 //  C-Breeze
00005 //  C Compiler Framework
00006 // 
00007 //  Copyright (c) 2000 University of Texas at Austin
00008 // 
00009 //  Teck Bok Tok
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_CONSTPROP_H
00040 #define CBZ_CONSTPROP_H
00041 
00042 #include "udduChains.h"
00043 
00053 class constantPropChanger : public Changer {
00054 public:
00055   typedef list<threeAddrNode*> threeAddr_list;
00056 
00058   static void change();
00059 
00061   static void change(unitNode *);
00062 
00064   static void change(procNode *);
00065 
00066 private:
00070   constantPropChanger (udduChains *chain) : 
00071     Changer (Preorder, Subtree, false),
00072     _changed (false), _udchain(chain) { }
00073 
00075   inline void reset() { _changed = false; }
00076 
00078   udduChains *_udchain;
00079 
00081   bool _changed;
00082 
00083   exprNode *at_expr (exprNode *);  // not related to Changer's at_expr()
00084   Node *at_threeAddr (threeAddrNode *, Order);
00085   Node *at_conditiongoto (conditiongotoNode *, Order);
00086   Node *at_return (returnNode*, Order);
00087 };
00088 
00089 
00112 class constantFoldingChanger : public Changer {
00113   friend class constantPropChanger;
00114 public:
00115 
00117   static void change();
00118 
00120   static void change(unitNode *);
00121 
00123   static void change(procNode *);
00124 
00125 private:
00126   constantFoldingChanger () : 
00127     Changer (Preorder, Subtree, false),
00128     _changed (false), _cfg_changed(false), _current_block(NULL) {}
00129 
00131   inline void reset() { _changed = _cfg_changed = false; }
00132 
00134   bool _changed;
00135 
00137   bool _cfg_changed;
00138 
00140   basicblockNode *_current_block;
00141 
00142   Node *at_threeAddr (threeAddrNode *, Order);
00143   Node *at_conditiongoto (conditiongotoNode *, Order);
00144   Node *at_basicblock (basicblockNode *, Order);
00145 };
00146 
00147 #endif // CBZ_CONSTPROP_H

Generated on August 27, 2003
Back to the C-Breeze home page