@@ -1350,6 +1350,7 @@ OBJS = \
resource.o \
rtl-error.o \
rtl.o \
+ rtlhash.o \
rtlanal.o \
rtlhooks.o \
sbitmap.o \
@@ -71,6 +71,7 @@ along with GCC; see the file COPYING3. If not see
#include "flags.h"
#include "hard-reg-set.h"
#include "regs.h"
+#include "rtlhash.h"
#include "insn-config.h"
#include "reload.h"
#include "function.h"
@@ -3277,7 +3278,7 @@ static void gen_scheduled_generic_parms_dies (void);
static const char *comp_dir_string (void);
-static hashval_t hash_loc_operands (dw_loc_descr_ref, hashval_t);
+static void hash_loc_operands (dw_loc_descr_ref, inchash::hash &);
/* enum for tracking thread-local variables whose address is really an offset
relative to the TLS pointer, which will need link-time relocation, but will
@@ -4190,17 +4191,22 @@ static hashval_t
addr_table_entry_do_hash (const void *x)
{
const addr_table_entry *a = (const addr_table_entry *) x;
+ inchash::hash hstate;
switch (a->kind)
{
case ate_kind_rtx:
- return iterative_hash_rtx (a->addr.rtl, 0);
+ hstate.add_int (0);
+ break;
case ate_kind_rtx_dtprel:
- return iterative_hash_rtx (a->addr.rtl, 1);
+ hstate.add_int (1);
+ break;
case ate_kind_label:
return htab_hash_string (a->addr.label);
default:
gcc_unreachable ();
}
+ inchash::add_rtx (a->addr.rtl, hstate);
+ return hstate.end ();
}
/* Determine equality for two address_table_entries. */
@@ -5544,11 +5550,13 @@ static inline void
loc_checksum (dw_loc_descr_ref loc, struct md5_ctx *ctx)
{
int tem;
- hashval_t hash = 0;
+ inchash::hash hstate;
+ hashval_t hash;
tem = (loc->dtprel << 8) | ((unsigned int) loc->dw_loc_opc);
CHECKSUM (tem);
- hash = hash_loc_operands (loc, hash);
+ hash_loc_operands (loc, hstate);
+ hash = hstate.end();
CHECKSUM (hash);
}
@@ -5758,11 +5766,13 @@ loc_checksum_ordered (dw_loc_descr_ref loc, struct md5_ctx *ctx)
/* Otherwise, just checksum the raw location expression. */
while (loc != NULL)
{
- hashval_t hash = 0;
+ inchash::hash hstate;
+ hashval_t hash;
CHECKSUM_ULEB128 (loc->dtprel);
CHECKSUM_ULEB128 (loc->dw_loc_opc);
- hash = hash_loc_operands (loc, hash);
+ hash_loc_operands (loc, hstate);
+ hash = hstate.end ();
CHECKSUM (hash);
loc = loc->dw_loc_next;
}
@@ -23619,10 +23629,10 @@ resolve_addr (dw_die_ref die)
This pass tries to share identical local lists in .debug_loc
section. */
-/* Iteratively hash operands of LOC opcode. */
+/* Iteratively hash operands of LOC opcode into HSTATE. */
-static hashval_t
-hash_loc_operands (dw_loc_descr_ref loc, hashval_t hash)
+static void
+hash_loc_operands (dw_loc_descr_ref loc, inchash::hash &hstate)
{
dw_val_ref val1 = &loc->dw_loc_oprnd1;
dw_val_ref val2 = &loc->dw_loc_oprnd2;
@@ -23681,7 +23691,7 @@ hash_loc_operands (dw_loc_descr_ref loc, hashval_t hash)
case DW_OP_piece:
case DW_OP_deref_size:
case DW_OP_xderef_size:
- hash = iterative_hash_object (val1->v.val_int, hash);
+ hstate.add_object (val1->v.val_int);
break;
case DW_OP_skip:
case DW_OP_bra:
@@ -23690,36 +23700,35 @@ hash_loc_operands (dw_loc_descr_ref loc, hashval_t hash)
gcc_assert (val1->val_class == dw_val_class_loc);
offset = val1->v.val_loc->dw_loc_addr - (loc->dw_loc_addr + 3);
- hash = iterative_hash_object (offset, hash);
+ hstate.add_object (offset);
}
break;
case DW_OP_implicit_value:
- hash = iterative_hash_object (val1->v.val_unsigned, hash);
+ hstate.add_object (val1->v.val_unsigned);
switch (val2->val_class)
{
case dw_val_class_const:
- hash = iterative_hash_object (val2->v.val_int, hash);
+ hstate.add_object (val2->v.val_int);
break;
case dw_val_class_vec:
{
unsigned int elt_size = val2->v.val_vec.elt_size;
unsigned int len = val2->v.val_vec.length;
- hash = iterative_hash_object (elt_size, hash);
- hash = iterative_hash_object (len, hash);
- hash = iterative_hash (val2->v.val_vec.array,
- len * elt_size, hash);
+ hstate.add_int (elt_size);
+ hstate.add_int (len);
+ hstate.add (val2->v.val_vec.array, len * elt_size);
}
break;
case dw_val_class_const_double:
- hash = iterative_hash_object (val2->v.val_double.low, hash);
- hash = iterative_hash_object (val2->v.val_double.high, hash);
+ hstate.add_object (val2->v.val_double.low);
+ hstate.add_object (val2->v.val_double.high);
break;
case dw_val_class_wide_int:
- hash = iterative_hash_object (*val2->v.val_wide, hash);
+ hstate.add_object (*val2->v.val_wide);
break;
- case dw_val_class_addr:
- hash = iterative_hash_rtx (val2->v.val_addr, hash);
+ case dw_val_class_addr:
+ inchash::add_rtx (val2->v.val_addr, hstate);
break;
default:
gcc_unreachable ();
@@ -23727,17 +23736,17 @@ hash_loc_operands (dw_loc_descr_ref loc, hashval_t hash)
break;
case DW_OP_bregx:
case DW_OP_bit_piece:
- hash = iterative_hash_object (val1->v.val_int, hash);
- hash = iterative_hash_object (val2->v.val_int, hash);
+ hstate.add_object (val1->v.val_int);
+ hstate.add_object (val2->v.val_int);
break;
case DW_OP_addr:
hash_addr:
if (loc->dtprel)
{
unsigned char dtprel = 0xd1;
- hash = iterative_hash_object (dtprel, hash);
+ hstate.add_object (dtprel);
}
- hash = iterative_hash_rtx (val1->v.val_addr, hash);
+ inchash::add_rtx (val1->v.val_addr, hstate);
break;
case DW_OP_GNU_addr_index:
case DW_OP_GNU_const_index:
@@ -23745,16 +23754,16 @@ hash_loc_operands (dw_loc_descr_ref loc, hashval_t hash)
if (loc->dtprel)
{
unsigned char dtprel = 0xd1;
- hash = iterative_hash_object (dtprel, hash);
+ hstate.add_object (dtprel);
}
- hash = iterative_hash_rtx (val1->val_entry->addr.rtl, hash);
+ inchash::add_rtx (val1->val_entry->addr.rtl, hstate);
}
break;
case DW_OP_GNU_implicit_pointer:
- hash = iterative_hash_object (val2->v.val_int, hash);
+ hstate.add_int (val2->v.val_int);
break;
case DW_OP_GNU_entry_value:
- hash = hash_loc_operands (val1->v.val_loc, hash);
+ hstate.add_object (val1->v.val_loc);
break;
case DW_OP_GNU_regval_type:
case DW_OP_GNU_deref_type:
@@ -23763,16 +23772,16 @@ hash_loc_operands (dw_loc_descr_ref loc, hashval_t hash)
= get_AT_unsigned (val2->v.val_die_ref.die, DW_AT_byte_size);
unsigned int encoding
= get_AT_unsigned (val2->v.val_die_ref.die, DW_AT_encoding);
- hash = iterative_hash_object (val1->v.val_int, hash);
- hash = iterative_hash_object (byte_size, hash);
- hash = iterative_hash_object (encoding, hash);
+ hstate.add_object (val1->v.val_int);
+ hstate.add_object (byte_size);
+ hstate.add_object (encoding);
}
break;
case DW_OP_GNU_convert:
case DW_OP_GNU_reinterpret:
if (val1->val_class == dw_val_class_unsigned_const)
{
- hash = iterative_hash_object (val1->v.val_unsigned, hash);
+ hstate.add_object (val1->v.val_unsigned);
break;
}
/* FALLTHRU */
@@ -23782,33 +23791,32 @@ hash_loc_operands (dw_loc_descr_ref loc, hashval_t hash)
= get_AT_unsigned (val1->v.val_die_ref.die, DW_AT_byte_size);
unsigned int encoding
= get_AT_unsigned (val1->v.val_die_ref.die, DW_AT_encoding);
- hash = iterative_hash_object (byte_size, hash);
- hash = iterative_hash_object (encoding, hash);
+ hstate.add_object (byte_size);
+ hstate.add_object (encoding);
if (loc->dw_loc_opc != DW_OP_GNU_const_type)
break;
- hash = iterative_hash_object (val2->val_class, hash);
+ hstate.add_object (val2->val_class);
switch (val2->val_class)
{
case dw_val_class_const:
- hash = iterative_hash_object (val2->v.val_int, hash);
+ hstate.add_object (val2->v.val_int);
break;
case dw_val_class_vec:
{
unsigned int elt_size = val2->v.val_vec.elt_size;
unsigned int len = val2->v.val_vec.length;
- hash = iterative_hash_object (elt_size, hash);
- hash = iterative_hash_object (len, hash);
- hash = iterative_hash (val2->v.val_vec.array,
- len * elt_size, hash);
+ hstate.add_object (elt_size);
+ hstate.add_object (len);
+ hstate.add (val2->v.val_vec.array, len * elt_size);
}
break;
case dw_val_class_const_double:
- hash = iterative_hash_object (val2->v.val_double.low, hash);
- hash = iterative_hash_object (val2->v.val_double.high, hash);
+ hstate.add_object (val2->v.val_double.low);
+ hstate.add_object (val2->v.val_double.high);
break;
case dw_val_class_wide_int:
- hash = iterative_hash_object (*val2->v.val_wide, hash);
+ hstate.add_object (*val2->v.val_wide);
break;
default:
gcc_unreachable ();
@@ -23820,13 +23828,12 @@ hash_loc_operands (dw_loc_descr_ref loc, hashval_t hash)
/* Other codes have no operands. */
break;
}
- return hash;
}
-/* Iteratively hash the whole DWARF location expression LOC. */
+/* Iteratively hash the whole DWARF location expression LOC into HSTATE. */
-static inline hashval_t
-hash_locs (dw_loc_descr_ref loc, hashval_t hash)
+static inline void
+hash_locs (dw_loc_descr_ref loc, inchash::hash &hstate)
{
dw_loc_descr_ref l;
bool sizes_computed = false;
@@ -23836,15 +23843,14 @@ hash_locs (dw_loc_descr_ref loc, hashval_t hash)
for (l = loc; l != NULL; l = l->dw_loc_next)
{
enum dwarf_location_atom opc = l->dw_loc_opc;
- hash = iterative_hash_object (opc, hash);
+ hstate.add_object (opc);
if ((opc == DW_OP_skip || opc == DW_OP_bra) && !sizes_computed)
{
size_of_locs (loc);
sizes_computed = true;
}
- hash = hash_loc_operands (l, hash);
+ hash_loc_operands (l, hstate);
}
- return hash;
}
/* Compute hash of the whole location list LIST_HEAD. */
@@ -23853,18 +23859,17 @@ static inline void
hash_loc_list (dw_loc_list_ref list_head)
{
dw_loc_list_ref curr = list_head;
- hashval_t hash = 0;
+ inchash::hash hstate;
for (curr = list_head; curr != NULL; curr = curr->dw_loc_next)
{
- hash = iterative_hash (curr->begin, strlen (curr->begin) + 1, hash);
- hash = iterative_hash (curr->end, strlen (curr->end) + 1, hash);
+ hstate.add (curr->begin, strlen (curr->begin) + 1);
+ hstate.add (curr->end, strlen (curr->end) + 1);
if (curr->section)
- hash = iterative_hash (curr->section, strlen (curr->section) + 1,
- hash);
- hash = hash_locs (curr->expr, hash);
+ hstate.add (curr->section, strlen (curr->section) + 1);
+ hash_locs (curr->expr, hstate);
}
- list_head->hash = hash;
+ list_head->hash = hstate.end ();
}
/* Return true if X and Y opcodes have the same operands. */
@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. If not see
#ifdef GENERATOR_FILE
# include "errors.h"
#else
+# include "rtlhash.h"
# include "diagnostic-core.h"
#endif
@@ -654,84 +655,6 @@ rtx_equal_p (const_rtx x, const_rtx y)
return 1;
}
-/* Iteratively hash rtx X. */
-
-hashval_t
-iterative_hash_rtx (const_rtx x, hashval_t hash)
-{
- enum rtx_code code;
- enum machine_mode mode;
- int i, j;
- const char *fmt;
-
- if (x == NULL_RTX)
- return hash;
- code = GET_CODE (x);
- hash = iterative_hash_object (code, hash);
- mode = GET_MODE (x);
- hash = iterative_hash_object (mode, hash);
- switch (code)
- {
- case REG:
- i = REGNO (x);
- return iterative_hash_object (i, hash);
- case CONST_INT:
- return iterative_hash_object (INTVAL (x), hash);
- case CONST_WIDE_INT:
- for (i = 0; i < CONST_WIDE_INT_NUNITS (x); i++)
- hash = iterative_hash_object (CONST_WIDE_INT_ELT (x, i), hash);
- return hash;
- case SYMBOL_REF:
- if (XSTR (x, 0))
- return iterative_hash (XSTR (x, 0), strlen (XSTR (x, 0)) + 1,
- hash);
- return hash;
- case LABEL_REF:
- case DEBUG_EXPR:
- case VALUE:
- case SCRATCH:
- case CONST_DOUBLE:
- case CONST_FIXED:
- case DEBUG_IMPLICIT_PTR:
- case DEBUG_PARAMETER_REF:
- return hash;
- default:
- break;
- }
-
- fmt = GET_RTX_FORMAT (code);
- for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
- switch (fmt[i])
- {
- case 'w':
- hash = iterative_hash_object (XWINT (x, i), hash);
- break;
- case 'n':
- case 'i':
- hash = iterative_hash_object (XINT (x, i), hash);
- break;
- case 'V':
- case 'E':
- j = XVECLEN (x, i);
- hash = iterative_hash_object (j, hash);
- for (j = 0; j < XVECLEN (x, i); j++)
- hash = iterative_hash_rtx (XVECEXP (x, i, j), hash);
- break;
- case 'e':
- hash = iterative_hash_rtx (XEXP (x, i), hash);
- break;
- case 'S':
- case 's':
- if (XSTR (x, i))
- hash = iterative_hash (XSTR (x, 0), strlen (XSTR (x, 0)) + 1,
- hash);
- break;
- default:
- break;
- }
- return hash;
-}
-
void
dump_rtx_statistics (void)
{
@@ -1983,7 +1983,6 @@ extern unsigned int rtx_size (const_rtx);
extern rtx shallow_copy_rtx_stat (const_rtx MEM_STAT_DECL);
#define shallow_copy_rtx(a) shallow_copy_rtx_stat (a MEM_STAT_INFO)
extern int rtx_equal_p (const_rtx, const_rtx);
-extern hashval_t iterative_hash_rtx (const_rtx, hashval_t);
/* In emit-rtl.c */
extern rtvec gen_rtvec_v (int, rtx *);
new file mode 100644
@@ -0,0 +1,107 @@
+/* RTL hash functions.
+ Copyright (C) 1987-2014 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "ggc.h"
+#include "rtl.h"
+#include "rtlhash.h"
+
+namespace inchash
+{
+
+/* Iteratively hash rtx X into HSTATE. */
+
+void
+add_rtx (const_rtx x, hash &hstate)
+{
+ enum rtx_code code;
+ enum machine_mode mode;
+ int i, j;
+ const char *fmt;
+
+ if (x == NULL_RTX)
+ return;
+ code = GET_CODE (x);
+ hstate.add_object (code);
+ mode = GET_MODE (x);
+ hstate.add_object (mode);
+ switch (code)
+ {
+ case REG:
+ hstate.add_int (REGNO (x));
+ return;
+ case CONST_INT:
+ hstate.add_object (INTVAL (x));
+ return;
+ case CONST_WIDE_INT:
+ for (i = 0; i < CONST_WIDE_INT_NUNITS (x); i++)
+ hstate.add_object (CONST_WIDE_INT_ELT (x, i));
+ return;
+ case SYMBOL_REF:
+ if (XSTR (x, 0))
+ hstate.add (XSTR (x, 0), strlen (XSTR (x, 0)) + 1);
+ return;
+ case LABEL_REF:
+ case DEBUG_EXPR:
+ case VALUE:
+ case SCRATCH:
+ case CONST_DOUBLE:
+ case CONST_FIXED:
+ case DEBUG_IMPLICIT_PTR:
+ case DEBUG_PARAMETER_REF:
+ return;
+ default:
+ break;
+ }
+
+ fmt = GET_RTX_FORMAT (code);
+ for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
+ switch (fmt[i])
+ {
+ case 'w':
+ hstate.add_object (XWINT (x, i));
+ break;
+ case 'n':
+ case 'i':
+ hstate.add_object (XINT (x, i));
+ break;
+ case 'V':
+ case 'E':
+ j = XVECLEN (x, i);
+ hstate.add_int (j);
+ for (j = 0; j < XVECLEN (x, i); j++)
+ inchash::add_rtx (XVECEXP (x, i, j), hstate);
+ break;
+ case 'e':
+ inchash::add_rtx (XEXP (x, i), hstate);
+ break;
+ case 'S':
+ case 's':
+ if (XSTR (x, i))
+ hstate.add (XSTR (x, 0), strlen (XSTR (x, 0)) + 1);
+ break;
+ default:
+ break;
+ }
+}
+
+}
new file mode 100644
@@ -0,0 +1,32 @@
+/* Register Transfer Language (RTL) hash functions.
+ Copyright (C) 1987-2014 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#ifndef RTL_HASH_H
+#define RTL_HASH_H 1
+
+#include "inchash.h"
+
+namespace inchash
+{
+
+extern void add_rtx (const_rtx, hash &);
+
+}
+
+#endif
From: Andi Kleen <ak@linux.intel.com> Convert dwarf2out and rtl.c to the new inchash interface. I moved the rtl hash code to another file to avoid having to link all the hash code into the generator functions. v2: Removed ??? comment. gcc/: 2014-07-29 Andi Kleen <ak@linux.intel.com> * Makefile.in (OBJS): Add rtlhash.o * dwarf2out.c (addr_table_entry_do_hash): Convert to inchash. (loc_checksum): Dito. (loc_checksum_ordered): Dito. (hash_loc_operands): Dito. (hash_locs): Dito. (hash_loc_list): Dito. * rtl.c (iterative_hash_rtx): Moved to rtlhash.c * rtl.h (iterative_hash_rtx): Moved to rtlhash.h * rtlhash.c: New file. * rtlhash.h: New file. --- gcc/Makefile.in | 1 + gcc/dwarf2out.c | 125 +++++++++++++++++++++++++++++--------------------------- gcc/rtl.c | 79 +---------------------------------- gcc/rtl.h | 1 - gcc/rtlhash.c | 107 ++++++++++++++++++++++++++++++++++++++++++++++++ gcc/rtlhash.h | 32 +++++++++++++++ 6 files changed, 206 insertions(+), 139 deletions(-) create mode 100644 gcc/rtlhash.c create mode 100644 gcc/rtlhash.h