tree-phinodes.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* Header file for PHI node routines
  2. Copyright (C) 2013-2015 Free Software Foundation, Inc.
  3. This file is part of GCC.
  4. GCC is free software; you can redistribute it and/or modify it under
  5. the terms of the GNU General Public License as published by the Free
  6. Software Foundation; either version 3, or (at your option) any later
  7. version.
  8. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  9. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  11. for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GCC; see the file COPYING3. If not see
  14. <http://www.gnu.org/licenses/>. */
  15. #ifndef GCC_TREE_PHINODES_H
  16. #define GCC_TREE_PHINODES_H
  17. extern void phinodes_print_statistics (void);
  18. extern void release_phi_node (gimple);
  19. extern void reserve_phi_args_for_new_edge (basic_block);
  20. extern void add_phi_node_to_bb (gphi *phi, basic_block bb);
  21. extern gphi *create_phi_node (tree, basic_block);
  22. extern void add_phi_arg (gphi *, tree, edge, source_location);
  23. extern void remove_phi_args (edge);
  24. extern void remove_phi_node (gimple_stmt_iterator *, bool);
  25. extern void remove_phi_nodes (basic_block);
  26. extern tree degenerate_phi_result (gphi *);
  27. extern void set_phi_nodes (basic_block, gimple_seq);
  28. static inline use_operand_p
  29. gimple_phi_arg_imm_use_ptr (gimple gs, int i)
  30. {
  31. return &gimple_phi_arg (gs, i)->imm_use;
  32. }
  33. /* Return the phi argument which contains the specified use. */
  34. static inline int
  35. phi_arg_index_from_use (use_operand_p use)
  36. {
  37. struct phi_arg_d *element, *root;
  38. size_t index;
  39. gimple phi;
  40. /* Since the use is the first thing in a PHI argument element, we can
  41. calculate its index based on casting it to an argument, and performing
  42. pointer arithmetic. */
  43. phi = USE_STMT (use);
  44. element = (struct phi_arg_d *)use;
  45. root = gimple_phi_arg (phi, 0);
  46. index = element - root;
  47. /* Make sure the calculation doesn't have any leftover bytes. If it does,
  48. then imm_use is likely not the first element in phi_arg_d. */
  49. gcc_checking_assert ((((char *)element - (char *)root)
  50. % sizeof (struct phi_arg_d)) == 0
  51. && index < gimple_phi_capacity (phi));
  52. return index;
  53. }
  54. #endif /* GCC_TREE_PHINODES_H */