From patchwork Tue Jul 20 20:23:40 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Pop X-Patchwork-Id: 59366 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 318561007D1 for ; Wed, 21 Jul 2010 06:25:15 +1000 (EST) Received: (qmail 11098 invoked by alias); 20 Jul 2010 20:24:16 -0000 Received: (qmail 10882 invoked by uid 22791); 20 Jul 2010 20:24:09 -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, T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-gw0-f47.google.com (HELO mail-gw0-f47.google.com) (74.125.83.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 20 Jul 2010 20:24:03 +0000 Received: by gwj22 with SMTP id 22so3464196gwj.20 for ; Tue, 20 Jul 2010 13:24:01 -0700 (PDT) Received: by 10.151.50.14 with SMTP id c14mr885033ybk.11.1279657440921; Tue, 20 Jul 2010 13:24:00 -0700 (PDT) Received: from napoca ([163.181.251.115]) by mx.google.com with ESMTPS id 36sm5319370ybr.8.2010.07.20.13.23.58 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 20 Jul 2010 13:24:00 -0700 (PDT) Received: by napoca (sSMTP sendmail emulation); Tue, 20 Jul 2010 15:23:57 -0500 From: Sebastian Pop To: gcc-patches@gcc.gnu.org Cc: gcc-graphite@googlegroups.com, Sebastian Pop Subject: [PATCH 3/5] Dot refined regions. Date: Tue, 20 Jul 2010 15:23:40 -0500 Message-Id: <1279657422-17300-3-git-send-email-sebpop@gmail.com> In-Reply-To: <1279657422-17300-1-git-send-email-sebpop@gmail.com> References: <1279657422-17300-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-20 Vladimir Kargov * refined-regions.c: Include tree-pass.h, cfgloop.h, gimple.h, and tree-data-ref.h. (dot_regions_1): New. (dot_regions): New. * refined-regions.h (dot_regions): Declared. * Makefile.in (refined-regions.o): Update dependences. --- gcc/ChangeLog.graphite | 9 +++ gcc/Makefile.in | 3 +- gcc/refined-regions.c | 161 +++++++++++++++++++++++++++++++++++++++++++++++- gcc/refined-regions.h | 1 + 4 files changed, 171 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite index f6e077a..58ab265 100644 --- a/gcc/ChangeLog.graphite +++ b/gcc/ChangeLog.graphite @@ -1,3 +1,12 @@ +2010-07-20 Vladimir Kargov + + * refined-regions.c: Include tree-pass.h, cfgloop.h, gimple.h, and + tree-data-ref.h. + (dot_regions_1): New. + (dot_regions): New. + * refined-regions.h (dot_regions): Declared. + * Makefile.in (refined-regions.o): Update dependences. + 2010-07-20 Sebastian Pop * graphite-sese-to-poly.c (rewrite_close_phi_out_of_ssa): Add an diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 69c5b45..4a14d94 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -2657,7 +2657,8 @@ graphite-poly.o: graphite-poly.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ graphite-ppl.o: graphite-ppl.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ $(GGC_H) graphite-ppl.h graphite-cloog-util.h refined-regions.o: refined-regions.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ - $(TM_H) $(GGC_H) domwalk.h refined-regions.h + $(TM_H) $(BASIC_BLOCK_H) $(TIMEVAR_H) $(BITMAP_H) domwalk.h $(TREE_PASS_H) \ + refined-regions.h graphite-scop-detection.o: graphite-scop-detection.c $(CONFIG_H) $(SYSTEM_H) \ $(GGC_H) $(TREE_H) $(RTL_H) $(BASIC_BLOCK_H) $(DIAGNOSTIC_H) $(TOPLEV_H) \ $(TREE_FLOW_H) $(TREE_DUMP_H) $(TIMEVAR_H) $(CFGLOOP_H) $(GIMPLE_H) \ diff --git a/gcc/refined-regions.c b/gcc/refined-regions.c index b10daea..ef37533 100644 --- a/gcc/refined-regions.c +++ b/gcc/refined-regions.c @@ -26,9 +26,9 @@ along with GCC; see the file COPYING3. If not see #include "basic-block.h" #include "timevar.h" #include "bitmap.h" - -#include "refined-regions.h" #include "domwalk.h" +#include "tree-pass.h" +#include "refined-regions.h" /* Auxiliary function for qsort () that compares two basic blocks according to the values of their indices. */ @@ -620,3 +620,160 @@ free_region_tree (refined_region_p region) VEC_free (refined_region_p, heap, region->children); free (region); } + +/* Pretty print to FILE all the REGIONS in DOT format and mark them with + different colors. The behavior is the same as in dot_all_scops_1. */ + +static void +dot_regions_1 (FILE *file, VEC (refined_region_p, heap) *regions) +{ + basic_block bb; + edge e; + edge_iterator ei; + refined_region_p region; + const char* color; + int i; + + /* Disable debugging while printing graph. */ + int tmp_dump_flags = dump_flags; + dump_flags = 0; + + fprintf (file, "digraph all {\n"); + + FOR_ALL_BB (bb) + { + int part_of_scop = false; + + /* Use HTML for every bb label. So we are able to print bbs + which are part of two different SCoPs, with two different + background colors. */ + fprintf (file, "%d [label=<\n index); + fprintf (file, "CELLSPACING=\"0\">\n"); + + /* Select color for SCoP. */ + for (i = 0; VEC_iterate (refined_region_p, regions, i, region); i++) + { + if (refined_region_contains_bb_p (region, bb) + || (region->exit == bb) + || (region->entry == bb)) + { + switch (i % 17) + { + case 0: /* red */ + color = "#e41a1c"; + break; + case 1: /* blue */ + color = "#377eb8"; + break; + case 2: /* green */ + color = "#4daf4a"; + break; + case 3: /* purple */ + color = "#984ea3"; + break; + case 4: /* orange */ + color = "#ff7f00"; + break; + case 5: /* yellow */ + color = "#ffff33"; + break; + case 6: /* brown */ + color = "#a65628"; + break; + case 7: /* rose */ + color = "#f781bf"; + break; + case 8: + color = "#8dd3c7"; + break; + case 9: + color = "#ffffb3"; + break; + case 10: + color = "#bebada"; + break; + case 11: + color = "#fb8072"; + break; + case 12: + color = "#80b1d3"; + break; + case 13: + color = "#fdb462"; + break; + case 14: + color = "#b3de69"; + break; + case 15: + color = "#fccde5"; + break; + case 16: + color = "#bc80bd"; + break; + default: /* gray */ + color = "#999999"; + } + + fprintf (file, " \n"); + part_of_scop = true; + } + } + + if (!part_of_scop) + { + fprintf (file, " \n", bb->index); + } + fprintf (file, "
", color); + + if (!refined_region_contains_bb_p (region, bb)) + fprintf (file, " ("); + + if (bb == region->entry + && bb == region->exit) + fprintf (file, " %d*# ", bb->index); + else if (bb == region->entry) + fprintf (file, " %d* ", bb->index); + else if (bb == region->exit) + fprintf (file, " %d# ", bb->index); + else + fprintf (file, " %d ", bb->index); + + if (!refined_region_contains_bb_p (region, bb)) + fprintf (file, ")"); + + fprintf (file, "
"); + fprintf (file, " %d
>, shape=box, style=\"setlinewidth(0)\"]\n"); + } + + FOR_ALL_BB (bb) + { + FOR_EACH_EDGE (e, ei, bb->succs) + fprintf (file, "%d -> %d;\n", bb->index, e->dest->index); + } + + fputs ("}\n\n", file); + + /* Enable debugging again. */ + dump_flags = tmp_dump_flags; +} + +/* Display refined REGIONS using dotty. */ + +void +dot_regions (VEC (refined_region_p, heap) *regions) +{ + /* When debugging, enable the following code. This cannot be used + in production compilers because it calls "system". */ +#if 1 + FILE *stream = fopen ("/tmp/regions.dot", "w"); + gcc_assert (stream); + + dot_regions_1 (stream, regions); + fclose (stream); + + system ("dotty /tmp/regions.dot &"); +#else + dot_all_scops_1 (stderr, regions); +#endif +} diff --git a/gcc/refined-regions.h b/gcc/refined-regions.h index 534e3a4..9f0615a 100644 --- a/gcc/refined-regions.h +++ b/gcc/refined-regions.h @@ -92,5 +92,6 @@ extern bool refined_region_contains_region_p (refined_region_p, extern void print_refined_region (FILE*, refined_region_p, int, bool); extern void debug_refined_region (refined_region_p); extern void get_bbs_in_region (refined_region_p, VEC (basic_block, heap) **); +extern void dot_regions (VEC (refined_region_p, heap) *); #endif /* GCC_REFINED_REGIONS_H */