|
||
dummy_reg_alloc.hGo to the documentation of this file.00001 // $Id: dummy_reg_alloc.h,v 1.7 2003/08/11 17:38:51 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 _DUMMY_REG_ALLOC_H 00039 #define _DUMMY_REG_ALLOC_H 00040 00041 #include "reg_alloc.h" 00042 00043 // 00044 // dummy register allocator - assumes all variables stored in stack 00045 // and fixes up virtual register references to be real references. 00046 // 00047 class dummy_reg_alloc : public reg_alloc 00048 { 00049 public: 00050 00051 // ctor/dtor 00052 dummy_reg_alloc(); 00053 ~dummy_reg_alloc(); 00054 00055 // allocate registers for a procedure 00056 void allocate(procNode *proc); 00057 00058 public: 00060 // data structures 00061 00062 // forward defines 00063 struct rreg_info; 00064 struct vreg_info; 00065 00066 // status of a particular virtual register 00067 struct vreg_info 00068 { 00069 // ctor 00070 vreg_info() : pRealReg(0), reclaimed(false) 00071 { 00072 } 00073 00074 // a register object representing this register 00075 Register reg; 00076 00077 // real register to which it's currently allocated 00078 rreg_info * pRealReg; 00079 00080 // whether or not the real register we used for this 00081 // has been reclaimed 00082 bool reclaimed; 00083 }; 00084 00085 // status of a particular real register 00086 struct rreg_info 00087 { 00088 // ctor 00089 rreg_info() : pInfo(0), pVirtualReg(0) 00090 { 00091 } 00092 00093 // info about this register 00094 arch_info::register_info * pInfo; 00095 00096 // a register object representing this register 00097 Register reg; 00098 00099 // virtual register currently living in this real register 00100 // or NULL if unoccupied. 00101 vreg_info * pVirtualReg; 00102 }; 00103 00104 00105 protected: 00107 // helpers 00108 00109 // setup real register info 00110 void setup_rregs(); 00111 00112 // find out if a register is real (otherwise it's virtual) 00113 bool is_real_reg( const Register & reg ); 00114 00115 // get info for a virtual register 00116 vreg_info* get_vreg( const Register & vreg ); 00117 00118 // get info for a real register 00119 rreg_info* get_rreg( const Register & rreg ); 00120 00121 // verify that a particular virtual register already has a 00122 // real register and change the virtual to match the real 00123 // returns false if the virtual register does not have a real 00124 // register associated with it or if one could not be 00125 // allocated. 00126 bool fix_allocated_virtual( Register & reg, const LirInst & inst ); 00127 00128 // allocate a real register for a virtual register. 00129 // returns false one could not be allocated. 00130 bool allocate_real_for_virtual( Register & reg, declNode * pDecl, const LirInst & inst ); 00131 00132 00133 protected: 00134 00135 // info on each virtual register - indexed by register number, 00136 // NULL if never seen before 00137 vector<vreg_info*> _vregs; 00138 00139 // info on each virtual register - indexed by register number, 00140 // NULL if never seen before 00141 vector<rreg_info*> _rregsGpr; 00142 int _rregsGprCount; 00143 vector<rreg_info*> _rregsFpr; 00144 int _rregsFprCount; 00145 00146 // most recently-allocated real register 00147 int _lastRealRegFixed; 00148 int _lastRealRegFloat; 00149 00150 }; 00151 00152 00153 class dummy_reg_alloc_walker : public Walker 00154 { 00155 public: 00156 // ctor 00157 dummy_reg_alloc_walker(); 00158 00159 // handle various things 00160 // acb - 6 May 2003 00161 // is this necessary? 00162 void at_unit(unitNode *the_unit, Order ord); 00163 void at_proc(procNode *the_proc, Order ord); 00164 00165 }; 00166 00167 #endif |
Generated on August 27, 2003
Back to the C-Breeze home page