summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorromangareev <romangareev@138bc75d-0d04-0410-961f-82ee72b054a4>2014-06-29 14:20:35 +0000
committerromangareev <romangareev@138bc75d-0d04-0410-961f-82ee72b054a4>2014-06-29 14:20:35 +0000
commit5eb0077df225a2d15ff86cc493f8caaed7b08c63 (patch)
tree95e882342ab8217fe3b1e2dff48e7f7f5620b2d7 /gcc
parent7136063b1a7a591994cd8b16cf482caa12ba5fc7 (diff)
downloadgcc-5eb0077df225a2d15ff86cc493f8caaed7b08c63.tar.gz
gcc/
* Makefile.in: Add the compilation of graphite-isl-ast-to-gimple.o. * common.opt: Add new switch fgraphite-code-generator=[isl|cloog]. * flag-types.h: Add new enum fgraphite_generator. * graphite-isl-ast-to-gimple.c: New. * graphite-isl-ast-to-gimple.h: New. * graphite.c (graphite_transform_loops): Add choice of Graphite code generator, which depends on flag_graphite_code_gen. gcc/testsuite/gcc.dg/graphite/isl-codegen-loop-dumping.c: New testcase that checks that the dump is generated. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@212124 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog17
-rw-r--r--gcc/Makefile.in1
-rw-r--r--gcc/common.opt13
-rw-r--r--gcc/flag-types.h6
-rw-r--r--gcc/graphite-isl-ast-to-gimple.c133
-rw-r--r--gcc/graphite-isl-ast-to-gimple.h26
-rw-r--r--gcc/graphite.c6
-rw-r--r--gcc/testsuite/gcc.dg/graphite/isl-codegen-loop-dumping.c16
8 files changed, 217 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index dcf5f1566fa..7c34af8b3d5 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,22 @@
2014-06-29 Roman Gareev <gareevroman@gmail.com>
+ * Makefile.in:
+ Add the compilation of graphite-isl-ast-to-gimple.o.
+ * common.opt:
+ Add new switch fgraphite-code-generator=[isl|cloog].
+ * flag-types.h:
+ Add new enum fgraphite_generator.
+ * graphite-isl-ast-to-gimple.c: New.
+ * graphite-isl-ast-to-gimple.h: New.
+ * graphite.c (graphite_transform_loops):
+ Add choice of Graphite code generator,
+ which depends on flag_graphite_code_gen.
+
+ testsuite/gcc.dg/graphite/isl-codegen-loop-dumping.c:
+ New testcase that checks that the dump is generated.
+
+2014-06-29 Roman Gareev <gareevroman@gmail.com>
+
* graphite-dependences.c (subtract_commutative_associative_deps):
Add NULL checking of the following variables: must_raw_no_source,
may_raw_no_source, must_war_no_source, may_war_no_source,
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 3d15eff267d..af6554f8234 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1250,6 +1250,7 @@ OBJS = \
graphite.o \
graphite-blocking.o \
graphite-clast-to-gimple.o \
+ graphite-isl-ast-to-gimple.o \
graphite-dependences.o \
graphite-interchange.o \
graphite-optimize-isl.o \
diff --git a/gcc/common.opt b/gcc/common.opt
index 15371dfbe9b..e9ceab16551 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1250,6 +1250,19 @@ Enable in and out of Graphite representation
fgraphite-identity
Common Report Var(flag_graphite_identity) Optimization
Enable Graphite Identity transformation
+
+fgraphite-code-generator=
+Common Report RejectNegative Joined Optimization Enum(fgraphite_generator) Var(flag_graphite_code_gen) Init(FGRAPHITE_CODE_GEN_CLOOG)
+Choose code generator of Graphite
+
+Enum
+Name(fgraphite_generator) Type(enum fgraphite_generator) UnknownError(unknown code generator of graphite %qs)
+
+EnumValue
+Enum(fgraphite_generator) String(isl) Value(FGRAPHITE_CODE_GEN_ISL)
+
+EnumValue
+Enum(fgraphite_generator) String(cloog) Value(FGRAPHITE_CODE_GEN_CLOOG)
fhoist-adjacent-loads
Common Report Var(flag_hoist_adjacent_loads) Optimization
diff --git a/gcc/flag-types.h b/gcc/flag-types.h
index 4b8e33889a7..2849455d793 100644
--- a/gcc/flag-types.h
+++ b/gcc/flag-types.h
@@ -254,4 +254,10 @@ enum lto_partition_model {
LTO_PARTITION_MAX = 4
};
+/* The code generator used by graphite */
+enum fgraphite_generator {
+ FGRAPHITE_CODE_GEN_ISL = 0,
+ FGRAPHITE_CODE_GEN_CLOOG = 1
+};
+
#endif /* ! GCC_FLAG_TYPES_H */
diff --git a/gcc/graphite-isl-ast-to-gimple.c b/gcc/graphite-isl-ast-to-gimple.c
new file mode 100644
index 00000000000..6437474741e
--- /dev/null
+++ b/gcc/graphite-isl-ast-to-gimple.c
@@ -0,0 +1,133 @@
+/* Translation of ISL AST to Gimple.
+ Copyright (C) 2014 Free Software Foundation, Inc.
+ Contributed by Roman Gareev <gareevroman@gmail.com>.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#include "config.h"
+
+#include <isl/set.h>
+#include <isl/map.h>
+#include <isl/union_map.h>
+#include <isl/ast_build.h>
+
+#include "system.h"
+#include "coretypes.h"
+#include "tree.h"
+#include "basic-block.h"
+#include "tree-ssa-alias.h"
+#include "internal-fn.h"
+#include "gimple-expr.h"
+#include "is-a.h"
+#include "gimple.h"
+#include "gimple-iterator.h"
+#include "tree-ssa-loop.h"
+#include "tree-pass.h"
+#include "cfgloop.h"
+#include "tree-data-ref.h"
+#include "sese.h"
+
+#include "graphite-poly.h"
+#include "graphite-isl-ast-to-gimple.h"
+
+/* This flag is set when an error occurred during the translation of
+ ISL AST to Gimple. */
+
+static bool graphite_regenerate_error;
+
+/* Prints NODE to FILE. */
+
+void
+print_isl_ast_node (FILE *file, __isl_keep isl_ast_node *node,
+ __isl_keep isl_ctx *ctx)
+{
+ isl_printer *prn = isl_printer_to_file (ctx, file);
+ prn = isl_printer_set_output_format (prn, ISL_FORMAT_C);
+ prn = isl_printer_print_ast_node (prn, node);
+ prn = isl_printer_print_str (prn, "\n");
+ isl_printer_free (prn);
+}
+
+/* Generates a build, which specifies the constraints on the parameters. */
+
+static isl_ast_build *
+generate_isl_context (scop_p scop)
+{
+ isl_set *context_isl = isl_set_params (isl_set_copy (scop->context));
+ return isl_ast_build_from_context (context_isl);
+}
+
+/* Generates a schedule, which specifies an order used to
+ visit elements in a domain. */
+
+static isl_union_map *
+generate_isl_schedule (scop_p scop)
+{
+ int i;
+ poly_bb_p pbb;
+ isl_union_map *schedule_isl =
+ isl_union_map_empty (isl_set_get_space (scop->context));
+
+ FOR_EACH_VEC_ELT (SCOP_BBS (scop), i, pbb)
+ {
+ /* Dead code elimination: when the domain of a PBB is empty,
+ don't generate code for the PBB. */
+ if (isl_set_is_empty (pbb->domain))
+ continue;
+
+ isl_map *bb_schedule = isl_map_copy (pbb->transformed);
+ bb_schedule = isl_map_intersect_domain (bb_schedule,
+ isl_set_copy (pbb->domain));
+ schedule_isl =
+ isl_union_map_union (schedule_isl,
+ isl_union_map_from_map (bb_schedule));
+ }
+ return schedule_isl;
+}
+
+static isl_ast_node *
+scop_to_isl_ast (scop_p scop)
+{
+ isl_union_map *schedule_isl = generate_isl_schedule (scop);
+ isl_ast_build *context_isl = generate_isl_context (scop);
+ isl_ast_node *ast_isl = isl_ast_build_ast_from_schedule (context_isl,
+ schedule_isl);
+ isl_ast_build_free (context_isl);
+ return ast_isl;
+}
+
+/* GIMPLE Loop Generator: generates loops from STMT in GIMPLE form for
+ the given SCOP. Return true if code generation succeeded.
+
+ FIXME: This is not yet a full implementation of the code generator
+ with ISL ASTs. Generation of GIMPLE code is have to be added. */
+
+bool
+graphite_regenerate_ast_isl (scop_p scop)
+{
+ timevar_push (TV_GRAPHITE_CODE_GEN);
+ graphite_regenerate_error = false;
+ isl_ast_node *root_node = scop_to_isl_ast (scop);
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ {
+ fprintf (dump_file, "\nISL AST generated by ISL: \n");
+ print_isl_ast_node (dump_file, root_node, scop->ctx);
+ }
+ isl_ast_node_free (root_node);
+ timevar_pop (TV_GRAPHITE_CODE_GEN);
+ return !graphite_regenerate_error;
+}
diff --git a/gcc/graphite-isl-ast-to-gimple.h b/gcc/graphite-isl-ast-to-gimple.h
new file mode 100644
index 00000000000..0d98780523f
--- /dev/null
+++ b/gcc/graphite-isl-ast-to-gimple.h
@@ -0,0 +1,26 @@
+/* Translation of ISL AST to Gimple.
+ Copyright (C) 2014 Free Software Foundation, Inc.
+ Contributed by Roman Gareev <gareevroman@gmail.com>.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#ifndef GCC_GRAPHITE_ISL_AST_TO_GIMPLE_H
+#define GCC_GRAPHITE_ISL_AST_TO_GIMPLE_H
+
+extern bool graphite_regenerate_ast_isl (scop_p);
+
+#endif
diff --git a/gcc/graphite.c b/gcc/graphite.c
index 16f154cde2b..0e424d01a05 100644
--- a/gcc/graphite.c
+++ b/gcc/graphite.c
@@ -73,6 +73,7 @@ along with GCC; see the file COPYING3. If not see
#include "graphite-poly.h"
#include "graphite-scop-detection.h"
#include "graphite-clast-to-gimple.h"
+#include "graphite-isl-ast-to-gimple.h"
#include "graphite-sese-to-poly.h"
#include "graphite-htab.h"
@@ -299,7 +300,10 @@ graphite_transform_loops (void)
if (POLY_SCOP_P (scop)
&& apply_poly_transforms (scop)
- && graphite_regenerate_ast_cloog (scop, &bb_pbb_mapping))
+ && (((flag_graphite_code_gen == FGRAPHITE_CODE_GEN_ISL)
+ && graphite_regenerate_ast_isl (scop))
+ || ((flag_graphite_code_gen == FGRAPHITE_CODE_GEN_CLOOG)
+ && graphite_regenerate_ast_cloog (scop, &bb_pbb_mapping))))
need_cfg_cleanup_p = true;
}
diff --git a/gcc/testsuite/gcc.dg/graphite/isl-codegen-loop-dumping.c b/gcc/testsuite/gcc.dg/graphite/isl-codegen-loop-dumping.c
new file mode 100644
index 00000000000..65d51555580
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/graphite/isl-codegen-loop-dumping.c
@@ -0,0 +1,16 @@
+/* { dg-options "-O2 -fdump-tree-graphite-all -fgraphite-identity -fgraphite-code-generator=isl" } */
+
+int
+main (int n, int *a)
+{
+ int i, j;
+
+ for (i = 0; i < n - 1; i++)
+ for (j = 0; j < n; j++)
+ a[j] = i + n;
+
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "ISL AST generated by ISL: \nfor \\(int c1 = 0; c1 < n - 1; c1 \\+= 1\\)\n for \\(int c3 = 0; c3 < n; c3 \\+= 1\\)\n S_4\\(c1, c3\\);" 1 "graphite"} } */
+/* { dg-final { cleanup-tree-dump "graphite" } } */