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-2013 Free Software Foundation, Inc.
3 
4 This file is part of GCC.
5 
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
9 version.
10 
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
14 for more details.
15 
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/>. */
19 
20 /* Describe a value. */
21 typedef struct cselib_val_struct {
22  /* The hash value. */
23  unsigned int hash;
24 
25  /* A unique id assigned to values. */
26  int uid;
27 
28  /* A VALUE rtx that points back to this structure. */
29  rtx val_rtx;
30 
31  /* All rtl expressions that hold this value at the current time during a
32  scan. */
33  struct elt_loc_list *locs;
34 
35  /* If this value is used as an address, points to a list of values that
36  use it as an address in a MEM. */
37  struct elt_list *addr_list;
38 
40 } cselib_val;
41 
42 /* A list of rtl expressions that hold the same value. */
43 struct elt_loc_list {
44  /* Next element in the list. */
45  struct elt_loc_list *next;
46  /* An rtl expression that holds the value. */
47  rtx loc;
48  /* The insn that made the equivalence. */
50 };
51 
52 /* Describe a single set that is part of an insn. */
53 struct cselib_set
54 {
55  rtx src;
56  rtx dest;
59 };
60 
62 {
65 };
66 
67 extern void (*cselib_discard_hook) (cselib_val *);
68 extern void (*cselib_record_sets_hook) (rtx insn, struct cselib_set *sets,
69  int n_sets);
70 
71 extern cselib_val *cselib_lookup (rtx, enum machine_mode,
72  int, enum machine_mode);
73 extern cselib_val *cselib_lookup_from_insn (rtx, enum machine_mode,
74  int, enum machine_mode, rtx);
75 extern void cselib_init (int);
76 extern void cselib_clear_table (void);
77 extern void cselib_finish (void);
78 extern void cselib_process_insn (rtx);
79 extern bool fp_setter_insn (rtx);
80 extern enum machine_mode cselib_reg_set_mode (const_rtx);
81 extern int rtx_equal_for_cselib_p (rtx, rtx);
82 extern int references_value_p (const_rtx, int);
83 extern rtx cselib_expand_value_rtx (rtx, bitmap, int);
84 typedef rtx (*cselib_expand_callback)(rtx, bitmap, int, void *);
86  cselib_expand_callback, void *);
88  cselib_expand_callback, void *);
89 extern rtx cselib_subst_to_values (rtx, enum machine_mode);
90 extern rtx cselib_subst_to_values_from_insn (rtx, enum machine_mode, rtx);
91 extern void cselib_invalidate_rtx (rtx);
92 
93 extern void cselib_reset_table (unsigned int);
94 extern unsigned int cselib_get_next_uid (void);
95 extern void cselib_preserve_value (cselib_val *);
97 extern void cselib_preserve_only_values (void);
98 extern void cselib_preserve_cfa_base_value (cselib_val *, unsigned int);
100 extern bool cselib_have_permanent_equivalences (void);
101 extern void cselib_set_value_sp_based (cselib_val *);
102 extern bool cselib_sp_based_value_p (cselib_val *);
103 
104 extern void dump_cselib_table (FILE *);
105 
106 /* Return the canonical value for VAL, following the equivalence chain
107  towards the earliest (== lowest uid) equivalent value. */
108 
109 static inline cselib_val *
111 {
112  cselib_val *canon;
113 
114  if (!val->locs || val->locs->next
115  || !val->locs->loc || GET_CODE (val->locs->loc) != VALUE
116  || val->uid < CSELIB_VAL_PTR (val->locs->loc)->uid)
117  return val;
118 
119  canon = CSELIB_VAL_PTR (val->locs->loc);
120  gcc_checking_assert (canonical_cselib_val (canon) == canon);
121  return canon;
122 }