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_DOMINANCEFRONTIERS_H 00038 #define CBZ_DOMINANCEFRONTIERS_H 00039 00040 #include <bitset> 00041 #include "clone_changer.h" 00042 #include "dominators.h" 00043 00044 // The DominanceFrontier class compute the dominance frontier for the 00045 // procedure given in its constructor. The class is a subclass of 00046 // basicblock_map, which maps a basic block to the list containing the 00047 // elements of its dominance frontier. Thus, it may be accessed 00048 // directly like this: 00049 00050 // DominanceFrontiers dfs(my_proc); 00051 // basicblock_list & dfx = dfs[x]; 00052 00053 typedef bitset<1024> basicblock_bitset; 00054 00055 typedef map< basicblockNode *, basicblock_bitset > basicblockset_map; 00056 typedef basicblockset_map::iterator basicblockset_map_p; 00057 00058 typedef map< basicblockNode *, basicblock_list> basicblock_map; 00059 typedef basicblock_map::iterator basicblock_map_p; 00060 00061 typedef vector<basicblockNode *> basicblock_vec; 00062 typedef basicblock_vec::iterator basicblock_vec_p; 00063 00064 class DominanceFrontiers : public basicblock_map 00065 { 00066 private: 00067 00068 // --- The procedure to analyze 00069 00070 procNode * _proc; 00071 00072 // --- The root node 00073 00074 basicblockNode * _root; 00075 00076 // --- Basic blocks in depth first order 00077 00078 basicblock_vec df_vec; 00079 00080 // --- Compute 00081 00082 void depth_first_search(basicblockNode * node); 00083 void compute_dominance_frontiers(); 00084 int _index; 00085 00086 public: 00087 00088 DominanceFrontiers(procNode * proc); 00089 }; 00090 00091 #endif //