aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorKirill Yukhin <kirill.yukhin@intel.com>2015-11-16 13:14:57 +0000
committerKirill Yukhin <kyukhin@gcc.gnu.org>2015-11-16 13:14:57 +0000
commitfff7721799b3bf7cabbcdf1096eeab18b68ef5d3 (patch)
tree5731243bcaf252b767216c4d28809a9959258645 /gcc
parent56b08a5894fd02a502b2b40897a2aa892f70caec (diff)
downloadgcc-fff7721799b3bf7cabbcdf1096eeab18b68ef5d3.zip
gcc-fff7721799b3bf7cabbcdf1096eeab18b68ef5d3.tar.gz
gcc-fff7721799b3bf7cabbcdf1096eeab18b68ef5d3.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/c-family/ChangeLog6
-rw-r--r--gcc/c-family/c-common.c32
-rw-r--r--gcc/c/ChangeLog5
-rw-r--r--gcc/c/c-parser.c23
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/parser.c8
-rw-r--r--gcc/doc/extend.texi16
-rw-r--r--gcc/omp-low.c5
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/c-c++-common/attr-simd-2.c21
-rw-r--r--gcc/testsuite/c-c++-common/attr-simd-3.c5
-rw-r--r--gcc/testsuite/c-c++-common/attr-simd.c38
13 files changed, 164 insertions, 12 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b5d3fe3..8fb0728 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2015-11-16 Kirill Yukhin <kirill.yukhin@intel.com>
+
+ * omp-low.c (pass_omp_simd_clone::gate): If target allows - call
+ without additional conditions.
+ * doc/extend.texi (@item simd): New.
+
2015-11-16 Tom de Vries <tom@codesourcery.com>
* passes.c (first_pass_instance): Remove variable.
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 7262cfd..518c5ef 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,9 @@
+2015-11-16 Kirill Yukhin <kirill.yukhin@intel.com>
+
+ * c-common.c (handle_simd_attribute): New.
+ (struct attribute_spec): Add entry for "simd".
+ (handle_simd_attribute): New.
+
2015-11-13 Kai Tietz <ktietz70@googlemail.com>
* c-lex.c (interpret_float): Use fold_convert.
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 89e978d..f8ccb6d 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -387,6 +387,7 @@ static tree handle_warn_unused_attribute (tree *, tree, tree, int, bool *);
static tree handle_returns_nonnull_attribute (tree *, tree, tree, int, bool *);
static tree handle_omp_declare_simd_attribute (tree *, tree, tree, int,
bool *);
+static tree handle_simd_attribute (tree *, tree, tree, int, bool *);
static tree handle_omp_declare_target_attribute (tree *, tree, tree, int,
bool *);
static tree handle_designated_init_attribute (tree *, tree, tree, int, bool *);
@@ -817,6 +818,8 @@ const struct attribute_spec c_common_attribute_table[] =
handle_omp_declare_simd_attribute, false },
{ "cilk simd function", 0, -1, true, false, false,
handle_omp_declare_simd_attribute, false },
+ { "simd", 0, 0, true, false, false,
+ handle_simd_attribute, false },
{ "omp declare target", 0, 0, true, false, false,
handle_omp_declare_target_attribute, false },
{ "alloc_align", 1, 1, false, true, true,
@@ -9021,6 +9024,35 @@ handle_omp_declare_simd_attribute (tree *, tree, tree, int, bool *)
return NULL_TREE;
}
+/* Handle a "simd" attribute. */
+
+static tree
+handle_simd_attribute (tree *node, tree name, tree, int, bool *no_add_attrs)
+{
+ if (TREE_CODE (*node) == FUNCTION_DECL)
+ {
+ if (lookup_attribute ("cilk simd function",
+ DECL_ATTRIBUTES (*node)) != NULL)
+ {
+ error_at (DECL_SOURCE_LOCATION (*node),
+ "%<__simd__%> attribute cannot be used in the same "
+ "function marked as a Cilk Plus SIMD-enabled function");
+ *no_add_attrs = true;
+ }
+ else
+ DECL_ATTRIBUTES (*node)
+ = tree_cons (get_identifier ("omp declare simd"),
+ NULL_TREE, DECL_ATTRIBUTES (*node));
+ }
+ else
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
/* Handle an "omp declare target" attribute; arguments as in
struct attribute_spec.handler. */
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 <kirill.yukhin@intel.com>
+
+ * c-parser.c (c_finish_omp_declare_simd): Look for
+ "simd" attribute as well. Update error message.
+
2015-11-14 Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
* 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<c_token> 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 %<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;
}
@@ -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;
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 322b693..7027d93 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2015-11-16 Kirill Yukhin <kirill.yukhin@intel.com>
+
+ * parser.c (cp_parser_late_parsing_cilk_simd_fn_info): Look for
+ "simd" attribute as well. Update error message.
+
2015-11-14 Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
* parser.c (cp_parser_omp_declare_target): Adjust.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 5e8614b..286c8db 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -35049,10 +35049,12 @@ cp_parser_late_parsing_cilk_simd_fn_info (cp_parser *parser, tree attrs)
cp_omp_declare_simd_data *info = parser->cilk_simd_fn_info;
int ii = 0;
- if (parser->omp_declare_simd != NULL)
+ if (parser->omp_declare_simd != NULL
+ || lookup_attribute ("simd", attrs))
{
- 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%> of %<simd%> attribute cannot be "
+ "used in the same function marked as a Cilk Plus SIMD-enabled "
+ " function");
XDELETE (parser->cilk_simd_fn_info);
parser->cilk_simd_fn_info = NULL;
return attrs;
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 4d64e14..f5c2fdf 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -3143,6 +3143,22 @@ one compiled with @option{-msse4.1} and another with @option{-mavx}.
At the function call it will create resolver @code{ifunc}, that will
dynamically call a clone suitable for current architecture.
+@item simd
+@cindex @code{simd} function attribute.
+This attribute enables creation of one or more function versions that
+can process multiple arguments using SIMD instructions from a
+single invocation. Specifying this attribute allows compiler to
+assume that such versions are available at link time (provided
+in the same or another translation unit). Generated versions are
+target dependent and described in corresponding Vector ABI document. For
+x86_64 target this document can be found
+@w{@uref{https://sourceware.org/glibc/wiki/libmvec?action=AttachFile&do=view&target=VectorABI.txt,here}}.
+The attribute should not be used together with Cilk Plus @code{vector}
+attribute on the same function.
+If the attribute is specified and @code{#pragma omp declare simd}
+present on a declaration and @code{-fopenmp} or @code{-fopenmp-simd}
+switch is specified, then the attribute is ignored.
+
@item target (@var{options})
@cindex @code{target} function attribute
Multiple target back ends implement the @code{target} attribute
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 58248d9..efcc971 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -18407,10 +18407,7 @@ public:
bool
pass_omp_simd_clone::gate (function *)
{
- return ((flag_openmp || flag_openmp_simd
- || flag_cilkplus
- || (in_lto_p && !flag_wpa))
- && (targetm.simd_clone.compute_vecsize_and_simdlen != NULL));
+ return targetm.simd_clone.compute_vecsize_and_simdlen != NULL;
}
} // anon namespace
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 82402bf..6b9370e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2015-11-16 Kirill Yukhin <kirill.yukhin@intel.com>
+
+ * 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.
+
2015-11-16 Alan Lawrence <alan.lawrence@arm.com>
* gcc.target/aarch64/vclz.c: Correctly place INHIB_OPTIMIZATION.
diff --git a/gcc/testsuite/c-c++-common/attr-simd-2.c b/gcc/testsuite/c-c++-common/attr-simd-2.c
new file mode 100644
index 0000000..dd08d18
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/attr-simd-2.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-fdump-tree-optimized -fopenmp-simd" } */
+
+#pragma omp declare simd
+extern
+#ifdef __cplusplus
+"C"
+#endif
+__attribute__((__simd__))
+int simd_attr (void)
+{
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump "omp declare simd" "optimized" } } */
+/* { dg-final { scan-assembler-times "_ZGVbN4_simd_attr:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVbM4_simd_attr:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVcN4_simd_attr:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVcM4_simd_attr:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVdN8_simd_attr:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVdM8_simd_attr:" 1 { target { i?86-*-* x86_64-*-* } } } } */
diff --git a/gcc/testsuite/c-c++-common/attr-simd-3.c b/gcc/testsuite/c-c++-common/attr-simd-3.c
new file mode 100644
index 0000000..2bbdf04
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/attr-simd-3.c
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+/* { dg-options "-fcilkplus" } */
+/* { dg-prune-output "undeclared here \\(not in a function\\)|\[^\n\r\]* was not declared in this scope" } */
+
+void f () __attribute__((__simd__, __vector__)); /* { dg-error "in the same function marked as a Cilk Plus" } */
diff --git a/gcc/testsuite/c-c++-common/attr-simd.c b/gcc/testsuite/c-c++-common/attr-simd.c
new file mode 100644
index 0000000..61974e3
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/attr-simd.c
@@ -0,0 +1,38 @@
+/* { dg-do compile } */
+/* { dg-options "-fdump-tree-optimized" } */
+
+extern
+#ifdef __cplusplus
+"C"
+#endif
+__attribute__((__simd__))
+int simd_attr (void)
+{
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump "simd_attr\[ \\t\]simdclone|vector" "optimized" } } */
+/* { dg-final { scan-assembler-times "_ZGVbN4_simd_attr:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVbM4_simd_attr:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVcN4_simd_attr:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVcM4_simd_attr:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVdN8_simd_attr:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVdM8_simd_attr:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+
+extern
+#ifdef __cplusplus
+"C"
+#endif
+__attribute__((simd))
+int simd_attr2 (void)
+{
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump "simd_attr2\[ \\t\]simdclone|vector" "optimized" } } */
+/* { dg-final { scan-assembler-times "_ZGVbN4_simd_attr2:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVbM4_simd_attr2:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVcN4_simd_attr2:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVcM4_simd_attr2:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVdN8_simd_attr2:" 1 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "_ZGVdM8_simd_attr2:" 1 { target { i?86-*-* x86_64-*-* } } } } */