From patchwork Tue Aug 29 15:40:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 1827316 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=VcPOk7R3; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RZs8q2t7hz1yZs for ; Wed, 30 Aug 2023 01:41:13 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 98E943858402 for ; Tue, 29 Aug 2023 15:41:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 98E943858402 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1693323671; bh=kAEQ7eQfFIaMmflSY8EGy4DgNmqXDWnO3rBDrsmHupg=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=VcPOk7R393vqvJlHbWkSbNe18rUvcvZdGDNY3Fyoyz1+fO0Bh6mSiY3D7i8Fypq1S DUO+WPelPzfjsWm7LqH1vn1OwthiYpscLTxHE/buHLz2InTjb2bcBMV7FurdhM4t9P oVpVT+XxB9/BBKa+mPLg4caM/sKyxPwkyzzPr2VQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 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) 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 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Sandiford via Gcc-patches From: Richard Sandiford Reply-To: Richard Sandiford Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "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 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)