Commit 287b3dd2 by Mikael Morin Committed by Mikael Morin

trans-array.c (gfc_conv_section_startstride): Move code to evaluate_bound.

	* trans-array.c (gfc_conv_section_startstride): Move code to
	evaluate_bound.  Use evaluate_bound.
	(evaluate_bound): New function.

From-SVN: r179681
parent b0ac6998
2011-10-07 Mikael Morin <mikael.morin@sfr.fr> 2011-10-07 Mikael Morin <mikael.morin@sfr.fr>
* trans-array.c (gfc_conv_section_startstride): Move code to
evaluate_bound. Use evaluate_bound.
(evaluate_bound): New function.
2011-10-07 Mikael Morin <mikael.morin@sfr.fr>
* trans-array.c (gfc_conv_section_startstride): Update assertion to * trans-array.c (gfc_conv_section_startstride): Update assertion to
also accept coarrays. also accept coarrays.
......
...@@ -3175,14 +3175,46 @@ gfc_trans_scalarized_loop_boundary (gfc_loopinfo * loop, stmtblock_t * body) ...@@ -3175,14 +3175,46 @@ gfc_trans_scalarized_loop_boundary (gfc_loopinfo * loop, stmtblock_t * body)
} }
/* Precalculate (either lower or upper) bound of an array section.
BLOCK: Block in which the (pre)calculation code will go.
BOUNDS[DIM]: Where the bound value will be stored once evaluated.
VALUES[DIM]: Specified bound (NULL <=> unspecified).
DESC: Array descriptor from which the bound will be picked if unspecified
(either lower or upper bound according to LBOUND). */
static void
evaluate_bound (stmtblock_t *block, tree *bounds, gfc_expr ** values,
tree desc, int dim, bool lbound)
{
gfc_se se;
gfc_expr * input_val = values[dim];
tree *output = &bounds[dim];
if (input_val)
{
/* Specified section bound. */
gfc_init_se (&se, NULL);
gfc_conv_expr_type (&se, input_val, gfc_array_index_type);
gfc_add_block_to_block (block, &se.pre);
*output = se.expr;
}
else
{
/* No specific bound specified so use the bound of the array. */
*output = lbound ? gfc_conv_array_lbound (desc, dim) :
gfc_conv_array_ubound (desc, dim);
}
*output = gfc_evaluate_now (*output, block);
}
/* Calculate the lower bound of an array section. */ /* Calculate the lower bound of an array section. */
static void static void
gfc_conv_section_startstride (gfc_loopinfo * loop, gfc_ss * ss, int dim, gfc_conv_section_startstride (gfc_loopinfo * loop, gfc_ss * ss, int dim,
bool coarray, bool coarray_last) bool coarray, bool coarray_last)
{ {
gfc_expr *start;
gfc_expr *end;
gfc_expr *stride = NULL; gfc_expr *stride = NULL;
tree desc; tree desc;
gfc_se se; gfc_se se;
...@@ -3207,48 +3239,18 @@ gfc_conv_section_startstride (gfc_loopinfo * loop, gfc_ss * ss, int dim, ...@@ -3207,48 +3239,18 @@ gfc_conv_section_startstride (gfc_loopinfo * loop, gfc_ss * ss, int dim,
gcc_assert (ar->dimen_type[dim] == DIMEN_RANGE gcc_assert (ar->dimen_type[dim] == DIMEN_RANGE
|| ar->dimen_type[dim] == DIMEN_THIS_IMAGE); || ar->dimen_type[dim] == DIMEN_THIS_IMAGE);
desc = info->descriptor; desc = info->descriptor;
start = ar->start[dim];
end = ar->end[dim];
if (!coarray) if (!coarray)
stride = ar->stride[dim]; stride = ar->stride[dim];
/* Calculate the start of the range. For vector subscripts this will /* Calculate the start of the range. For vector subscripts this will
be the range of the vector. */ be the range of the vector. */
if (start) evaluate_bound (&loop->pre, info->start, ar->start, desc, dim, true);
{
/* Specified section start. */
gfc_init_se (&se, NULL);
gfc_conv_expr_type (&se, start, gfc_array_index_type);
gfc_add_block_to_block (&loop->pre, &se.pre);
info->start[dim] = se.expr;
}
else
{
/* No lower bound specified so use the bound of the array. */
info->start[dim] = gfc_conv_array_lbound (desc, dim);
}
info->start[dim] = gfc_evaluate_now (info->start[dim], &loop->pre);
/* Similarly calculate the end. Although this is not used in the /* Similarly calculate the end. Although this is not used in the
scalarizer, it is needed when checking bounds and where the end scalarizer, it is needed when checking bounds and where the end
is an expression with side-effects. */ is an expression with side-effects. */
if (!coarray_last) if (!coarray_last)
{ evaluate_bound (&loop->pre, info->end, ar->end, desc, dim, false);
if (end)
{
/* Specified section start. */
gfc_init_se (&se, NULL);
gfc_conv_expr_type (&se, end, gfc_array_index_type);
gfc_add_block_to_block (&loop->pre, &se.pre);
info->end[dim] = se.expr;
}
else
{
/* No upper bound specified so use the bound of the array. */
info->end[dim] = gfc_conv_array_ubound (desc, dim);
}
info->end[dim] = gfc_evaluate_now (info->end[dim], &loop->pre);
}
/* Calculate the stride. */ /* Calculate the stride. */
if (!coarray && stride == NULL) if (!coarray && stride == NULL)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment