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  

ssa.h

Go to the documentation of this file.
00001 // $Id: ssa.h,v 1.9 2003/08/07 23:14:21 pnav Exp $
00002 // ----------------------------------------------------------------------
00003 //
00004 //  C-Breeze
00005 //  C Compiler Framework
00006 // 
00007 //  Copyright (c) 2000 University of Texas at Austin
00008 // 
00009 //  Samuel Z. Guyer
00010 //  Daniel A. Jimenez
00011 //  Calvin Lin
00012 // 
00013 //  Permission is hereby granted, free of charge, to any person
00014 //  obtaining a copy of this software and associated documentation
00015 //  files (the "Software"), to deal in the Software without
00016 //  restriction, including without limitation the rights to use, copy,
00017 //  modify, merge, publish, distribute, sublicense, and/or sell copies
00018 //  of the Software, and to permit persons to whom the Software is
00019 //  furnished to do so, subject to the following conditions:
00020 //  
00021 //  The above copyright notice and this permission notice shall be
00022 //  included in all copies or substantial portions of the Software.
00023 //  
00024 //  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00025 //  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00026 //  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00027 //  NONINFRINGEMENT.  IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT
00028 //  AUSTIN BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
00029 //  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
00030 //  OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00031 //  THE SOFTWARE.
00032 //
00033 //  We acknowledge the C-to-C Translator from MIT Laboratory for
00034 //  Computer Science for inspiring parts of the C-Breeze design.
00035 //
00036 // ----------------------------------------------------------------------
00037 
00038 #ifndef CBZ_SSA_H
00039 #define CBZ_SSA_H
00040 
00041 #include <bitset>
00042 #include "ref_clone_changer.h"
00043 #include "dominators.h"
00044 #include "dominancefrontiers.h"
00047 class ssa_info : public algorithm_info
00048 {
00049 public:
00050 
00051   int HasAlready;
00052   int Work;
00053 
00054   ssa_info()
00055     : HasAlready(0), Work(0)
00056   {}
00057 };
00058 
00059 typedef vector<basicblockNode *> basicblock_vec;
00060 
00061 typedef map<declNode *, int_list> varstack_map;
00062 
00063 typedef map<declNode *, int> counter_map;
00064 typedef counter_map::iterator counter_map_p;
00065 
00066 typedef map<basicblockNode *, basicblock_bitset> basicblockset_map;
00067 typedef basicblockset_map::iterator basicblockset_map_p;
00068 
00069 typedef pair< idNode * , int > var_change;
00070 typedef list< var_change > var_changes;
00071 typedef var_changes::iterator var_changes_p;
00072 
00073 typedef vector< declNode * > decl_vector;
00074 typedef map< declNode *, decl_vector > decl_decl_map;
00075 
00078 class SSA
00079 {
00080 private:
00081 
00083   const procNode * _proc;
00084 
00086   basicblockNode * _root;
00087   basicblock_list _cfg;
00088 
00093   varstack_map Stack;
00094   counter_map Counter;
00095   var_changes Changes;
00098 
00099   DominanceFrontiers DF;
00100 
00101 private:
00102 
00107   void place_phi_functions();
00108   static void place_one_phi(declNode * d, basicblockNode * block);
00115   void rename();
00116   void search(basicblockNode * X);
00117   int which_pred(basicblockNode * node, basicblockNode * pred);
00118   void push_new_decl(declNode * de, int index);
00119   void rename_all_variables();
00120   string name_with_index(string & name, int index);
00123 
00124   static int & HasAlready(basicblockNode * n)
00125   {
00126     return ((ssa_info *)(n)->info())->HasAlready;
00127   }
00128 
00129   static int & Work(basicblockNode * n)
00130   {
00131     return ((ssa_info *)(n)->info())->Work;
00132   }
00133 
00134 public:
00135 
00136   SSA(procNode * proc, bool forward = true, bool rename = true);
00137 
00138   void print() {}
00139 
00144   static binaryNode * assignment(stmtNode * s);
00145   static idNode * lhs(stmtNode * s);
00146   static bool need_ssa (declNode* decl);
00147   static callNode * phi(stmtNode * s);  
00148   void record_index(idNode * id);
00153   static bool add_phi_function(declNode * d, basicblockNode * block);
00154   // basicblock_list * dominance_frontier(basicblockNode * block);
00155 };
00156 
00157 #endif // CBZ_SSA_H

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