* pt.c (lookup_template_class_1): Splice out abi_tag attribute if
[official-gcc.git] / gcc / cselib.h
blobecf53e1ad1be2bb66bc0a4cd03e0431e3109a09c
1 /* Common subexpression elimination for GNU compiler.
2 Copyright (C) 1987-2014 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
9 version.
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.
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/>. */
20 /* Describe a value. */
21 struct cselib_val {
22 /* The hash value. */
23 unsigned int hash;
25 /* A unique id assigned to values. */
26 int uid;
28 /* A VALUE rtx that points back to this structure. */
29 rtx val_rtx;
31 /* All rtl expressions that hold this value at the current time during a
32 scan. */
33 struct elt_loc_list *locs;
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;
39 struct cselib_val *next_containing_mem;
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. */
49 rtx_insn *setting_insn;
52 /* Describe a single set that is part of an insn. */
53 struct cselib_set
55 rtx src;
56 rtx dest;
57 cselib_val *src_elt;
58 cselib_val *dest_addr_elt;
61 enum cselib_record_what
63 CSELIB_RECORD_MEMORY = 1,
64 CSELIB_PRESERVE_CONSTANTS = 2
67 extern void (*cselib_discard_hook) (cselib_val *);
68 extern void (*cselib_record_sets_hook) (rtx_insn *insn, struct cselib_set *sets,
69 int n_sets);
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_insn *);
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_insn *);
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 *);
85 extern rtx cselib_expand_value_rtx_cb (rtx, bitmap, int,
86 cselib_expand_callback, void *);
87 extern bool cselib_dummy_expand_value_rtx_cb (rtx, bitmap, int,
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_insn *);
91 extern void cselib_invalidate_rtx (rtx);
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 *);
96 extern bool cselib_preserved_value_p (cselib_val *);
97 extern void cselib_preserve_only_values (void);
98 extern void cselib_preserve_cfa_base_value (cselib_val *, unsigned int);
99 extern void cselib_add_permanent_equiv (cselib_val *, rtx, rtx_insn *);
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 *);
104 extern void dump_cselib_table (FILE *);
106 /* Return the canonical value for VAL, following the equivalence chain
107 towards the earliest (== lowest uid) equivalent value. */
109 static inline cselib_val *
110 canonical_cselib_val (cselib_val *val)
112 cselib_val *canon;
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;
119 canon = CSELIB_VAL_PTR (val->locs->loc);
120 gcc_checking_assert (canonical_cselib_val (canon) == canon);
121 return canon;