Mikhail Maltsev <malts...@gmail.com> writes: > Hi, all. > > I noticed that defaults.h file contains stub generator functions which > simply call gcc_unreachable. FWIW, Trevor added them to remove some > conditional compilation which depends on HAVE_<insn_name> macros (I mean > something like r223624). > > Because we still have ~80 more such conditions in GCC, and probably some > of them will be fixed in the same way, I propose a patch, which allows > to generate required stubs in genflags.
Nice! > +/* Structure which holds data, required for generating stub gen_* function. > */ No comma after "data" > +/* These instructions require default stub function. Stubs are never called. "require a default" > +/* Helper traits for using null-terminated strings as keys in hash map. > + FIXME: Unify various "string hashers" and move them to hash-map-traits.h. > */ > +struct gflg_string_hasher : default_hashmap_traits > +{ > + typedef const char *value_type; > + typedef const char *compare_type; > + > + static inline hashval_t hash (const char *s) > + { > + return htab_hash_string (s); > + } > + > + static inline bool equal_keys (const char *p1, const char *p2) > + { > + return strcmp (p1, p2) == 0; > + } > +}; > + > +/* Mapping from insn name to corresponding stub_info_t entry. */ > +static hash_map<const char *, stub_info_t *, gflg_string_hasher> > + stubs_map (ARRAY_SIZE (stubs), false, false); Seems like this is more naturally a hash_table rather than a hash_map. I think there's also a preference to avoid static constructor-based initialisation. There again, this is a generator, so those kinds of concerns aren't particularly important. If we do keep the above though, I think we should put the hasher in hash-map-table.h now. Otherwise these FIXMEs are just going to accumulate, and each time makes it less likely that any consolidation will actually happen. Thanks, Richard