hppa: Fix LO_SUM DLTIND14R address support in PRINT_OPERAND_ADDRESS
[official-gcc.git] / gcc / analyzer / trimmed-graph.h
blob07d5c4dee0f8c21ac45fc231fdc6262ca865d6fc
1 /* Trimming an exploded graph to a subset of nodes and edges.
2 Copyright (C) 2021-2024 Free Software Foundation, Inc.
3 Contributed by David Malcolm <dmalcolm@redhat.com>.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
12 GCC is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #ifndef GCC_ANALYZER_TRIMMED_GRAPH_H
22 #define GCC_ANALYZER_TRIMMED_GRAPH_H
24 namespace ana {
26 /* Forward decls. */
28 class trimmed_node;
29 class trimmed_edge;
30 class trimmed_graph;
31 class trimmed_cluster;
33 /* A traits class for trimming a digraph to a subset of nodes and edges. */
35 struct tg_traits
37 typedef trimmed_node node_t;
38 typedef trimmed_edge edge_t;
39 typedef trimmed_graph graph_t;
40 struct dump_args_t
42 typedef typename eg_traits::dump_args_t inner_args_t;
44 dump_args_t (const inner_args_t &inner_args)
45 : m_inner_args (inner_args)
49 const inner_args_t &m_inner_args;
51 typedef trimmed_cluster cluster_t;
54 /* A node within the trimmed_graph, corresponding to an "inner node"
55 within the original exploded_graph. */
57 class trimmed_node : public dnode<tg_traits>
59 public:
60 trimmed_node (const exploded_node *inner_node)
61 : m_inner_node (inner_node) {}
63 void dump_dot (graphviz_out *gv,
64 const dump_args_t &args) const final override;
66 private:
67 const exploded_node *m_inner_node;
70 /* An edge within the trimmed_graph, corresponding to an "inner edge"
71 within the original exploded_graph. */
73 class trimmed_edge : public dedge<tg_traits>
75 public:
76 trimmed_edge (trimmed_node *src, trimmed_node *dest,
77 const exploded_edge *inner_edge);
79 void dump_dot (graphviz_out *gv,
80 const dump_args_t &args) const final override;
82 private:
83 const exploded_edge *m_inner_edge;
86 /* A digraph for trimming an exploded_graph to the subset of nodes and edges
87 from which paths reach INNER_DST_NODE (along with a precanned way to print
88 these in .dot form). */
90 class trimmed_graph : public digraph <tg_traits>
92 public:
93 trimmed_graph (const exploded_graph &inner_graph,
94 const exploded_node *inner_dst_node);
96 bool contains_p (const exploded_edge *eedge) const
98 hash_set <const exploded_edge *> & mut
99 = const_cast <hash_set <const exploded_edge *> &> (m_eedges);
100 return mut.contains (eedge);
103 void log_stats (logger *logger) const;
105 private:
106 /* The subset of nodes in the inner graph that are in the
107 trimmed graph. */
108 hash_set <const exploded_node *> m_enodes;
109 /* Likewise for edges. */
110 hash_set <const exploded_edge *> m_eedges;
112 typedef hash_map<const exploded_node *, trimmed_node *> map_t;
113 map_t m_map_from_enode_to_tnode;
116 class trimmed_cluster : public cluster <tg_traits>
120 } // namespace ana
122 #endif /* GCC_ANALYZER_TRIMMED_GRAPH_H */