|
||
copyprop.hGo 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 // Teck Bok Tok 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_COPYPROP1_H 00039 #define CBZ_COPYPROP1_H 00040 00041 #include "c_breeze.h" 00042 00064 class copyPropChanger : public Changer { 00065 public: 00066 typedef set<threeAddrNode*> threeAddr_set; 00067 typedef threeAddr_set::iterator threeAddr_set_p; 00068 typedef set<declNode*> decl_set; 00069 typedef decl_set::iterator decl_set_p; 00070 00072 static void change(); 00073 00075 static void change(unitNode *); 00076 00078 static void change(procNode *); 00079 00080 private: 00081 00083 copyPropChanger() : Changer(Preorder, Subtree, false) {} 00084 00085 Node *at_proc(procNode *, Order ord); 00086 00087 threeAddr_set copies, // copy statements 00088 ambiguous; // statements with ambiguous 00089 // statements 00090 map<threeAddrNode*,declNode*> defines; // what does statement define? 00091 class GetDefsWalker; // helper class to obtain 00092 // copies and ambiguous 00093 00094 /* The algorithm is divided into two phase: a global phase and a local 00095 * phase. */ 00096 00097 //{ global phase 00098 00099 // flow value 00100 class copyFlowVal; 00101 copyFlowVal *_top, *_bottom; 00102 00103 map<basicblockNode*, copyFlowVal*> Gen, Kill, In, Out; 00104 00105 copyFlowVal * create_copy_set(basicblockNode *); 00106 copyFlowVal * create_kill_set(basicblockNode *, stmt_list); 00107 void solve_global_dataflow(stmt_list); 00108 00109 //} 00110 00111 //{ local phase 00112 00113 // internal data structure 00114 typedef pair<declNode*,declNode*> Var_pair; // a copy pair. 00115 typedef set<Var_pair> ACP; // available copy instuctions 00116 00117 void local_copy_prop(basicblockNode *); 00118 00119 static void remove_ACP(ACP &acp, declNode *v); 00120 void copy_value(operandNode *opnd, const ACP &acp); 00121 idNode *copy_value(idNode *opnd, const ACP &acp); 00122 //} 00123 }; 00124 00125 #endif // CBZ_COPYPROP_H |
Generated on August 27, 2003
Back to the C-Breeze home page