C-Breeze
C Compiler Infrastructure

[ Project home page]

mergepoints.h

Go to the documentation of this file.
00001 // $Id: mergepoints.h,v 1.9 2003/08/07 23:14:26 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_MERGEPOINTS_H
00039 #define CBZ_MERGEPOINTS_H
00040 
00041 #include "pointeroptions.h"
00042 #include "memoryblock.h"
00043 #include "proceduredb.h"
00044 
00045 // ------------------------------------------------------------
00046 // mergePoints : Holds all the merge points for the system --
00047 // essentially, all the phi functions. Each entry holds the list of
00048 // objects whose states should be merged at a particular point in the
00049 // program.
00050 
00051 // mergepoint_pair (df element, predecessors) : given a basic block,
00052 // we use the DFPreds class to find its dominance frontier. For each
00053 // element of the dominance frontier, we also return the list of basic
00054 // blocks that come immediately before that element.
00055 
00056 typedef pair< basicblockLocation *, basicblock_set > mergepoint_pair;
00057 typedef list< mergepoint_pair > mergepoint_list;
00058 typedef mergepoint_list::iterator mergepoint_list_p;
00059 
00060 // mergepoint_map : for each merge point, record the objects that need
00061 // to be merged there.
00062 
00063 typedef map< basicblockLocation *, memoryblock_set > mergepoint_map;
00064 typedef mergepoint_map::iterator mergepoint_map_p;
00065 
00066 class mergePoints : public mergepoint_map
00067 {
00068 private:
00069 
00070   procedureDB * Procedures;
00071   bool _debug;
00072 
00073 public:
00074 
00075   mergePoints(procedureDB * procedures, bool debug = false)
00076     : mergepoint_map(),
00077       Procedures(procedures),
00078       _debug(debug)
00079   {}
00080 
00081 
00082 
00083   // --- Given a list of definitions and their location, find the set
00084   // of merge points (dominance frontier) and record the objects at
00085   // those points. This is equivalent to the SSA process that adds phi
00086   // functions for a particular set of definitions.
00087 
00088   void add_merge_points(basicblockLocation * location_of_def,
00089                         int last_stmt_num,
00090                         const memoryblock_set & defs);
00091 
00092   // --- Find the dominance frontier for a particular program
00093   // point. We do this interprocedurally by searching up the call
00094   // stack until we find a suitable place for the merge.
00095 
00096   void find_merge_points(basicblockLocation * cur,
00097                          mergepoint_list & merge_points);
00098 
00099   // --- Add a block to the list of blocks that need to be merged at
00100   // the given merge point.
00101 
00102   void add_block_to_merge_point(mergepoint_pair & merge_point,
00103                                 memoryBlock * block);
00104 
00105   // --- Lookup a merge point: given a particular basic block, see if
00106   // there are any objects to be merged at its entry.
00107 
00108   memoryblock_set * lookup_merge_point(basicblockLocation * where);
00109 
00110   // --- Print some statistics
00111 
00112   void stats();
00113 };
00114 
00115 #endif // CBZ_MERGEPOINTS_H

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