From patchwork Thu Sep 30 18:01:04 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Pop X-Patchwork-Id: 66199 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 ED765B6EED for ; Fri, 1 Oct 2010 04:03:38 +1000 (EST) Received: (qmail 7735 invoked by alias); 30 Sep 2010 18:02:38 -0000 Received: (qmail 7543 invoked by uid 22791); 30 Sep 2010 18:02:34 -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_CP, TW_SV, T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-yw0-f47.google.com (HELO mail-yw0-f47.google.com) (209.85.213.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 30 Sep 2010 18:02:25 +0000 Received: by mail-yw0-f47.google.com with SMTP id 9so836327ywe.20 for ; Thu, 30 Sep 2010 11:02:25 -0700 (PDT) Received: by 10.100.57.1 with SMTP id f1mr4507118ana.205.1285869745314; Thu, 30 Sep 2010 11:02:25 -0700 (PDT) Received: from napoca ([163.181.251.115]) by mx.google.com with ESMTPS id c19sm155717ana.22.2010.09.30.11.02.23 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 30 Sep 2010 11:02:24 -0700 (PDT) Received: by napoca (sSMTP sendmail emulation); Thu, 30 Sep 2010 13:02:22 -0500 From: Sebastian Pop To: gcc-patches@gcc.gnu.org Cc: gcc-graphite@googlegroups.com Subject: [PATCH 12/44] Dump each scop in a separate file. Date: Thu, 30 Sep 2010 13:01:04 -0500 Message-Id: <1285869696-10915-13-git-send-email-sebpop@gmail.com> In-Reply-To: <1285869696-10915-1-git-send-email-sebpop@gmail.com> References: <1285869696-10915-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 From: spop 2010-08-17 Riyadh Baghdadi * graphite-poly.c (init_graphite_out_file): New. (init_graphite_in_file): New. (apply_poly_transforms): Updated to enable reading and writing of multiple scop files. * toplev.c (init_asm_output): Remove graphite in/out file initialization. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/graphite@163315 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 7 +++++ gcc/ChangeLog.graphite | 8 +++++ gcc/graphite-poly.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 81 insertions(+), 2 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 12a289c..b90eae7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2010-09-30 Riyadh Baghdadi + + * graphite-poly.c (init_graphite_out_file): New. + (init_graphite_in_file): New. + (apply_poly_transforms): Updated to enable reading and writing of + multiple scop files. + 2010-09-30 Tobias Grosser * graphite-scop-detection.c (graphite_can_represent_scev): Remove diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite index cb63848..e61bee6 100644 --- a/gcc/ChangeLog.graphite +++ b/gcc/ChangeLog.graphite @@ -1,3 +1,11 @@ +2010-08-17 Riyadh Baghdadi + + * graphite-poly.c (init_graphite_out_file): New. + (init_graphite_in_file): New. + (apply_poly_transforms): Updated to enable reading and writing of + multiple scop files. + * toplev.c (init_asm_output): Remove graphite in/out file initialization. + 2010-08-17 Tobias Grosser * graphite-scop-detection.c (graphite_can_represent_scev): Remove diff --git a/gcc/graphite-poly.c b/gcc/graphite-poly.c index eb4d61f..27215e1 100644 --- a/gcc/graphite-poly.c +++ b/gcc/graphite-poly.c @@ -683,18 +683,78 @@ graphite_read_scop_file (FILE *file, scop_p scop) return transform_done; } +/* Initialize and return a file that will be used to write a scop. SCOP_NUMBER + is a sequential number (identifier) used to differentiate scop files. + Examples of the generated file names: dump_base_name.0.graphite, + dump_base_name.1.graphite, dump_base_name.2.graphite, etc. */ + +static FILE * +init_graphite_out_file (int scop_number) +{ + FILE *graphite_out_file; + int len = strlen (dump_base_name); + char *dumpname = XNEWVEC (char, len + 25); + char *s_scop_number = XNEWVEC (char, 15); + + memcpy (dumpname, dump_base_name, len + 1); + strip_off_ending (dumpname, len); + sprintf (s_scop_number, ".%d", scop_number); + strcat (dumpname, s_scop_number); + strcat (dumpname, ".graphite"); + graphite_out_file = fopen (dumpname, "w+b"); + + if (graphite_out_file == 0) + fatal_error ("can%'t open %s for writing: %m", dumpname); + + free (dumpname); + + return graphite_out_file; +} + +/* Open and return a file used for scop reading. SCOP_NUMBER is a sequential + number (identifier) used to differentiate scop files. Examples of the + generated file names: dump_base_name.0.graphite, dump_base_name.1.graphite, + dump_base_name.2.graphite, etc. */ + +static FILE * +init_graphite_in_file (int scop_number) +{ + FILE *graphite_in_file; + int len = strlen (dump_base_name); + char *dumpname = XNEWVEC (char, len + 25); + char *s_scop_number = XNEWVEC (char, 15); + + memcpy (dumpname, dump_base_name, len + 1); + strip_off_ending (dumpname, len); + sprintf (s_scop_number, ".%d", scop_number); + strcat (dumpname, s_scop_number); + strcat (dumpname, ".graphite"); + graphite_in_file = fopen (dumpname, "r+b"); + + if (graphite_in_file == 0) + fatal_error ("can%'t open %s for reading: %m", dumpname); + + free (dumpname); + + return graphite_in_file; +} + /* Apply graphite transformations to all the basic blocks of SCOP. */ bool apply_poly_transforms (scop_p scop) { bool transform_done = false; + FILE *graphite_file; + static size_t file_scop_number = 0; /* This feature is only enabled in the Graphite branch. */ if (0) { - transform_done |= graphite_read_scop_file (dump_file, scop); + graphite_file = init_graphite_in_file (file_scop_number); + transform_done |= graphite_read_scop_file (graphite_file, scop); gcc_assert (graphite_legal_transform (scop)); + file_scop_number++; } /* Generate code even if we did not apply any real transformation. @@ -721,7 +781,11 @@ apply_poly_transforms (scop_p scop) /* This feature is only enabled in the Graphite branch. */ if (0) - print_scop (dump_file, scop, 1); + { + graphite_file = init_graphite_out_file (file_scop_number); + print_scop (graphite_file, scop, 1); + file_scop_number++; + } return transform_done; }