OSDN Git Service

* bitmap.h (EXECUTE_IF_SET_IN_BITMAP, EXECUTE_IF_AND_COMPL_IN_BITMAP,
[pf3gnuchains/gcc-fork.git] / gcc / basic-block.h
1 /* Define control and data flow tables, and regsets.
2    Copyright (C) 1987, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
3    Free Software Foundation, Inc.
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
10 version.
11
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING.  If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA.  */
21
22 #ifndef GCC_BASIC_BLOCK_H
23 #define GCC_BASIC_BLOCK_H
24
25 #include "bitmap.h"
26 #include "sbitmap.h"
27 #include "varray.h"
28 #include "partition.h"
29 #include "hard-reg-set.h"
30 #include "predict.h"
31
32 /* Head of register set linked list.  */
33 typedef bitmap_head regset_head;
34
35 /* A pointer to a regset_head.  */
36 typedef bitmap regset;
37
38 /* Initialize a new regset.  */
39 #define INIT_REG_SET(HEAD) bitmap_initialize (HEAD, 1)
40
41 /* Clear a register set by freeing up the linked list.  */
42 #define CLEAR_REG_SET(HEAD) bitmap_clear (HEAD)
43
44 /* Copy a register set to another register set.  */
45 #define COPY_REG_SET(TO, FROM) bitmap_copy (TO, FROM)
46
47 /* Compare two register sets.  */
48 #define REG_SET_EQUAL_P(A, B) bitmap_equal_p (A, B)
49
50 /* `and' a register set with a second register set.  */
51 #define AND_REG_SET(TO, FROM) bitmap_operation (TO, TO, FROM, BITMAP_AND)
52
53 /* `and' the complement of a register set with a register set.  */
54 #define AND_COMPL_REG_SET(TO, FROM) \
55   bitmap_operation (TO, TO, FROM, BITMAP_AND_COMPL)
56
57 /* Inclusive or a register set with a second register set.  */
58 #define IOR_REG_SET(TO, FROM) bitmap_operation (TO, TO, FROM, BITMAP_IOR)
59
60 /* Exclusive or a register set with a second register set.  */
61 #define XOR_REG_SET(TO, FROM) bitmap_operation (TO, TO, FROM, BITMAP_XOR)
62
63 /* Or into TO the register set FROM1 `and'ed with the complement of FROM2.  */
64 #define IOR_AND_COMPL_REG_SET(TO, FROM1, FROM2) \
65   bitmap_ior_and_compl (TO, FROM1, FROM2)
66
67 /* Clear a single register in a register set.  */
68 #define CLEAR_REGNO_REG_SET(HEAD, REG) bitmap_clear_bit (HEAD, REG)
69
70 /* Set a single register in a register set.  */
71 #define SET_REGNO_REG_SET(HEAD, REG) bitmap_set_bit (HEAD, REG)
72
73 /* Return true if a register is set in a register set.  */
74 #define REGNO_REG_SET_P(TO, REG) bitmap_bit_p (TO, REG)
75
76 /* Copy the hard registers in a register set to the hard register set.  */
77 extern void reg_set_to_hard_reg_set (HARD_REG_SET *, bitmap);
78 #define REG_SET_TO_HARD_REG_SET(TO, FROM)                               \
79 do {                                                                    \
80   CLEAR_HARD_REG_SET (TO);                                              \
81   reg_set_to_hard_reg_set (&TO, FROM);                                  \
82 } while (0)
83
84 /* Loop over all registers in REGSET, starting with MIN, setting REGNUM to the
85    register number and executing CODE for all registers that are set.  */
86 #define EXECUTE_IF_SET_IN_REG_SET(REGSET, MIN, REGNUM, CODE)            \
87   do                                                                    \
88     {                                                                   \
89       bitmap_iterator bi;                                               \
90                                                                         \
91       EXECUTE_IF_SET_IN_BITMAP (REGSET, MIN, REGNUM, bi)                \
92         {                                                               \
93           CODE;                                                         \
94         }                                                               \
95     } while (0)
96
97 /* Loop over all registers in REGSET1 and REGSET2, starting with MIN, setting
98    REGNUM to the register number and executing CODE for all registers that are
99    set in the first regset and not set in the second.  */
100 #define EXECUTE_IF_AND_COMPL_IN_REG_SET(REGSET1, REGSET2, MIN, REGNUM, CODE) \
101   do                                                                    \
102     {                                                                   \
103       bitmap_iterator bi;                                               \
104                                                                         \
105       EXECUTE_IF_AND_COMPL_IN_BITMAP (REGSET1, REGSET2, MIN, REGNUM, bi) \
106         {                                                               \
107           CODE;                                                         \
108         }                                                               \
109     } while (0)
110
111 /* Loop over all registers in REGSET1 and REGSET2, starting with MIN, setting
112    REGNUM to the register number and executing CODE for all registers that are
113    set in both regsets.  */
114 #define EXECUTE_IF_AND_IN_REG_SET(REGSET1, REGSET2, MIN, REGNUM, CODE) \
115   do                                                                    \
116     {                                                                   \
117       bitmap_iterator bi;                                               \
118                                                                         \
119       EXECUTE_IF_AND_IN_BITMAP (REGSET1, REGSET2, MIN, REGNUM, bi)      \
120         {                                                               \
121           CODE;                                                         \
122         }                                                               \
123     } while (0)
124
125 /* Allocate a register set with oballoc.  */
126 #define OBSTACK_ALLOC_REG_SET(OBSTACK) BITMAP_OBSTACK_ALLOC (OBSTACK)
127
128 /* Initialize a register set.  Returns the new register set.  */
129 #define INITIALIZE_REG_SET(HEAD) bitmap_initialize (&HEAD, 1)
130
131 /* Do any cleanup needed on a regset when it is no longer used.  */
132 #define FREE_REG_SET(REGSET) BITMAP_FREE(REGSET)
133
134 /* Do any one-time initializations needed for regsets.  */
135 #define INIT_ONCE_REG_SET() BITMAP_INIT_ONCE ()
136
137 /* Grow any tables needed when the number of registers is calculated
138    or extended.  For the linked list allocation, nothing needs to
139    be done, other than zero the statistics on the first allocation.  */
140 #define MAX_REGNO_REG_SET(NUM_REGS, NEW_P, RENUMBER_P)
141
142 /* Type we use to hold basic block counters.  Should be at least
143    64bit.  Although a counter cannot be negative, we use a signed
144    type, because erroneous negative counts can be generated when the
145    flow graph is manipulated by various optimizations.  A signed type
146    makes those easy to detect.  */
147 typedef HOST_WIDEST_INT gcov_type;
148
149 /* Control flow edge information.  */
150 struct edge_def GTY((chain_next ("%h.pred_next")))
151 {
152   /* Links through the predecessor and successor lists.  */
153   struct edge_def *pred_next;
154   struct edge_def *succ_next;
155
156   /* The two blocks at the ends of the edge.  */
157   struct basic_block_def *src;
158   struct basic_block_def *dest;
159
160   /* Instructions queued on the edge.  */
161   union edge_def_insns {
162     rtx GTY ((tag ("0"))) r;
163     tree GTY ((tag ("1"))) t;
164   } GTY ((desc ("ir_type ()"))) insns;
165
166   /* Auxiliary info specific to a pass.  */
167   PTR GTY ((skip (""))) aux;
168
169   /* Location of any goto implicit in the edge, during tree-ssa.  */
170   source_locus goto_locus;
171
172   int flags;                    /* see EDGE_* below  */
173   int probability;              /* biased by REG_BR_PROB_BASE */
174   gcov_type count;              /* Expected number of executions calculated
175                                    in profile.c  */
176 };
177
178 typedef struct edge_def *edge;
179
180 #define EDGE_FALLTHRU           1       /* 'Straight line' flow */
181 #define EDGE_ABNORMAL           2       /* Strange flow, like computed
182                                            label, or eh */
183 #define EDGE_ABNORMAL_CALL      4       /* Call with abnormal exit
184                                            like an exception, or sibcall */
185 #define EDGE_EH                 8       /* Exception throw */
186 #define EDGE_FAKE               16      /* Not a real edge (profile.c) */
187 #define EDGE_DFS_BACK           32      /* A backwards edge */
188 #define EDGE_CAN_FALLTHRU       64      /* Candidate for straight line
189                                            flow.  */
190 #define EDGE_IRREDUCIBLE_LOOP   128     /* Part of irreducible loop.  */
191 #define EDGE_SIBCALL            256     /* Edge from sibcall to exit.  */
192 #define EDGE_LOOP_EXIT          512     /* Exit of a loop.  */
193 #define EDGE_TRUE_VALUE         1024    /* Edge taken when controlling
194                                            predicate is nonzero.  */
195 #define EDGE_FALSE_VALUE        2048    /* Edge taken when controlling
196                                            predicate is zero.  */
197 #define EDGE_EXECUTABLE         4096    /* Edge is executable.  Only
198                                            valid during SSA-CCP.  */
199 #define EDGE_CROSSING           8192    /* Edge crosses between hot
200                                            and cold sections, when we
201                                            do partitioning.  */
202 #define EDGE_ALL_FLAGS         16383
203
204 #define EDGE_COMPLEX    (EDGE_ABNORMAL | EDGE_ABNORMAL_CALL | EDGE_EH)
205
206 /* Counter summary from the last set of coverage counts read by
207    profile.c.  */
208 extern const struct gcov_ctr_summary *profile_info;
209
210 /* Declared in cfgloop.h.  */
211 struct loop;
212 struct loops;
213
214 /* Declared in tree-flow.h.  */
215 struct bb_ann_d;
216
217 /* A basic block is a sequence of instructions with only entry and
218    only one exit.  If any one of the instructions are executed, they
219    will all be executed, and in sequence from first to last.
220
221    There may be COND_EXEC instructions in the basic block.  The
222    COND_EXEC *instructions* will be executed -- but if the condition
223    is false the conditionally executed *expressions* will of course
224    not be executed.  We don't consider the conditionally executed
225    expression (which might have side-effects) to be in a separate
226    basic block because the program counter will always be at the same
227    location after the COND_EXEC instruction, regardless of whether the
228    condition is true or not.
229
230    Basic blocks need not start with a label nor end with a jump insn.
231    For example, a previous basic block may just "conditionally fall"
232    into the succeeding basic block, and the last basic block need not
233    end with a jump insn.  Block 0 is a descendant of the entry block.
234
235    A basic block beginning with two labels cannot have notes between
236    the labels.
237
238    Data for jump tables are stored in jump_insns that occur in no
239    basic block even though these insns can follow or precede insns in
240    basic blocks.  */
241
242 /* Basic block information indexed by block number.  */
243 struct basic_block_def GTY((chain_next ("%h.next_bb"), chain_prev ("%h.prev_bb")))
244 {
245   /* The first and last insns of the block.  */
246   rtx head_;
247   rtx end_;
248
249   /* Pointers to the first and last trees of the block.  */
250   tree stmt_list;
251
252   /* The edges into and out of the block.  */
253   edge pred;
254   edge succ;
255
256   /* Liveness info.  */
257
258   /* The registers that are modified within this in block.  */
259   bitmap GTY ((skip (""))) local_set;
260   /* The registers that are conditionally modified within this block.
261      In other words, registers that are set only as part of a
262      COND_EXEC.  */
263   bitmap GTY ((skip (""))) cond_local_set;
264   /* The registers that are live on entry to this block.
265
266      Note that in SSA form, global_live_at_start does not reflect the
267      use of regs in phi functions, since the liveness of these regs
268      may depend on which edge was taken into the block.  */
269   bitmap GTY ((skip (""))) global_live_at_start;
270   /* The registers that are live on exit from this block.  */
271   bitmap GTY ((skip (""))) global_live_at_end;
272
273   /* Auxiliary info specific to a pass.  */
274   PTR GTY ((skip (""))) aux;
275
276   /* Innermost loop containing the block.  */
277   struct loop * GTY ((skip (""))) loop_father;
278
279   /* The dominance and postdominance information node.  */
280   struct et_node * GTY ((skip (""))) dom[2];
281
282   /* Previous and next blocks in the chain.  */
283   struct basic_block_def *prev_bb;
284   struct basic_block_def *next_bb;
285
286   /* The data used by basic block copying and reordering functions.  */
287   struct reorder_block_def * GTY ((skip (""))) rbi;
288
289   /* Annotations used at the tree level.  */
290   struct bb_ann_d *tree_annotations;
291
292   /* Expected number of executions: calculated in profile.c.  */
293   gcov_type count;
294
295   /* The index of this block.  */
296   int index;
297
298   /* The loop depth of this block.  */
299   int loop_depth;
300
301   /* Expected frequency.  Normalized to be in range 0 to BB_FREQ_MAX.  */
302   int frequency;
303
304   /* Various flags.  See BB_* below.  */
305   int flags;
306 };
307
308 typedef struct basic_block_def *basic_block;
309
310 /* Structure to hold information about the blocks during reordering and
311    copying.  */
312
313 typedef struct reorder_block_def
314 {
315   rtx header;
316   rtx footer;
317   basic_block next;
318   basic_block original;
319   /* Used by loop copying.  */
320   basic_block copy;
321   int duplicated;
322   int copy_number;
323
324   /* These fields are used by bb-reorder pass.  */
325   int visited;
326 } *reorder_block_def_p;
327
328 #define BB_FREQ_MAX 10000
329
330 /* Masks for basic_block.flags.  */
331 #define BB_DIRTY                1
332 #define BB_NEW                  2
333 #define BB_REACHABLE            4
334 #define BB_VISITED              8
335 #define BB_IRREDUCIBLE_LOOP     16
336 #define BB_SUPERBLOCK           32
337 #define BB_DISABLE_SCHEDULE     64
338
339 #define BB_HOT_PARTITION        128
340 #define BB_COLD_PARTITION       256
341 #define BB_UNPARTITIONED        0
342
343 /* Partitions, to be used when partitioning hot and cold basic blocks into
344    separate sections.  */
345 #define BB_PARTITION(bb) ((bb)->flags & (BB_HOT_PARTITION|BB_COLD_PARTITION))
346 #define BB_SET_PARTITION(bb, part) do {                                 \
347   basic_block bb_ = (bb);                                               \
348   bb_->flags = ((bb_->flags & ~(BB_HOT_PARTITION|BB_COLD_PARTITION))    \
349                 | (part));                                              \
350 } while (0)
351
352 #define BB_COPY_PARTITION(dstbb, srcbb) \
353   BB_SET_PARTITION (dstbb, BB_PARTITION (srcbb))
354
355 /* Number of basic blocks in the current function.  */
356
357 extern int n_basic_blocks;
358
359 /* First free basic block number.  */
360
361 extern int last_basic_block;
362
363 /* Number of edges in the current function.  */
364
365 extern int n_edges;
366
367 /* Signalize the status of profile information in the CFG.  */
368 extern enum profile_status
369 {
370   PROFILE_ABSENT,
371   PROFILE_GUESSED,
372   PROFILE_READ
373 } profile_status;
374
375 /* Index by basic block number, get basic block struct info.  */
376
377 extern GTY(()) varray_type basic_block_info;
378
379 #define BASIC_BLOCK(N)  (VARRAY_BB (basic_block_info, (N)))
380
381 /* For iterating over basic blocks.  */
382 #define FOR_BB_BETWEEN(BB, FROM, TO, DIR) \
383   for (BB = FROM; BB != TO; BB = BB->DIR)
384
385 #define FOR_EACH_BB(BB) \
386   FOR_BB_BETWEEN (BB, ENTRY_BLOCK_PTR->next_bb, EXIT_BLOCK_PTR, next_bb)
387
388 #define FOR_EACH_BB_REVERSE(BB) \
389   FOR_BB_BETWEEN (BB, EXIT_BLOCK_PTR->prev_bb, ENTRY_BLOCK_PTR, prev_bb)
390
391 /* For iterating over insns in basic block.  */
392 #define FOR_BB_INSNS(BB, INSN)                  \
393   for ((INSN) = BB_HEAD (BB);                   \
394        (INSN) != NEXT_INSN (BB_END (BB));       \
395        (INSN) = NEXT_INSN (INSN))
396
397 #define FOR_BB_INSNS_REVERSE(BB, INSN)          \
398   for ((INSN) = BB_END (BB);                    \
399        (INSN) != PREV_INSN (BB_HEAD (BB));      \
400        (INSN) = PREV_INSN (INSN))
401
402 /* Cycles through _all_ basic blocks, even the fake ones (entry and
403    exit block).  */
404
405 #define FOR_ALL_BB(BB) \
406   for (BB = ENTRY_BLOCK_PTR; BB; BB = BB->next_bb)
407
408 /* What registers are live at the setjmp call.  */
409
410 extern regset regs_live_at_setjmp;
411
412 /* Special labels found during CFG build.  */
413
414 extern GTY(()) rtx label_value_list;
415
416 extern struct obstack flow_obstack;
417
418 /* Indexed by n, gives number of basic block that  (REG n) is used in.
419    If the value is REG_BLOCK_GLOBAL (-2),
420    it means (REG n) is used in more than one basic block.
421    REG_BLOCK_UNKNOWN (-1) means it hasn't been seen yet so we don't know.
422    This information remains valid for the rest of the compilation
423    of the current function; it is used to control register allocation.  */
424
425 #define REG_BLOCK_UNKNOWN -1
426 #define REG_BLOCK_GLOBAL -2
427
428 #define REG_BASIC_BLOCK(N) (VARRAY_REG (reg_n_info, N)->basic_block)
429 \f
430 /* Stuff for recording basic block info.  */
431
432 #define BB_HEAD(B)      (B)->head_
433 #define BB_END(B)       (B)->end_
434
435 /* Special block numbers [markers] for entry and exit.  */
436 #define ENTRY_BLOCK (-1)
437 #define EXIT_BLOCK (-2)
438
439 /* Special block number not valid for any block.  */
440 #define INVALID_BLOCK (-3)
441
442 /* Similarly, block pointers for the edge list.  */
443 extern GTY(()) basic_block ENTRY_BLOCK_PTR;
444 extern GTY(()) basic_block EXIT_BLOCK_PTR;
445
446 #define BLOCK_NUM(INSN)       (BLOCK_FOR_INSN (INSN)->index + 0)
447 #define set_block_for_insn(INSN, BB)  (BLOCK_FOR_INSN (INSN) = BB)
448
449 extern void compute_bb_for_insn (void);
450 extern void free_bb_for_insn (void);
451 extern void update_bb_for_insn (basic_block);
452
453 extern void free_basic_block_vars (void);
454
455 extern void insert_insn_on_edge (rtx, edge);
456 bool safe_insert_insn_on_edge (rtx, edge);
457
458 extern void commit_edge_insertions (void);
459 extern void commit_edge_insertions_watch_calls (void);
460
461 extern void remove_fake_edges (void);
462 extern void remove_fake_exit_edges (void);
463 extern void add_noreturn_fake_exit_edges (void);
464 extern void connect_infinite_loops_to_exit (void);
465 extern edge unchecked_make_edge (basic_block, basic_block, int);
466 extern edge cached_make_edge (sbitmap *, basic_block, basic_block, int);
467 extern edge make_edge (basic_block, basic_block, int);
468 extern edge make_single_succ_edge (basic_block, basic_block, int);
469 extern void remove_edge (edge);
470 extern void redirect_edge_succ (edge, basic_block);
471 extern edge redirect_edge_succ_nodup (edge, basic_block);
472 extern void redirect_edge_pred (edge, basic_block);
473 extern basic_block create_basic_block_structure (rtx, rtx, rtx, basic_block);
474 extern void clear_bb_flags (void);
475 extern void flow_reverse_top_sort_order_compute (int *);
476 extern int flow_depth_first_order_compute (int *, int *);
477 extern void flow_preorder_transversal_compute (int *);
478 extern int dfs_enumerate_from (basic_block, int,
479                                bool (*)(basic_block, void *),
480                                basic_block *, int, void *);
481 extern void compute_dominance_frontiers (bitmap *);
482 extern void dump_edge_info (FILE *, edge, int);
483 extern void brief_dump_cfg (FILE *);
484 extern void clear_edges (void);
485 extern void mark_critical_edges (void);
486 extern rtx first_insn_after_basic_block_note (basic_block);
487
488 /* Structure to group all of the information to process IF-THEN and
489    IF-THEN-ELSE blocks for the conditional execution support.  This
490    needs to be in a public file in case the IFCVT macros call
491    functions passing the ce_if_block data structure.  */
492
493 typedef struct ce_if_block
494 {
495   basic_block test_bb;                  /* First test block.  */
496   basic_block then_bb;                  /* THEN block.  */
497   basic_block else_bb;                  /* ELSE block or NULL.  */
498   basic_block join_bb;                  /* Join THEN/ELSE blocks.  */
499   basic_block last_test_bb;             /* Last bb to hold && or || tests.  */
500   int num_multiple_test_blocks;         /* # of && and || basic blocks.  */
501   int num_and_and_blocks;               /* # of && blocks.  */
502   int num_or_or_blocks;                 /* # of || blocks.  */
503   int num_multiple_test_insns;          /* # of insns in && and || blocks.  */
504   int and_and_p;                        /* Complex test is &&.  */
505   int num_then_insns;                   /* # of insns in THEN block.  */
506   int num_else_insns;                   /* # of insns in ELSE block.  */
507   int pass;                             /* Pass number.  */
508
509 #ifdef IFCVT_EXTRA_FIELDS
510   IFCVT_EXTRA_FIELDS                    /* Any machine dependent fields.  */
511 #endif
512
513 } ce_if_block_t;
514
515 /* This structure maintains an edge list vector.  */
516 struct edge_list
517 {
518   int num_blocks;
519   int num_edges;
520   edge *index_to_edge;
521 };
522
523 /* This is the value which indicates no edge is present.  */
524 #define EDGE_INDEX_NO_EDGE      -1
525
526 /* EDGE_INDEX returns an integer index for an edge, or EDGE_INDEX_NO_EDGE
527    if there is no edge between the 2 basic blocks.  */
528 #define EDGE_INDEX(el, pred, succ) (find_edge_index ((el), (pred), (succ)))
529
530 /* INDEX_EDGE_PRED_BB and INDEX_EDGE_SUCC_BB return a pointer to the basic
531    block which is either the pred or succ end of the indexed edge.  */
532 #define INDEX_EDGE_PRED_BB(el, index)   ((el)->index_to_edge[(index)]->src)
533 #define INDEX_EDGE_SUCC_BB(el, index)   ((el)->index_to_edge[(index)]->dest)
534
535 /* INDEX_EDGE returns a pointer to the edge.  */
536 #define INDEX_EDGE(el, index)           ((el)->index_to_edge[(index)])
537
538 /* Number of edges in the compressed edge list.  */
539 #define NUM_EDGES(el)                   ((el)->num_edges)
540
541 /* BB is assumed to contain conditional jump.  Return the fallthru edge.  */
542 #define FALLTHRU_EDGE(bb)               ((bb)->succ->flags & EDGE_FALLTHRU \
543                                          ? (bb)->succ : (bb)->succ->succ_next)
544
545 /* BB is assumed to contain conditional jump.  Return the branch edge.  */
546 #define BRANCH_EDGE(bb)                 ((bb)->succ->flags & EDGE_FALLTHRU \
547                                          ? (bb)->succ->succ_next : (bb)->succ)
548
549 /* Return expected execution frequency of the edge E.  */
550 #define EDGE_FREQUENCY(e)               (((e)->src->frequency \
551                                           * (e)->probability \
552                                           + REG_BR_PROB_BASE / 2) \
553                                          / REG_BR_PROB_BASE)
554
555 /* Return nonzero if edge is critical.  */
556 #define EDGE_CRITICAL_P(e)              ((e)->src->succ->succ_next \
557                                          && (e)->dest->pred->pred_next)
558
559 struct edge_list * create_edge_list (void);
560 void free_edge_list (struct edge_list *);
561 void print_edge_list (FILE *, struct edge_list *);
562 void verify_edge_list (FILE *, struct edge_list *);
563 int find_edge_index (struct edge_list *, basic_block, basic_block);
564 edge find_edge (basic_block, basic_block);
565
566
567 enum update_life_extent
568 {
569   UPDATE_LIFE_LOCAL = 0,
570   UPDATE_LIFE_GLOBAL = 1,
571   UPDATE_LIFE_GLOBAL_RM_NOTES = 2
572 };
573
574 /* Flags for life_analysis and update_life_info.  */
575
576 #define PROP_DEATH_NOTES        1       /* Create DEAD and UNUSED notes.  */
577 #define PROP_LOG_LINKS          2       /* Create LOG_LINKS.  */
578 #define PROP_REG_INFO           4       /* Update regs_ever_live et al.  */
579 #define PROP_KILL_DEAD_CODE     8       /* Remove dead code.  */
580 #define PROP_SCAN_DEAD_CODE     16      /* Scan for dead code.  */
581 #define PROP_ALLOW_CFG_CHANGES  32      /* Allow the CFG to be changed
582                                            by dead code removal.  */
583 #define PROP_AUTOINC            64      /* Create autoinc mem references.  */
584 #define PROP_EQUAL_NOTES        128     /* Take into account REG_EQUAL notes.  */
585 #define PROP_SCAN_DEAD_STORES   256     /* Scan for dead code.  */
586 #define PROP_ASM_SCAN           512     /* Internal flag used within flow.c
587                                            to flag analysis of asms.  */
588 #define PROP_FINAL              (PROP_DEATH_NOTES | PROP_LOG_LINKS  \
589                                  | PROP_REG_INFO | PROP_KILL_DEAD_CODE  \
590                                  | PROP_SCAN_DEAD_CODE | PROP_AUTOINC \
591                                  | PROP_ALLOW_CFG_CHANGES \
592                                  | PROP_SCAN_DEAD_STORES)
593 #define PROP_POSTRELOAD         (PROP_DEATH_NOTES  \
594                                  | PROP_KILL_DEAD_CODE  \
595                                  | PROP_SCAN_DEAD_CODE | PROP_AUTOINC \
596                                  | PROP_SCAN_DEAD_STORES)
597
598 #define CLEANUP_EXPENSIVE       1       /* Do relatively expensive optimizations
599                                            except for edge forwarding */
600 #define CLEANUP_CROSSJUMP       2       /* Do crossjumping.  */
601 #define CLEANUP_POST_REGSTACK   4       /* We run after reg-stack and need
602                                            to care REG_DEAD notes.  */
603 #define CLEANUP_PRE_LOOP        8       /* Take care to preserve syntactic loop
604                                            notes.  */
605 #define CLEANUP_UPDATE_LIFE     16      /* Keep life information up to date.  */
606 #define CLEANUP_THREADING       32      /* Do jump threading.  */
607 #define CLEANUP_NO_INSN_DEL     64      /* Do not try to delete trivially dead
608                                            insns.  */
609 #define CLEANUP_CFGLAYOUT       128     /* Do cleanup in cfglayout mode.  */
610 #define CLEANUP_LOG_LINKS       256     /* Update log links.  */
611
612 extern void life_analysis (FILE *, int);
613 extern int update_life_info (sbitmap, enum update_life_extent, int);
614 extern int update_life_info_in_dirty_blocks (enum update_life_extent, int);
615 extern int count_or_remove_death_notes (sbitmap, int);
616 extern int propagate_block (basic_block, regset, regset, regset, int);
617
618 struct propagate_block_info;
619 extern rtx propagate_one_insn (struct propagate_block_info *, rtx);
620 extern struct propagate_block_info *init_propagate_block_info
621  (basic_block, regset, regset, regset, int);
622 extern void free_propagate_block_info (struct propagate_block_info *);
623
624 /* In lcm.c */
625 extern struct edge_list *pre_edge_lcm (FILE *, int, sbitmap *, sbitmap *,
626                                        sbitmap *, sbitmap *, sbitmap **,
627                                        sbitmap **);
628 extern struct edge_list *pre_edge_rev_lcm (FILE *, int, sbitmap *,
629                                            sbitmap *, sbitmap *,
630                                            sbitmap *, sbitmap **,
631                                            sbitmap **);
632 extern void compute_available (sbitmap *, sbitmap *, sbitmap *, sbitmap *);
633 extern int optimize_mode_switching (FILE *);
634
635 /* In emit-rtl.c.  */
636 extern rtx emit_block_insn_after (rtx, rtx, basic_block);
637 extern rtx emit_block_insn_before (rtx, rtx, basic_block);
638
639 /* In predict.c */
640 extern void estimate_probability (struct loops *);
641 extern void expected_value_to_br_prob (void);
642 extern bool maybe_hot_bb_p (basic_block);
643 extern bool probably_cold_bb_p (basic_block);
644 extern bool probably_never_executed_bb_p (basic_block);
645 extern bool tree_predicted_by_p (basic_block, enum br_predictor);
646 extern bool rtl_predicted_by_p (basic_block, enum br_predictor);
647 extern void tree_predict_edge (edge, enum br_predictor, int);
648 extern void rtl_predict_edge (edge, enum br_predictor, int);
649 extern void predict_edge_def (edge, enum br_predictor, enum prediction);
650 extern void guess_outgoing_edge_probabilities (basic_block);
651
652 /* In flow.c */
653 extern void init_flow (void);
654 extern void debug_bb (basic_block);
655 extern basic_block debug_bb_n (int);
656 extern void dump_regset (regset, FILE *);
657 extern void debug_regset (regset);
658 extern void allocate_reg_life_data (void);
659 extern void allocate_bb_life_data (void);
660 extern void expunge_block (basic_block);
661 extern void link_block (basic_block, basic_block);
662 extern void unlink_block (basic_block);
663 extern void compact_blocks (void);
664 extern basic_block alloc_block (void);
665 extern void find_unreachable_blocks (void);
666 extern int delete_noop_moves (void);
667 extern basic_block force_nonfallthru (edge);
668 extern rtx block_label (basic_block);
669 extern bool forwarder_block_p (basic_block);
670 extern bool purge_all_dead_edges (int);
671 extern bool purge_dead_edges (basic_block);
672 extern void find_sub_basic_blocks (basic_block);
673 extern void find_many_sub_basic_blocks (sbitmap);
674 extern void rtl_make_eh_edge (sbitmap *, basic_block, rtx);
675 extern bool can_fallthru (basic_block, basic_block);
676 extern bool could_fall_through (basic_block, basic_block);
677 extern void flow_nodes_print (const char *, const sbitmap, FILE *);
678 extern void flow_edge_list_print (const char *, const edge *, int, FILE *);
679 extern void alloc_aux_for_block (basic_block, int);
680 extern void alloc_aux_for_blocks (int);
681 extern void clear_aux_for_blocks (void);
682 extern void free_aux_for_blocks (void);
683 extern void alloc_aux_for_edge (edge, int);
684 extern void alloc_aux_for_edges (int);
685 extern void clear_aux_for_edges (void);
686 extern void free_aux_for_edges (void);
687 extern void find_basic_blocks (rtx, int, FILE *);
688 extern bool cleanup_cfg (int);
689 extern bool delete_unreachable_blocks (void);
690 extern bool merge_seq_blocks (void);
691
692 typedef struct conflict_graph_def *conflict_graph;
693
694 /* Callback function when enumerating conflicts.  The arguments are
695    the smaller and larger regno in the conflict.  Returns zero if
696    enumeration is to continue, nonzero to halt enumeration.  */
697 typedef int (*conflict_graph_enum_fn) (int, int, void *);
698
699
700 /* Prototypes of operations on conflict graphs.  */
701
702 extern conflict_graph conflict_graph_new
703  (int);
704 extern void conflict_graph_delete (conflict_graph);
705 extern int conflict_graph_add (conflict_graph, int, int);
706 extern int conflict_graph_conflict_p (conflict_graph, int, int);
707 extern void conflict_graph_enum (conflict_graph, int, conflict_graph_enum_fn,
708                                  void *);
709 extern void conflict_graph_merge_regs (conflict_graph, int, int);
710 extern void conflict_graph_print (conflict_graph, FILE*);
711 extern conflict_graph conflict_graph_compute (regset, partition);
712 extern bool mark_dfs_back_edges (void);
713 extern void set_edge_can_fallthru_flag (void);
714 extern void update_br_prob_note (basic_block);
715 extern void fixup_abnormal_edges (void);
716 extern bool can_hoist_insn_p (rtx, rtx, regset);
717 extern rtx hoist_insn_after (rtx, rtx, rtx, rtx);
718 extern rtx hoist_insn_to_edge (rtx, edge, rtx, rtx);
719 extern bool inside_basic_block_p (rtx);
720 extern bool control_flow_insn_p (rtx);
721
722 /* In bb-reorder.c */
723 extern void reorder_basic_blocks (unsigned int);
724 extern void partition_hot_cold_basic_blocks (void);
725
726 /* In cfg.c */
727 extern void alloc_rbi_pool (void);
728 extern void initialize_bb_rbi (basic_block bb);
729 extern void free_rbi_pool (void);
730
731 /* In dominance.c */
732
733 enum cdi_direction
734 {
735   CDI_DOMINATORS,
736   CDI_POST_DOMINATORS
737 };
738
739 enum dom_state
740 {
741   DOM_NONE,             /* Not computed at all.  */
742   DOM_CONS_OK,          /* The data is conservatively OK, i.e. if it says you that A dominates B,
743                            it indeed does.  */
744   DOM_NO_FAST_QUERY,    /* The data is OK, but the fast query data are not usable.  */
745   DOM_OK                /* Everything is ok.  */
746 };
747
748 extern enum dom_state dom_computed[2];
749
750 extern void calculate_dominance_info (enum cdi_direction);
751 extern void free_dominance_info (enum cdi_direction);
752 extern basic_block nearest_common_dominator (enum cdi_direction,
753                                              basic_block, basic_block);
754 extern void set_immediate_dominator (enum cdi_direction, basic_block,
755                                      basic_block);
756 extern basic_block get_immediate_dominator (enum cdi_direction, basic_block);
757 extern bool dominated_by_p (enum cdi_direction, basic_block, basic_block);
758 extern int get_dominated_by (enum cdi_direction, basic_block, basic_block **);
759 extern unsigned get_dominated_by_region (enum cdi_direction, basic_block *,
760                                          unsigned, basic_block *);
761 extern void add_to_dominance_info (enum cdi_direction, basic_block);
762 extern void delete_from_dominance_info (enum cdi_direction, basic_block);
763 basic_block recount_dominator (enum cdi_direction, basic_block);
764 extern void redirect_immediate_dominators (enum cdi_direction, basic_block,
765                                            basic_block);
766 extern void iterate_fix_dominators (enum cdi_direction, basic_block *, int);
767 extern void verify_dominators (enum cdi_direction);
768 extern basic_block first_dom_son (enum cdi_direction, basic_block);
769 extern basic_block next_dom_son (enum cdi_direction, basic_block);
770 extern edge try_redirect_by_replacing_jump (edge, basic_block, bool);
771 extern void break_superblocks (void);
772 extern void check_bb_profile (basic_block, FILE *);
773 extern void update_bb_profile_for_threading (basic_block, int, gcov_type, edge);
774
775 #include "cfghooks.h"
776
777 #endif /* GCC_BASIC_BLOCK_H */