00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00037
00038
00039
00040
00041
00043
00044
00045
00046
00047
00048
00049
00050 #ifdef USE_PCH
00051 #include "cg_pch.h"
00052 #endif // USE_PCH
00053 #pragma hdrstop
00054
00055 #ifdef _KEEP_RCS_ID
00056 static char *rcs_id = "$Source: /scratch/mee/2.4-65/kpro64-pending/be/cg/gra_mon/SCCS/s.gra_interfere.cxx $ $Revision: 1.2 $";
00057 #endif
00058
00059 #include "defs.h"
00060 #include "mempool.h"
00061 #include "gra_bb.h"
00062 #include "gra_lunit.h"
00063 #include "gra_lrange.h"
00064 #include "gra_interfere.h"
00065 #include "gra_lrange_subuniverse.h"
00066 #include "gra_lrange_vset.h"
00067 #include "lrange_set.h"
00068 #include "gra_region.h"
00069
00070 INTERFERE_MGR intf_mgr;
00071
00073
00074
00075
00076
00077
00078 INTERFERE
00079 INTERFERE_DEREF::Add_Neighbor(LRANGE* lrange, LRANGE_SUBUNIVERSE* subuniverse)
00080 {
00081 LRANGE_SET* set = Bitset();
00082 return intf_mgr.Make_Bitset(LRANGE_SET_Union1DS(set,lrange,GRA_pool,
00083 subuniverse));
00084 }
00085
00087
00088
00089 INTERFERE
00090 INTERFERE_DEREF::Remove_Neighbor(LRANGE* lrange,
00091 LRANGE_SUBUNIVERSE* subuniverse)
00092 {
00093 if ( Is_Vec() ) {
00094 Vec()->Delete_Element(lrange);
00095 return this;
00096 }
00097 else {
00098 LRANGE_SET* set =
00099 LRANGE_SET_Difference1DS(Bitset(),lrange, subuniverse);
00100 return intf_mgr.Make_Bitset(set);
00101 }
00102 }
00103
00105
00106 INTERFERE
00107 INTERFERE_DEREF::Replace_Neighbor(LRANGE* old_lr, LRANGE* new_lr,
00108 LRANGE_SUBUNIVERSE* subuniverse)
00109 {
00110 if ( Is_Vec() ) {
00111 Vec()->Replace_Element(old_lr,new_lr);
00112 return this;
00113 }
00114 else {
00115 LRANGE_SET* set = Bitset();
00116
00117 set = LRANGE_SET_Difference1DS(set,old_lr,subuniverse);
00118 set = LRANGE_SET_Union1DS(set,new_lr,GRA_pool,subuniverse);
00119 return intf_mgr.Make_Bitset(set);
00120 }
00121 }
00122
00124
00125
00126
00127 INTERFERE
00128 INTERFERE_MGR::Create_Empty(LRANGE_SUBUNIVERSE* subuniverse)
00129 {
00130 size_t size = subuniverse->Count();
00131 return intf_mgr.Make_Bitset(LRANGE_SET_Create_Empty(size,GRA_pool));
00132 }
00133
00135
00136
00137
00138
00139 void
00140 INTERFERE_MGR::Create_Begin( LRANGE_SUBUNIVERSE* su )
00141 {
00142 MEM_POOL_Push(&neighbor_vec_pool);
00143
00144 neighbor_vec_size = su->Count();
00145 neighbor_vec = TYPE_MEM_POOL_ALLOC_N(LRANGE*,&neighbor_vec_pool,
00146 neighbor_vec_size);
00147 neighbor_subuniverse = su;
00148 neighbor_count = 0;
00149 neighbor_id_max = -1;
00150 lrange_mgr.Clear_One_Set();
00151 }
00152
00154
00155 void
00156 INTERFERE_MGR::Create_Add_Neighbor( LRANGE* neighbor )
00157 {
00158 if ( ! lrange_mgr.One_Set_MemberP(neighbor) ) {
00159 DevAssert(neighbor_count + 1 <= neighbor_vec_size,
00160 ("GRA interference creation vector overflow"));
00161 lrange_mgr.One_Set_Union1(neighbor);
00162 neighbor_vec[neighbor_count++] = neighbor;
00163 if ( neighbor->Id() > neighbor_id_max )
00164 neighbor_id_max = neighbor->Id();
00165 }
00166 }
00167
00169
00170
00171
00172 INTERFERE
00173 INTERFERE_MGR::Create_End( void )
00174 {
00175 INTERFERE result;
00176 size_t v_size = neighbor_count * sizeof(LRANGE*);
00177 size_t s_size = LRANGE_SET_Size_Alloc_Size(neighbor_id_max + 1);
00178
00179
00180
00181
00182
00183
00184 if ( v_size < s_size ) {
00185 result = intf_mgr.Make_Vec(LRANGE_VSET_Create(neighbor_vec,
00186 neighbor_count,
00187 GRA_pool));
00188 }
00189 else {
00190 INT32 i;
00191 LRANGE_SET* ns = LRANGE_SET_Create_Empty(neighbor_id_max,GRA_pool);
00192
00193 for ( i = neighbor_count - 1; i >= 0; --i ) {
00194 ns = LRANGE_SET_Union1DS(ns,neighbor_vec[i],GRA_pool,
00195 neighbor_subuniverse);
00196 }
00197
00198 result = intf_mgr.Make_Bitset(ns);
00199 }
00200
00201 MEM_POOL_Pop(&neighbor_vec_pool);
00202
00203 return result;
00204 }