From patchwork Tue Dec 11 22:44:41 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lawrence Crowl X-Patchwork-Id: 205330 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]) by ozlabs.org (Postfix) with SMTP id 280932C0091 for ; Wed, 12 Dec 2012 09:52:35 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1355871156; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:Date:Message-ID:Subject:From:To: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=Ho41yO9 16V9BVffFhznh+YnyidI=; b=WePD9KzbSoxF11y1wemhB5OoWf06Hhs+0r+U08n XLoATAvbt5zyIfK46QO19jbmWMmpbUXJpprCMSnevj6CIP4QuK0kwDCwUWhBGDDV 5brfy65pGpM+mLrShI1LuMj9vPvyaXNZ0XpO5wJQhTHQq8hLM2xcrTVTpJ6vNZR6 ggJc= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-Google-DKIM-Signature:MIME-Version:Received:Received:Date:Message-ID:Subject:From:To:Content-Type:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=FAYI0imQ+v67XXMROOG/v/Wp+F0S54HtiF71A2oW3k1CbKSxtsdFaap2C7AsFb AD4FWScy1BLfFQ9mD2AKe9NwBfyndmdt5CLcACLqNkDb/ExzN7JOBkbG7d7V5Jr1 wNMjPSupi35kdSFxD2z1hjj7rAvi00l8bZQ/cjzbhVUAU=; Received: (qmail 21300 invoked by alias); 11 Dec 2012 22:44:54 -0000 Received: (qmail 21291 invoked by uid 22791); 11 Dec 2012 22:44:53 -0000 X-SWARE-Spam-Status: No, hits=-5.1 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-ie0-f174.google.com (HELO mail-ie0-f174.google.com) (209.85.223.174) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 11 Dec 2012 22:44:43 +0000 Received: by mail-ie0-f174.google.com with SMTP id c11so14647088ieb.33 for ; Tue, 11 Dec 2012 14:44:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type :x-gm-message-state; bh=izY3oVkx59rrT9cLRm3CceDAFRkUfSVsOJ+GleB+q5k=; b=HT/+xzSByrgXJi+jPqwJ5q9S+TmarJ4KKS2c1+N9dA8uLaY21Sd1dF67jvZfdRd0Tm 7Z8SDkA7y1Xx+r20B+ymtuXGh3vvDtjceWl7jqvBqZsk7ORlwQOKXZ5Iux/RQ3sn9lIh 9rOPyxzZOljTuOr1VbrOoF54pZiLwEh/+j1dgVtVcoqIAJxxWUE4QgiJoHv4a+OSr0nH WxCG3vlx2z0hp9gyO/ETaKyhK319kqGBGtWP0i0LcOUFP8OnJ/6UC5LoEWZW0Z7AWf/y 6VxKOIWbrnZu5BWqZ1Jgt6XQ5TO/5QkLA8ZDKOXIeJF/zOZahaB/rjobd9y7J33FfBoO 0IlA== MIME-Version: 1.0 Received: by 10.50.104.164 with SMTP id gf4mr11776813igb.1.1355265881470; Tue, 11 Dec 2012 14:44:41 -0800 (PST) Received: by 10.231.199.18 with HTTP; Tue, 11 Dec 2012 14:44:41 -0800 (PST) Date: Tue, 11 Dec 2012 14:44:41 -0800 Message-ID: Subject: [cxx-conversion] Convert tree-sra.c'candidates to hash_table From: Lawrence Crowl To: gcc-patches List X-Gm-Message-State: ALoCoQlt5R6kwiubvIizyvDnGCHLTft4LxFJoc+4/9fwlg3mD2CJ4h7d4TYO0MiJZ4vurBtfOzohbJ2WX9+PcsCkCxGNs4DVA9XQeb40O+8iyNV2Ommj1fFV8QVd3xGgXN/v5TLp9qVh500W+MsDpnLc7lubhl2uSR1r4Y6MYu/aBNcGh6g4J+e/Upa1v8KoOBwwdQMcZK5s X-IsSubscribed: yes 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 Convert tree-sra.c'candidates from htab_t to hash_table. Fold uid_decl_map_hash and uid_decl_map_eq into new struct uid_decl_hasher. This change moves the definitions from tree-ssa.c into tree-sra.c and removes the declarations from tree-flow.h Update dependent calls and types to hash_table. Tested on x86_64. Okay for branch? Index: gcc/tree-sra.c =================================================================== --- gcc/tree-sra.c (revision 194381) +++ gcc/tree-sra.c (working copy) @@ -74,6 +74,7 @@ along with GCC; see the file COPYING3. #include "config.h" #include "system.h" #include "coretypes.h" +#include "hash-table.h" #include "alloc-pool.h" #include "tm.h" #include "tree.h" @@ -269,18 +270,44 @@ static alloc_pool link_pool; /* Base (tree) -> Vector (vec *) map. */ static struct pointer_map_t *base_access_vec; +/* Candidate ashtable helpers. */ + +struct uid_decl_hasher : typed_noop_remove +{ + typedef tree_node value_type; + typedef tree_node compare_type; + static inline hashval_t hash (const value_type *); + static inline bool equal (const value_type *, const compare_type *); +}; + +/* Hash a tree in a uid_decl_map. */ + +inline hashval_t +uid_decl_hasher::hash (const value_type *item) +{ + return item->decl_minimal.uid; +} + +/* Return true if the DECL_UID in both trees are equal. */ + +inline bool +uid_decl_hasher::equal (const value_type *a, const compare_type *b) +{ + return (a->decl_minimal.uid == b->decl_minimal.uid); +} + /* Set of candidates. */ static bitmap candidate_bitmap; -static htab_t candidates; +static hash_table candidates; /* For a candidate UID return the candidates decl. */ static inline tree candidate (unsigned uid) { - struct tree_decl_minimal t; - t.uid = uid; - return (tree) htab_find_with_hash (candidates, &t, uid); + tree_node t; + t.decl_minimal.uid = uid; + return candidates.find_with_hash (&t, static_cast (uid)); } /* Bitmap of candidates which we should try to entirely scalarize away and @@ -611,8 +638,7 @@ static void sra_initialize (void) { candidate_bitmap = BITMAP_ALLOC (NULL); - candidates = htab_create (vec_safe_length (cfun->local_decls) / 2, - uid_decl_map_hash, uid_decl_map_eq, NULL); + candidates.create (vec_safe_length (cfun->local_decls) / 2); should_scalarize_away_bitmap = BITMAP_ALLOC (NULL); cannot_scalarize_away_bitmap = BITMAP_ALLOC (NULL); gcc_obstack_init (&name_obstack); @@ -642,7 +668,7 @@ static void sra_deinitialize (void) { BITMAP_FREE (candidate_bitmap); - htab_delete (candidates); + candidates.dispose (); BITMAP_FREE (should_scalarize_away_bitmap); BITMAP_FREE (cannot_scalarize_away_bitmap); free_alloc_pool (access_pool); @@ -659,9 +685,9 @@ static void disqualify_candidate (tree decl, const char *reason) { if (bitmap_clear_bit (candidate_bitmap, DECL_UID (decl))) - htab_clear_slot (candidates, - htab_find_slot_with_hash (candidates, decl, - DECL_UID (decl), NO_INSERT)); + candidates.clear_slot (candidates.find_slot_with_hash (decl, + DECL_UID (decl), + NO_INSERT)); if (dump_file && (dump_flags & TDF_DETAILS)) { @@ -1687,7 +1713,7 @@ maybe_add_sra_candidate (tree var) { tree type = TREE_TYPE (var); const char *msg; - void **slot; + tree_node **slot; if (!AGGREGATE_TYPE_P (type)) { @@ -1735,8 +1761,8 @@ maybe_add_sra_candidate (tree var) } bitmap_set_bit (candidate_bitmap, DECL_UID (var)); - slot = htab_find_slot_with_hash (candidates, var, DECL_UID (var), INSERT); - *slot = (void *) var; + slot = candidates.find_slot_with_hash (var, DECL_UID (var), INSERT); + *slot = var; if (dump_file && (dump_flags & TDF_DETAILS)) { @@ -3589,7 +3615,7 @@ find_param_candidates (void) parm = DECL_CHAIN (parm)) { tree type = TREE_TYPE (parm); - void **slot; + tree_node **slot; count++; @@ -3628,9 +3654,8 @@ find_param_candidates (void) continue; bitmap_set_bit (candidate_bitmap, DECL_UID (parm)); - slot = htab_find_slot_with_hash (candidates, parm, - DECL_UID (parm), INSERT); - *slot = (void *) parm; + slot = candidates.find_slot_with_hash (parm, DECL_UID (parm), INSERT); + *slot = parm; ret = true; if (dump_file && (dump_flags & TDF_DETAILS)) Index: gcc/tree-ssa.c =================================================================== --- gcc/tree-ssa.c (revision 194381) +++ gcc/tree-ssa.c (working copy) @@ -1052,24 +1052,6 @@ err: /* Return true if the DECL_UID in both trees are equal. */ -int -uid_decl_map_eq (const void *va, const void *vb) -{ - const_tree a = (const_tree) va; - const_tree b = (const_tree) vb; - return (a->decl_minimal.uid == b->decl_minimal.uid); -} - -/* Hash a tree in a uid_decl_map. */ - -unsigned int -uid_decl_map_hash (const void *item) -{ - return ((const_tree)item)->decl_minimal.uid; -} - -/* Return true if the DECL_UID in both trees are equal. */ - static int uid_ssaname_map_eq (const void *va, const void *vb) { Index: gcc/tree-flow.h =================================================================== --- gcc/tree-flow.h (revision 194381) +++ gcc/tree-flow.h (working copy) @@ -283,9 +283,6 @@ struct int_tree_map { tree to; }; -extern unsigned int uid_decl_map_hash (const void *); -extern int uid_decl_map_eq (const void *, const void *); - #define num_ssa_names (vec_safe_length (cfun->gimple_df->ssa_names)) #define ssa_name(i) ((*cfun->gimple_df->ssa_names)[(i)]) Index: gcc/Makefile.in =================================================================== --- gcc/Makefile.in (revision 194381) +++ gcc/Makefile.in (working copy) @@ -3034,7 +3034,7 @@ tree-ssa-strlen.o : tree-ssa-strlen.c $( $(TREE_FLOW_H) $(TREE_PASS_H) domwalk.h alloc-pool.h tree-ssa-propagate.h \ $(GIMPLE_PRETTY_PRINT_H) $(PARAMS_H) $(EXPR_H) tree-sra.o : tree-sra.c $(CONFIG_H) $(SYSTEM_H) coretypes.h alloc-pool.h \ - $(TM_H) $(TREE_H) $(GIMPLE_H) $(CGRAPH_H) $(TREE_FLOW_H) \ + $(HASH_TABLE_H) $(TM_H) $(TREE_H) $(GIMPLE_H) $(CGRAPH_H) $(TREE_FLOW_H) \ $(IPA_PROP_H) $(DIAGNOSTIC_H) statistics.h \ $(PARAMS_H) $(TARGET_H) $(FLAGS_H) \ $(DBGCNT_H) $(TREE_INLINE_H) $(GIMPLE_PRETTY_PRINT_H)