From patchwork Sun Dec 2 01:44:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lawrence Crowl X-Patchwork-Id: 203170 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 9A0A82C0080 for ; Sun, 2 Dec 2012 12:44:27 +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=1355017467; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:Date:Message-ID:Subject:From:To: Cc:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=w8FjkKn CMm5DP9nLsF6xJBsADUc=; b=hTRmSlt2hOf0WKP1uwgb29WK6eiYMKNh4D1q/Ij otpPKNzhwBwrzgCwnSs/UcdBNZ90F01ezfLWWxYncsi+9Gvjap2A5Kx/SQBA861G LXMR4/KpGr9S/Y+KT1I4UcKGyctAJ8RHS+/rtiI8RW5k8zN+FtK5agtubPxGO3Ti 0bIg= 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:Cc: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=K6EWIiEudJ9t/IuV0JFaJbFyuZvwY+8DktxLeCJ8yhVL6r1GqGfP00IGb1+VUQ cX0Aq0wRGaHkBzMFr4+LUvMx2GbwXcZT2n8IzBAF7ut/3ztVbyc6hrYvF5WvBoDx On9V2rwpUatDEQ0gAoxJLmouY8cXpLqWNfy9QgqQ63sdI=; Received: (qmail 19765 invoked by alias); 2 Dec 2012 01:44:22 -0000 Received: (qmail 19754 invoked by uid 22791); 2 Dec 2012 01:44:22 -0000 X-SWARE-Spam-Status: No, hits=-5.3 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, TW_TM, TW_TX X-Spam-Check-By: sourceware.org Received: from mail-qa0-f54.google.com (HELO mail-qa0-f54.google.com) (209.85.216.54) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 02 Dec 2012 01:44:12 +0000 Received: by mail-qa0-f54.google.com with SMTP id j15so526421qaq.20 for ; Sat, 01 Dec 2012 17:44:12 -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:cc:content-type :x-gm-message-state; bh=XzQe0JC1fbfGkD8qRvsKxata6H7yOutDFN/5wVNk7L8=; b=AywTtysSDkw/mLUdwjBpkvggfQnzTGdYsnoRH8BcoswtV4KHLwDXrYBEWQR7fxTHsr 4qHFkIyQIOxGq4tbQ0i4SpiBKb71uj+Cab6HB+JwMrK/AIUjp6n2NRyTXx1LoEBRDPh7 Hv8WJFCPlfn8BI+xJUT/nPWDApTsKleQG6YbS9B03V7KW3Ekrg4TQxi4z8B/VULKHPD7 4zcGUbNnbdpYT+QXpUQa9xD04ddhvtg8gdKZhQbtyU1WLSvMIfMKyrHRQB2OuJPfxh00 v3mXS+vMZwh8NybczuNUyQ2meewGz4ogNrKkKkQbotALTY2L25X7XdW2mQZobr9UY/3Y S6mw== MIME-Version: 1.0 Received: by 10.49.128.37 with SMTP id nl5mr11073396qeb.59.1354412651823; Sat, 01 Dec 2012 17:44:11 -0800 (PST) Received: by 10.229.136.199 with HTTP; Sat, 1 Dec 2012 17:44:11 -0800 (PST) Date: Sat, 1 Dec 2012 17:44:11 -0800 Message-ID: Subject: [cxx-conversion] gimplify_ctx::temp_htab hash table From: Lawrence Crowl To: gcc-patches List Cc: Diego Novillo X-Gm-Message-State: ALoCoQkDX3FZo+LEYpIs1R6v8+DQEYX1Rf7nc9+ETc2zWY60CSViqqAPtIAtgz4vGltrsWoY60W665Pfg1ZUXTPmV/pYqw3GseBTNL1lhOJHEk9rEem3O8esW3uhXrmOeCJwNstEO4xJH+tQAnw8l/Qo+eL2W1v0vsOlHLrDf/c1hSKHJqCC7DIXr3kGdchIV2zI92qjAw3m 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 Change gimplify.c gimplify_ctx::temp_htab hash table from htab_t to hash_table. Move struct gimple_temp_hash_elt and struct gimplify_ctx to a new gimplify-ctx.h, because they are used few places. Tested on x86-64. Okay for branch? Index: gcc/ChangeLog 2012-11-30 Lawrence Crowl * gimple.h (struct gimplify_ctx): Move to gimplify-ctx.h. (push_gimplify_context): Likewise. (pop_gimplify_context): Likewise. * gimplify-ctx.h: New. (struct gimple_temp_hash_elt): Move from gimplify.c. (class gimplify_hasher): New. (struct gimplify_ctx): Move from gimple.h. (htab_t gimplify_ctx::temp_htab): Change type to hash_table. Update dependent calls and types. * gimple-fold.c: Include gimplify-ctx.h. * gimplify.c: Include gimplify-ctx.h. (struct gimple_temp_hash_elt): Move to gimplify-ctx.h. (htab_t gimplify_ctx::temp_htab): Update dependent calls and types for new type hash_table. (gimple_tree_hash): Move into gimplify_hasher in gimplify-ctx.h. (gimple_tree_eq): Move into gimplify_hasher in gimplify-ctx.h. * omp-low.c: Include gimplify-ctx.h. * tree-inline.c: Include gimplify-ctx.h. * tree-mudflap.c: Include gimplify-ctx.h. * Makefile.in: Update to changes above. Index: gcc/omp-low.c =================================================================== --- gcc/omp-low.c (revision 193902) +++ gcc/omp-low.c (working copy) @@ -29,6 +29,7 @@ along with GCC; see the file COPYING3. #include "tree.h" #include "rtl.h" #include "gimple.h" +#include "gimplify-ctx.h" #include "tree-iterator.h" #include "tree-inline.h" #include "langhooks.h" Index: gcc/gimplify.c =================================================================== --- gcc/gimplify.c (revision 193902) +++ gcc/gimplify.c (working copy) @@ -44,6 +44,7 @@ along with GCC; see the file COPYING3. #include "splay-tree.h" #include "vec.h" #include "gimple.h" +#include "gimplify-ctx.h" #include "langhooks-def.h" /* FIXME: for lhd_set_decl_assembler_name */ #include "tree-pass.h" /* FIXME: only for PROP_gimple_any */ @@ -88,15 +89,6 @@ static struct gimplify_ctx *gimplify_ctx static struct gimplify_omp_ctx *gimplify_omp_ctxp; -/* Formal (expression) temporary table handling: multiple occurrences of - the same scalar expression are evaluated into the same temporary. */ - -typedef struct gimple_temp_hash_elt -{ - tree val; /* Key */ - tree temp; /* Value */ -} elt_t; - /* Forward declaration. */ static enum gimplify_status gimplify_compound_expr (tree *, gimple_seq *, bool); @@ -131,40 +123,6 @@ mark_addressable (tree x) } } -/* Return a hash value for a formal temporary table entry. */ - -static hashval_t -gimple_tree_hash (const void *p) -{ - tree t = ((const elt_t *) p)->val; - return iterative_hash_expr (t, 0); -} - -/* Compare two formal temporary table entries. */ - -static int -gimple_tree_eq (const void *p1, const void *p2) -{ - tree t1 = ((const elt_t *) p1)->val; - tree t2 = ((const elt_t *) p2)->val; - enum tree_code code = TREE_CODE (t1); - - if (TREE_CODE (t2) != code - || TREE_TYPE (t1) != TREE_TYPE (t2)) - return 0; - - if (!operand_equal_p (t1, t2, 0)) - return 0; - -#ifdef ENABLE_CHECKING - /* Only allow them to compare equal if they also hash equal; otherwise - results are nondeterminate, and we fail bootstrap comparison. */ - gcc_assert (gimple_tree_hash (p1) == gimple_tree_hash (p2)); -#endif - - return 1; -} - /* Link gimple statement GS to the end of the sequence *SEQ_P. If *SEQ_P is NULL, a new sequence is allocated. This function is similar to gimple_seq_add_stmt, but does not scan the operands. @@ -242,8 +200,8 @@ pop_gimplify_context (gimple body) else record_vars (c->temps); - if (c->temp_htab) - htab_delete (c->temp_htab); + if (c->temp_htab.is_created ()) + c->temp_htab.dispose (); } /* Push a GIMPLE_BIND tuple onto the stack of bindings. */ @@ -586,23 +544,22 @@ lookup_tmp_var (tree val, bool is_formal else { elt_t elt, *elt_p; - void **slot; + elt_t **slot; elt.val = val; - if (gimplify_ctxp->temp_htab == NULL) - gimplify_ctxp->temp_htab - = htab_create (1000, gimple_tree_hash, gimple_tree_eq, free); - slot = htab_find_slot (gimplify_ctxp->temp_htab, (void *)&elt, INSERT); + if (!gimplify_ctxp->temp_htab.is_created ()) + gimplify_ctxp->temp_htab.create (1000); + slot = gimplify_ctxp->temp_htab.find_slot (&elt, INSERT); if (*slot == NULL) { elt_p = XNEW (elt_t); elt_p->val = val; elt_p->temp = ret = create_tmp_from_val (val, is_formal); - *slot = (void *) elt_p; + *slot = elt_p; } else { - elt_p = (elt_t *) *slot; + elt_p = *slot; ret = elt_p->temp; } } Index: gcc/gimple-fold.c =================================================================== --- gcc/gimple-fold.c (revision 193902) +++ gcc/gimple-fold.c (working copy) @@ -30,6 +30,7 @@ along with GCC; see the file COPYING3. #include "tree-ssa-propagate.h" #include "target.h" #include "gimple-fold.h" +#include "gimplify-ctx.h" /* Return true when DECL can be referenced from current unit. FROM_DECL (if non-null) specify constructor of variable DECL was taken from. Index: gcc/tree-mudflap.c =================================================================== --- gcc/tree-mudflap.c (revision 193902) +++ gcc/tree-mudflap.c (working copy) @@ -43,6 +43,7 @@ along with GCC; see the file COPYING3. #include "ggc.h" #include "cgraph.h" #include "gimple.h" +#include "gimplify-ctx.h" extern void add_bb_to_loop (basic_block, struct loop *); Index: gcc/tree-inline.c =================================================================== --- gcc/tree-inline.c (revision 193902) +++ gcc/tree-inline.c (working copy) @@ -48,6 +48,7 @@ along with GCC; see the file COPYING3. #include "value-prof.h" #include "tree-pass.h" #include "target.h" +#include "gimplify-ctx.h" #include "rtl.h" /* FIXME: For asm_str_count. */ Index: gcc/Makefile.in =================================================================== --- gcc/Makefile.in (revision 193902) +++ gcc/Makefile.in (working copy) @@ -877,6 +877,7 @@ BASIC_BLOCK_H = basic-block.h $(PREDICT_ GIMPLE_H = gimple.h gimple.def gsstruct.def pointer-set.h $(VEC_H) \ $(GGC_H) $(BASIC_BLOCK_H) $(TREE_H) tree-ssa-operands.h \ tree-ssa-alias.h $(INTERNAL_FN_H) +GIMPLIFY_CTX_H = gimplify-ctx.h $(TREE_H) $(HASH_TABLE_H) TRANS_MEM_H = trans-mem.h GCOV_IO_H = gcov-io.h gcov-iov.h auto-host.h COVERAGE_H = coverage.h $(GCOV_IO_H) @@ -2214,7 +2215,7 @@ tree-dump.o: tree-dump.c $(CONFIG_H) $(S tree-inline.o : tree-inline.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ $(TREE_H) $(RTL_H) $(FLAGS_H) $(PARAMS_H) $(INPUT_H) insn-config.h \ $(HASHTAB_H) langhooks.h $(TREE_INLINE_H) $(CGRAPH_H) \ - intl.h $(FUNCTION_H) $(GIMPLE_H) \ + intl.h $(FUNCTION_H) $(GIMPLE_H) $(GIMPLIFY_CTX_H) \ debug.h $(DIAGNOSTIC_H) $(EXCEPT_H) $(TREE_FLOW_H) tree-iterator.h tree-mudflap.h \ $(IPA_PROP_H) value-prof.h $(TREE_PASS_H) $(TARGET_H) \ $(TREE_PRETTY_PRINT_H) @@ -2512,14 +2513,15 @@ tree-optimize.o : tree-optimize.c $(TREE $(TREE_PASS_H) $(CFGLOOP_H) $(EXCEPT_H) gimplify.o : gimplify.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(GIMPLE_H) \ - $(DIAGNOSTIC_H) $(TREE_INLINE_H) langhooks.h \ + $(GIMPLIFY_CTX_H) $(DIAGNOSTIC_H) $(TREE_INLINE_H) langhooks.h \ $(LANGHOOKS_DEF_H) $(TREE_FLOW_H) $(CGRAPH_H) $(TIMEVAR_H) $(TM_H) \ coretypes.h $(EXCEPT_H) $(FLAGS_H) $(RTL_H) $(FUNCTION_H) $(EXPR_H) \ $(GGC_H) gt-gimplify.h $(HASHTAB_H) $(TARGET_H) $(DIAGNOSTIC_CORE_H) $(OPTABS_H) \ $(SPLAY_TREE_H) $(VEC_H) tree-iterator.h $(TREE_PASS_H) $(TREE_PRETTY_PRINT_H) gimple-iterator.o : gimple-iterator.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ $(TREE_H) $(GIMPLE_H) $(TREE_FLOW_H) value-prof.h -gimple-fold.o : gimple-fold.c $(TREE_FLOW_H) $(CONFIG_H) coretypes.h dumpfile.h \ +gimple-fold.o : gimple-fold.c $(TREE_FLOW_H) $(CONFIG_H) coretypes.h \ + $(GIMPLIFY_CTX_H) dumpfile.h \ $(SYSTEM_H) $(RTL_H) $(TREE_H) $(TM_P_H) $(GGC_H) \ $(FUNCTION_H) $(TM_H) $(BASIC_BLOCK_H) langhooks.h \ tree-ssa-propagate.h $(FLAGS_H) $(TARGET_H) gimple-fold.h @@ -2529,7 +2531,8 @@ gimple-low.o : gimple-low.c $(CONFIG_H) $(EXCEPT_H) $(FLAGS_H) $(RTL_H) $(FUNCTION_H) $(TREE_PASS_H) \ $(HASHTAB_H) $(DIAGNOSTIC_CORE_H) tree-iterator.h langhooks.h omp-low.o : omp-low.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \ - $(RTL_H) $(GIMPLE_H) $(TREE_INLINE_H) langhooks.h $(DIAGNOSTIC_CORE_H) \ + $(RTL_H) $(GIMPLE_H) $(GIMPLIFY_CTX_H) $(TREE_INLINE_H) langhooks.h \ + $(DIAGNOSTIC_CORE_H) \ $(TREE_FLOW_H) $(FLAGS_H) $(EXPR_H) $(DIAGNOSTIC_CORE_H) \ $(TREE_PASS_H) $(GGC_H) $(EXCEPT_H) $(SPLAY_TREE_H) $(OPTABS_H) \ $(CFGLOOP_H) tree-iterator.h gt-omp-low.h @@ -2634,8 +2637,9 @@ gimple-pretty-print.o : gimple-pretty-pr $(TREE_H) $(DIAGNOSTIC_H) $(HASHTAB_H) $(TREE_FLOW_H) \ $(TM_H) $(GIMPLE_H) value-prof.h \ $(TRANS_MEM_H) $(GIMPLE_PRETTY_PRINT_H) -tree-mudflap.o : $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(TREE_INLINE_H) \ - $(GIMPLE_H) $(DIAGNOSTIC_H) $(DEMANGLE_H) $(HASHTAB_H) langhooks.h tree-mudflap.h \ +tree-mudflap.o : tree-mudflap.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) \ + $(TREE_INLINE_H) $(GIMPLE_H) $(GIMPLIFY_CTX_H) $(DIAGNOSTIC_H) \ + $(DEMANGLE_H) $(HASHTAB_H) langhooks.h tree-mudflap.h \ $(TM_H) coretypes.h $(TREE_PASS_H) $(CGRAPH_H) $(GGC_H) \ gt-tree-mudflap.h $(BASIC_BLOCK_H) $(FLAGS_H) $(FUNCTION_H) \ $(TM_P_H) $(TREE_FLOW_H) $(DIAGNOSTIC_CORE_H) $(GIMPLE_H) tree-iterator.h Index: gcc/gimplify-ctx.h =================================================================== --- gcc/gimplify-ctx.h (revision 0) +++ gcc/gimplify-ctx.h (revision 0) @@ -0,0 +1,101 @@ +/* Gimplify_ctx structure definitions. + + Copyright 2012 Free Software Foundation, Inc. + Contributed by Lawrence Crowl + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +#ifndef GCC_GIMPLIFY_CTX_H +#define GCC_GIMPLIFY_CTX_H + +#include "tree.h" +#include "hash-table.h" + +/* Formal (expression) temporary table handling: multiple occurrences of + the same scalar expression are evaluated into the same temporary. */ + +typedef struct gimple_temp_hash_elt +{ + tree val; /* Key */ + tree temp; /* Value */ +} elt_t; + +/* Gimplify hashtable helper. */ + +struct gimplify_hasher : typed_free_remove +{ + typedef elt_t value_type; + typedef elt_t compare_type; + static inline hashval_t hash (const value_type *); + static inline bool equal (const value_type *, const compare_type *); +}; + +inline hashval_t +gimplify_hasher::hash (const value_type *p) +{ + tree t = p->val; + return iterative_hash_expr (t, 0); +} + +inline bool +gimplify_hasher::equal (const value_type *p1, const compare_type *p2) +{ + tree t1 = p1->val; + tree t2 = p2->val; + enum tree_code code = TREE_CODE (t1); + + if (TREE_CODE (t2) != code + || TREE_TYPE (t1) != TREE_TYPE (t2)) + return 0; + + if (!operand_equal_p (t1, t2, 0)) + return 0; + +#ifdef ENABLE_CHECKING + /* Only allow them to compare equal if they also hash equal; otherwise + results are nondeterminate, and we fail bootstrap comparison. */ + gcc_assert (gimple_tree_hash (p1) == gimple_tree_hash (p2)); +#endif + + return 1; +} + +struct gimplify_ctx +{ + struct gimplify_ctx *prev_context; + + vec bind_expr_stack; + tree temps; + gimple_seq conditional_cleanups; + tree exit_label; + tree return_temp; + + vec case_labels; + /* The formal temporary table. Should this be persistent? */ + hash_table temp_htab; + + int conditions; + bool save_stack; + bool into_ssa; + bool allow_rhs_cond_expr; + bool in_cleanup_point_expr; +}; + +extern void push_gimplify_context (struct gimplify_ctx *); +extern void pop_gimplify_context (gimple); + +#endif /* GCC_GIMPLIFY_CTX_H */ Index: gcc/gimple.h =================================================================== --- gcc/gimple.h (revision 193902) +++ gcc/gimple.h (working copy) @@ -936,27 +936,6 @@ enum gimplify_status { GS_ALL_DONE = 1 /* The expression is fully gimplified. */ }; -struct gimplify_ctx -{ - struct gimplify_ctx *prev_context; - - vec bind_expr_stack; - tree temps; - gimple_seq conditional_cleanups; - tree exit_label; - tree return_temp; - - vec case_labels; - /* The formal temporary table. Should this be persistent? */ - htab_t temp_htab; - - int conditions; - bool save_stack; - bool into_ssa; - bool allow_rhs_cond_expr; - bool in_cleanup_point_expr; -}; - /* Return true if gimplify_one_sizepos doesn't need to gimplify expr (when in TYPE_SIZE{,_UNIT} and similar type/decl size/bitsize fields). */ @@ -981,8 +960,6 @@ extern void gimplify_type_sizes (tree, g extern void gimplify_one_sizepos (tree *, gimple_seq *); extern bool gimplify_stmt (tree *, gimple_seq *); extern gimple gimplify_body (tree, bool); -extern void push_gimplify_context (struct gimplify_ctx *); -extern void pop_gimplify_context (gimple); extern void gimplify_and_add (tree, gimple_seq *); /* Miscellaneous helpers. */