diff options
author | Julia Koval <julia.koval@intel.com> | 2017-11-28 11:35:37 +0100 |
---|---|---|
committer | Julia Koval <jkoval@gcc.gnu.org> | 2017-11-28 11:35:37 +0100 |
commit | 5e9d6aa4c2fd245837ec26de1d01ee8eb7786af3 (patch) | |
tree | 193e05dc5baa657f44264efe9cf165e8572a0ccc /gcc/c-family | |
parent | 1be49a38e45a80d1ee6854f262c94abeb621dfda (diff) | |
download | gcc-5e9d6aa4c2fd245837ec26de1d01ee8eb7786af3.zip gcc-5e9d6aa4c2fd245837ec26de1d01ee8eb7786af3.tar.gz gcc-5e9d6aa4c2fd245837ec26de1d01ee8eb7786af3.tar.bz2 |
Remove Cilk Plus support.
* Makefile.def (target_modules): Remove libcilkrts.
* Makefile.in: Ditto.
* configure: Ditto.
* configure.ac: Ditto.
contrib/
* contrib/gcc_update: Ditto.
gcc/
* Makefile.in (cilkplus.def, cilk-builtins.def, c-family/cilk.o,
c-family/c-cilkplus.o, c-family/array-notation-common.o,
cilk-common.o, cilk.h, cilk-common.c): Remove.
* builtin-types.def
(BT_FN_INT_PTR_PTR_PTR_FTYPE_BT_INT_BT_PTR_BT_PTR_BT_PTR): Remove.
* builtins.c (is_builtin_name): Remove cilkplus condition.
(BUILT_IN_CILK_DETACH, BUILT_IN_CILK_POP_FRAME): Remove.
* builtins.def (DEF_CILK_BUILTIN_STUB, DEF_CILKPLUS_BUILTIN,
cilk-builtins.def, cilkplus.def): Remove.
* cif-code.def (CILK_SPAWN): Remove.
* cilk-builtins.def: Delete.
* cilk-common.c: Ditto.
* cilk.h: Ditto.
* cilkplus.def: Ditto.
* config/darwin.h (fcilkplus): Delete.
* cppbuiltin.c: Ditto.
* doc/extend.texi: Remove cilkplus doc.
* doc/generic.texi: Ditto.
* doc/invoke.texi: Ditto.
* doc/passes.texi: Ditto.
* gcc.c (fcilkplus): Remove.
* gengtype.c (cilk.h): Remove.
* gimple-pretty-print.c (dump_gimple_omp_for): Remove cilkplus support.
* gimple.h (GF_OMP_FOR_KIND_CILKFOR, GF_OMP_FOR_KIND_CILKSIMD): Remove.
* gimplify.c (gimplify_return_expr, maybe_fold_stmt,
gimplify_call_expr, is_gimple_stmt, gimplify_modify_expr,
gimplify_scan_omp_clauses, gimplify_adjust_omp_clauses,
gimplify_omp_for, gimplify_expr): Remove cilkplus conditions.
* ipa-fnsummary.c (ipa_dump_fn_summary, compute_fn_summary,
inline_read_section): Ditto.
* ipa-inline-analysis.c (cilk.h): Remove.
* ira.c (ira_setup_eliminable_regset): Remove cilkplus support.
* lto-wrapper.c (merge_and_complain, append_compiler_options,
append_linker_options): Remove condition for fcilkplus.
* lto/lto-lang.c (cilk.h): Remove.
(lto_init): Remove condition for fcilkplus.
* omp-expand.c (expand_cilk_for_call): Delete.
(expand_omp_taskreg, expand_omp_for_static_chunk,
expand_omp_for): Remove cilkplus
conditions.
(expand_cilk_for): Delete.
* omp-general.c (omp_extract_for_data): Remove cilkplus support.
* omp-low.c (scan_sharing_clauses, create_omp_child_function,
execute_lower_omp, diagnose_sb_0): Ditto.
* omp-simd-clone.c (simd_clone_clauses_extract): Ditto.
* tree-core.h (OMP_CLAUSE__CILK_FOR_COUNT_): Delete.
* tree-nested.c: Ditto.
* tree-pretty-print.c (dump_omp_clause): Remove cilkplus support.
(dump_generic_node): Ditto.
* tree.c (OMP_CLAUSE__CILK_FOR_COUNT_): Delete.
* tree.def (cilk_simd, cilk_for, cilk_spawn_stmt,
cilk_sync_stmt): Delete.
* tree.h (CILK_SPAWN_FN, EXPR_CILK_SPAWN): Delete.
gcc/c-family/
* array-notation-common.c: Delete.
* c-cilkplus.c: Ditto.
* c-common.c (_Cilk_spawn, _Cilk_sync, _Cilk_for): Remove.
* c-common.def (ARRAY_NOTATION_REF): Remove.
* c-common.h (RID_CILK_SPAWN, build_array_notation_expr,
build_array_notation_ref, C_ORT_CILK, c_check_cilk_loop,
c_validate_cilk_plus_loop, cilkplus_an_parts,
cilk_ignorable_spawn_rhs_op,
cilk_recognize_spawn): Remove.
* c-gimplify.c (CILK_SPAWN_STMT): Remove.
* c-omp.c: Remove CILK_SIMD check.
* c-pragma.c: Ditto.
* c-pragma.h: Remove CILK related pragmas.
* c-pretty-print.c (c_pretty_printer::postfix_expression): Remove
ARRAY_NOTATION_REF condition.
(c_pretty_printer::expression): Ditto.
* c.opt (fcilkplus): Remove.
* cilk.c: Delete.
gcc/c/
* Make-lang.in (c/c-array-notation.o): Remove.
* c-array-notation.c: Delete.
* c-decl.c: Remove cilkplus condition.
* c-parser.c (c_parser_cilk_simd, c_parser_cilk_for,
c_parser_cilk_verify_simd, c_parser_array_notation,
c_parser_cilk_clause_vectorlength, c_parser_cilk_grainsize,
c_parser_cilk_simd_fn_vector_attrs,
c_finish_cilk_simd_fn_tokens): Delete.
(c_parser_declaration_or_fndef): Remove cilkplus condition.
(c_parser_direct_declarator_inner): Ditto.
(CILK_SIMD_FN_CLAUSE_MASK): Delete.
(c_parser_attributes, c_parser_compound_statement,
c_parser_statement_after_labels, c_parser_if_statement,
c_parser_switch_statement, c_parser_while_statement,
c_parser_do_statement, c_parser_for_statement,
c_parser_unary_expression, c_parser_postfix_expression,
c_parser_postfix_expression_after_primary,
c_parser_pragma, c_parser_omp_clause_name, c_parser_omp_all_clauses,
c_parser_omp_for_loop,
c_finish_omp_declare_simd): Remove cilkplus support.
* c-typeck.c (build_array_ref, build_function_call_vec,
convert_arguments, lvalue_p, build_compound_expr, c_finish_return,
c_finish_if_stmt, c_finish_loop,
build_binary_op): Remove cilkplus support.
gcc/cp/
* Make-lang.in (cp/cp-array-notation.o, cp/cp-cilkplus.o): Delete.
* call.c (convert_for_arg_passing, build_cxx_call): Remove cilkplus.
* constexpr.c (potential_constant_expression_1): Ditto.
* cp-array-notation.c: Delete.
* cp-cilkplus.c: Ditto.
* cp-cilkplus.h: Ditto.
* cp-gimplify.c (cp_gimplify_expr, cp_fold_r, cp_genericize): Remove
cilkplus condition.
* cp-objcp-common.c (ARRAY_NOTATION_REF): Delete.
* cp-tree.h (cilkplus_an_triplet_types_ok_p): Delete.
* decl.c (grokfndecl, finish_function): Remove cilkplus condition.
* error.c (dump_decl, dump_expr): Remove ARRAY_NOTATION_REF condition.
* lambda.c (cp-cilkplus.h): Remove.
* parser.c (cp_parser_cilk_simd, cp_parser_cilk_for,
cp_parser_cilk_simd_vectorlength): Delete.
(cp_debug_parser, cp_parser_ctor_initializer_opt_and_function_body,
cp_parser_postfix_expression, cp_parser_postfix_open_square_expression,
cp_parser_statement, cp_parser_jump_statement,
cp_parser_direct_declarator,
cp_parser_late_return_type_opt, cp_parser_gnu_attribute_list,
cp_parser_omp_clause_name, cp_parser_omp_clause_aligned,
cp_parser_omp_clause_linear, cp_parser_omp_all_clauses,
cp_parser_omp_flush, cp_parser_omp_for_cond, cp_parser_omp_for_incr,
cp_parser_omp_for_loop_init, cp_parser_omp_for_loop,
cp_parser_omp_declare_simd): Remove cilkplus support.
(CILK_SIMD_FN_CLAUSE_MASK, cp_parser_late_parsing_cilk_simd_fn_info,
cp_parser_cilk_grainsize): Remove.
(cp_parser_pragma, c_parse_file): Remove cilkplus support.
(cp_parser_cilk_simd_vectorlength, cp_parser_cilk_simd_linear,
cp_parser_cilk_simd_clause_name, cp_parser_cilk_simd_all_clauses,
cp_parser_cilk_simd, cp_parser_cilk_for): Remove.
* parser.h (IN_CILK_SIMD_FOR, IN_CILK_SPAWN): Remove.
* pt.c (tsubst_attribute, tsubst_expr, tsubst_copy_and_build): Remove
cilkplus support.
* semantics.c (finish_goto_stmt, begin_while_stmt, finish_do_body,
finish_init_stmt, finish_switch_cond, simplify_aggr_init_expr,
finish_omp_clauses, finish_omp_clauses,
finish_omp_for): Remove cilkplus support.
* tree.c (lvalue_kind): Remove ARRAY_NOTATION_REF conditon.
* typeck.c (cp_build_array_ref, cp_build_compound_expr,
check_return_expr): Remove cilkplus support.
gcc/testsuite/
* c-c++-common/attr-simd-3.c: Delete.
* c-c++-common/cilk-plus/AN/an-if.c: Delete.
* c-c++-common/cilk-plus/AN/array_test1.c: Delete.
* c-c++-common/cilk-plus/AN/array_test2.c: Delete.
* c-c++-common/cilk-plus/AN/array_test_ND.c: Delete.
* c-c++-common/cilk-plus/AN/builtin_fn_custom.c: Delete.
* c-c++-common/cilk-plus/AN/builtin_fn_mutating.c: Delete.
* c-c++-common/cilk-plus/AN/builtin_func_double.c: Delete.
* c-c++-common/cilk-plus/AN/builtin_func_double2.c: Delete.
* c-c++-common/cilk-plus/AN/comma_exp.c: Delete.
* c-c++-common/cilk-plus/AN/conditional.c: Delete.
* c-c++-common/cilk-plus/AN/decl-ptr-colon.c: Delete.
* c-c++-common/cilk-plus/AN/dimensionless-arrays.c: Delete.
* c-c++-common/cilk-plus/AN/exec-once.c: Delete.
* c-c++-common/cilk-plus/AN/exec-once2.c: Delete.
* c-c++-common/cilk-plus/AN/fn_ptr-2.c: Delete.
* c-c++-common/cilk-plus/AN/fn_ptr.c: Delete.
* c-c++-common/cilk-plus/AN/fp_triplet_values.c: Delete.
* c-c++-common/cilk-plus/AN/gather-scatter-errors.c: Delete.
* c-c++-common/cilk-plus/AN/gather_scatter.c: Delete.
* c-c++-common/cilk-plus/AN/if_test.c: Delete.
* c-c++-common/cilk-plus/AN/if_test_errors.c: Delete.
* c-c++-common/cilk-plus/AN/misc.c: Delete.
* c-c++-common/cilk-plus/AN/n-ptr-test.c: Delete.
* c-c++-common/cilk-plus/AN/parser_errors.c: Delete.
* c-c++-common/cilk-plus/AN/parser_errors2.c: Delete.
* c-c++-common/cilk-plus/AN/parser_errors3.c: Delete.
* c-c++-common/cilk-plus/AN/parser_errors4.c: Delete.
* c-c++-common/cilk-plus/AN/pr57457-2.c: Delete.
* c-c++-common/cilk-plus/AN/pr57457.c: Delete.
* c-c++-common/cilk-plus/AN/pr57490.c: Delete.
* c-c++-common/cilk-plus/AN/pr57541-2.c: Delete.
* c-c++-common/cilk-plus/AN/pr57541.c: Delete.
* c-c++-common/cilk-plus/AN/pr57577.c: Delete.
* c-c++-common/cilk-plus/AN/pr58942.c: Delete.
* c-c++-common/cilk-plus/AN/pr61191.c: Delete.
* c-c++-common/cilk-plus/AN/pr61455-2.c: Delete.
* c-c++-common/cilk-plus/AN/pr61455.c: Delete.
* c-c++-common/cilk-plus/AN/pr61962.c: Delete.
* c-c++-common/cilk-plus/AN/pr61963.c: Delete.
* c-c++-common/cilk-plus/AN/pr62008.c: Delete.
* c-c++-common/cilk-plus/AN/pr63884.c: Delete.
* c-c++-common/cilk-plus/AN/rank_mismatch.c: Delete.
* c-c++-common/cilk-plus/AN/rank_mismatch2.c: Delete.
* c-c++-common/cilk-plus/AN/rank_mismatch3.c: Delete.
* c-c++-common/cilk-plus/AN/sec_implicit.c: Delete.
* c-c++-common/cilk-plus/AN/sec_implicit2.c: Delete.
* c-c++-common/cilk-plus/AN/sec_implicit_ex.c: Delete.
* c-c++-common/cilk-plus/AN/sec_reduce_ind_same_value.c: Delete.
* c-c++-common/cilk-plus/AN/sec_reduce_max_min_ind.c: Delete.
* c-c++-common/cilk-plus/AN/sec_reduce_return.c: Delete.
* c-c++-common/cilk-plus/AN/side-effects-1.c: Delete.
* c-c++-common/cilk-plus/AN/test_builtin_return.c: Delete.
* c-c++-common/cilk-plus/AN/test_sec_limits.c: Delete.
* c-c++-common/cilk-plus/AN/tst_lngth.c: Delete.
* c-c++-common/cilk-plus/AN/vla.c: Delete.
* c-c++-common/cilk-plus/CK/Wparentheses-1.c: Delete.
* c-c++-common/cilk-plus/CK/cilk-for-2.c: Delete.
* c-c++-common/cilk-plus/CK/cilk-for-3.c: Delete.
* c-c++-common/cilk-plus/CK/cilk-fors.c: Delete.
* c-c++-common/cilk-plus/CK/cilk_for_errors.c: Delete.
* c-c++-common/cilk-plus/CK/cilk_for_grain.c: Delete.
* c-c++-common/cilk-plus/CK/cilk_for_grain_errors.c: Delete.
* c-c++-common/cilk-plus/CK/cilk_for_ptr_iter.c: Delete.
* c-c++-common/cilk-plus/CK/compound_cilk_spawn.c: Delete.
* c-c++-common/cilk-plus/CK/concec_cilk_spawn.c: Delete.
* c-c++-common/cilk-plus/CK/errors.c: Delete.
* c-c++-common/cilk-plus/CK/fib.c: Delete.
* c-c++-common/cilk-plus/CK/fib_init_expr_xy.c: Delete.
* c-c++-common/cilk-plus/CK/fib_no_return.c: Delete.
* c-c++-common/cilk-plus/CK/fib_no_sync.c: Delete.
* c-c++-common/cilk-plus/CK/invalid_spawns.c: Delete.
* c-c++-common/cilk-plus/CK/invalid_sync.c: Delete.c
* c-c++-common/cilk-plus/CK/nested_cilk_for.c: Delete.
* c-c++-common/cilk-plus/CK/no_args_error.c: Delete.
* c-c++-common/cilk-plus/CK/pr59631.c: Delete.
* c-c++-common/cilk-plus/CK/pr60197-2.c: Delete.
* c-c++-common/cilk-plus/CK/pr60197.c: Delete.
* c-c++-common/cilk-plus/CK/pr60469.c: Delete.
* c-c++-common/cilk-plus/CK/pr60586.c: Delete.
* c-c++-common/cilk-plus/CK/pr63307.c: Delete.
* c-c++-common/cilk-plus/CK/pr69826-1.c: Delete.
* c-c++-common/cilk-plus/CK/pr69826-2.c: Delete.
* c-c++-common/cilk-plus/CK/pr79428-4.c: Delete.
* c-c++-common/cilk-plus/CK/pr79428-7.c: Delete.
* c-c++-common/cilk-plus/CK/spawn_in_return.c: Delete.
* c-c++-common/cilk-plus/CK/spawnee_inline.c: Delete.
* c-c++-common/cilk-plus/CK/spawner_inline.c: Delete.
* c-c++-common/cilk-plus/CK/spawning_arg.c: Delete.
* c-c++-common/cilk-plus/CK/steal_check.c: Delete.
* c-c++-common/cilk-plus/CK/sync_wo_spawn.c: Delete.
* c-c++-common/cilk-plus/CK/test__cilk.c: Delete.
* c-c++-common/cilk-plus/CK/varargs_test.c: Delete.
* c-c++-common/cilk-plus/PS/Wparentheses-1.c: Delete.
* c-c++-common/cilk-plus/PS/body.c: Delete.
* c-c++-common/cilk-plus/PS/clauses1.c: Delete.
* c-c++-common/cilk-plus/PS/clauses2.c: Delete.
* c-c++-common/cilk-plus/PS/clauses3.c: Delete.
* c-c++-common/cilk-plus/PS/clauses4.c: Delete.
* c-c++-common/cilk-plus/PS/for1.c: Delete.
* c-c++-common/cilk-plus/PS/for2.c: Delete.
* c-c++-common/cilk-plus/PS/for3.c: Delete.
* c-c++-common/cilk-plus/PS/pr69363.c: Delete.
* c-c++-common/cilk-plus/PS/reduction-1.c: Delete.
* c-c++-common/cilk-plus/PS/reduction-2.c: Delete.
* c-c++-common/cilk-plus/PS/reduction-3.c: Delete.
* c-c++-common/cilk-plus/PS/run-1.c: Delete.
* c-c++-common/cilk-plus/PS/safelen.c: Delete.
* c-c++-common/cilk-plus/PS/vectorlength-2.c: Delete.
* c-c++-common/cilk-plus/PS/vectorlength-3.c: Delete.
* c-c++-common/cilk-plus/PS/vectorlength.c: Delete.
* c-c++-common/cilk-plus/SE/ef_error.c: Delete.
* c-c++-common/cilk-plus/SE/ef_error2.c: Delete.
* c-c++-common/cilk-plus/SE/ef_error3.c: Delete.
* c-c++-common/cilk-plus/SE/ef_test.c: Delete.
* c-c++-common/cilk-plus/SE/ef_test2.c: Delete.
* c-c++-common/cilk-plus/SE/vlength_errors.c: Delete.
* g++.dg/cilk-plus/AN/array_function.c: Delete.
* g++.dg/cilk-plus/AN/array_test1_tplt.c: Delete.
* g++.dg/cilk-plus/AN/array_test2_tplt.c: Delete.
* g++.dg/cilk-plus/AN/array_test_ND_tplt.c: Delete.
* g++.dg/cilk-plus/AN/braced_list.c: Delete.
* g++.dg/cilk-plus/AN/builtin_fn_custom_tplt.c: Delete.
* g++.dg/cilk-plus/AN/builtin_fn_mutating_tplt.c: Delete.
* g++.dg/cilk-plus/AN/fp_triplet_values_tplt.c: Delete.
* g++.dg/cilk-plus/AN/postincr_test.c: Delete.
* g++.dg/cilk-plus/AN/preincr_test.c: Delete.
* g++.dg/cilk-plus/CK/catch_exc.c: Delete.
* g++.dg/cilk-plus/CK/cf3.c: Delete.
* g++.dg/cilk-plus/CK/cilk-for-tplt.c: Delete.
* g++.dg/cilk-plus/CK/const_spawn.c: Delete.
* g++.dg/cilk-plus/CK/fib-opr-overload.c: Delete.
* g++.dg/cilk-plus/CK/fib-tplt.c: Delete.
* g++.dg/cilk-plus/CK/for1.c: Delete.
* g++.dg/cilk-plus/CK/lambda_spawns.c: Delete.
* g++.dg/cilk-plus/CK/lambda_spawns_tplt.c: Delete.
* g++.dg/cilk-plus/CK/pr60586.c: Delete.
* g++.dg/cilk-plus/CK/pr66326.c: Delete.
* g++.dg/cilk-plus/CK/pr68001.c: Delete.
* g++.dg/cilk-plus/CK/pr68997.c: Delete.
* g++.dg/cilk-plus/CK/pr69024.c: Delete.
* g++.dg/cilk-plus/CK/pr69048.c: Delete.
* g++.dg/cilk-plus/CK/pr69267.c: Delete.
* g++.dg/cilk-plus/CK/pr80038.c: Delete.
* g++.dg/cilk-plus/CK/stl_iter.c: Delete.
* g++.dg/cilk-plus/CK/stl_rev_iter.c: Delete.
* g++.dg/cilk-plus/CK/stl_test.c: Delete.
* g++.dg/cilk-plus/cilk-plus.exp
* g++.dg/cilk-plus/ef_test.C: Delete.
* g++.dg/cilk-plus/for.C: Delete.
* g++.dg/cilk-plus/for2.C: Delete.
* g++.dg/cilk-plus/for3.C: Delete.
* g++.dg/cilk-plus/for4.C: Delete.
* g++.dg/cilk-plus/pr60967.C: Delete.
* g++.dg/cilk-plus/pr69028.C: Delete.
* g++.dg/cilk-plus/pr70565.C: Delete.
* g++.dg/pr57662.C: Delete.
* gcc.dg/cilk-plus/cilk-plus.exp
* gcc.dg/cilk-plus/for1.c: Delete.
* gcc.dg/cilk-plus/for2.c: Delete.
* gcc.dg/cilk-plus/jump-openmp.c: Delete.
* gcc.dg/cilk-plus/jump.c: Delete.
* gcc.dg/cilk-plus/pr69798-1.c: Delete.
* gcc.dg/cilk-plus/pr69798-2.c: Delete.
* gcc.dg/cilk-plus/pr78306.c: Delete.
* gcc.dg/cilk-plus/pr79116.c: Delete.
* gcc.dg/graphite/id-28.c: Delete.
* lib/cilk-plus-dg.exp: Delete.
* lib/target-supports.exp (cilkplus_runtime): Delete.
Co-Authored-By: Sebastian Peryt <sebastian.peryt@intel.com>
From-SVN: r255195
Diffstat (limited to 'gcc/c-family')
-rw-r--r-- | gcc/c-family/ChangeLog | 22 | ||||
-rw-r--r-- | gcc/c-family/array-notation-common.c | 689 | ||||
-rw-r--r-- | gcc/c-family/c-cilkplus.c | 175 | ||||
-rw-r--r-- | gcc/c-family/c-common.c | 7 | ||||
-rw-r--r-- | gcc/c-family/c-common.def | 7 | ||||
-rw-r--r-- | gcc/c-family/c-common.h | 94 | ||||
-rw-r--r-- | gcc/c-family/c-gimplify.c | 20 | ||||
-rw-r--r-- | gcc/c-family/c-omp.c | 9 | ||||
-rw-r--r-- | gcc/c-family/c-pragma.c | 22 | ||||
-rw-r--r-- | gcc/c-family/c-pragma.h | 20 | ||||
-rw-r--r-- | gcc/c-family/c-pretty-print.c | 12 | ||||
-rw-r--r-- | gcc/c-family/c.opt | 4 | ||||
-rw-r--r-- | gcc/c-family/cilk.c | 1363 |
13 files changed, 30 insertions, 2414 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 08d8cec..ce966bb 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,25 @@ +2017-11-28 Julia Koval <julia.koval@intel.com> + Sebastian Peryt <sebastian.peryt@intel.com> + + * array-notation-common.c: Delete. + * c-cilkplus.c: Ditto. + * c-common.c (_Cilk_spawn, _Cilk_sync, _Cilk_for): Remove. + * c-common.def (ARRAY_NOTATION_REF): Remove. + * c-common.h (RID_CILK_SPAWN, build_array_notation_expr, + build_array_notation_ref, C_ORT_CILK, c_check_cilk_loop, + c_validate_cilk_plus_loop, cilkplus_an_parts, + cilk_ignorable_spawn_rhs_op, + cilk_recognize_spawn): Remove. + * c-gimplify.c (CILK_SPAWN_STMT): Remove. + * c-omp.c: Remove CILK_SIMD check. + * c-pragma.c: Ditto. + * c-pragma.h: Remove CILK related pragmas. + * c-pretty-print.c (c_pretty_printer::postfix_expression): Remove + ARRAY_NOTATION_REF condition. + (c_pretty_printer::expression): Ditto. + * c.opt (fcilkplus): Remove. + * cilk.c: Delete. + 2017-11-21 Marc Glisse <marc.glisse@inria.fr> * c-pretty-print.c (pp_c_additive_expression, diff --git a/gcc/c-family/array-notation-common.c b/gcc/c-family/array-notation-common.c deleted file mode 100644 index a480994..0000000 --- a/gcc/c-family/array-notation-common.c +++ /dev/null @@ -1,689 +0,0 @@ -/* This file is part of the Intel(R) Cilk(TM) Plus support - This file contains the builtin functions for Array - notations. - Copyright (C) 2013-2017 Free Software Foundation, Inc. - Contributed by Balaji V. Iyer <balaji.v.iyer@intel.com>, - Intel Corporation - -This file is part of GCC. - -GCC is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 3, or (at your option) -any later version. - -GCC is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GCC; see the file COPYING3. If not see -<http://www.gnu.org/licenses/>. */ - -#include "config.h" -#include "system.h" -#include "coretypes.h" -#include "options.h" -#include "c-family/c-common.h" -#include "tree-iterator.h" -#include "stringpool.h" -#include "attribs.h" - -/* Returns true if the function call in FNDECL is __sec_implicit_index. */ - -bool -is_sec_implicit_index_fn (tree fndecl) -{ - if (!fndecl) - return false; - - if (TREE_CODE (fndecl) == ADDR_EXPR) - fndecl = TREE_OPERAND (fndecl, 0); - - return - (TREE_CODE (fndecl) == FUNCTION_DECL - && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL - && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CILKPLUS_SEC_IMPLICIT_INDEX); -} - -/* Returns the first and only argument for FN, which should be a - sec_implicit_index function. FN's location in the source file is as - indicated by LOCATION. The argument to FN must be a constant integer - expression, otherwise returns -1. */ - -HOST_WIDE_INT -extract_sec_implicit_index_arg (location_t location, tree fn) -{ - tree fn_arg; - HOST_WIDE_INT return_int = 0; - - if (TREE_CODE (fn) == CALL_EXPR) - { - fn_arg = CALL_EXPR_ARG (fn, 0); - if (TREE_CODE (fn_arg) == INTEGER_CST) - return_int = int_cst_value (fn_arg); - else - { - /* If the location is unknown, and if fn has a location, then use that - information so that the user has a better idea where the error - could be. */ - if (location == UNKNOWN_LOCATION && EXPR_HAS_LOCATION (fn)) - location = EXPR_LOCATION (fn); - error_at (location, "__sec_implicit_index parameter must be an " - "integer constant expression"); - return -1; - } - } - return return_int; -} - -/* 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. */ - -bool -length_mismatch_in_expr_p (location_t loc, vec<vec<an_parts> >list) -{ - size_t ii, jj; - tree length = NULL_TREE; - - 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 - && !tree_int_cst_equal (list[ii][jj].length, length)) - { - 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; -} - -/* Given an FNDECL of type FUNCTION_DECL or ADDR_EXPR, return the corresponding - BUILT_IN_CILKPLUS_SEC_REDUCE_* being called. If none, return - BUILT_IN_NONE. */ - -enum built_in_function -is_cilkplus_reduce_builtin (tree fndecl) -{ - if (!fndecl) - return BUILT_IN_NONE; - if (TREE_CODE (fndecl) == ADDR_EXPR) - fndecl = TREE_OPERAND (fndecl, 0); - - if (TREE_CODE (fndecl) == FUNCTION_DECL - && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL) - switch (DECL_FUNCTION_CODE (fndecl)) - { - case BUILT_IN_CILKPLUS_SEC_REDUCE_ADD: - case BUILT_IN_CILKPLUS_SEC_REDUCE_MUL: - case BUILT_IN_CILKPLUS_SEC_REDUCE_ALL_ZERO: - case BUILT_IN_CILKPLUS_SEC_REDUCE_ANY_ZERO: - case BUILT_IN_CILKPLUS_SEC_REDUCE_MAX: - case BUILT_IN_CILKPLUS_SEC_REDUCE_MIN: - case BUILT_IN_CILKPLUS_SEC_REDUCE_MIN_IND: - case BUILT_IN_CILKPLUS_SEC_REDUCE_MAX_IND: - case BUILT_IN_CILKPLUS_SEC_REDUCE_ANY_NONZERO: - case BUILT_IN_CILKPLUS_SEC_REDUCE_ALL_NONZERO: - case BUILT_IN_CILKPLUS_SEC_REDUCE: - case BUILT_IN_CILKPLUS_SEC_REDUCE_MUTATING: - return DECL_FUNCTION_CODE (fndecl); - default: - break; - } - - return BUILT_IN_NONE; -} - -/* This function will recurse into EXPR finding any - ARRAY_NOTATION_EXPRs and calculate the overall rank of EXPR, - storing it in *RANK. LOC is the location of the original expression. - - ORIG_EXPR is the original expression used to display if any rank - mismatch errors are found. - - Upon entry, *RANK must be either 0, or the rank of a parent - expression that must have the same rank as the one being - calculated. It is illegal to have multiple array notation with different - rank in the same expression (see examples below for clarification). - - If there were any rank mismatches while calculating the rank, an - error will be issued, and FALSE will be returned. Otherwise, TRUE - is returned. - - If IGNORE_BUILTIN_FN is TRUE, ignore array notation specific - built-in functions (__sec_reduce_*, etc). - - Here are some examples of array notations and their rank: - - Expression RANK - 5 0 - X (a variable) 0 - *Y (a pointer) 0 - A[5] 0 - B[5][10] 0 - A[:] 1 - B[0:10] 1 - C[0:10:2] 1 - D[5][0:10:2] 1 (since D[5] is considered "scalar") - D[5][:][10] 1 - E[:] + 5 1 - F[:][:][:] + 5 + X 3 - F[:][:][:] + E[:] + 5 + X RANKMISMATCH-ERROR since rank (E[:]) = 1 and - rank (F[:][:][:]) = 3. They must be equal - or have a rank of zero. - F[:][5][10] + E[:] * 5 + *Y 1 - - int func (int); - func (A[:]) 1 - func (B[:][:][:][:]) 4 - - int func2 (int, int) - func2 (A[:], B[:][:][:][:]) RANKMISMATCH-ERROR -- Since Rank (A[:]) = 1 - and Rank (B[:][:][:][:]) = 4 - - A[:] + func (B[:][:][:][:]) RANKMISMATCH-ERROR - func2 (A[:], B[:]) + func (A) 1 - - */ - -bool -find_rank (location_t loc, tree orig_expr, tree expr, bool ignore_builtin_fn, - size_t *rank) -{ - tree ii_tree; - size_t ii = 0, current_rank = 0; - - if (TREE_CODE (expr) == ARRAY_NOTATION_REF) - { - ii_tree = expr; - while (ii_tree) - { - if (TREE_CODE (ii_tree) == ARRAY_NOTATION_REF) - { - current_rank++; - ii_tree = ARRAY_NOTATION_ARRAY (ii_tree); - } - else if (handled_component_p (ii_tree) - || INDIRECT_REF_P (ii_tree)) - ii_tree = TREE_OPERAND (ii_tree, 0); - else if (TREE_CODE (ii_tree) == PARM_DECL - || VAR_P (ii_tree)) - break; - else - gcc_unreachable (); - } - if (*rank == 0) - /* In this case, all the expressions this function has encountered thus - far have been scalars or expressions with zero rank. Please see - header comment for examples of such expression. */ - *rank = current_rank; - else if (*rank != current_rank) - { - /* In this case, find rank is being recursed through a set of - expression of the form A <OPERATION> B, where A and B both have - array notations in them and the rank of A is not equal to rank of - B. - A simple example of such case is the following: X[:] + Y[:][:] */ - *rank = current_rank; - return false; - } - } - else if (TREE_CODE (expr) == STATEMENT_LIST) - { - tree_stmt_iterator ii_tsi; - for (ii_tsi = tsi_start (expr); !tsi_end_p (ii_tsi); - tsi_next (&ii_tsi)) - if (!find_rank (loc, orig_expr, *tsi_stmt_ptr (ii_tsi), - ignore_builtin_fn, rank)) - return false; - } - else - { - if (TREE_CODE (expr) == CALL_EXPR) - { - tree func_name = CALL_EXPR_FN (expr); - tree prev_arg = NULL_TREE, arg; - call_expr_arg_iterator iter; - size_t prev_rank = 0; - if (TREE_CODE (func_name) == ADDR_EXPR) - if (!ignore_builtin_fn) - if (is_cilkplus_reduce_builtin (func_name)) - /* 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)) - { - if (prev_arg && EXPR_HAS_LOCATION (prev_arg) - && prev_rank != *rank) - error_at (EXPR_LOCATION (prev_arg), - "rank mismatch between %qE and %qE", prev_arg, - arg); - else if (prev_arg && prev_rank != *rank) - /* Here the original expression is printed as a "heads-up" - to the programmer. This is because since there is no - location information for the offending argument, the - error could be in some internally generated code that is - not visible for the programmer. Thus, the correct fix - may lie in the original expression. */ - error_at (loc, "rank mismatch in expression %qE", - orig_expr); - return false; - } - prev_arg = arg; - prev_rank = *rank; - } - } - else - { - tree prev_arg = NULL_TREE; - for (ii = 0; ii < TREE_CODE_LENGTH (TREE_CODE (expr)); ii++) - { - if (TREE_OPERAND (expr, ii) - && !find_rank (loc, orig_expr, TREE_OPERAND (expr, ii), - ignore_builtin_fn, rank)) - { - if (prev_arg && EXPR_HAS_LOCATION (prev_arg)) - error_at (EXPR_LOCATION (prev_arg), - "rank mismatch between %qE and %qE", prev_arg, - TREE_OPERAND (expr, ii)); - return false; - } - prev_arg = TREE_OPERAND (expr, ii); - } - } - } - return true; -} - -/* Extracts all array notations in NODE and stores them in ARRAY_LIST. If - IGNORE_BUILTIN_FN is set, then array notations inside array notation - specific built-in functions are ignored. The NODE can be constants, - VAR_DECL, PARM_DECLS, STATEMENT_LISTS or full expressions. */ - -void -extract_array_notation_exprs (tree node, bool ignore_builtin_fn, - vec<tree, va_gc> **array_list) -{ - size_t ii = 0; - - if (!node) - return; - if (TREE_CODE (node) == ARRAY_NOTATION_REF) - { - vec_safe_push (*array_list, node); - return; - } - if (TREE_CODE (node) == DECL_EXPR) - { - tree x = DECL_EXPR_DECL (node); - if (DECL_INITIAL (x)) - extract_array_notation_exprs (DECL_INITIAL (x), - ignore_builtin_fn, - array_list); - } - else if (TREE_CODE (node) == STATEMENT_LIST) - { - tree_stmt_iterator ii_tsi; - for (ii_tsi = tsi_start (node); !tsi_end_p (ii_tsi); tsi_next (&ii_tsi)) - extract_array_notation_exprs (*tsi_stmt_ptr (ii_tsi), - ignore_builtin_fn, array_list); - } - else if (TREE_CODE (node) == CALL_EXPR) - { - tree arg; - call_expr_arg_iterator iter; - if (is_cilkplus_reduce_builtin (CALL_EXPR_FN (node))) - { - if (ignore_builtin_fn) - return; - else - { - vec_safe_push (*array_list, node); - return; - } - } - if (is_sec_implicit_index_fn (CALL_EXPR_FN (node))) - { - 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); - } - else - for (ii = 0; ii < TREE_CODE_LENGTH (TREE_CODE (node)); ii++) - if (TREE_OPERAND (node, ii)) - extract_array_notation_exprs (TREE_OPERAND (node, ii), - ignore_builtin_fn, array_list); - return; -} - -/* LIST contains all the array notations found in *ORIG and ARRAY_OPERAND - contains the expanded ARRAY_REF. E.g., if LIST[<some_index>] contains - an array_notation expression, then ARRAY_OPERAND[<some_index>] contains its - expansion. If *ORIG matches LIST[<some_index>] then *ORIG is set to - ARRAY_OPERAND[<some_index>]. This function recursively steps through - all the sub-trees of *ORIG, if it is larger than a single - ARRAY_NOTATION_REF. */ - -void -replace_array_notations (tree *orig, bool ignore_builtin_fn, - vec<tree, va_gc> *list, - vec<tree, va_gc> *array_operand) -{ - size_t ii = 0; - extern tree build_c_cast (location_t, tree, tree); - tree node = NULL_TREE, node_replacement = NULL_TREE; - - if (vec_safe_length (list) == 0) - return; - - if (TREE_CODE (*orig) == ARRAY_NOTATION_REF) - { - for (ii = 0; vec_safe_iterate (list, ii, &node); ii++) - if (*orig == node) - { - node_replacement = (*array_operand)[ii]; - *orig = node_replacement; - } - } - else if (TREE_CODE (*orig) == STATEMENT_LIST) - { - tree_stmt_iterator ii_tsi; - for (ii_tsi = tsi_start (*orig); !tsi_end_p (ii_tsi); tsi_next (&ii_tsi)) - replace_array_notations (tsi_stmt_ptr (ii_tsi), ignore_builtin_fn, list, - array_operand); - } - else if (TREE_CODE (*orig) == CALL_EXPR) - { - tree arg; - call_expr_arg_iterator iter; - if (is_cilkplus_reduce_builtin (CALL_EXPR_FN (*orig))) - { - if (!ignore_builtin_fn) - { - for (ii = 0; vec_safe_iterate (list, ii, &node); ii++) - if (*orig == node) - { - node_replacement = (*array_operand)[ii]; - *orig = node_replacement; - } - } - return; - } - if (is_sec_implicit_index_fn (CALL_EXPR_FN (*orig))) - { - for (ii = 0; vec_safe_iterate (list, ii, &node); ii++) - if (*orig == node) - { - node_replacement = (*array_operand)[ii]; - *orig = build_c_cast (EXPR_LOCATION (*orig), - TREE_TYPE (*orig), node_replacement); - } - 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) - { - replace_array_notations (&arg, ignore_builtin_fn, list, - array_operand); - CALL_EXPR_ARG (*orig, ii) = arg; - ii++; - } - } - else - { - for (ii = 0; ii < (size_t) TREE_CODE_LENGTH (TREE_CODE (*orig)); ii++) - if (TREE_OPERAND (*orig, ii)) - replace_array_notations (&TREE_OPERAND (*orig, ii), ignore_builtin_fn, - list, array_operand); - } - return; -} - -/* Callback for walk_tree. Find all the scalar expressions in *TP and push - them in DATA struct, typecasted to (void *). If *WALK_SUBTREES is set to 0 - then do not go into the *TP's subtrees. Since this function steps through - all the subtrees, *TP and TP can be NULL_TREE and NULL, respectively. The - function returns NULL_TREE unconditionally. */ - -tree -find_inv_trees (tree *tp, int *walk_subtrees, void *data) -{ - struct inv_list *i_list = (struct inv_list *) data; - unsigned int ii = 0; - - if (!tp || !*tp) - return NULL_TREE; - if (TREE_CONSTANT (*tp)) - return NULL_TREE; /* No need to save constant to a variable. */ - if (TREE_CODE (*tp) != COMPOUND_EXPR && !contains_array_notation_expr (*tp)) - { - vec_safe_push (i_list->list_values, *tp); - *walk_subtrees = 0; - } - else if (TREE_CODE (*tp) == ARRAY_NOTATION_REF - || TREE_CODE (*tp) == ARRAY_REF - || TREE_CODE (*tp) == CALL_EXPR) - /* No need to step through the internals of array notation. */ - *walk_subtrees = 0; - else - { - *walk_subtrees = 1; - - /* This function is used by C and C++ front-ends. In C++, additional - tree codes such as TARGET_EXPR must be eliminated. These codes are - passed into additional_tcodes and are walked through and checked. */ - for (ii = 0; ii < vec_safe_length (i_list->additional_tcodes); ii++) - if (TREE_CODE (*tp) == (*(i_list->additional_tcodes))[ii]) - *walk_subtrees = 0; - } - return NULL_TREE; -} - -/* Callback for walk_tree. Replace all the scalar expressions in *TP with the - appropriate replacement stored in the struct *DATA (typecasted to void*). - The subtrees are not touched if *WALK_SUBTREES is set to zero. */ - -tree -replace_inv_trees (tree *tp, int *walk_subtrees, void *data) -{ - size_t ii = 0; - tree t, r; - struct inv_list *i_list = (struct inv_list *) data; - - if (vec_safe_length (i_list->list_values)) - { - for (ii = 0; vec_safe_iterate (i_list->list_values, ii, &t); ii++) - if (simple_cst_equal (*tp, t) == 1) - { - vec_safe_iterate (i_list->replacement, ii, &r); - gcc_assert (r != NULL_TREE); - *tp = r; - *walk_subtrees = 0; - } - } - else - *walk_subtrees = 0; - return NULL_TREE; -} - -/* Returns true if EXPR or any of its subtrees contain ARRAY_NOTATION_EXPR - node. */ - -bool -contains_array_notation_expr (tree expr) -{ - vec<tree, va_gc> *array_list = NULL; - - if (!expr) - return false; - if (TREE_CODE (expr) == FUNCTION_DECL) - if (is_cilkplus_reduce_builtin (expr)) - return true; - - extract_array_notation_exprs (expr, false, &array_list); - if (vec_safe_length (array_list) == 0) - return false; - else - return true; -} - -/* This function will check if OP is a CALL_EXPR that is a built-in array - notation function. If so, then we will return its type to be the type of - the array notation inside. */ - -tree -find_correct_array_notation_type (tree op) -{ - tree fn_arg, return_type = NULL_TREE; - - if (op) - { - return_type = TREE_TYPE (op); /* This is the default case. */ - if (TREE_CODE (op) == CALL_EXPR) - if (is_cilkplus_reduce_builtin (CALL_EXPR_FN (op))) - { - fn_arg = CALL_EXPR_ARG (op, 0); - if (fn_arg) - return_type = TREE_TYPE (fn_arg); - } - } - return return_type; -} - -/* Extracts all the array notation triplet information from LIST and stores - them in the following fields of the 2-D array NODE(size x rank): - START, LENGTH and STRIDE, holding the starting index, length, and stride, - respectively. In addition, it also sets two bool fields, IS_VECTOR and - COUNT_DOWN, in NODE indicating whether a certain value at a certain field - is a vector and if the array is accessed from high to low. */ - -void -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; - - node->safe_grow_cleared (size); - array_exprs.safe_grow_cleared (size); - - if (rank > 0) - for (size_t ii = 0; ii < size; ii++) - { - (*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 - 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++) - { - 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 - = fold_build1 (CONVERT_EXPR, integer_type_node, - 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)); - } - - release_vec_vec (array_exprs); -} - -/* Replaces all the __sec_implicit_arg functions in LIST with the induction - variable stored in VAR at the appropriate location pointed by the - __sec_implicit_arg's first parameter. Emits an error if the parameter is - not between 0 and RANK. */ - -vec <tree, va_gc> * -fix_sec_implicit_args (location_t loc, vec <tree, va_gc> *list, - vec<an_loop_parts> an_loop_info, size_t rank, - tree orig_stmt) -{ - 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 - && is_sec_implicit_index_fn (CALL_EXPR_FN ((*list)[ii]))) - { - int idx = extract_sec_implicit_index_arg (loc, (*list)[ii]); - 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 " - "less than the rank of %qE", idx, orig_stmt); - return NULL; - } - } - else - /* Save the existing value into the array operand. */ - vec_safe_push (array_operand, (*list)[ii]); - return array_operand; -} - -/* Returns true if NAME is an IDENTIFIER_NODE with identifier "vector", - "__vector", or "__vector__". */ - -bool -is_cilkplus_vector_p (tree name) -{ - return flag_cilkplus && is_attribute_p ("vector", name); -} diff --git a/gcc/c-family/c-cilkplus.c b/gcc/c-family/c-cilkplus.c deleted file mode 100644 index a537193..0000000 --- a/gcc/c-family/c-cilkplus.c +++ /dev/null @@ -1,175 +0,0 @@ -/* This file contains routines to construct and validate Cilk Plus - constructs within the C and C++ front ends. - - Copyright (C) 2013-2017 Free Software Foundation, Inc. - Contributed by Aldy Hernandez <aldyh@redhat.com>. - -This file is part of GCC. - -GCC is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 3, or (at your option) -any later version. - -GCC is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GCC; see the file COPYING3. If not see -<http://www.gnu.org/licenses/>. */ - -#include "config.h" -#include "system.h" -#include "coretypes.h" -#include "c-common.h" - -/* Validate the body of a _Cilk_for construct or a <#pragma simd> for - loop. - - Returns true if there were no errors, false otherwise. */ - -bool -c_check_cilk_loop (location_t loc, tree decl) -{ - if (TREE_THIS_VOLATILE (decl)) - { - error_at (loc, "iteration variable cannot be volatile"); - return false; - } - return true; -} - -/* Calculate number of iterations of CILK_FOR. */ - -tree -cilk_for_number_of_iterations (tree cilk_for) -{ - tree t, v, n1, n2, step, type, init, cond, incr, itype; - enum tree_code cond_code; - location_t loc = EXPR_LOCATION (cilk_for); - - init = TREE_VEC_ELT (OMP_FOR_INIT (cilk_for), 0); - v = TREE_OPERAND (init, 0); - cond = TREE_VEC_ELT (OMP_FOR_COND (cilk_for), 0); - incr = TREE_VEC_ELT (OMP_FOR_INCR (cilk_for), 0); - type = TREE_TYPE (v); - - gcc_assert (TREE_CODE (TREE_TYPE (v)) == INTEGER_TYPE - || TREE_CODE (TREE_TYPE (v)) == POINTER_TYPE); - n1 = TREE_OPERAND (init, 1); - cond_code = TREE_CODE (cond); - n2 = TREE_OPERAND (cond, 1); - switch (cond_code) - { - case LT_EXPR: - case GT_EXPR: - case NE_EXPR: - break; - case LE_EXPR: - if (POINTER_TYPE_P (TREE_TYPE (n2))) - n2 = fold_build_pointer_plus_hwi_loc (loc, n2, 1); - else - n2 = fold_build2_loc (loc, PLUS_EXPR, TREE_TYPE (n2), n2, - build_int_cst (TREE_TYPE (n2), 1)); - cond_code = LT_EXPR; - break; - case GE_EXPR: - if (POINTER_TYPE_P (TREE_TYPE (n2))) - n2 = fold_build_pointer_plus_hwi_loc (loc, n2, -1); - else - n2 = fold_build2_loc (loc, MINUS_EXPR, TREE_TYPE (n2), n2, - build_int_cst (TREE_TYPE (n2), 1)); - cond_code = GT_EXPR; - break; - default: - gcc_unreachable (); - } - - step = NULL_TREE; - switch (TREE_CODE (incr)) - { - case PREINCREMENT_EXPR: - case POSTINCREMENT_EXPR: - step = build_int_cst (TREE_TYPE (v), 1); - break; - case PREDECREMENT_EXPR: - case POSTDECREMENT_EXPR: - step = build_int_cst (TREE_TYPE (v), -1); - break; - case MODIFY_EXPR: - t = TREE_OPERAND (incr, 1); - gcc_assert (TREE_OPERAND (t, 0) == v); - switch (TREE_CODE (t)) - { - case PLUS_EXPR: - step = TREE_OPERAND (t, 1); - break; - case POINTER_PLUS_EXPR: - step = fold_convert (ssizetype, TREE_OPERAND (t, 1)); - break; - case MINUS_EXPR: - step = TREE_OPERAND (t, 1); - step = fold_build1_loc (loc, NEGATE_EXPR, TREE_TYPE (step), step); - break; - default: - gcc_unreachable (); - } - break; - default: - gcc_unreachable (); - } - - itype = type; - if (POINTER_TYPE_P (itype)) - itype = signed_type_for (itype); - if (cond_code == NE_EXPR) - { - /* For NE_EXPR, we need to find out if the iterator increases - or decreases from whether step is positive or negative. */ - tree stype = itype; - if (TYPE_UNSIGNED (stype)) - stype = signed_type_for (stype); - cond = fold_build2_loc (loc, GE_EXPR, boolean_type_node, - fold_convert_loc (loc, stype, step), - build_int_cst (stype, 0)); - t = fold_build3_loc (loc, COND_EXPR, itype, cond, - build_int_cst (itype, -1), - build_int_cst (itype, 1)); - } - else - t = build_int_cst (itype, (cond_code == LT_EXPR ? -1 : 1)); - t = fold_build2_loc (loc, PLUS_EXPR, itype, - fold_convert_loc (loc, itype, step), t); - t = fold_build2_loc (loc, PLUS_EXPR, itype, t, - fold_convert_loc (loc, itype, n2)); - t = fold_build2_loc (loc, MINUS_EXPR, itype, t, - fold_convert_loc (loc, itype, n1)); - if (TYPE_UNSIGNED (itype) && cond_code == GT_EXPR) - t = fold_build2_loc (loc, TRUNC_DIV_EXPR, itype, - fold_build1_loc (loc, NEGATE_EXPR, itype, t), - fold_build1_loc (loc, NEGATE_EXPR, itype, - fold_convert_loc (loc, itype, - step))); - else if (TYPE_UNSIGNED (itype) && cond_code == NE_EXPR) - { - tree t1 - = fold_build2_loc (loc, TRUNC_DIV_EXPR, itype, t, - fold_convert_loc (loc, itype, step)); - tree t2 - = fold_build2_loc (loc, TRUNC_DIV_EXPR, itype, - fold_build1_loc (loc, NEGATE_EXPR, itype, t), - fold_build1_loc (loc, NEGATE_EXPR, itype, - fold_convert_loc (loc, itype, - step))); - t = fold_build3_loc (loc, COND_EXPR, itype, cond, t1, t2); - } - else - t = fold_build2_loc (loc, TRUNC_DIV_EXPR, itype, t, - fold_convert_loc (loc, itype, step)); - cond = fold_build2_loc (loc, cond_code, boolean_type_node, n1, n2); - t = fold_build3_loc (loc, COND_EXPR, itype, cond, t, - build_int_cst (itype, 0)); - return t; -} diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 9970e61..82561657 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -338,9 +338,6 @@ const struct c_common_resword c_common_reswords[] = { "_Atomic", RID_ATOMIC, D_CONLY }, { "_Bool", RID_BOOL, D_CONLY }, { "_Complex", RID_COMPLEX, 0 }, - { "_Cilk_spawn", RID_CILK_SPAWN, 0 }, - { "_Cilk_sync", RID_CILK_SYNC, 0 }, - { "_Cilk_for", RID_CILK_FOR, 0 }, { "_Imaginary", RID_IMAGINARY, D_CONLY }, { "_Float16", RID_FLOAT16, D_CONLY }, { "_Float32", RID_FLOAT32, D_CONLY }, @@ -3935,9 +3932,6 @@ c_define_builtins (tree va_list_ref_type_node, tree va_list_arg_type_node) targetm.init_builtins (); build_common_builtin_nodes (); - - if (flag_cilkplus) - cilk_init_builtins (); } /* Like get_identifier, but avoid warnings about null arguments when @@ -7569,7 +7563,6 @@ c_common_init_ts (void) { MARK_TS_TYPED (C_MAYBE_CONST_EXPR); MARK_TS_TYPED (EXCESS_PRECISION_EXPR); - MARK_TS_TYPED (ARRAY_NOTATION_REF); } /* Build a user-defined numeric literal out of an integer constant type VALUE diff --git a/gcc/c-family/c-common.def b/gcc/c-family/c-common.def index aeec271..2d89472 100644 --- a/gcc/c-family/c-common.def +++ b/gcc/c-family/c-common.def @@ -55,13 +55,6 @@ DEFTREECODE (USERDEF_LITERAL, "userdef_literal", tcc_exceptional, 3) or for the purpose of -Wsizeof-pointer-memaccess warning. */ DEFTREECODE (SIZEOF_EXPR, "sizeof_expr", tcc_expression, 1) -/* Array Notation expression. - Operand 0 is the array. - Operand 1 is the starting array index. - Operand 2 contains the number of elements you need to access. - Operand 3 is the stride. */ -DEFTREECODE (ARRAY_NOTATION_REF, "array_notation_ref", tcc_reference, 4) - /* Local variables: mode:c diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 3cf4b0a..5e55e5e 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -184,9 +184,6 @@ enum rid /* C++ transactional memory. */ RID_ATOMIC_NOEXCEPT, RID_ATOMIC_CANCEL, RID_SYNCHRONIZED, - /* Cilk Plus keywords. */ - RID_CILK_SPAWN, RID_CILK_SYNC, RID_CILK_FOR, - /* Objective-C ("AT" reserved words - they are only keywords when they follow '@') */ RID_AT_ENCODE, RID_AT_END, @@ -586,9 +583,6 @@ extern void push_cleanup (tree, tree, bool); extern tree build_modify_expr (location_t, tree, tree, enum tree_code, location_t, tree, tree); -extern tree build_array_notation_expr (location_t, tree, tree, enum tree_code, - location_t, tree, tree); -extern tree build_array_notation_ref (location_t, tree, tree, tree, tree, tree); extern tree build_indirect_ref (location_t, tree, ref_operator); extern bool has_c_linkage (const_tree decl); @@ -1255,9 +1249,8 @@ enum c_omp_clause_split enum c_omp_region_type { C_ORT_OMP = 1 << 0, - C_ORT_CILK = 1 << 1, - C_ORT_ACC = 1 << 2, - C_ORT_DECLARE_SIMD = 1 << 3, + C_ORT_ACC = 1 << 1, + C_ORT_DECLARE_SIMD = 1 << 2, C_ORT_OMP_DECLARE_SIMD = C_ORT_OMP | C_ORT_DECLARE_SIMD }; @@ -1364,23 +1357,6 @@ enum stv_conv { extern enum stv_conv scalar_to_vector (location_t loc, enum tree_code code, tree op0, tree op1, bool); -/* In c-cilkplus.c */ -extern tree c_validate_cilk_plus_loop (tree *, int *, void *); -extern bool c_check_cilk_loop (location_t, tree); - -/* These #defines allow users to access different operands of the - array notation tree. */ - -#define ARRAY_NOTATION_CHECK(NODE) TREE_CHECK (NODE, ARRAY_NOTATION_REF) -#define ARRAY_NOTATION_ARRAY(NODE) \ - TREE_OPERAND (ARRAY_NOTATION_CHECK (NODE), 0) -#define ARRAY_NOTATION_START(NODE) \ - TREE_OPERAND (ARRAY_NOTATION_CHECK (NODE), 1) -#define ARRAY_NOTATION_LENGTH(NODE) \ - TREE_OPERAND (ARRAY_NOTATION_CHECK (NODE), 2) -#define ARRAY_NOTATION_STRIDE(NODE) \ - TREE_OPERAND (ARRAY_NOTATION_CHECK (NODE), 3) - /* This structure holds all the scalar values and its appropriate variable replacment. It is mainly used by the function that pulls all the invariant parts that should be executed only once, which comes with array notation @@ -1392,76 +1368,12 @@ struct inv_list vec<enum tree_code, va_gc> *additional_tcodes; }; -/* This structure holds all the important components that can be extracted - from an ARRAY_NOTATION_REF expression. It is used to pass array notation - information between the functions that are responsible for expansion. */ -typedef struct cilkplus_an_parts -{ - tree value; - tree start; - tree length; - tree stride; - bool is_vector; -} an_parts; - -/* This structure holds the components necessary to create the loop around - the ARRAY_REF that is created using the ARRAY_NOTATION information. */ - -typedef struct cilkplus_an_loop_parts -{ - tree var; /* Loop induction variable. */ - tree incr; /* Loop increment/decrement expression. */ - tree cmp; /* Loop condition. */ - tree ind_init; /* Initialization of the loop induction variable. */ -} an_loop_parts; - -/* In array-notation-common.c. */ -extern HOST_WIDE_INT extract_sec_implicit_index_arg (location_t, tree); -extern bool is_sec_implicit_index_fn (tree); -extern void array_notation_init_builtins (void); -extern struct c_expr fix_array_notation_expr (location_t, enum tree_code, - struct c_expr); -extern bool contains_array_notation_expr (tree); -extern tree expand_array_notation_exprs (tree); -extern tree fix_conditional_array_notations (tree); -extern tree find_correct_array_notation_type (tree); -extern bool length_mismatch_in_expr_p (location_t, vec<vec<an_parts> >); -extern enum built_in_function is_cilkplus_reduce_builtin (tree); -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 replace_array_notations (tree *, bool, vec<tree, va_gc> *, - vec<tree, va_gc> *); extern tree find_inv_trees (tree *, int *, void *); extern tree replace_inv_trees (tree *, int *, void *); -extern tree find_correct_array_notation_type (tree op); -extern void cilkplus_extract_an_triplets (vec<tree, va_gc> *, size_t, size_t, - vec<vec<an_parts> > *); -extern vec <tree, va_gc> *fix_sec_implicit_args - (location_t, vec <tree, va_gc> *, vec<an_loop_parts>, size_t, tree); -extern bool is_cilkplus_vector_p (tree); - -/* In cilk.c. */ -extern tree insert_cilk_frame (tree); -extern void cilk_init_builtins (void); -extern int gimplify_cilk_spawn (tree *); -extern void cilk_install_body_with_frame_cleanup (tree, tree, void *); -extern bool cilk_detect_spawn_and_unwrap (tree *); -extern bool cilk_set_spawn_marker (location_t, tree); -extern tree build_cilk_sync (void); -extern tree build_cilk_spawn (location_t, tree); -extern tree make_cilk_frame (tree); -extern tree create_cilk_function_exit (tree, bool, bool); -extern void cilk_outline (tree, tree *, void *); -extern bool contains_cilk_spawn_stmt (tree); -extern tree cilk_for_number_of_iterations (tree); -extern bool check_no_cilk (tree, const char *, const char *, - location_t loc = UNKNOWN_LOCATION); + extern bool reject_gcc_builtin (const_tree, location_t = UNKNOWN_LOCATION); extern bool valid_array_size_p (location_t, tree, tree); -extern bool cilk_ignorable_spawn_rhs_op (tree); -extern bool cilk_recognize_spawn (tree, tree *); - /* In c-warn.c. */ extern void constant_expression_warning (tree); extern void constant_expression_error (tree); diff --git a/gcc/c-family/c-gimplify.c b/gcc/c-family/c-gimplify.c index 91f9bf9..152eb8a 100644 --- a/gcc/c-family/c-gimplify.c +++ b/gcc/c-family/c-gimplify.c @@ -36,7 +36,6 @@ along with GCC; see the file COPYING3. If not see #include "gimplify.h" #include "langhooks.h" #include "dumpfile.h" -#include "cilk.h" #include "c-ubsan.h" /* The gimplification pass converts the language-dependent trees @@ -277,25 +276,6 @@ c_gimplify_expr (tree *expr_p, gimple_seq *pre_p ATTRIBUTE_UNUSED, break; } - case CILK_SPAWN_STMT: - gcc_assert(fn_contains_cilk_spawn_p (cfun) - && cilk_detect_spawn_and_unwrap (expr_p)); - - if (!seen_error ()) - return (enum gimplify_status) gimplify_cilk_spawn (expr_p); - return GS_ERROR; - - case MODIFY_EXPR: - case INIT_EXPR: - case CALL_EXPR: - if (fn_contains_cilk_spawn_p (cfun) - && cilk_detect_spawn_and_unwrap (expr_p) - /* If an error is found, the spawn wrapper is removed and the - original expression (MODIFY/INIT/CALL_EXPR) is processes as - it is supposed to be. */ - && !seen_error ()) - return (enum gimplify_status) gimplify_cilk_spawn (expr_p); - default:; } diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c index 8e04509..5c5d7a7 100644 --- a/gcc/c-family/c-omp.c +++ b/gcc/c-family/c-omp.c @@ -536,10 +536,6 @@ c_finish_omp_for (location_t locus, enum tree_code code, tree declv, bool fail = false; int i; - if ((code == CILK_SIMD || code == CILK_FOR) - && !c_check_cilk_loop (locus, TREE_VEC_ELT (declv, 0))) - fail = true; - gcc_assert (TREE_VEC_LENGTH (declv) == TREE_VEC_LENGTH (initv)); gcc_assert (TREE_VEC_LENGTH (declv) == TREE_VEC_LENGTH (condv)); gcc_assert (TREE_VEC_LENGTH (declv) == TREE_VEC_LENGTH (incrv)); @@ -671,8 +667,7 @@ c_finish_omp_for (location_t locus, enum tree_code code, tree declv, { if (!INTEGRAL_TYPE_P (TREE_TYPE (decl))) { - if (code != CILK_SIMD && code != CILK_FOR) - cond_ok = false; + cond_ok = false; } else if (operand_equal_p (TREE_OPERAND (cond, 1), TYPE_MIN_VALUE (TREE_TYPE (decl)), @@ -684,7 +679,7 @@ c_finish_omp_for (location_t locus, enum tree_code code, tree declv, 0)) TREE_SET_CODE (cond, TREE_CODE (cond) == NE_EXPR ? LT_EXPR : GE_EXPR); - else if (code != CILK_SIMD && code != CILK_FOR) + else cond_ok = false; } diff --git a/gcc/c-family/c-pragma.c b/gcc/c-family/c-pragma.c index f7b59b3..daa9e5a 100644 --- a/gcc/c-family/c-pragma.c +++ b/gcc/c-family/c-pragma.c @@ -1343,20 +1343,6 @@ c_pp_lookup_pragma (unsigned int id, const char **space, const char **name) return; } - if (id == PRAGMA_CILK_SIMD) - { - *space = NULL; - *name = "simd"; - return; - } - - if (id == PRAGMA_CILK_GRAINSIZE) - { - *space = "cilk"; - *name = "grainsize"; - return; - } - if (id >= PRAGMA_FIRST_EXTERNAL && (id < PRAGMA_FIRST_EXTERNAL + registered_pp_pragmas.length ())) { @@ -1532,10 +1518,6 @@ init_pragma (void) omp_pragmas_simd[i].id, true, true); } - if (flag_cilkplus) - cpp_register_deferred_pragma (parse_in, NULL, "simd", PRAGMA_CILK_SIMD, - true, false); - if (!flag_preprocess_only) cpp_register_deferred_pragma (parse_in, "GCC", "pch_preprocess", PRAGMA_GCC_PCH_PREPROCESS, false, false); @@ -1544,10 +1526,6 @@ init_pragma (void) cpp_register_deferred_pragma (parse_in, "GCC", "ivdep", PRAGMA_IVDEP, false, false); - if (flag_cilkplus) - cpp_register_deferred_pragma (parse_in, "cilk", "grainsize", - PRAGMA_CILK_GRAINSIZE, true, false); - #ifdef HANDLE_PRAGMA_PACK_WITH_EXPANSION c_register_pragma_with_expansion (0, "pack", handle_pragma_pack); #else diff --git a/gcc/c-family/c-pragma.h b/gcc/c-family/c-pragma.h index a79036e..e035b3a 100644 --- a/gcc/c-family/c-pragma.h +++ b/gcc/c-family/c-pragma.h @@ -67,12 +67,6 @@ enum pragma_kind { PRAGMA_OMP_THREADPRIVATE, PRAGMA_OMP_TEAMS, - /* Top level clause to handle all Cilk Plus pragma simd clauses. */ - PRAGMA_CILK_SIMD, - - /* This pragma handles setting of grainsize for a _Cilk_for. */ - PRAGMA_CILK_GRAINSIZE, - PRAGMA_GCC_PCH_PREPROCESS, PRAGMA_IVDEP, @@ -134,20 +128,8 @@ enum pragma_omp_clause { PRAGMA_OMP_CLAUSE_UNTIED, PRAGMA_OMP_CLAUSE_USE_DEVICE_PTR, - /* Clauses for Cilk Plus SIMD-enabled function. */ - PRAGMA_CILK_CLAUSE_NOMASK, - PRAGMA_CILK_CLAUSE_MASK, - PRAGMA_CILK_CLAUSE_VECTORLENGTH, - PRAGMA_CILK_CLAUSE_NONE = PRAGMA_OMP_CLAUSE_NONE, - PRAGMA_CILK_CLAUSE_LINEAR = PRAGMA_OMP_CLAUSE_LINEAR, - PRAGMA_CILK_CLAUSE_PRIVATE = PRAGMA_OMP_CLAUSE_PRIVATE, - PRAGMA_CILK_CLAUSE_FIRSTPRIVATE = PRAGMA_OMP_CLAUSE_FIRSTPRIVATE, - PRAGMA_CILK_CLAUSE_LASTPRIVATE = PRAGMA_OMP_CLAUSE_LASTPRIVATE, - PRAGMA_CILK_CLAUSE_REDUCTION = PRAGMA_OMP_CLAUSE_REDUCTION, - PRAGMA_CILK_CLAUSE_UNIFORM = PRAGMA_OMP_CLAUSE_UNIFORM, - /* Clauses for OpenACC. */ - PRAGMA_OACC_CLAUSE_ASYNC = PRAGMA_CILK_CLAUSE_VECTORLENGTH + 1, + PRAGMA_OACC_CLAUSE_ASYNC, PRAGMA_OACC_CLAUSE_AUTO, PRAGMA_OACC_CLAUSE_COPY, PRAGMA_OACC_CLAUSE_COPYOUT, diff --git a/gcc/c-family/c-pretty-print.c b/gcc/c-family/c-pretty-print.c index 15e13ea..de5ab4b 100644 --- a/gcc/c-family/c-pretty-print.c +++ b/gcc/c-family/c-pretty-print.c @@ -1482,17 +1482,6 @@ c_pretty_printer::postfix_expression (tree e) pp_c_right_bracket (this); break; - case ARRAY_NOTATION_REF: - postfix_expression (ARRAY_NOTATION_ARRAY (e)); - pp_c_left_bracket (this); - expression (ARRAY_NOTATION_START (e)); - pp_colon (this); - expression (ARRAY_NOTATION_LENGTH (e)); - pp_colon (this); - expression (ARRAY_NOTATION_STRIDE (e)); - pp_c_right_bracket (this); - break; - case CALL_EXPR: { call_expr_arg_iterator iter; @@ -2192,7 +2181,6 @@ c_pretty_printer::expression (tree e) case POSTINCREMENT_EXPR: case POSTDECREMENT_EXPR: case ARRAY_REF: - case ARRAY_NOTATION_REF: case CALL_EXPR: case COMPONENT_REF: case BIT_FIELD_REF: diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index d857dfc..b254810 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -1330,9 +1330,9 @@ Driver static-libmpxwrappers Driver -fcilkplus +fcilkplus Undocumented C ObjC C++ ObjC++ LTO Report Var(flag_cilkplus) Init(0) -Enable Cilk Plus. +Deprecated in GCC 8. This switch has no effect. fconcepts C++ ObjC++ Var(flag_concepts) diff --git a/gcc/c-family/cilk.c b/gcc/c-family/cilk.c deleted file mode 100644 index e6df498..0000000 --- a/gcc/c-family/cilk.c +++ /dev/null @@ -1,1363 +0,0 @@ -/* This file is part of the Intel(R) Cilk(TM) Plus support - This file contains the CilkPlus Intrinsics - Copyright (C) 2013-2017 Free Software Foundation, Inc. - Contributed by Balaji V. Iyer <balaji.v.iyer@intel.com>, - Intel Corporation - -This file is part of GCC. - -GCC is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 3, or (at your option) -any later version. - -GCC is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GCC; see the file COPYING3. If not see -<http://www.gnu.org/licenses/>. */ - -#include "config.h" -#include "system.h" -#include "coretypes.h" -#include "tm.h" -#include "function.h" -#include "c-family/c-common.h" -#include "gimple-expr.h" -#include "stringpool.h" -#include "cgraph.h" -#include "diagnostic.h" -#include "gimplify.h" -#include "tree-iterator.h" -#include "tree-inline.h" -#include "toplev.h" -#include "calls.h" -#include "cilk.h" - -enum add_variable_type { - /* Reference to previously-defined variable. */ - ADD_READ, - /* Definition of a new variable in inner-scope. */ - ADD_BIND, - /* Write to possibly previously-defined variable. */ - ADD_WRITE -}; - -enum cilk_block_type { - /* Indicates a _Cilk_spawn block. 30 was an arbitary number picked for - ease of debugging. */ - CILK_BLOCK_SPAWN = 30, - /* Indicates _Cilk_for statement block. */ - CILK_BLOCK_FOR -}; - -struct wrapper_data -{ - /* Kind of function to be created. */ - enum cilk_block_type type; - /* Signature of helper function. */ - tree fntype; - /* Containing function. */ - tree context; - /* Disposition of all variables in the inner statement. */ - hash_map<tree, tree> *decl_map; - /* True if this function needs a static chain. */ - bool nested; - /* Arguments to be passed to wrapper function, currently a list. */ - tree arglist; - /* Argument types, a list. */ - tree argtypes; - /* Incoming parameters. */ - tree parms; - /* Outer BLOCK object. */ - tree block; -}; - -static tree contains_cilk_spawn_stmt_walker (tree *tp, int *, void *); -static void extract_free_variables (tree, struct wrapper_data *, - enum add_variable_type); -static HOST_WIDE_INT cilk_wrapper_count; - -/* Marks the CALL_EXPR or FUNCTION_DECL, FCALL, as a spawned function call - and the current function as a spawner. Emit error if the function call - is outside a function or if a non function-call is spawned. */ - -inline bool -cilk_set_spawn_marker (location_t loc, tree fcall) -{ - if (!current_function_decl) - { - error_at (loc, "%<_Cilk_spawn%> may only be used inside a function"); - return false; - } - else if (fcall == error_mark_node) - /* Error reporting here is not necessary here since if FCALL is an - error_mark_node, the function marking it as error would have reported - it. */ - return false; - else if (TREE_CODE (fcall) != CALL_EXPR - /* In C++, TARGET_EXPR is generated when we have an overloaded - '=' operator. */ - && TREE_CODE (fcall) != TARGET_EXPR) - { - error_at (loc, "only function calls can be spawned"); - return false; - } - else - { - cfun->calls_cilk_spawn = true; - if (TREE_CODE (fcall) == CALL_EXPR) - EXPR_CILK_SPAWN (fcall) = 1; - else /* TREE_CODE (fcall) == TARGET_EXPR */ - EXPR_CILK_SPAWN (TREE_OPERAND (fcall, 1)) = 1; - return true; - } -} - -/* This function will output the exit conditions for a spawn call. */ - -tree -create_cilk_function_exit (tree frame, bool detaches, bool needs_sync) -{ - tree epi = alloc_stmt_list (); - - if (needs_sync) - append_to_statement_list (build_cilk_sync (), &epi); - tree func_ptr = build1 (ADDR_EXPR, cilk_frame_ptr_type_decl, frame); - tree pop_frame = build_call_expr (cilk_pop_fndecl, 1, func_ptr); - tree worker = cilk_dot (frame, CILK_TI_FRAME_WORKER, 0); - tree current = cilk_arrow (worker, CILK_TI_WORKER_CUR, 0); - tree parent = cilk_dot (frame, CILK_TI_FRAME_PARENT, 0); - tree set_current = build2 (MODIFY_EXPR, void_type_node, current, parent); - append_to_statement_list (set_current, &epi); - append_to_statement_list (pop_frame, &epi); - tree call = build_call_expr (cilk_leave_fndecl, 1, func_ptr); - if (!detaches) - { - tree flags = cilk_dot (frame, CILK_TI_FRAME_FLAGS, false); - tree flags_cmp_expr = fold_build2 (NE_EXPR, TREE_TYPE (flags), flags, - build_int_cst (TREE_TYPE (flags), - CILK_FRAME_VERSION)); - call = fold_build3 (COND_EXPR, void_type_node, flags_cmp_expr, - call, build_empty_stmt (EXPR_LOCATION (flags))); - } - append_to_statement_list (call, &epi); - return epi; -} - -/* Trying to get the correct cfun for the FUNCTION_DECL indicated by OUTER. */ - -static void -pop_cfun_to (tree outer) -{ - pop_cfun (); - current_function_decl = outer; - gcc_assert (cfun == DECL_STRUCT_FUNCTION (current_function_decl)); - gcc_assert (cfun->decl == current_function_decl); -} - -/* This function does whatever is necessary to make the compiler emit a newly - generated function, FNDECL. */ - -static void -call_graph_add_fn (tree fndecl) -{ - const tree outer = current_function_decl; - struct function *f = DECL_STRUCT_FUNCTION (fndecl); - gcc_assert (TREE_CODE (fndecl) == FUNCTION_DECL); - - f->is_cilk_function = 1; - f->curr_properties = cfun->curr_properties; - gcc_assert (cfun == DECL_STRUCT_FUNCTION (outer)); - gcc_assert (cfun->decl == outer); - - push_cfun (f); - cgraph_node::create (fndecl); - pop_cfun_to (outer); -} - -/* Return true if this is a tree which is allowed to contain a spawn as - operand 0. - A spawn call may be wrapped in a series of unary operations such - as conversions. These conversions need not be "useless" - to be disregarded because they are retained in the spawned - statement. They are bypassed only to look for a spawn - within. - A comparison to constant is simple enough to allow, and - is used to convert to bool. */ - -bool -cilk_ignorable_spawn_rhs_op (tree exp) -{ - enum tree_code code = TREE_CODE (exp); - switch (TREE_CODE_CLASS (code)) - { - case tcc_expression: - return code == ADDR_EXPR; - case tcc_comparison: - /* We need the spawn as operand 0 for now. That's where it - appears in the only case we really care about, conversion - to bool. */ - return (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST); - case tcc_unary: - case tcc_reference: - return true; - default: - return false; - } -} - -/* Helper function for walk_tree. If *TP is a CILK_SPAWN_STMT, then unwrap - this "wrapper." The function returns NULL_TREE regardless. */ - -static tree -unwrap_cilk_spawn_stmt (tree *tp, int *walk_subtrees, void *) -{ - if (TREE_CODE (*tp) == CILK_SPAWN_STMT) - { - *tp = CILK_SPAWN_FN (*tp); - *walk_subtrees = 0; - } - return NULL_TREE; -} - -/* Returns true when EXP is a CALL_EXPR with _Cilk_spawn in front. Unwraps - CILK_SPAWN_STMT wrapper from the CALL_EXPR in *EXP0 statement. */ - -bool -cilk_recognize_spawn (tree exp, tree *exp0) -{ - bool spawn_found = false; - if (TREE_CODE (exp) == CILK_SPAWN_STMT) - { - /* Remove the CALL_EXPR from CILK_SPAWN_STMT wrapper. */ - exp = CILK_SPAWN_FN (exp); - walk_tree (exp0, unwrap_cilk_spawn_stmt, NULL, NULL); - spawn_found = true; - } - /* _Cilk_spawn can't be wrapped in expression such as PLUS_EXPR. */ - else if (contains_cilk_spawn_stmt (exp)) - { - location_t loc = EXPR_LOCATION (exp); - if (loc == UNKNOWN_LOCATION) - { - tree stmt = walk_tree (&exp, - contains_cilk_spawn_stmt_walker, - NULL, - NULL); - gcc_assert (stmt != NULL_TREE); - loc = EXPR_LOCATION (stmt); - } - error_at (loc, "invalid use of %<_Cilk_spawn%>"); - } - return spawn_found; -} - -/* Returns true if *EXP0 is a recognized form of spawn. Recognized forms are, - after conversion to void, a call expression at outer level or an assignment - at outer level with the right hand side being a spawned call. - In addition to this, it also unwraps the CILK_SPAWN_STMT cover from the - CALL_EXPR that is being spawned. - Note that `=' in C++ may turn into a CALL_EXPR rather than a MODIFY_EXPR. */ - -bool -cilk_detect_spawn_and_unwrap (tree *exp0) -{ - tree exp = *exp0; - - if (!TREE_SIDE_EFFECTS (exp)) - return false; - - /* Strip off any conversion to void. It does not affect whether spawn - is supported here. */ - if (TREE_CODE (exp) == CONVERT_EXPR && VOID_TYPE_P (TREE_TYPE (exp))) - exp = TREE_OPERAND (exp, 0); - - if (TREE_CODE (exp) == MODIFY_EXPR || TREE_CODE (exp) == INIT_EXPR) - exp = TREE_OPERAND (exp, 1); - - while (cilk_ignorable_spawn_rhs_op (exp)) - exp = TREE_OPERAND (exp, 0); - - if (TREE_CODE (exp) == TARGET_EXPR) - if (TARGET_EXPR_INITIAL (exp) - && TREE_CODE (TARGET_EXPR_INITIAL (exp)) != AGGR_INIT_EXPR) - exp = TARGET_EXPR_INITIAL (exp); - - /* Happens with C++ TARGET_EXPR. */ - if (exp == NULL_TREE) - return false; - - while (TREE_CODE (exp) == CLEANUP_POINT_EXPR || TREE_CODE (exp) == EXPR_STMT) - exp = TREE_OPERAND (exp, 0); - - /* Now we should have a CALL_EXPR with a CILK_SPAWN_STMT wrapper around - it, or return false. */ - if (cilk_recognize_spawn (exp, exp0)) - return true; - return false; -} - -/* This function will build and return a FUNCTION_DECL using information - from *WD. */ - -static tree -create_cilk_helper_decl (struct wrapper_data *wd) -{ - char name[20]; - if (wd->type == CILK_BLOCK_FOR) - sprintf (name, "_cilk_for_" HOST_WIDE_INT_PRINT_DEC, cilk_wrapper_count++); - else if (wd->type == CILK_BLOCK_SPAWN) - sprintf (name, "_cilk_spn_" HOST_WIDE_INT_PRINT_DEC, cilk_wrapper_count++); - else - gcc_unreachable (); - - clean_symbol_name (name); - - tree fndecl = build_decl (DECL_SOURCE_LOCATION (current_function_decl), - FUNCTION_DECL, get_identifier (name), wd->fntype); - - TREE_PUBLIC (fndecl) = 0; - TREE_STATIC (fndecl) = 1; - TREE_USED (fndecl) = 1; - DECL_ARTIFICIAL (fndecl) = 0; - DECL_IGNORED_P (fndecl) = 0; - DECL_EXTERNAL (fndecl) = 0; - - DECL_CONTEXT (fndecl) = wd->context; - tree block = make_node (BLOCK); - DECL_INITIAL (fndecl) = block; - TREE_USED (block) = 1; - BLOCK_SUPERCONTEXT (block) = fndecl; - gcc_assert (!DECL_SAVED_TREE (fndecl)); - - /* Inlining would defeat the purpose of this wrapper. - Either it secretly switches stack frames or it allocates - a stable stack frame to hold function arguments even if - the parent stack frame is stolen. */ - DECL_UNINLINABLE (fndecl) = 1; - - tree result_decl = build_decl (UNKNOWN_LOCATION, RESULT_DECL, NULL_TREE, - void_type_node); - DECL_ARTIFICIAL (result_decl) = 0; - DECL_IGNORED_P (result_decl) = 1; - DECL_CONTEXT (result_decl) = fndecl; - DECL_RESULT (fndecl) = result_decl; - - return fndecl; -} - -struct cilk_decls -{ - tree key; - tree *val; -}; - -/* A function used by traversal to fill vector of decls for further work. */ - -bool -fill_decls_vec (tree const &key0, tree *val0, auto_vec<struct cilk_decls> *v) -{ - tree t1 = key0; - struct cilk_decls dp; - - if (DECL_P (t1)) - { - dp.key = t1; - dp.val = val0; - v->safe_push (dp); - } - return true; -} - -/* Function that actually creates necessary parm lists. */ - -static void -create_parm_list (struct wrapper_data *wd, tree *val0, tree arg) -{ - tree val = *val0; - tree parm; - - if (val == error_mark_node || val == arg) - return; - - if (TREE_CODE (val) == PAREN_EXPR) - { - /* We should not reach here with a register receiver. - We may see a register variable modified in the - argument list. Because register variables are - worker-local we don't need to work hard to support - them in code that spawns. */ - if (VAR_P (arg) && DECL_HARD_REGISTER (arg)) - { - error_at (EXPR_LOCATION (arg), - "explicit register variable %qD may not be modified in " - "spawn", arg); - arg = null_pointer_node; - } - else - arg = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (arg)), arg); - - val = TREE_OPERAND (val, 0); - *val0 = val; - gcc_assert (INDIRECT_REF_P (val)); - parm = TREE_OPERAND (val, 0); - STRIP_NOPS (parm); - } - else - parm = val; - TREE_CHAIN (parm) = wd->parms; - wd->parms = parm; - wd->argtypes = tree_cons (NULL_TREE, TREE_TYPE (parm), wd->argtypes); - wd->arglist = tree_cons (NULL_TREE, arg, wd->arglist); -} - -/* Sorting decls in a vector. */ - -static int -compare_decls (const void *a, const void *b) -{ - const struct cilk_decls *t1 = (const struct cilk_decls *) a; - const struct cilk_decls *t2 = (const struct cilk_decls *) b; - - if (DECL_UID (t1->key) > DECL_UID (t2->key)) - return 1; - else if (DECL_UID (t1->key) < DECL_UID (t2->key)) - return -1; - else - return 0; -} - -/* This function is used to build a wrapper of a certain type. */ - -static void -build_wrapper_type (struct wrapper_data *wd) -{ - unsigned int j; - struct cilk_decls * c; - auto_vec<struct cilk_decls> vd; - wd->arglist = NULL_TREE; - wd->parms = NULL_TREE; - wd->argtypes = void_list_node; - - gcc_assert (wd->type != CILK_BLOCK_FOR); - wd->decl_map->traverse<auto_vec<struct cilk_decls> *, fill_decls_vec> (&vd); - vd.qsort (compare_decls); - - FOR_EACH_VEC_ELT (vd, j, c) - create_parm_list (wd, c->val, c->key); - - /* Now build a function. - Its return type is void (all side effects are via explicit parameters). - Its parameters are WRAPPER_PARMS with type WRAPPER_TYPES. - Actual arguments in the caller are WRAPPER_ARGS. */ - wd->fntype = build_function_type (void_type_node, wd->argtypes); -} - -/* This function checks all the CALL_EXPRs in *TP found by cilk_outline. */ - -static tree -check_outlined_calls (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED, - void *data) -{ - bool *throws = (bool *) data; - tree t = *tp; - int flags; - - if (TREE_CODE (t) != CALL_EXPR) - return 0; - flags = call_expr_flags (t); - - if (!(flags & ECF_NOTHROW) && flag_exceptions) - *throws = true; - if (flags & ECF_RETURNS_TWICE) - error_at (EXPR_LOCATION (t), - "cannot spawn call to function that returns twice"); - return 0; -} - -/* Each DECL in the source code (spawned statement) is passed to this function - once. Each instance of the DECL is replaced with the result of this - function. - - The parameters of the wrapper should have been entered into the map already. - This function only deals with variables with scope limited to the - spawned expression. */ - -static tree -copy_decl_for_cilk (tree decl, copy_body_data *id) -{ - switch (TREE_CODE (decl)) - { - case VAR_DECL: - return copy_decl_no_change (decl, id); - - case LABEL_DECL: - error_at (EXPR_LOCATION (decl), "invalid use of label %q+D in " - "%<_Cilk_spawn%>", - decl); - return error_mark_node; - - case RESULT_DECL: - case PARM_DECL: - /* RESULT_DECL and PARM_DECL has already been entered into the map. */ - default: - gcc_unreachable (); - return error_mark_node; - } -} - -/* Alter a tree STMT from OUTER_FN to form the body of INNER_FN. */ - -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; - bool throws; - auto_vec<struct cilk_decls> vd; - unsigned int j; - struct cilk_decls * c; - - DECL_STATIC_CHAIN (outer_fn) = 1; - - memset (&id, 0, sizeof (id)); - /* Copy from the function containing the spawn... */ - id.src_fn = outer_fn; - - /* ...to the wrapper. */ - id.dst_fn = inner_fn; - id.src_cfun = DECL_STRUCT_FUNCTION (outer_fn); - - /* There shall be no RETURN in spawn helper. */ - id.retvar = 0; - id.decl_map = wd->decl_map; - id.copy_decl = nested ? copy_decl_no_change : copy_decl_for_cilk; - id.block = DECL_INITIAL (inner_fn); - id.transform_lang_insert_block = NULL; - - id.transform_new_cfg = true; - id.transform_call_graph_edges = CB_CGE_MOVE; - id.remap_var_for_cilk = true; - id.regimplify = true; /* unused? */ - - insert_decl_map (&id, wd->block, DECL_INITIAL (inner_fn)); - - wd->decl_map->traverse<auto_vec<struct cilk_decls> *, fill_decls_vec> (&vd); - vd.qsort (compare_decls); - /* We don't want the private variables any more. */ - FOR_EACH_VEC_ELT (vd, j, c) - if (*(c->val) == error_mark_node) - *(c->val) = nested ? copy_decl_no_change (c->key, &id) - : copy_decl_for_cilk (c->key, &id); - - 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 - flag_exceptions && !flag_non_call_exceptions. */ - throws = false ; - (void) walk_tree_without_duplicates (stmt_p, check_outlined_calls, &throws); -} - -/* Generate the body of a wrapper function that assigns the - result of the expression RHS into RECEIVER. RECEIVER must - be NULL if this is not a spawn -- the wrapper will return - a value. If this is a spawn, the wrapper will return void. */ - -static tree -create_cilk_wrapper_body (tree stmt, struct wrapper_data *wd) -{ - const tree outer = current_function_decl; - tree fndecl; - tree p; - - /* Build the type of the wrapper and its argument list from the - variables that it requires. */ - build_wrapper_type (wd); - - /* Emit a function that takes WRAPPER_PARMS incoming and applies ARGS - (modified) to the wrapped function. Return the wrapper and modified ARGS - to the caller to generate a function call. */ - fndecl = create_cilk_helper_decl (wd); - push_struct_function (fndecl); - if (wd->nested && (wd->type == CILK_BLOCK_FOR)) - { - gcc_assert (TREE_VALUE (wd->arglist) == NULL_TREE); - TREE_VALUE (wd->arglist) = build2 (FDESC_EXPR, ptr_type_node, - fndecl, integer_one_node); - } - DECL_ARGUMENTS (fndecl) = wd->parms; - - for (p = wd->parms; p; p = TREE_CHAIN (p)) - DECL_CONTEXT (p) = fndecl; - - /* The statement containing the spawn expression might create temporaries with - destructors defined; if so we need to add a CLEANUP_POINT_EXPR to ensure - the expression is properly gimplified. */ - stmt = fold_build_cleanup_point_expr (void_type_node, stmt); - - gcc_assert (!DECL_SAVED_TREE (fndecl)); - cilk_install_body_with_frame_cleanup (fndecl, stmt, (void *) wd); - gcc_assert (DECL_SAVED_TREE (fndecl)); - - pop_cfun_to (outer); - - /* Recognize the new function. */ - call_graph_add_fn (fndecl); - return fndecl; -} - -/* Initializes the wrapper data structure. */ - -static void -init_wd (struct wrapper_data *wd, enum cilk_block_type type) -{ - wd->type = type; - wd->fntype = NULL_TREE; - wd->context = current_function_decl; - wd->decl_map = new hash_map<tree, tree>; - /* _Cilk_for bodies are always nested. Others start off as - normal functions. */ - wd->nested = (type == CILK_BLOCK_FOR); - wd->arglist = NULL_TREE; - wd->argtypes = NULL_TREE; - wd->block = NULL_TREE; -} - -/* Clears the wrapper data structure. */ - -static void -free_wd (struct wrapper_data *wd) -{ - delete wd->decl_map; - wd->nested = false; - wd->arglist = NULL_TREE; - wd->argtypes = NULL_TREE; - wd->parms = NULL_TREE; -} - - - /* Given a variable in an expression to be extracted into - a helper function, declare the helper function parameter - to receive it. - - On entry the value of the (key, value) pair may be - - (*, error_mark_node) -- Variable is private to helper function, - do nothing. - - (var, var) -- Reference to outer scope (function or global scope). - - (var, integer 0) -- Capture by value, save newly-declared PARM_DECL - for value in value slot. - - (var, integer 1) -- Capture by reference, declare pointer to type - as new PARM_DECL and store (spawn_stmt (indirect_ref (parm)). - - (var, ???) -- Pure output argument, handled similarly to above. -*/ - -bool -declare_one_free_variable (tree var0, tree *map0) -{ - const_tree var = var0; - tree map = *map0; - tree var_type = TREE_TYPE (var), arg_type; - bool by_reference; - tree parm; - - gcc_assert (DECL_P (var)); - - /* Ignore truly local variables. */ - if (map == error_mark_node) - return true; - /* Ignore references to the parent function. */ - if (map == var) - return true; - - gcc_assert (TREE_CODE (map) == INTEGER_CST); - - /* A value is passed by reference if: - - 1. It is addressable, so that a copy may not be made. - 2. It is modified in the spawned statement. - In the future this function may want to arrange - a warning if the spawned statement is a loop body - because an output argument would indicate a race. - Note: Earlier passes must have marked the variable addressable. - 3. It is expensive to copy. */ - by_reference = - (TREE_ADDRESSABLE (var_type) - /* Arrays must be passed by reference. This is required for C - semantics -- arrays are not first class objects. Other - aggregate types can and should be passed by reference if - they are not passed to the spawned function. We aren't yet - distinguishing safe uses in argument calculation from unsafe - uses as outgoing function arguments, so we make a copy to - stabilize the value. */ - || TREE_CODE (var_type) == ARRAY_TYPE - || (tree) map == integer_one_node); - - if (by_reference) - var_type = build_qualified_type (build_pointer_type (var_type), - TYPE_QUAL_RESTRICT); - gcc_assert (!TREE_ADDRESSABLE (var_type)); - - /* Maybe promote to int. */ - if (INTEGRAL_TYPE_P (var_type) && COMPLETE_TYPE_P (var_type) - && tree_int_cst_lt (TYPE_SIZE (var_type), TYPE_SIZE (integer_type_node))) - arg_type = integer_type_node; - else - arg_type = var_type; - - parm = build_decl (UNKNOWN_LOCATION, PARM_DECL, NULL_TREE, var_type); - DECL_ARG_TYPE (parm) = arg_type; - DECL_ARTIFICIAL (parm) = 0; - TREE_READONLY (parm) = 1; - - if (by_reference) - { - parm = build1 (INDIRECT_REF, TREE_TYPE (var_type), parm); - parm = build1 (PAREN_EXPR, void_type_node, parm); - } - *map0 = parm; - return true; -} - -/* Returns a wrapper function for a _Cilk_spawn. */ - -static tree -create_cilk_wrapper (tree exp, tree *args_out) -{ - struct wrapper_data wd; - tree fndecl; - unsigned int j; - struct cilk_decls * c; - auto_vec<struct cilk_decls> vd; - - init_wd (&wd, CILK_BLOCK_SPAWN); - - if (TREE_CODE (exp) == CONVERT_EXPR) - exp = TREE_OPERAND (exp, 0); - - /* Special handling for top level INIT_EXPR. Usually INIT_EXPR means the - variable is defined in the spawned expression and can be private to the - spawn helper. A top level INIT_EXPR defines a variable to be initialized - by spawn and the variable must remain in the outer function. */ - if (TREE_CODE (exp) == INIT_EXPR) - { - extract_free_variables (TREE_OPERAND (exp, 0), &wd, ADD_WRITE); - extract_free_variables (TREE_OPERAND (exp, 1), &wd, ADD_READ); - /* TREE_TYPE should be void. Be defensive. */ - if (TREE_TYPE (exp) != void_type_node) - extract_free_variables (TREE_TYPE (exp), &wd, ADD_READ); - } - else - extract_free_variables (exp, &wd, ADD_READ); - wd.decl_map->traverse<auto_vec<struct cilk_decls> *, fill_decls_vec> (&vd); - vd.qsort (compare_decls); - FOR_EACH_VEC_ELT (vd, j, c) - declare_one_free_variable (c->key, c->val); - - wd.block = TREE_BLOCK (exp); - if (!wd.block) - wd.block = DECL_INITIAL (current_function_decl); - - /* Now fvars maps the old variable to incoming variable. Update - the expression and arguments to refer to the new names. */ - fndecl = create_cilk_wrapper_body (exp, &wd); - *args_out = wd.arglist; - - free_wd (&wd); - - return fndecl; -} - -/* Transform *SPAWN_P, a spawned CALL_EXPR, to gimple. *SPAWN_P can be a - CALL_EXPR, INIT_EXPR or MODIFY_EXPR. Returns GS_OK if everything is fine, - and GS_UNHANDLED, otherwise. */ - -int -gimplify_cilk_spawn (tree *spawn_p) -{ - tree expr = *spawn_p; - tree function, call1, call2, new_args; - tree ii_args = NULL_TREE; - int total_args = 0, ii = 0; - tree *arg_array; - tree setjmp_cond_expr = NULL_TREE; - tree setjmp_expr, spawn_expr, setjmp_value = NULL_TREE; - - cfun->calls_cilk_spawn = 1; - cfun->is_cilk_function = 1; - - /* Remove CLEANUP_POINT_EXPR and EXPR_STMT from *spawn_p. */ - while (TREE_CODE (expr) == CLEANUP_POINT_EXPR - || TREE_CODE (expr) == EXPR_STMT) - expr = TREE_OPERAND (expr, 0); - - new_args = NULL; - function = create_cilk_wrapper (expr, &new_args); - - /* This should give the number of parameters. */ - total_args = list_length (new_args); - if (total_args) - arg_array = XNEWVEC (tree, total_args); - else - arg_array = NULL; - - ii_args = new_args; - for (ii = 0; ii < total_args; ii++) - { - arg_array[ii] = TREE_VALUE (ii_args); - ii_args = TREE_CHAIN (ii_args); - } - - TREE_USED (function) = 1; - rest_of_decl_compilation (function, 0, 0); - - call1 = cilk_call_setjmp (cfun->cilk_frame_decl); - - if (arg_array == NULL || *arg_array == NULL_TREE) - call2 = build_call_expr (function, 0); - else - call2 = build_call_expr_loc_array (EXPR_LOCATION (*spawn_p), function, - total_args, arg_array); - *spawn_p = alloc_stmt_list (); - tree f_ptr_type = build_pointer_type (TREE_TYPE (cfun->cilk_frame_decl)); - tree frame_ptr = build1 (ADDR_EXPR, f_ptr_type, cfun->cilk_frame_decl); - tree save_fp = build_call_expr (cilk_save_fp_fndecl, 1, frame_ptr); - append_to_statement_list (save_fp, spawn_p); - setjmp_value = create_tmp_var (TREE_TYPE (call1)); - setjmp_expr = fold_build2 (MODIFY_EXPR, void_type_node, setjmp_value, call1); - - append_to_statement_list_force (setjmp_expr, spawn_p); - - setjmp_cond_expr = fold_build2 (EQ_EXPR, TREE_TYPE (call1), setjmp_value, - build_int_cst (TREE_TYPE (call1), 0)); - spawn_expr = fold_build3 (COND_EXPR, void_type_node, setjmp_cond_expr, - call2, build_empty_stmt (EXPR_LOCATION (call1))); - append_to_statement_list (spawn_expr, spawn_p); - - free (arg_array); - return GS_OK; -} - -/* Make the frames necessary for a spawn call. */ - -tree -make_cilk_frame (tree fn) -{ - struct function *f = DECL_STRUCT_FUNCTION (fn); - tree decl; - - if (f->cilk_frame_decl) - return f->cilk_frame_decl; - - decl = build_decl (EXPR_LOCATION (fn), VAR_DECL, NULL_TREE, - cilk_frame_type_decl); - DECL_CONTEXT (decl) = fn; - DECL_SEEN_IN_BIND_EXPR_P (decl) = 1; - f->cilk_frame_decl = decl; - return decl; -} - -/* 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. */ - -static void -add_variable (struct wrapper_data *wd, tree var, enum add_variable_type how) -{ - tree *valp = wd->decl_map->get (var); - if (valp) - { - tree val = (tree) *valp; - /* If the variable is local, do nothing. */ - if (val == error_mark_node) - return; - /* If the variable was entered with itself as value, - meaning it belongs to an outer scope, do not alter - the value. */ - if (val == var) - return; - /* A statement expression may cause a variable to be - bound twice, once in BIND_EXPR and again in a - DECL_EXPR. That case caused a return in the - test above. Any other duplicate definition is - an error. */ - gcc_assert (how != ADD_BIND); - if (how != ADD_WRITE) - return; - /* This variable might have been entered as read but is now written. */ - *valp = var; - wd->nested = true; - return; - } - else - { - tree val = NULL_TREE; - - /* Nested function rewriting silently discards hard register - assignments for function scope variables, and they wouldn't - work anyway. Warn here. This misses one case: if the - register variable is used as the loop bound or increment it - has already been added to the map. */ - if ((how != ADD_BIND) && VAR_P (var) - && !DECL_EXTERNAL (var) && DECL_HARD_REGISTER (var)) - warning (0, "register assignment ignored for %qD used in Cilk block", - var); - - switch (how) - { - /* ADD_BIND means always make a fresh new variable. */ - case ADD_BIND: - val = error_mark_node; - break; - /* ADD_READ means - 1. For cilk_for, refer to the outer scope definition as-is - 2. For a spawned block, take a scalar in an rgument - and otherwise refer to the outer scope definition as-is. - 3. For a spawned call, take a scalar in an argument. */ - case ADD_READ: - switch (wd->type) - { - case CILK_BLOCK_FOR: - val = var; - break; - case CILK_BLOCK_SPAWN: - if (TREE_ADDRESSABLE (var)) - { - val = var; - wd->nested = true; - break; - } - val = integer_zero_node; - break; - } - break; - case ADD_WRITE: - switch (wd->type) - { - case CILK_BLOCK_FOR: - val = var; - wd->nested = true; - break; - case CILK_BLOCK_SPAWN: - if (TREE_ADDRESSABLE (var)) - val = integer_one_node; - else - { - val = var; - wd->nested = true; - } - break; - } - } - wd->decl_map->put (var, val); - } -} - -/* Find the variables referenced in an expression T. This does not avoid - duplicates because a variable may be read in one context and written in - another. HOW describes the context in which the reference is seen. If - NESTED is true a nested function is being generated and variables in the - original context should not be remapped. */ - -static void -extract_free_variables (tree t, struct wrapper_data *wd, - enum add_variable_type how) -{ - if (t == NULL_TREE) - return; - - enum tree_code code = TREE_CODE (t); - bool is_expr = IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (code)); - - if (is_expr) - extract_free_variables (TREE_TYPE (t), wd, ADD_READ); - - switch (code) - { - case ERROR_MARK: - case IDENTIFIER_NODE: - case VOID_CST: - case INTEGER_CST: - case REAL_CST: - case FIXED_CST: - case STRING_CST: - case BLOCK: - case PLACEHOLDER_EXPR: - case FIELD_DECL: - case VOID_TYPE: - case REAL_TYPE: - /* These do not contain variable references. */ - return; - - case SSA_NAME: - /* Currently we don't see SSA_NAME. */ - extract_free_variables (SSA_NAME_VAR (t), wd, how); - return; - - case LABEL_DECL: - /* This might be a reference to a label outside the Cilk block, - which is an error, or a reference to a label in the Cilk block - that we haven't seen yet. We can't tell. Ignore it. An - invalid use will cause an error later in copy_decl_for_cilk. */ - return; - - case RESULT_DECL: - if (wd->type != CILK_BLOCK_SPAWN) - TREE_ADDRESSABLE (t) = 1; - /* FALLTHRU */ - case VAR_DECL: - case PARM_DECL: - if (!is_global_var (t)) - add_variable (wd, t, how); - return; - - case NON_LVALUE_EXPR: - case CONVERT_EXPR: - case NOP_EXPR: - 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); - return; - - case MODIFY_EXPR: - case PREDECREMENT_EXPR: - case PREINCREMENT_EXPR: - case POSTDECREMENT_EXPR: - case POSTINCREMENT_EXPR: - /* These write their result. */ - extract_free_variables (TREE_OPERAND (t, 0), wd, ADD_WRITE); - extract_free_variables (TREE_OPERAND (t, 1), wd, ADD_READ); - return; - - case ADDR_EXPR: - /* This might modify its argument, and the value needs to be - passed by reference in any case to preserve identity and - type if is a promoting type. In the case of a nested loop - just notice that we touch the variable. It will already - be addressable, and marking it modified will cause a spurious - warning about writing the control variable. */ - if (wd->type != CILK_BLOCK_SPAWN) - extract_free_variables (TREE_OPERAND (t, 0), wd, ADD_READ); - else - extract_free_variables (TREE_OPERAND (t, 0), wd, ADD_WRITE); - return; - - case ARRAY_REF: - /* Treating ARRAY_REF and BIT_FIELD_REF identically may - mark the array as written but the end result is correct - because the array is passed by pointer anyway. */ - case BIT_FIELD_REF: - /* Propagate the access type to the object part of which - is being accessed here. As for ADDR_EXPR, don't do this - in a nested loop, unless the access is to a fixed index. */ - if (wd->type != CILK_BLOCK_FOR || TREE_CONSTANT (TREE_OPERAND (t, 1))) - extract_free_variables (TREE_OPERAND (t, 0), wd, how); - else - extract_free_variables (TREE_OPERAND (t, 0), wd, ADD_READ); - extract_free_variables (TREE_OPERAND (t, 1), wd, ADD_READ); - extract_free_variables (TREE_OPERAND (t, 2), wd, ADD_READ); - return; - - case TREE_LIST: - extract_free_variables (TREE_PURPOSE (t), wd, ADD_READ); - extract_free_variables (TREE_VALUE (t), wd, ADD_READ); - extract_free_variables (TREE_CHAIN (t), wd, ADD_READ); - return; - - case TREE_VEC: - { - int len = TREE_VEC_LENGTH (t); - int i; - for (i = 0; i < len; i++) - extract_free_variables (TREE_VEC_ELT (t, i), wd, ADD_READ); - return; - } - - case VECTOR_CST: - { - unsigned ii = 0; - for (ii = 0; ii < VECTOR_CST_NELTS (t); ii++) - extract_free_variables (VECTOR_CST_ELT (t, ii), wd, ADD_READ); - break; - } - - case COMPLEX_CST: - extract_free_variables (TREE_REALPART (t), wd, ADD_READ); - extract_free_variables (TREE_IMAGPART (t), wd, ADD_READ); - return; - - case BIND_EXPR: - { - tree decl; - for (decl = BIND_EXPR_VARS (t); decl; decl = TREE_CHAIN (decl)) - { - add_variable (wd, decl, ADD_BIND); - /* A self-referential initialization is no problem because - we already entered the variable into the map as local. */ - extract_free_variables (DECL_INITIAL (decl), wd, ADD_READ); - extract_free_variables (DECL_SIZE (decl), wd, ADD_READ); - extract_free_variables (DECL_SIZE_UNIT (decl), wd, ADD_READ); - } - extract_free_variables (BIND_EXPR_BODY (t), wd, ADD_READ); - return; - } - - case STATEMENT_LIST: - { - tree_stmt_iterator i; - for (i = tsi_start (t); !tsi_end_p (i); tsi_next (&i)) - extract_free_variables (*tsi_stmt_ptr (i), wd, ADD_READ); - return; - } - - case TARGET_EXPR: - { - extract_free_variables (TREE_OPERAND (t, 0), wd, ADD_BIND); - extract_free_variables (TREE_OPERAND (t, 1), wd, ADD_READ); - extract_free_variables (TREE_OPERAND (t, 2), wd, ADD_READ); - if (TREE_OPERAND (t, 3) != TREE_OPERAND (t, 1)) - extract_free_variables (TREE_OPERAND (t, 3), wd, ADD_READ); - return; - } - - case RETURN_EXPR: - if (TREE_NO_WARNING (t)) - { - gcc_assert (errorcount); - return; - } - return; - - case DECL_EXPR: - if (TREE_CODE (DECL_EXPR_DECL (t)) != TYPE_DECL) - extract_free_variables (DECL_EXPR_DECL (t), wd, ADD_BIND); - return; - - case INTEGER_TYPE: - case ENUMERAL_TYPE: - case BOOLEAN_TYPE: - extract_free_variables (TYPE_MIN_VALUE (t), wd, ADD_READ); - extract_free_variables (TYPE_MAX_VALUE (t), wd, ADD_READ); - return; - - case POINTER_TYPE: - extract_free_variables (TREE_TYPE (t), wd, ADD_READ); - break; - - case ARRAY_TYPE: - extract_free_variables (TREE_TYPE (t), wd, ADD_READ); - extract_free_variables (TYPE_DOMAIN (t), wd, ADD_READ); - return; - - case RECORD_TYPE: - extract_free_variables (TYPE_FIELDS (t), wd, ADD_READ); - return; - - case METHOD_TYPE: - extract_free_variables (TYPE_ARG_TYPES (t), wd, ADD_READ); - extract_free_variables (TYPE_METHOD_BASETYPE (t), wd, ADD_READ); - return; - - case AGGR_INIT_EXPR: - { - int len = 0; - int ii = 0; - extract_free_variables (TREE_OPERAND (t, 1), wd, ADD_READ); - if (TREE_CODE (TREE_OPERAND (t, 0)) == INTEGER_CST) - { - len = TREE_INT_CST_LOW (TREE_OPERAND (t, 0)); - - for (ii = 3; ii < len; ii++) - extract_free_variables (TREE_OPERAND (t, ii), wd, ADD_READ); - extract_free_variables (TREE_TYPE (t), wd, ADD_READ); - } - break; - } - - case CALL_EXPR: - { - int len = 0; - int ii = 0; - if (TREE_CODE (TREE_OPERAND (t, 0)) == INTEGER_CST) - { - len = TREE_INT_CST_LOW (TREE_OPERAND (t, 0)); - - for (ii = 0; ii < len; ii++) - extract_free_variables (TREE_OPERAND (t, ii), wd, ADD_READ); - extract_free_variables (TREE_TYPE (t), wd, ADD_READ); - } - 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) - { - int i, len; - - /* Walk over all the sub-trees of this operand. */ - len = TREE_CODE_LENGTH (code); - - /* Go through the subtrees. We need to do this in forward order so - that the scope of a FOR_EXPR is handled properly. */ - for (i = 0; i < len; ++i) - extract_free_variables (TREE_OPERAND (t, i), wd, ADD_READ); - } - } -} - -/* Add appropriate frames needed for a Cilk spawned function call, FNDECL. - Returns the __cilkrts_stack_frame * variable. */ - -tree -insert_cilk_frame (tree fndecl) -{ - tree addr, body, enter, out, orig_body; - location_t loc = EXPR_LOCATION (fndecl); - - if (!cfun || cfun->decl != fndecl) - push_cfun (DECL_STRUCT_FUNCTION (fndecl)); - - tree decl = cfun->cilk_frame_decl; - if (!decl) - { - tree *saved_tree = &DECL_SAVED_TREE (fndecl); - decl = make_cilk_frame (fndecl); - add_local_decl (cfun, decl); - - addr = build1 (ADDR_EXPR, cilk_frame_ptr_type_decl, decl); - enter = build_call_expr (cilk_enter_fndecl, 1, addr); - out = create_cilk_function_exit (cfun->cilk_frame_decl, false, true); - - /* The new body will be: - __cilkrts_enter_frame_1 (&sf); - try { - orig_body; - } - finally { - __cilkrts_pop_frame (&sf); - __cilkrts_leave_frame (&sf); - } */ - - body = alloc_stmt_list (); - orig_body = *saved_tree; - - if (TREE_CODE (orig_body) == BIND_EXPR) - orig_body = BIND_EXPR_BODY (orig_body); - - append_to_statement_list (enter, &body); - append_to_statement_list (build_stmt (loc, TRY_FINALLY_EXPR, orig_body, - out), &body); - if (TREE_CODE (*saved_tree) == BIND_EXPR) - BIND_EXPR_BODY (*saved_tree) = body; - else - *saved_tree = body; - } - return decl; -} - -/* Wraps CALL, a CALL_EXPR, into a CILK_SPAWN_STMT tree and returns it. */ - -tree -build_cilk_spawn (location_t loc, tree call) -{ - if (!cilk_set_spawn_marker (loc, call)) - return error_mark_node; - tree spawn_stmt = build1 (CILK_SPAWN_STMT, TREE_TYPE (call), call); - TREE_SIDE_EFFECTS (spawn_stmt) = 1; - return spawn_stmt; -} - -/* Returns a tree of type CILK_SYNC_STMT. */ - -tree -build_cilk_sync (void) -{ - tree sync = build0 (CILK_SYNC_STMT, void_type_node); - TREE_SIDE_EFFECTS (sync) = 1; - return sync; -} - -/* Helper for contains_cilk_spawn_stmt, callback for walk_tree. Return - non-null tree if TP contains CILK_SPAWN_STMT. */ - -static tree -contains_cilk_spawn_stmt_walker (tree *tp, int *, void *) -{ - if (TREE_CODE (*tp) == CILK_SPAWN_STMT) - return *tp; - else - return NULL_TREE; -} - -/* Returns true if EXPR or any of its subtrees contain CILK_SPAWN_STMT - node. */ - -bool -contains_cilk_spawn_stmt (tree expr) -{ - return walk_tree (&expr, contains_cilk_spawn_stmt_walker, NULL, NULL) - != NULL_TREE; -} - -/* Return a error location for EXPR if LOC is not set. */ - -static location_t -get_error_location (tree expr, location_t loc) -{ - if (loc == UNKNOWN_LOCATION) - { - if (TREE_CODE (expr) == MODIFY_EXPR) - expr = TREE_OPERAND (expr, 0); - loc = EXPR_LOCATION (expr); - } - return loc; -} - -/* Check that no array notation or spawn statement is in EXPR. - If not true generate an error at LOC for ARRAY_GMSGID or - SPAWN_MSGID. */ - -bool -check_no_cilk (tree expr, const char *array_msgid, const char *spawn_msgid, - location_t loc) -{ - if (!flag_cilkplus) - return false; - if (contains_array_notation_expr (expr)) - { - loc = get_error_location (expr, loc); - error_at (loc, array_msgid); - return true; - } - if (walk_tree (&expr, contains_cilk_spawn_stmt_walker, NULL, NULL)) - { - loc = get_error_location (expr, loc); - error_at (loc, spawn_msgid); - return true; - } - return false; -} |