00001 /*------------------------------------------------------------------- 00002 * Name: legoProc.H 00003 * 00004 * Designer: Willie Glover 00005 * 00006 * Created: 5/28/96 00007 * 00008 * Description: This file contains the LEGO header file which 00009 * defines the procedure region derived class. 00010 * 00011 * Location: /ncsu/tinker/LEGO/src/derived/legoProc.H 00012 -------------------------------------------------------------------- 00013 * 5/28/96 WTG: Initial file creation. 00014 * 3/22/97 WAH: Added RefreshEdges method et al. 00015 * 4/8/97 WAH: Fixed default constructor to allocate 5 bytes for name. 00016 * 4/11/97 WAH: Added Kiss Of Death to destructor. 00017 * 4/29/97 WAH: Added FindDominators method. 00018 * 6/11/97 WAH: Added GetOpCount method. 00019 * 1/9/98 WAH: Fixed SetProcName to handle NULL. 00020 --------------------------------------------------------------------*/ 00021 00022 #ifndef LEGOPROC_H 00023 #define LEGOPROC_H 00024 00025 #include "opEdges.H" 00026 #include "attr.H" 00027 #include "legoJump.H" 00028 #include "region.H" 00029 #include "lSymTab.H" 00030 00031 //--------------------------------------------------------------------------- 00032 00033 //class symbolTable; 00034 class opEdges; 00035 class attrs; 00036 class jumpTable; 00037 class memvrs; 00038 00039 class legoProc: 00040 public legoRegion 00041 { 00042 00043 char *procName; 00044 00045 importTypes scope; 00046 char * info; 00047 00048 // symbolTable* dataPtr; 00049 // symbolTable* data1Ptr; 00050 // symbolTable* bssPtr; 00051 00052 opEdges* edgeDictionary; 00053 attrs* attrDictionary; 00054 jumpTable* jumpDictionary; 00055 memvrs* memDictionary; 00056 00057 public: 00058 00059 legoProc () : legoRegion(RT_PROC,1) 00060 { 00061 // fprintf(stderr,"Creating LEGOPROC %p\n",this); 00062 procName = new char[5]; 00063 (void)strcpy(procName,"none"); 00064 edgeDictionary = NULL; 00065 attrDictionary = NULL; 00066 jumpDictionary = NULL; 00067 memDictionary = NULL; 00068 00069 info = NULL; 00070 scope = LIR_LOCAL; 00071 } 00072 00073 legoProc (char* name="none", unsigned rId = 1) 00074 : legoRegion(RT_PROC,rId) 00075 { 00076 // fprintf(stderr,"Creating LEGOPROC %p\n",this); 00077 procName = new char[strlen(name)+1]; 00078 (void)strcpy(procName,name); 00079 edgeDictionary = NULL; 00080 attrDictionary = NULL; 00081 jumpDictionary = NULL; 00082 memDictionary = NULL; 00083 00084 info = NULL; 00085 scope = LIR_LOCAL; 00086 } 00087 00088 legoProc (const legoProc &orig) : legoRegion ((legoRegion) orig) 00089 { 00090 // fprintf(stderr,"Creating LEGOPROC %p\n",this); 00091 if (procName != NULL) 00092 { 00093 procName = new char[strlen(orig.procName)+1]; 00094 (void)strcpy(procName,orig.procName); 00095 } // end if 00096 else 00097 procName = NULL; 00098 if (orig.edgeDictionary != NULL) 00099 edgeDictionary = new opEdges (*(orig.edgeDictionary)); 00100 else 00101 edgeDictionary = NULL; 00102 if (orig.attrDictionary != NULL) 00103 attrDictionary = new attrs (*(orig.attrDictionary)); 00104 else 00105 attrDictionary = NULL; 00106 if (orig.jumpDictionary != NULL) 00107 jumpDictionary = new jumpTable (*(orig.jumpDictionary)); 00108 else 00109 jumpDictionary = NULL; 00110 memDictionary = NULL; 00111 // if (orig.memDictionary != NULL) 00112 // memDictionary = new (*(orig.memDictionary)); 00113 info = NULL; 00114 if(orig.info != NULL) 00115 SetInfo(orig.info); 00116 scope = orig.scope; 00117 00118 } 00119 00120 ~legoProc () 00121 { 00122 if(info != NULL) 00123 { 00124 delete [] info; 00125 info = NULL; 00126 } 00127 00128 delete[] procName; 00129 delete edgeDictionary; 00130 delete attrDictionary; 00131 delete jumpDictionary; 00132 // delete memDictionary; 00133 Mark(RM_KISSOFDEATH); // to signify to dying regions that proc dies too 00134 RegionKiller(); 00135 // fprintf(stderr,"Deleting LEGOPROC %p\n",this); 00136 } 00137 00138 void SetScope(importTypes inScope) 00139 { 00140 scope = inScope; 00141 } 00142 importTypes GetScope() 00143 { 00144 return scope; 00145 } 00146 00147 void SetInfo(char * newInfo) 00148 { 00149 if(info != NULL) 00150 { 00151 delete [] info; 00152 info = NULL; 00153 } 00154 if(newInfo != NULL) 00155 { 00156 info = new char[strlen(newInfo) + 1]; 00157 strcpy(info, newInfo); 00158 } 00159 } 00160 00161 char * GetInfo() { return info;} 00162 int GetOpCount (void) 00163 { 00164 int opct = 0; 00165 00166 for (int i = 0; i < GetCount(); i++) 00167 opct += ((legoRegion *) GetItem(i))->GetOpCount(); 00168 return opct; 00169 } 00170 00171 void SetProcName(char *pName) 00172 { 00173 delete[] procName; 00174 if (pName != NULL) 00175 { 00176 procName = new char[strlen(pName)+1]; 00177 (void)strcpy(procName,pName); 00178 } // end if 00179 else procName = NULL; 00180 } 00181 00182 /*------------------------------------------------------------------- 00183 Update the "data" data segment pointer. 00184 --------------------------------------------------------------------*/ 00185 // void SetDataPtr(symbolTable* newDataPtr) { dataPtr = newDataPtr; } 00186 00187 /*------------------------------------------------------------------- 00188 Update the "data1" data segment pointer. 00189 --------------------------------------------------------------------*/ 00190 // void SetData1Ptr(symbolTable* newData1Ptr) { data1Ptr = newData1Ptr; } 00191 00192 /*------------------------------------------------------------------- 00193 Update the "bss" data segment pointer. 00194 --------------------------------------------------------------------*/ 00195 // void SetBssPtr(symbolTable* newBssPtr) { bssPtr = newBssPtr; } 00196 00197 /*------------------------------------------------------------------- 00198 Update the edge dictionary pointer. 00199 --------------------------------------------------------------------*/ 00200 void SetEdgeDictionary(opEdges *newEdgeDictionary) 00201 { edgeDictionary = newEdgeDictionary; } 00202 00203 /*------------------------------------------------------------------- 00204 Update the attribute dictionary pointer. 00205 --------------------------------------------------------------------*/ 00206 void SetAttrDictionary(attrs *newAttrDictionary) 00207 { attrDictionary = newAttrDictionary; } 00208 00209 /*------------------------------------------------------------------- 00210 Update the jump dictionary pointer. 00211 --------------------------------------------------------------------*/ 00212 void SetJumpDictionary(jumpTable *newJumpDictionary) 00213 { jumpDictionary = newJumpDictionary; } 00214 00215 /*------------------------------------------------------------------- 00216 Update the memvrs dictionary pointer. 00217 --------------------------------------------------------------------*/ 00218 void SetMemDictionary(memvrs *newMemDictionary) 00219 { memDictionary = newMemDictionary; } 00220 00221 /*------------------------------------------------------------------- 00222 Get the procedure name. 00223 --------------------------------------------------------------------*/ 00224 char *GetProcName(void) { return procName; } 00225 00226 /*------------------------------------------------------------------- 00227 Get the "data" data segment pointer. 00228 --------------------------------------------------------------------*/ 00229 // symbolTable* GetDataPtr(void) { return dataPtr; } 00230 00231 /*------------------------------------------------------------------- 00232 Get the "data1" data segment pointer 00233 --------------------------------------------------------------------*/ 00234 // symbolTable* GetData1Ptr(void) { return data1Ptr; } 00235 00236 /*------------------------------------------------------------------- 00237 Get the "bss" data segment pointer. 00238 --------------------------------------------------------------------*/ 00239 // symbolTable* GetBssPtr(void) { return bssPtr; } 00240 00241 /*------------------------------------------------------------------- 00242 Get the edge dictionary pointer. 00243 --------------------------------------------------------------------*/ 00244 opEdges *GetEdgeDictionary(void) { return edgeDictionary; } 00245 00246 /*------------------------------------------------------------------- 00247 Get the attribute dictionary pointer. 00248 --------------------------------------------------------------------*/ 00249 attrs *GetAttrDictionary(void) { return attrDictionary; } 00250 00251 /*------------------------------------------------------------------- 00252 Get the jump dictionary pointer. 00253 --------------------------------------------------------------------*/ 00254 jumpTable *GetJumpDictionary(void) { return jumpDictionary; } 00255 00256 /*------------------------------------------------------------------- 00257 Get the memvrs dictionary pointer. 00258 --------------------------------------------------------------------*/ 00259 memvrs *GetMemDictionary(void) { return memDictionary; } 00260 00261 void RefreshOps (void); 00262 void RefreshEdges (void) {}; // no edges in or out of proc 00263 00264 void FindDominators (void); 00265 }; 00266 00267 #endif // LEGOPROC_H
1.3.2