Commit 713b46fa by Balaji V. Iyer Committed by Balaji V. Iyer

Replaced Dynamic arrays with vec trees in Array Notation for C.

gcc/c-family/ChangeLog
2013-06-21  Balaji V. Iyer  <balaji.v.iyer@intel.com>

        * array-notation-common.c (length_mismatch_in_expr): Changed the
        parameter type's from a dynamic array to a vec_tree.  Also removed
        the size parameters.
        * c-common.h (length_mismatch_in_expr_p): Fixed prototype's as per
        the change above.

gcc/cp/ChangeLog
2013-06-21  Balaji V. Iyer  <balaji.v.iyer@intel.com>

        * cp-array-notation.c (cp_length_mismatch_in_expr_p): Remove.
        (expand_an_in_modify_expr): Changed a function call from the above
        removed function to length_mismatch_in_expr_p.

gcc/c/ChangeLog
2013-06-21  Balaji V. Iyer  <balaji.v.iyer@intel.com>

        * c-array-notation.c (make_triplet_val_inv): New function.
        (create_cmp_incr): Likewise.
        (create_array_refs): Likewise.
        (fix_builtin_array_notation_fn): Replaced all mallocs with tree vec.
        Also modularized common parts between functions and called the function.
        (build_array_notation_expr): Likewise.
        (fix_conditional_array_notations_1): Likewise.
        (fix_array_notation_expr): Likewise.
        (fix_array_notation_call_expr): Likewise.

From-SVN: r200405
parent 818cac82
...@@ -6,6 +6,14 @@ ...@@ -6,6 +6,14 @@
2013-06-21 Balaji V. Iyer <balaji.v.iyer@intel.com> 2013-06-21 Balaji V. Iyer <balaji.v.iyer@intel.com>
* array-notation-common.c (length_mismatch_in_expr): Changed the
parameter type's from a dynamic array to a vec_tree. Also removed
the size parameters.
* c-common.h (length_mismatch_in_expr_p): Fixed prototype's as per
the change above.
2013-06-21 Balaji V. Iyer <balaji.v.iyer@intel.com>
* c-common.h (struct cilkplus_an_parts): New structure. * c-common.h (struct cilkplus_an_parts): New structure.
(struct cilkplus_an_loop_parts): Likewise. (struct cilkplus_an_loop_parts): Likewise.
(cilkplus_extract_an_triplets): New prototype. (cilkplus_extract_an_triplets): New prototype.
......
...@@ -75,35 +75,37 @@ extract_sec_implicit_index_arg (location_t location, tree fn) ...@@ -75,35 +75,37 @@ extract_sec_implicit_index_arg (location_t location, tree fn)
return return_int; return return_int;
} }
/* Returns true if there is length mismatch among expressions /* Returns true if there is a length mismatch among exprssions that are at the
on the same dimension and on the same side of the equal sign. The same dimension and one the same side of the equal sign. The Array notation
expressions (or ARRAY_NOTATION lengths) are passed in through 2-D array lengths (LIST->LENGTH) is passed in as a 2D vector of trees. */
**LIST where X and Y indicate first and second dimension sizes of LIST,
respectively. */
bool bool
length_mismatch_in_expr_p (location_t loc, tree **list, size_t x, size_t y) length_mismatch_in_expr_p (location_t loc, vec<vec<an_parts> >list)
{ {
size_t ii, jj; size_t ii, jj;
tree start = NULL_TREE; tree length = NULL_TREE;
HOST_WIDE_INT l_start, l_node; HOST_WIDE_INT l_length, l_node;
size_t x = list.length ();
size_t y = list[0].length ();
for (jj = 0; jj < y; jj++) for (jj = 0; jj < y; jj++)
{ {
start = NULL_TREE; length = NULL_TREE;
for (ii = 0; ii < x; ii++) for (ii = 0; ii < x; ii++)
{ {
if (!start) if (!length)
start = list[ii][jj]; length = list[ii][jj].length;
else if (TREE_CODE (start) == INTEGER_CST) else if (TREE_CODE (length) == INTEGER_CST)
{ {
/* If start is a INTEGER, and list[ii][jj] is an integer then /* 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 check if they are equal. If they are not equal then return
true. */ true. */
if (TREE_CODE (list[ii][jj]) == INTEGER_CST) if (TREE_CODE (list[ii][jj].length) == INTEGER_CST)
{ {
l_node = int_cst_value (list[ii][jj]); l_node = int_cst_value (list[ii][jj].length);
l_start = int_cst_value (start); l_length = int_cst_value (length);
if (absu_hwi (l_start) != absu_hwi (l_node)) if (absu_hwi (l_length) != absu_hwi (l_node))
{ {
error_at (loc, "length mismatch in expression"); error_at (loc, "length mismatch in expression");
return true; return true;
...@@ -111,9 +113,9 @@ length_mismatch_in_expr_p (location_t loc, tree **list, size_t x, size_t y) ...@@ -111,9 +113,9 @@ length_mismatch_in_expr_p (location_t loc, tree **list, size_t x, size_t y)
} }
} }
else else
/* We set the start node as the current node just in case it turns /* We set the length node as the current node just in case it turns
out to be an integer. */ out to be an integer. */
start = list[ii][jj]; length = list[ii][jj].length;
} }
} }
return false; return false;
......
...@@ -1193,7 +1193,7 @@ extern bool contains_array_notation_expr (tree); ...@@ -1193,7 +1193,7 @@ extern bool contains_array_notation_expr (tree);
extern tree expand_array_notation_exprs (tree); extern tree expand_array_notation_exprs (tree);
extern tree fix_conditional_array_notations (tree); extern tree fix_conditional_array_notations (tree);
extern tree find_correct_array_notation_type (tree); extern tree find_correct_array_notation_type (tree);
extern bool length_mismatch_in_expr_p (location_t, tree **, size_t, size_t); extern bool length_mismatch_in_expr_p (location_t, vec<vec<an_parts> >);
extern enum built_in_function is_cilkplus_reduce_builtin (tree); extern enum built_in_function is_cilkplus_reduce_builtin (tree);
extern bool find_rank (location_t, tree, tree, bool, size_t *); extern bool find_rank (location_t, tree, tree, bool, size_t *);
extern void extract_array_notation_exprs (tree, bool, vec<tree, va_gc> **); extern void extract_array_notation_exprs (tree, bool, vec<tree, va_gc> **);
......
2013-06-21 Balaji V. Iyer <balaji.v.iyer@intel.com>
* c-array-notation.c (make_triplet_val_inv): New function.
(create_cmp_incr): Likewise.
(create_array_refs): Likewise.
(fix_builtin_array_notation_fn): Replaced all mallocs with tree vec.
Also modularized common parts between functions and called the function.
(build_array_notation_expr): Likewise.
(fix_conditional_array_notations_1): Likewise.
(fix_array_notation_expr): Likewise.
(fix_array_notation_call_expr): Likewise.
2013-06-18 Marek Polacek <polacek@redhat.com> 2013-06-18 Marek Polacek <polacek@redhat.com>
PR c/57630 PR c/57630
......
...@@ -42,6 +42,12 @@ ...@@ -42,6 +42,12 @@
2013-06-21 Balaji V. Iyer <balaji.v.iyer@intel.com> 2013-06-21 Balaji V. Iyer <balaji.v.iyer@intel.com>
* cp-array-notation.c (cp_length_mismatch_in_expr_p): Remove.
(expand_an_in_modify_expr): Changed a function call from the above
removed function to length_mismatch_in_expr_p.
2013-06-21 Balaji V. Iyer <balaji.v.iyer@intel.com>
* call.c (convert_like_real): Added a check if array notation is present * call.c (convert_like_real): Added a check if array notation is present
in expression. If so, then no conversion of arguments is necessary. in expression. If so, then no conversion of arguments is necessary.
(build_over_call): Likewise. (build_over_call): Likewise.
......
...@@ -78,52 +78,6 @@ create_an_loop (tree init, tree cond, tree incr, tree body) ...@@ -78,52 +78,6 @@ create_an_loop (tree init, tree cond, tree incr, tree body)
finish_for_stmt (for_stmt); finish_for_stmt (for_stmt);
} }
/* Returns true if there is a length mismatch among exprssions that are at the
same dimension and one the same side of the equal sign. The Array notation
lengths (LIST->LENGTH) is passed in as a 2D vector of trees. */
static bool
cp_length_mismatch_in_expr_p (location_t loc, vec<vec<an_parts> >list)
{
size_t ii, jj;
tree length = NULL_TREE;
HOST_WIDE_INT l_length, l_node;
size_t x = list.length ();
size_t y = list[0].length ();
for (jj = 0; jj < y; jj++)
{
length = NULL_TREE;
for (ii = 0; ii < x; ii++)
{
if (!length)
length = list[ii][jj].length;
else if (TREE_CODE (length) == INTEGER_CST)
{
/* 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;
}
}
}
else
/* We set the length node as the current node just in case it turns
out to be an integer. */
length = list[ii][jj].length;
}
}
return false;
}
/* If *VALUE is not a constant integer, then this function replaces it with /* If *VALUE is not a constant integer, then this function replaces it with
a variable to make it loop invariant for array notations. */ a variable to make it loop invariant for array notations. */
...@@ -744,8 +698,8 @@ expand_an_in_modify_expr (location_t location, tree lhs, ...@@ -744,8 +698,8 @@ expand_an_in_modify_expr (location_t location, tree lhs,
if (rhs_list) if (rhs_list)
cilkplus_extract_an_triplets (rhs_list, rhs_list_size, rhs_rank, cilkplus_extract_an_triplets (rhs_list, rhs_list_size, rhs_rank,
&rhs_an_info); &rhs_an_info);
if (cp_length_mismatch_in_expr_p (EXPR_LOCATION (lhs), lhs_an_info) if (length_mismatch_in_expr_p (EXPR_LOCATION (lhs), lhs_an_info)
|| (rhs_list && cp_length_mismatch_in_expr_p (EXPR_LOCATION (rhs), || (rhs_list && length_mismatch_in_expr_p (EXPR_LOCATION (rhs),
rhs_an_info))) rhs_an_info)))
{ {
pop_stmt_list (an_init); pop_stmt_list (an_init);
......
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