#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "rtl.h"
#include "hard-reg-set.h"
#include "obstack.h"
#include "basic-block.h"
#include "cfgloop.h"
#include "cfglayout.h"
struct loops *
loop_optimizer_init (FILE *dumpfile)
{
struct loops *loops = xcalloc (1, sizeof (struct loops));
edge e;
edge_iterator ei;
static bool first_time = true;
if (first_time)
{
first_time = false;
init_set_costs ();
}
for (ei = ei_start (EXIT_BLOCK_PTR->preds); (e = ei_safe_edge (ei)); )
if ((e->flags & EDGE_FALLTHRU) && EDGE_COUNT (e->src->succs) > 1)
split_edge (e);
else
ei_next (&ei);
if (flow_loops_find (loops, LOOP_TREE) <= 1)
{
flow_loops_free (loops);
free (loops);
return NULL;
}
free (loops->cfg.rc_order);
loops->cfg.rc_order = NULL;
free (loops->cfg.dfs_order);
loops->cfg.dfs_order = NULL;
create_preheaders (loops, CP_SIMPLE_PREHEADERS);
force_single_succ_latches (loops);
mark_irreducible_loops (loops);
flow_loops_dump (loops, dumpfile, NULL, 1);
#ifdef ENABLE_CHECKING
verify_dominators (CDI_DOMINATORS);
verify_loop_structure (loops);
#endif
return loops;
}
void
loop_optimizer_finalize (struct loops *loops, FILE *dumpfile)
{
unsigned i;
if (!loops)
return;
for (i = 1; i < loops->num; i++)
if (loops->parray[i])
free_simple_loop_desc (loops->parray[i]);
flow_loops_dump (loops, dumpfile, NULL, 1);
flow_loops_free (loops);
free (loops);
#ifdef ENABLE_CHECKING
verify_flow_info ();
#endif
}