190075Sobrien/* Common subexpression elimination for GNU compiler.
290075Sobrien   Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3169689Skan   1999, 2003, 2004, 2005 Free Software Foundation, Inc.
490075Sobrien
590075SobrienThis file is part of GCC.
690075Sobrien
790075SobrienGCC is free software; you can redistribute it and/or modify it under
890075Sobrienthe terms of the GNU General Public License as published by the Free
990075SobrienSoftware Foundation; either version 2, or (at your option) any later
1090075Sobrienversion.
1190075Sobrien
1290075SobrienGCC is distributed in the hope that it will be useful, but WITHOUT ANY
1390075SobrienWARRANTY; without even the implied warranty of MERCHANTABILITY or
1490075SobrienFITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1590075Sobrienfor more details.
1690075Sobrien
1790075SobrienYou should have received a copy of the GNU General Public License
1890075Sobrienalong with GCC; see the file COPYING.  If not, write to the Free
19169689SkanSoftware Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
20169689Skan02110-1301, USA.  */
2190075Sobrien
2290075Sobrien/* Describe a value.  */
23117395Skantypedef struct cselib_val_struct GTY(())
2490075Sobrien{
2590075Sobrien  /* The hash value.  */
2690075Sobrien  unsigned int value;
27117395Skan  union cselib_val_u
2890075Sobrien  {
2990075Sobrien    /* A VALUE rtx that points back to this structure.  */
30117395Skan    rtx GTY ((tag ("1"))) val_rtx;
3190075Sobrien    /* Used to keep a list of free cselib_val structures.  */
32169689Skan    struct cselib_val_struct * GTY ((skip)) next_free;
33117395Skan  } GTY ((desc ("1"))) u;
3490075Sobrien
3590075Sobrien  /* All rtl expressions that hold this value at the current time during a
3690075Sobrien     scan.  */
3790075Sobrien  struct elt_loc_list *locs;
3890075Sobrien  /* If this value is used as an address, points to a list of values that
3990075Sobrien     use it as an address in a MEM.  */
4090075Sobrien  struct elt_list *addr_list;
41132718Skan
42132718Skan  struct cselib_val_struct *next_containing_mem;
4390075Sobrien} cselib_val;
4490075Sobrien
4590075Sobrien/* A list of rtl expressions that hold the same value.  */
46117395Skanstruct elt_loc_list GTY(())
4790075Sobrien{
4890075Sobrien  /* Next element in the list.  */
4990075Sobrien  struct elt_loc_list *next;
5090075Sobrien  /* An rtl expression that holds the value.  */
5190075Sobrien  rtx loc;
5290075Sobrien  /* The insn that made the equivalence.  */
5390075Sobrien  rtx setting_insn;
54117395Skan  /* True when setting insn is inside libcall.  */
55117395Skan  bool in_libcall;
5690075Sobrien};
5790075Sobrien
5890075Sobrien/* A list of cselib_val structures.  */
59117395Skanstruct elt_list GTY(())
6090075Sobrien{
6190075Sobrien  struct elt_list *next;
6290075Sobrien  cselib_val *elt;
6390075Sobrien};
6490075Sobrien
65132718Skanextern cselib_val *cselib_lookup (rtx, enum machine_mode, int);
66169689Skanextern void cselib_init (bool record_memory);
67169689Skanextern void cselib_clear_table (void);
68132718Skanextern void cselib_finish (void);
69132718Skanextern void cselib_process_insn (rtx);
70132718Skanextern enum machine_mode cselib_reg_set_mode (rtx);
71132718Skanextern int rtx_equal_for_cselib_p (rtx, rtx);
72132718Skanextern int references_value_p (rtx, int);
73132718Skanextern rtx cselib_subst_to_values (rtx);
74146895Skanextern void cselib_invalidate_rtx (rtx);
75