* [PATCH] attribs: Use existing traits for excl_hash_traits
@ 2023-08-29 15:40 Richard Sandiford
2023-11-06 12:32 ` Richard Sandiford
0 siblings, 1 reply; 3+ messages in thread
From: Richard Sandiford @ 2023-08-29 15:40 UTC (permalink / raw)
To: gcc-patches
excl_hash_traits can be defined more simply by reusing existing traits.
Tested on aarch64-linux-gnu. OK to install?
Richard
gcc/
* attribs.cc (excl_hash_traits): Delete.
(test_attribute_exclusions): Use pair_hash and nofree_string_hash
instead.
---
gcc/attribs.cc | 45 +++------------------------------------------
1 file changed, 3 insertions(+), 42 deletions(-)
diff --git a/gcc/attribs.cc b/gcc/attribs.cc
index b8cb55b97df..0d4ab23aeb6 100644
--- a/gcc/attribs.cc
+++ b/gcc/attribs.cc
@@ -2640,47 +2640,6 @@ namespace selftest
typedef std::pair<const char *, const char *> excl_pair;
-struct excl_hash_traits: typed_noop_remove<excl_pair>
-{
- typedef excl_pair value_type;
- typedef value_type compare_type;
-
- static hashval_t hash (const value_type &x)
- {
- hashval_t h1 = htab_hash_string (x.first);
- hashval_t h2 = htab_hash_string (x.second);
- return h1 ^ h2;
- }
-
- static bool equal (const value_type &x, const value_type &y)
- {
- return !strcmp (x.first, y.first) && !strcmp (x.second, y.second);
- }
-
- static void mark_deleted (value_type &x)
- {
- x = value_type (NULL, NULL);
- }
-
- static const bool empty_zero_p = false;
-
- static void mark_empty (value_type &x)
- {
- x = value_type ("", "");
- }
-
- static bool is_deleted (const value_type &x)
- {
- return !x.first && !x.second;
- }
-
- static bool is_empty (const value_type &x)
- {
- return !*x.first && !*x.second;
- }
-};
-
-
/* Self-test to verify that each attribute exclusion is symmetric,
meaning that if attribute A is encoded as incompatible with
attribute B then the opposite relationship is also encoded.
@@ -2690,13 +2649,15 @@ struct excl_hash_traits: typed_noop_remove<excl_pair>
static void
test_attribute_exclusions ()
{
+ using excl_hash_traits = pair_hash<nofree_string_hash, nofree_string_hash>;
+
/* Iterate over the array of attribute tables first (with TI0 as
the index) and over the array of attribute_spec in each table
(with SI0 as the index). */
const size_t ntables = ARRAY_SIZE (attribute_tables);
/* Set of pairs of mutually exclusive attributes. */
- typedef hash_set<excl_pair, false, excl_hash_traits> exclusion_set;
+ typedef hash_set<excl_hash_traits> exclusion_set;
exclusion_set excl_set;
for (size_t ti0 = 0; ti0 != ntables; ++ti0)
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] attribs: Use existing traits for excl_hash_traits
2023-08-29 15:40 [PATCH] attribs: Use existing traits for excl_hash_traits Richard Sandiford
@ 2023-11-06 12:32 ` Richard Sandiford
2023-11-10 20:28 ` Jeff Law
0 siblings, 1 reply; 3+ messages in thread
From: Richard Sandiford @ 2023-11-06 12:32 UTC (permalink / raw)
To: gcc-patches
Ping.
Richard Sandiford via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
> excl_hash_traits can be defined more simply by reusing existing traits.
>
> Tested on aarch64-linux-gnu. OK to install?
>
> Richard
>
>
> gcc/
> * attribs.cc (excl_hash_traits): Delete.
> (test_attribute_exclusions): Use pair_hash and nofree_string_hash
> instead.
> ---
> gcc/attribs.cc | 45 +++------------------------------------------
> 1 file changed, 3 insertions(+), 42 deletions(-)
>
> diff --git a/gcc/attribs.cc b/gcc/attribs.cc
> index b8cb55b97df..0d4ab23aeb6 100644
> --- a/gcc/attribs.cc
> +++ b/gcc/attribs.cc
> @@ -2640,47 +2640,6 @@ namespace selftest
>
> typedef std::pair<const char *, const char *> excl_pair;
>
> -struct excl_hash_traits: typed_noop_remove<excl_pair>
> -{
> - typedef excl_pair value_type;
> - typedef value_type compare_type;
> -
> - static hashval_t hash (const value_type &x)
> - {
> - hashval_t h1 = htab_hash_string (x.first);
> - hashval_t h2 = htab_hash_string (x.second);
> - return h1 ^ h2;
> - }
> -
> - static bool equal (const value_type &x, const value_type &y)
> - {
> - return !strcmp (x.first, y.first) && !strcmp (x.second, y.second);
> - }
> -
> - static void mark_deleted (value_type &x)
> - {
> - x = value_type (NULL, NULL);
> - }
> -
> - static const bool empty_zero_p = false;
> -
> - static void mark_empty (value_type &x)
> - {
> - x = value_type ("", "");
> - }
> -
> - static bool is_deleted (const value_type &x)
> - {
> - return !x.first && !x.second;
> - }
> -
> - static bool is_empty (const value_type &x)
> - {
> - return !*x.first && !*x.second;
> - }
> -};
> -
> -
> /* Self-test to verify that each attribute exclusion is symmetric,
> meaning that if attribute A is encoded as incompatible with
> attribute B then the opposite relationship is also encoded.
> @@ -2690,13 +2649,15 @@ struct excl_hash_traits: typed_noop_remove<excl_pair>
> static void
> test_attribute_exclusions ()
> {
> + using excl_hash_traits = pair_hash<nofree_string_hash, nofree_string_hash>;
> +
> /* Iterate over the array of attribute tables first (with TI0 as
> the index) and over the array of attribute_spec in each table
> (with SI0 as the index). */
> const size_t ntables = ARRAY_SIZE (attribute_tables);
>
> /* Set of pairs of mutually exclusive attributes. */
> - typedef hash_set<excl_pair, false, excl_hash_traits> exclusion_set;
> + typedef hash_set<excl_hash_traits> exclusion_set;
> exclusion_set excl_set;
>
> for (size_t ti0 = 0; ti0 != ntables; ++ti0)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] attribs: Use existing traits for excl_hash_traits
2023-11-06 12:32 ` Richard Sandiford
@ 2023-11-10 20:28 ` Jeff Law
0 siblings, 0 replies; 3+ messages in thread
From: Jeff Law @ 2023-11-10 20:28 UTC (permalink / raw)
To: gcc-patches, richard.sandiford
On 11/6/23 05:32, Richard Sandiford wrote:
> Ping.
>
> Richard Sandiford via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
>> excl_hash_traits can be defined more simply by reusing existing traits.
>>
>> Tested on aarch64-linux-gnu. OK to install?
>>
>> Richard
>>
>>
>> gcc/
>> * attribs.cc (excl_hash_traits): Delete.
>> (test_attribute_exclusions): Use pair_hash and nofree_string_hash
>> instead.
OK. Sorry this fell through the cracks.
jeff
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-11-10 20:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-29 15:40 [PATCH] attribs: Use existing traits for excl_hash_traits Richard Sandiford
2023-11-06 12:32 ` Richard Sandiford
2023-11-10 20:28 ` Jeff Law
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).