|
||
lir_flow_walker.hGo to the documentation of this file.00001 // $Id: lir_flow_walker.h,v 1.7 2003/08/11 17:38:52 abrown Exp $ 00002 // ---------------------------------------------------------------------- 00003 // 00004 // C-Breeze 00005 // C Compiler Framework 00006 // 00007 // Copyright (c) 2002 University of Texas at Austin 00008 // 00009 // Paul Arthur Navratil 00010 // Charles Nevill 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 __LIR_FLOW_WALKER_H 00039 #define __LIR_FLOW_WALKER_H 00040 00041 #include "c_breeze.h" 00042 #include "instruction.h" 00043 #include "register.h" 00044 00045 class lir_flow_walker:public Walker 00046 { 00047 public: 00048 00049 // constructor 00050 lir_flow_walker (); 00051 00052 // destructor 00053 ~lir_flow_walker (); 00054 00055 00056 public: 00058 // walker interface 00059 00060 // what to do at a procedure 00061 void at_proc (procNode * the_proc, Order ord); 00062 00063 00064 public: 00066 // block analysis helpers 00067 00068 // structure defining edge 00069 struct edge 00070 { 00071 LirBlock *source; 00072 LirBlock *target; 00073 }; 00074 00075 // a list of edges 00076 typedef list < edge > edge_list; 00077 typedef edge_list::iterator edge_list_p; 00078 00079 // build basic blocks for LIR in a procedure 00080 static void build_lir_blocks (procNode * the_proc); 00081 00082 // recursively generate depth-first ordering of blocks 00083 static void get_block_dfo (LirBlock * entryblock, LirBlockList & blocks); 00084 00085 // do dominator analysis of blocks in a procedure 00086 static void find_block_doms (procNode * the_proc); 00087 00088 // find all the loops in a procedure, also sets _depth member of all lir 00089 // blocks 00090 // need_recompute_flow - whether or not to recompute flow info 00091 // before looking for loops 00092 static void find_loops (procNode * proc, bool need_recompute_flow, 00093 vector < LirBlockSet > &loops); 00094 00095 public: 00097 // instruction-level analysis 00098 00099 // compute register liveness at each instruction 00100 static void computeRegisterLiveness (instruction_list & insts, 00101 inst_to_reg_id_map & liveRegs); 00102 00103 // recursively visit instructions and build up postorder ordering 00104 static void getInstructionsPostorder (instruction_list & insts, 00105 instruction_list_p it, 00106 instruction_list & ordering); 00107 00108 // generate predecessor/successor info for an instruction 00109 static void getInstructionFlowInfo (instruction_list & insts); 00110 00111 // find an instruction in a list 00112 static instruction_list_p findInstruction (instruction_list & insts, 00113 const LirInst * inst); 00114 00115 protected: 00116 00117 // print out block info for debugging purposes (disabled in non-debug mode) 00118 static void debug_print_block_info (procNode * proc); 00119 00120 }; 00121 00122 #endif // __CODEGENPHASE_H__ |
Generated on August 27, 2003
Back to the C-Breeze home page