1 /* Common subexpression elimination for GNU compiler.
2 Copyright (C) 1987-2020 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
23 /* Describe a value. */
29 /* A unique id assigned to values. */
32 /* A VALUE rtx that points back to this structure. */
35 /* All rtl expressions that hold this value at the current time during a
37 struct elt_loc_list
*locs
;
39 /* If this value is used as an address, points to a list of values that
40 use it as an address in a MEM. */
41 struct elt_list
*addr_list
;
43 struct cselib_val
*next_containing_mem
;
46 /* A list of rtl expressions that hold the same value. */
48 /* Next element in the list. */
49 struct elt_loc_list
*next
;
50 /* An rtl expression that holds the value. */
52 /* The insn that made the equivalence. */
53 rtx_insn
*setting_insn
;
56 /* Describe a single set that is part of an insn. */
62 cselib_val
*dest_addr_elt
;
65 enum cselib_record_what
67 CSELIB_RECORD_MEMORY
= 1,
68 CSELIB_PRESERVE_CONSTANTS
= 2
71 extern void (*cselib_discard_hook
) (cselib_val
*);
72 extern void (*cselib_record_sets_hook
) (rtx_insn
*insn
, struct cselib_set
*sets
,
75 extern cselib_val
*cselib_lookup (rtx
, machine_mode
,
77 extern cselib_val
*cselib_lookup_from_insn (rtx
, machine_mode
,
78 int, machine_mode
, rtx_insn
*);
79 extern void cselib_init (int);
80 extern void cselib_clear_table (void);
81 extern void cselib_finish (void);
82 extern void cselib_process_insn (rtx_insn
*);
83 extern bool fp_setter_insn (rtx_insn
*);
84 extern machine_mode
cselib_reg_set_mode (const_rtx
);
85 extern int rtx_equal_for_cselib_1 (rtx
, rtx
, machine_mode
, int);
86 extern int references_value_p (const_rtx
, int);
87 extern rtx
cselib_expand_value_rtx (rtx
, bitmap
, int);
88 typedef rtx (*cselib_expand_callback
)(rtx
, bitmap
, int, void *);
89 extern rtx
cselib_expand_value_rtx_cb (rtx
, bitmap
, int,
90 cselib_expand_callback
, void *);
91 extern bool cselib_dummy_expand_value_rtx_cb (rtx
, bitmap
, int,
92 cselib_expand_callback
, void *);
93 extern rtx
cselib_subst_to_values (rtx
, machine_mode
);
94 extern rtx
cselib_subst_to_values_from_insn (rtx
, machine_mode
, rtx_insn
*);
95 extern void cselib_invalidate_rtx (rtx
);
97 extern void cselib_reset_table (unsigned int);
98 extern unsigned int cselib_get_next_uid (void);
99 extern void cselib_preserve_value (cselib_val
*);
100 extern bool cselib_preserved_value_p (cselib_val
*);
101 extern void cselib_preserve_only_values (void);
102 extern void cselib_preserve_cfa_base_value (cselib_val
*, unsigned int);
103 extern void cselib_add_permanent_equiv (cselib_val
*, rtx
, rtx_insn
*);
104 extern bool cselib_have_permanent_equivalences (void);
105 extern void cselib_set_value_sp_based (cselib_val
*);
106 extern bool cselib_sp_based_value_p (cselib_val
*);
107 extern void cselib_record_sp_cfa_base_equiv (HOST_WIDE_INT
, rtx_insn
*);
108 extern bool cselib_sp_derived_value_p (cselib_val
*);
110 extern void dump_cselib_table (FILE *);
112 /* Return the canonical value for VAL, following the equivalence chain
113 towards the earliest (== lowest uid) equivalent value. */
115 static inline cselib_val
*
116 canonical_cselib_val (cselib_val
*val
)
120 if (!val
->locs
|| val
->locs
->next
121 || !val
->locs
->loc
|| GET_CODE (val
->locs
->loc
) != VALUE
122 || val
->uid
< CSELIB_VAL_PTR (val
->locs
->loc
)->uid
)
125 canon
= CSELIB_VAL_PTR (val
->locs
->loc
);
126 gcc_checking_assert (canonical_cselib_val (canon
) == canon
);
130 /* Return nonzero if we can prove that X and Y contain the same value, taking
131 our gathered information into account. */
134 rtx_equal_for_cselib_p (rtx x
, rtx y
)
139 return rtx_equal_for_cselib_1 (x
, y
, VOIDmode
, 0);
142 #endif /* GCC_CSELIB_H */