}
}
-static tree
-gcc_expression_from_isl_expression (tree type, __isl_take isl_ast_expr *,
- ivs_params &ip);
+class translate_isl_ast_to_gimple
+{
+ public:
+ translate_isl_ast_to_gimple (sese r)
+ : region (r)
+ { }
+
+ /* Translates an ISL AST node NODE to GCC representation in the
+ context of a SESE. */
+ edge translate_isl_ast (loop_p context_loop, __isl_keep isl_ast_node *node,
+ edge next_e, ivs_params &ip);
+
+ /* Translates an isl_ast_node_for to Gimple. */
+ edge translate_isl_ast_node_for (loop_p context_loop,
+ __isl_keep isl_ast_node *node,
+ edge next_e, ivs_params &ip);
+
+ /* Create the loop for a isl_ast_node_for.
+
+ - NEXT_E is the edge where new generated code should be attached. */
+ edge translate_isl_ast_for_loop (loop_p context_loop,
+ __isl_keep isl_ast_node *node_for,
+ edge next_e,
+ tree type, tree lb, tree ub,
+ ivs_params &ip);
+
+ /* Translates an isl_ast_node_if to Gimple. */
+ edge translate_isl_ast_node_if (loop_p context_loop,
+ __isl_keep isl_ast_node *node,
+ edge next_e, ivs_params &ip);
+
+ /* Translates an isl_ast_node_user to Gimple.
+
+ FIXME: We should remove iv_map.create (loop->num + 1), if it is
+ possible. */
+ edge translate_isl_ast_node_user (__isl_keep isl_ast_node *node,
+ edge next_e, ivs_params &ip);
+
+ /* Translates an isl_ast_node_block to Gimple. */
+ edge translate_isl_ast_node_block (loop_p context_loop,
+ __isl_keep isl_ast_node *node,
+ edge next_e, ivs_params &ip);
+
+ /* Converts a unary isl_ast_expr_op expression E to a GCC expression tree of
+ type TYPE. */
+ tree unary_op_to_tree (tree type, __isl_take isl_ast_expr *expr,
+ ivs_params &ip);
+
+ /* Converts a binary isl_ast_expr_op expression E to a GCC expression tree of
+ type TYPE. */
+ tree binary_op_to_tree (tree type, __isl_take isl_ast_expr *expr,
+ ivs_params &ip);
+
+ /* Converts a ternary isl_ast_expr_op expression E to a GCC expression tree of
+ type TYPE. */
+ tree ternary_op_to_tree (tree type, __isl_take isl_ast_expr *expr,
+ ivs_params &ip);
+
+ /* Converts an isl_ast_expr_op expression E with unknown number of arguments
+ to a GCC expression tree of type TYPE. */
+ tree nary_op_to_tree (tree type, __isl_take isl_ast_expr *expr,
+ ivs_params &ip);
+
+ /* Converts an ISL AST expression E back to a GCC expression tree of
+ type TYPE. */
+ tree gcc_expression_from_isl_expression (tree type,
+ __isl_take isl_ast_expr *,
+ ivs_params &ip);
+
+ /* Return the tree variable that corresponds to the given isl ast identifier
+ expression (an isl_ast_expr of type isl_ast_expr_id).
+
+ FIXME: We should replace blind conversation of id's type with derivation
+ of the optimal type when we get the corresponding isl support. Blindly
+ converting type sizes may be problematic when we switch to smaller
+ types. */
+ tree gcc_expression_from_isl_ast_expr_id (tree type,
+ __isl_keep isl_ast_expr *expr_id,
+ ivs_params &ip);
+
+ /* Converts an isl_ast_expr_int expression E to a GCC expression tree of
+ type TYPE. */
+ tree gcc_expression_from_isl_expr_int (tree type,
+ __isl_take isl_ast_expr *expr);
+
+ /* Converts an isl_ast_expr_op expression E to a GCC expression tree of
+ type TYPE. */
+ tree gcc_expression_from_isl_expr_op (tree type,
+ __isl_take isl_ast_expr *expr,
+ ivs_params &ip);
+
+ /* Creates a new LOOP corresponding to isl_ast_node_for. Inserts an
+ induction variable for the new LOOP. New LOOP is attached to CFG
+ starting at ENTRY_EDGE. LOOP is inserted into the loop tree and
+ becomes the child loop of the OUTER_LOOP. NEWIVS_INDEX binds
+ ISL's scattering name to the induction variable created for the
+ loop of STMT. The new induction variable is inserted in the NEWIVS
+ vector and is of type TYPE. */
+ struct loop *graphite_create_new_loop (edge entry_edge,
+ __isl_keep isl_ast_node *node_for,
+ loop_p outer, tree type,
+ tree lb, tree ub, ivs_params &ip);
+
+ /* All loops generated by create_empty_loop_on_edge have the form of
+ a post-test loop:
+
+ do
+
+ {
+ body of the loop;
+ } while (lower bound < upper bound);
+
+ We create a new if region protecting the loop to be executed, if
+ the execution count is zero (lower bound > upper bound). */
+ edge graphite_create_new_loop_guard (edge entry_edge,
+ __isl_keep isl_ast_node *node_for,
+ tree *type,
+ tree *lb, tree *ub, ivs_params &ip);
+
+ /* Creates a new if region corresponding to ISL's cond. */
+ edge graphite_create_new_guard (edge entry_edge,
+ __isl_take isl_ast_expr *if_cond,
+ ivs_params &ip);
+
+ /* Inserts in iv_map a tuple (OLD_LOOP->num, NEW_NAME) for the induction
+ variables of the loops around GBB in SESE.
+
+ FIXME: Instead of using a vec<tree> that maps each loop id to a possible
+ chrec, we could consider using a map<int, tree> that maps loop ids to the
+ corresponding tree expressions. */
+ void build_iv_mapping (vec<tree> iv_map, gimple_bb_p gbb,
+ __isl_keep isl_ast_expr *user_expr, ivs_params &ip,
+ sese region);
+private:
+ sese region;
+};
/* Return the tree variable that corresponds to the given isl ast identifier
expression (an isl_ast_expr of type isl_ast_expr_id).
converting type sizes may be problematic when we switch to smaller
types. */
-static tree
+tree
+translate_isl_ast_to_gimple::
gcc_expression_from_isl_ast_expr_id (tree type,
__isl_keep isl_ast_expr *expr_id,
ivs_params &ip)
res = ip.find (tmp_isl_id);
isl_id_free (tmp_isl_id);
gcc_assert (res != ip.end () &&
- "Could not map isl_id to tree expression");
+ "Could not map isl_id to tree expression");
isl_ast_expr_free (expr_id);
return fold_convert (type, res->second);
}
/* Converts an isl_ast_expr_int expression E to a GCC expression tree of
type TYPE. */
-static tree
+tree
+translate_isl_ast_to_gimple::
gcc_expression_from_isl_expr_int (tree type, __isl_take isl_ast_expr *expr)
{
gcc_assert (isl_ast_expr_get_type (expr) == isl_ast_expr_int);
/* Converts a binary isl_ast_expr_op expression E to a GCC expression tree of
type TYPE. */
-static tree
+tree
+translate_isl_ast_to_gimple::
binary_op_to_tree (tree type, __isl_take isl_ast_expr *expr, ivs_params &ip)
{
isl_ast_expr *arg_expr = isl_ast_expr_get_op_arg (expr, 0);
/* Converts a ternary isl_ast_expr_op expression E to a GCC expression tree of
type TYPE. */
-static tree
+tree
+translate_isl_ast_to_gimple::
ternary_op_to_tree (tree type, __isl_take isl_ast_expr *expr, ivs_params &ip)
{
gcc_assert (isl_ast_expr_get_op_type (expr) == isl_ast_op_minus);
/* Converts a unary isl_ast_expr_op expression E to a GCC expression tree of
type TYPE. */
-static tree
+tree
+translate_isl_ast_to_gimple::
unary_op_to_tree (tree type, __isl_take isl_ast_expr *expr, ivs_params &ip)
{
gcc_assert (isl_ast_expr_get_op_type (expr) == isl_ast_op_minus);
/* Converts an isl_ast_expr_op expression E with unknown number of arguments
to a GCC expression tree of type TYPE. */
-static tree
+tree
+translate_isl_ast_to_gimple::
nary_op_to_tree (tree type, __isl_take isl_ast_expr *expr, ivs_params &ip)
{
enum tree_code op_code;
return res;
}
-
/* Converts an isl_ast_expr_op expression E to a GCC expression tree of
type TYPE. */
-static tree
+tree
+translate_isl_ast_to_gimple::
gcc_expression_from_isl_expr_op (tree type, __isl_take isl_ast_expr *expr,
ivs_params &ip)
{
/* Converts an ISL AST expression E back to a GCC expression tree of
type TYPE. */
-static tree
+tree
+translate_isl_ast_to_gimple::
gcc_expression_from_isl_expression (tree type, __isl_take isl_ast_expr *expr,
ivs_params &ip)
{
loop of STMT. The new induction variable is inserted in the NEWIVS
vector and is of type TYPE. */
-static struct loop *
+struct loop *
+translate_isl_ast_to_gimple::
graphite_create_new_loop (edge entry_edge, __isl_keep isl_ast_node *node_for,
loop_p outer, tree type, tree lb, tree ub,
ivs_params &ip)
return loop;
}
-static edge
-translate_isl_ast (loop_p context_loop, __isl_keep isl_ast_node *node,
- edge next_e, ivs_params &ip);
-
/* Create the loop for a isl_ast_node_for.
- NEXT_E is the edge where new generated code should be attached. */
-static edge
+edge
+translate_isl_ast_to_gimple::
translate_isl_ast_for_loop (loop_p context_loop,
__isl_keep isl_ast_node *node_for, edge next_e,
tree type, tree lb, tree ub,
We create a new if region protecting the loop to be executed, if
the execution count is zero (lower bound > upper bound). */
-static edge
+edge
+translate_isl_ast_to_gimple::
graphite_create_new_loop_guard (edge entry_edge,
__isl_keep isl_ast_node *node_for, tree *type,
tree *lb, tree *ub, ivs_params &ip)
/* Translates an isl_ast_node_for to Gimple. */
-static edge
+edge
+translate_isl_ast_to_gimple::
translate_isl_ast_node_for (loop_p context_loop, __isl_keep isl_ast_node *node,
edge next_e, ivs_params &ip)
{
chrec, we could consider using a map<int, tree> that maps loop ids to the
corresponding tree expressions. */
-static void
+void
+translate_isl_ast_to_gimple::
build_iv_mapping (vec<tree> iv_map, gimple_bb_p gbb,
__isl_keep isl_ast_expr *user_expr, ivs_params &ip,
sese region)
{
gcc_assert (isl_ast_expr_get_type (user_expr) == isl_ast_expr_op &&
- isl_ast_expr_get_op_type (user_expr) == isl_ast_op_call);
+ isl_ast_expr_get_op_type (user_expr) == isl_ast_op_call);
int i;
isl_ast_expr *arg_expr;
for (i = 1; i < isl_ast_expr_get_op_n_arg (user_expr); i++)
{
arg_expr = isl_ast_expr_get_op_arg (user_expr, i);
tree type =
- build_nonstandard_integer_type (graphite_expression_type_precision, 0);
+ build_nonstandard_integer_type (graphite_expression_type_precision, 0);
tree t = gcc_expression_from_isl_expression (type, arg_expr, ip);
loop_p old_loop = gbb_loop_at_index (gbb, region, i - 1);
iv_map[old_loop->num] = t;
FIXME: We should remove iv_map.create (loop->num + 1), if it is possible. */
-static edge
+edge
+translate_isl_ast_to_gimple::
translate_isl_ast_node_user (__isl_keep isl_ast_node *node,
edge next_e, ivs_params &ip)
{
/* Translates an isl_ast_node_block to Gimple. */
-static edge
+edge
+translate_isl_ast_to_gimple::
translate_isl_ast_node_block (loop_p context_loop,
__isl_keep isl_ast_node *node,
edge next_e, ivs_params &ip)
/* Creates a new if region corresponding to ISL's cond. */
-static edge
+edge
+translate_isl_ast_to_gimple::
graphite_create_new_guard (edge entry_edge, __isl_take isl_ast_expr *if_cond,
ivs_params &ip)
{
/* Translates an isl_ast_node_if to Gimple. */
-static edge
+edge
+translate_isl_ast_to_gimple::
translate_isl_ast_node_if (loop_p context_loop,
__isl_keep isl_ast_node *node,
edge next_e, ivs_params &ip)
/* Translates an ISL AST node NODE to GCC representation in the
context of a SESE. */
-static edge
-translate_isl_ast (loop_p context_loop, __isl_keep isl_ast_node *node,
- edge next_e, ivs_params &ip)
+edge
+translate_isl_ast_to_gimple::translate_isl_ast (loop_p context_loop,
+ __isl_keep isl_ast_node *node,
+ edge next_e, ivs_params &ip)
{
switch (isl_ast_node_get_type (node))
{
context_loop = SESE_ENTRY (region)->src->loop_father;
- translate_isl_ast (context_loop, root_node, if_region->true_region->entry,
+ translate_isl_ast_to_gimple t (region);
+
+ t.translate_isl_ast (context_loop, root_node, if_region->true_region->entry,
ip);
mark_virtual_operands_for_renaming (cfun);