From fff7721799b3bf7cabbcdf1096eeab18b68ef5d3 Mon Sep 17 00:00:00 2001 From: Kirill Yukhin Date: Mon, 16 Nov 2015 13:14:57 +0000 Subject: Add __attribute__((__simd__)) to GCC. gcc/ * omp-low.c (pass_omp_simd_clone::gate): If target allows - call without additional conditions. * doc/extend.texi (@item simd): New. gcc/c-family/ * c-common.c (handle_simd_attribute): New. (struct attribute_spec): Add entry for "simd". (handle_simd_attribute): New. gcc/c/ * c-parser.c (c_finish_omp_declare_simd): Look for "simd" attribute as well. Update error message. gcc/cp/ * parser.c (cp_parser_late_parsing_cilk_simd_fn_info): Look for "simd" attribute as well. Update error message. gcc/testsuite/ * c-c++-common/attr-simd.c: New test. * c-c++-common/attr-simd-2.c: New test. * c-c++-common/attr-simd-3.c: New test. From-SVN: r230422 --- gcc/c/ChangeLog | 5 +++++ gcc/c/c-parser.c | 23 ++++++++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index ce4d7c0..3868771 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,8 @@ +2015-11-16 Kirill Yukhin + + * c-parser.c (c_finish_omp_declare_simd): Look for + "simd" attribute as well. Update error message. + 2015-11-14 Trevor Saunders * c-parser.c (c_parser_omp_declare_target): Adjust. diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index e470234..e63148e 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -16141,10 +16141,13 @@ c_finish_omp_declare_simd (c_parser *parser, tree fndecl, tree parms, vec clauses) { if (flag_cilkplus - && clauses.exists () && !vec_safe_is_empty (parser->cilk_simd_fn_tokens)) + && (clauses.exists () + || lookup_attribute ("simd", DECL_ATTRIBUTES (fndecl))) + && !vec_safe_is_empty (parser->cilk_simd_fn_tokens)) { - error ("%<#pragma omp declare simd%> cannot be used in the same " - "function marked as a Cilk Plus SIMD-enabled function"); + error ("%<#pragma omp declare simd%> or % attribute cannot be " + "used in the same function marked as a Cilk Plus SIMD-enabled " + "function"); vec_free (parser->cilk_simd_fn_tokens); return; } @@ -16182,6 +16185,16 @@ c_finish_omp_declare_simd (c_parser *parser, tree fndecl, tree parms, parser->tokens = parser->cilk_simd_fn_tokens->address (); parser->tokens_avail = vec_safe_length (parser->cilk_simd_fn_tokens); is_cilkplus_cilk_simd_fn = true; + + if (lookup_attribute ("simd", DECL_ATTRIBUTES (fndecl)) != NULL) + { + error_at (DECL_SOURCE_LOCATION (fndecl), + "%<__simd__%> attribute cannot be used in the same " + "function marked as a Cilk Plus SIMD-enabled function"); + vec_free (parser->cilk_simd_fn_tokens); + return; + } + } else { @@ -16213,12 +16226,12 @@ c_finish_omp_declare_simd (c_parser *parser, tree fndecl, tree parms, if (c != NULL_TREE) c = tree_cons (NULL_TREE, c, NULL_TREE); if (is_cilkplus_cilk_simd_fn) - { + { tree k = build_tree_list (get_identifier ("cilk simd function"), NULL_TREE); TREE_CHAIN (k) = DECL_ATTRIBUTES (fndecl); DECL_ATTRIBUTES (fndecl) = k; - } + } c = build_tree_list (get_identifier ("omp declare simd"), c); TREE_CHAIN (c) = DECL_ATTRIBUTES (fndecl); DECL_ATTRIBUTES (fndecl) = c; -- cgit v1.1