aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authorThomas Schwinge <tschwinge@gcc.gnu.org>2015-10-27 09:39:15 +0100
committerThomas Schwinge <tschwinge@gcc.gnu.org>2015-10-27 09:39:15 +0100
commit88bae6f494dc867edd8e6257658974d629bdc53b (patch)
tree6ab5ea8ba1b8126fa0e7ad76b11ad320ba2c7edb /gcc/c
parent5acdb61b69011e9d0f6b507fc37160b85ba04c51 (diff)
downloadgcc-88bae6f494dc867edd8e6257658974d629bdc53b.zip
gcc-88bae6f494dc867edd8e6257658974d629bdc53b.tar.gz
gcc-88bae6f494dc867edd8e6257658974d629bdc53b.tar.bz2
[PR c/64765, c/64880] Support OpenACC Combined Directives in C, C++
gcc/c-family/ PR c/64765 PR c/64880 * c-common.h (c_oacc_split_loop_clauses): Declare function. * c-omp.c (c_oacc_split_loop_clauses): New function. gcc/c/ PR c/64765 PR c/64880 * c-parser.c (c_parser_oacc_loop): Add mask, cclauses formal parameters, and handle these. Adjust all users. (c_parser_oacc_kernels, c_parser_oacc_parallel): Merge functions into... (c_parser_oacc_kernels_parallel): ... this new function. Adjust all users. * c-tree.h (c_finish_oacc_parallel, c_finish_oacc_kernels): Don't declare functions. (c_finish_omp_construct): Declare function. * c-typeck.c (c_finish_oacc_parallel, c_finish_oacc_kernels): Merge functions into... (c_finish_omp_construct): ... this new function. gcc/cp/ PR c/64765 PR c/64880 * cp-tree.h (finish_oacc_kernels, finish_oacc_parallel): Don't declare functions. (finish_omp_construct): Declare function. * parser.c (cp_parser_oacc_loop): Add p_name, mask, cclauses formal parameters, and handle these. Adjust all users. (cp_parser_oacc_kernels, cp_parser_oacc_parallel): Merge functions into... (cp_parser_oacc_kernels_parallel): ... this new function. Adjust all users. * semantics.c (finish_oacc_kernels, finish_oacc_parallel): Merge functions into... (finish_omp_construct): ... this new function. gcc/ * tree.h (OACC_PARALLEL_BODY, OACC_PARALLEL_CLAUSES) (OACC_KERNELS_BODY, OACC_KERNELS_CLAUSES, OACC_KERNELS_COMBINED) (OACC_PARALLEL_COMBINED): Don't define macros. Adjust all users. gcc/testsuite/ PR c/64765 PR c/64880 * c-c++-common/goacc/loop-1.c: Don't skip for C++. Don't prune sorry message. (PR64765): New function. * gfortran.dg/goacc/coarray_2.f90: XFAIL. * gfortran.dg/goacc/combined_loop.f90: Extend. Don't prune sorry message. * gfortran.dg/goacc/cray.f95: Refine prune directive. * gfortran.dg/goacc/parameter.f95: Likewise. libgomp/ * testsuite/libgomp.oacc-c-c++-common/combdir-1.c: New file. * testsuite/libgomp.oacc-fortran/combdir-1.f90: Likewise. From-SVN: r229404
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/ChangeLog19
-rw-r--r--gcc/c/c-parser.c148
-rw-r--r--gcc/c/c-tree.h3
-rw-r--r--gcc/c/c-typeck.c36
4 files changed, 94 insertions, 112 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index aed7a62..da4c801 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,22 @@
+2015-10-27 Thomas Schwinge <thomas@codesourcery.com>
+ James Norris <jnorris@codesourcery.com>
+ Cesar Philippidis <cesar@codesourcery.com>
+
+ PR c/64765
+ PR c/64880
+ * c-parser.c (c_parser_oacc_loop): Add mask, cclauses formal
+ parameters, and handle these. Adjust all users.
+ (c_parser_oacc_kernels, c_parser_oacc_parallel): Merge functions
+ into...
+ (c_parser_oacc_kernels_parallel): ... this new function. Adjust
+ all users.
+ * c-tree.h (c_finish_oacc_parallel, c_finish_oacc_kernels): Don't
+ declare functions.
+ (c_finish_omp_construct): Declare function.
+ * c-typeck.c (c_finish_oacc_parallel, c_finish_oacc_kernels):
+ Merge functions into...
+ (c_finish_omp_construct): ... this new function.
+
2015-10-22 Richard Biener <rguenther@suse.de>
* c-typeck.c (c_finish_omp_clauses): Properly convert operands
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index c8c6a2d..ec918c1 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -1237,7 +1237,6 @@ static vec<tree, va_gc> *c_parser_expr_list (c_parser *, bool, bool,
unsigned int * = NULL);
static void c_parser_oacc_enter_exit_data (c_parser *, bool);
static void c_parser_oacc_update (c_parser *);
-static tree c_parser_oacc_loop (location_t, c_parser *, char *);
static void c_parser_omp_construct (c_parser *);
static void c_parser_omp_threadprivate (c_parser *);
static void c_parser_omp_barrier (c_parser *);
@@ -12875,60 +12874,6 @@ c_parser_oacc_data (location_t loc, c_parser *parser)
}
/* OpenACC 2.0:
- # pragma acc kernels oacc-kernels-clause[optseq] new-line
- structured-block
-
- LOC is the location of the #pragma token.
-*/
-
-#define OACC_KERNELS_CLAUSE_MASK \
- ( (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_ASYNC) \
- | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPY) \
- | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPYIN) \
- | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPYOUT) \
- | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_CREATE) \
- | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_DEVICEPTR) \
- | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_IF) \
- | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT) \
- | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT_OR_COPY) \
- | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT_OR_COPYIN) \
- | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT_OR_COPYOUT) \
- | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT_OR_CREATE) \
- | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_WAIT) )
-
-static tree
-c_parser_oacc_kernels (location_t loc, c_parser *parser, char *p_name)
-{
- tree stmt, clauses = NULL_TREE, block;
-
- strcat (p_name, " kernels");
-
- if (c_parser_next_token_is (parser, CPP_NAME))
- {
- const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
- if (strcmp (p, "loop") == 0)
- {
- c_parser_consume_token (parser);
- block = c_begin_omp_parallel ();
- c_parser_oacc_loop (loc, parser, p_name);
- stmt = c_finish_oacc_kernels (loc, clauses, block);
- OACC_KERNELS_COMBINED (stmt) = 1;
- return stmt;
- }
- }
-
- clauses = c_parser_oacc_all_clauses (parser, OACC_KERNELS_CLAUSE_MASK,
- p_name);
-
- block = c_begin_omp_parallel ();
- add_stmt (c_parser_omp_structured_block (parser));
-
- stmt = c_finish_oacc_kernels (loc, clauses, block);
-
- return stmt;
-}
-
-/* OpenACC 2.0:
# pragma acc enter data oacc-enter-data-clause[optseq] new-line
or
@@ -13018,16 +12963,25 @@ c_parser_oacc_enter_exit_data (c_parser *parser, bool enter)
| (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_REDUCTION) )
static tree
-c_parser_oacc_loop (location_t loc, c_parser *parser, char *p_name)
+c_parser_oacc_loop (location_t loc, c_parser *parser, char *p_name,
+ omp_clause_mask mask, tree *cclauses)
{
- tree stmt, clauses, block;
-
strcat (p_name, " loop");
+ mask |= OACC_LOOP_CLAUSE_MASK;
- clauses = c_parser_oacc_all_clauses (parser, OACC_LOOP_CLAUSE_MASK, p_name);
+ tree clauses = c_parser_oacc_all_clauses (parser, mask, p_name,
+ cclauses == NULL);
+ if (cclauses)
+ {
+ clauses = c_oacc_split_loop_clauses (clauses, cclauses);
+ if (*cclauses)
+ c_finish_omp_clauses (*cclauses, false);
+ if (clauses)
+ c_finish_omp_clauses (clauses, false);
+ }
- block = c_begin_compound_stmt (true);
- stmt = c_parser_omp_for_loop (loc, parser, OACC_LOOP, clauses, NULL);
+ tree block = c_begin_compound_stmt (true);
+ tree stmt = c_parser_omp_for_loop (loc, parser, OACC_LOOP, clauses, NULL);
block = c_end_compound_stmt (loc, block, true);
add_stmt (block);
@@ -13035,12 +12989,32 @@ c_parser_oacc_loop (location_t loc, c_parser *parser, char *p_name)
}
/* OpenACC 2.0:
+ # pragma acc kernels oacc-kernels-clause[optseq] new-line
+ structured-block
+
+ or
+
# pragma acc parallel oacc-parallel-clause[optseq] new-line
structured-block
LOC is the location of the #pragma token.
*/
+#define OACC_KERNELS_CLAUSE_MASK \
+ ( (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_ASYNC) \
+ | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPY) \
+ | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPYIN) \
+ | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPYOUT) \
+ | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_CREATE) \
+ | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_DEVICEPTR) \
+ | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_IF) \
+ | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT) \
+ | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT_OR_COPY) \
+ | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT_OR_COPYIN) \
+ | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT_OR_COPYOUT) \
+ | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_PRESENT_OR_CREATE) \
+ | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_WAIT) )
+
#define OACC_PARALLEL_CLAUSE_MASK \
( (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_ASYNC) \
| (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_COPY) \
@@ -13061,11 +13035,26 @@ c_parser_oacc_loop (location_t loc, c_parser *parser, char *p_name)
| (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_WAIT) )
static tree
-c_parser_oacc_parallel (location_t loc, c_parser *parser, char *p_name)
+c_parser_oacc_kernels_parallel (location_t loc, c_parser *parser,
+ enum pragma_kind p_kind, char *p_name)
{
- tree stmt, clauses = NULL_TREE, block;
-
- strcat (p_name, " parallel");
+ omp_clause_mask mask;
+ enum tree_code code;
+ switch (p_kind)
+ {
+ case PRAGMA_OACC_KERNELS:
+ strcat (p_name, " kernels");
+ mask = OACC_KERNELS_CLAUSE_MASK;
+ code = OACC_KERNELS;
+ break;
+ case PRAGMA_OACC_PARALLEL:
+ strcat (p_name, " parallel");
+ mask = OACC_PARALLEL_CLAUSE_MASK;
+ code = OACC_PARALLEL;
+ break;
+ default:
+ gcc_unreachable ();
+ }
if (c_parser_next_token_is (parser, CPP_NAME))
{
@@ -13073,23 +13062,21 @@ c_parser_oacc_parallel (location_t loc, c_parser *parser, char *p_name)
if (strcmp (p, "loop") == 0)
{
c_parser_consume_token (parser);
- block = c_begin_omp_parallel ();
- c_parser_oacc_loop (loc, parser, p_name);
- stmt = c_finish_oacc_parallel (loc, clauses, block);
- OACC_PARALLEL_COMBINED (stmt) = 1;
- return stmt;
+ mask |= OACC_LOOP_CLAUSE_MASK;
+
+ tree block = c_begin_omp_parallel ();
+ tree clauses;
+ c_parser_oacc_loop (loc, parser, p_name, mask, &clauses);
+ return c_finish_omp_construct (loc, code, block, clauses);
}
}
- clauses = c_parser_oacc_all_clauses (parser, OACC_PARALLEL_CLAUSE_MASK,
- p_name);
+ tree clauses = c_parser_oacc_all_clauses (parser, mask, p_name);
- block = c_begin_omp_parallel ();
+ tree block = c_begin_omp_parallel ();
add_stmt (c_parser_omp_structured_block (parser));
- stmt = c_finish_oacc_parallel (loc, clauses, block);
-
- return stmt;
+ return c_finish_omp_construct (loc, code, block, clauses);
}
/* OpenACC 2.0:
@@ -16079,16 +16066,13 @@ c_parser_omp_construct (c_parser *parser)
stmt = c_parser_oacc_data (loc, parser);
break;
case PRAGMA_OACC_KERNELS:
+ case PRAGMA_OACC_PARALLEL:
strcpy (p_name, "#pragma acc");
- stmt = c_parser_oacc_kernels (loc, parser, p_name);
+ stmt = c_parser_oacc_kernels_parallel (loc, parser, p_kind, p_name);
break;
case PRAGMA_OACC_LOOP:
strcpy (p_name, "#pragma acc");
- stmt = c_parser_oacc_loop (loc, parser, p_name);
- break;
- case PRAGMA_OACC_PARALLEL:
- strcpy (p_name, "#pragma acc");
- stmt = c_parser_oacc_parallel (loc, parser, p_name);
+ stmt = c_parser_oacc_loop (loc, parser, p_name, mask, NULL);
break;
case PRAGMA_OACC_WAIT:
strcpy (p_name, "#pragma wait");
diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h
index bee03d3..04991f7 100644
--- a/gcc/c/c-tree.h
+++ b/gcc/c/c-tree.h
@@ -640,8 +640,7 @@ extern tree c_finish_bc_stmt (location_t, tree *, bool);
extern tree c_finish_goto_label (location_t, tree);
extern tree c_finish_goto_ptr (location_t, tree);
extern tree c_expr_to_decl (tree, bool *, bool *);
-extern tree c_finish_oacc_parallel (location_t, tree, tree);
-extern tree c_finish_oacc_kernels (location_t, tree, tree);
+extern tree c_finish_omp_construct (location_t, enum tree_code, tree, tree);
extern tree c_finish_oacc_data (location_t, tree, tree);
extern tree c_begin_omp_parallel (void);
extern tree c_finish_omp_parallel (location_t, tree, tree);
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index 61c5313..64ea1c2 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -11481,39 +11481,19 @@ c_expr_to_decl (tree expr, bool *tc ATTRIBUTE_UNUSED, bool *se)
return expr;
}
-/* Generate OACC_PARALLEL, with CLAUSES and BLOCK as its compound
- statement. LOC is the location of the OACC_PARALLEL. */
+/* Generate OMP construct CODE, with BODY and CLAUSES as its compound
+ statement. LOC is the location of the construct. */
tree
-c_finish_oacc_parallel (location_t loc, tree clauses, tree block)
+c_finish_omp_construct (location_t loc, enum tree_code code, tree body,
+ tree clauses)
{
- tree stmt;
-
- block = c_end_compound_stmt (loc, block, true);
-
- stmt = make_node (OACC_PARALLEL);
- TREE_TYPE (stmt) = void_type_node;
- OACC_PARALLEL_CLAUSES (stmt) = clauses;
- OACC_PARALLEL_BODY (stmt) = block;
- SET_EXPR_LOCATION (stmt, loc);
-
- return add_stmt (stmt);
-}
-
-/* Generate OACC_KERNELS, with CLAUSES and BLOCK as its compound
- statement. LOC is the location of the OACC_KERNELS. */
-
-tree
-c_finish_oacc_kernels (location_t loc, tree clauses, tree block)
-{
- tree stmt;
-
- block = c_end_compound_stmt (loc, block, true);
+ body = c_end_compound_stmt (loc, body, true);
- stmt = make_node (OACC_KERNELS);
+ tree stmt = make_node (code);
TREE_TYPE (stmt) = void_type_node;
- OACC_KERNELS_CLAUSES (stmt) = clauses;
- OACC_KERNELS_BODY (stmt) = block;
+ OMP_BODY (stmt) = body;
+ OMP_CLAUSES (stmt) = clauses;
SET_EXPR_LOCATION (stmt, loc);
return add_stmt (stmt);