]>
Commit | Line | Data |
---|---|---|
e9751143 | 1 | /* Measuring the complexity of svalues/regions. |
99dee823 | 2 | Copyright (C) 2020-2021 Free Software Foundation, Inc. |
e9751143 DM |
3 | Contributed by David Malcolm <dmalcolm@redhat.com>. |
4 | ||
5 | This file is part of GCC. | |
6 | ||
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. | |
11 | ||
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. | |
16 | ||
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/>. */ | |
20 | ||
21 | #include "config.h" | |
22 | #include "system.h" | |
23 | #include "coretypes.h" | |
24 | #include "tree.h" | |
25 | #include "diagnostic-core.h" | |
26 | #include "gimple-pretty-print.h" | |
27 | #include "function.h" | |
28 | #include "basic-block.h" | |
29 | #include "gimple.h" | |
30 | #include "gimple-iterator.h" | |
31 | #include "diagnostic-core.h" | |
32 | #include "graphviz.h" | |
33 | #include "options.h" | |
34 | #include "cgraph.h" | |
35 | #include "tree-dfa.h" | |
36 | #include "stringpool.h" | |
37 | #include "convert.h" | |
38 | #include "target.h" | |
39 | #include "fold-const.h" | |
40 | #include "tree-pretty-print.h" | |
41 | #include "tristate.h" | |
42 | #include "bitmap.h" | |
43 | #include "selftest.h" | |
44 | #include "function.h" | |
45 | #include "json.h" | |
46 | #include "analyzer/analyzer.h" | |
47 | #include "analyzer/analyzer-logging.h" | |
48 | #include "options.h" | |
49 | #include "cgraph.h" | |
50 | #include "cfg.h" | |
51 | #include "digraph.h" | |
52 | #include "analyzer/call-string.h" | |
53 | #include "analyzer/program-point.h" | |
54 | #include "analyzer/store.h" | |
55 | #include "analyzer/complexity.h" | |
56 | #include "analyzer/svalue.h" | |
57 | #include "analyzer/region.h" | |
58 | ||
59 | #if ENABLE_ANALYZER | |
60 | ||
61 | namespace ana { | |
62 | ||
63 | /* struct complexity. */ | |
64 | ||
65 | /* Get complexity for a new node that references REG | |
66 | (the complexity of REG, plus one for the new node). */ | |
67 | ||
68 | complexity::complexity (const region *reg) | |
69 | : m_num_nodes (reg->get_complexity ().m_num_nodes + 1), | |
70 | m_max_depth (reg->get_complexity ().m_max_depth + 1) | |
71 | { | |
72 | } | |
73 | ||
74 | /* Get complexity for a new node that references SVAL. | |
75 | (the complexity of SVAL, plus one for the new node). */ | |
76 | ||
77 | complexity::complexity (const svalue *sval) | |
78 | : m_num_nodes (sval->get_complexity ().m_num_nodes + 1), | |
79 | m_max_depth (sval->get_complexity ().m_max_depth + 1) | |
80 | { | |
81 | } | |
82 | ||
83 | /* Get complexity for a new node that references nodes with complexity | |
84 | C1 and C2. */ | |
85 | ||
86 | complexity | |
87 | complexity::from_pair (const complexity &c1, const complexity &c2) | |
88 | { | |
89 | return complexity (c1.m_num_nodes + c2.m_num_nodes + 1, | |
90 | MAX (c1.m_max_depth, c2.m_max_depth) + 1); | |
91 | } | |
92 | ||
93 | } // namespace ana | |
94 | ||
95 | #endif /* #if ENABLE_ANALYZER */ |