tree-ssa-propagate.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /* Data structures and function declarations for the SSA value propagation
  2. engine.
  3. Copyright (C) 2004-2019 Free Software Foundation, Inc.
  4. Contributed by Diego Novillo <dnovillo@redhat.com>
  5. This file is part of GCC.
  6. GCC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 3, or (at your option)
  9. any later version.
  10. GCC is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with GCC; see the file COPYING3. If not see
  16. <http://www.gnu.org/licenses/>. */
  17. #ifndef _TREE_SSA_PROPAGATE_H
  18. #define _TREE_SSA_PROPAGATE_H 1
  19. /* If SIM_P is true, statement S will be simulated again. */
  20. static inline void
  21. prop_set_simulate_again (gimple *s, bool visit_p)
  22. {
  23. gimple_set_visited (s, visit_p);
  24. }
  25. /* Return true if statement T should be simulated again. */
  26. static inline bool
  27. prop_simulate_again_p (gimple *s)
  28. {
  29. return gimple_visited_p (s);
  30. }
  31. /* Lattice values used for propagation purposes. Specific instances
  32. of a propagation engine must return these values from the statement
  33. and PHI visit functions to direct the engine. */
  34. enum ssa_prop_result {
  35. /* The statement produces nothing of interest. No edges will be
  36. added to the work lists. */
  37. SSA_PROP_NOT_INTERESTING,
  38. /* The statement produces an interesting value. The set SSA_NAMEs
  39. returned by SSA_PROP_VISIT_STMT should be added to
  40. INTERESTING_SSA_EDGES. If the statement being visited is a
  41. conditional jump, SSA_PROP_VISIT_STMT should indicate which edge
  42. out of the basic block should be marked executable. */
  43. SSA_PROP_INTERESTING,
  44. /* The statement produces a varying (i.e., useless) value and
  45. should not be simulated again. If the statement being visited
  46. is a conditional jump, all the edges coming out of the block
  47. will be considered executable. */
  48. SSA_PROP_VARYING
  49. };
  50. extern bool valid_gimple_rhs_p (tree);
  51. extern void move_ssa_defining_stmt_for_defs (gimple *, gimple *);
  52. extern bool update_gimple_call (gimple_stmt_iterator *, tree, int, ...);
  53. extern bool update_call_from_tree (gimple_stmt_iterator *, tree);
  54. extern bool stmt_makes_single_store (gimple *);
  55. extern bool may_propagate_copy (tree, tree);
  56. extern bool may_propagate_copy_into_stmt (gimple *, tree);
  57. extern bool may_propagate_copy_into_asm (tree);
  58. extern void propagate_value (use_operand_p, tree);
  59. extern void replace_exp (use_operand_p, tree);
  60. extern void propagate_tree_value (tree *, tree);
  61. extern void propagate_tree_value_into_stmt (gimple_stmt_iterator *, tree);
  62. /* Public interface into the SSA propagation engine. Clients should inherit
  63. from this class and provide their own visitors. */
  64. class ssa_propagation_engine
  65. {
  66. public:
  67. virtual ~ssa_propagation_engine (void) { }
  68. /* Virtual functions the clients must provide to visit statements
  69. and phi nodes respectively. */
  70. virtual enum ssa_prop_result visit_stmt (gimple *, edge *, tree *) = 0;
  71. virtual enum ssa_prop_result visit_phi (gphi *) = 0;
  72. /* Main interface into the propagation engine. */
  73. void ssa_propagate (void);
  74. private:
  75. /* Internal implementation details. */
  76. void simulate_stmt (gimple *stmt);
  77. void simulate_block (basic_block);
  78. };
  79. class substitute_and_fold_engine
  80. {
  81. public:
  82. virtual ~substitute_and_fold_engine (void) { }
  83. virtual bool fold_stmt (gimple_stmt_iterator *) { return false; }
  84. virtual tree get_value (tree) { return NULL_TREE; }
  85. bool substitute_and_fold (basic_block = NULL);
  86. bool replace_uses_in (gimple *);
  87. bool replace_phi_args_in (gphi *);
  88. };
  89. #endif /* _TREE_SSA_PROPAGATE_H */