Re: [cxx-conversion] Change uses of htab_t in gcc/config to hash_table.
On Sun, Jan 6, 2013 at 6:55 AM, Xinliang David Li davi...@google.com wrote: I noticed that the traverse and traverse_noresize method takes Argument as the first template parameter. It should be moved to be the second after the callback. In most of the cases, the type of the Argument can be deduced from the callsite, so that the user only need to specify the callback: ht-traverse_noresizethe_call_back_function(arg); In the current way, user has to do this: ht-traverse_noresizearg_type, the_call_back_function (arg); which is not as friendly. Agreed. David On Tue, Dec 18, 2012 at 8:02 PM, Lawrence Crowl cr...@googlers.com wrote: Update various config htab_t uses 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 contrib/config-list.mk. Okay for branch? Index: gcc/config/arm/arm.c === --- gcc/config/arm/arm.c(revision 194511) +++ gcc/config/arm/arm.c(working copy) @@ -25,6 +25,7 @@ #include config.h #include system.h #include coretypes.h +#include hash-table.h #include tm.h #include rtl.h #include tree.h @@ -3716,36 +3717,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, @@ -3804,7 +3817,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 194511) +++ gcc/config/arm/t-arm(working copy) @@ -73,8 +73,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) \ Index: gcc/config/i386/winnt.c
Re: [cxx-conversion] Change uses of htab_t in gcc/config to hash_table.
On 1/6/13, Richard Biener richard.guent...@gmail.com wrote: On Sun, Jan 6, 2013 at 6:55 AM, Xinliang David Li davi...@google.com wrote: I noticed that the traverse and traverse_noresize method takes Argument as the first template parameter. It should be moved to be the second after the callback. In most of the cases, the type of the Argument can be deduced from the callsite, so that the user only need to specify the callback: ht-traverse_noresizethe_call_back_function(arg); In the current way, user has to do this: ht-traverse_noresizearg_type, the_call_back_function (arg); which is not as friendly. Agreed. Agreed. The current structure was handy in the conversion process. Now that the conversion is done, we could change the order. David On Tue, Dec 18, 2012 at 8:02 PM, Lawrence Crowl cr...@googlers.com wrote: Update various config htab_t uses 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 contrib/config-list.mk. Okay for branch? Index: gcc/config/arm/arm.c === --- gcc/config/arm/arm.c(revision 194511) +++ gcc/config/arm/arm.c(working copy) @@ -25,6 +25,7 @@ #include config.h #include system.h #include coretypes.h +#include hash-table.h #include tm.h #include rtl.h #include tree.h @@ -3716,36 +3717,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, @@ -3804,7 +3817,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 194511) +++ gcc/config/arm/t-arm(working copy) @@ -73,8 +73,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
Re: [cxx-conversion] Change uses of htab_t in gcc/config to hash_table.
I noticed that the traverse and traverse_noresize method takes Argument as the first template parameter. It should be moved to be the second after the callback. In most of the cases, the type of the Argument can be deduced from the callsite, so that the user only need to specify the callback: ht-traverse_noresizethe_call_back_function(arg); In the current way, user has to do this: ht-traverse_noresizearg_type, the_call_back_function (arg); which is not as friendly. David On Tue, Dec 18, 2012 at 8:02 PM, Lawrence Crowl cr...@googlers.com wrote: Update various config htab_t uses 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 contrib/config-list.mk. Okay for branch? Index: gcc/config/arm/arm.c === --- gcc/config/arm/arm.c(revision 194511) +++ gcc/config/arm/arm.c(working copy) @@ -25,6 +25,7 @@ #include config.h #include system.h #include coretypes.h +#include hash-table.h #include tm.h #include rtl.h #include tree.h @@ -3716,36 +3717,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, @@ -3804,7 +3817,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 194511) +++ gcc/config/arm/t-arm(working copy) @@ -73,8 +73,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) \ Index: gcc/config/i386/winnt.c === --- gcc/config/i386/winnt.c (revision 194511) +++
[cxx-conversion] Change uses of htab_t in gcc/config to hash_table.
Update various config htab_t uses 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 contrib/config-list.mk. Okay for branch? Index: gcc/config/arm/arm.c === --- gcc/config/arm/arm.c(revision 194511) +++ gcc/config/arm/arm.c(working copy) @@ -25,6 +25,7 @@ #include config.h #include system.h #include coretypes.h +#include hash-table.h #include tm.h #include rtl.h #include tree.h @@ -3716,36 +3717,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, @@ -3804,7 +3817,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 194511) +++ gcc/config/arm/t-arm(working copy) @@ -73,8 +73,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) \ Index: gcc/config/i386/winnt.c === --- gcc/config/i386/winnt.c (revision 194511) +++ gcc/config/i386/winnt.c (working copy) @@ -31,7 +31,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