/* Translation of ISL AST to Gimple.
- Copyright (C) 2014 Free Software Foundation, Inc.
+ Copyright (C) 2014-2015 Free Software Foundation, Inc.
Contributed by Roman Gareev <gareevroman@gmail.com>.
This file is part of GCC.
#include "config.h"
-#ifdef HAVE_cloog
+#ifdef HAVE_isl
#include <isl/set.h>
#include <isl/map.h>
#include <isl/union_map.h>
#include <isl/ast_build.h>
-#if defined(__cplusplus)
+
+/* Since ISL-0.13, the extern is in val_gmp.h. */
+#if !defined(HAVE_ISL_SCHED_CONSTRAINTS_COMPUTE_SCHEDULE) && defined(__cplusplus)
extern "C" {
#endif
#include <isl/val_gmp.h>
-#if defined(__cplusplus)
+#if !defined(HAVE_ISL_SCHED_CONSTRAINTS_COMPUTE_SCHEDULE) && defined(__cplusplus)
}
#endif
#endif
#include "system.h"
#include "coretypes.h"
+#include "alias.h"
+#include "symtab.h"
+#include "options.h"
#include "tree.h"
+#include "fold-const.h"
+#include "predict.h"
+#include "tm.h"
+#include "hard-reg-set.h"
+#include "function.h"
+#include "dominance.h"
+#include "cfg.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-into-ssa.h"
#include <map>
-#ifdef HAVE_cloog
+#ifdef HAVE_isl
#include "graphite-poly.h"
#include "graphite-isl-ast-to-gimple.h"
return schedule;
}
+/* Set the separation_class option for unroll and jam. */
+
+static __isl_give isl_union_map *
+generate_luj_sepclass_opt (scop_p scop, __isl_take isl_union_set *domain,
+ int dim, int cl)
+{
+ isl_map *map;
+ isl_space *space, *space_sep;
+ isl_ctx *ctx;
+ isl_union_map *mapu;
+ int nsched = get_max_schedule_dimensions (scop);
+
+ ctx = scop->ctx;
+ space_sep = isl_space_alloc (ctx, 0, 1, 1);
+ space_sep = isl_space_wrap (space_sep);
+ space_sep = isl_space_set_tuple_name (space_sep, isl_dim_set,
+ "separation_class");
+ space = isl_set_get_space (scop->context);
+ space_sep = isl_space_align_params (space_sep, isl_space_copy(space));
+ space = isl_space_map_from_domain_and_range (space, space_sep);
+ space = isl_space_add_dims (space,isl_dim_in, nsched);
+ map = isl_map_universe (space);
+ isl_map_fix_si (map,isl_dim_out,0,dim);
+ isl_map_fix_si (map,isl_dim_out,1,cl);
+
+ mapu = isl_union_map_intersect_domain (isl_union_map_from_map (map),
+ domain);
+ return (mapu);
+}
+
+/* Compute the separation class for loop unroll and jam. */
+
+static __isl_give isl_union_set *
+generate_luj_sepclass (scop_p scop)
+{
+ int i;
+ poly_bb_p pbb;
+ isl_union_set *domain_isl;
+
+ domain_isl = isl_union_set_empty (isl_set_get_space (scop->context));
+
+ FOR_EACH_VEC_ELT (SCOP_BBS (scop), i, pbb)
+ {
+ isl_set *bb_domain;
+ isl_set *bb_domain_s;
+
+ if (pbb->map_sepclass == NULL)
+ continue;
+
+ if (isl_set_is_empty (pbb->domain))
+ continue;
+
+ bb_domain = isl_set_copy (pbb->domain);
+ bb_domain_s = isl_set_apply (bb_domain, pbb->map_sepclass);
+ pbb->map_sepclass = NULL;
+
+ domain_isl =
+ isl_union_set_union (domain_isl, isl_union_set_from_set (bb_domain_s));
+ }
+
+ return domain_isl;
+}
+
+/* Set the AST built options for loop unroll and jam. */
+
+static __isl_give isl_union_map *
+generate_luj_options (scop_p scop)
+{
+ isl_union_set *domain_isl;
+ isl_union_map *options_isl_ss;
+ isl_union_map *options_isl =
+ isl_union_map_empty (isl_set_get_space (scop->context));
+ int dim = get_max_schedule_dimensions (scop) - 1;
+ int dim1 = dim - PARAM_VALUE (PARAM_LOOP_UNROLL_JAM_DEPTH);
+
+ if (!flag_loop_unroll_jam)
+ return options_isl;
+
+ domain_isl = generate_luj_sepclass (scop);
+
+ options_isl_ss = generate_luj_sepclass_opt (scop, domain_isl, dim1, 0);
+ options_isl = isl_union_map_union (options_isl, options_isl_ss);
+
+ return options_isl;
+}
+
/* Generates a schedule, which specifies an order used to
visit elements in a domain. */
}
/* Set the separate option for all dimensions.
- This helps to reduce control overhead. */
+ This helps to reduce control overhead.
+ Set the options for unroll and jam. */
static __isl_give isl_ast_build *
set_options (__isl_take isl_ast_build *control,
- __isl_keep isl_union_map *schedule)
+ __isl_keep isl_union_map *schedule,
+ __isl_take isl_union_map *opt_luj)
{
isl_ctx *ctx = isl_union_map_get_ctx (schedule);
isl_space *range_space = isl_space_set_alloc (ctx, 0, 1);
isl_union_set *domain = isl_union_map_range (isl_union_map_copy (schedule));
domain = isl_union_set_universe (domain);
isl_union_map *options = isl_union_map_from_domain_and_range (domain, range);
+
+ options = isl_union_map_union (options, opt_luj);
+
return isl_ast_build_set_options (control, options);
}
isl_options_set_ast_build_atomic_upper_bound (scop->ctx, true);
add_parameters_to_ivs_params (scop, ip);
+
+ isl_union_map *options_luj = generate_luj_options (scop);
+
isl_union_map *schedule_isl = generate_isl_schedule (scop);
isl_ast_build *context_isl = generate_isl_context (scop);
- context_isl = set_options (context_isl, schedule_isl);
+
+ context_isl = set_options (context_isl, schedule_isl, options_luj);
+
isl_union_map *dependences = NULL;
if (flag_loop_parallelize_all)
{
translate_isl_ast (context_loop, root_node, if_region->true_region->entry,
ip);
+
+ mark_virtual_operands_for_renaming (cfun);
+ update_ssa (TODO_update_ssa);
+
graphite_verify ();
scev_reset ();
recompute_all_dominators ();