From patchwork Thu Jul 21 18:31:03 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Pop X-Patchwork-Id: 106133 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 3F279B6F71 for ; Fri, 22 Jul 2011 04:32:12 +1000 (EST) Received: (qmail 20672 invoked by alias); 21 Jul 2011 18:31:51 -0000 Received: (qmail 20517 invoked by uid 22791); 21 Jul 2011 18:31:47 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, TW_TM, T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-gx0-f175.google.com (HELO mail-gx0-f175.google.com) (209.85.161.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 21 Jul 2011 18:31:27 +0000 Received: by gxk3 with SMTP id 3so885340gxk.20 for ; Thu, 21 Jul 2011 11:31:26 -0700 (PDT) Received: by 10.236.184.74 with SMTP id r50mr852225yhm.189.1311273086301; Thu, 21 Jul 2011 11:31:26 -0700 (PDT) Received: from napoca (adsl-99-184-92-236.dsl.austtx.sbcglobal.net [99.184.92.236]) by mx.google.com with ESMTPS id v4sm943457yhm.34.2011.07.21.11.31.23 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 21 Jul 2011 11:31:25 -0700 (PDT) Received: by napoca (sSMTP sendmail emulation); Thu, 21 Jul 2011 13:31:22 -0500 From: Sebastian Pop To: gcc-patches@gcc.gnu.org Cc: rguenther@suse.de, tobias@grosser.es, Sebastian Pop Subject: [PATCH 03/10] Record the loop level that defines a clast_name. Date: Thu, 21 Jul 2011 13:31:03 -0500 Message-Id: <1311273070-12128-4-git-send-email-sebpop@gmail.com> In-Reply-To: <1311273070-12128-1-git-send-email-sebpop@gmail.com> References: <1311273070-12128-1-git-send-email-sebpop@gmail.com> 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 2011-07-21 Sebastian Pop * graphite-clast-to-gimple.c (struct clast_name_index): Add level. (new_clast_name_index): Add level parameter. (clast_name_to_level): New. (save_clast_name_index): Add level parameter. (newivs_to_depth_to_newiv): Removed. (clast_name_to_gcc): Inlined newivs_to_depth_to_newiv. (graphite_create_new_loop): Add level parameter. Pass level to save_clast_name_index. (translate_clast_for_loop): Pass level to graphite_create_new_loop. (create_params_index): Pass level to save_clast_name_index. --- gcc/ChangeLog | 13 ++++++++ gcc/graphite-clast-to-gimple.c | 61 +++++++++++++++++++++++++++------------- 2 files changed, 54 insertions(+), 20 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 13a8bd8..d74938f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2011-07-21 Sebastian Pop + + * graphite-clast-to-gimple.c (struct clast_name_index): Add level. + (new_clast_name_index): Add level parameter. + (clast_name_to_level): New. + (save_clast_name_index): Add level parameter. + (newivs_to_depth_to_newiv): Removed. + (clast_name_to_gcc): Inlined newivs_to_depth_to_newiv. + (graphite_create_new_loop): Add level parameter. Pass level to + save_clast_name_index. + (translate_clast_for_loop): Pass level to graphite_create_new_loop. + (create_params_index): Pass level to save_clast_name_index. + 2011-07-05 Sebastian Pop * graphite-clast-to-gimple.c (graphite_create_new_loop): Do not diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c index a8ac9c6..c442f1e 100644 --- a/gcc/graphite-clast-to-gimple.c +++ b/gcc/graphite-clast-to-gimple.c @@ -56,26 +56,55 @@ graphite_verify (void) #endif } -/* Stores the INDEX in a vector for a given clast NAME. */ +/* Stores the INDEX in a vector and the loop nesting LEVEL for a given + clast NAME. */ typedef struct clast_name_index { int index; + int level; const char *name; } *clast_name_index_p; /* Returns a pointer to a new element of type clast_name_index_p built - from NAME and INDEX. */ + from NAME, LEVEL, and INDEX. */ static inline clast_name_index_p -new_clast_name_index (const char *name, int index) +new_clast_name_index (const char *name, int index, int level) { clast_name_index_p res = XNEW (struct clast_name_index); res->name = name; + res->level = level; res->index = index; return res; } +/* For a given clast NAME, returns -1 if NAME is not in the + INDEX_TABLE, otherwise returns the loop level for the induction + variable NAME, or if it is a parameter, the parameter number in the + vector of parameters. */ + +static inline int +clast_name_to_level (clast_name_p name, htab_t index_table) +{ + struct clast_name_index tmp; + PTR *slot; + +#ifdef CLOOG_ORG + gcc_assert (name->type == clast_expr_name); + tmp.name = ((const struct clast_name *) name)->name; +#else + tmp.name = name; +#endif + + slot = htab_find_slot (index_table, &tmp, NO_INSERT); + + if (slot && *slot) + return ((struct clast_name_index *) *slot)->level; + + return -1; +} + /* For a given clast NAME, returns -1 if it does not correspond to any parameter, or otherwise, returns the index in the PARAMS or SCATTERING_DIMENSIONS vector. */ @@ -101,10 +130,11 @@ clast_name_to_index (clast_name_p name, htab_t index_table) return -1; } -/* Records in INDEX_TABLE the INDEX for NAME. */ +/* Records in INDEX_TABLE the INDEX and LEVEL for NAME. */ static inline void -save_clast_name_index (htab_t index_table, const char *name, int index) +save_clast_name_index (htab_t index_table, const char *name, + int index, int level) { struct clast_name_index tmp; PTR *slot; @@ -116,7 +146,7 @@ save_clast_name_index (htab_t index_table, const char *name, int index) { free (*slot); - *slot = new_clast_name_index (name, index); + *slot = new_clast_name_index (name, index, level); } } @@ -139,15 +169,6 @@ eq_clast_name_indexes (const void *e1, const void *e2) return (elt1->name == elt2->name); } -/* For a given scattering dimension, return the new induction variable - associated to it. */ - -static inline tree -newivs_to_depth_to_newiv (VEC (tree, heap) *newivs, int depth) -{ - return VEC_index (tree, newivs, depth); -} - /* Returns the tree variable from the name NAME that was given in @@ -172,7 +193,7 @@ clast_name_to_gcc (clast_name_p name, sese region, VEC (tree, heap) *newivs, index = clast_name_to_index (name, newivs_index); gcc_assert (index >= 0); - return newivs_to_depth_to_newiv (newivs, index); + return VEC_index (tree, newivs, index); } /* Returns the signed maximal precision type for expressions TYPE1 and TYPE2. */ @@ -703,7 +724,7 @@ graphite_create_new_loop (edge entry_edge, struct clast_for *stmt, loop_p outer, VEC (tree, heap) **newivs, htab_t newivs_index, - tree type, tree lb, tree ub) + tree type, tree lb, tree ub, int level) { tree stride = gmp_cst_to_tree (type, stmt->stride); tree ivvar = create_tmp_var (type, "graphite_IV"); @@ -715,7 +736,7 @@ graphite_create_new_loop (edge entry_edge, add_referenced_var (ivvar); save_clast_name_index (newivs_index, stmt->iterator, - VEC_length (tree, *newivs)); + VEC_length (tree, *newivs), level); VEC_safe_push (tree, heap, *newivs, iv); return loop; } @@ -942,7 +963,7 @@ translate_clast_for_loop (sese region, loop_p context_loop, struct loop *loop = graphite_create_new_loop (next_e, stmt, context_loop, newivs, newivs_index, - type, lb, ub); + type, lb, ub, level); edge last_e = single_exit (loop); edge to_body = single_succ_edge (loop->header); basic_block after = to_body->dest; @@ -1423,7 +1444,7 @@ create_params_index (htab_t index_table, CloogProgram *prog) { int i; for (i = 0; i < nb_parameters; i++) - save_clast_name_index (index_table, parameters[i], i); + save_clast_name_index (index_table, parameters[i], i, i); } /* GIMPLE Loop Generator: generates loops from STMT in GIMPLE form for