From 3a4f280bec545db82380fb4cbc704ac7af438585 Mon Sep 17 00:00:00 2001 From: Lawrence Crowl Date: Thu, 30 May 2013 01:26:05 +0000 Subject: [PATCH] This patch is a consolodation of the hash_table patches to the cxx-conversion branch for files under gcc/config. 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-05-29 Lawrence Crowl * 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. From-SVN: r199435 --- gcc/ChangeLog | 29 +++++++++++++++- gcc/config/arm/arm.c | 37 +++++++++++++------- gcc/config/arm/t-arm | 4 +-- gcc/config/i386/t-cygming | 2 +- gcc/config/i386/t-interix | 2 +- gcc/config/i386/winnt.c | 42 ++++++++++++++++------- gcc/config/ia64/ia64.c | 71 +++++++++++++++++++-------------------- gcc/config/ia64/t-ia64 | 3 +- gcc/config/mips/mips.c | 49 +++++++++++++++++---------- gcc/config/sol2.c | 53 ++++++++++++++++------------- gcc/config/t-sol2 | 2 +- 11 files changed, 183 insertions(+), 111 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7c852915a6f..4e3a6f80942 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,31 @@ +2013-05-29 Lawrence Crowl + + * 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. + 2013-05-29 Teresa Johnson * passes.c (dump_passes): Use FOR_EACH_FUNCTION since @@ -860,7 +888,6 @@ * config/rs6000/rs6000-opts.h (PROCESSOR_POWER8): Likewise. (enum rs6000_vector): Add power8 vector support. ->>>>>>> .r199383 2013-05-22 Ramana Radhakrishnan PR target/19599 diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 43dfe2772f6..9f0f2a80cb5 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -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" @@ -3816,36 +3817,48 @@ arm_function_value(const_tree type, const_tree func, 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 +{ + 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 ((const_rtx) p1, (const_rtx) 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_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, @@ -3904,7 +3917,7 @@ arm_libcall_uses_aapcs_base (const_rtx libcall) DFmode)); } - return libcall && htab_find (libcall_htab, libcall) != NULL; + return libcall && libcall_htab.find (libcall) != NULL; } static rtx diff --git a/gcc/config/arm/t-arm b/gcc/config/arm/t-arm index fe075e5862a..246f0f5b540 100644 --- a/gcc/config/arm/t-arm +++ b/gcc/config/arm/t-arm @@ -78,8 +78,8 @@ $(srcdir)/config/arm/arm-tables.opt: $(srcdir)/config/arm/genopt.sh \ $(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) \ diff --git a/gcc/config/i386/t-cygming b/gcc/config/i386/t-cygming index f615ad7a2af..ba076a7f49a 100644 --- a/gcc/config/i386/t-cygming +++ b/gcc/config/i386/t-cygming @@ -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 diff --git a/gcc/config/i386/t-interix b/gcc/config/i386/t-interix index 43443e72a45..4d7b5987037 100644 --- a/gcc/config/i386/t-interix +++ b/gcc/config/i386/t-interix @@ -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 diff --git a/gcc/config/i386/winnt.c b/gcc/config/i386/winnt.c index f0f972c56d9..c9e3aa98a37 100644 --- a/gcc/config/i386/winnt.c +++ b/gcc/config/i386/winnt.c @@ -30,7 +30,7 @@ along with GCC; see the file COPYING3. If not see #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 > htab; unsigned int flags; unsigned int **slot; @@ -460,8 +460,8 @@ i386_pe_section_type_flags (tree decl, const char *name, int reloc) /* 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, const char *name, int reloc) 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 +{ + 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 wrappers; if (first_time) { @@ -746,8 +763,7 @@ i386_find_on_wrapper_list (const char *target) 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 *target) 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 */ diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c index ee8ee5be3df..a128b19c7ca 100644 --- a/gcc/config/ia64/ia64.c +++ b/gcc/config/ia64/ia64.c @@ -47,7 +47,7 @@ along with GCC; see the file COPYING3. If not see #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_bundle_state (void); 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); @@ -8526,18 +8524,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 +{ + 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++) @@ -8548,19 +8549,20 @@ bundle_state_hash (const void *bundle_state) /* 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_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. */ @@ -8568,39 +8570,35 @@ bundle_state_eq_p (const void *bundle_state_1, const void *bundle_state_2) 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; @@ -8611,8 +8609,7 @@ insert_bundle_state (struct bundle_state *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. */ @@ -8620,7 +8617,7 @@ initiate_bundle_state_table (void) static void finish_bundle_state_table (void) { - htab_delete (bundle_state_table); + bundle_state_table.dispose (); } diff --git a/gcc/config/ia64/t-ia64 b/gcc/config/ia64/t-ia64 index 5c3ac644be3..b009cdf2bc5 100644 --- a/gcc/config/ia64/t-ia64 +++ b/gcc/config/ia64/t-ia64 @@ -24,4 +24,5 @@ ia64-c.o: $(srcdir)/config/ia64/ia64-c.c $(CONFIG_H) $(SYSTEM_H) \ # 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) diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index c9383ea3408..222c768b9b9 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -43,7 +43,7 @@ along with GCC; see the file COPYING3. If not see #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" @@ -15806,30 +15806,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 +{ + 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_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. */ @@ -15838,7 +15851,7 @@ mips_lo_sum_offset_lookup (htab_t htab, rtx x, enum insert_option option) 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; @@ -15868,7 +15881,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; } @@ -15877,7 +15891,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; @@ -15985,7 +15999,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 (); @@ -16022,14 +16036,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; @@ -16086,7 +16099,7 @@ mips_reorg_process_insns (void) } } - htab_delete (htab); + htab.dispose (); } /* Return true if the function has a long branch instruction. */ diff --git a/gcc/config/sol2.c b/gcc/config/sol2.c index 718134e2b90..7c7c429db3d 100644 --- a/gcc/config/sol2.c +++ b/gcc/config/sol2.c @@ -29,7 +29,7 @@ along with GCC; see the file COPYING3. If not see #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, int vis ATTRIBUTE_UNUSED) #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 +{ + 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) { - const comdat_entry *entry = (const comdat_entry *) p; - 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 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 char *name, unsigned int flags, tree decl) 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 char *name, unsigned int flags, tree decl) /* 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 **slot, void *aux ATTRIBUTE_UNUSED) 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 (NULL); } void diff --git a/gcc/config/t-sol2 b/gcc/config/t-sol2 index 25b825017f6..142de89de95 100644 --- a/gcc/config/t-sol2 +++ b/gcc/config/t-sol2 @@ -34,5 +34,5 @@ sol2-stubs.o: $(srcdir)/config/sol2-stubs.c $(CONFIG_H) $(SYSTEM_H) coretypes.h # 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) $< -- 2.30.2