GCC Middle and Back End API Reference
cselib.h
Go to the documentation of this file.
1/* Common subexpression elimination for GNU compiler.
2 Copyright (C) 1987-2024 Free Software Foundation, Inc.
3
4This file is part of GCC.
5
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
8Software Foundation; either version 3, or (at your option) any later
9version.
10
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.
15
16You should have received a copy of the GNU General Public License
17along with GCC; see the file COPYING3. If not see
18<http://www.gnu.org/licenses/>. */
19
20#ifndef GCC_CSELIB_H
21#define GCC_CSELIB_H
22
23/* Describe a value. */
25{
26 /* The hash value. */
27 unsigned int hash;
28
29 /* A unique id assigned to values. */
30 int uid;
31
32 /* A VALUE rtx that points back to this structure. */
34
35 /* All rtl expressions that hold this value at the current time during a
36 scan. */
38
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. */
42
44};
45
46/* A list of rtl expressions that hold the same value. */
48 /* Next element in the list. */
50 /* An rtl expression that holds the value. */
52 /* The insn that made the equivalence. */
54};
55
56/* Describe a single set that is part of an insn. */
64
70
71extern void (*cselib_discard_hook) (cselib_val *);
72extern void (*cselib_record_sets_hook) (rtx_insn *insn, struct cselib_set *sets,
73 int n_sets);
74
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 *);
79extern void cselib_init (int);
80extern void cselib_clear_table (void);
81extern void cselib_finish (void);
82extern void cselib_process_insn (rtx_insn *);
83extern bool fp_setter_insn (rtx_insn *);
84extern machine_mode cselib_reg_set_mode (const_rtx);
85extern bool rtx_equal_for_cselib_1 (rtx, rtx, machine_mode, int);
86extern bool cselib_redundant_set_p (rtx);
87extern bool references_value_p (const_rtx, int);
89typedef rtx (*cselib_expand_callback)(rtx, bitmap, int, void *);
94extern rtx cselib_subst_to_values (rtx, machine_mode);
95extern rtx cselib_subst_to_values_from_insn (rtx, machine_mode, rtx_insn *);
96extern void cselib_invalidate_rtx (rtx);
97
98extern void cselib_reset_table (unsigned int);
99extern unsigned int cselib_get_next_uid (void);
100extern void cselib_preserve_value (cselib_val *);
102extern void cselib_preserve_only_values (void);
103extern void cselib_preserve_cfa_base_value (cselib_val *, unsigned int);
105extern bool cselib_have_permanent_equivalences (void);
107extern bool cselib_sp_based_value_p (cselib_val *);
108extern void cselib_record_sp_cfa_base_equiv (HOST_WIDE_INT, rtx_insn *);
110
111extern void dump_cselib_table (FILE *);
112
113/* Return the canonical value for VAL, following the equivalence chain
114 towards the earliest (== lowest uid) equivalent value. */
115
116inline cselib_val *
118{
119 cselib_val *canon;
120
121 if (!val->locs || val->locs->next
122 || !val->locs->loc || GET_CODE (val->locs->loc) != VALUE
123 || val->uid < CSELIB_VAL_PTR (val->locs->loc)->uid)
124 return val;
125
126 canon = CSELIB_VAL_PTR (val->locs->loc);
127 gcc_checking_assert (canonical_cselib_val (canon) == canon);
128 return canon;
129}
130
131/* Return true if we can prove that X and Y contain the same value, taking
132 our gathered information into account. */
133
134inline bool
136{
137 if (x == y)
138 return true;
139
140 return rtx_equal_for_cselib_1 (x, y, VOIDmode, 0);
141}
142
143#endif /* GCC_CSELIB_H */
struct rtx_def * rtx
Definition coretypes.h:57
class bitmap_head * bitmap
Definition coretypes.h:51
void cselib_reset_table(unsigned int)
Definition cselib.cc:537
void cselib_preserve_value(cselib_val *)
Definition cselib.cc:772
rtx cselib_subst_to_values_from_insn(rtx, machine_mode, rtx_insn *)
Definition cselib.cc:2309
cselib_val * cselib_lookup_from_insn(rtx, machine_mode, int, machine_mode, rtx_insn *)
Definition cselib.cc:2459
void cselib_preserve_only_values(void)
Definition cselib.cc:804
bool cselib_have_permanent_equivalences(void)
Definition cselib.cc:2806
bool cselib_dummy_expand_value_rtx_cb(rtx, bitmap, int, cselib_expand_callback, void *)
Definition cselib.cc:1879
void cselib_finish(void)
Definition cselib.cc:3291
cselib_val * cselib_lookup(rtx, machine_mode, int, machine_mode)
Definition cselib.cc:2478
void cselib_set_value_sp_based(cselib_val *)
Definition cselib.cc:822
bool cselib_sp_based_value_p(cselib_val *)
Definition cselib.cc:831
bool fp_setter_insn(rtx_insn *)
Definition cselib.cc:3107
cselib_record_what
Definition cselib.h:66
@ CSELIB_RECORD_MEMORY
Definition cselib.h:67
@ CSELIB_PRESERVE_CONSTANTS
Definition cselib.h:68
bool cselib_preserved_value_p(cselib_val *)
Definition cselib.cc:780
bool rtx_equal_for_cselib_1(rtx, rtx, machine_mode, int)
Definition cselib.cc:941
rtx cselib_expand_value_rtx_cb(rtx, bitmap, int, cselib_expand_callback, void *)
Definition cselib.cc:1861
rtx(* cselib_expand_callback)(rtx, bitmap, int, void *)
Definition cselib.h:89
void cselib_process_insn(rtx_insn *)
Definition cselib.cc:3151
void cselib_init(int)
Definition cselib.cc:3251
void cselib_record_sp_cfa_base_equiv(HOST_WIDE_INT, rtx_insn *)
Definition cselib.cc:2816
bool cselib_redundant_set_p(rtx)
Definition cselib.cc:1188
void cselib_add_permanent_equiv(cselib_val *, rtx, rtx_insn *)
Definition cselib.cc:2777
rtx cselib_expand_value_rtx(rtx, bitmap, int)
Definition cselib.cc:1842
bool cselib_sp_derived_value_p(cselib_val *)
Definition cselib.cc:2851
bool rtx_equal_for_cselib_p(rtx x, rtx y)
Definition cselib.h:135
void cselib_clear_table(void)
Definition cselib.cc:460
machine_mode cselib_reg_set_mode(const_rtx)
Definition cselib.cc:842
bool references_value_p(const_rtx, int)
Definition cselib.cc:640
void cselib_invalidate_rtx(rtx)
Definition cselib.cc:2706
cselib_val * canonical_cselib_val(cselib_val *val)
Definition cselib.h:117
void(* cselib_discard_hook)(cselib_val *)
Definition cselib.cc:281
void dump_cselib_table(FILE *)
Definition cselib.cc:3394
void cselib_preserve_cfa_base_value(cselib_val *, unsigned int)
Definition cselib.cc:789
void(* cselib_record_sets_hook)(rtx_insn *insn, struct cselib_set *sets, int n_sets)
Definition cselib.cc:288
rtx cselib_subst_to_values(rtx, machine_mode)
Definition cselib.cc:2178
unsigned int cselib_get_next_uid(void)
Definition cselib.cc:611
#define CSELIB_VAL_PTR(RTX)
Definition rtl.h:1616
#define GET_CODE(RTX)
Definition rtl.h:726
Definition cselib.h:58
cselib_val * dest_addr_elt
Definition cselib.h:62
cselib_val * src_elt
Definition cselib.h:61
rtx src
Definition cselib.h:59
rtx dest
Definition cselib.h:60
Definition cselib.h:25
int uid
Definition cselib.h:30
struct elt_loc_list * locs
Definition cselib.h:37
struct elt_list * addr_list
Definition cselib.h:41
rtx val_rtx
Definition cselib.h:33
struct cselib_val * next_containing_mem
Definition cselib.h:43
unsigned int hash
Definition cselib.h:27
Definition cselib.cc:39
Definition cselib.h:47
rtx loc
Definition cselib.h:51
struct elt_loc_list * next
Definition cselib.h:49
rtx_insn * setting_insn
Definition cselib.h:53
Definition rtl.h:312
Definition rtl.h:546
#define gcc_checking_assert(EXPR)
Definition system.h:821
const T2 & y
Definition wide-int.h:3870