annotate gcc/domwalk.h @ 16:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents 77e2b8dfacca
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 /* Generic dominator tree walker
16
kono
parents: 9
diff changeset
2 Copyright (C) 2003-2017 Free Software Foundation, Inc.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 Contributed by Diego Novillo <dnovillo@redhat.com>
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 This file is part of GCC.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 GCC is free software; you can redistribute it and/or modify
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 it under the terms of the GNU General Public License as published by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 the Free Software Foundation; either version 3, or (at your option)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 any later version.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 GCC is distributed in the hope that it will be useful,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 GNU General Public License for more details.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 along with GCC; see the file COPYING3. If not see
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20
16
kono
parents: 9
diff changeset
21 #ifndef GCC_DOM_WALK_H
kono
parents: 9
diff changeset
22 #define GCC_DOM_WALK_H
kono
parents: 9
diff changeset
23
kono
parents: 9
diff changeset
24 /**
kono
parents: 9
diff changeset
25 * This is the main class for the dominator walker. It is expected that
kono
parents: 9
diff changeset
26 * consumers will have a custom class inheriting from it, which will over ride
kono
parents: 9
diff changeset
27 * at least one of before_dom_children and after_dom_children to implement the
kono
parents: 9
diff changeset
28 * custom behavior.
kono
parents: 9
diff changeset
29 */
kono
parents: 9
diff changeset
30 class dom_walker
kono
parents: 9
diff changeset
31 {
kono
parents: 9
diff changeset
32 public:
kono
parents: 9
diff changeset
33 static const edge STOP;
kono
parents: 9
diff changeset
34
kono
parents: 9
diff changeset
35 /* Use SKIP_UNREACHBLE_BLOCKS = true when your client can discover
kono
parents: 9
diff changeset
36 that some edges are not executable.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37
16
kono
parents: 9
diff changeset
38 If a client can discover that a COND, SWITCH or GOTO has a static
kono
parents: 9
diff changeset
39 target in the before_dom_children callback, the taken edge should
kono
parents: 9
diff changeset
40 be returned. The generic walker will clear EDGE_EXECUTABLE on all
kono
parents: 9
diff changeset
41 edges it can determine are not executable.
kono
parents: 9
diff changeset
42
kono
parents: 9
diff changeset
43 You can provide a mapping of basic-block index to RPO if you
kono
parents: 9
diff changeset
44 have that readily available or you do multiple walks. */
kono
parents: 9
diff changeset
45 dom_walker (cdi_direction direction, bool skip_unreachable_blocks = false,
kono
parents: 9
diff changeset
46 int *bb_index_to_rpo = NULL);
kono
parents: 9
diff changeset
47
kono
parents: 9
diff changeset
48 ~dom_walker ();
kono
parents: 9
diff changeset
49
kono
parents: 9
diff changeset
50 /* Walk the dominator tree. */
kono
parents: 9
diff changeset
51 void walk (basic_block);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52
16
kono
parents: 9
diff changeset
53 /* Function to call before the recursive walk of the dominator children.
kono
parents: 9
diff changeset
54
kono
parents: 9
diff changeset
55 Return value is the always taken edge if the block has multiple outgoing
kono
parents: 9
diff changeset
56 edges, NULL otherwise. When skipping unreachable blocks, the walker
kono
parents: 9
diff changeset
57 uses the taken edge information to clear EDGE_EXECUTABLE on the other
kono
parents: 9
diff changeset
58 edges, exposing unreachable blocks. A NULL return value means all
kono
parents: 9
diff changeset
59 outgoing edges should still be considered executable. A return value
kono
parents: 9
diff changeset
60 of STOP means to stop the domwalk from processing dominated blocks from
kono
parents: 9
diff changeset
61 here. This can be used to process a SEME region only (note domwalk
kono
parents: 9
diff changeset
62 will still do work linear in function size). */
kono
parents: 9
diff changeset
63 virtual edge before_dom_children (basic_block) { return NULL; }
kono
parents: 9
diff changeset
64
kono
parents: 9
diff changeset
65 /* Function to call after the recursive walk of the dominator children. */
kono
parents: 9
diff changeset
66 virtual void after_dom_children (basic_block) {}
kono
parents: 9
diff changeset
67
kono
parents: 9
diff changeset
68 private:
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 /* This is the direction of the dominator tree we want to walk. i.e.,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 if it is set to CDI_DOMINATORS, then we walk the dominator tree,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 if it is set to CDI_POST_DOMINATORS, then we walk the post
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 dominator tree. */
16
kono
parents: 9
diff changeset
73 const ENUM_BITFIELD (cdi_direction) m_dom_direction : 2;
kono
parents: 9
diff changeset
74 bool m_skip_unreachable_blocks;
kono
parents: 9
diff changeset
75 bool m_user_bb_to_rpo;
kono
parents: 9
diff changeset
76 basic_block m_unreachable_dom;
kono
parents: 9
diff changeset
77 int *m_bb_to_rpo;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78
16
kono
parents: 9
diff changeset
79 /* Query whether or not the given block is reachable or not. */
kono
parents: 9
diff changeset
80 bool bb_reachable (struct function *, basic_block);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81
16
kono
parents: 9
diff changeset
82 /* Given an unreachable block, propagate that property to outgoing
kono
parents: 9
diff changeset
83 and possibly incoming edges for the block. Typically called after
kono
parents: 9
diff changeset
84 determining a block is unreachable in the before_dom_children
kono
parents: 9
diff changeset
85 callback. */
kono
parents: 9
diff changeset
86 void propagate_unreachable_to_edges (basic_block, FILE *, dump_flags_t);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
87
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 };
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
89
16
kono
parents: 9
diff changeset
90 #endif