diff options
author | Mariam Arutunian <mariamarutunian@gmail.com> | 2022-11-11 16:22:58 +0400 |
---|---|---|
committer | Jeff Law <jlaw@ventanamicro> | 2023-03-21 09:03:17 -0600 |
commit | 49d77f4ef166755a7da2b8c26ed89231c0c44c83 (patch) | |
tree | c4588bab878f64a7dafd3af547c0ffb57759d232 | |
parent | ffc3c645da55beea809e558a6dc203115b3ac269 (diff) | |
download | gcc-49d77f4ef166755a7da2b8c26ed89231c0c44c83.tar.gz |
Traverse and execute CRC function v1: - Added get_function_local_ssa_vars and make_symbolic_function_arguments_and_sizes functions.
-rw-r--r-- | gcc/Makefile.in | 1 | ||||
-rw-r--r-- | gcc/symb-execute-all-paths.cc | 89 | ||||
-rw-r--r-- | gcc/symb-execute-all-paths.h | 45 |
3 files changed, 135 insertions, 0 deletions
diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 48043b0a450..d67213d0d2d 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1647,6 +1647,7 @@ OBJS = \ tree-iterator.o \ tree-logical-location.o \ tree-loop-distribution.o \ + symb-execute-all-paths.o \ gimple-crc-optimization.o \ sym-exec/expression.o \ sym-exec/state.o \ diff --git a/gcc/symb-execute-all-paths.cc b/gcc/symb-execute-all-paths.cc new file mode 100644 index 00000000000..117d27367c5 --- /dev/null +++ b/gcc/symb-execute-all-paths.cc @@ -0,0 +1,89 @@ +/* + Execute symbolically all paths of the function. Iterate loops only onceā¤ + Copyright (C) 2006-2022 Free Software Foundation, Inc. + +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 "symb-execute-all-paths.h" +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "backend.h" +#include "tree.h" +#include "gimple.h" +#include "tree-pass.h" +#include "ssa.h" +#include "gimple-iterator.h" +#include "tree-cfg.h" +#include "tree-ssa-loop-niter.h" +#include "cfgloop.h" +#include "gimple-range.h" +#include "tree-scalar-evolution.h" +#include "hwint.h" +#include "gimple-pretty-print.h" +#include "function.h" + +void get_function_local_ssa_vars (function *fun) +{ + unsigned ix; + tree name; + // get ssa names of the function, yet print sizes and names + FOR_EACH_SSA_NAME (ix, name, fun) + { + if (TREE_CODE (TREE_TYPE (name)) == INTEGER_TYPE) + { + if (TYPE_UNSIGNED (TREE_TYPE (name))) + { + if (dump_file) + fprintf (dump_file, + "unsigned "); //we need this info in symb execution + } + if (dump_file) + fprintf (dump_file, " size is %ld ", + tree_to_shwi (TYPE_SIZE (TREE_TYPE (name)))); + } else if (TREE_CODE (TREE_TYPE (name)) == POINTER_TYPE) + { + if (dump_file) + fprintf (stderr, "pointer type size is %ld ", + tree_to_shwi (TYPE_SIZE (TREE_TYPE (name)))); + } else + continue; + if (dump_file) + { + print_generic_expr (dump_file, name, dump_flags); + fprintf (dump_file, "\n"); + } + } +} + +void make_symbolic_function_arguments_and_sizes (function *fun) +{ + // Get size and name of function's arguments + for (tree arg = DECL_ARGUMENTS (fun->decl); arg; arg = DECL_CHAIN (arg)) + { + if (TREE_CODE (DECL_SIZE (arg)) == INTEGER_CST && DECL_NAME (arg)) + { + if (dump_file) + fprintf (dump_file, "%s : %ld ", + IDENTIFIER_POINTER (DECL_NAME (arg)), + tree_to_shwi (DECL_SIZE (arg))); + } else + if (dump_file) + fprintf (dump_file, "Argument not const or no name"); + } +} + diff --git a/gcc/symb-execute-all-paths.h b/gcc/symb-execute-all-paths.h new file mode 100644 index 00000000000..88e72d52cdf --- /dev/null +++ b/gcc/symb-execute-all-paths.h @@ -0,0 +1,45 @@ +/* + Execute symbolically all paths of the function. Iterate loops only once. + Copyright (C) 2006-2022 Free Software Foundation, Inc. + +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/>. */ + +#ifndef GCC_EXECUTE_ALL_PATHS_H +#define GCC_EXECUTE_ALL_PATHS_H + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "backend.h" +#include "tree.h" +#include "gimple.h" +#include "tree-pass.h" +#include "ssa.h" +#include "gimple-iterator.h" +#include "tree-cfg.h" +#include "tree-ssa-loop-niter.h" +#include "cfgloop.h" +#include "gimple-range.h" +#include "tree-scalar-evolution.h" +#include "hwint.h" +#include "function.h" + +void get_function_local_ssa_vars (function *); + +void make_symbolic_function_arguments_and_sizes (function *); + +#endif //GCC_EXECUTE_ALL_PATHS_H |