From patchwork Thu Aug 22 13:45:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 1151612 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-507516-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="UcBcLxJR"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46Dm6C1tvPz9s00 for ; Thu, 22 Aug 2019 23:46:43 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:in-reply-to:references:mime-version :content-transfer-encoding:message-id; q=dns; s=default; b=ePBhB 0rVfPdEyHmWSPRa102voXQ2tz6WtdNfMTiZ56U+ptQwqrYFQU5s0q9yMK9iCbYXj uzVnkNUX+RtAraub7Hs2qGyxKHT6FJ/ewP+Ny9rZftORyz2/4MZZ8J3eu7v4Q1Cq nml9HlGUzHie5ZR3BaUqbQkANpmqxriWiwYFN4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:in-reply-to:references:mime-version :content-transfer-encoding:message-id; s=default; bh=2/k7kYXcAmN OlNxOn3VNQ0vcoD4=; b=UcBcLxJRHi6NoUmi/ZhwGlqqF2od7ktqVHpaTQOU68L B3VoAX8mS732AAt38VDuaQqrbBLM7uajkQVfGla9GQE34ALfS5Vrw/4n9YppAZin sfYVz4B3509NbpyPqPXAMLQwrf7Aumho49dRnJF5v8/3U7fmxrmDA3WlwdVpzvrQ = Received: (qmail 72654 invoked by alias); 22 Aug 2019 13:46:33 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 72567 invoked by uid 89); 22 Aug 2019 13:46:32 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Aug 2019 13:46:30 +0000 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x7MDZp7S076083 for ; Thu, 22 Aug 2019 09:46:28 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0b-001b2d01.pphosted.com with ESMTP id 2uhs8nqtyt-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 22 Aug 2019 09:46:28 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 22 Aug 2019 14:46:26 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 22 Aug 2019 14:46:23 +0100 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x7MDkMDv44892250 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 22 Aug 2019 13:46:22 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B2E654204B; Thu, 22 Aug 2019 13:46:22 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8524542045; Thu, 22 Aug 2019 13:46:22 +0000 (GMT) Received: from white.boeblingen.de.ibm.com (unknown [9.152.99.241]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 22 Aug 2019 13:46:22 +0000 (GMT) From: Ilya Leoshkevich To: gcc-patches@gcc.gnu.org Cc: richard.sandiford@arm.com, segher@kernel.crashing.org, Ilya Leoshkevich Subject: [PATCH v2 2/9] hash_traits: split pointer_hash_mark from pointer_hash Date: Thu, 22 Aug 2019 15:45:44 +0200 In-Reply-To: <20190822134551.18924-1-iii@linux.ibm.com> References: <20190822134551.18924-1-iii@linux.ibm.com> MIME-Version: 1.0 x-cbid: 19082213-0028-0000-0000-000003928223 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19082213-0029-0000-0000-00002454AD88 Message-Id: <20190822134551.18924-3-iii@linux.ibm.com> X-IsSubscribed: yes The next patch introducing can_vector_compare_p function needs to store rtxes in a hash table and look them up using a special key type. Currently pointer_hash requires value_type to be the same as compare_type, so it would not be usable and one would have to implement mark_deleted, mark_empty, is_deleted and is_empty manually. Split pointer_hash_mark out of pointer_hash in order to support such use cases. Also make use of it in the existing code where possible. gcc/ChangeLog: 2019-08-22 Ilya Leoshkevich * hash-traits.h (struct pointer_hash_mark): New trait. (Pointer>::mark_deleted): Move from pointer_hash. (Pointer>::mark_empty): Likewise. (Pointer>::is_deleted): Likewise. (Pointer>::is_empty): Likewise. (struct pointer_hash): Inherit from pointer_hash_mark. (Type>::mark_deleted): Move to pointer_hash_mark. (Type>::mark_empty): Likewise. (Type>::is_deleted): Likewise. (Type>::is_empty): Likewise. * ipa-prop.c (struct ipa_bit_ggc_hash_traits): Use pointer_hash_mark. (struct ipa_vr_ggc_hash_traits): Likewise. gcc/cp/ChangeLog: 2019-08-22 Ilya Leoshkevich * decl2.c (struct mangled_decl_hash): Use pointer_hash_mark. --- gcc/cp/decl2.c | 14 +-------- gcc/hash-traits.h | 74 ++++++++++++++++++++++++++--------------------- gcc/ipa-prop.c | 47 ++++-------------------------- 3 files changed, 47 insertions(+), 88 deletions(-) diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index a32108f9d16..36a10f491fa 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -105,7 +105,7 @@ static GTY(()) vec *mangling_aliases; /* hash traits for declarations. Hashes single decls via DECL_ASSEMBLER_NAME_RAW. */ -struct mangled_decl_hash : ggc_remove +struct mangled_decl_hash : pointer_hash_mark , ggc_remove { typedef tree value_type; /* A DECL. */ typedef tree compare_type; /* An identifier. */ @@ -119,18 +119,6 @@ struct mangled_decl_hash : ggc_remove tree name = DECL_ASSEMBLER_NAME_RAW (existing); return candidate == name; } - - static inline void mark_empty (value_type &p) {p = NULL_TREE;} - static inline bool is_empty (value_type p) {return !p;} - - static bool is_deleted (value_type e) - { - return e == reinterpret_cast (1); - } - static void mark_deleted (value_type &e) - { - e = reinterpret_cast (1); - } }; /* A hash table of decls keyed by mangled name. Used to figure out if diff --git a/gcc/hash-traits.h b/gcc/hash-traits.h index 2d17e2c982a..e5c9e88d99f 100644 --- a/gcc/hash-traits.h +++ b/gcc/hash-traits.h @@ -136,12 +136,52 @@ int_hash ::is_empty (Type x) return x == Empty; } +/* Base class for pointer hashers that want to implement marking in a generic + way. */ + +template +struct pointer_hash_mark +{ + static inline void mark_deleted (Pointer &); + static inline void mark_empty (Pointer &); + static inline bool is_deleted (Pointer); + static inline bool is_empty (Pointer); +}; + +template +inline void +pointer_hash_mark ::mark_deleted (Pointer &e) +{ + e = reinterpret_cast (1); +} + +template +inline void +pointer_hash_mark ::mark_empty (Pointer &e) +{ + e = NULL; +} + +template +inline bool +pointer_hash_mark ::is_deleted (Pointer e) +{ + return e == reinterpret_cast (1); +} + +template +inline bool +pointer_hash_mark ::is_empty (Pointer e) +{ + return e == NULL; +} + /* Pointer hasher based on pointer equality. Other types of pointer hash can inherit this and override the hash and equal functions with some other form of equality (such as string equality). */ template -struct pointer_hash +struct pointer_hash : pointer_hash_mark { typedef Type *value_type; typedef Type *compare_type; @@ -149,10 +189,6 @@ struct pointer_hash static inline hashval_t hash (const value_type &); static inline bool equal (const value_type &existing, const compare_type &candidate); - static inline void mark_deleted (Type *&); - static inline void mark_empty (Type *&); - static inline bool is_deleted (Type *); - static inline bool is_empty (Type *); }; template @@ -172,34 +208,6 @@ pointer_hash ::equal (const value_type &existing, return existing == candidate; } -template -inline void -pointer_hash ::mark_deleted (Type *&e) -{ - e = reinterpret_cast (1); -} - -template -inline void -pointer_hash ::mark_empty (Type *&e) -{ - e = NULL; -} - -template -inline bool -pointer_hash ::is_deleted (Type *e) -{ - return e == reinterpret_cast (1); -} - -template -inline bool -pointer_hash ::is_empty (Type *e) -{ - return e == NULL; -} - /* Hasher for "const char *" strings, using string rather than pointer equality. */ diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index 1a0e12e6c0c..6fde7500cf4 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -64,7 +64,8 @@ ipa_edge_args_sum_t *ipa_edge_args_sum; /* Traits for a hash table for reusing already existing ipa_bits. */ -struct ipa_bit_ggc_hash_traits : public ggc_cache_remove +struct ipa_bit_ggc_hash_traits : pointer_hash_mark , + ggc_cache_remove { typedef ipa_bits *value_type; typedef ipa_bits *compare_type; @@ -79,26 +80,6 @@ struct ipa_bit_ggc_hash_traits : public ggc_cache_remove { return a->value == b->value && a->mask == b->mask; } - static void - mark_empty (ipa_bits *&p) - { - p = NULL; - } - static bool - is_empty (const ipa_bits *p) - { - return p == NULL; - } - static bool - is_deleted (const ipa_bits *p) - { - return p == reinterpret_cast (1); - } - static void - mark_deleted (ipa_bits *&p) - { - p = reinterpret_cast (1); - } }; /* Hash table for avoid repeated allocations of equal ipa_bits. */ @@ -107,7 +88,9 @@ static GTY ((cache)) hash_table *ipa_bits_hash_table; /* Traits for a hash table for reusing value_ranges used for IPA. Note that the equiv bitmap is not hashed and is expected to be NULL. */ -struct ipa_vr_ggc_hash_traits : public ggc_cache_remove +struct ipa_vr_ggc_hash_traits : pointer_hash_mark , + ggc_cache_remove + { typedef value_range_base *value_type; typedef value_range_base *compare_type; @@ -124,26 +107,6 @@ struct ipa_vr_ggc_hash_traits : public ggc_cache_remove { return a->equal_p (*b); } - static void - mark_empty (value_range_base *&p) - { - p = NULL; - } - static bool - is_empty (const value_range_base *p) - { - return p == NULL; - } - static bool - is_deleted (const value_range_base *p) - { - return p == reinterpret_cast (1); - } - static void - mark_deleted (value_range_base *&p) - { - p = reinterpret_cast (1); - } }; /* Hash table for avoid repeated allocations of equal value_ranges. */