From 9a771876d342f9cf0b64c2ceada267ff50e18206 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 2 Sep 2014 14:52:29 +0200 Subject: cilk-builtins.def (__cilkrts_cilk_for_32): New. gcc/ * cilk-builtins.def (__cilkrts_cilk_for_32): New. (__cilkrts_cilk_for_64): Likewise. * cilk-common.c (declare_cilk_for_builtin): New function. (cilk_init_builtins): Declare __cilkrts_cilk_for_32 and __cilkrts_cilk_for_64 bultins. * cilk.h (enum cilk_tree_index): Added CILK_TI_F_LOOP_32 and CILK_TI_F_LOOP_64. (cilk_for_32_fndecl): New define. (cilk_for_64_fndecl): Likewise. * gimple-pretty-print.c (dump_gimple_omp_for): Correct hadling of GF_OMP_FOR_KIND_CILKFOR cases; Added NE_EXPR case. * gimple.h (enum gf_mask): Added GF_OMP_FOR_KIND_CILKFOR; adjusted GF_OMP_FOR_KIND_MASK, GF_OMP_FOR_SIMD, GF_OMP_FOR_COMBINED, GF_OMP_FOR_COMBINED_INTO. * gimplify.c (gimplify_scan_omp_clauses): Added OMP_CLAUSE__CILK_FOR_COUNT_ case. (gimplify_adjust_omp_clauses): Ditto. (gimplify_omp_for): Added CILK_FOR case. (gimplify_expr): Ditto. * omp-low.c: Include cilk.h. (extract_omp_for_data): Set appropriate kind for GF_OMP_FOR_KIND_CILKFOR; added check for GF_OMP_FOR_KIND_CILKFOR. (scan_sharing_clauses): Added OMP_CLAUSE__CILK_FOR_COUNT_ cases. (create_omp_child_function_name): Added second argument to handle cilk_for case. (cilk_for_check_loop_diff_type): New function. (expand_cilk_for_call): Likewise. (expand_cilk_for): Likewise. (create_omp_child_function): Set cilk_for_count; handle the cases when it is true; call create_omp_child_function_name with second argument. (expand_omp_taskreg): Set is_cilk_for and handle cases when it's true. (expand_omp_for): Handle case of GF_OMP_FOR_KIND_CILKFOR. * tree-core.h (omp_clause_code): Added OMP_CLAUSE__CILK_FOR_COUNT_. * tree-nested.c (convert_nonlocal_omp_clauses): Added OMP_CLAUSE__CILK_FOR_COUNT_ case. (convert_local_omp_clauses): Ditto. * tree-pretty-print.c (dump_omp_clause): Added OMP_CLAUSE__CILK_FOR_COUNT_ and OMP_CLAUSE_SCHEDULE_CILKFOR cases. (dump_generic_node): Added CILK_FOR case. * tree.c (omp_clause_num_ops): New element OMP_CLAUSE__CILK_FOR_COUNT_ (1). (omp_clause_code_name): New element _Cilk_for_count_. (walk_tree_1): Added OMP_CLAUSE__CILK_FOR_COUNT_ case. * tree.def: Add tree code for CILK_FOR. gcc/c/ * c-parser.c (c_parser_cilk_for): New function. (c_parser_cilk_grainsize): Likewise. (c_get_temp_regvar): Likewise. (c_parser_statement_after_labels): Added RID_CILK_FOR case. (c_parser_pragma): Added PRAGMA_CILK_GRAINSIZE case. (c_parser_omp_for_loop): Added CILK_FOR and CILK_SIMD checks. * c-typeck.c (c_finish_omp_clauses): Added OMP_CLAUSE__CILK_FOR_COUNT_ case. gcc/cp/ * cp-cilkplus.c (cpp_validate_cilk_plus_loop_aux): Loc definition simplified. * parser.c (cp_parser_cilk_for): New function. (cp_parser_cilk_grainsize): Likewise. (cp_parser_statement): Added RID_CILK_FOR case. (cp_parser_omp_for_cond): Added CILK_FOR check. (cp_parser_omp_for_loop_init): Change function argument to accept tree_code instead just a bool flag; change the check to use that tree_code; check for initialization declaration in case of Cilk_for. (cp_parser_omp_for_loop): Added checks for CILK_FOR and RID_CILK_FOR; changed call to cp_parser_omp_for_loop_init according new arguments' list. (cp_parser_pragma): Added PRAGMA_CILK_GRAINSIZE case. * pt.c (tsubst_expr): Added CILK_FOR case. * semantics.c: Include convert.h. (finish_omp_clauses): Properly handle OMP_CLAUSE_SCHEDULE_CILKFOR case; added OMP_CLAUSE__CILK_FOR_COUNT_. (handle_omp_for_class_iterator): New argument lastp and its usage; added NE_EXPR case. (finish_omp_for): Changed call to handle_omp_for_class_iterator according new arguments' list; in case of Cilk_for save very first decl and create empty stmt_list block; use block to build correct statement tree. gcc/c-family/ * c-cilkplus.c (cilk_for_number_of_iterations): New function. * c-common.c (c_common_reswords): Added _Cilk_for. * c-common.h (enum rid): Added RID_CILK_FOR. (cilk_for_number_of_iterations): Add declaration. * c-omp.c (c_finish_omp_for): Added checks for CILK_SIMD and CILK_FOR. * c-pragma.c (init_pragma): Register "grainsize" pragma. * c-pragma.h (enum pragma_kind): Add PRAGMA_CILK_GRAINSIZE. gcc/testsuite/ * c-c++-common/cilk-plus/CK/cilk-fors.c: New test. * c-c++-common/cilk-plus/CK/cilk-for-2.c: New test. * c-c++-common/cilk-plus/CK/cilk-for-3.c: New test. * c-c++-common/cilk-plus/CK/cilk_for_errors.c: New test. * c-c++-common/cilk-plus/CK/cilk_for_grain.c: New test. * c-c++-common/cilk-plus/CK/cilk_for_grain_errors.c: New test. * c-c++-common/cilk-plus/CK/cilk_for_ptr_iter.c: New test. * c-c++-common/cilk-plus/CK/nested_cilk_for.c: New test. * g++.dg/cilk-plus/CK/cf3.cc: New test. * g++.dg/cilk-plus/CK/cilk-for-tplt.cc: New test. * g++.dg/cilk-plus/CK/for1.cc: New test. * g++.dg/cilk-plus/CK/stl_iter.cc: New test. * g++.dg/cilk-plus/CK/stl_rev_iter.cc: New test. * g++.dg/cilk-plus/CK/stl_test.cc: New test. Co-Authored-By: Balaji V. Iyer Co-Authored-By: Igor Zamyatin From-SVN: r214818 --- gcc/cilk-common.c | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) (limited to 'gcc/cilk-common.c') diff --git a/gcc/cilk-common.c b/gcc/cilk-common.c index a6a1aa2..35c47e1 100644 --- a/gcc/cilk-common.c +++ b/gcc/cilk-common.c @@ -105,6 +105,27 @@ install_builtin (const char *name, tree fntype, enum built_in_function code, return fndecl; } +/* Returns a FUNCTION_DECL of type TYPE whose name is *NAME. */ + +static tree +declare_cilk_for_builtin (const char *name, tree type, + enum built_in_function code) +{ + tree cb, ft, fn; + + cb = build_function_type_list (void_type_node, + ptr_type_node, type, type, + NULL_TREE); + cb = build_pointer_type (cb); + ft = build_function_type_list (void_type_node, + cb, ptr_type_node, type, + integer_type_node, NULL_TREE); + fn = install_builtin (name, ft, code, false); + TREE_NOTHROW (fn) = 0; + + return fn; +} + /* Creates and initializes all the built-in Cilk keywords functions and three structures: __cilkrts_stack_frame, __cilkrts_pedigree and __cilkrts_worker. Detailed information about __cilkrts_stack_frame and @@ -119,7 +140,7 @@ cilk_init_builtins (void) uint64_t rank; struct __cilkrts_pedigree *parent; } */ - + tree pedigree_type = lang_hooks.types.make_type (RECORD_TYPE); tree pedigree_ptr = build_pointer_type (pedigree_type); tree field = add_field ("rank", uint64_type_node, NULL_TREE); @@ -131,7 +152,7 @@ cilk_init_builtins (void) lang_hooks.types.register_builtin_type (pedigree_type, "__cilkrts_pedigree_t"); cilk_pedigree_type_decl = pedigree_type; - + /* Build the Cilk Stack Frame: struct __cilkrts_stack_frame { uint32_t flags; @@ -212,7 +233,7 @@ cilk_init_builtins (void) tree sysdep_t = lang_hooks.types.make_type (RECORD_TYPE); finish_builtin_struct (sysdep_t, "__cilkrts_worker_sysdep_state", NULL_TREE, NULL_TREE); - + field = add_field ("tail", fptr_vol_ptr_vol, NULL_TREE); cilk_trees[CILK_TI_WORKER_TAIL] = field; field = add_field ("head", fptr_vol_ptr_vol, field); @@ -234,16 +255,16 @@ cilk_init_builtins (void) tree fptr_arglist = tree_cons (NULL_TREE, frame_ptr, void_list_node); tree fptr_fun = build_function_type (void_type_node, fptr_arglist); - + /* void __cilkrts_enter_frame_1 (__cilkrts_stack_frame *); */ cilk_enter_fndecl = install_builtin ("__cilkrts_enter_frame_1", fptr_fun, BUILT_IN_CILK_ENTER_FRAME, false); /* void __cilkrts_enter_frame_fast_1 (__cilkrts_stack_frame *); */ cilk_enter_fast_fndecl = - install_builtin ("__cilkrts_enter_frame_fast_1", fptr_fun, + install_builtin ("__cilkrts_enter_frame_fast_1", fptr_fun, BUILT_IN_CILK_ENTER_FRAME_FAST, false); - + /* void __cilkrts_pop_frame (__cilkrts_stack_frame *); */ cilk_pop_fndecl = install_builtin ("__cilkrts_pop_frame", fptr_fun, BUILT_IN_CILK_POP_FRAME, false); @@ -261,14 +282,22 @@ cilk_init_builtins (void) BUILT_IN_CILK_DETACH, false); /* __cilkrts_rethrow (struct stack_frame *); */ - cilk_rethrow_fndecl = install_builtin ("__cilkrts_rethrow", fptr_fun, + cilk_rethrow_fndecl = install_builtin ("__cilkrts_rethrow", fptr_fun, BUILT_IN_CILK_RETHROW, false); TREE_NOTHROW (cilk_rethrow_fndecl) = 0; /* __cilkrts_save_fp_ctrl_state (__cilkrts_stack_frame *); */ - cilk_save_fp_fndecl = install_builtin ("__cilkrts_save_fp_ctrl_state", + cilk_save_fp_fndecl = install_builtin ("__cilkrts_save_fp_ctrl_state", fptr_fun, BUILT_IN_CILK_SAVE_FP, false); + /* __cilkrts_cilk_for_32 (...); */ + cilk_for_32_fndecl = declare_cilk_for_builtin ("__cilkrts_cilk_for_32", + unsigned_intSI_type_node, + BUILT_IN_CILK_FOR_32); + /* __cilkrts_cilk_for_64 (...); */ + cilk_for_64_fndecl = declare_cilk_for_builtin ("__cilkrts_cilk_for_64", + unsigned_intDI_type_node, + BUILT_IN_CILK_FOR_64); } /* Get the appropriate frame arguments for CALL that is of type CALL_EXPR. */ -- cgit v1.1