Patchwork Hash table changes from cxx-conversion branch - config part

login
register
mail settings
Submitter Lawrence Crowl
Date April 24, 2013, 7:02 p.m.
Message ID <CAGqM8fbbORKP1N1UKSLO1teMjNdhutvioLvBG4+uRRmhqE=SRQ@mail.gmail.com>
Download mbox | patch
Permalink /patch/239301/
State New
Headers show

Comments

Lawrence Crowl - April 24, 2013, 7:02 p.m.
This patch is a consolodation of the hash_table patches to the
cxx-conversion branch for files under gcc/config.

Recipients:
config/arm/arm.c - nickc@redhat.com, ramana.radhakrishnan@arm.com
config/ia64/ia64.c - wilson@tuliptree.org, sellcey@mips.com
config/mips/mips.c - rdsandiford@googlemail.com
config/sol2.c - ro@CeBiTec.Uni-Bielefeld.DE
config/i386/winnt.c - cgf@gcc.gnu.org, ktietz@redhat.com
global - rguenther@suse.de, dnovillo@google.com

Update various hash tables from htab_t to hash_table.
Modify types and calls to match.

* config/arm/arm.c'arm_libcall_uses_aapcs_base::libcall_htab

Fold libcall_eq and libcall_hash into new struct libcall_hasher.

* config/ia64/ia64.c'bundle_state_table

Fold bundle_state_hash and bundle_state_eq_p into new struct
bundle_state_hasher.

* config/mips/mips.c'mips_offset_table

Fold mips_lo_sum_offset_hash and mips_lo_sum_offset_eq into new
struct mips_lo_sum_offset_hasher.

In mips_reorg_process_insns, change call to for_each_rtx to pass
a pointer to the hash_table rather than a htab_t.  This change
requires then dereferencing that pointer in mips_record_lo_sum to
obtain the hash_table.

* config/sol2.c'solaris_comdat_htab

Fold comdat_hash and comdat_eq into new struct comdat_entry_hasher.

* config/i386/winnt.c'i386_pe_section_type_flags::htab

* config/i386/winnt.c'i386_find_on_wrapper_list::wrappers

Fold wrapper_strcmp into new struct wrapped_symbol_hasher.

Tested on x86_64.  Tested with config-list.mk.
Richard Sandiford - April 25, 2013, 6:39 a.m.
Nice :-)  MIPS parts look good apart from a minor formatting nit:

Lawrence Crowl <crowl@googlers.com> writes:
> @@ -15945,7 +15958,8 @@ static int
>  mips_record_lo_sum (rtx *loc, void *data)
>  {
>    if (GET_CODE (*loc) == LO_SUM)
> -    mips_lo_sum_offset_lookup ((htab_t) data, XEXP (*loc, 1), INSERT);
> +    mips_lo_sum_offset_lookup (*(mips_offset_table*)data,
> +			       XEXP (*loc, 1), INSERT);

the space before "data" should be kept.

Thanks,
Richard
Ramana Radhakrishnan - April 25, 2013, 11:58 a.m.
On 04/24/13 20:02, Lawrence Crowl wrote:
> This patch is a consolodation of the hash_table patches to the
> cxx-conversion branch for files under gcc/config.
>
> Recipients:
> config/arm/arm.c - nickc@redhat.com, ramana.radhakrishnan@arm.com
> config/ia64/ia64.c - wilson@tuliptree.org, sellcey@mips.com
> config/mips/mips.c - rdsandiford@googlemail.com
> config/sol2.c - ro@CeBiTec.Uni-Bielefeld.DE
> config/i386/winnt.c - cgf@gcc.gnu.org, ktietz@redhat.com
> global - rguenther@suse.de, dnovillo@google.com
>
> Update various hash tables from htab_t to hash_table.
> Modify types and calls to match.
>
> * config/arm/arm.c'arm_libcall_uses_aapcs_base::libcall_htab

LGTM- The ARM bits are ok to apply.

Thanks,
Ramana
Rainer Orth - April 26, 2013, 10:47 a.m.
Lawrence,

> * config/sol2.c'solaris_comdat_htab
>
> Fold comdat_hash and comdat_eq into new struct comdat_entry_hasher.
[...]
> Index: gcc/ChangeLog
>
> 2013-04-24  Lawrence Crowl  <crowl@google.com>
> 	* config/sol2.c (solaris_comdat_htab):
> 	Change type to hash_table.  Update dependent calls and types.
>
> 	* config/t-sol2: Update for above.

Just a nit: your ChangeLog entries are formatted strangely: No newline
immetiately after the colons, and better group e.g. all *sol2* entries
together without a blank line between.

Unfortunately, your mail client mangled the patch, so I had to apply it
manually.  Once that was done, it survived a i386-pc-solaris2.10
bootstrap without regressions, so the Solaris parts are ok.

Thanks.
        Rainer
Lawrence Crowl - May 13, 2013, 10:03 p.m.
I still have not heard from i386 or ia64 folks.  Anyone?

On 4/24/13, Lawrence Crowl <crowl@googlers.com> wrote:
> This patch is a consolodation of the hash_table patches to the
> cxx-conversion branch for files under gcc/config.
>
> Recipients:
> config/arm/arm.c - nickc@redhat.com, ramana.radhakrishnan@arm.com
> config/ia64/ia64.c - wilson@tuliptree.org, sellcey@mips.com
> config/mips/mips.c - rdsandiford@googlemail.com
> config/sol2.c - ro@CeBiTec.Uni-Bielefeld.DE
> config/i386/winnt.c - cgf@gcc.gnu.org, ktietz@redhat.com
> global - rguenther@suse.de, dnovillo@google.com
>
> Update various hash tables from htab_t to hash_table.
> Modify types and calls to match.
>
> * config/arm/arm.c'arm_libcall_uses_aapcs_base::libcall_htab
>
> Fold libcall_eq and libcall_hash into new struct libcall_hasher.
>
> * config/ia64/ia64.c'bundle_state_table
>
> Fold bundle_state_hash and bundle_state_eq_p into new struct
> bundle_state_hasher.
>
> * config/mips/mips.c'mips_offset_table
>
> Fold mips_lo_sum_offset_hash and mips_lo_sum_offset_eq into new
> struct mips_lo_sum_offset_hasher.
>
> In mips_reorg_process_insns, change call to for_each_rtx to pass
> a pointer to the hash_table rather than a htab_t.  This change
> requires then dereferencing that pointer in mips_record_lo_sum to
> obtain the hash_table.
>
> * config/sol2.c'solaris_comdat_htab
>
> Fold comdat_hash and comdat_eq into new struct comdat_entry_hasher.
>
> * config/i386/winnt.c'i386_pe_section_type_flags::htab
>
> * config/i386/winnt.c'i386_find_on_wrapper_list::wrappers
>
> Fold wrapper_strcmp into new struct wrapped_symbol_hasher.
>
> Tested on x86_64.  Tested with config-list.mk.
>
>
> Index: gcc/ChangeLog
>
> 2013-04-24  Lawrence Crowl  <crowl@google.com>
>
> 	* config/arm/t-arm: Update for below.
>
> 	* config/arm/arm.c (arm_libcall_uses_aapcs_base::libcall_htab):
> 	Change type to hash_table.  Update dependent calls and types.
>
> 	* config/i386/t-cygming: Update for below.
>
> 	* config/i386/t-interix: Update for below.
>
> 	* config/i386/winnt.c (i386_pe_section_type_flags::htab):
> 	Change type to hash_table.  Update dependent calls and types.
> 	(i386_find_on_wrapper_list::wrappers): Likewise.
>
> 	* config/ia64/t-ia64: Update for below.
>
> 	* config/ia64/ia64.c (bundle_state_table):
> 	Change type to hash_table.  Update dependent calls and types.
>
> 	* config/mips/mips.c (mips_reorg_process_insns::htab):
> 	Change type to hash_table.  Update dependent calls and types.
>
> 	* config/sol2.c (solaris_comdat_htab):
> 	Change type to hash_table.  Update dependent calls and types.
>
> 	* config/t-sol2: Update for above.
>
> Index: gcc/config/ia64/ia64.c
> ===================================================================
> --- gcc/config/ia64/ia64.c	(revision 198213)
> +++ gcc/config/ia64/ia64.c	(working copy)
> @@ -47,7 +47,7 @@ along with GCC; see the file COPYING3.
>  #include "target-def.h"
>  #include "common/common-target.h"
>  #include "tm_p.h"
> -#include "hashtab.h"
> +#include "hash-table.h"
>  #include "langhooks.h"
>  #include "gimple.h"
>  #include "intl.h"
> @@ -257,8 +257,6 @@ static struct bundle_state *get_free_bun
>  static void free_bundle_state (struct bundle_state *);
>  static void initiate_bundle_states (void);
>  static void finish_bundle_states (void);
> -static unsigned bundle_state_hash (const void *);
> -static int bundle_state_eq_p (const void *, const void *);
>  static int insert_bundle_state (struct bundle_state *);
>  static void initiate_bundle_state_table (void);
>  static void finish_bundle_state_table (void);
> @@ -8528,18 +8526,21 @@ finish_bundle_states (void)
>      }
>  }
>
> -/* Hash table of the bundle states.  The key is dfa_state and insn_num
> -   of the bundle states.  */
> +/* Hashtable helpers.  */
>
> -static htab_t bundle_state_table;
> +struct bundle_state_hasher : typed_noop_remove <bundle_state>
> +{
> +  typedef bundle_state value_type;
> +  typedef bundle_state compare_type;
> +  static inline hashval_t hash (const value_type *);
> +  static inline bool equal (const value_type *, const compare_type *);
> +};
>
>  /* The function returns hash of BUNDLE_STATE.  */
>
> -static unsigned
> -bundle_state_hash (const void *bundle_state)
> +inline hashval_t
> +bundle_state_hasher::hash (const value_type *state)
>  {
> -  const struct bundle_state *const state
> -    = (const struct bundle_state *) bundle_state;
>    unsigned result, i;
>
>    for (result = i = 0; i < dfa_state_size; i++)
> @@ -8550,19 +8551,20 @@ bundle_state_hash (const void *bundle_st
>
>  /* The function returns nonzero if the bundle state keys are equal.  */
>
> -static int
> -bundle_state_eq_p (const void *bundle_state_1, const void *bundle_state_2)
> +inline bool
> +bundle_state_hasher::equal (const value_type *state1,
> +			    const compare_type *state2)
>  {
> -  const struct bundle_state *const state1
> -    = (const struct bundle_state *) bundle_state_1;
> -  const struct bundle_state *const state2
> -    = (const struct bundle_state *) bundle_state_2;
> -
>    return (state1->insn_num == state2->insn_num
>  	  && memcmp (state1->dfa_state, state2->dfa_state,
>  		     dfa_state_size) == 0);
>  }
>
> +/* Hash table of the bundle states.  The key is dfa_state and insn_num
> +   of the bundle states.  */
> +
> +static hash_table <bundle_state_hasher> bundle_state_table;
> +
>  /* The function inserts the BUNDLE_STATE into the hash table.  The
>     function returns nonzero if the bundle has been inserted into the
>     table.  The table contains the best bundle state with given key.  */
> @@ -8570,39 +8572,35 @@ bundle_state_eq_p (const void *bundle_st
>  static int
>  insert_bundle_state (struct bundle_state *bundle_state)
>  {
> -  void **entry_ptr;
> +  struct bundle_state **entry_ptr;
>
> -  entry_ptr = htab_find_slot (bundle_state_table, bundle_state, INSERT);
> +  entry_ptr = bundle_state_table.find_slot (bundle_state, INSERT);
>    if (*entry_ptr == NULL)
>      {
>        bundle_state->next = index_to_bundle_states
> [bundle_state->insn_num];
>        index_to_bundle_states [bundle_state->insn_num] = bundle_state;
> -      *entry_ptr = (void *) bundle_state;
> +      *entry_ptr = bundle_state;
>        return TRUE;
>      }
> -  else if (bundle_state->cost < ((struct bundle_state *) *entry_ptr)->cost
> -	   || (bundle_state->cost == ((struct bundle_state *) *entry_ptr)->cost
> -	       && (((struct bundle_state *)*entry_ptr)->accumulated_insns_num
> +  else if (bundle_state->cost < (*entry_ptr)->cost
> +	   || (bundle_state->cost == (*entry_ptr)->cost
> +	       && ((*entry_ptr)->accumulated_insns_num
>  		   > bundle_state->accumulated_insns_num
> -		   || (((struct bundle_state *)
> -			*entry_ptr)->accumulated_insns_num
> +		   || ((*entry_ptr)->accumulated_insns_num
>  		       == bundle_state->accumulated_insns_num
> -		       && (((struct bundle_state *)
> -			    *entry_ptr)->branch_deviation
> +		       && ((*entry_ptr)->branch_deviation
>  			   > bundle_state->branch_deviation
> -			   || (((struct bundle_state *)
> -				*entry_ptr)->branch_deviation
> +			   || ((*entry_ptr)->branch_deviation
>  			       == bundle_state->branch_deviation
> -			       && ((struct bundle_state *)
> -				   *entry_ptr)->middle_bundle_stops
> +			       && (*entry_ptr)->middle_bundle_stops
>  			       > bundle_state->middle_bundle_stops))))))
>
>      {
>        struct bundle_state temp;
>
> -      temp = *(struct bundle_state *) *entry_ptr;
> -      *(struct bundle_state *) *entry_ptr = *bundle_state;
> -      ((struct bundle_state *) *entry_ptr)->next = temp.next;
> +      temp = **entry_ptr;
> +      **entry_ptr = *bundle_state;
> +      (*entry_ptr)->next = temp.next;
>        *bundle_state = temp;
>      }
>    return FALSE;
> @@ -8613,8 +8611,7 @@ insert_bundle_state (struct bundle_state
>  static void
>  initiate_bundle_state_table (void)
>  {
> -  bundle_state_table = htab_create (50, bundle_state_hash,
> bundle_state_eq_p,
> -				    (htab_del) 0);
> +  bundle_state_table.create (50);
>  }
>
>  /* Finish work with the hash table.  */
> @@ -8622,7 +8619,7 @@ initiate_bundle_state_table (void)
>  static void
>  finish_bundle_state_table (void)
>  {
> -  htab_delete (bundle_state_table);
> +  bundle_state_table.dispose ();
>  }
>
>  
> Index: gcc/config/ia64/t-ia64
> ===================================================================
> --- gcc/config/ia64/t-ia64	(revision 198213)
> +++ gcc/config/ia64/t-ia64	(working copy)
> @@ -24,4 +24,5 @@ ia64-c.o: $(srcdir)/config/ia64/ia64-c.c
>  # genattrtab generates very long string literals.
>  insn-attrtab.o-warn = -Wno-error
>
> -ia64.o: debug.h $(PARAMS_H) sel-sched.h reload.h $(OPTS_H) dumpfile.h
> +ia64.o: $(srcdir)/config/ia64/ia64.c debug.h $(PARAMS_H) sel-sched.h
> reload.h \
> +	$(OPTS_H) dumpfile.h $(HASH_TABLE_H)
> Index: gcc/config/mips/mips.c
> ===================================================================
> --- gcc/config/mips/mips.c	(revision 198213)
> +++ gcc/config/mips/mips.c	(working copy)
> @@ -43,7 +43,7 @@ along with GCC; see the file COPYING3.
>  #include "tm_p.h"
>  #include "ggc.h"
>  #include "gstab.h"
> -#include "hashtab.h"
> +#include "hash-table.h"
>  #include "debug.h"
>  #include "target.h"
>  #include "target-def.h"
> @@ -15883,30 +15883,43 @@ mips_hash_base (rtx base)
>    return hash_rtx (base, GET_MODE (base), &do_not_record_p, NULL, false);
>  }
>
> +/* Hashtable helpers.  */
> +
> +struct mips_lo_sum_offset_hasher : typed_free_remove <mips_lo_sum_offset>
> +{
> +  typedef mips_lo_sum_offset value_type;
> +  typedef rtx_def compare_type;
> +  static inline hashval_t hash (const value_type *);
> +  static inline bool equal (const value_type *, const compare_type *);
> +};
> +
>  /* Hash-table callbacks for mips_lo_sum_offsets.  */
>
> -static hashval_t
> -mips_lo_sum_offset_hash (const void *entry)
> +inline hashval_t
> +mips_lo_sum_offset_hasher::hash (const value_type *entry)
>  {
> -  return mips_hash_base (((const struct mips_lo_sum_offset *)
> entry)->base);
> +  return mips_hash_base (entry->base);
>  }
>
> -static int
> -mips_lo_sum_offset_eq (const void *entry, const void *value)
> +inline bool
> +mips_lo_sum_offset_hasher::equal (const value_type *entry,
> +				  const compare_type *value)
>  {
> -  return rtx_equal_p (((const struct mips_lo_sum_offset *) entry)->base,
> -		      (const_rtx) value);
> +  return rtx_equal_p (entry->base, value);
>  }
>
> +typedef hash_table <mips_lo_sum_offset_hasher> mips_offset_table;
> +
>  /* Look up symbolic constant X in HTAB, which is a hash table of
>     mips_lo_sum_offsets.  If OPTION is NO_INSERT, return true if X can be
>     paired with a recorded LO_SUM, otherwise record X in the table.  */
>
>  static bool
> -mips_lo_sum_offset_lookup (htab_t htab, rtx x, enum insert_option option)
> +mips_lo_sum_offset_lookup (mips_offset_table htab, rtx x,
> +			   enum insert_option option)
>  {
>    rtx base, offset;
> -  void **slot;
> +  mips_lo_sum_offset **slot;
>    struct mips_lo_sum_offset *entry;
>
>    /* Split X into a base and offset.  */
> @@ -15915,7 +15928,7 @@ mips_lo_sum_offset_lookup (htab_t htab,
>      base = UNSPEC_ADDRESS (base);
>
>    /* Look up the base in the hash table.  */
> -  slot = htab_find_slot_with_hash (htab, base, mips_hash_base (base),
> option);
> +  slot = htab.find_slot_with_hash (base, mips_hash_base (base), option);
>    if (slot == NULL)
>      return false;
>
> @@ -15945,7 +15958,8 @@ static int
>  mips_record_lo_sum (rtx *loc, void *data)
>  {
>    if (GET_CODE (*loc) == LO_SUM)
> -    mips_lo_sum_offset_lookup ((htab_t) data, XEXP (*loc, 1), INSERT);
> +    mips_lo_sum_offset_lookup (*(mips_offset_table*)data,
> +			       XEXP (*loc, 1), INSERT);
>    return 0;
>  }
>
> @@ -15954,7 +15968,7 @@ mips_record_lo_sum (rtx *loc, void *data
>     LO_SUMs in the current function.  */
>
>  static bool
> -mips_orphaned_high_part_p (htab_t htab, rtx insn)
> +mips_orphaned_high_part_p (mips_offset_table htab, rtx insn)
>  {
>    enum mips_symbol_type type;
>    rtx x, set;
> @@ -16062,7 +16076,7 @@ mips_reorg_process_insns (void)
>  {
>    rtx insn, last_insn, subinsn, next_insn, lo_reg, delayed_reg;
>    int hilo_delay;
> -  htab_t htab;
> +  mips_offset_table htab;
>
>    /* Force all instructions to be split into their final form.  */
>    split_all_insns_noflow ();
> @@ -16099,14 +16113,13 @@ mips_reorg_process_insns (void)
>    if (TARGET_FIX_VR4130 && !ISA_HAS_MACCHI)
>      cfun->machine->all_noreorder_p = false;
>
> -  htab = htab_create (37, mips_lo_sum_offset_hash,
> -		      mips_lo_sum_offset_eq, free);
> +  htab.create (37);
>
>    /* Make a first pass over the instructions, recording all the LO_SUMs.
> */
>    for (insn = get_insns (); insn != 0; insn = NEXT_INSN (insn))
>      FOR_EACH_SUBINSN (subinsn, insn)
>        if (USEFUL_INSN_P (subinsn))
> -	for_each_rtx (&PATTERN (subinsn), mips_record_lo_sum, htab);
> +	for_each_rtx (&PATTERN (subinsn), mips_record_lo_sum, &htab);
>
>    last_insn = 0;
>    hilo_delay = 2;
> @@ -16163,7 +16176,7 @@ mips_reorg_process_insns (void)
>  	}
>      }
>
> -  htab_delete (htab);
> +  htab.dispose ();
>  }
>
>  /* Return true if the function has a long branch instruction.  */
> Index: gcc/config/sol2.c
> ===================================================================
> --- gcc/config/sol2.c	(revision 198213)
> +++ gcc/config/sol2.c	(working copy)
> @@ -29,7 +29,7 @@ along with GCC; see the file COPYING3.
>  #include "tm_p.h"
>  #include "diagnostic-core.h"
>  #include "ggc.h"
> -#include "hashtab.h"
> +#include "hash-table.h"
>
>  tree solaris_pending_aligns, solaris_pending_inits, solaris_pending_finis;
>
> @@ -157,10 +157,6 @@ solaris_assemble_visibility (tree decl,
>  #endif
>  }
>
> -/* Hash table of group signature symbols.  */
> -
> -static htab_t solaris_comdat_htab;
> -
>  /* Group section information entry stored in solaris_comdat_htab.  */
>
>  typedef struct comdat_entry
> @@ -171,25 +167,34 @@ typedef struct comdat_entry
>    const char *sig;
>  } comdat_entry;
>
> -/* Helper routines for maintaining solaris_comdat_htab.  */
> +/* Helpers for maintaining solaris_comdat_htab.  */
>
> -static hashval_t
> -comdat_hash (const void *p)
> +struct comdat_entry_hasher : typed_noop_remove <comdat_entry>
>  {
> -  const comdat_entry *entry = (const comdat_entry *) p;
> +  typedef comdat_entry value_type;
> +  typedef comdat_entry compare_type;
> +  static inline hashval_t hash (const value_type *);
> +  static inline bool equal (const value_type *, const compare_type *);
> +  static inline void remove (value_type *);
> +};
>
> +inline hashval_t
> +comdat_entry_hasher::hash (const value_type *entry)
> +{
>    return htab_hash_string (entry->sig);
>  }
>
> -static int
> -comdat_eq (const void *p1, const void *p2)
> +inline bool
> +comdat_entry_hasher::equal (const value_type *entry1,
> +			    const compare_type *entry2)
>  {
> -  const comdat_entry *entry1 = (const comdat_entry *) p1;
> -  const comdat_entry *entry2 = (const comdat_entry *) p2;
> -
>    return strcmp (entry1->sig, entry2->sig) == 0;
>  }
>
> +/* Hash table of group signature symbols.  */
> +
> +static hash_table <comdat_entry_hasher> solaris_comdat_htab;
> +
>  /* Output assembly to switch to COMDAT group section NAME with attributes
>     FLAGS and group signature symbol DECL, using Sun as syntax.  */
>
> @@ -229,12 +234,11 @@ solaris_elf_asm_comdat_section (const ch
>       identify the missing ones without changing the affected frontents,
>       remember the signature symbols and emit those not marked
>       TREE_SYMBOL_REFERENCED in solaris_file_end.  */
> -  if (solaris_comdat_htab == NULL)
> -    solaris_comdat_htab = htab_create_alloc (37, comdat_hash, comdat_eq,
> NULL,
> -					     xcalloc, free);
> +  if (!solaris_comdat_htab.is_created ())
> +    solaris_comdat_htab.create (37);
>
>    entry.sig = signature;
> -  slot = (comdat_entry **) htab_find_slot (solaris_comdat_htab,
> &entry, INSERT);
> +  slot = solaris_comdat_htab.find_slot (&entry, INSERT);
>
>    if (*slot == NULL)
>      {
> @@ -250,10 +254,11 @@ solaris_elf_asm_comdat_section (const ch
>
>  /* Define unreferenced COMDAT group signature symbol corresponding to SLOT.
>  */
>
> -static int
> -solaris_define_comdat_signature (void **slot, void *aux ATTRIBUTE_UNUSED)
> +int
> +solaris_define_comdat_signature (comdat_entry **slot,
> +				 void *aux ATTRIBUTE_UNUSED)
>  {
> -  comdat_entry *entry = *(comdat_entry **) slot;
> +  comdat_entry *entry = *slot;
>    tree decl = entry->decl;
>
>    if (TREE_CODE (decl) != IDENTIFIER_NODE)
> @@ -277,10 +282,10 @@ solaris_define_comdat_signature (void **
>  void
>  solaris_file_end (void)
>  {
> -  if (solaris_comdat_htab == NULL)
> +  if (!solaris_comdat_htab.is_created ())
>      return;
>
> -  htab_traverse (solaris_comdat_htab, solaris_define_comdat_signature,
> NULL);
> +  solaris_comdat_htab.traverse <void *,
> solaris_define_comdat_signature> (NULL);
>  }
>
>  void
> Index: gcc/config/i386/winnt.c
> ===================================================================
> --- gcc/config/i386/winnt.c	(revision 198213)
> +++ gcc/config/i386/winnt.c	(working copy)
> @@ -30,7 +30,7 @@ along with GCC; see the file COPYING3.
>  #include "flags.h"
>  #include "tm_p.h"
>  #include "diagnostic-core.h"
> -#include "hashtab.h"
> +#include "hash-table.h"
>  #include "langhooks.h"
>  #include "ggc.h"
>  #include "target.h"
> @@ -449,7 +449,7 @@ i386_pe_reloc_rw_mask (void)
>  unsigned int
>  i386_pe_section_type_flags (tree decl, const char *name, int reloc)
>  {
> -  static htab_t htab;
> +  static hash_table <pointer_hash <unsigned int> > htab;
>    unsigned int flags;
>    unsigned int **slot;
>
> @@ -460,8 +460,8 @@ i386_pe_section_type_flags (tree decl, c
>    /* The names we put in the hashtable will always be the unique
>       versions given to us by the stringtable, so we can just use
>       their addresses as the keys.  */
> -  if (!htab)
> -    htab = htab_create (31, htab_hash_pointer, htab_eq_pointer, NULL);
> +  if (!htab.is_created ())
> +    htab.create (31);
>
>    if (decl && TREE_CODE (decl) == FUNCTION_DECL)
>      flags = SECTION_CODE;
> @@ -480,7 +480,7 @@ i386_pe_section_type_flags (tree decl, c
>      flags |= SECTION_LINKONCE;
>
>    /* See if we already have an entry for this section.  */
> -  slot = (unsigned int **) htab_find_slot (htab, name, INSERT);
> +  slot = htab.find_slot ((unsigned int *)name, INSERT);
>    if (!*slot)
>      {
>        *slot = (unsigned int *) xmalloc (sizeof (unsigned int));
> @@ -714,12 +714,29 @@ i386_pe_record_stub (const char *name)
>
>  #ifdef CXX_WRAP_SPEC_LIST
>
> +/* Hashtable helpers.  */
> +
> +struct wrapped_symbol_hasher : typed_noop_remove <char>
> +{
> +  typedef char value_type;
> +  typedef char compare_type;
> +  static inline hashval_t hash (const value_type *);
> +  static inline bool equal (const value_type *, const compare_type *);
> +  static inline void remove (value_type *);
> +};
> +
> +inline hashval_t
> +wrapped_symbol_hasher::hash (const value_type *v)
> +{
> +  return htab_hash_string (v);
> +}
> +
>  /*  Hash table equality helper function.  */
>
> -static int
> -wrapper_strcmp (const void *x, const void *y)
> +inline bool
> +wrapped_symbol_hasher::equal (const value_type *x, const compare_type *y)
>  {
> -  return !strcmp ((const char *) x, (const char *) y);
> +  return !strcmp (x, y);
>  }
>
>  /* Search for a function named TARGET in the list of library wrappers
> @@ -733,7 +750,7 @@ static const char *
>  i386_find_on_wrapper_list (const char *target)
>  {
>    static char first_time = 1;
> -  static htab_t wrappers;
> +  static hash_table <wrapped_symbol_hasher> wrappers;
>
>    if (first_time)
>      {
> @@ -746,8 +763,7 @@ i386_find_on_wrapper_list (const char *t
>        char *bufptr;
>        /* Breaks up the char array into separated strings
>           strings and enter them into the hash table.  */
> -      wrappers = htab_create_alloc (8, htab_hash_string, wrapper_strcmp,
> -	0, xcalloc, free);
> +      wrappers.create (8);
>        for (bufptr = wrapper_list_buffer; *bufptr; ++bufptr)
>  	{
>  	  char *found = NULL;
> @@ -760,12 +776,12 @@ i386_find_on_wrapper_list (const char *t
>  	  if (*bufptr)
>  	    *bufptr = 0;
>  	  if (found)
> -	    *htab_find_slot (wrappers, found, INSERT) = found;
> +	    *wrappers.find_slot (found, INSERT) = found;
>  	}
>        first_time = 0;
>      }
>
> -  return (const char *) htab_find (wrappers, target);
> +  return wrappers.find (target);
>  }
>
>  #endif /* CXX_WRAP_SPEC_LIST */
> Index: gcc/config/i386/t-interix
> ===================================================================
> --- gcc/config/i386/t-interix	(revision 198213)
> +++ gcc/config/i386/t-interix	(working copy)
> @@ -18,7 +18,7 @@
>
>  winnt.o: $(srcdir)/config/i386/winnt.c $(CONFIG_H) $(SYSTEM_H) coretypes.h
> \
>    $(TM_H) $(RTL_H) $(REGS_H) hard-reg-set.h output.h $(TREE_H) flags.h \
> -  $(TM_P_H) $(HASHTAB_H) $(GGC_H)
> +  $(TM_P_H) $(HASH_TABLE_H) $(GGC_H)
>  	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
>  		$(srcdir)/config/i386/winnt.c
>
> Index: gcc/config/i386/t-cygming
> ===================================================================
> --- gcc/config/i386/t-cygming	(revision 198213)
> +++ gcc/config/i386/t-cygming	(working copy)
> @@ -22,7 +22,7 @@ LIMITS_H_TEST = true
>
>  winnt.o: $(srcdir)/config/i386/winnt.c $(CONFIG_H) $(SYSTEM_H) coretypes.h
> \
>    $(TM_H) $(RTL_H) $(REGS_H) hard-reg-set.h output.h $(TREE_H) flags.h \
> -  $(TM_P_H) $(HASHTAB_H) $(GGC_H) $(LTO_STREAMER_H)
> +  $(TM_P_H) $(HASH_TABLE_H) $(GGC_H) $(LTO_STREAMER_H)
>  	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
>  	$(srcdir)/config/i386/winnt.c
>
> Index: gcc/config/t-sol2
> ===================================================================
> --- gcc/config/t-sol2	(revision 198213)
> +++ gcc/config/t-sol2	(working copy)
> @@ -34,5 +34,5 @@ sol2-stubs.o: $(srcdir)/config/sol2-stub
>
>  # Solaris-specific attributes
>  sol2.o: $(srcdir)/config/sol2.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
> -  tree.h output.h $(TM_H) $(TARGET_H) $(TM_P_H) $(GGC_H)
> +  tree.h output.h $(TM_H) $(TARGET_H) $(TM_P_H) $(GGC_H) $(HASH_TABLE_H)
>  	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
> Index: gcc/config/arm/arm.c
> ===================================================================
> --- gcc/config/arm/arm.c	(revision 198213)
> +++ gcc/config/arm/arm.c	(working copy)
> @@ -23,6 +23,7 @@
>  #include "config.h"
>  #include "system.h"
>  #include "coretypes.h"
> +#include "hash-table.h"
>  #include "tm.h"
>  #include "rtl.h"
>  #include "tree.h"
> @@ -3812,36 +3813,48 @@ arm_function_value(const_tree type, cons
>    return arm_libcall_value_1 (mode);
>  }
>
> -static int
> -libcall_eq (const void *p1, const void *p2)
> +/* libcall hashtable helpers.  */
> +
> +struct libcall_hasher : typed_noop_remove <rtx_def>
>  {
> -  return rtx_equal_p ((const_rtx) p1, (const_rtx) p2);
> +  typedef rtx_def value_type;
> +  typedef rtx_def compare_type;
> +  static inline hashval_t hash (const value_type *);
> +  static inline bool equal (const value_type *, const compare_type *);
> +  static inline void remove (value_type *);
> +};
> +
> +inline bool
> +libcall_hasher::equal (const value_type *p1, const compare_type *p2)
> +{
> +  return rtx_equal_p (p1, p2);
>  }
>
> -static hashval_t
> -libcall_hash (const void *p1)
> +inline hashval_t
> +libcall_hasher::hash (const value_type *p1)
>  {
> -  return hash_rtx ((const_rtx) p1, VOIDmode, NULL, NULL, FALSE);
> +  return hash_rtx (p1, VOIDmode, NULL, NULL, FALSE);
>  }
>
> +typedef hash_table <libcall_hasher> libcall_table_type;
> +
>  static void
> -add_libcall (htab_t htab, rtx libcall)
> +add_libcall (libcall_table_type htab, rtx libcall)
>  {
> -  *htab_find_slot (htab, libcall, INSERT) = libcall;
> +  *htab.find_slot (libcall, INSERT) = libcall;
>  }
>
>  static bool
>  arm_libcall_uses_aapcs_base (const_rtx libcall)
>  {
>    static bool init_done = false;
> -  static htab_t libcall_htab;
> +  static libcall_table_type libcall_htab;
>
>    if (!init_done)
>      {
>        init_done = true;
>
> -      libcall_htab = htab_create (31, libcall_hash, libcall_eq,
> -				  NULL);
> +      libcall_htab.create (31);
>        add_libcall (libcall_htab,
>  		   convert_optab_libfunc (sfloat_optab, SFmode, SImode));
>        add_libcall (libcall_htab,
> @@ -3900,7 +3913,7 @@ arm_libcall_uses_aapcs_base (const_rtx l
>  							DFmode));
>      }
>
> -  return libcall && htab_find (libcall_htab, libcall) != NULL;
> +  return libcall && libcall_htab.find (libcall) != NULL;
>  }
>
>  static rtx
> Index: gcc/config/arm/t-arm
> ===================================================================
> --- gcc/config/arm/t-arm	(revision 198213)
> +++ gcc/config/arm/t-arm	(working copy)
> @@ -78,8 +78,8 @@ $(srcdir)/config/arm/arm-tables.opt: $(s
>  	$(SHELL) $(srcdir)/config/arm/genopt.sh $(srcdir)/config/arm > \
>  		$(srcdir)/config/arm/arm-tables.opt
>
> -arm.o: $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
> -  $(RTL_H) $(TREE_H) $(OBSTACK_H) $(REGS_H) hard-reg-set.h \
> +arm.o: $(srcdir)/config/arm/arm.c $(CONFIG_H) $(SYSTEM_H) coretypes.h
> $(TM_H) \
> +  $(RTL_H) $(TREE_H) $(HASH_TABLE_H) $(OBSTACK_H) $(REGS_H) hard-reg-set.h
> \
>    insn-config.h conditions.h output.h dumpfile.h \
>    $(INSN_ATTR_H) $(FLAGS_H) reload.h $(FUNCTION_H) \
>    $(EXPR_H) $(OPTABS_H) $(RECOG_H) $(CGRAPH_H) \
>
> --
> Lawrence Crowl
>
Steve Ellcey - May 14, 2013, 3:08 p.m.
On Mon, 2013-05-13 at 15:03 -0700, Lawrence Crowl wrote:
> I still have not heard from i386 or ia64 folks.  Anyone?

The IA64 part looks OK to me.

Steve Ellcey
sellcey@imgtec.com (sellcey@mips.com)
Lawrence Crowl - May 30, 2013, 2:24 a.m.
On 5/21/13, Diego Novillo <dnovillo@google.com> wrote:
> On May 13, 2013 Lawrence Crowl <crowl@googlers.com> wrote:
> > I still have not heard from i386 or ia64 folks.  Anyone?
>
> The i386 bits look fine to me as well.  Please wait 48 hours to
> give the i386 maintainers a chance to object.

Committed.

Patch

Index: gcc/ChangeLog

2013-04-24  Lawrence Crowl  <crowl@google.com>

	* config/arm/t-arm: Update for below.

	* config/arm/arm.c (arm_libcall_uses_aapcs_base::libcall_htab):
	Change type to hash_table.  Update dependent calls and types.

	* config/i386/t-cygming: Update for below.

	* config/i386/t-interix: Update for below.

	* config/i386/winnt.c (i386_pe_section_type_flags::htab):
	Change type to hash_table.  Update dependent calls and types.
	(i386_find_on_wrapper_list::wrappers): Likewise.

	* config/ia64/t-ia64: Update for below.

	* config/ia64/ia64.c (bundle_state_table):
	Change type to hash_table.  Update dependent calls and types.

	* config/mips/mips.c (mips_reorg_process_insns::htab):
	Change type to hash_table.  Update dependent calls and types.

	* config/sol2.c (solaris_comdat_htab):
	Change type to hash_table.  Update dependent calls and types.

	* config/t-sol2: Update for above.

Index: gcc/config/ia64/ia64.c
===================================================================
--- gcc/config/ia64/ia64.c	(revision 198213)
+++ gcc/config/ia64/ia64.c	(working copy)
@@ -47,7 +47,7 @@  along with GCC; see the file COPYING3.
 #include "target-def.h"
 #include "common/common-target.h"
 #include "tm_p.h"
-#include "hashtab.h"
+#include "hash-table.h"
 #include "langhooks.h"
 #include "gimple.h"
 #include "intl.h"
@@ -257,8 +257,6 @@  static struct bundle_state *get_free_bun
 static void free_bundle_state (struct bundle_state *);
 static void initiate_bundle_states (void);
 static void finish_bundle_states (void);
-static unsigned bundle_state_hash (const void *);
-static int bundle_state_eq_p (const void *, const void *);
 static int insert_bundle_state (struct bundle_state *);
 static void initiate_bundle_state_table (void);
 static void finish_bundle_state_table (void);
@@ -8528,18 +8526,21 @@  finish_bundle_states (void)
     }
 }

-/* Hash table of the bundle states.  The key is dfa_state and insn_num
-   of the bundle states.  */
+/* Hashtable helpers.  */

-static htab_t bundle_state_table;
+struct bundle_state_hasher : typed_noop_remove <bundle_state>
+{
+  typedef bundle_state value_type;
+  typedef bundle_state compare_type;
+  static inline hashval_t hash (const value_type *);
+  static inline bool equal (const value_type *, const compare_type *);
+};

 /* The function returns hash of BUNDLE_STATE.  */

-static unsigned
-bundle_state_hash (const void *bundle_state)
+inline hashval_t
+bundle_state_hasher::hash (const value_type *state)
 {
-  const struct bundle_state *const state
-    = (const struct bundle_state *) bundle_state;
   unsigned result, i;

   for (result = i = 0; i < dfa_state_size; i++)
@@ -8550,19 +8551,20 @@  bundle_state_hash (const void *bundle_st

 /* The function returns nonzero if the bundle state keys are equal.  */

-static int
-bundle_state_eq_p (const void *bundle_state_1, const void *bundle_state_2)
+inline bool
+bundle_state_hasher::equal (const value_type *state1,
+			    const compare_type *state2)
 {
-  const struct bundle_state *const state1
-    = (const struct bundle_state *) bundle_state_1;
-  const struct bundle_state *const state2
-    = (const struct bundle_state *) bundle_state_2;
-
   return (state1->insn_num == state2->insn_num
 	  && memcmp (state1->dfa_state, state2->dfa_state,
 		     dfa_state_size) == 0);
 }

+/* Hash table of the bundle states.  The key is dfa_state and insn_num
+   of the bundle states.  */
+
+static hash_table <bundle_state_hasher> bundle_state_table;
+
 /* The function inserts the BUNDLE_STATE into the hash table.  The
    function returns nonzero if the bundle has been inserted into the
    table.  The table contains the best bundle state with given key.  */
@@ -8570,39 +8572,35 @@  bundle_state_eq_p (const void *bundle_st
 static int
 insert_bundle_state (struct bundle_state *bundle_state)
 {
-  void **entry_ptr;
+  struct bundle_state **entry_ptr;

-  entry_ptr = htab_find_slot (bundle_state_table, bundle_state, INSERT);
+  entry_ptr = bundle_state_table.find_slot (bundle_state, INSERT);
   if (*entry_ptr == NULL)
     {
       bundle_state->next = index_to_bundle_states [bundle_state->insn_num];
       index_to_bundle_states [bundle_state->insn_num] = bundle_state;
-      *entry_ptr = (void *) bundle_state;
+      *entry_ptr = bundle_state;
       return TRUE;
     }
-  else if (bundle_state->cost < ((struct bundle_state *) *entry_ptr)->cost
-	   || (bundle_state->cost == ((struct bundle_state *) *entry_ptr)->cost
-	       && (((struct bundle_state *)*entry_ptr)->accumulated_insns_num
+  else if (bundle_state->cost < (*entry_ptr)->cost
+	   || (bundle_state->cost == (*entry_ptr)->cost
+	       && ((*entry_ptr)->accumulated_insns_num
 		   > bundle_state->accumulated_insns_num
-		   || (((struct bundle_state *)
-			*entry_ptr)->accumulated_insns_num
+		   || ((*entry_ptr)->accumulated_insns_num
 		       == bundle_state->accumulated_insns_num
-		       && (((struct bundle_state *)
-			    *entry_ptr)->branch_deviation
+		       && ((*entry_ptr)->branch_deviation
 			   > bundle_state->branch_deviation
-			   || (((struct bundle_state *)
-				*entry_ptr)->branch_deviation
+			   || ((*entry_ptr)->branch_deviation
 			       == bundle_state->branch_deviation
-			       && ((struct bundle_state *)
-				   *entry_ptr)->middle_bundle_stops
+			       && (*entry_ptr)->middle_bundle_stops
 			       > bundle_state->middle_bundle_stops))))))

     {
       struct bundle_state temp;

-      temp = *(struct bundle_state *) *entry_ptr;
-      *(struct bundle_state *) *entry_ptr = *bundle_state;
-      ((struct bundle_state *) *entry_ptr)->next = temp.next;
+      temp = **entry_ptr;
+      **entry_ptr = *bundle_state;
+      (*entry_ptr)->next = temp.next;
       *bundle_state = temp;
     }
   return FALSE;
@@ -8613,8 +8611,7 @@  insert_bundle_state (struct bundle_state
 static void
 initiate_bundle_state_table (void)
 {
-  bundle_state_table = htab_create (50, bundle_state_hash, bundle_state_eq_p,
-				    (htab_del) 0);
+  bundle_state_table.create (50);
 }

 /* Finish work with the hash table.  */
@@ -8622,7 +8619,7 @@  initiate_bundle_state_table (void)
 static void
 finish_bundle_state_table (void)
 {
-  htab_delete (bundle_state_table);
+  bundle_state_table.dispose ();
 }

 
Index: gcc/config/ia64/t-ia64
===================================================================
--- gcc/config/ia64/t-ia64	(revision 198213)
+++ gcc/config/ia64/t-ia64	(working copy)
@@ -24,4 +24,5 @@  ia64-c.o: $(srcdir)/config/ia64/ia64-c.c
 # genattrtab generates very long string literals.
 insn-attrtab.o-warn = -Wno-error

-ia64.o: debug.h $(PARAMS_H) sel-sched.h reload.h $(OPTS_H) dumpfile.h
+ia64.o: $(srcdir)/config/ia64/ia64.c debug.h $(PARAMS_H) sel-sched.h reload.h \
+	$(OPTS_H) dumpfile.h $(HASH_TABLE_H)
Index: gcc/config/mips/mips.c
===================================================================
--- gcc/config/mips/mips.c	(revision 198213)
+++ gcc/config/mips/mips.c	(working copy)
@@ -43,7 +43,7 @@  along with GCC; see the file COPYING3.
 #include "tm_p.h"
 #include "ggc.h"
 #include "gstab.h"
-#include "hashtab.h"
+#include "hash-table.h"
 #include "debug.h"
 #include "target.h"
 #include "target-def.h"
@@ -15883,30 +15883,43 @@  mips_hash_base (rtx base)
   return hash_rtx (base, GET_MODE (base), &do_not_record_p, NULL, false);
 }

+/* Hashtable helpers.  */
+
+struct mips_lo_sum_offset_hasher : typed_free_remove <mips_lo_sum_offset>
+{
+  typedef mips_lo_sum_offset value_type;
+  typedef rtx_def compare_type;
+  static inline hashval_t hash (const value_type *);
+  static inline bool equal (const value_type *, const compare_type *);
+};
+
 /* Hash-table callbacks for mips_lo_sum_offsets.  */

-static hashval_t
-mips_lo_sum_offset_hash (const void *entry)
+inline hashval_t
+mips_lo_sum_offset_hasher::hash (const value_type *entry)
 {
-  return mips_hash_base (((const struct mips_lo_sum_offset *) entry)->base);
+  return mips_hash_base (entry->base);
 }

-static int
-mips_lo_sum_offset_eq (const void *entry, const void *value)
+inline bool
+mips_lo_sum_offset_hasher::equal (const value_type *entry,
+				  const compare_type *value)
 {
-  return rtx_equal_p (((const struct mips_lo_sum_offset *) entry)->base,
-		      (const_rtx) value);
+  return rtx_equal_p (entry->base, value);
 }

+typedef hash_table <mips_lo_sum_offset_hasher> mips_offset_table;
+
 /* Look up symbolic constant X in HTAB, which is a hash table of
    mips_lo_sum_offsets.  If OPTION is NO_INSERT, return true if X can be
    paired with a recorded LO_SUM, otherwise record X in the table.  */

 static bool
-mips_lo_sum_offset_lookup (htab_t htab, rtx x, enum insert_option option)
+mips_lo_sum_offset_lookup (mips_offset_table htab, rtx x,
+			   enum insert_option option)
 {
   rtx base, offset;
-  void **slot;
+  mips_lo_sum_offset **slot;
   struct mips_lo_sum_offset *entry;

   /* Split X into a base and offset.  */
@@ -15915,7 +15928,7 @@  mips_lo_sum_offset_lookup (htab_t htab,
     base = UNSPEC_ADDRESS (base);

   /* Look up the base in the hash table.  */
-  slot = htab_find_slot_with_hash (htab, base, mips_hash_base (base), option);
+  slot = htab.find_slot_with_hash (base, mips_hash_base (base), option);
   if (slot == NULL)
     return false;

@@ -15945,7 +15958,8 @@  static int
 mips_record_lo_sum (rtx *loc, void *data)
 {
   if (GET_CODE (*loc) == LO_SUM)
-    mips_lo_sum_offset_lookup ((htab_t) data, XEXP (*loc, 1), INSERT);
+    mips_lo_sum_offset_lookup (*(mips_offset_table*)data,
+			       XEXP (*loc, 1), INSERT);
   return 0;
 }

@@ -15954,7 +15968,7 @@  mips_record_lo_sum (rtx *loc, void *data
    LO_SUMs in the current function.  */

 static bool
-mips_orphaned_high_part_p (htab_t htab, rtx insn)
+mips_orphaned_high_part_p (mips_offset_table htab, rtx insn)
 {
   enum mips_symbol_type type;
   rtx x, set;
@@ -16062,7 +16076,7 @@  mips_reorg_process_insns (void)
 {
   rtx insn, last_insn, subinsn, next_insn, lo_reg, delayed_reg;
   int hilo_delay;
-  htab_t htab;
+  mips_offset_table htab;

   /* Force all instructions to be split into their final form.  */
   split_all_insns_noflow ();
@@ -16099,14 +16113,13 @@  mips_reorg_process_insns (void)
   if (TARGET_FIX_VR4130 && !ISA_HAS_MACCHI)
     cfun->machine->all_noreorder_p = false;

-  htab = htab_create (37, mips_lo_sum_offset_hash,
-		      mips_lo_sum_offset_eq, free);
+  htab.create (37);

   /* Make a first pass over the instructions, recording all the LO_SUMs.  */
   for (insn = get_insns (); insn != 0; insn = NEXT_INSN (insn))
     FOR_EACH_SUBINSN (subinsn, insn)
       if (USEFUL_INSN_P (subinsn))
-	for_each_rtx (&PATTERN (subinsn), mips_record_lo_sum, htab);
+	for_each_rtx (&PATTERN (subinsn), mips_record_lo_sum, &htab);

   last_insn = 0;
   hilo_delay = 2;
@@ -16163,7 +16176,7 @@  mips_reorg_process_insns (void)
 	}
     }

-  htab_delete (htab);
+  htab.dispose ();
 }

 /* Return true if the function has a long branch instruction.  */
Index: gcc/config/sol2.c
===================================================================
--- gcc/config/sol2.c	(revision 198213)
+++ gcc/config/sol2.c	(working copy)
@@ -29,7 +29,7 @@  along with GCC; see the file COPYING3.
 #include "tm_p.h"
 #include "diagnostic-core.h"
 #include "ggc.h"
-#include "hashtab.h"
+#include "hash-table.h"

 tree solaris_pending_aligns, solaris_pending_inits, solaris_pending_finis;

@@ -157,10 +157,6 @@  solaris_assemble_visibility (tree decl,
 #endif
 }

-/* Hash table of group signature symbols.  */
-
-static htab_t solaris_comdat_htab;
-
 /* Group section information entry stored in solaris_comdat_htab.  */

 typedef struct comdat_entry
@@ -171,25 +167,34 @@  typedef struct comdat_entry
   const char *sig;
 } comdat_entry;

-/* Helper routines for maintaining solaris_comdat_htab.  */
+/* Helpers for maintaining solaris_comdat_htab.  */

-static hashval_t
-comdat_hash (const void *p)
+struct comdat_entry_hasher : typed_noop_remove <comdat_entry>
 {
-  const comdat_entry *entry = (const comdat_entry *) p;
+  typedef comdat_entry value_type;
+  typedef comdat_entry compare_type;
+  static inline hashval_t hash (const value_type *);
+  static inline bool equal (const value_type *, const compare_type *);
+  static inline void remove (value_type *);
+};

+inline hashval_t
+comdat_entry_hasher::hash (const value_type *entry)
+{
   return htab_hash_string (entry->sig);
 }

-static int
-comdat_eq (const void *p1, const void *p2)
+inline bool
+comdat_entry_hasher::equal (const value_type *entry1,
+			    const compare_type *entry2)
 {
-  const comdat_entry *entry1 = (const comdat_entry *) p1;
-  const comdat_entry *entry2 = (const comdat_entry *) p2;
-
   return strcmp (entry1->sig, entry2->sig) == 0;
 }

+/* Hash table of group signature symbols.  */
+
+static hash_table <comdat_entry_hasher> solaris_comdat_htab;
+
 /* Output assembly to switch to COMDAT group section NAME with attributes
    FLAGS and group signature symbol DECL, using Sun as syntax.  */

@@ -229,12 +234,11 @@  solaris_elf_asm_comdat_section (const ch
      identify the missing ones without changing the affected frontents,
      remember the signature symbols and emit those not marked
      TREE_SYMBOL_REFERENCED in solaris_file_end.  */
-  if (solaris_comdat_htab == NULL)
-    solaris_comdat_htab = htab_create_alloc (37, comdat_hash, comdat_eq, NULL,
-					     xcalloc, free);
+  if (!solaris_comdat_htab.is_created ())
+    solaris_comdat_htab.create (37);

   entry.sig = signature;
-  slot = (comdat_entry **) htab_find_slot (solaris_comdat_htab,
&entry, INSERT);
+  slot = solaris_comdat_htab.find_slot (&entry, INSERT);

   if (*slot == NULL)
     {
@@ -250,10 +254,11 @@  solaris_elf_asm_comdat_section (const ch

 /* Define unreferenced COMDAT group signature symbol corresponding to SLOT.  */

-static int
-solaris_define_comdat_signature (void **slot, void *aux ATTRIBUTE_UNUSED)
+int
+solaris_define_comdat_signature (comdat_entry **slot,
+				 void *aux ATTRIBUTE_UNUSED)
 {
-  comdat_entry *entry = *(comdat_entry **) slot;
+  comdat_entry *entry = *slot;
   tree decl = entry->decl;

   if (TREE_CODE (decl) != IDENTIFIER_NODE)
@@ -277,10 +282,10 @@  solaris_define_comdat_signature (void **
 void
 solaris_file_end (void)
 {
-  if (solaris_comdat_htab == NULL)
+  if (!solaris_comdat_htab.is_created ())
     return;

-  htab_traverse (solaris_comdat_htab, solaris_define_comdat_signature, NULL);
+  solaris_comdat_htab.traverse <void *,
solaris_define_comdat_signature> (NULL);
 }

 void
Index: gcc/config/i386/winnt.c
===================================================================
--- gcc/config/i386/winnt.c	(revision 198213)
+++ gcc/config/i386/winnt.c	(working copy)
@@ -30,7 +30,7 @@  along with GCC; see the file COPYING3.
 #include "flags.h"
 #include "tm_p.h"
 #include "diagnostic-core.h"
-#include "hashtab.h"
+#include "hash-table.h"
 #include "langhooks.h"
 #include "ggc.h"
 #include "target.h"
@@ -449,7 +449,7 @@  i386_pe_reloc_rw_mask (void)
 unsigned int
 i386_pe_section_type_flags (tree decl, const char *name, int reloc)
 {
-  static htab_t htab;
+  static hash_table <pointer_hash <unsigned int> > htab;
   unsigned int flags;
   unsigned int **slot;

@@ -460,8 +460,8 @@  i386_pe_section_type_flags (tree decl, c
   /* The names we put in the hashtable will always be the unique
      versions given to us by the stringtable, so we can just use
      their addresses as the keys.  */
-  if (!htab)
-    htab = htab_create (31, htab_hash_pointer, htab_eq_pointer, NULL);
+  if (!htab.is_created ())
+    htab.create (31);

   if (decl && TREE_CODE (decl) == FUNCTION_DECL)
     flags = SECTION_CODE;
@@ -480,7 +480,7 @@  i386_pe_section_type_flags (tree decl, c
     flags |= SECTION_LINKONCE;

   /* See if we already have an entry for this section.  */
-  slot = (unsigned int **) htab_find_slot (htab, name, INSERT);
+  slot = htab.find_slot ((unsigned int *)name, INSERT);
   if (!*slot)
     {
       *slot = (unsigned int *) xmalloc (sizeof (unsigned int));
@@ -714,12 +714,29 @@  i386_pe_record_stub (const char *name)

 #ifdef CXX_WRAP_SPEC_LIST

+/* Hashtable helpers.  */
+
+struct wrapped_symbol_hasher : typed_noop_remove <char>
+{
+  typedef char value_type;
+  typedef char compare_type;
+  static inline hashval_t hash (const value_type *);
+  static inline bool equal (const value_type *, const compare_type *);
+  static inline void remove (value_type *);
+};
+
+inline hashval_t
+wrapped_symbol_hasher::hash (const value_type *v)
+{
+  return htab_hash_string (v);
+}
+
 /*  Hash table equality helper function.  */

-static int
-wrapper_strcmp (const void *x, const void *y)
+inline bool
+wrapped_symbol_hasher::equal (const value_type *x, const compare_type *y)
 {
-  return !strcmp ((const char *) x, (const char *) y);
+  return !strcmp (x, y);
 }

 /* Search for a function named TARGET in the list of library wrappers
@@ -733,7 +750,7 @@  static const char *
 i386_find_on_wrapper_list (const char *target)
 {
   static char first_time = 1;
-  static htab_t wrappers;
+  static hash_table <wrapped_symbol_hasher> wrappers;

   if (first_time)
     {
@@ -746,8 +763,7 @@  i386_find_on_wrapper_list (const char *t
       char *bufptr;
       /* Breaks up the char array into separated strings
          strings and enter them into the hash table.  */
-      wrappers = htab_create_alloc (8, htab_hash_string, wrapper_strcmp,
-	0, xcalloc, free);
+      wrappers.create (8);
       for (bufptr = wrapper_list_buffer; *bufptr; ++bufptr)
 	{
 	  char *found = NULL;
@@ -760,12 +776,12 @@  i386_find_on_wrapper_list (const char *t
 	  if (*bufptr)
 	    *bufptr = 0;
 	  if (found)
-	    *htab_find_slot (wrappers, found, INSERT) = found;
+	    *wrappers.find_slot (found, INSERT) = found;
 	}
       first_time = 0;
     }

-  return (const char *) htab_find (wrappers, target);
+  return wrappers.find (target);
 }

 #endif /* CXX_WRAP_SPEC_LIST */
Index: gcc/config/i386/t-interix
===================================================================
--- gcc/config/i386/t-interix	(revision 198213)
+++ gcc/config/i386/t-interix	(working copy)
@@ -18,7 +18,7 @@ 

 winnt.o: $(srcdir)/config/i386/winnt.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
   $(TM_H) $(RTL_H) $(REGS_H) hard-reg-set.h output.h $(TREE_H) flags.h \
-  $(TM_P_H) $(HASHTAB_H) $(GGC_H)
+  $(TM_P_H) $(HASH_TABLE_H) $(GGC_H)
 	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
 		$(srcdir)/config/i386/winnt.c

Index: gcc/config/i386/t-cygming
===================================================================
--- gcc/config/i386/t-cygming	(revision 198213)
+++ gcc/config/i386/t-cygming	(working copy)
@@ -22,7 +22,7 @@  LIMITS_H_TEST = true

 winnt.o: $(srcdir)/config/i386/winnt.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
   $(TM_H) $(RTL_H) $(REGS_H) hard-reg-set.h output.h $(TREE_H) flags.h \
-  $(TM_P_H) $(HASHTAB_H) $(GGC_H) $(LTO_STREAMER_H)
+  $(TM_P_H) $(HASH_TABLE_H) $(GGC_H) $(LTO_STREAMER_H)
 	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
 	$(srcdir)/config/i386/winnt.c

Index: gcc/config/t-sol2
===================================================================
--- gcc/config/t-sol2	(revision 198213)
+++ gcc/config/t-sol2	(working copy)
@@ -34,5 +34,5 @@  sol2-stubs.o: $(srcdir)/config/sol2-stub

 # Solaris-specific attributes
 sol2.o: $(srcdir)/config/sol2.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
-  tree.h output.h $(TM_H) $(TARGET_H) $(TM_P_H) $(GGC_H)
+  tree.h output.h $(TM_H) $(TARGET_H) $(TM_P_H) $(GGC_H) $(HASH_TABLE_H)
 	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
Index: gcc/config/arm/arm.c
===================================================================
--- gcc/config/arm/arm.c	(revision 198213)
+++ gcc/config/arm/arm.c	(working copy)
@@ -23,6 +23,7 @@ 
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
+#include "hash-table.h"
 #include "tm.h"
 #include "rtl.h"
 #include "tree.h"
@@ -3812,36 +3813,48 @@  arm_function_value(const_tree type, cons
   return arm_libcall_value_1 (mode);
 }

-static int
-libcall_eq (const void *p1, const void *p2)
+/* libcall hashtable helpers.  */
+
+struct libcall_hasher : typed_noop_remove <rtx_def>
 {
-  return rtx_equal_p ((const_rtx) p1, (const_rtx) p2);
+  typedef rtx_def value_type;
+  typedef rtx_def compare_type;
+  static inline hashval_t hash (const value_type *);
+  static inline bool equal (const value_type *, const compare_type *);
+  static inline void remove (value_type *);
+};
+
+inline bool
+libcall_hasher::equal (const value_type *p1, const compare_type *p2)
+{
+  return rtx_equal_p (p1, p2);
 }

-static hashval_t
-libcall_hash (const void *p1)
+inline hashval_t
+libcall_hasher::hash (const value_type *p1)
 {
-  return hash_rtx ((const_rtx) p1, VOIDmode, NULL, NULL, FALSE);
+  return hash_rtx (p1, VOIDmode, NULL, NULL, FALSE);
 }

+typedef hash_table <libcall_hasher> libcall_table_type;
+
 static void
-add_libcall (htab_t htab, rtx libcall)
+add_libcall (libcall_table_type htab, rtx libcall)
 {
-  *htab_find_slot (htab, libcall, INSERT) = libcall;
+  *htab.find_slot (libcall, INSERT) = libcall;
 }

 static bool
 arm_libcall_uses_aapcs_base (const_rtx libcall)
 {
   static bool init_done = false;
-  static htab_t libcall_htab;
+  static libcall_table_type libcall_htab;

   if (!init_done)
     {
       init_done = true;

-      libcall_htab = htab_create (31, libcall_hash, libcall_eq,
-				  NULL);
+      libcall_htab.create (31);
       add_libcall (libcall_htab,
 		   convert_optab_libfunc (sfloat_optab, SFmode, SImode));
       add_libcall (libcall_htab,
@@ -3900,7 +3913,7 @@  arm_libcall_uses_aapcs_base (const_rtx l
 							DFmode));
     }

-  return libcall && htab_find (libcall_htab, libcall) != NULL;
+  return libcall && libcall_htab.find (libcall) != NULL;
 }

 static rtx
Index: gcc/config/arm/t-arm
===================================================================
--- gcc/config/arm/t-arm	(revision 198213)
+++ gcc/config/arm/t-arm	(working copy)
@@ -78,8 +78,8 @@  $(srcdir)/config/arm/arm-tables.opt: $(s
 	$(SHELL) $(srcdir)/config/arm/genopt.sh $(srcdir)/config/arm > \
 		$(srcdir)/config/arm/arm-tables.opt

-arm.o: $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
-  $(RTL_H) $(TREE_H) $(OBSTACK_H) $(REGS_H) hard-reg-set.h \
+arm.o: $(srcdir)/config/arm/arm.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
+  $(RTL_H) $(TREE_H) $(HASH_TABLE_H) $(OBSTACK_H) $(REGS_H) hard-reg-set.h \
   insn-config.h conditions.h output.h dumpfile.h \
   $(INSN_ATTR_H) $(FLAGS_H) reload.h $(FUNCTION_H) \
   $(EXPR_H) $(OPTABS_H) $(RECOG_H) $(CGRAPH_H) \