xref: /openbsd/gnu/usr.bin/gcc/gcc/basic-block.h (revision c87b03e5)
1*c87b03e5Sespie /* Define control and data flow tables, and regsets.
2*c87b03e5Sespie    Copyright (C) 1987, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3*c87b03e5Sespie    Free Software Foundation, Inc.
4*c87b03e5Sespie 
5*c87b03e5Sespie This file is part of GCC.
6*c87b03e5Sespie 
7*c87b03e5Sespie GCC is free software; you can redistribute it and/or modify it under
8*c87b03e5Sespie the terms of the GNU General Public License as published by the Free
9*c87b03e5Sespie Software Foundation; either version 2, or (at your option) any later
10*c87b03e5Sespie version.
11*c87b03e5Sespie 
12*c87b03e5Sespie GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13*c87b03e5Sespie WARRANTY; without even the implied warranty of MERCHANTABILITY or
14*c87b03e5Sespie FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15*c87b03e5Sespie for more details.
16*c87b03e5Sespie 
17*c87b03e5Sespie You should have received a copy of the GNU General Public License
18*c87b03e5Sespie along with GCC; see the file COPYING.  If not, write to the Free
19*c87b03e5Sespie Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20*c87b03e5Sespie 02111-1307, USA.  */
21*c87b03e5Sespie 
22*c87b03e5Sespie #ifndef GCC_BASIC_BLOCK_H
23*c87b03e5Sespie #define GCC_BASIC_BLOCK_H
24*c87b03e5Sespie 
25*c87b03e5Sespie #include "bitmap.h"
26*c87b03e5Sespie #include "sbitmap.h"
27*c87b03e5Sespie #include "varray.h"
28*c87b03e5Sespie #include "partition.h"
29*c87b03e5Sespie #include "hard-reg-set.h"
30*c87b03e5Sespie 
31*c87b03e5Sespie /* Head of register set linked list.  */
32*c87b03e5Sespie typedef bitmap_head regset_head;
33*c87b03e5Sespie /* A pointer to a regset_head.  */
34*c87b03e5Sespie typedef bitmap regset;
35*c87b03e5Sespie 
36*c87b03e5Sespie /* Initialize a new regset.  */
37*c87b03e5Sespie #define INIT_REG_SET(HEAD) bitmap_initialize (HEAD, 1)
38*c87b03e5Sespie 
39*c87b03e5Sespie /* Clear a register set by freeing up the linked list.  */
40*c87b03e5Sespie #define CLEAR_REG_SET(HEAD) bitmap_clear (HEAD)
41*c87b03e5Sespie 
42*c87b03e5Sespie /* Copy a register set to another register set.  */
43*c87b03e5Sespie #define COPY_REG_SET(TO, FROM) bitmap_copy (TO, FROM)
44*c87b03e5Sespie 
45*c87b03e5Sespie /* Compare two register sets.  */
46*c87b03e5Sespie #define REG_SET_EQUAL_P(A, B) bitmap_equal_p (A, B)
47*c87b03e5Sespie 
48*c87b03e5Sespie /* `and' a register set with a second register set.  */
49*c87b03e5Sespie #define AND_REG_SET(TO, FROM) bitmap_operation (TO, TO, FROM, BITMAP_AND)
50*c87b03e5Sespie 
51*c87b03e5Sespie /* `and' the complement of a register set with a register set.  */
52*c87b03e5Sespie #define AND_COMPL_REG_SET(TO, FROM) \
53*c87b03e5Sespie   bitmap_operation (TO, TO, FROM, BITMAP_AND_COMPL)
54*c87b03e5Sespie 
55*c87b03e5Sespie /* Inclusive or a register set with a second register set.  */
56*c87b03e5Sespie #define IOR_REG_SET(TO, FROM) bitmap_operation (TO, TO, FROM, BITMAP_IOR)
57*c87b03e5Sespie 
58*c87b03e5Sespie /* Exclusive or a register set with a second register set.  */
59*c87b03e5Sespie #define XOR_REG_SET(TO, FROM) bitmap_operation (TO, TO, FROM, BITMAP_XOR)
60*c87b03e5Sespie 
61*c87b03e5Sespie /* Or into TO the register set FROM1 `and'ed with the complement of FROM2.  */
62*c87b03e5Sespie #define IOR_AND_COMPL_REG_SET(TO, FROM1, FROM2) \
63*c87b03e5Sespie   bitmap_ior_and_compl (TO, FROM1, FROM2)
64*c87b03e5Sespie 
65*c87b03e5Sespie /* Clear a single register in a register set.  */
66*c87b03e5Sespie #define CLEAR_REGNO_REG_SET(HEAD, REG) bitmap_clear_bit (HEAD, REG)
67*c87b03e5Sespie 
68*c87b03e5Sespie /* Set a single register in a register set.  */
69*c87b03e5Sespie #define SET_REGNO_REG_SET(HEAD, REG) bitmap_set_bit (HEAD, REG)
70*c87b03e5Sespie 
71*c87b03e5Sespie /* Return true if a register is set in a register set.  */
72*c87b03e5Sespie #define REGNO_REG_SET_P(TO, REG) bitmap_bit_p (TO, REG)
73*c87b03e5Sespie 
74*c87b03e5Sespie /* Copy the hard registers in a register set to the hard register set.  */
75*c87b03e5Sespie extern void reg_set_to_hard_reg_set PARAMS ((HARD_REG_SET *, bitmap));
76*c87b03e5Sespie #define REG_SET_TO_HARD_REG_SET(TO, FROM)				\
77*c87b03e5Sespie do {									\
78*c87b03e5Sespie   CLEAR_HARD_REG_SET (TO);						\
79*c87b03e5Sespie   reg_set_to_hard_reg_set (&TO, FROM);					\
80*c87b03e5Sespie } while (0)
81*c87b03e5Sespie 
82*c87b03e5Sespie /* Loop over all registers in REGSET, starting with MIN, setting REGNUM to the
83*c87b03e5Sespie    register number and executing CODE for all registers that are set.  */
84*c87b03e5Sespie #define EXECUTE_IF_SET_IN_REG_SET(REGSET, MIN, REGNUM, CODE)		\
85*c87b03e5Sespie   EXECUTE_IF_SET_IN_BITMAP (REGSET, MIN, REGNUM, CODE)
86*c87b03e5Sespie 
87*c87b03e5Sespie /* Loop over all registers in REGSET1 and REGSET2, starting with MIN, setting
88*c87b03e5Sespie    REGNUM to the register number and executing CODE for all registers that are
89*c87b03e5Sespie    set in the first regset and not set in the second.  */
90*c87b03e5Sespie #define EXECUTE_IF_AND_COMPL_IN_REG_SET(REGSET1, REGSET2, MIN, REGNUM, CODE) \
91*c87b03e5Sespie   EXECUTE_IF_AND_COMPL_IN_BITMAP (REGSET1, REGSET2, MIN, REGNUM, CODE)
92*c87b03e5Sespie 
93*c87b03e5Sespie /* Loop over all registers in REGSET1 and REGSET2, starting with MIN, setting
94*c87b03e5Sespie    REGNUM to the register number and executing CODE for all registers that are
95*c87b03e5Sespie    set in both regsets.  */
96*c87b03e5Sespie #define EXECUTE_IF_AND_IN_REG_SET(REGSET1, REGSET2, MIN, REGNUM, CODE) \
97*c87b03e5Sespie   EXECUTE_IF_AND_IN_BITMAP (REGSET1, REGSET2, MIN, REGNUM, CODE)
98*c87b03e5Sespie 
99*c87b03e5Sespie /* Allocate a register set with oballoc.  */
100*c87b03e5Sespie #define OBSTACK_ALLOC_REG_SET(OBSTACK) BITMAP_OBSTACK_ALLOC (OBSTACK)
101*c87b03e5Sespie 
102*c87b03e5Sespie /* Initialize a register set.  Returns the new register set.  */
103*c87b03e5Sespie #define INITIALIZE_REG_SET(HEAD) bitmap_initialize (&HEAD, 1)
104*c87b03e5Sespie 
105*c87b03e5Sespie /* Do any cleanup needed on a regset when it is no longer used.  */
106*c87b03e5Sespie #define FREE_REG_SET(REGSET) BITMAP_FREE(REGSET)
107*c87b03e5Sespie 
108*c87b03e5Sespie /* Do any one-time initializations needed for regsets.  */
109*c87b03e5Sespie #define INIT_ONCE_REG_SET() BITMAP_INIT_ONCE ()
110*c87b03e5Sespie 
111*c87b03e5Sespie /* Grow any tables needed when the number of registers is calculated
112*c87b03e5Sespie    or extended.  For the linked list allocation, nothing needs to
113*c87b03e5Sespie    be done, other than zero the statistics on the first allocation.  */
114*c87b03e5Sespie #define MAX_REGNO_REG_SET(NUM_REGS, NEW_P, RENUMBER_P)
115*c87b03e5Sespie 
116*c87b03e5Sespie /* Type we use to hold basic block counters.  Should be at least 64bit.  */
117*c87b03e5Sespie typedef HOST_WIDEST_INT gcov_type;
118*c87b03e5Sespie 
119*c87b03e5Sespie /* Control flow edge information.  */
120*c87b03e5Sespie typedef struct edge_def {
121*c87b03e5Sespie   /* Links through the predecessor and successor lists.  */
122*c87b03e5Sespie   struct edge_def *pred_next, *succ_next;
123*c87b03e5Sespie 
124*c87b03e5Sespie   /* The two blocks at the ends of the edge.  */
125*c87b03e5Sespie   struct basic_block_def *src, *dest;
126*c87b03e5Sespie 
127*c87b03e5Sespie   /* Instructions queued on the edge.  */
128*c87b03e5Sespie   rtx insns;
129*c87b03e5Sespie 
130*c87b03e5Sespie   /* Auxiliary info specific to a pass.  */
131*c87b03e5Sespie   void *aux;
132*c87b03e5Sespie 
133*c87b03e5Sespie   int flags;			/* see EDGE_* below  */
134*c87b03e5Sespie   int probability;		/* biased by REG_BR_PROB_BASE */
135*c87b03e5Sespie   gcov_type count;		/* Expected number of executions calculated
136*c87b03e5Sespie 				   in profile.c  */
137*c87b03e5Sespie } *edge;
138*c87b03e5Sespie 
139*c87b03e5Sespie #define EDGE_FALLTHRU		1	/* 'Straight line' flow */
140*c87b03e5Sespie #define EDGE_ABNORMAL		2	/* Strange flow, like computed
141*c87b03e5Sespie 					   label, or eh */
142*c87b03e5Sespie #define EDGE_ABNORMAL_CALL	4	/* Call with abnormal exit
143*c87b03e5Sespie 					   like an exception, or sibcall */
144*c87b03e5Sespie #define EDGE_EH			8	/* Exception throw */
145*c87b03e5Sespie #define EDGE_FAKE		16	/* Not a real edge (profile.c) */
146*c87b03e5Sespie #define EDGE_DFS_BACK		32	/* A backwards edge */
147*c87b03e5Sespie #define EDGE_CAN_FALLTHRU	64	/* Candidate for straight line
148*c87b03e5Sespie 					   flow.  */
149*c87b03e5Sespie 
150*c87b03e5Sespie #define EDGE_COMPLEX	(EDGE_ABNORMAL | EDGE_ABNORMAL_CALL | EDGE_EH)
151*c87b03e5Sespie 
152*c87b03e5Sespie 
153*c87b03e5Sespie /* A basic block is a sequence of instructions with only entry and
154*c87b03e5Sespie    only one exit.  If any one of the instructions are executed, they
155*c87b03e5Sespie    will all be executed, and in sequence from first to last.
156*c87b03e5Sespie 
157*c87b03e5Sespie    There may be COND_EXEC instructions in the basic block.  The
158*c87b03e5Sespie    COND_EXEC *instructions* will be executed -- but if the condition
159*c87b03e5Sespie    is false the conditionally executed *expressions* will of course
160*c87b03e5Sespie    not be executed.  We don't consider the conditionally executed
161*c87b03e5Sespie    expression (which might have side-effects) to be in a separate
162*c87b03e5Sespie    basic block because the program counter will always be at the same
163*c87b03e5Sespie    location after the COND_EXEC instruction, regardless of whether the
164*c87b03e5Sespie    condition is true or not.
165*c87b03e5Sespie 
166*c87b03e5Sespie    Basic blocks need not start with a label nor end with a jump insn.
167*c87b03e5Sespie    For example, a previous basic block may just "conditionally fall"
168*c87b03e5Sespie    into the succeeding basic block, and the last basic block need not
169*c87b03e5Sespie    end with a jump insn.  Block 0 is a descendant of the entry block.
170*c87b03e5Sespie 
171*c87b03e5Sespie    A basic block beginning with two labels cannot have notes between
172*c87b03e5Sespie    the labels.
173*c87b03e5Sespie 
174*c87b03e5Sespie    Data for jump tables are stored in jump_insns that occur in no
175*c87b03e5Sespie    basic block even though these insns can follow or precede insns in
176*c87b03e5Sespie    basic blocks.  */
177*c87b03e5Sespie 
178*c87b03e5Sespie /* Basic block information indexed by block number.  */
179*c87b03e5Sespie typedef struct basic_block_def {
180*c87b03e5Sespie   /* The first and last insns of the block.  */
181*c87b03e5Sespie   rtx head, end;
182*c87b03e5Sespie 
183*c87b03e5Sespie   /* The first and last trees of the block.  */
184*c87b03e5Sespie   tree head_tree;
185*c87b03e5Sespie   tree end_tree;
186*c87b03e5Sespie 
187*c87b03e5Sespie   /* The edges into and out of the block.  */
188*c87b03e5Sespie   edge pred, succ;
189*c87b03e5Sespie 
190*c87b03e5Sespie   /* Liveness info.  */
191*c87b03e5Sespie 
192*c87b03e5Sespie   /* The registers that are modified within this in block.  */
193*c87b03e5Sespie   regset local_set;
194*c87b03e5Sespie   /* The registers that are conditionally modified within this block.
195*c87b03e5Sespie      In other words, registers that are set only as part of a
196*c87b03e5Sespie      COND_EXEC.  */
197*c87b03e5Sespie   regset cond_local_set;
198*c87b03e5Sespie   /* The registers that are live on entry to this block.
199*c87b03e5Sespie 
200*c87b03e5Sespie      Note that in SSA form, global_live_at_start does not reflect the
201*c87b03e5Sespie      use of regs in phi functions, since the liveness of these regs
202*c87b03e5Sespie      may depend on which edge was taken into the block.  */
203*c87b03e5Sespie   regset global_live_at_start;
204*c87b03e5Sespie   /* The registers that are live on exit from this block.  */
205*c87b03e5Sespie   regset global_live_at_end;
206*c87b03e5Sespie 
207*c87b03e5Sespie   /* Auxiliary info specific to a pass.  */
208*c87b03e5Sespie   void *aux;
209*c87b03e5Sespie 
210*c87b03e5Sespie   /* The index of this block.  */
211*c87b03e5Sespie   int index;
212*c87b03e5Sespie 
213*c87b03e5Sespie   /* Previous and next blocks in the chain.  */
214*c87b03e5Sespie   struct basic_block_def *prev_bb, *next_bb;
215*c87b03e5Sespie 
216*c87b03e5Sespie   /* The loop depth of this block.  */
217*c87b03e5Sespie   int loop_depth;
218*c87b03e5Sespie 
219*c87b03e5Sespie   /* Outermost loop containing the block.  */
220*c87b03e5Sespie   struct loop *loop_father;
221*c87b03e5Sespie 
222*c87b03e5Sespie   /* Expected number of executions: calculated in profile.c.  */
223*c87b03e5Sespie   gcov_type count;
224*c87b03e5Sespie 
225*c87b03e5Sespie   /* Expected frequency.  Normalized to be in range 0 to BB_FREQ_MAX.  */
226*c87b03e5Sespie   int frequency;
227*c87b03e5Sespie 
228*c87b03e5Sespie   /* Various flags.  See BB_* below.  */
229*c87b03e5Sespie   int flags;
230*c87b03e5Sespie } *basic_block;
231*c87b03e5Sespie 
232*c87b03e5Sespie #define BB_FREQ_MAX 10000
233*c87b03e5Sespie 
234*c87b03e5Sespie /* Masks for basic_block.flags.  */
235*c87b03e5Sespie #define BB_DIRTY		1
236*c87b03e5Sespie #define BB_NEW			2
237*c87b03e5Sespie #define BB_REACHABLE		4
238*c87b03e5Sespie #define BB_VISITED		8
239*c87b03e5Sespie 
240*c87b03e5Sespie /* Number of basic blocks in the current function.  */
241*c87b03e5Sespie 
242*c87b03e5Sespie extern int n_basic_blocks;
243*c87b03e5Sespie 
244*c87b03e5Sespie /* First free basic block number.  */
245*c87b03e5Sespie 
246*c87b03e5Sespie extern int last_basic_block;
247*c87b03e5Sespie 
248*c87b03e5Sespie /* Number of edges in the current function.  */
249*c87b03e5Sespie 
250*c87b03e5Sespie extern int n_edges;
251*c87b03e5Sespie 
252*c87b03e5Sespie /* Index by basic block number, get basic block struct info.  */
253*c87b03e5Sespie 
254*c87b03e5Sespie extern varray_type basic_block_info;
255*c87b03e5Sespie 
256*c87b03e5Sespie #define BASIC_BLOCK(N)  (VARRAY_BB (basic_block_info, (N)))
257*c87b03e5Sespie 
258*c87b03e5Sespie /* For iterating over basic blocks.  */
259*c87b03e5Sespie #define FOR_BB_BETWEEN(BB, FROM, TO, DIR) \
260*c87b03e5Sespie   for (BB = FROM; BB != TO; BB = BB->DIR)
261*c87b03e5Sespie 
262*c87b03e5Sespie #define FOR_EACH_BB(BB) \
263*c87b03e5Sespie   FOR_BB_BETWEEN (BB, ENTRY_BLOCK_PTR->next_bb, EXIT_BLOCK_PTR, next_bb)
264*c87b03e5Sespie 
265*c87b03e5Sespie #define FOR_EACH_BB_REVERSE(BB) \
266*c87b03e5Sespie   FOR_BB_BETWEEN (BB, EXIT_BLOCK_PTR->prev_bb, ENTRY_BLOCK_PTR, prev_bb)
267*c87b03e5Sespie 
268*c87b03e5Sespie /* Cycles through _all_ basic blocks, even the fake ones (entry and
269*c87b03e5Sespie    exit block).  */
270*c87b03e5Sespie 
271*c87b03e5Sespie #define FOR_ALL_BB(BB) \
272*c87b03e5Sespie   for (BB = ENTRY_BLOCK_PTR; BB; BB = BB->next_bb)
273*c87b03e5Sespie 
274*c87b03e5Sespie /* What registers are live at the setjmp call.  */
275*c87b03e5Sespie 
276*c87b03e5Sespie extern regset regs_live_at_setjmp;
277*c87b03e5Sespie 
278*c87b03e5Sespie /* Special labels found during CFG build.  */
279*c87b03e5Sespie 
280*c87b03e5Sespie extern GTY(()) rtx label_value_list;
281*c87b03e5Sespie extern GTY(()) rtx tail_recursion_label_list;
282*c87b03e5Sespie 
283*c87b03e5Sespie extern struct obstack flow_obstack;
284*c87b03e5Sespie 
285*c87b03e5Sespie /* Indexed by n, gives number of basic block that  (REG n) is used in.
286*c87b03e5Sespie    If the value is REG_BLOCK_GLOBAL (-2),
287*c87b03e5Sespie    it means (REG n) is used in more than one basic block.
288*c87b03e5Sespie    REG_BLOCK_UNKNOWN (-1) means it hasn't been seen yet so we don't know.
289*c87b03e5Sespie    This information remains valid for the rest of the compilation
290*c87b03e5Sespie    of the current function; it is used to control register allocation.  */
291*c87b03e5Sespie 
292*c87b03e5Sespie #define REG_BLOCK_UNKNOWN -1
293*c87b03e5Sespie #define REG_BLOCK_GLOBAL -2
294*c87b03e5Sespie 
295*c87b03e5Sespie #define REG_BASIC_BLOCK(N) (VARRAY_REG (reg_n_info, N)->basic_block)
296*c87b03e5Sespie 
297*c87b03e5Sespie /* Stuff for recording basic block info.  */
298*c87b03e5Sespie 
299*c87b03e5Sespie #define BLOCK_HEAD(B)      (BASIC_BLOCK (B)->head)
300*c87b03e5Sespie #define BLOCK_END(B)       (BASIC_BLOCK (B)->end)
301*c87b03e5Sespie 
302*c87b03e5Sespie #define BLOCK_HEAD_TREE(B) (BASIC_BLOCK (B)->head_tree)
303*c87b03e5Sespie #define BLOCK_END_TREE(B) (BASIC_BLOCK (B)->end_tree)
304*c87b03e5Sespie 
305*c87b03e5Sespie /* Special block numbers [markers] for entry and exit.  */
306*c87b03e5Sespie #define ENTRY_BLOCK (-1)
307*c87b03e5Sespie #define EXIT_BLOCK (-2)
308*c87b03e5Sespie 
309*c87b03e5Sespie /* Special block number not valid for any block.  */
310*c87b03e5Sespie #define INVALID_BLOCK (-3)
311*c87b03e5Sespie 
312*c87b03e5Sespie /* Similarly, block pointers for the edge list.  */
313*c87b03e5Sespie extern struct basic_block_def entry_exit_blocks[2];
314*c87b03e5Sespie #define ENTRY_BLOCK_PTR	(&entry_exit_blocks[0])
315*c87b03e5Sespie #define EXIT_BLOCK_PTR	(&entry_exit_blocks[1])
316*c87b03e5Sespie 
317*c87b03e5Sespie #define BLOCK_NUM(INSN)	      (BLOCK_FOR_INSN (INSN)->index + 0)
318*c87b03e5Sespie #define set_block_for_insn(INSN, BB)  (BLOCK_FOR_INSN (INSN) = BB)
319*c87b03e5Sespie 
320*c87b03e5Sespie extern void compute_bb_for_insn		PARAMS ((void));
321*c87b03e5Sespie extern void free_bb_for_insn		PARAMS ((void));
322*c87b03e5Sespie extern void update_bb_for_insn		PARAMS ((basic_block));
323*c87b03e5Sespie 
324*c87b03e5Sespie extern void free_basic_block_vars	PARAMS ((int));
325*c87b03e5Sespie 
326*c87b03e5Sespie extern edge split_block			PARAMS ((basic_block, rtx));
327*c87b03e5Sespie extern basic_block split_edge		PARAMS ((edge));
328*c87b03e5Sespie extern void insert_insn_on_edge		PARAMS ((rtx, edge));
329*c87b03e5Sespie 
330*c87b03e5Sespie extern void commit_edge_insertions	PARAMS ((void));
331*c87b03e5Sespie extern void commit_edge_insertions_watch_calls	PARAMS ((void));
332*c87b03e5Sespie 
333*c87b03e5Sespie extern void remove_fake_edges		PARAMS ((void));
334*c87b03e5Sespie extern void add_noreturn_fake_exit_edges	PARAMS ((void));
335*c87b03e5Sespie extern void connect_infinite_loops_to_exit	PARAMS ((void));
336*c87b03e5Sespie extern int flow_call_edges_add		PARAMS ((sbitmap));
337*c87b03e5Sespie extern edge cached_make_edge		PARAMS ((sbitmap *, basic_block,
338*c87b03e5Sespie 						 basic_block, int));
339*c87b03e5Sespie extern edge unchecked_make_edge		PARAMS ((basic_block,
340*c87b03e5Sespie 						 basic_block, int));
341*c87b03e5Sespie extern edge make_edge			PARAMS ((basic_block,
342*c87b03e5Sespie 						 basic_block, int));
343*c87b03e5Sespie extern edge make_single_succ_edge	PARAMS ((basic_block,
344*c87b03e5Sespie 						 basic_block, int));
345*c87b03e5Sespie extern void remove_edge			PARAMS ((edge));
346*c87b03e5Sespie extern void redirect_edge_succ		PARAMS ((edge, basic_block));
347*c87b03e5Sespie extern edge redirect_edge_succ_nodup	PARAMS ((edge, basic_block));
348*c87b03e5Sespie extern void redirect_edge_pred		PARAMS ((edge, basic_block));
349*c87b03e5Sespie extern basic_block create_basic_block_structure PARAMS ((rtx, rtx, rtx, basic_block));
350*c87b03e5Sespie extern basic_block create_basic_block	PARAMS ((rtx, rtx, basic_block));
351*c87b03e5Sespie extern int flow_delete_block		PARAMS ((basic_block));
352*c87b03e5Sespie extern int flow_delete_block_noexpunge	PARAMS ((basic_block));
353*c87b03e5Sespie extern void clear_bb_flags		PARAMS ((void));
354*c87b03e5Sespie extern void merge_blocks_nomove		PARAMS ((basic_block, basic_block));
355*c87b03e5Sespie extern void tidy_fallthru_edge		PARAMS ((edge, basic_block,
356*c87b03e5Sespie 						 basic_block));
357*c87b03e5Sespie extern void tidy_fallthru_edges		PARAMS ((void));
358*c87b03e5Sespie extern void flow_reverse_top_sort_order_compute	PARAMS ((int *));
359*c87b03e5Sespie extern int flow_depth_first_order_compute	PARAMS ((int *, int *));
360*c87b03e5Sespie extern void flow_preorder_transversal_compute	PARAMS ((int *));
361*c87b03e5Sespie extern void dump_edge_info		PARAMS ((FILE *, edge, int));
362*c87b03e5Sespie extern void clear_edges			PARAMS ((void));
363*c87b03e5Sespie extern void mark_critical_edges		PARAMS ((void));
364*c87b03e5Sespie extern rtx first_insn_after_basic_block_note	PARAMS ((basic_block));
365*c87b03e5Sespie 
366*c87b03e5Sespie /* Dominator information for basic blocks.  */
367*c87b03e5Sespie 
368*c87b03e5Sespie typedef struct dominance_info *dominance_info;
369*c87b03e5Sespie 
370*c87b03e5Sespie /* Structure to hold information for each natural loop.  */
371*c87b03e5Sespie struct loop
372*c87b03e5Sespie {
373*c87b03e5Sespie   /* Index into loops array.  */
374*c87b03e5Sespie   int num;
375*c87b03e5Sespie 
376*c87b03e5Sespie   /* Basic block of loop header.  */
377*c87b03e5Sespie   basic_block header;
378*c87b03e5Sespie 
379*c87b03e5Sespie   /* Basic block of loop latch.  */
380*c87b03e5Sespie   basic_block latch;
381*c87b03e5Sespie 
382*c87b03e5Sespie   /* Basic block of loop pre-header or NULL if it does not exist.  */
383*c87b03e5Sespie   basic_block pre_header;
384*c87b03e5Sespie 
385*c87b03e5Sespie   /* Array of edges along the pre-header extended basic block trace.
386*c87b03e5Sespie      The source of the first edge is the root node of pre-header
387*c87b03e5Sespie      extended basic block, if it exists.  */
388*c87b03e5Sespie   edge *pre_header_edges;
389*c87b03e5Sespie 
390*c87b03e5Sespie   /* Number of edges along the pre_header extended basic block trace.  */
391*c87b03e5Sespie   int num_pre_header_edges;
392*c87b03e5Sespie 
393*c87b03e5Sespie   /* The first block in the loop.  This is not necessarily the same as
394*c87b03e5Sespie      the loop header.  */
395*c87b03e5Sespie   basic_block first;
396*c87b03e5Sespie 
397*c87b03e5Sespie   /* The last block in the loop.  This is not necessarily the same as
398*c87b03e5Sespie      the loop latch.  */
399*c87b03e5Sespie   basic_block last;
400*c87b03e5Sespie 
401*c87b03e5Sespie   /* Bitmap of blocks contained within the loop.  */
402*c87b03e5Sespie   sbitmap nodes;
403*c87b03e5Sespie 
404*c87b03e5Sespie   /* Number of blocks contained within the loop.  */
405*c87b03e5Sespie   int num_nodes;
406*c87b03e5Sespie 
407*c87b03e5Sespie   /* Array of edges that enter the loop.  */
408*c87b03e5Sespie   edge *entry_edges;
409*c87b03e5Sespie 
410*c87b03e5Sespie   /* Number of edges that enter the loop.  */
411*c87b03e5Sespie   int num_entries;
412*c87b03e5Sespie 
413*c87b03e5Sespie   /* Array of edges that exit the loop.  */
414*c87b03e5Sespie   edge *exit_edges;
415*c87b03e5Sespie 
416*c87b03e5Sespie   /* Number of edges that exit the loop.  */
417*c87b03e5Sespie   int num_exits;
418*c87b03e5Sespie 
419*c87b03e5Sespie   /* Bitmap of blocks that dominate all exits of the loop.  */
420*c87b03e5Sespie   sbitmap exits_doms;
421*c87b03e5Sespie 
422*c87b03e5Sespie   /* The loop nesting depth.  */
423*c87b03e5Sespie   int depth;
424*c87b03e5Sespie 
425*c87b03e5Sespie   /* Superloops of the loop.  */
426*c87b03e5Sespie   struct loop **pred;
427*c87b03e5Sespie 
428*c87b03e5Sespie   /* The height of the loop (enclosed loop levels) within the loop
429*c87b03e5Sespie      hierarchy tree.  */
430*c87b03e5Sespie   int level;
431*c87b03e5Sespie 
432*c87b03e5Sespie   /* The outer (parent) loop or NULL if outermost loop.  */
433*c87b03e5Sespie   struct loop *outer;
434*c87b03e5Sespie 
435*c87b03e5Sespie   /* The first inner (child) loop or NULL if innermost loop.  */
436*c87b03e5Sespie   struct loop *inner;
437*c87b03e5Sespie 
438*c87b03e5Sespie   /* Link to the next (sibling) loop.  */
439*c87b03e5Sespie   struct loop *next;
440*c87b03e5Sespie 
441*c87b03e5Sespie   /* Nonzero if the loop is invalid (e.g., contains setjmp.).  */
442*c87b03e5Sespie   int invalid;
443*c87b03e5Sespie 
444*c87b03e5Sespie   /* Auxiliary info specific to a pass.  */
445*c87b03e5Sespie   void *aux;
446*c87b03e5Sespie 
447*c87b03e5Sespie   /* The following are currently used by loop.c but they are likely to
448*c87b03e5Sespie      disappear as loop.c is converted to use the CFG.  */
449*c87b03e5Sespie 
450*c87b03e5Sespie   /* Nonzero if the loop has a NOTE_INSN_LOOP_VTOP.  */
451*c87b03e5Sespie   rtx vtop;
452*c87b03e5Sespie 
453*c87b03e5Sespie   /* Nonzero if the loop has a NOTE_INSN_LOOP_CONT.
454*c87b03e5Sespie      A continue statement will generate a branch to NEXT_INSN (cont).  */
455*c87b03e5Sespie   rtx cont;
456*c87b03e5Sespie 
457*c87b03e5Sespie   /* The NOTE_INSN_LOOP_BEG.  */
458*c87b03e5Sespie   rtx start;
459*c87b03e5Sespie 
460*c87b03e5Sespie   /* The NOTE_INSN_LOOP_END.  */
461*c87b03e5Sespie   rtx end;
462*c87b03e5Sespie 
463*c87b03e5Sespie   /* For a rotated loop that is entered near the bottom,
464*c87b03e5Sespie      this is the label at the top.  Otherwise it is zero.  */
465*c87b03e5Sespie   rtx top;
466*c87b03e5Sespie 
467*c87b03e5Sespie   /* Place in the loop where control enters.  */
468*c87b03e5Sespie   rtx scan_start;
469*c87b03e5Sespie 
470*c87b03e5Sespie   /* The position where to sink insns out of the loop.  */
471*c87b03e5Sespie   rtx sink;
472*c87b03e5Sespie 
473*c87b03e5Sespie   /* List of all LABEL_REFs which refer to code labels outside the
474*c87b03e5Sespie      loop.  Used by routines that need to know all loop exits, such as
475*c87b03e5Sespie      final_biv_value and final_giv_value.
476*c87b03e5Sespie 
477*c87b03e5Sespie      This does not include loop exits due to return instructions.
478*c87b03e5Sespie      This is because all bivs and givs are pseudos, and hence must be
479*c87b03e5Sespie      dead after a return, so the presense of a return does not affect
480*c87b03e5Sespie      any of the optimizations that use this info.  It is simpler to
481*c87b03e5Sespie      just not include return instructions on this list.  */
482*c87b03e5Sespie   rtx exit_labels;
483*c87b03e5Sespie 
484*c87b03e5Sespie   /* The number of LABEL_REFs on exit_labels for this loop and all
485*c87b03e5Sespie      loops nested inside it.  */
486*c87b03e5Sespie   int exit_count;
487*c87b03e5Sespie };
488*c87b03e5Sespie 
489*c87b03e5Sespie 
490*c87b03e5Sespie /* Structure to hold CFG information about natural loops within a function.  */
491*c87b03e5Sespie struct loops
492*c87b03e5Sespie {
493*c87b03e5Sespie   /* Number of natural loops in the function.  */
494*c87b03e5Sespie   int num;
495*c87b03e5Sespie 
496*c87b03e5Sespie   /* Maxium nested loop level in the function.  */
497*c87b03e5Sespie   int levels;
498*c87b03e5Sespie 
499*c87b03e5Sespie   /* Array of natural loop descriptors (scanning this array in reverse order
500*c87b03e5Sespie      will find the inner loops before their enclosing outer loops).  */
501*c87b03e5Sespie   struct loop *array;
502*c87b03e5Sespie 
503*c87b03e5Sespie   /* The above array is unused in new loop infrastructure and is kept only for
504*c87b03e5Sespie      purposes of the old loop optimizer.  Instead we store just pointers to
505*c87b03e5Sespie      loops here.  */
506*c87b03e5Sespie   struct loop **parray;
507*c87b03e5Sespie 
508*c87b03e5Sespie   /* Pointer to root of loop heirachy tree.  */
509*c87b03e5Sespie   struct loop *tree_root;
510*c87b03e5Sespie 
511*c87b03e5Sespie   /* Information derived from the CFG.  */
512*c87b03e5Sespie   struct cfg
513*c87b03e5Sespie   {
514*c87b03e5Sespie     /* The bitmap vector of dominators or NULL if not computed.  */
515*c87b03e5Sespie     dominance_info dom;
516*c87b03e5Sespie 
517*c87b03e5Sespie     /* The ordering of the basic blocks in a depth first search.  */
518*c87b03e5Sespie     int *dfs_order;
519*c87b03e5Sespie 
520*c87b03e5Sespie     /* The reverse completion ordering of the basic blocks found in a
521*c87b03e5Sespie        depth first search.  */
522*c87b03e5Sespie     int *rc_order;
523*c87b03e5Sespie   } cfg;
524*c87b03e5Sespie 
525*c87b03e5Sespie   /* Headers shared by multiple loops that should be merged.  */
526*c87b03e5Sespie   sbitmap shared_headers;
527*c87b03e5Sespie };
528*c87b03e5Sespie 
529*c87b03e5Sespie /* Structure to group all of the information to process IF-THEN and
530*c87b03e5Sespie    IF-THEN-ELSE blocks for the conditional execution support.  This
531*c87b03e5Sespie    needs to be in a public file in case the IFCVT macros call
532*c87b03e5Sespie    functions passing the ce_if_block data structure.  */
533*c87b03e5Sespie 
534*c87b03e5Sespie typedef struct ce_if_block
535*c87b03e5Sespie {
536*c87b03e5Sespie   basic_block test_bb;			/* First test block.  */
537*c87b03e5Sespie   basic_block then_bb;			/* THEN block.  */
538*c87b03e5Sespie   basic_block else_bb;			/* ELSE block or NULL.  */
539*c87b03e5Sespie   basic_block join_bb;			/* Join THEN/ELSE blocks.  */
540*c87b03e5Sespie   basic_block last_test_bb;		/* Last bb to hold && or || tests.  */
541*c87b03e5Sespie   int num_multiple_test_blocks;		/* # of && and || basic blocks.  */
542*c87b03e5Sespie   int num_and_and_blocks;		/* # of && blocks.  */
543*c87b03e5Sespie   int num_or_or_blocks;			/* # of || blocks.  */
544*c87b03e5Sespie   int num_multiple_test_insns;		/* # of insns in && and || blocks.  */
545*c87b03e5Sespie   int and_and_p;			/* Complex test is &&.  */
546*c87b03e5Sespie   int num_then_insns;			/* # of insns in THEN block.  */
547*c87b03e5Sespie   int num_else_insns;			/* # of insns in ELSE block.  */
548*c87b03e5Sespie   int pass;				/* Pass number.  */
549*c87b03e5Sespie 
550*c87b03e5Sespie #ifdef IFCVT_EXTRA_FIELDS
551*c87b03e5Sespie   IFCVT_EXTRA_FIELDS			/* Any machine dependent fields.  */
552*c87b03e5Sespie #endif
553*c87b03e5Sespie 
554*c87b03e5Sespie } ce_if_block_t;
555*c87b03e5Sespie 
556*c87b03e5Sespie extern int flow_loops_find PARAMS ((struct loops *, int flags));
557*c87b03e5Sespie extern int flow_loops_update PARAMS ((struct loops *, int flags));
558*c87b03e5Sespie extern void flow_loops_free PARAMS ((struct loops *));
559*c87b03e5Sespie extern void flow_loops_dump PARAMS ((const struct loops *, FILE *,
560*c87b03e5Sespie 				     void (*)(const struct loop *,
561*c87b03e5Sespie 					      FILE *, int), int));
562*c87b03e5Sespie extern void flow_loop_dump PARAMS ((const struct loop *, FILE *,
563*c87b03e5Sespie 				    void (*)(const struct loop *,
564*c87b03e5Sespie 					     FILE *, int), int));
565*c87b03e5Sespie extern int flow_loop_scan PARAMS ((struct loops *, struct loop *, int));
566*c87b03e5Sespie extern void flow_loop_tree_node_add PARAMS ((struct loop *, struct loop *));
567*c87b03e5Sespie extern void flow_loop_tree_node_remove PARAMS ((struct loop *));
568*c87b03e5Sespie 
569*c87b03e5Sespie /* This structure maintains an edge list vector.  */
570*c87b03e5Sespie struct edge_list
571*c87b03e5Sespie {
572*c87b03e5Sespie   int num_blocks;
573*c87b03e5Sespie   int num_edges;
574*c87b03e5Sespie   edge *index_to_edge;
575*c87b03e5Sespie };
576*c87b03e5Sespie 
577*c87b03e5Sespie /* This is the value which indicates no edge is present.  */
578*c87b03e5Sespie #define EDGE_INDEX_NO_EDGE	-1
579*c87b03e5Sespie 
580*c87b03e5Sespie /* EDGE_INDEX returns an integer index for an edge, or EDGE_INDEX_NO_EDGE
581*c87b03e5Sespie    if there is no edge between the 2 basic blocks.  */
582*c87b03e5Sespie #define EDGE_INDEX(el, pred, succ) (find_edge_index ((el), (pred), (succ)))
583*c87b03e5Sespie 
584*c87b03e5Sespie /* INDEX_EDGE_PRED_BB and INDEX_EDGE_SUCC_BB return a pointer to the basic
585*c87b03e5Sespie    block which is either the pred or succ end of the indexed edge.  */
586*c87b03e5Sespie #define INDEX_EDGE_PRED_BB(el, index)	((el)->index_to_edge[(index)]->src)
587*c87b03e5Sespie #define INDEX_EDGE_SUCC_BB(el, index)	((el)->index_to_edge[(index)]->dest)
588*c87b03e5Sespie 
589*c87b03e5Sespie /* INDEX_EDGE returns a pointer to the edge.  */
590*c87b03e5Sespie #define INDEX_EDGE(el, index)           ((el)->index_to_edge[(index)])
591*c87b03e5Sespie 
592*c87b03e5Sespie /* Number of edges in the compressed edge list.  */
593*c87b03e5Sespie #define NUM_EDGES(el)			((el)->num_edges)
594*c87b03e5Sespie 
595*c87b03e5Sespie /* BB is assumed to contain conditional jump.  Return the fallthru edge.  */
596*c87b03e5Sespie #define FALLTHRU_EDGE(bb)		((bb)->succ->flags & EDGE_FALLTHRU \
597*c87b03e5Sespie 					 ? (bb)->succ : (bb)->succ->succ_next)
598*c87b03e5Sespie 
599*c87b03e5Sespie /* BB is assumed to contain conditional jump.  Return the branch edge.  */
600*c87b03e5Sespie #define BRANCH_EDGE(bb)			((bb)->succ->flags & EDGE_FALLTHRU \
601*c87b03e5Sespie 					 ? (bb)->succ->succ_next : (bb)->succ)
602*c87b03e5Sespie 
603*c87b03e5Sespie /* Return expected execution frequency of the edge E.  */
604*c87b03e5Sespie #define EDGE_FREQUENCY(e)		(((e)->src->frequency \
605*c87b03e5Sespie 					  * (e)->probability \
606*c87b03e5Sespie 					  + REG_BR_PROB_BASE / 2) \
607*c87b03e5Sespie 					 / REG_BR_PROB_BASE)
608*c87b03e5Sespie 
609*c87b03e5Sespie /* Return nonzero if edge is critical.  */
610*c87b03e5Sespie #define EDGE_CRITICAL_P(e)		((e)->src->succ->succ_next \
611*c87b03e5Sespie 					 && (e)->dest->pred->pred_next)
612*c87b03e5Sespie 
613*c87b03e5Sespie struct edge_list * create_edge_list	PARAMS ((void));
614*c87b03e5Sespie void free_edge_list			PARAMS ((struct edge_list *));
615*c87b03e5Sespie void print_edge_list			PARAMS ((FILE *, struct edge_list *));
616*c87b03e5Sespie void verify_edge_list			PARAMS ((FILE *, struct edge_list *));
617*c87b03e5Sespie int find_edge_index			PARAMS ((struct edge_list *,
618*c87b03e5Sespie 						 basic_block, basic_block));
619*c87b03e5Sespie 
620*c87b03e5Sespie 
621*c87b03e5Sespie enum update_life_extent
622*c87b03e5Sespie {
623*c87b03e5Sespie   UPDATE_LIFE_LOCAL = 0,
624*c87b03e5Sespie   UPDATE_LIFE_GLOBAL = 1,
625*c87b03e5Sespie   UPDATE_LIFE_GLOBAL_RM_NOTES = 2
626*c87b03e5Sespie };
627*c87b03e5Sespie 
628*c87b03e5Sespie /* Flags for life_analysis and update_life_info.  */
629*c87b03e5Sespie 
630*c87b03e5Sespie #define PROP_DEATH_NOTES	1	/* Create DEAD and UNUSED notes.  */
631*c87b03e5Sespie #define PROP_LOG_LINKS		2	/* Create LOG_LINKS.  */
632*c87b03e5Sespie #define PROP_REG_INFO		4	/* Update regs_ever_live et al.  */
633*c87b03e5Sespie #define PROP_KILL_DEAD_CODE	8	/* Remove dead code.  */
634*c87b03e5Sespie #define PROP_SCAN_DEAD_CODE	16	/* Scan for dead code.  */
635*c87b03e5Sespie #define PROP_ALLOW_CFG_CHANGES	32	/* Allow the CFG to be changed
636*c87b03e5Sespie 					   by dead code removal.  */
637*c87b03e5Sespie #define PROP_AUTOINC		64	/* Create autoinc mem references.  */
638*c87b03e5Sespie #define PROP_EQUAL_NOTES	128	/* Take into account REG_EQUAL notes.  */
639*c87b03e5Sespie #define PROP_SCAN_DEAD_STORES	256	/* Scan for dead code.  */
640*c87b03e5Sespie #define PROP_FINAL		(PROP_DEATH_NOTES | PROP_LOG_LINKS  \
641*c87b03e5Sespie 				 | PROP_REG_INFO | PROP_KILL_DEAD_CODE  \
642*c87b03e5Sespie 				 | PROP_SCAN_DEAD_CODE | PROP_AUTOINC \
643*c87b03e5Sespie 				 | PROP_ALLOW_CFG_CHANGES \
644*c87b03e5Sespie 				 | PROP_SCAN_DEAD_STORES)
645*c87b03e5Sespie 
646*c87b03e5Sespie #define CLEANUP_EXPENSIVE	1	/* Do relativly expensive optimizations
647*c87b03e5Sespie 					   except for edge forwarding */
648*c87b03e5Sespie #define CLEANUP_CROSSJUMP	2	/* Do crossjumping.  */
649*c87b03e5Sespie #define CLEANUP_POST_REGSTACK	4	/* We run after reg-stack and need
650*c87b03e5Sespie 					   to care REG_DEAD notes.  */
651*c87b03e5Sespie #define CLEANUP_PRE_SIBCALL	8	/* Do not get confused by code hidden
652*c87b03e5Sespie 					   inside call_placeholders..  */
653*c87b03e5Sespie #define CLEANUP_PRE_LOOP	16	/* Take care to preserve syntactic loop
654*c87b03e5Sespie 					   notes.  */
655*c87b03e5Sespie #define CLEANUP_UPDATE_LIFE	32	/* Keep life information up to date.  */
656*c87b03e5Sespie #define CLEANUP_THREADING	64	/* Do jump threading.  */
657*c87b03e5Sespie #define CLEANUP_NO_INSN_DEL	128	/* Do not try to delete trivially dead
658*c87b03e5Sespie 					   insns.  */
659*c87b03e5Sespie /* Flags for loop discovery.  */
660*c87b03e5Sespie 
661*c87b03e5Sespie #define LOOP_TREE		1	/* Build loop hierarchy tree.  */
662*c87b03e5Sespie #define LOOP_PRE_HEADER		2	/* Analyse loop pre-header.  */
663*c87b03e5Sespie #define LOOP_ENTRY_EDGES	4	/* Find entry edges.  */
664*c87b03e5Sespie #define LOOP_EXIT_EDGES		8	/* Find exit edges.  */
665*c87b03e5Sespie #define LOOP_EDGES		(LOOP_ENTRY_EDGES | LOOP_EXIT_EDGES)
666*c87b03e5Sespie #define LOOP_ALL	       15	/* All of the above  */
667*c87b03e5Sespie 
668*c87b03e5Sespie extern void life_analysis	PARAMS ((rtx, FILE *, int));
669*c87b03e5Sespie extern int update_life_info	PARAMS ((sbitmap, enum update_life_extent,
670*c87b03e5Sespie 					 int));
671*c87b03e5Sespie extern int update_life_info_in_dirty_blocks PARAMS ((enum update_life_extent,
672*c87b03e5Sespie 						      int));
673*c87b03e5Sespie extern int count_or_remove_death_notes	PARAMS ((sbitmap, int));
674*c87b03e5Sespie extern int propagate_block	PARAMS ((basic_block, regset, regset, regset,
675*c87b03e5Sespie 					 int));
676*c87b03e5Sespie 
677*c87b03e5Sespie struct propagate_block_info;
678*c87b03e5Sespie extern rtx propagate_one_insn	PARAMS ((struct propagate_block_info *, rtx));
679*c87b03e5Sespie extern struct propagate_block_info *init_propagate_block_info
680*c87b03e5Sespie   PARAMS ((basic_block, regset, regset, regset, int));
681*c87b03e5Sespie extern void free_propagate_block_info PARAMS ((struct propagate_block_info *));
682*c87b03e5Sespie 
683*c87b03e5Sespie /* In lcm.c */
684*c87b03e5Sespie extern struct edge_list *pre_edge_lcm	PARAMS ((FILE *, int, sbitmap *,
685*c87b03e5Sespie 						 sbitmap *, sbitmap *,
686*c87b03e5Sespie 						 sbitmap *, sbitmap **,
687*c87b03e5Sespie 						 sbitmap **));
688*c87b03e5Sespie extern struct edge_list *pre_edge_rev_lcm PARAMS ((FILE *, int, sbitmap *,
689*c87b03e5Sespie 						   sbitmap *, sbitmap *,
690*c87b03e5Sespie 						   sbitmap *, sbitmap **,
691*c87b03e5Sespie 						   sbitmap **));
692*c87b03e5Sespie extern void compute_available		PARAMS ((sbitmap *, sbitmap *,
693*c87b03e5Sespie 						 sbitmap *, sbitmap *));
694*c87b03e5Sespie extern int optimize_mode_switching	PARAMS ((FILE *));
695*c87b03e5Sespie 
696*c87b03e5Sespie /* In emit-rtl.c.  */
697*c87b03e5Sespie extern rtx emit_block_insn_after	PARAMS ((rtx, rtx, basic_block));
698*c87b03e5Sespie extern rtx emit_block_insn_before	PARAMS ((rtx, rtx, basic_block));
699*c87b03e5Sespie 
700*c87b03e5Sespie /* In predict.c */
701*c87b03e5Sespie extern void estimate_probability        PARAMS ((struct loops *));
702*c87b03e5Sespie extern void note_prediction_to_br_prob	PARAMS ((void));
703*c87b03e5Sespie extern void expected_value_to_br_prob	PARAMS ((void));
704*c87b03e5Sespie extern void note_prediction_to_br_prob	PARAMS ((void));
705*c87b03e5Sespie extern bool maybe_hot_bb_p		PARAMS ((basic_block));
706*c87b03e5Sespie extern bool probably_cold_bb_p		PARAMS ((basic_block));
707*c87b03e5Sespie extern bool probably_never_executed_bb_p PARAMS ((basic_block));
708*c87b03e5Sespie 
709*c87b03e5Sespie /* In flow.c */
710*c87b03e5Sespie extern void init_flow                   PARAMS ((void));
711*c87b03e5Sespie extern void reorder_basic_blocks	PARAMS ((void));
712*c87b03e5Sespie extern void dump_bb			PARAMS ((basic_block, FILE *));
713*c87b03e5Sespie extern void debug_bb			PARAMS ((basic_block));
714*c87b03e5Sespie extern void debug_bb_n			PARAMS ((int));
715*c87b03e5Sespie extern void dump_regset			PARAMS ((regset, FILE *));
716*c87b03e5Sespie extern void debug_regset		PARAMS ((regset));
717*c87b03e5Sespie extern void allocate_reg_life_data      PARAMS ((void));
718*c87b03e5Sespie extern void allocate_bb_life_data	PARAMS ((void));
719*c87b03e5Sespie extern void expunge_block		PARAMS ((basic_block));
720*c87b03e5Sespie extern void link_block			PARAMS ((basic_block, basic_block));
721*c87b03e5Sespie extern void unlink_block		PARAMS ((basic_block));
722*c87b03e5Sespie extern void compact_blocks		PARAMS ((void));
723*c87b03e5Sespie extern basic_block alloc_block		PARAMS ((void));
724*c87b03e5Sespie extern void find_unreachable_blocks	PARAMS ((void));
725*c87b03e5Sespie extern int delete_noop_moves		PARAMS ((rtx));
726*c87b03e5Sespie extern basic_block redirect_edge_and_branch_force PARAMS ((edge, basic_block));
727*c87b03e5Sespie extern basic_block force_nonfallthru	PARAMS ((edge));
728*c87b03e5Sespie extern bool redirect_edge_and_branch	PARAMS ((edge, basic_block));
729*c87b03e5Sespie extern rtx block_label			PARAMS ((basic_block));
730*c87b03e5Sespie extern bool forwarder_block_p		PARAMS ((basic_block));
731*c87b03e5Sespie extern bool purge_all_dead_edges	PARAMS ((int));
732*c87b03e5Sespie extern bool purge_dead_edges		PARAMS ((basic_block));
733*c87b03e5Sespie extern void find_sub_basic_blocks	PARAMS ((basic_block));
734*c87b03e5Sespie extern void find_many_sub_basic_blocks	PARAMS ((sbitmap));
735*c87b03e5Sespie extern bool can_fallthru		PARAMS ((basic_block, basic_block));
736*c87b03e5Sespie extern void flow_nodes_print		PARAMS ((const char *, const sbitmap,
737*c87b03e5Sespie 						 FILE *));
738*c87b03e5Sespie extern void flow_edge_list_print	PARAMS ((const char *, const edge *,
739*c87b03e5Sespie 						 int, FILE *));
740*c87b03e5Sespie extern void alloc_aux_for_block		PARAMS ((basic_block, int));
741*c87b03e5Sespie extern void alloc_aux_for_blocks	PARAMS ((int));
742*c87b03e5Sespie extern void clear_aux_for_blocks	PARAMS ((void));
743*c87b03e5Sespie extern void free_aux_for_blocks		PARAMS ((void));
744*c87b03e5Sespie extern void alloc_aux_for_edge		PARAMS ((edge, int));
745*c87b03e5Sespie extern void alloc_aux_for_edges		PARAMS ((int));
746*c87b03e5Sespie extern void clear_aux_for_edges		PARAMS ((void));
747*c87b03e5Sespie extern void free_aux_for_edges		PARAMS ((void));
748*c87b03e5Sespie 
749*c87b03e5Sespie /* This function is always defined so it can be called from the
750*c87b03e5Sespie    debugger, and it is declared extern so we don't get warnings about
751*c87b03e5Sespie    it being unused.  */
752*c87b03e5Sespie extern void verify_flow_info		PARAMS ((void));
753*c87b03e5Sespie extern bool flow_loop_outside_edge_p	PARAMS ((const struct loop *, edge));
754*c87b03e5Sespie extern bool flow_loop_nested_p		PARAMS ((const struct loop *,
755*c87b03e5Sespie 						 const struct loop *));
756*c87b03e5Sespie extern bool flow_bb_inside_loop_p	PARAMS ((const struct loop *,
757*c87b03e5Sespie 						 const basic_block));
758*c87b03e5Sespie extern basic_block *get_loop_body       PARAMS ((const struct loop *));
759*c87b03e5Sespie extern int dfs_enumerate_from           PARAMS ((basic_block, int,
760*c87b03e5Sespie 				         bool (*)(basic_block, void *),
761*c87b03e5Sespie 					 basic_block *, int, void *));
762*c87b03e5Sespie 
763*c87b03e5Sespie extern edge loop_preheader_edge PARAMS ((struct loop *));
764*c87b03e5Sespie extern edge loop_latch_edge PARAMS ((struct loop *));
765*c87b03e5Sespie 
766*c87b03e5Sespie extern void add_bb_to_loop PARAMS ((basic_block, struct loop *));
767*c87b03e5Sespie extern void remove_bb_from_loops PARAMS ((basic_block));
768*c87b03e5Sespie extern struct loop * find_common_loop PARAMS ((struct loop *, struct loop *));
769*c87b03e5Sespie 
770*c87b03e5Sespie extern void verify_loop_structure PARAMS ((struct loops *, int));
771*c87b03e5Sespie #define VLS_EXPECT_PREHEADERS 1
772*c87b03e5Sespie #define VLS_EXPECT_SIMPLE_LATCHES 2
773*c87b03e5Sespie 
774*c87b03e5Sespie typedef struct conflict_graph_def *conflict_graph;
775*c87b03e5Sespie 
776*c87b03e5Sespie /* Callback function when enumerating conflicts.  The arguments are
777*c87b03e5Sespie    the smaller and larger regno in the conflict.  Returns zero if
778*c87b03e5Sespie    enumeration is to continue, nonzero to halt enumeration.  */
779*c87b03e5Sespie typedef int (*conflict_graph_enum_fn) PARAMS ((int, int, void *));
780*c87b03e5Sespie 
781*c87b03e5Sespie 
782*c87b03e5Sespie /* Prototypes of operations on conflict graphs.  */
783*c87b03e5Sespie 
784*c87b03e5Sespie extern conflict_graph conflict_graph_new
785*c87b03e5Sespie                                         PARAMS ((int));
786*c87b03e5Sespie extern void conflict_graph_delete       PARAMS ((conflict_graph));
787*c87b03e5Sespie extern int conflict_graph_add           PARAMS ((conflict_graph,
788*c87b03e5Sespie 						 int, int));
789*c87b03e5Sespie extern int conflict_graph_conflict_p    PARAMS ((conflict_graph,
790*c87b03e5Sespie 						 int, int));
791*c87b03e5Sespie extern void conflict_graph_enum         PARAMS ((conflict_graph, int,
792*c87b03e5Sespie 						 conflict_graph_enum_fn,
793*c87b03e5Sespie 						 void *));
794*c87b03e5Sespie extern void conflict_graph_merge_regs   PARAMS ((conflict_graph, int,
795*c87b03e5Sespie 						 int));
796*c87b03e5Sespie extern void conflict_graph_print        PARAMS ((conflict_graph, FILE*));
797*c87b03e5Sespie extern conflict_graph conflict_graph_compute
798*c87b03e5Sespie                                         PARAMS ((regset,
799*c87b03e5Sespie 						 partition));
800*c87b03e5Sespie extern bool mark_dfs_back_edges		PARAMS ((void));
801*c87b03e5Sespie extern void set_edge_can_fallthru_flag	PARAMS ((void));
802*c87b03e5Sespie extern void update_br_prob_note		PARAMS ((basic_block));
803*c87b03e5Sespie extern void fixup_abnormal_edges	PARAMS ((void));
804*c87b03e5Sespie extern bool can_hoist_insn_p		PARAMS ((rtx, rtx, regset));
805*c87b03e5Sespie extern rtx hoist_insn_after		PARAMS ((rtx, rtx, rtx, rtx));
806*c87b03e5Sespie extern rtx hoist_insn_to_edge		PARAMS ((rtx, edge, rtx, rtx));
807*c87b03e5Sespie extern bool control_flow_insn_p		PARAMS ((rtx));
808*c87b03e5Sespie 
809*c87b03e5Sespie /* In dominance.c */
810*c87b03e5Sespie 
811*c87b03e5Sespie enum cdi_direction
812*c87b03e5Sespie {
813*c87b03e5Sespie   CDI_DOMINATORS,
814*c87b03e5Sespie   CDI_POST_DOMINATORS
815*c87b03e5Sespie };
816*c87b03e5Sespie 
817*c87b03e5Sespie extern dominance_info calculate_dominance_info	PARAMS ((enum cdi_direction));
818*c87b03e5Sespie extern void free_dominance_info			PARAMS ((dominance_info));
819*c87b03e5Sespie extern basic_block nearest_common_dominator	PARAMS ((dominance_info,
820*c87b03e5Sespie 						 basic_block, basic_block));
821*c87b03e5Sespie extern void set_immediate_dominator	PARAMS ((dominance_info,
822*c87b03e5Sespie 						 basic_block, basic_block));
823*c87b03e5Sespie extern basic_block get_immediate_dominator	PARAMS ((dominance_info,
824*c87b03e5Sespie 						 basic_block));
825*c87b03e5Sespie extern bool dominated_by_p	PARAMS ((dominance_info, basic_block, basic_block));
826*c87b03e5Sespie extern int get_dominated_by PARAMS ((dominance_info, basic_block, basic_block **));
827*c87b03e5Sespie extern void add_to_dominance_info PARAMS ((dominance_info, basic_block));
828*c87b03e5Sespie extern void delete_from_dominance_info PARAMS ((dominance_info, basic_block));
829*c87b03e5Sespie basic_block recount_dominator PARAMS ((dominance_info, basic_block));
830*c87b03e5Sespie extern void redirect_immediate_dominators PARAMS ((dominance_info, basic_block,
831*c87b03e5Sespie 						 basic_block));
832*c87b03e5Sespie void iterate_fix_dominators PARAMS ((dominance_info, basic_block *, int));
833*c87b03e5Sespie extern void verify_dominators PARAMS ((dominance_info));
834*c87b03e5Sespie #endif /* GCC_BASIC_BLOCK_H */
835