Commit 74558dd9 by Balaji V. Iyer Committed by Balaji V. Iyer

Added support for Cilk Plus SIMD-enabled functions for C++.

gcc/c/c-parser.c
2014-01-23  Balaji V. Iyer  <balaji.v.iyer@intel.com>

        * c-parser.c (c_finish_omp_declare_simd): Made "cilk simd function"
        attribute an attribute without value.

gcc/cp/ChangeLog
2014-01-23  Balaji V. Iyer  <balaji.v.iyer@intel.com>

        * parser.c (cp_parser_direct_declarator): When Cilk Plus is enabled
        see if there is an attribute after function decl.  If so, then
        parse them now.
        (cp_parser_late_return_type_opt): Handle parsing of Cilk Plus SIMD
        enabled function late parsing.
        (cp_parser_gnu_attribute_list): Parse all the tokens for the vector
        attribute for a SIMD-enabled function.
        (cp_parser_omp_all_clauses): Skip parsing to the end of pragma when
        the function is used by SIMD-enabled function (indicated by NULL
        pragma token).   Added 3 new clauses: PRAGMA_CILK_CLAUSE_MASK,
        PRAGMA_CILK_CLAUSE_NOMASK and PRAGMA_CILK_CLAUSE_VECTORLENGTH
        (cp_parser_cilk_simd_vectorlength): Modified this function to handle
        vectorlength clause in SIMD-enabled function and #pragma SIMD's
        vectorlength clause.  Added a new bool parameter to differentiate
        between the two.
        (cp_parser_cilk_simd_fn_vector_attrs): New function.
        (is_cilkplus_vector_p): Likewise.
        (cp_parser_late_parsing_elem_fn_info): Likewise.
        (cp_parser_omp_clause_name): Added a check for "mask", "nomask"
        and "vectorlength" clauses when Cilk Plus is enabled.
        (cp_parser_omp_clause_linear): Added a new parameter of type bool
        and emit a sorry message when step size is a parameter.
        * parser.h (cp_parser::cilk_simd_fn_info): New field.
        * decl.c (grokfndecl): Added flag_enable_cilkplus along with
        flag_openmp.
        * pt.c (apply_late_template_attributes): Likewise.

testsuite/ChangeLog
2014-01-23  Balaji V. Iyer  <balaji.v.iyer@intel.com>

        * g++.dg/cilk-plus/cilk-plus.exp: Called the C/C++ common tests for
        SIMD enabled function.
        * g++.dg/cilk-plus/ef_test.C: New test.
        * c-c++-common/cilk-plus/ef_error3.c: Made certain messages C specific
        and added C++ ones.
        * c-c++-common/cilk-plus/vlength_errors.c: Added new dg-error tags
        to differenciate C error messages from C++ ones.

From-SVN: r206975
parent d5ecead9
2014-01-23 Balaji V. Iyer <balaji.v.iyer@intel.com>
* c-parser.c (c_finish_omp_declare_simd): Made "cilk simd function"
attribute an attribute without value.
2014-01-23 Jakub Jelinek <jakub@redhat.com>
PR middle-end/58809
......
......@@ -12924,7 +12924,8 @@ c_finish_omp_declare_simd (c_parser *parser, tree fndecl, tree parms,
c = tree_cons (NULL_TREE, c, NULL_TREE);
if (is_cilkplus_cilk_simd_fn)
{
tree k = build_tree_list (get_identifier ("cilk simd function"), c);
tree k = build_tree_list (get_identifier ("cilk simd function"),
NULL_TREE);
TREE_CHAIN (k) = DECL_ATTRIBUTES (fndecl);
DECL_ATTRIBUTES (fndecl) = k;
}
......
2014-01-23 Balaji V. Iyer <balaji.v.iyer@intel.com>
* parser.c (cp_parser_direct_declarator): When Cilk Plus is enabled
see if there is an attribute after function decl. If so, then
parse them now.
(cp_parser_late_return_type_opt): Handle parsing of Cilk Plus SIMD
enabled function late parsing.
(cp_parser_gnu_attribute_list): Parse all the tokens for the vector
attribute for a SIMD-enabled function.
(cp_parser_omp_all_clauses): Skip parsing to the end of pragma when
the function is used by SIMD-enabled function (indicated by NULL
pragma token). Added 3 new clauses: PRAGMA_CILK_CLAUSE_MASK,
PRAGMA_CILK_CLAUSE_NOMASK and PRAGMA_CILK_CLAUSE_VECTORLENGTH
(cp_parser_cilk_simd_vectorlength): Modified this function to handle
vectorlength clause in SIMD-enabled function and #pragma SIMD's
vectorlength clause. Added a new bool parameter to differentiate
between the two.
(cp_parser_cilk_simd_fn_vector_attrs): New function.
(is_cilkplus_vector_p): Likewise.
(cp_parser_late_parsing_elem_fn_info): Likewise.
(cp_parser_omp_clause_name): Added a check for "mask", "nomask"
and "vectorlength" clauses when Cilk Plus is enabled.
(cp_parser_omp_clause_linear): Added a new parameter of type bool
and emit a sorry message when step size is a parameter.
* parser.h (cp_parser::cilk_simd_fn_info): New field.
* decl.c (grokfndecl): Added flag_enable_cilkplus along with
flag_openmp.
* pt.c (apply_late_template_attributes): Likewise.
2014-01-23 Jakub Jelinek <jakub@redhat.com>
PR middle-end/58809
......
......@@ -7674,7 +7674,7 @@ grokfndecl (tree ctype,
if (TYPE_NOTHROW_P (type) || nothrow_libfn_p (decl))
TREE_NOTHROW (decl) = 1;
if (flag_openmp)
if (flag_openmp || flag_enable_cilkplus)
{
/* Adjust "omp declare simd" attributes. */
tree ods = lookup_attribute ("omp declare simd", *attrlist);
......
......@@ -362,6 +362,13 @@ typedef struct GTY(()) cp_parser {
data structure with everything needed for parsing the clauses. */
cp_omp_declare_simd_data * GTY((skip)) omp_declare_simd;
/* When parsing the vector attribute in Cilk Plus SIMD-enabled function,
this is a pointer to data structure with everything needed for parsing
the clauses. The cp_omp_declare_simd_data struct will hold all the
necessary information, so creating another struct for this is not
necessary. */
cp_omp_declare_simd_data * GTY((skip)) cilk_simd_fn_info;
/* Nonzero if parsing a parameter list where 'auto' should trigger an implicit
template parameter. */
bool auto_is_implicit_function_template_parm_p;
......
......@@ -8613,7 +8613,7 @@ apply_late_template_attributes (tree *decl_p, tree attributes, int attr_flags,
{
*p = TREE_CHAIN (t);
TREE_CHAIN (t) = NULL_TREE;
if (flag_openmp
if ((flag_openmp || flag_enable_cilkplus)
&& is_attribute_p ("omp declare simd",
get_attribute_name (t))
&& TREE_VALUE (t))
......
2014-01-23 Balaji V. Iyer <balaji.v.iyer@intel.com>
* g++.dg/cilk-plus/cilk-plus.exp: Called the C/C++ common tests for
SIMD enabled function.
* g++.dg/cilk-plus/ef_test.C: New test.
* c-c++-common/cilk-plus/ef_error3.c: Made certain messages C specific
and added C++ ones.
* c-c++-common/cilk-plus/vlength_errors.c: Added new dg-error tags
to differenciate C error messages from C++ ones.
2014-01-23 Alex Velenko <Alex.Velenko@arm.com>
* gcc.target/aarch64/vld1-vst1_1.c: New test_case.
......
/* { dg-do compile { target { i?86-*-* x86_64-*-* } } } */
/* { dg-options "-fcilkplus -Wall" } */
__attribute__((vector (linear (x:y))))
__attribute__((vector (linear (x:y)))) /* { dg-message "parameter" "" { target c++ } } */
int func2 (int x, int y)
{ /* { dg-message "using parameters for" } */
{ /* { dg-message "using parameters for" "" { target c } } */
return (x+y);
}
......
......@@ -5,7 +5,8 @@
int z = Q;
__attribute__ ((vector (uniform(x), vectorlength (), linear (y:1) ))) /* { dg-error "expected expression" } */
__attribute__ ((vector (uniform(x), vectorlength (), linear (y:1) ))) /* { dg-error "expected expression" "" { target c } } */
/* { dg-error "expected primary-expression" "" { target c++ } 8 } */
int func2 (int x, int y)
{
int zq = 5;
......@@ -19,7 +20,8 @@ int func3 (int x, int y)
return x + (y*zq);
}
__attribute__ ((vector (uniform(x), linear (y:1), vectorlength (z) ))) /* { dg-error "vectorlength must be an integer" } */
__attribute__ ((vector (uniform(x), linear (y:1), vectorlength (z) ))) /* { dg-error "vectorlength must be an integer" "" { target c } } */
/* { dg-error "constant" "" { target c++ } 23 } */
int func4 (int x, int y)
{
int zq = 5;
......@@ -33,7 +35,8 @@ int func5 (int x, int y)
return x + (y*zq);
}
__attribute__ ((vector (uniform(x), vectorlength (z), linear (y:1)))) /* { dg-error "vectorlength must be an integer" } */
__attribute__ ((vector (uniform(x), vectorlength (z), linear (y:1)))) /* { dg-error "vectorlength must be an integer" "" { target c } } */
/* { dg-error "constant" "" { target c++ } 38 } */
int func6 (int x, int y)
{
int zq = 5;
......
......@@ -33,6 +33,9 @@ set TEST_EXTRA_LIBS "-L${library_var}/libcilkrts/.libs"
dg-init
# Run the tests that are shared with C.
g++-dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/PS/*.c]] ""
dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/SE/*.c]] "-O3" " "
dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/SE/*.c]] " " " "
dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/SE/*.c]] "-g -O2" " "
# Run the C++ only tests.
g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C]] ""
dg-finish
......
/* { dg-do run } */
/* { dg-options "-fcilkplus" } */
__attribute__((vector (nomask), vector(mask), vector(mask,linear(x:1))))
int func (int x)
{
return x+5;
}
__attribute__((vector(mask,uniform (y), linear(x:1))))
__attribute__((vector (nomask, uniform (x), linear(y:1))))
int func2 (int x, int y)
{
return x+y;
}
int func4 (int x, int y) __attribute__((vector, vector (nomask), vector (uniform(y), linear(x:1))));
template <class T, class R>
__attribute__((vector, vector(mask,uniform (y), linear(x:1))))
T func3 (T x, R y)
{
return x+(T)y;
}
int main (void)
{
if ((func3 (5, 4) + func2 (5, 4) + func (5) + (int) func3<long, int> (5, 4)) !=
(5 + 4) + (5 + 4) + (5 + 5) + (int) ((long)5 +(int)4))
__builtin_abort ();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment