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: 137120 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a7d1:0:b0:3f2:4152:657d with SMTP id p17csp4004624vqm; Tue, 29 Aug 2023 08:41:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGS0sA+sryXoNWmOcNh1IGXn4LEbxY7WNfVweNk2M2cVOdQ8g6NK8XfqM9wuqCViBQWeLte X-Received: by 2002:a05:6402:b1b:b0:525:6d6e:ed4a with SMTP id bm27-20020a0564020b1b00b005256d6eed4amr22463960edb.23.1693323696224; Tue, 29 Aug 2023 08:41:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693323696; cv=none; d=google.com; s=arc-20160816; b=EMks1bn0M1OXFhVWsoGycGoiiwt12Zv4ABHukFSDejSw1E5zhKgK5aFMkGcABBfU62 CwkAo7Cps96JZhhhsz04S+L3yeSAN8VGyhyxDcoI5HsrtOSSnGtWuB9KlJS1sGHTBJht 1Jbl9PCUO3SqjFrhr30WkAvfYRDUoRY/FRhIF0ioC5INIx/AJPDscKyms1FrOp7lR/St 2VDsghxOTf8L4avFuvRxRo4BEc55MWftOUt3eaHSte+9uEz9DspmdhqaVTbnrvwGyx/E qSIe3NWeJ0ML9W7ReEco/cqzy4m6tn717ZFJEZdKrJObzffjJZgC22pceQLFWqdg7EZ1 YR9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:mime-version :user-agent:message-id:date:subject:mail-followup-to:to:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=kAEQ7eQfFIaMmflSY8EGy4DgNmqXDWnO3rBDrsmHupg=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=YUGtXOF1PiWRjV9DlsaTfvlJuKsRH1Bg04zXprzR4w+o4bnobBr30GIeehkgErB5+V 0ztGZd1MXpJw00r7oYDvtHR4AoXyhirxl6XsFsDSj/j1uOjtw535TOmxQPM9J2pmPUpy 1GDbJ2js4T1n0qJ8pE63i/HZvykvNryd1Y051MXL/7g8SRDd4gK5woPYRPr6LZX5RECT A0XDWCi6UDeU4KAyiX18Z+7AIZpwWOUW6YkXIYU1reyfeY/hyC2/RRggTCwGCK2S9y76 +nO1KrHrBdDOHq1MSxYzOYmHOkKI7Jre1JDxXf+TNppZdT+3VdZ7srj+KdYQW7ukdTRT iUbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=xNi9IkUP; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id f6-20020a50ee86000000b005231db540d4si6451418edr.230.2023.08.29.08.41.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Aug 2023 08:41:36 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=xNi9IkUP; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 93EB53858422 for ; Tue, 29 Aug 2023 15:41:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 93EB53858422 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1693323694; bh=kAEQ7eQfFIaMmflSY8EGy4DgNmqXDWnO3rBDrsmHupg=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=xNi9IkUPnMCc7XhTebUDLQmQQZZ96f09NEvIodr73CHvhGiiytMbm7UwPasH8ShbI lz/BMCk9hl2b7zGM43ybZbjKqaPByZ5z8urUQCEmb7NuzaMPaVkZRcJrTmaoqQa46S GaE97JsQU2EWxaHBgwyuKzNf9zzmALq4pklhUG0s= 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1775578588523567014 X-GMAIL-MSGID: 1775578588523567014 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)