cselib.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /* Common subexpression elimination for GNU compiler.
  2. Copyright (C) 1987-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_CSELIB_H
  16. #define GCC_CSELIB_H
  17. /* Describe a value. */
  18. struct cselib_val {
  19. /* The hash value. */
  20. unsigned int hash;
  21. /* A unique id assigned to values. */
  22. int uid;
  23. /* A VALUE rtx that points back to this structure. */
  24. rtx val_rtx;
  25. /* All rtl expressions that hold this value at the current time during a
  26. scan. */
  27. struct elt_loc_list *locs;
  28. /* If this value is used as an address, points to a list of values that
  29. use it as an address in a MEM. */
  30. struct elt_list *addr_list;
  31. struct cselib_val *next_containing_mem;
  32. };
  33. /* A list of rtl expressions that hold the same value. */
  34. struct elt_loc_list {
  35. /* Next element in the list. */
  36. struct elt_loc_list *next;
  37. /* An rtl expression that holds the value. */
  38. rtx loc;
  39. /* The insn that made the equivalence. */
  40. rtx_insn *setting_insn;
  41. };
  42. /* Describe a single set that is part of an insn. */
  43. struct cselib_set
  44. {
  45. rtx src;
  46. rtx dest;
  47. cselib_val *src_elt;
  48. cselib_val *dest_addr_elt;
  49. };
  50. enum cselib_record_what
  51. {
  52. CSELIB_RECORD_MEMORY = 1,
  53. CSELIB_PRESERVE_CONSTANTS = 2
  54. };
  55. extern void (*cselib_discard_hook) (cselib_val *);
  56. extern void (*cselib_record_sets_hook) (rtx_insn *insn, struct cselib_set *sets,
  57. int n_sets);
  58. extern cselib_val *cselib_lookup (rtx, machine_mode,
  59. int, machine_mode);
  60. extern cselib_val *cselib_lookup_from_insn (rtx, machine_mode,
  61. int, machine_mode, rtx_insn *);
  62. extern void cselib_init (int);
  63. extern void cselib_clear_table (void);
  64. extern void cselib_finish (void);
  65. extern void cselib_process_insn (rtx_insn *);
  66. extern bool fp_setter_insn (rtx);
  67. extern machine_mode cselib_reg_set_mode (const_rtx);
  68. extern int rtx_equal_for_cselib_p (rtx, rtx);
  69. extern int references_value_p (const_rtx, int);
  70. extern rtx cselib_expand_value_rtx (rtx, bitmap, int);
  71. typedef rtx (*cselib_expand_callback)(rtx, bitmap, int, void *);
  72. extern rtx cselib_expand_value_rtx_cb (rtx, bitmap, int,
  73. cselib_expand_callback, void *);
  74. extern bool cselib_dummy_expand_value_rtx_cb (rtx, bitmap, int,
  75. cselib_expand_callback, void *);
  76. extern rtx cselib_subst_to_values (rtx, machine_mode);
  77. extern rtx cselib_subst_to_values_from_insn (rtx, machine_mode, rtx_insn *);
  78. extern void cselib_invalidate_rtx (rtx);
  79. extern void cselib_reset_table (unsigned int);
  80. extern unsigned int cselib_get_next_uid (void);
  81. extern void cselib_preserve_value (cselib_val *);
  82. extern bool cselib_preserved_value_p (cselib_val *);
  83. extern void cselib_preserve_only_values (void);
  84. extern void cselib_preserve_cfa_base_value (cselib_val *, unsigned int);
  85. extern void cselib_add_permanent_equiv (cselib_val *, rtx, rtx_insn *);
  86. extern bool cselib_have_permanent_equivalences (void);
  87. extern void cselib_set_value_sp_based (cselib_val *);
  88. extern bool cselib_sp_based_value_p (cselib_val *);
  89. extern void dump_cselib_table (FILE *);
  90. /* Return the canonical value for VAL, following the equivalence chain
  91. towards the earliest (== lowest uid) equivalent value. */
  92. static inline cselib_val *
  93. canonical_cselib_val (cselib_val *val)
  94. {
  95. cselib_val *canon;
  96. if (!val->locs || val->locs->next
  97. || !val->locs->loc || GET_CODE (val->locs->loc) != VALUE
  98. || val->uid < CSELIB_VAL_PTR (val->locs->loc)->uid)
  99. return val;
  100. canon = CSELIB_VAL_PTR (val->locs->loc);
  101. gcc_checking_assert (canonical_cselib_val (canon) == canon);
  102. return canon;
  103. }
  104. #endif /* GCC_CSELIB_H */