From patchwork Tue Jun 23 14:53:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 487673 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 2AAF214010F for ; Wed, 24 Jun 2015 00:53:46 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=Qi6qGj1M; dkim-atps=neutral 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:subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=EZX RS0yPbV1HjJ3+s75Gf5uhx4hQ9Wot3DOwVWxuzJBy8ptzj4vr56ZRD4SMdtNoxIK 7RyCb4FKsErE3ikKqEpciR1LYxfIY7t6ICgNZZd8EHDwS8+jBMZcKenY9KqqNi5d 2C4G74A+74iXwXVI8rBMicGF5lFflBiv0mfZw4GU= 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:subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; s=default; bh=ZIrrcNaXo 2uDDEFnbQ5FMVtvo7w=; b=Qi6qGj1MjLVREGLM+L1vMc+8km0XzSUA2TqNcfP1v Z0u1ZpHSbVk/ZFrm9QBTmhnG1TTOUtEW23ZBvHPsX44m1fktKSmrqubjkchLndji FDiAQ0VTwx3i/VVY5V/owUzY8zMWXKb28f0EsNdcGKB9FAK//igKXCwSeBOml395 cM= Received: (qmail 52671 invoked by alias); 23 Jun 2015 14:53:39 -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 52661 invoked by uid 89); 23 Jun 2015 14:53:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.2 required=5.0 tests=AWL, BAYES_50, KAM_ASCII_DIVIDERS, SPF_PASS autolearn=no version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (207.82.80.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 23 Jun 2015 14:53:37 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-8-VnR75ZFeRP-Ml8K8foNPaQ-1 Received: from localhost ([10.1.2.79]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 23 Jun 2015 15:53:34 +0100 From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [09/12] Remove all but one use of default_hashmap_traits References: <87egl2bicm.fsf@e105548-lin.cambridge.arm.com> Date: Tue, 23 Jun 2015 15:53:33 +0100 In-Reply-To: <87egl2bicm.fsf@e105548-lin.cambridge.arm.com> (Richard Sandiford's message of "Tue, 23 Jun 2015 15:38:17 +0100") Message-ID: <877fqua32q.fsf@e105548-lin.cambridge.arm.com> User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-MC-Unique: VnR75ZFeRP-Ml8K8foNPaQ-1 After the previous patches in the series, there are three remaining hash traits that use the key to represent empty and deleted entries. This patch makes them use simple_hashmap_traits. gcc/ * ipa-icf.h (symbol_compare_hash): New class. (symbol_compare_hashmap_traits): Use it. * mem-stats.h (mem_alloc_description::mem_location_hash): New class. (mem_alloc_description::mem_alloc_hashmap_traits): Use it. (mem_alloc_description::reverse_mem_map_t): Remove redundant default_hashmap_traits. * sanopt.c (sanopt_tree_triplet_hash): New class. (sanopt_tree_triplet_map_traits): Use it. Index: gcc/ipa-icf.h =================================================================== --- gcc/ipa-icf.h 2015-06-23 15:52:24.937095524 +0100 +++ gcc/ipa-icf.h 2015-06-23 15:52:24.929095617 +0100 @@ -87,10 +87,10 @@ enum sem_item_type /* Hash traits for symbol_compare_collection map. */ -struct symbol_compare_hashmap_traits: default_hashmap_traits +struct symbol_compare_hash : nofree_ptr_hash { static hashval_t - hash (const symbol_compare_collection *v) + hash (value_type v) { inchash::hash hstate; hstate.add_int (v->m_references.length ()); @@ -107,8 +107,7 @@ struct symbol_compare_hashmap_traits: de } static bool - equal_keys (const symbol_compare_collection *a, - const symbol_compare_collection *b) + equal (value_type a, value_type b) { if (a->m_references.length () != b->m_references.length () || a->m_interposables.length () != b->m_interposables.length ()) @@ -126,6 +125,8 @@ struct symbol_compare_hashmap_traits: de return true; } }; +typedef simple_hashmap_traits + symbol_compare_hashmap_traits; /* Semantic item usage pair. */ Index: gcc/mem-stats.h =================================================================== --- gcc/mem-stats.h 2015-06-23 15:52:24.937095524 +0100 +++ gcc/mem-stats.h 2015-06-23 15:52:24.929095617 +0100 @@ -238,10 +238,10 @@ struct mem_usage_pair class mem_alloc_description { public: - struct mem_alloc_hashmap_traits: default_hashmap_traits + struct mem_location_hash : nofree_ptr_hash { static hashval_t - hash (const mem_location *l) + hash (value_type l) { inchash::hash hstate; @@ -253,18 +253,18 @@ struct mem_usage_pair } static bool - equal_keys (const mem_location *l1, const mem_location *l2) + equal (value_type l1, value_type l2) { return l1->m_filename == l2->m_filename && l1->m_function == l2->m_function && l1->m_line == l2->m_line; } }; + typedef simple_hashmap_traits mem_alloc_hashmap_traits; /* Internal class type definitions. */ typedef hash_map mem_map_t; - typedef hash_map , default_hashmap_traits> - reverse_mem_map_t; + typedef hash_map > reverse_mem_map_t; typedef hash_map > reverse_object_map_t; typedef std::pair mem_list_t; Index: gcc/sanopt.c =================================================================== --- gcc/sanopt.c 2015-06-23 15:52:24.937095524 +0100 +++ gcc/sanopt.c 2015-06-23 15:52:24.929095617 +0100 @@ -109,8 +109,11 @@ struct sanopt_tree_triplet /* Traits class for tree triplet hash maps below. */ -struct sanopt_tree_triplet_map_traits : default_hashmap_traits +struct sanopt_tree_triplet_hash : typed_noop_remove { + typedef sanopt_tree_triplet value_type; + typedef sanopt_tree_triplet compare_type; + static inline hashval_t hash (const sanopt_tree_triplet &ref) { @@ -122,41 +125,39 @@ struct sanopt_tree_triplet_map_traits : } static inline bool - equal_keys (const sanopt_tree_triplet &ref1, const sanopt_tree_triplet &ref2) + equal (const sanopt_tree_triplet &ref1, const sanopt_tree_triplet &ref2) { return operand_equal_p (ref1.t1, ref2.t1, 0) && operand_equal_p (ref1.t2, ref2.t2, 0) && operand_equal_p (ref1.t3, ref2.t3, 0); } - template static inline void - mark_deleted (T &e) + mark_deleted (sanopt_tree_triplet &ref) { - e.m_key.t1 = reinterpret_cast (1); + ref.t1 = reinterpret_cast (1); } - template static inline void - mark_empty (T &e) + mark_empty (sanopt_tree_triplet &ref) { - e.m_key.t1 = NULL; + ref.t1 = NULL; } - template static inline bool - is_deleted (T &e) + is_deleted (const sanopt_tree_triplet &ref) { - return e.m_key.t1 == (void *) 1; + return ref.t1 == (void *) 1; } - template static inline bool - is_empty (T &e) + is_empty (const sanopt_tree_triplet &ref) { - return e.m_key.t1 == NULL; + return ref.t1 == NULL; } }; +typedef simple_hashmap_traits + sanopt_tree_triplet_map_traits; /* This is used to carry various hash maps and variables used in sanopt_optimize_walker. */