summaryrefslogtreecommitdiff
path: root/0171-Backport-SME-attribs-Use-existing-traits-for-excl_ha.patch
blob: ecd15bd7358bcfa5efd43bb1ba8fe68d001a777e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
From 11f813112629dbad432134f7b4c7c9a93551eb3c Mon Sep 17 00:00:00 2001
From: Richard Sandiford <richard.sandiford@arm.com>
Date: Mon, 27 Nov 2023 13:38:16 +0000
Subject: [PATCH 072/157] [Backport][SME] attribs: Use existing traits for
 excl_hash_traits

Reference: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=5b33cf3a3a2025a4856f90fea8bd04884c2f6b31

excl_hash_traits can be defined more simply by reusing existing traits.

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 b219f8780..16d05b1da 100644
--- a/gcc/attribs.cc
+++ b/gcc/attribs.cc
@@ -2555,47 +2555,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.
@@ -2605,13 +2564,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.33.0