aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family/array-notation-common.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/c-family/array-notation-common.c')
-rw-r--r--gcc/c-family/array-notation-common.c93
1 files changed, 46 insertions, 47 deletions
diff --git a/gcc/c-family/array-notation-common.c b/gcc/c-family/array-notation-common.c
index 8eab89b..5e17009 100644
--- a/gcc/c-family/array-notation-common.c
+++ b/gcc/c-family/array-notation-common.c
@@ -101,15 +101,11 @@ length_mismatch_in_expr_p (location_t loc, vec<vec<an_parts> >list)
/* If length is a INTEGER, and list[ii][jj] is an integer then
check if they are equal. If they are not equal then return
true. */
- if (TREE_CODE (list[ii][jj].length) == INTEGER_CST)
- {
- l_node = int_cst_value (list[ii][jj].length);
- l_length = int_cst_value (length);
- if (absu_hwi (l_length) != absu_hwi (l_node))
- {
- error_at (loc, "length mismatch in expression");
- return true;
- }
+ if (TREE_CODE (list[ii][jj].length) == INTEGER_CST
+ && !tree_int_cst_equal (list[ii][jj].length, length))
+ {
+ error_at (loc, "length mismatch in expression");
+ return true;
}
}
else
@@ -271,6 +267,8 @@ find_rank (location_t loc, tree orig_expr, tree expr, bool ignore_builtin_fn,
/* If it is a built-in function, then we know it returns a
scalar. */
return true;
+ if (!find_rank (loc, orig_expr, func_name, ignore_builtin_fn, rank))
+ return false;
FOR_EACH_CALL_EXPR_ARG (arg, iter, expr)
{
if (!find_rank (loc, orig_expr, arg, ignore_builtin_fn, rank))
@@ -358,6 +356,9 @@ extract_array_notation_exprs (tree node, bool ignore_builtin_fn,
vec_safe_push (*array_list, node);
return;
}
+ /* This will extract array notations in function pointers. */
+ extract_array_notation_exprs (CALL_EXPR_FN (node), ignore_builtin_fn,
+ array_list);
FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
extract_array_notation_exprs (arg, ignore_builtin_fn, array_list);
}
@@ -433,6 +434,9 @@ replace_array_notations (tree *orig, bool ignore_builtin_fn,
}
return;
}
+ /* Fixes array notations in array notations in function pointers. */
+ replace_array_notations (&CALL_EXPR_FN (*orig), ignore_builtin_fn, list,
+ array_operand);
ii = 0;
FOR_EACH_CALL_EXPR_ARG (arg, iter, *orig)
{
@@ -575,53 +579,49 @@ cilkplus_extract_an_triplets (vec<tree, va_gc> *list, size_t size, size_t rank,
vec<vec<struct cilkplus_an_parts> > *node)
{
vec<vec<tree> > array_exprs = vNULL;
- struct cilkplus_an_parts init = { NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE,
- false };
+
node->safe_grow_cleared (size);
array_exprs.safe_grow_cleared (size);
- for (size_t ii = 0; ii < size; ii++)
- for (size_t jj = 0; jj < rank; jj++)
+
+ if (rank > 0)
+ for (size_t ii = 0; ii < size; ii++)
{
- (*node)[ii].safe_push (init);
- array_exprs[ii].safe_push (NULL_TREE);
+ (*node)[ii].safe_grow_cleared (rank);
+ array_exprs[ii].safe_grow_cleared (rank);
}
-
for (size_t ii = 0; ii < size; ii++)
{
size_t jj = 0;
tree ii_tree = (*list)[ii];
while (ii_tree)
- if (TREE_CODE (ii_tree) == ARRAY_NOTATION_REF)
- {
- array_exprs[ii][jj] = ii_tree;
- jj++;
- ii_tree = ARRAY_NOTATION_ARRAY (ii_tree);
- }
- else if (TREE_CODE (ii_tree) == ARRAY_REF)
- ii_tree = TREE_OPERAND (ii_tree, 0);
- else if (TREE_CODE (ii_tree) == VAR_DECL
- || TREE_CODE (ii_tree) == CALL_EXPR
- || TREE_CODE (ii_tree) == PARM_DECL)
- break;
- else
- gcc_unreachable ();
+ {
+ if (TREE_CODE (ii_tree) == ARRAY_NOTATION_REF)
+ {
+ array_exprs[ii][jj] = ii_tree;
+ jj++;
+ ii_tree = ARRAY_NOTATION_ARRAY (ii_tree);
+ }
+ else if (TREE_CODE (ii_tree) == ARRAY_REF)
+ ii_tree = TREE_OPERAND (ii_tree, 0);
+ else
+ break;
+ }
}
for (size_t ii = 0; ii < size; ii++)
if (TREE_CODE ((*list)[ii]) == ARRAY_NOTATION_REF)
for (size_t jj = 0; jj < rank; jj++)
- if (TREE_CODE (array_exprs[ii][jj]) == ARRAY_NOTATION_REF)
- {
- tree ii_tree = array_exprs[ii][jj];
- (*node)[ii][jj].is_vector = true;
- (*node)[ii][jj].value = ARRAY_NOTATION_ARRAY (ii_tree);
- (*node)[ii][jj].start = ARRAY_NOTATION_START (ii_tree);
- (*node)[ii][jj].length =
- fold_build1 (CONVERT_EXPR, integer_type_node,
- ARRAY_NOTATION_LENGTH (ii_tree));
- (*node)[ii][jj].stride =
- fold_build1 (CONVERT_EXPR, integer_type_node,
- ARRAY_NOTATION_STRIDE (ii_tree));
- }
+ {
+ tree ii_tree = array_exprs[ii][jj];
+ (*node)[ii][jj].is_vector = true;
+ (*node)[ii][jj].value = ARRAY_NOTATION_ARRAY (ii_tree);
+ (*node)[ii][jj].start = ARRAY_NOTATION_START (ii_tree);
+ (*node)[ii][jj].length =
+ fold_build1 (CONVERT_EXPR, integer_type_node,
+ ARRAY_NOTATION_LENGTH (ii_tree));
+ (*node)[ii][jj].stride =
+ fold_build1 (CONVERT_EXPR, integer_type_node,
+ ARRAY_NOTATION_STRIDE (ii_tree));
+ }
}
/* Replaces all the __sec_implicit_arg functions in LIST with the induction
@@ -637,16 +637,15 @@ fix_sec_implicit_args (location_t loc, vec <tree, va_gc> *list,
vec <tree, va_gc> *array_operand = NULL;
for (size_t ii = 0; ii < vec_safe_length (list); ii++)
if (TREE_CODE ((*list)[ii]) == CALL_EXPR
- && TREE_CODE (CALL_EXPR_FN ((*list)[ii])) == ADDR_EXPR
&& is_sec_implicit_index_fn (CALL_EXPR_FN ((*list)[ii])))
{
int idx = extract_sec_implicit_index_arg (loc, (*list)[ii]);
- if (idx < (int) rank && idx >= 0)
- vec_safe_push (array_operand, an_loop_info[idx].var);
- else if (idx == -1)
+ if (idx < 0)
/* In this case, the returning function would have emitted an
error thus it is not necessary to do so again. */
return NULL;
+ else if (idx < (int) rank)
+ vec_safe_push (array_operand, an_loop_info[idx].var);
else
{
error_at (loc, "__sec_implicit_index argument %d must be "