From patchwork Sat Dec 25 06:26:50 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Pop X-Patchwork-Id: 76663 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 361A7B70DF for ; Sat, 25 Dec 2010 17:27:57 +1100 (EST) Received: (qmail 30979 invoked by alias); 25 Dec 2010 06:27:51 -0000 Received: (qmail 30736 invoked by uid 22791); 25 Dec 2010 06:27:49 -0000 X-SWARE-Spam-Status: No, hits=0.8 required=5.0 tests=AWL, BAYES_40, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, FSL_RU_URL, RCVD_IN_DNSWL_LOW, TW_TM, T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-yx0-f175.google.com (HELO mail-yx0-f175.google.com) (209.85.213.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 25 Dec 2010 06:27:41 +0000 Received: by yxd5 with SMTP id 5so3456534yxd.20 for ; Fri, 24 Dec 2010 22:27:39 -0800 (PST) Received: by 10.151.110.2 with SMTP id n2mr13101442ybm.81.1293258459529; Fri, 24 Dec 2010 22:27:39 -0800 (PST) Received: from napoca ([75.54.87.199]) by mx.google.com with ESMTPS id q8sm5471885yhg.1.2010.12.24.22.27.37 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 24 Dec 2010 22:27:38 -0800 (PST) Received: by napoca (sSMTP sendmail emulation); Sat, 25 Dec 2010 00:27:35 -0600 From: Sebastian Pop To: gcc-patches@gcc.gnu.org Cc: gcc-graphite@googlegroups.com, amonakov@ispras.ru, kayrick@ispras.ru, abel@ispras.ru, basile@starynkevitch.net, grosser@fim.uni-passau.de, Sebastian Pop Subject: [PATCH 1/4] Make some of the graphite functions from graphite-clast-to-gimple.c exposed for the new files. Date: Sat, 25 Dec 2010 00:26:50 -0600 Message-Id: <1293258413-29902-2-git-send-email-sebpop@gmail.com> In-Reply-To: References: 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 2010-12-25 Alexey Kravets * graphite-clast-to-gimple.c (struct clast_name_index): Move definition to graphite-clast-to-gimple.h. (clast_name_to_index): Ditto. (clast_name_index_elt_info): Ditto. (eq_clast_name_indexes): Ditto. (save_clast_name_index): Export. (clast_name_to_gcc): Ditto. (clast_to_gcc_expression): Ditto. (gcc_type_for_clast_expr): Ditto. (graphite_create_new_guard): Ditto. (gcc_type_for_iv_of_clast_loop): Ditto. (graphite_create_new_loop): Ditto. (build_iv_mapping): Ditto. (graphite_create_new_loop_guard): Ditto. (debug_clast_name_index): New. (debug_clast_name_indices): New debug function. --- gcc/ChangeLog.graphite | 19 ++++++++ gcc/graphite-clast-to-gimple.c | 99 ++++++++++++--------------------------- gcc/graphite-clast-to-gimple.h | 65 ++++++++++++++++++++++++++ gcc/graphite-cloog-compat.h | 18 +++++++ 4 files changed, 133 insertions(+), 68 deletions(-) diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite index cf73e30..9d03354 100644 --- a/gcc/ChangeLog.graphite +++ b/gcc/ChangeLog.graphite @@ -1,3 +1,22 @@ +2010-12-25 Alexey Kravets + + * graphite-clast-to-gimple.c (struct clast_name_index): Move + definition to graphite-clast-to-gimple.h. + (clast_name_to_index): Ditto. + (clast_name_index_elt_info): Ditto. + (eq_clast_name_indexes): Ditto. + (save_clast_name_index): Export. + (clast_name_to_gcc): Ditto. + (clast_to_gcc_expression): Ditto. + (gcc_type_for_clast_expr): Ditto. + (graphite_create_new_guard): Ditto. + (gcc_type_for_iv_of_clast_loop): Ditto. + (graphite_create_new_loop): Ditto. + (build_iv_mapping): Ditto. + (graphite_create_new_loop_guard): Ditto. + (debug_clast_name_index): New. + (debug_clast_name_indices): New debug function. + 2010-12-21 Sebastian Pop PR tree-optimization/47021 diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c index c33bb61..9c732aa 100644 --- a/gcc/graphite-clast-to-gimple.c +++ b/gcc/graphite-clast-to-gimple.c @@ -70,13 +70,6 @@ graphite_verify (void) #endif } -/* Stores the INDEX in a vector for a given clast NAME. */ - -typedef struct clast_name_index { - int index; - 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. */ @@ -90,34 +83,9 @@ new_clast_name_index (const char *name, int index) return res; } -/* 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. */ - -static inline int -clast_name_to_index (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)->index; - - return -1; -} - /* Records in INDEX_TABLE the INDEX for NAME. */ -static inline void +void save_clast_name_index (htab_t index_table, const char *name, int index) { struct clast_name_index tmp; @@ -135,25 +103,6 @@ save_clast_name_index (htab_t index_table, const char *name, int index) } } -/* Computes a hash function for database element ELT. */ - -static inline hashval_t -clast_name_index_elt_info (const void *elt) -{ - return htab_hash_pointer (((const struct clast_name_index *) elt)->name); -} - -/* Compares database elements E1 and E2. */ - -static inline int -eq_clast_name_indexes (const void *e1, const void *e2) -{ - const struct clast_name_index *elt1 = (const struct clast_name_index *) e1; - const struct clast_name_index *elt2 = (const struct clast_name_index *) e2; - - return (elt1->name == elt2->name); -} - /* For a given scattering dimension, return the new induction variable associated to it. */ @@ -168,7 +117,7 @@ newivs_to_depth_to_newiv (VEC (tree, heap) *newivs, int depth) /* Returns the tree variable from the name NAME that was given in Cloog representation. */ -static tree +tree clast_name_to_gcc (clast_name_p name, sese region, VEC (tree, heap) *newivs, htab_t newivs_index, htab_t params_index) { @@ -243,10 +192,6 @@ max_precision_type (tree type1, tree type2) return TYPE_PRECISION (type1) > TYPE_PRECISION (type2) ? type1 : type2; } -static tree -clast_to_gcc_expression (tree, struct clast_expr *, sese, VEC (tree, heap) *, - htab_t, htab_t); - /* Converts a Cloog reduction expression R with reduction operation OP to a GCC expression tree of type TYPE. */ @@ -274,7 +219,7 @@ clast_to_gcc_expression_red (tree type, enum tree_code op, /* Converts a Cloog AST expression E back to a GCC expression tree of type TYPE. */ -static tree +tree clast_to_gcc_expression (tree type, struct clast_expr *e, sese region, VEC (tree, heap) *newivs, htab_t newivs_index, htab_t params_index) @@ -514,10 +459,6 @@ gcc_type_for_clast_term (struct clast_term *t, newivs_index, params_index)); } -static tree -gcc_type_for_clast_expr (struct clast_expr *, sese, - VEC (tree, heap) *, htab_t, htab_t); - /* Return the type for the clast_reduction R used in STMT. */ static tree @@ -570,7 +511,7 @@ gcc_type_for_clast_bin (struct clast_binary *b, /* Returns the type for the CLAST expression E when used in statement STMT. */ -static tree +tree gcc_type_for_clast_expr (struct clast_expr *e, sese region, VEC (tree, heap) *newivs, htab_t newivs_index, htab_t params_index) @@ -665,7 +606,7 @@ graphite_create_guard_cond_expr (sese region, struct clast_guard *stmt, /* Creates a new if region corresponding to Cloog's guard. */ -static edge +edge graphite_create_new_guard (sese region, edge entry_edge, struct clast_guard *stmt, VEC (tree, heap) *newivs, @@ -751,7 +692,7 @@ clast_get_body_of_loop (struct clast_stmt *stmt) /* Returns the type for the induction variable for the loop translated from STMT_FOR. */ -static tree +tree gcc_type_for_iv_of_clast_loop (struct clast_for *stmt_for, int level, tree lb_type, tree ub_type) { @@ -773,7 +714,7 @@ gcc_type_for_iv_of_clast_loop (struct clast_for *stmt_for, int level, loop of STMT. The new induction variable is inserted in the NEWIVS vector. */ -static struct loop * +struct loop * graphite_create_new_loop (sese region, edge entry_edge, struct clast_for *stmt, loop_p outer, VEC (tree, heap) **newivs, @@ -806,7 +747,7 @@ graphite_create_new_loop (sese region, edge entry_edge, /* Inserts in iv_map a tuple (OLD_LOOP->num, NEW_NAME) for the induction variables of the loops around GBB in SESE. */ -static void +void build_iv_mapping (VEC (tree, heap) *iv_map, sese region, VEC (tree, heap) *newivs, htab_t newivs_index, struct clast_user_stmt *user_stmt, @@ -958,7 +899,7 @@ translate_clast_user (sese region, struct clast_user_stmt *stmt, edge next_e, /* Creates a new if region protecting the loop to be executed, if the execution count is zero (lb > ub). */ -static edge +edge graphite_create_new_loop_guard (sese region, edge entry_edge, struct clast_for *stmt, VEC (tree, heap) *newivs, @@ -1441,6 +1382,28 @@ debug_clast_stmt (struct clast_stmt *stmt) print_clast_stmt (stderr, stmt); } +/* Helper function for debug_clast_name_indices. */ + +static int +debug_clast_name_index (void **slot, void *s ATTRIBUTE_UNUSED) +{ + struct clast_name_index *entry = (struct clast_name_index *) *slot; + fprintf (stderr, "(index = %d, name = %s)\n", entry->index, entry->name); + return 1; +} + +extern void debug_clast_name_indices (htab_t); + +/* Print to stderr all the elements of MAP. */ + +DEBUG_FUNCTION void +debug_clast_name_indices (htab_t map) +{ + htab_traverse (map, debug_clast_name_index, NULL); +} + + + /* Translate SCOP to a CLooG program and clast. These two representations should be freed together: a clast cannot be used without a program. */ diff --git a/gcc/graphite-clast-to-gimple.h b/gcc/graphite-clast-to-gimple.h index cd3cbca..20c486c 100644 --- a/gcc/graphite-clast-to-gimple.h +++ b/gcc/graphite-clast-to-gimple.h @@ -37,10 +37,29 @@ typedef struct bb_pbb_def poly_bb_p pbb; }bb_pbb_def; +/* From graphite-clast-to-gimple.c */ extern bool gloog (scop_p, htab_t); extern cloog_prog_clast scop_to_clast (scop_p, CloogState *); extern void debug_clast_stmt (struct clast_stmt *); extern void print_clast_stmt (FILE *, struct clast_stmt *); +extern void build_iv_mapping (VEC (tree, heap) *, sese, VEC (tree, heap) *, + htab_t, struct clast_user_stmt *, htab_t); +extern struct loop *graphite_create_new_loop (sese, edge, struct clast_for *, + loop_p, VEC (tree, heap) **, + htab_t, htab_t, int); +extern edge graphite_create_new_loop_guard (sese, edge, struct clast_for *, + VEC (tree, heap) *, htab_t, htab_t); +extern edge graphite_create_new_guard (sese, edge, struct clast_guard *, + VEC (tree, heap) *, htab_t, htab_t); +extern tree clast_to_gcc_expression (tree, struct clast_expr *, sese, + VEC (tree, heap) *, htab_t, htab_t); +extern tree gcc_type_for_iv_of_clast_loop (struct clast_for *, int, tree, tree); + +extern tree gcc_type_for_clast_expr (struct clast_expr *, sese, + VEC (tree, heap) *, htab_t, htab_t); +extern tree clast_name_to_gcc (clast_name_p, sese, VEC (tree, heap) *, + htab_t, htab_t); +extern void save_clast_name_index (htab_t, const char *, int); /* Hash function for data base element BB_PBB. */ @@ -72,4 +91,50 @@ static inline int get_scattering_level (int depth) return 2 * depth - 1; } +/* Stores the INDEX in a vector for a given clast NAME. */ + +typedef struct clast_name_index +{ + int index; + const char *name; +} *clast_name_index_p; + +/* Computes a hash function for database element ELT. */ + +static inline hashval_t +clast_name_index_elt_info (const void *elt) +{ + return htab_hash_pointer (((const struct clast_name_index *) elt)->name); +} + +/* Compares database elements E1 and E2. */ + +static inline int +eq_clast_name_indexes (const void *e1, const void *e2) +{ + const struct clast_name_index *elt1 = (const struct clast_name_index *) e1; + const struct clast_name_index *elt2 = (const struct clast_name_index *) e2; + + return (elt1->name == elt2->name); +} + +/* 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. */ + +static inline int +clast_name_to_index (clast_name_p name, htab_t index_table) +{ + struct clast_name_index tmp; + PTR *slot; + + tmp.name = clast_name_to_str (name); + slot = htab_find_slot (index_table, &tmp, NO_INSERT); + + if (slot && *slot) + return ((struct clast_name_index *) *slot)->index; + + return -1; +} + #endif diff --git a/gcc/graphite-cloog-compat.h b/gcc/graphite-cloog-compat.h index f118824..aab7214 100644 --- a/gcc/graphite-cloog-compat.h +++ b/gcc/graphite-cloog-compat.h @@ -77,6 +77,14 @@ typedef int matrix_num_type; #define cloog_program_dump_cloog(DUMPFILE, PROGRAM, SCATTERINGLIST)\ cloog_program_dump_cloog (DUMPFILE, PROGRAM) +/* Returns a string of characters for NAME. */ + +static inline const char * +clast_name_to_str (clast_name_p name) +{ + return (const char *) name; +} + #endif /* Adapt CLooG accessors from CLooG legacy to @@ -273,5 +281,15 @@ static inline int cloog_matrix_nrows (CloogMatrix * m) { return m->NbRows; } + +/* Returns a string of characters for NAME. */ + +static inline const char * +clast_name_to_str (clast_name_p name) +{ + gcc_assert (name->type == clast_expr_name); + return ((const struct clast_name*) name)->name; +} + #endif /* CLOOG_ORG */ #endif /* GRAPHITE_CLOOG_COMPAT_H */