#include "flags.h"
#include "hard-reg-set.h"
#include "regs.h"
+#include "rtlhash.h"
#include "insn-config.h"
#include "reload.h"
#include "function.h"
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
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. */
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);
}
/* 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;
}
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;
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:
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 ();
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:
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:
= 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 */
= 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 ();
/* 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;
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. */
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. */
--- /dev/null
+/* 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;
+ }
+}
+
+}