OSDN Git Service

* tree-inline.c (find_builtin_longjmp_call): Save and restore
[pf3gnuchains/gcc-fork.git] / gcc / loop-init.c
1 /* Loop optimizer initialization routines.
2    Copyright (C) 2002, 2003 Free Software Foundation, Inc.
3
4 This file is part of GCC.
5
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
9 version.
10
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING.  If not, write to the Free
18 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19 02111-1307, USA.  */
20
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "tm.h"
25 #include "rtl.h"
26 #include "hard-reg-set.h"
27 #include "basic-block.h"
28 #include "cfgloop.h"
29 #include "cfglayout.h"
30 #include "gcov-io.h"
31 #include "profile.h"
32
33 /* Initialize loop optimizer.  */
34
35 struct loops *
36 loop_optimizer_init (dumpfile)
37      FILE *dumpfile;
38 {
39   struct loops *loops = xcalloc (1, sizeof (struct loops));
40   edge e;
41
42   /* Avoid annoying special cases of edges going to exit
43      block.  */
44   for (e = EXIT_BLOCK_PTR->pred; e; e = e->pred_next)
45     if ((e->flags & EDGE_FALLTHRU) && e->src->succ->succ_next)
46       split_edge (e);
47
48   /* Find the loops.  */
49
50   if (flow_loops_find (loops, LOOP_TREE) <= 1)
51     {
52       /* No loops.  */
53       flow_loops_free (loops);
54       free (loops);
55       return NULL;
56     }
57
58   /* Not going to update these.  */
59   free (loops->cfg.rc_order);
60   loops->cfg.rc_order = NULL;
61   free (loops->cfg.dfs_order);
62   loops->cfg.dfs_order = NULL;
63
64   /* Initialize structures for layout changes.  */
65   cfg_layout_initialize (loops);
66
67   /* Create pre-headers.  */
68   create_preheaders (loops, CP_SIMPLE_PREHEADERS | CP_INSIDE_CFGLAYOUT);
69
70   /* Force all latches to have only single successor.  */
71   force_single_succ_latches (loops);
72
73   /* Mark irreducible loops.  */
74   mark_irreducible_loops (loops);
75
76   /* Dump loops.  */
77   flow_loops_dump (loops, dumpfile, NULL, 1);
78
79 #ifdef ENABLE_CHECKING
80   verify_dominators (loops->cfg.dom);
81   verify_loop_structure (loops);
82 #endif
83
84   return loops;
85 }
86
87 /* Finalize loop optimizer.  */
88 void
89 loop_optimizer_finalize (loops, dumpfile)
90      struct loops *loops;
91      FILE *dumpfile;
92 {
93   basic_block bb;
94
95   /* Finalize layout changes.  */
96   /* Make chain.  */
97   FOR_EACH_BB (bb)
98     if (bb->next_bb != EXIT_BLOCK_PTR)
99       RBI (bb)->next = bb->next_bb;
100
101   /* Another dump.  */
102   flow_loops_dump (loops, dumpfile, NULL, 1);
103
104   /* Clean up.  */
105   flow_loops_free (loops);
106   free (loops);
107  
108   /* Finalize changes.  */
109   cfg_layout_finalize ();
110
111   /* Checking.  */
112 #ifdef ENABLE_CHECKING
113   verify_flow_info ();
114 #endif
115 }
116