Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

ssa.h

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

Generated on Thu Jan 10 12:06:20 2002 for C-Breeze by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001