From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 60673 invoked by alias); 23 Jun 2015 14:55:20 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 60646 invoked by uid 89); 23 Jun 2015 14:55:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL,BAYES_00,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) (146.101.78.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 23 Jun 2015 14:55:16 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-5-vQczlsK9RgqMnVhjDl-rlA-1 Received: from localhost ([10.1.2.79]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 23 Jun 2015 15:55:13 +0100 From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [10/12] Add helper class for valued-based empty and deleted slots References: <87egl2bicm.fsf@e105548-lin.cambridge.arm.com> Date: Tue, 23 Jun 2015 14:56:00 -0000 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: <87381ia2zy.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: vQczlsK9RgqMnVhjDl-rlA-1 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable X-SW-Source: 2015-06/txt/msg01576.txt.bz2 part_traits in cfgexpand.c needs to use the value rather than the key to represent empty and deleted slots. What it's doing is pretty generic, so this patch adds a helper class to hash-map-traits.h. gcc/ * hash-map-traits.h (unbounded_hashmap_traits): New class. (unbounded_int_hashmap_traits): Likewise. * cfgexpand.c (part_traits): Use unbounded_int_hashmap_traits. Index: gcc/hash-map-traits.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- gcc/hash-map-traits.h 2015-06-23 15:54:04.515950631 +0100 +++ gcc/hash-map-traits.h 2015-06-23 15:54:04.511950679 +0100 @@ -174,4 +174,84 @@ simple_hashmap_traits ::mark_deleted H::mark_deleted (entry.m_key); } =20 +/* Implement traits for a hash_map with values of type Value for cases + in which the key cannot represent empty and deleted slots. Instead + record empty and deleted entries in Value. Derived classes must + implement the hash and equal_keys functions. */ + +template +struct unbounded_hashmap_traits +{ + template static inline void remove (T &); + template static inline bool is_empty (const T &); + template static inline bool is_deleted (const T &); + template static inline void mark_empty (T &); + template static inline void mark_deleted (T &); +}; + +template +template +inline void +unbounded_hashmap_traits ::remove (T &entry) +{ + default_hash_traits ::remove (entry.m_value); +} + +template +template +inline bool +unbounded_hashmap_traits ::is_empty (const T &entry) +{ + return default_hash_traits ::is_empty (entry.m_value); +} + +template +template +inline bool +unbounded_hashmap_traits ::is_deleted (const T &entry) +{ + return default_hash_traits ::is_deleted (entry.m_value); +} + +template +template +inline void +unbounded_hashmap_traits ::mark_empty (T &entry) +{ + default_hash_traits ::mark_empty (entry.m_value); +} + +template +template +inline void +unbounded_hashmap_traits ::mark_deleted (T &entry) +{ + default_hash_traits ::mark_deleted (entry.m_value); +} + +/* Implement traits for a hash_map from integer type Key to Value in + cases where Key has no spare values for recording empty and deleted + slots. */ + +template +struct unbounded_int_hashmap_traits : unbounded_hashmap_traits +{ + static inline hashval_t hash (Key); + static inline bool equal_keys (Key, Key); +}; + +template +inline hashval_t +unbounded_int_hashmap_traits ::hash (Key k) +{ + return k; +} + +template +inline bool +unbounded_int_hashmap_traits ::equal_keys (Key k1, Key k2) +{ + return k1 =3D=3D k2; +} + #endif // HASH_MAP_TRAITS_H Index: gcc/cfgexpand.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- gcc/cfgexpand.c 2015-06-23 15:54:04.515950631 +0100 +++ gcc/cfgexpand.c 2015-06-23 15:54:04.511950679 +0100 @@ -612,25 +612,7 @@ stack_var_cmp (const void *a, const void return 0; } =20 -struct part_traits : default_hashmap_traits -{ - template - static bool - is_deleted (T &e) - { return e.m_value =3D=3D reinterpret_cast (1); } - - template static bool is_empty (T &e) { return e.m_value =3D= =3D NULL; } - template - static void - mark_deleted (T &e) - { e.m_value =3D reinterpret_cast (1); } - - template - static void - mark_empty (T &e) - { e.m_value =3D NULL; } -}; - +struct part_traits : unbounded_int_hashmap_traits {}; typedef hash_map part_hashmap; =20 /* If the points-to solution *PI points to variables that are in a partiti= on