comparison gcc/domwalk.h @ 16:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents 77e2b8dfacca
children 84e7813d76e9
comparison
equal deleted inserted replaced
15:561a7518be6b 16:04ced10e8804
1 /* Generic dominator tree walker 1 /* Generic dominator tree walker
2 Copyright (C) 2003, 2004, 2005, 2007, 2008 Free Software Foundation, Inc. 2 Copyright (C) 2003-2017 Free Software Foundation, Inc.
3 Contributed by Diego Novillo <dnovillo@redhat.com> 3 Contributed by Diego Novillo <dnovillo@redhat.com>
4 4
5 This file is part of GCC. 5 This file is part of GCC.
6 6
7 GCC is free software; you can redistribute it and/or modify 7 GCC is free software; you can redistribute it and/or modify
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see 18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */ 19 <http://www.gnu.org/licenses/>. */
20 20
21 typedef void *void_p; 21 #ifndef GCC_DOM_WALK_H
22 DEF_VEC_P(void_p); 22 #define GCC_DOM_WALK_H
23 DEF_VEC_ALLOC_P(void_p,heap);
24 23
25 /* This is the main data structure for the dominator walker. It provides 24 /**
26 the callback hooks as well as a convenient place to hang block local 25 * This is the main class for the dominator walker. It is expected that
27 data and pass-global data. */ 26 * consumers will have a custom class inheriting from it, which will over ride
27 * at least one of before_dom_children and after_dom_children to implement the
28 * custom behavior.
29 */
30 class dom_walker
31 {
32 public:
33 static const edge STOP;
28 34
29 struct dom_walk_data 35 /* Use SKIP_UNREACHBLE_BLOCKS = true when your client can discover
30 { 36 that some edges are not executable.
37
38 If a client can discover that a COND, SWITCH or GOTO has a static
39 target in the before_dom_children callback, the taken edge should
40 be returned. The generic walker will clear EDGE_EXECUTABLE on all
41 edges it can determine are not executable.
42
43 You can provide a mapping of basic-block index to RPO if you
44 have that readily available or you do multiple walks. */
45 dom_walker (cdi_direction direction, bool skip_unreachable_blocks = false,
46 int *bb_index_to_rpo = NULL);
47
48 ~dom_walker ();
49
50 /* Walk the dominator tree. */
51 void walk (basic_block);
52
53 /* Function to call before the recursive walk of the dominator children.
54
55 Return value is the always taken edge if the block has multiple outgoing
56 edges, NULL otherwise. When skipping unreachable blocks, the walker
57 uses the taken edge information to clear EDGE_EXECUTABLE on the other
58 edges, exposing unreachable blocks. A NULL return value means all
59 outgoing edges should still be considered executable. A return value
60 of STOP means to stop the domwalk from processing dominated blocks from
61 here. This can be used to process a SEME region only (note domwalk
62 will still do work linear in function size). */
63 virtual edge before_dom_children (basic_block) { return NULL; }
64
65 /* Function to call after the recursive walk of the dominator children. */
66 virtual void after_dom_children (basic_block) {}
67
68 private:
31 /* This is the direction of the dominator tree we want to walk. i.e., 69 /* This is the direction of the dominator tree we want to walk. i.e.,
32 if it is set to CDI_DOMINATORS, then we walk the dominator tree, 70 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 71 if it is set to CDI_POST_DOMINATORS, then we walk the post
34 dominator tree. */ 72 dominator tree. */
35 ENUM_BITFIELD (cdi_direction) dom_direction : 2; 73 const ENUM_BITFIELD (cdi_direction) m_dom_direction : 2;
74 bool m_skip_unreachable_blocks;
75 bool m_user_bb_to_rpo;
76 basic_block m_unreachable_dom;
77 int *m_bb_to_rpo;
36 78
37 /* Function to initialize block local data. 79 /* Query whether or not the given block is reachable or not. */
80 bool bb_reachable (struct function *, basic_block);
38 81
39 Note that the dominator walker infrastructure may provide a new 82 /* Given an unreachable block, propagate that property to outgoing
40 fresh, and zero'd block local data structure, or it may re-use an 83 and possibly incoming edges for the block. Typically called after
41 existing block local data structure. 84 determining a block is unreachable in the before_dom_children
85 callback. */
86 void propagate_unreachable_to_edges (basic_block, FILE *, dump_flags_t);
42 87
43 If the block local structure has items such as virtual arrays, then
44 that allows your optimizer to re-use those arrays rather than
45 creating new ones. */
46 void (*initialize_block_local_data) (struct dom_walk_data *,
47 basic_block, bool);
48
49 /* Function to call before the recursive walk of the dominator children. */
50 void (*before_dom_children) (struct dom_walk_data *, basic_block);
51
52 /* Function to call after the recursive walk of the dominator children. */
53 void (*after_dom_children) (struct dom_walk_data *, basic_block);
54
55 /* Global data for a walk through the dominator tree. */
56 void *global_data;
57
58 /* Stack of any data we need to keep on a per-block basis.
59
60 If you have no local data, then BLOCK_DATA_STACK will be NULL. */
61 VEC(void_p,heap) *block_data_stack;
62
63 /* Size of the block local data. If this is zero, then it is assumed
64 you have no local data and thus no BLOCK_DATA_STACK as well. */
65 size_t block_local_data_size;
66
67 /* From here below are private data. Please do not use this
68 information/data outside domwalk.c. */
69
70 /* Stack of available block local structures. */
71 VEC(void_p,heap) *free_block_data;
72 }; 88 };
73 89
74 void walk_dominator_tree (struct dom_walk_data *, basic_block); 90 #endif
75 void init_walk_dominator_tree (struct dom_walk_data *);
76 void fini_walk_dominator_tree (struct dom_walk_data *);