diff options
author | Ian Lance Taylor <iant@golang.org> | 2021-09-13 10:37:49 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2021-09-13 10:37:49 -0700 |
commit | e252b51ccde010cbd2a146485d8045103cd99533 (patch) | |
tree | e060f101cdc32bf5e520de8e5275db9d4236b74c /gcc/value-pointer-equiv.h | |
parent | f10c7c4596dda99d2ee872c995ae4aeda65adbdf (diff) | |
parent | 104c05c5284b7822d770ee51a7d91946c7e56d50 (diff) | |
download | gcc-e252b51ccde010cbd2a146485d8045103cd99533.zip gcc-e252b51ccde010cbd2a146485d8045103cd99533.tar.gz gcc-e252b51ccde010cbd2a146485d8045103cd99533.tar.bz2 |
Merge from trunk revision 104c05c5284b7822d770ee51a7d91946c7e56d50.
Diffstat (limited to 'gcc/value-pointer-equiv.h')
-rw-r--r-- | gcc/value-pointer-equiv.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/gcc/value-pointer-equiv.h b/gcc/value-pointer-equiv.h new file mode 100644 index 0000000..0921579 --- /dev/null +++ b/gcc/value-pointer-equiv.h @@ -0,0 +1,62 @@ +/* Header file for the context-aware pointer equivalence tracker. + Copyright (C) 2020-2021 Free Software Foundation, Inc. + Contributed by Aldy Hernandez <aldyh@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/>. */ + +#ifndef GCC_VALUE_POINTER_EQUIV_H +#define GCC_VALUE_POINTER_EQUIV_H + +// Simple context-aware pointer equivalency analyzer that returns what +// a pointer SSA name is equivalent to at a given point during a walk +// of the IL. +// +// Note that global equivalency take priority over conditional +// equivalency. That is, p = &q takes priority over a later p == &t. +// +// This class is meant to be called during a DOM walk. + +class pointer_equiv_analyzer +{ +public: + pointer_equiv_analyzer (gimple_ranger *r); + ~pointer_equiv_analyzer (); + void enter (basic_block); + void leave (basic_block); + void visit_stmt (gimple *stmt); + tree get_equiv (tree ssa) const; + +private: + void visit_edge (edge e); + tree get_equiv_expr (tree_code code, tree expr) const; + void set_global_equiv (tree ssa, tree pointee); + void set_cond_equiv (tree ssa, tree pointee); + + gimple_ranger *m_ranger; + // Global pointer equivalency indexed by SSA_NAME_VERSION. + tree *m_global_points; + // Conditional pointer equivalency. + class ssa_equiv_stack *m_cond_points; +}; + +inline bool +supported_pointer_equiv_p (tree expr) +{ + return TREE_CODE (expr) == SSA_NAME && POINTER_TYPE_P (TREE_TYPE (expr)); +} + +#endif // GCC_VALUE_POINTER_EQUIV_H |