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
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 #ifdef USE_PCH
00057 #include "opt_pch.h"
00058 #endif // USE_PCH
00059 #pragma hdrstop
00060
00061
00062 #include <sys/elf_whirl.h>
00063
00064 #include "defs.h"
00065 #include "config.h"
00066 #include "config_debug.h"
00067 #include "glob.h"
00068 #include "timing.h"
00069 #include "tracing.h"
00070
00071 #include "wn.h"
00072 #include "stab.h"
00073 #include "optimizer.h"
00074
00075 #include "opt_defs.h"
00076 #include "opt_config.h"
00077 #include "region_util.h"
00078 #include "region_main.h"
00079 #include "be_version.h"
00080
00081
00082 #include "config_wopt.h"
00083
00084 #include "wodriver.h"
00085
00086 #ifdef SHARED_BUILD
00087 #if defined(BUILD_OS_DARWIN)
00088 extern char * Ipa_File_Name;
00089 #endif
00090 #endif
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105 void
00106 wopt_main (INT wopt_argc, char **wopt_argv, INT be_argc, char **be_argv)
00107 {
00108 extern const char *Whirl_Revision;
00109
00110 if (strcmp (Whirl_Revision, WHIRL_REVISION) != 0)
00111 FmtAssert (!DEBUG_Ir_Version_Check,
00112 ("WHIRL revision mismatch between be.so (%s) and wopt.so (%s)",
00113 Whirl_Revision, WHIRL_REVISION));
00114
00115 if (&Get_BE_Version == NULL ||
00116 strcmp (Get_BE_Version(), BE_VERSION) != 0)
00117 FmtAssert (FALSE,
00118 ("BE version (in be/com/be_version.h) mismatch between be.so (%s) and wopt.so (%s)",
00119 &Get_BE_Version != NULL ? Get_BE_Version() : "undef", BE_VERSION));
00120
00121 WOPT_Skip_List = Build_Skiplist ( WOPT_Skip );
00122 WOPT_Unroll_Skip_List = Build_Skiplist ( WOPT_Unroll_Skip );
00123 #if 0
00124 extern INT32 WOPT_Unroll_Skip;
00125 WOPT_Unroll_Skip_List = Build_Skiplist ( WOPT_Unroll_Skip );
00126 #endif
00127 }
00128
00129
00130
00131 void
00132 Wopt_Init (void)
00133 {
00134 Set_Error_Phase ( "Wopt Initialization" );
00135
00136 return;
00137 }
00138
00139
00140
00141
00142
00143 WN *
00144 Perform_Global_Optimization (WN *pu_wn, WN *region_wn,
00145 struct ALIAS_MANAGER *alias_mgr)
00146 {
00147 WN *opt_pu;
00148 struct DU_MANAGER *du_mgr;
00149
00150 Is_True(region_wn != NULL,
00151 ("Perform_Global_Optimization, NULL region found"));
00152 OPT_POOL_Push ( &MEM_local_pool, MEM_DUMP_FLAG+17 );
00153
00154 Start_Timer ( T_Wopt_CU );
00155 Set_Error_Phase ( "Global Optimizer" );
00156
00157 du_mgr = Create_Du_Manager(MEM_pu_nz_pool_ptr);
00158
00159 opt_pu = Pre_Optimizer(MAINOPT_PHASE, region_wn, du_mgr, alias_mgr);
00160
00161 Delete_Du_Manager(du_mgr,MEM_pu_nz_pool_ptr);
00162
00163 Stop_Timer ( T_Wopt_CU );
00164
00165 OPT_POOL_Pop ( &MEM_local_pool, MEM_DUMP_FLAG+17 );
00166
00167 return opt_pu;
00168 }
00169
00170
00171
00172
00173 WN *
00174 Perform_Preopt_Optimization(WN *pu_wn, WN *region_wn)
00175 {
00176 WN *opt_pu = NULL;
00177 DU_MANAGER *du_mgr;
00178 ALIAS_MANAGER *alias_mgr;
00179
00180 OPT_POOL_Push ( &MEM_local_pool, MEM_DUMP_FLAG+19 );
00181
00182 Start_Timer ( T_Preopt_CU );
00183 Set_Error_Phase ( "Global Optimizer" );
00184
00185 du_mgr = Create_Du_Manager(MEM_pu_nz_pool_ptr);
00186
00187 alias_mgr = Create_Alias_Manager(MEM_pu_nz_pool_ptr);
00188 opt_pu = Pre_Optimizer(PREOPT_PHASE, region_wn, du_mgr, alias_mgr);
00189
00190 Delete_Du_Manager(du_mgr,MEM_pu_nz_pool_ptr);
00191 Delete_Alias_Manager(alias_mgr,MEM_pu_nz_pool_ptr);
00192
00193 Stop_Timer ( T_Preopt_CU );
00194
00195 OPT_POOL_Pop ( &MEM_local_pool, MEM_DUMP_FLAG+19 );
00196
00197 return opt_pu;
00198 }
00199
00200
00201 void
00202 Wopt_Fini (void)
00203 {
00204 return;
00205 }