From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 66D123858D35 for ; Tue, 29 Aug 2023 15:40:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 66D123858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 766AB2F4 for ; Tue, 29 Aug 2023 08:41:23 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.110.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id ABAE03F738 for ; Tue, 29 Aug 2023 08:40:43 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [PATCH] attribs: Use existing traits for excl_hash_traits Date: Tue, 29 Aug 2023 16:40:42 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-25.4 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_NONE,KAM_DMARC_STATUS,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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 excl_pair; -struct excl_hash_traits: typed_noop_remove -{ - 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 static void test_attribute_exclusions () { + using excl_hash_traits = pair_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 exclusion_set; + typedef hash_set exclusion_set; exclusion_set excl_set; for (size_t ti0 = 0; ti0 != ntables; ++ti0) -- 2.25.1