diff options
author | David Malcolm <dmalcolm@redhat.com> | 2020-10-28 20:09:04 -0400 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2020-10-28 20:09:04 -0400 |
commit | e9751143e237b507a81234a573a200ea45e7111a (patch) | |
tree | 67c5ae2a3112bd02c8b4aa98f8287251481a3e3a /gcc/analyzer/complexity.cc | |
parent | 0a36f5f21cd9dcaaf99e78d2ec995d6cb2918274 (diff) | |
download | gcc-e9751143e237b507a81234a573a200ea45e7111a.zip gcc-e9751143e237b507a81234a573a200ea45e7111a.tar.gz gcc-e9751143e237b507a81234a573a200ea45e7111a.tar.bz2 |
analyzer: move svalue and region decls to their own header files
gcc/ChangeLog:
* Makefile.in (ANALYZER_OBJS): Add analyzer/complexity.o.
gcc/analyzer/ChangeLog:
* analyzer.h (class state_machine): New forward decl.
(class logger): Likewise.
(class visitor): Likewise.
* complexity.cc: New file, taken from svalue.cc.
* complexity.h: New file, taken from region-model.h.
* region-model.h: Include "analyzer/svalue.h" and
"analyzer/region.h". Move struct complexity to complexity.h.
Move svalue, its subclasses and supporting decls to svalue.h.
Move region, its subclasses and supporting decls to region.h.
* region.cc: Include "analyzer/region.h".
(symbolic_region::symbolic_region): Move here from region-model.h.
* region.h: New file, based on material from region-model.h.
* svalue.cc: Include "analyzer/svalue.h".
(complexity::complexity): Move to complexity.cc.
(complexity::from_pair): Likewise.
* svalue.h: New file, based on material from region-model.h.
Diffstat (limited to 'gcc/analyzer/complexity.cc')
-rw-r--r-- | gcc/analyzer/complexity.cc | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/gcc/analyzer/complexity.cc b/gcc/analyzer/complexity.cc new file mode 100644 index 0000000..221f3a6 --- /dev/null +++ b/gcc/analyzer/complexity.cc @@ -0,0 +1,95 @@ +/* Measuring the complexity of svalues/regions. + Copyright (C) 2020 Free Software Foundation, Inc. + Contributed by David Malcolm <dmalcolm@redhat.com>. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tree.h" +#include "diagnostic-core.h" +#include "gimple-pretty-print.h" +#include "function.h" +#include "basic-block.h" +#include "gimple.h" +#include "gimple-iterator.h" +#include "diagnostic-core.h" +#include "graphviz.h" +#include "options.h" +#include "cgraph.h" +#include "tree-dfa.h" +#include "stringpool.h" +#include "convert.h" +#include "target.h" +#include "fold-const.h" +#include "tree-pretty-print.h" +#include "tristate.h" +#include "bitmap.h" +#include "selftest.h" +#include "function.h" +#include "json.h" +#include "analyzer/analyzer.h" +#include "analyzer/analyzer-logging.h" +#include "options.h" +#include "cgraph.h" +#include "cfg.h" +#include "digraph.h" +#include "analyzer/call-string.h" +#include "analyzer/program-point.h" +#include "analyzer/store.h" +#include "analyzer/complexity.h" +#include "analyzer/svalue.h" +#include "analyzer/region.h" + +#if ENABLE_ANALYZER + +namespace ana { + +/* struct complexity. */ + +/* Get complexity for a new node that references REG + (the complexity of REG, plus one for the new node). */ + +complexity::complexity (const region *reg) +: m_num_nodes (reg->get_complexity ().m_num_nodes + 1), + m_max_depth (reg->get_complexity ().m_max_depth + 1) +{ +} + +/* Get complexity for a new node that references SVAL. + (the complexity of SVAL, plus one for the new node). */ + +complexity::complexity (const svalue *sval) +: m_num_nodes (sval->get_complexity ().m_num_nodes + 1), + m_max_depth (sval->get_complexity ().m_max_depth + 1) +{ +} + +/* Get complexity for a new node that references nodes with complexity + C1 and C2. */ + +complexity +complexity::from_pair (const complexity &c1, const complexity &c2) +{ + return complexity (c1.m_num_nodes + c2.m_num_nodes + 1, + MAX (c1.m_max_depth, c2.m_max_depth) + 1); +} + +} // namespace ana + +#endif /* #if ENABLE_ANALYZER */ |