summaryrefslogtreecommitdiff
path: root/gcc/c-family/cilk.c
diff options
context:
space:
mode:
authorbviyer <bviyer@138bc75d-0d04-0410-961f-82ee72b054a4>2013-12-11 18:23:27 +0000
committerbviyer <bviyer@138bc75d-0d04-0410-961f-82ee72b054a4>2013-12-11 18:23:27 +0000
commit433e804e86dd7cc6234ea6d992e529938e27d47c (patch)
tree9072ab2966c9b71528a27a7a515b6a3bd19545b2 /gcc/c-family/cilk.c
parent61a1f9deac56e4b3fdccf2246e1fac24bc86f38d (diff)
downloadgcc-433e804e86dd7cc6234ea6d992e529938e27d47c.tar.gz
Added Compiler Support for _Cilk_spawn and _Cilk_sync for C++.
gcc/c-family/ChangeLog 2013-12-11 Balaji V. Iyer <balaji.v.iyer@intel.com> * cilk.c (cilk_outline): Made this function non-static. (gimplify_cilk_spawn): Removed pre_p and post_p arguments. (create_cilk_wrapper): Added a new parameter: a function pointer. (c_install_body_w_frame_cleanup): Remove (extract_free_variables): Added VEC_INIT_EXPR and CONSTRUCTOR case. * c-common.h (cilk_outline): New prototype. (gimplify_cilk_spawn): Removed two parameters. (cilk_install_body_with_frame_cleanup): New prototype. * c-gimplify.c (c_gimplify_expr): Added MODIFY_EXPR, CALL_EXPR and CILK_SPAWN_STMT case. gcc/c/ChangeLog 2013-12-11 Balaji V. Iyer <balaji.v.iyer@intel.com> * c-objc-common.h (LANG_HOOKS_CILKPLUS_FRAME_CLEANUP): Remove. (LANG_HOOKS_CILKPLUS_DETECT_SPAWN_AND_UNWRAP): Likewise. (LANG_HOOKS_CILKPLUS_CILKPLUS_GIMPLIFY_SPAWN): Likewise. * c-typeck.c (cilk_install_body_with_frame_cleanup): New function. gcc/ChangeLog 2013-12-11 Balaji V. Iyer <balaji.v.iyer@intel.com> * langhooks.h (lang_hooks_for_decls): Remove lang_hooks_for_cilkplus. (lang_hooks_for_cilkplus): Remove. * langhooks.c (lhd_cilk_detect_spawn): Likewise. (lhd_install_body_with_frame_cleanup): Likewise. * langhooks-def.h (LANG_HOOKS_CILKPLUS_FRAME_CLEANUP): Likewise. (LANG_HOOKS_CILKPLUS_DETECT_SPAWN_AND_UNWRAP): Likewise. (LANG_HOOKS_CILKPLUS_CILKPLUS_GIMPLIFY_SPAWN): Likewise. (LANG_HOOKS_CILKPLUS): Likewise. (LANG_HOOKS_DECLS): Remove LANG_HOOKS_CILKPLUS. * gimplify.c (gimplify_expr): Removed CILK_SPAWN_STMT case. (gimplify_modify_expr): Removed handling of _Cilk_spawn in expr. (gimplify_call_expr): Likewise. gcc/cp/ChangeLog 2013-12-11 Balaji V. Iyer <balaji.v.iyer@intel.com> * cp-tree.h (cilk_valid_spawn): New prototype. (gimplify_cilk_spawn): Likewise. (create_try_catch_expr): Likewise. * decl.c (finish_function): Insert Cilk function-calls when a _Cilk_spawn is used in a function. * parser.c (cp_parser_postfix_expression): Added RID_CILK_SPAWN and RID_CILK_SYNC cases. * cp-cilkplus.c (set_cilk_except_flag): New function. (set_cilk_except_data): Likewise. (cilk_install_body_with_frame_cleanup): Likewise. * except.c (create_try_catch_expr): Likewise. * parser.h (IN_CILK_SPAWN): New #define. * pt.c (tsubst_expr): Added CILK_SPAWN_STMT and CILK_SYNC_STMT cases. * semantics.c (potential_constant_expression_1): Likewise. * typeck.c (cp_build_compound_expr): Reject a spawned function in a compound expression. (check_return_expr): Reject a spawned function in a return expression. * cp-gimplify.c (cp_gimplify_expr): Added a CILK_SPAWN_STMT and CALL_EXPR case. Added handling of spawned function in MODIFY_EXPR and INIT_EXPR. gcc/testsuite/ChangeLog 2013-12-11 Balaji V. Iyer <balaji.v.iyer@intel.com> * g++.dg/cilk-plus/CK/catch_exc.cc: New test case. * g++.dg/cilk-plus/CK/const_spawn.cc: Likewise. * g++.dg/cilk-plus/CK/fib-opr-overload.cc: Likewise. * g++.dg/cilk-plus/CK/fib-tplt.cc: Likewise. * g++.dg/cilk-plus/CK/lambda_spawns.cc: Likewise. * g++.dg/cilk-plus/CK/lambda_spawns_tplt.cc: Likewise. * g++.dg/cilk-plus/cilk-plus.exp: Added support to run Cilk Keywords test stored in c-c++-common. Also, added the Cilk runtime's library to the ld_library_path. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205902 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-family/cilk.c')
-rw-r--r--gcc/c-family/cilk.c50
1 files changed, 16 insertions, 34 deletions
diff --git a/gcc/c-family/cilk.c b/gcc/c-family/cilk.c
index 99d9c7e354d..1b451723847 100644
--- a/gcc/c-family/cilk.c
+++ b/gcc/c-family/cilk.c
@@ -477,9 +477,10 @@ wrapper_local_cb (const void *k_v, void **vp, void *data)
/* Alter a tree STMT from OUTER_FN to form the body of INNER_FN. */
-static void
-cilk_outline (tree inner_fn, tree *stmt_p, struct wrapper_data *wd)
+void
+cilk_outline (tree inner_fn, tree *stmt_p, void *w)
{
+ struct wrapper_data *wd = (struct wrapper_data *) w;
const tree outer_fn = wd->context;
const bool nested = (wd->type == CILK_BLOCK_FOR);
copy_body_data id;
@@ -512,8 +513,7 @@ cilk_outline (tree inner_fn, tree *stmt_p, struct wrapper_data *wd)
/* We don't want the private variables any more. */
pointer_map_traverse (wd->decl_map, nested ? for_local_cb : wrapper_local_cb,
&id);
-
- walk_tree (stmt_p, copy_tree_body_r, &id, NULL);
+ walk_tree (stmt_p, copy_tree_body_r, (void *) &id, NULL);
/* See if this function can throw or calls something that should
not be spawned. The exception part is only necessary if
@@ -554,10 +554,8 @@ create_cilk_wrapper_body (tree stmt, struct wrapper_data *wd)
for (p = wd->parms; p; p = TREE_CHAIN (p))
DECL_CONTEXT (p) = fndecl;
- cilk_outline (fndecl, &stmt, wd);
- stmt = fold_build_cleanup_point_expr (void_type_node, stmt);
gcc_assert (!DECL_SAVED_TREE (fndecl));
- lang_hooks.cilkplus.install_body_with_frame_cleanup (fndecl, stmt);
+ cilk_install_body_with_frame_cleanup (fndecl, stmt, (void *) wd);
gcc_assert (DECL_SAVED_TREE (fndecl));
pop_cfun_to (outer);
@@ -733,8 +731,7 @@ create_cilk_wrapper (tree exp, tree *args_out)
and GS_UNHANDLED, otherwise. */
int
-gimplify_cilk_spawn (tree *spawn_p, gimple_seq *before ATTRIBUTE_UNUSED,
- gimple_seq *after ATTRIBUTE_UNUSED)
+gimplify_cilk_spawn (tree *spawn_p)
{
tree expr = *spawn_p;
tree function, call1, call2, new_args;
@@ -878,30 +875,6 @@ cilk_install_body_pedigree_operations (tree frame_ptr)
return body_list;
}
-/* Inserts "cleanup" functions after the function-body of FNDECL. FNDECL is a
- spawn-helper and BODY is the newly created body for FNDECL. */
-
-void
-c_cilk_install_body_w_frame_cleanup (tree fndecl, tree body)
-{
- tree list = alloc_stmt_list ();
- tree frame = make_cilk_frame (fndecl);
- tree dtor = create_cilk_function_exit (frame, false, true);
- add_local_decl (cfun, frame);
-
- DECL_SAVED_TREE (fndecl) = list;
- tree frame_ptr = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (frame)),
- frame);
- tree body_list = cilk_install_body_pedigree_operations (frame_ptr);
- gcc_assert (TREE_CODE (body_list) == STATEMENT_LIST);
-
- tree detach_expr = build_call_expr (cilk_detach_fndecl, 1, frame_ptr);
- append_to_statement_list (detach_expr, &body_list);
- append_to_statement_list (body, &body_list);
- append_to_statement_list (build_stmt (EXPR_LOCATION (body), TRY_FINALLY_EXPR,
- body_list, dtor), &list);
-}
-
/* Add a new variable, VAR to a variable list in WD->DECL_MAP. HOW indicates
whether the variable is previously defined, currently defined, or a variable
that is being written to. */
@@ -1062,6 +1035,7 @@ extract_free_variables (tree t, struct wrapper_data *wd,
extract_free_variables (TREE_OPERAND (t, 0), wd, ADD_READ);
return;
+ case VEC_INIT_EXPR:
case INIT_EXPR:
extract_free_variables (TREE_OPERAND (t, 0), wd, ADD_BIND);
extract_free_variables (TREE_OPERAND (t, 1), wd, ADD_READ);
@@ -1222,6 +1196,15 @@ extract_free_variables (tree t, struct wrapper_data *wd,
break;
}
+ case CONSTRUCTOR:
+ {
+ unsigned HOST_WIDE_INT idx = 0;
+ constructor_elt *ce;
+ for (idx = 0; vec_safe_iterate (CONSTRUCTOR_ELTS (t), idx, &ce); idx++)
+ extract_free_variables (ce->value, wd, ADD_READ);
+ break;
+ }
+
default:
if (is_expr)
{
@@ -1238,7 +1221,6 @@ extract_free_variables (tree t, struct wrapper_data *wd,
}
}
-
/* Add appropriate frames needed for a Cilk spawned function call, FNDECL.
Returns the __cilkrts_stack_frame * variable. */