]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/domwalk.h
backport: ChangeLog.tuples: ChangeLog from gimple-tuples-branch.
[thirdparty/gcc.git] / gcc / domwalk.h
CommitLineData
6de9cd9a 1/* Generic dominator tree walker
9dcd6f09 2 Copyright (C) 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
6de9cd9a
DN
3 Contributed by Diego Novillo <dnovillo@redhat.com>
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9dcd6f09 9the Free Software Foundation; either version 3, or (at your option)
6de9cd9a
DN
10any later version.
11
12GCC is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
9dcd6f09
NC
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
6de9cd9a 20
ea497bb8
KH
21typedef void *void_p;
22DEF_VEC_P(void_p);
23DEF_VEC_ALLOC_P(void_p,heap);
24
6de9cd9a
DN
25/* This is the main data structure for the dominator walker. It provides
26 the callback hooks as well as a convenient place to hang block local
27 data and pass-global data. */
28
29struct dom_walk_data
30{
454ff5cb 31 /* This is the direction of the dominator tree we want to walk. i.e.,
6de9cd9a
DN
32 if it is set to CDI_DOMINATORS, then we walk the dominator tree,
33 if it is set to CDI_POST_DOMINATORS, then we walk the post
34 dominator tree. */
35 ENUM_BITFIELD (cdi_direction) dom_direction : 2;
36
37 /* Nonzero if the statement walker should walk the statements from
38 last to first within a basic block instead of first to last.
39
40 Note this affects both statement walkers. We haven't yet needed
41 to use the second statement walker for anything, so it's hard to
42 predict if we really need the ability to select their direction
43 independently. */
2fac9c01 44 BOOL_BITFIELD walk_stmts_backward : 1;
6de9cd9a
DN
45
46 /* Function to initialize block local data.
47
48 Note that the dominator walker infrastructure may provide a new
49 fresh, and zero'd block local data structure, or it may re-use an
50 existing block local data structure.
51
52 If the block local structure has items such as virtual arrays, then
53 that allows your optimizer to re-use those arrays rather than
54 creating new ones. */
55 void (*initialize_block_local_data) (struct dom_walk_data *,
56 basic_block, bool);
57
58 /* Function to call before the statement walk occurring before the
59 recursive walk of the dominator children.
60
1f838355 61 This typically initializes a block local data and pushes that
6de9cd9a
DN
62 data onto BLOCK_DATA_STACK. */
63 void (*before_dom_children_before_stmts) (struct dom_walk_data *,
64 basic_block);
65
66 /* Function to call to walk statements before the recursive walk
67 of the dominator children. */
68 void (*before_dom_children_walk_stmts) (struct dom_walk_data *,
726a989a 69 basic_block, gimple_stmt_iterator);
6de9cd9a
DN
70
71 /* Function to call after the statement walk occurring before the
72 recursive walk of the dominator children. */
73 void (*before_dom_children_after_stmts) (struct dom_walk_data *,
74 basic_block);
75
76 /* Function to call before the statement walk occurring after the
77 recursive walk of the dominator children. */
78 void (*after_dom_children_before_stmts) (struct dom_walk_data *,
79 basic_block);
80
81 /* Function to call to walk statements after the recursive walk
82 of the dominator children. */
83 void (*after_dom_children_walk_stmts) (struct dom_walk_data *,
726a989a 84 basic_block, gimple_stmt_iterator);
6de9cd9a
DN
85
86 /* Function to call after the statement walk occurring after the
87 recursive walk of the dominator children.
88
89 This typically finalizes any block local data and pops
90 that data from BLOCK_DATA_STACK. */
91 void (*after_dom_children_after_stmts) (struct dom_walk_data *,
92 basic_block);
93
94 /* Global data for a walk through the dominator tree. */
95 void *global_data;
96
97 /* Stack of any data we need to keep on a per-block basis.
98
99 If you have no local data, then BLOCK_DATA_STACK will be NULL. */
ea497bb8 100 VEC(void_p,heap) *block_data_stack;
6de9cd9a
DN
101
102 /* Size of the block local data. If this is zero, then it is assumed
103 you have no local data and thus no BLOCK_DATA_STACK as well. */
104 size_t block_local_data_size;
105
106 /* From here below are private data. Please do not use this
107 information/data outside domwalk.c. */
108
471854f8 109 /* Stack of available block local structures. */
ea497bb8 110 VEC(void_p,heap) *free_block_data;
0bca51f0
DN
111
112 /* Interesting blocks to process. If this field is not NULL, this
113 set is used to determine which blocks to walk. If we encounter
114 block I in the dominator traversal, but block I is not present in
115 INTERESTING_BLOCKS, then none of the callback functions are
116 invoked on it. This is useful when a particular traversal wants
117 to filter out non-interesting blocks from the dominator tree. */
118 sbitmap interesting_blocks;
6de9cd9a
DN
119};
120
121void walk_dominator_tree (struct dom_walk_data *, basic_block);
122void init_walk_dominator_tree (struct dom_walk_data *);
123void fini_walk_dominator_tree (struct dom_walk_data *);