From patchwork Tue Jul 27 22:22:55 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Pop X-Patchwork-Id: 60056 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 2916FB70AB for ; Wed, 28 Jul 2010 08:24:03 +1000 (EST) Received: (qmail 7996 invoked by alias); 27 Jul 2010 22:23:51 -0000 Received: (qmail 7532 invoked by uid 22791); 27 Jul 2010 22:23:48 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, TW_TM, T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-vw0-f47.google.com (HELO mail-vw0-f47.google.com) (209.85.212.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 27 Jul 2010 22:23:35 +0000 Received: by mail-vw0-f47.google.com with SMTP id 13so4158622vws.20 for ; Tue, 27 Jul 2010 15:23:34 -0700 (PDT) Received: by 10.220.129.15 with SMTP id m15mr5463501vcs.198.1280269414410; Tue, 27 Jul 2010 15:23:34 -0700 (PDT) Received: from napoca ([163.181.251.115]) by mx.google.com with ESMTPS id e20sm1661677vcm.16.2010.07.27.15.23.32 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 27 Jul 2010 15:23:33 -0700 (PDT) Received: by napoca (sSMTP sendmail emulation); Tue, 27 Jul 2010 17:23:30 -0500 From: Sebastian Pop To: gcc-patches@gcc.gnu.org Cc: gcc-graphite@googlegroups.com, simbuerg@fim.uni-passau.de, Sebastian Pop Subject: [PATCH 4/7] Introduce compatibility to newer CLooG's CloogState and mask the use with macros where possible. Date: Tue, 27 Jul 2010 17:22:55 -0500 Message-Id: <1280269378-27054-5-git-send-email-sebpop@gmail.com> In-Reply-To: <1280269378-27054-1-git-send-email-sebpop@gmail.com> References: <1280269378-27054-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 2010-07-27 Andreas Simbuerger * graphite-clast-to-gimple.c (build_cloog_prog): Extend with CloogState. (set_cloog_options): Same. (print_clast_stmt): Same. (scop_to_clast): Same. (print_generated_program): Same. (gloog): Same. * graphite-clast-to-gimple.h: Include graphite-cloog-util.h. (scop_to_clast): Extend with CloogState. * graphite-cloog-util.c: Include graphite-cloog-compat.h (new_Cloog_Domain_from_ppl_Polyhedron): Extend with CloogState. Use cloog_domain_from_cloog_matrix (CLOOG_ORG). (new_Cloog_Domain_from_ppl_Pointset_Powerset): Extend with CloogState. (new_Cloog_Domain_from_ppl_Polyhedron): Same. * graphite-cloog-util.h (build_cloog_prog): Same. * graphite-cloog-copat.h (build_cloog_prog): New. (CloogState): New. (cloog_state_malloc): New. (cloog_state_free): New. (cloog_loop_malloc): New. (cloog_options_malloc): New. (cloog_statement_alloc): New. (cloog_domain_from_cloog_matrix): New. (new_Cloog_Domain_from_ppl_Pointset_Powerset): New. (new_Cloog_Domain_from_ppl_Polyhedron): New. --- gcc/ChangeLog.graphite | 28 +++++++++++++++++++++++ gcc/graphite-clast-to-gimple.c | 48 +++++++++++++++++++++++++--------------- gcc/graphite-clast-to-gimple.h | 3 +- gcc/graphite-cloog-compat.h | 16 ++++++++++++- gcc/graphite-cloog-util.c | 13 ++++++---- gcc/graphite-cloog-util.h | 7 +++-- 6 files changed, 87 insertions(+), 28 deletions(-) diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite index 55b0d9d..86cae90 100644 --- a/gcc/ChangeLog.graphite +++ b/gcc/ChangeLog.graphite @@ -1,5 +1,33 @@ 2010-07-27 Andreas Simbuerger + * graphite-clast-to-gimple.c (build_cloog_prog): Extend with + CloogState. + (set_cloog_options): Same. + (print_clast_stmt): Same. + (scop_to_clast): Same. + (print_generated_program): Same. + (gloog): Same. + * graphite-clast-to-gimple.h: Include graphite-cloog-util.h. + (scop_to_clast): Extend with CloogState. + * graphite-cloog-util.c: Include graphite-cloog-compat.h + (new_Cloog_Domain_from_ppl_Polyhedron): + Extend with CloogState. Use cloog_domain_from_cloog_matrix (CLOOG_ORG). + (new_Cloog_Domain_from_ppl_Pointset_Powerset): Extend with CloogState. + (new_Cloog_Domain_from_ppl_Polyhedron): Same. + * graphite-cloog-util.h (build_cloog_prog): Same. + * graphite-cloog-copat.h (build_cloog_prog): New. + (CloogState): New. + (cloog_state_malloc): New. + (cloog_state_free): New. + (cloog_loop_malloc): New. + (cloog_options_malloc): New. + (cloog_statement_alloc): New. + (cloog_domain_from_cloog_matrix): New. + (new_Cloog_Domain_from_ppl_Pointset_Powerset): New. + (new_Cloog_Domain_from_ppl_Polyhedron): New. + +2010-07-27 Andreas Simbuerger + * graphite-clast-to-gimple.c (clast_name_to_gcc): Parameter type of NAME now depends on used CLooG version. (clast_to_gcc_expression): Replace expr_* with clast_expr_*. diff --git a/gcc/graphite-clast-to-gimple.c b/gcc/graphite-clast-to-gimple.c index 6d51b98..8937002 100644 --- a/gcc/graphite-clast-to-gimple.c +++ b/gcc/graphite-clast-to-gimple.c @@ -1206,7 +1206,8 @@ initialize_cloog_names (scop_p scop, CloogProgram *prog) /* Build cloog program for SCoP. */ static void -build_cloog_prog (scop_p scop, CloogProgram *prog, CloogOptions *options) +build_cloog_prog (scop_p scop, CloogProgram *prog, + CloogOptions *options, CloogState *state ATTRIBUTE_UNUSED) { int i; int max_nb_loops = scop_max_loop_depth (scop); @@ -1218,7 +1219,8 @@ build_cloog_prog (scop_p scop, CloogProgram *prog, CloogOptions *options) int *scaldims; cloog_program_set_context - (prog, new_Cloog_Domain_from_ppl_Pointset_Powerset (SCOP_CONTEXT (scop))); + (prog, new_Cloog_Domain_from_ppl_Pointset_Powerset (SCOP_CONTEXT (scop), + scop_nb_params (scop), state)); nbs = unify_scattering_dimensions (scop); scaldims = (int *) xmalloc (nbs * (sizeof (int))); cloog_program_set_nb_scattdims (prog, nbs); @@ -1228,6 +1230,7 @@ build_cloog_prog (scop_p scop, CloogProgram *prog, CloogOptions *options) { CloogStatement *stmt; CloogBlock *block; + CloogDomain *dom; /* Dead code elimination: when the domain of a PBB is empty, don't generate code for the PBB. */ @@ -1235,17 +1238,18 @@ build_cloog_prog (scop_p scop, CloogProgram *prog, CloogOptions *options) continue; /* Build the new statement and its block. */ - stmt = cloog_statement_alloc (pbb_index (pbb)); + stmt = cloog_statement_alloc (state, pbb_index (pbb)); + dom = new_Cloog_Domain_from_ppl_Pointset_Powerset (PBB_DOMAIN (pbb), + scop_nb_params (scop), + state); block = cloog_block_alloc (stmt, 0, NULL, pbb_dim_iter_domain (pbb)); cloog_statement_set_usr (stmt, pbb); /* Build loop list. */ { - CloogLoop *new_loop_list = cloog_loop_malloc (); + CloogLoop *new_loop_list = cloog_loop_malloc (state); cloog_loop_set_next (new_loop_list, loop_list); - cloog_loop_set_domain - (new_loop_list, - new_Cloog_Domain_from_ppl_Pointset_Powerset (PBB_DOMAIN (pbb))); + cloog_loop_set_domain (new_loop_list, dom); cloog_loop_set_block (new_loop_list, block); loop_list = new_loop_list; } @@ -1268,7 +1272,8 @@ build_cloog_prog (scop_p scop, CloogProgram *prog, CloogOptions *options) CloogDomain *dom; scat = PBB_TRANSFORMED_SCATTERING (pbb); - dom = new_Cloog_Domain_from_ppl_Polyhedron (scat); + dom = new_Cloog_Domain_from_ppl_Polyhedron (scat, scop_nb_params (scop), + state); cloog_set_next_domain (new_scattering, scattering); cloog_set_domain (new_scattering, dom); @@ -1314,9 +1319,9 @@ build_cloog_prog (scop_p scop, CloogProgram *prog, CloogOptions *options) /* Return the options that will be used in GLOOG. */ static CloogOptions * -set_cloog_options (void) +set_cloog_options (CloogState *state ATTRIBUTE_UNUSED) { - CloogOptions *options = cloog_options_malloc (); + CloogOptions *options = cloog_options_malloc (state); /* Change cloog output language to C. If we do use FORTRAN instead, cloog will stop e.g. with "ERROR: unbounded loops not allowed in FORTRAN.", if @@ -1365,10 +1370,12 @@ set_cloog_options (void) void print_clast_stmt (FILE *file, struct clast_stmt *stmt) { - CloogOptions *options = set_cloog_options (); + CloogState *state = cloog_state_malloc (); + CloogOptions *options = set_cloog_options (state); clast_pprint (file, stmt, 0, options); cloog_options_free (options); + cloog_state_free (state); } /* Prints STMT to STDERR. */ @@ -1384,14 +1391,14 @@ debug_clast_stmt (struct clast_stmt *stmt) without a program. */ cloog_prog_clast -scop_to_clast (scop_p scop) +scop_to_clast (scop_p scop, CloogState *state) { - CloogOptions *options = set_cloog_options (); + CloogOptions *options = set_cloog_options (state); cloog_prog_clast pc; /* Connect new cloog prog generation to graphite. */ pc.prog = cloog_program_malloc (); - build_cloog_prog (scop, pc.prog, options); + build_cloog_prog (scop, pc.prog, options, state); pc.prog = cloog_program_generate (pc.prog, options); pc.stmt = cloog_clast_create (pc.prog, options); @@ -1404,8 +1411,10 @@ scop_to_clast (scop_p scop) void print_generated_program (FILE *file, scop_p scop) { - CloogOptions *options = set_cloog_options (); - cloog_prog_clast pc = scop_to_clast (scop); + CloogState *state = cloog_state_malloc (); + CloogOptions *options = set_cloog_options (state); + + cloog_prog_clast pc = scop_to_clast (scop, state); fprintf (file, " (prog: \n"); cloog_program_print (file, pc.prog); @@ -1456,11 +1465,13 @@ gloog (scop_p scop, htab_t bb_pbb_mapping) ifsese if_region = NULL; htab_t newivs_index, params_index; cloog_prog_clast pc; + CloogState *state; + state = cloog_state_malloc (); timevar_push (TV_GRAPHITE_CODE_GEN); gloog_error = false; - pc = scop_to_clast (scop); + pc = scop_to_clast (scop, state); if (dump_file && (dump_flags & TDF_DETAILS)) { @@ -1525,7 +1536,8 @@ gloog (scop_p scop, htab_t bb_pbb_mapping) num_no_dependency); } + cloog_state_free (state); + return !gloog_error; } - #endif diff --git a/gcc/graphite-clast-to-gimple.h b/gcc/graphite-clast-to-gimple.h index fbb4efa..cd3cbca 100644 --- a/gcc/graphite-clast-to-gimple.h +++ b/gcc/graphite-clast-to-gimple.h @@ -21,6 +21,7 @@ along with GCC; see the file COPYING3. If not see #ifndef GCC_GRAPHITE_CLAST_TO_GIMPLE_H #define GCC_GRAPHITE_CLAST_TO_GIMPLE_H +#include "graphite-cloog-util.h" /* Data structure for CLooG program representation. */ typedef struct cloog_prog_clast { @@ -37,7 +38,7 @@ typedef struct bb_pbb_def }bb_pbb_def; extern bool gloog (scop_p, htab_t); -extern cloog_prog_clast scop_to_clast (scop_p); +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 *); diff --git a/gcc/graphite-cloog-compat.h b/gcc/graphite-cloog-compat.h index 8ff0e43..f27ee5a 100644 --- a/gcc/graphite-cloog-compat.h +++ b/gcc/graphite-cloog-compat.h @@ -32,7 +32,8 @@ typedef const char *clast_name_p; #ifndef CLOOG_ORG /* CloogOptions compatibility. */ -#define build_cloog_prog(SCOP, PROG, OPT) build_cloog_prog (SCOP, PROG) +#define build_cloog_prog(SCOP, PROG, OPT, STATE)\ + build_cloog_prog (SCOP, PROG, STATE) #define cloog_program_extract_scalars(PROG, SCATT, OPT)\ cloog_program_extract_scalars (PROG, SCATT) #define cloog_program_scatter(PROG, SCATT, OPT)\ @@ -44,6 +45,19 @@ typedef const char *clast_name_p; #define clast_expr_bin expr_bin #define clast_pprint pprint +/* CloogState compatibility. */ +#define CloogState void +#define cloog_state_malloc() NULL +#define cloog_state_free(STATE) +#define cloog_loop_malloc(STATE) cloog_loop_malloc () +#define cloog_options_malloc(STATE) cloog_options_malloc () +#define cloog_statement_alloc(STATE, INDEX) cloog_statement_alloc (INDEX) +#define new_Cloog_Domain_from_ppl_Pointset_Powerset(PSPS, NB, STATE)\ + new_Cloog_Domain_from_ppl_Pointset_Powerset (PSPS) +#define new_Cloog_Domain_from_ppl_Polyhedron(POLY, NB, STATE)\ + new_Cloog_Domain_from_ppl_Polyhedron (POLY) +#define cloog_domain_from_cloog_matrix(STATE, MAT, NB)\ + cloog_domain_matrix2domain (MAT) #endif /* Adapt CLooG accessors from CLooG legacy to diff --git a/gcc/graphite-cloog-util.c b/gcc/graphite-cloog-util.c index 33ee5cf..500443f 100644 --- a/gcc/graphite-cloog-util.c +++ b/gcc/graphite-cloog-util.c @@ -30,6 +30,7 @@ along with GCC; see the file COPYING3. If not see #include "ppl_c.h" #include "cloog/cloog.h" #include "graphite-cloog-util.h" +#include "graphite-cloog-compat.h" /* Counts the number of constraints in PCS. */ @@ -228,10 +229,11 @@ new_C_Polyhedron_from_Cloog_Matrix (ppl_Polyhedron_t *ph, /* Creates a CloogDomain from polyhedron PH. */ CloogDomain * -new_Cloog_Domain_from_ppl_Polyhedron (ppl_const_Polyhedron_t ph) +new_Cloog_Domain_from_ppl_Polyhedron (ppl_const_Polyhedron_t ph, int nb_params, + CloogState *state ATTRIBUTE_UNUSED) { CloogMatrix *mat = new_Cloog_Matrix_from_ppl_Polyhedron (ph); - CloogDomain *res = cloog_domain_matrix2domain (mat); + CloogDomain *res = cloog_domain_from_cloog_matrix (state, mat, nb_params); cloog_matrix_free (mat); return res; } @@ -239,8 +241,9 @@ new_Cloog_Domain_from_ppl_Polyhedron (ppl_const_Polyhedron_t ph) /* Creates a CloogDomain from a pointset powerset PS. */ CloogDomain * -new_Cloog_Domain_from_ppl_Pointset_Powerset ( - ppl_Pointset_Powerset_C_Polyhedron_t ps) +new_Cloog_Domain_from_ppl_Pointset_Powerset + (ppl_Pointset_Powerset_C_Polyhedron_t ps, int nb_params, + CloogState *state ATTRIBUTE_UNUSED) { CloogDomain *res = NULL; ppl_Pointset_Powerset_C_Polyhedron_iterator_t it, end; @@ -257,7 +260,7 @@ new_Cloog_Domain_from_ppl_Pointset_Powerset ( CloogDomain *tmp; ppl_Pointset_Powerset_C_Polyhedron_iterator_dereference (it, &ph); - tmp = new_Cloog_Domain_from_ppl_Polyhedron (ph); + tmp = new_Cloog_Domain_from_ppl_Polyhedron (ph, nb_params, state); if (res == NULL) res = tmp; diff --git a/gcc/graphite-cloog-util.h b/gcc/graphite-cloog-util.h index da7b2e6..eaa48f3 100644 --- a/gcc/graphite-cloog-util.h +++ b/gcc/graphite-cloog-util.h @@ -25,9 +25,10 @@ along with GCC; see the file COPYING3. If not see #include "graphite-cloog-compat.h" CloogMatrix *new_Cloog_Matrix_from_ppl_Polyhedron (ppl_const_Polyhedron_t); -CloogDomain *new_Cloog_Domain_from_ppl_Polyhedron (ppl_const_Polyhedron_t); -CloogDomain * new_Cloog_Domain_from_ppl_Pointset_Powerset ( - ppl_Pointset_Powerset_C_Polyhedron_t); +CloogDomain *new_Cloog_Domain_from_ppl_Polyhedron (ppl_const_Polyhedron_t, + int, CloogState *); +CloogDomain * new_Cloog_Domain_from_ppl_Pointset_Powerset + (ppl_Pointset_Powerset_C_Polyhedron_t, int, CloogState *); void new_C_Polyhedron_from_Cloog_Matrix (ppl_Polyhedron_t *, CloogMatrix *); #endif /* GRAPHITE_CLOOG_UTIL_H */