tree-ssa-operands.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /* SSA operand management for trees.
  2. Copyright (C) 2003-2019 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_SSA_OPERANDS_H
  16. #define GCC_TREE_SSA_OPERANDS_H
  17. /* Interface to SSA operands. */
  18. /* This represents a pointer to a DEF operand. */
  19. typedef tree *def_operand_p;
  20. /* This represents a pointer to a USE operand. */
  21. typedef ssa_use_operand_t *use_operand_p;
  22. /* NULL operand types. */
  23. #define NULL_USE_OPERAND_P ((use_operand_p)NULL)
  24. #define NULL_DEF_OPERAND_P ((def_operand_p)NULL)
  25. /* This represents the USE operands of a stmt. */
  26. struct use_optype_d
  27. {
  28. struct use_optype_d *next;
  29. struct ssa_use_operand_t use_ptr;
  30. };
  31. typedef struct use_optype_d *use_optype_p;
  32. /* This structure represents a variable sized buffer which is allocated by the
  33. operand memory manager. Operands are suballocated out of this block. The
  34. MEM array varies in size. */
  35. struct GTY((chain_next("%h.next"))) ssa_operand_memory_d {
  36. struct ssa_operand_memory_d *next;
  37. char mem[1];
  38. };
  39. /* Per-function operand caches. */
  40. struct GTY(()) ssa_operands {
  41. struct ssa_operand_memory_d *operand_memory;
  42. unsigned operand_memory_index;
  43. /* Current size of the operand memory buffer. */
  44. unsigned int ssa_operand_mem_size;
  45. bool ops_active;
  46. struct use_optype_d * GTY ((skip (""))) free_uses;
  47. };
  48. #define USE_FROM_PTR(PTR) get_use_from_ptr (PTR)
  49. #define DEF_FROM_PTR(PTR) get_def_from_ptr (PTR)
  50. #define SET_USE(USE, V) set_ssa_use_from_ptr (USE, V)
  51. #define SET_DEF(DEF, V) ((*(DEF)) = (V))
  52. #define USE_STMT(USE) (USE)->loc.stmt
  53. #define USE_OP_PTR(OP) (&((OP)->use_ptr))
  54. #define USE_OP(OP) (USE_FROM_PTR (USE_OP_PTR (OP)))
  55. #define PHI_RESULT_PTR(PHI) gimple_phi_result_ptr (PHI)
  56. #define PHI_RESULT(PHI) DEF_FROM_PTR (PHI_RESULT_PTR (PHI))
  57. #define SET_PHI_RESULT(PHI, V) SET_DEF (PHI_RESULT_PTR (PHI), (V))
  58. /*
  59. #define PHI_ARG_DEF(PHI, I) USE_FROM_PTR (PHI_ARG_DEF_PTR ((PHI), (I)))
  60. */
  61. #define PHI_ARG_DEF_PTR(PHI, I) gimple_phi_arg_imm_use_ptr ((PHI), (I))
  62. #define PHI_ARG_DEF(PHI, I) gimple_phi_arg_def ((PHI), (I))
  63. #define SET_PHI_ARG_DEF(PHI, I, V) \
  64. SET_USE (PHI_ARG_DEF_PTR ((PHI), (I)), (V))
  65. #define PHI_ARG_DEF_FROM_EDGE(PHI, E) \
  66. PHI_ARG_DEF ((PHI), (E)->dest_idx)
  67. #define PHI_ARG_DEF_PTR_FROM_EDGE(PHI, E) \
  68. PHI_ARG_DEF_PTR ((PHI), (E)->dest_idx)
  69. #define PHI_ARG_INDEX_FROM_USE(USE) phi_arg_index_from_use (USE)
  70. extern bool ssa_operands_active (struct function *);
  71. extern void init_ssa_operands (struct function *fn);
  72. extern void fini_ssa_operands (struct function *);
  73. extern bool verify_ssa_operands (struct function *, gimple *stmt);
  74. extern void free_stmt_operands (struct function *, gimple *);
  75. extern void update_stmt_operands (struct function *, gimple *);
  76. extern void swap_ssa_operands (gimple *, tree *, tree *);
  77. extern bool verify_imm_links (FILE *f, tree var);
  78. extern void dump_immediate_uses_for (FILE *file, tree var);
  79. extern void dump_immediate_uses (FILE *file);
  80. extern void debug_immediate_uses (void);
  81. extern void debug_immediate_uses_for (tree var);
  82. extern void unlink_stmt_vdef (gimple *);
  83. /* Return the tree pointed-to by USE. */
  84. static inline tree
  85. get_use_from_ptr (use_operand_p use)
  86. {
  87. return *(use->use);
  88. }
  89. /* Return the tree pointed-to by DEF. */
  90. static inline tree
  91. get_def_from_ptr (def_operand_p def)
  92. {
  93. return *def;
  94. }
  95. #endif /* GCC_TREE_SSA_OPERANDS_H */