]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/cselib.h
gcov: rename 2 options.
[thirdparty/gcc.git] / gcc / cselib.h
CommitLineData
eab5c70a 1/* Common subexpression elimination for GNU compiler.
8d9254fc 2 Copyright (C) 1987-2020 Free Software Foundation, Inc.
eab5c70a 3
1322177d 4This file is part of GCC.
eab5c70a 5
1322177d
LB
6GCC is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
9dcd6f09 8Software Foundation; either version 3, or (at your option) any later
1322177d 9version.
eab5c70a 10
1322177d
LB
11GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14for more details.
eab5c70a
BS
15
16You should have received a copy of the GNU General Public License
9dcd6f09
NC
17along with GCC; see the file COPYING3. If not see
18<http://www.gnu.org/licenses/>. */
eab5c70a 19
f1717f8d
KC
20#ifndef GCC_CSELIB_H
21#define GCC_CSELIB_H
22
eab5c70a 23/* Describe a value. */
a78a26f1
ML
24struct cselib_val
25{
eab5c70a 26 /* The hash value. */
5440c0e7
AO
27 unsigned int hash;
28
29 /* A unique id assigned to values. */
30 int uid;
757bbef8
SB
31
32 /* A VALUE rtx that points back to this structure. */
33 rtx val_rtx;
eab5c70a
BS
34
35 /* All rtl expressions that hold this value at the current time during a
36 scan. */
37 struct elt_loc_list *locs;
757bbef8 38
eab5c70a
BS
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;
7101fb18 42
84562394
OE
43 struct cselib_val *next_containing_mem;
44};
eab5c70a
BS
45
46/* A list of rtl expressions that hold the same value. */
1aa67003 47struct elt_loc_list {
eab5c70a
BS
48 /* Next element in the list. */
49 struct elt_loc_list *next;
50 /* An rtl expression that holds the value. */
51 rtx loc;
52 /* The insn that made the equivalence. */
12ea1b95 53 rtx_insn *setting_insn;
eab5c70a
BS
54};
55
b5b8b0ac
AO
56/* Describe a single set that is part of an insn. */
57struct cselib_set
58{
59 rtx src;
60 rtx dest;
61 cselib_val *src_elt;
62 cselib_val *dest_addr_elt;
63};
64
457eeaae
JJ
65enum cselib_record_what
66{
67 CSELIB_RECORD_MEMORY = 1,
68 CSELIB_PRESERVE_CONSTANTS = 2
69};
70
6fb5fa3c 71extern void (*cselib_discard_hook) (cselib_val *);
46665961 72extern void (*cselib_record_sets_hook) (rtx_insn *insn, struct cselib_set *sets,
b5b8b0ac 73 int n_sets);
6fb5fa3c 74
ef4bddc2
RS
75extern cselib_val *cselib_lookup (rtx, machine_mode,
76 int, machine_mode);
77extern cselib_val *cselib_lookup_from_insn (rtx, machine_mode,
78 int, machine_mode, rtx_insn *);
457eeaae 79extern void cselib_init (int);
eb232f4e 80extern void cselib_clear_table (void);
7080f735 81extern void cselib_finish (void);
dd60a84c 82extern void cselib_process_insn (rtx_insn *);
8df68a82 83extern bool fp_setter_insn (rtx_insn *);
ef4bddc2 84extern machine_mode cselib_reg_set_mode (const_rtx);
005f12bf 85extern int rtx_equal_for_cselib_1 (rtx, rtx, machine_mode, int);
4f588890 86extern int references_value_p (const_rtx, int);
6fb5fa3c 87extern rtx cselib_expand_value_rtx (rtx, bitmap, int);
b5b8b0ac
AO
88typedef rtx (*cselib_expand_callback)(rtx, bitmap, int, void *);
89extern rtx cselib_expand_value_rtx_cb (rtx, bitmap, int,
864ddef7
JJ
90 cselib_expand_callback, void *);
91extern bool cselib_dummy_expand_value_rtx_cb (rtx, bitmap, int,
92 cselib_expand_callback, void *);
ef4bddc2
RS
93extern rtx cselib_subst_to_values (rtx, machine_mode);
94extern rtx cselib_subst_to_values_from_insn (rtx, machine_mode, rtx_insn *);
17d184e5 95extern void cselib_invalidate_rtx (rtx);
b5b8b0ac 96
5440c0e7
AO
97extern void cselib_reset_table (unsigned int);
98extern unsigned int cselib_get_next_uid (void);
b5b8b0ac
AO
99extern void cselib_preserve_value (cselib_val *);
100extern bool cselib_preserved_value_p (cselib_val *);
0de3e43f 101extern void cselib_preserve_only_values (void);
9de9cbaf 102extern void cselib_preserve_cfa_base_value (cselib_val *, unsigned int);
12ea1b95 103extern void cselib_add_permanent_equiv (cselib_val *, rtx, rtx_insn *);
0f68ba3e 104extern bool cselib_have_permanent_equivalences (void);
0fe03ac3
JJ
105extern void cselib_set_value_sp_based (cselib_val *);
106extern bool cselib_sp_based_value_p (cselib_val *);
33c45e51
JJ
107extern void cselib_record_sp_cfa_base_equiv (HOST_WIDE_INT, rtx_insn *);
108extern bool cselib_sp_derived_value_p (cselib_val *);
b5b8b0ac
AO
109
110extern void dump_cselib_table (FILE *);
6f2ffb4b
AO
111
112/* Return the canonical value for VAL, following the equivalence chain
113 towards the earliest (== lowest uid) equivalent value. */
114
115static inline cselib_val *
116canonical_cselib_val (cselib_val *val)
117{
118 cselib_val *canon;
119
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)
123 return val;
124
125 canon = CSELIB_VAL_PTR (val->locs->loc);
126 gcc_checking_assert (canonical_cselib_val (canon) == canon);
127 return canon;
128}
f1717f8d 129
08e5cf22
EB
130/* Return nonzero if we can prove that X and Y contain the same value, taking
131 our gathered information into account. */
132
133static inline int
134rtx_equal_for_cselib_p (rtx x, rtx y)
135{
136 if (x == y)
137 return 1;
138
005f12bf 139 return rtx_equal_for_cselib_1 (x, y, VOIDmode, 0);
08e5cf22
EB
140}
141
f1717f8d 142#endif /* GCC_CSELIB_H */