From patchwork Tue Jun 16 09:11:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 484870 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 171CF140293 for ; Tue, 16 Jun 2015 19:11:16 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=FbkS0+8l; 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=rVy LGh7Br8afoUveCoZXCohMzY17aSQP3VgYFWhDO/T6XzrhoD/eYw5kCzZa5i8arkC ZoJtiyDDZKxtuZzekYJurZlSSndMbEIo6Hk41h6vBADwwdfQe9KYSY7uFv7Xnfz8 2A7kvVcqGm87of2lJIEhfUUx3OmY0LnbgVwznxCM= 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=Duq71iobB Wqum+T7m/aSb2P3QhI=; b=FbkS0+8la+9Fg7EAHI/0tqq+ZGjmhNqsfFdpISFIQ B3ArAa4Vr2gW3J2w0YfalIQ6RpP/nV6yzyoZedwXqMcFf6B3ae0R9OTlbkOFBvMh DvYtBrHEFqz58ltfKjaXxVupBOMKPNtJigw1PdqiOcwh5L+RMAhG4+GbkSchGo9s gU= Received: (qmail 127954 invoked by alias); 16 Jun 2015 09:11:09 -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 127942 invoked by uid 89); 16 Jun 2015 09:11:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham 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, 16 Jun 2015 09:11:05 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by uk-mta-10.uk.mimecast.lan; Tue, 16 Jun 2015 10:11:01 +0100 Received: from localhost ([10.1.2.79]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 16 Jun 2015 10:11:01 +0100 From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [10/13] Require {mark,id}_{deleted,empty} functions References: <87fv5s2gej.fsf@e105548-lin.cambridge.arm.com> Date: Tue, 16 Jun 2015 10:11:01 +0100 In-Reply-To: <87fv5s2gej.fsf@e105548-lin.cambridge.arm.com> (Richard Sandiford's message of "Tue, 16 Jun 2015 09:42:28 +0100") Message-ID: <877fr410ii.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: mGgDg2liTKidAPzlGMTpvQ-1 After the previous changes, all traits classes provide an implementation of the empty & deleted entry functions, so we can remove the code that provided defaults. gcc/ * hash-table.h (has_is_deleted, is_deleted_helper): Delete. (has_is_empty, is_empty_helper): Delete. (has_mark_deleted, mark_deleted_helper): Delete. (has_mark_empty, mark_empty_helper): Delete. (hash_table::is_deleted): Call the Descriptor unconditionally. (hash_table::is_empty): Likewise. (hash_table::mark_deleted): Likewise. (hash_table::mark_empty): Likewise. Index: gcc/hash-table.h =================================================================== --- gcc/hash-table.h 2015-06-16 10:10:16.374654332 +0100 +++ gcc/hash-table.h 2015-06-16 10:10:16.370654379 +0100 @@ -323,122 +323,6 @@ hash_table_mod2 (hashval_t hash, unsigne return 1 + mul_mod (hash, p->prime - 2, p->inv_m2, p->shift); } - template - struct has_is_deleted -{ - template struct helper {}; - template static char test (helper *); - template static int test (...); - static const bool value = sizeof (test (0)) == sizeof (char); -}; - -template::value> -struct is_deleted_helper -{ - static inline bool - call (Type &v) - { - return Traits::is_deleted (v); - } -}; - -template -struct is_deleted_helper -{ - static inline bool - call (Type *v) - { - return v == HTAB_DELETED_ENTRY; - } -}; - - template - struct has_is_empty -{ - template struct helper {}; - template static char test (helper *); - template static int test (...); - static const bool value = sizeof (test (0)) == sizeof (char); -}; - -template::value> -struct is_empty_helper -{ - static inline bool - call (Type &v) - { - return Traits::is_empty (v); - } -}; - -template -struct is_empty_helper -{ - static inline bool - call (Type *v) - { - return v == HTAB_EMPTY_ENTRY; - } -}; - - template - struct has_mark_deleted -{ - template struct helper {}; - template static char test (helper *); - template static int test (...); - static const bool value = sizeof (test (0)) == sizeof (char); -}; - -template::value> -struct mark_deleted_helper -{ - static inline void - call (Type &v) - { - Traits::mark_deleted (v); - } -}; - -template -struct mark_deleted_helper -{ - static inline void - call (Type *&v) - { - v = static_cast (HTAB_DELETED_ENTRY); - } -}; - - template - struct has_mark_empty -{ - template struct helper {}; - template static char test (helper *); - template static int test (...); - static const bool value = sizeof (test (0)) == sizeof (char); -}; - -template::value> -struct mark_empty_helper -{ - static inline void - call (Type &v) - { - Traits::mark_empty (v); - } -}; - -template -struct mark_empty_helper -{ - static inline void - call (Type *&v) - { - v = static_cast (HTAB_EMPTY_ENTRY); - } -}; - class mem_usage; /* User-facing hash table type. @@ -610,23 +494,24 @@ struct mark_empty_helper::call (v); - } + { + return Descriptor::is_deleted (v); + } + static bool is_empty (value_type &v) - { - return is_empty_helper::call (v); - } + { + return Descriptor::is_empty (v); + } static void mark_deleted (value_type &v) - { - return mark_deleted_helper::call (v); - } + { + Descriptor::mark_deleted (v); + } static void mark_empty (value_type &v) - { - return mark_empty_helper::call (v); - } + { + Descriptor::mark_empty (v); + } /* Table itself. */ typename Descriptor::value_type *m_entries;