00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "config.h"
00022 #include "system.h"
00023 #include "coretypes.h"
00024 #include "tm.h"
00025 #include "rtl.h"
00026 #include "hard-reg-set.h"
00027 #include "obstack.h"
00028 #include "basic-block.h"
00029 #include "cfgloop.h"
00030 #include "cfglayout.h"
00031
00032
00033
00034 struct loops *
00035 loop_optimizer_init (FILE *dumpfile)
00036 {
00037 struct loops *loops = xcalloc (1, sizeof (struct loops));
00038 edge e;
00039 edge_iterator ei;
00040 static bool first_time = true;
00041
00042 if (first_time)
00043 {
00044 first_time = false;
00045 init_set_costs ();
00046 }
00047
00048
00049
00050
00051 for (ei = ei_start (EXIT_BLOCK_PTR->preds); (e = ei_safe_edge (ei)); )
00052 if ((e->flags & EDGE_FALLTHRU) && EDGE_COUNT (e->src->succs) > 1)
00053 split_edge (e);
00054 else
00055 ei_next (&ei);
00056
00057
00058
00059 if (flow_loops_find (loops, LOOP_TREE) <= 1)
00060 {
00061
00062 flow_loops_free (loops);
00063 free (loops);
00064
00065 return NULL;
00066 }
00067
00068
00069 free (loops->cfg.rc_order);
00070 loops->cfg.rc_order = NULL;
00071 free (loops->cfg.dfs_order);
00072 loops->cfg.dfs_order = NULL;
00073
00074
00075 create_preheaders (loops, CP_SIMPLE_PREHEADERS);
00076
00077
00078 force_single_succ_latches (loops);
00079
00080
00081 mark_irreducible_loops (loops);
00082
00083
00084 flow_loops_dump (loops, dumpfile, NULL, 1);
00085
00086 #ifdef ENABLE_CHECKING
00087 verify_dominators (CDI_DOMINATORS);
00088 verify_loop_structure (loops);
00089 #endif
00090
00091 return loops;
00092 }
00093
00094
00095 void
00096 loop_optimizer_finalize (struct loops *loops, FILE *dumpfile)
00097 {
00098 unsigned i;
00099
00100 if (!loops)
00101 return;
00102
00103 for (i = 1; i < loops->num; i++)
00104 if (loops->parray[i])
00105 free_simple_loop_desc (loops->parray[i]);
00106
00107
00108 flow_loops_dump (loops, dumpfile, NULL, 1);
00109
00110
00111 flow_loops_free (loops);
00112 free (loops);
00113
00114
00115 #ifdef ENABLE_CHECKING
00116 verify_flow_info ();
00117 #endif
00118 }