]> gcc.gnu.org Git - gcc.git/commit
openmp: Add C/C++ support for "omp unroll" directive
authorFrederik Harwath <frederik@codesourcery.com>
Fri, 24 Mar 2023 17:14:23 +0000 (18:14 +0100)
committerKwok Cheung Yeung <kcy@codesourcery.com>
Thu, 18 May 2023 15:11:55 +0000 (16:11 +0100)
commitc17983cd052ccdf71ca2a2ba7cff60769046b0cf
tree3ddccb4d5d92049d548bdd89e4c63602a1c59f96
parentea770a4a9f62c7b6bbf2dab89e83d3a4154b2997
openmp: Add C/C++ support for "omp unroll" directive

This commit implements the C and the C++ front end changes to support
the "omp unroll" directive.  The execution of the loop transformation
relies on the pass that has been added as a part of the earlier
Fortran patch.

gcc/c-family/ChangeLog:

* c-gimplify.cc (c_genericize_control_stmt): Handle OMP_UNROLL.
* c-omp.cc: Add "unroll" to omp_directives[].
* c-pragma.cc: Add "unroll" to omp_pragmas_simd[].
* c-pragma.h (enum pragma_kind): Add PRAGMA_OMP_UNROLL to
pragma_kind and adjust PRAGMA_OMP__LAST_.
(enum pragma_omp_clause): Add PRAGMA_OMP_CLAUSE_FULL and
PRAGMA_OMP_CLAUSE_PARTIAL.

gcc/c/ChangeLog:

* c-parser.cc (c_parser_omp_clause_name): Handle "full" and
"partial" clauses.
(check_no_duplicate_clause): Change return type to bool and
return check result.
(c_parser_omp_clause_unroll_full): New function for parsing
the "unroll clause".
(c_parser_omp_clause_unroll_partial): New function for
parsing the "partial" clause.
(c_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_FULL
and PRAGMA_OMP_CLAUSE_PARTIAL.
(c_parser_nested_omp_unroll_clauses): New function for parsing
"omp unroll" directives following another directive.
(OMP_UNROLL_CLAUSE_MASK): New definition.
(c_parser_omp_unroll): New function for parsing "omp unroll"
loops that are not associated with another directive.
(c_parser_omp_construct): Handle PRAGMA_OMP_UNROLL.
* c-typeck.cc (c_finish_omp_clauses): Handle
OMP_CLAUSE_UNROLL_FULL, OMP_CLAUSE_UNROLL_PARTIAL,
and OMP_CLAUSE_UNROLL_NONE.

gcc/cp/ChangeLog:

* cp-gimplify.cc (cp_gimplify_expr): Handle OMP_UNROLL.
(cp_fold_r): Likewise.
(cp_genericize_r): Likewise.
* parser.cc (cp_parser_omp_clause_name): Handle "full" clause.
(check_no_duplicate_clause): Change return type to bool and
return check result.
(cp_parser_omp_clause_unroll_full): New function for parsing
the "unroll clause".
(cp_parser_omp_clause_unroll_partial): New function for
parsing the "partial" clause.
(cp_parser_omp_all_clauses): Handle OMP_CLAUSE_UNROLL and
OMP_CLAUSE_FULL.
(cp_parser_nested_omp_unroll_clauses): New function for parsing
"omp unroll" directives following another directive.
(cp_parser_omp_for_loop): Handle "omp unroll" directives
between directive and loop.
(OMP_UNROLL_CLAUSE_MASK): New definition.
(cp_parser_omp_unroll): New function for parsing "omp unroll"
loops that are not associated with another directive.

(cp_parser_omp_construct): Handle PRAGMA_OMP_UNROLL.
(cp_parser_pragma): Handle PRAGMA_OMP_UNROLL.
* pt.cc (tsubst_omp_clauses): Handle
OMP_CLAUSE_UNROLL_PARTIAL, OMP_CLAUSE_UNROLL_FULL, and
OMP_CLAUSE_UNROLL_NONE.
(tsubst_expr): Handle OMP_UNROLL.
* semantics.cc (finish_omp_clauses): Handle
OMP_CLAUSE_UNROLL_FULL, OMP_CLAUSE_UNROLL_PARTIAL,
and OMP_CLAUSE_UNROLL_NONE.

libgomp/ChangeLog:

* testsuite/libgomp.c++/loop-transforms/unroll-1.C: New test.
* testsuite/libgomp.c++/loop-transforms/unroll-2.C: New test.
* testsuite/libgomp.c-c++-common/loop-transforms/unroll-1.c: New test.

gcc/testsuite/ChangeLog:

* c-c++-common/gomp/loop-transforms/unroll-1.c: New test.
* c-c++-common/gomp/loop-transforms/unroll-2.c: New test.
* c-c++-common/gomp/loop-transforms/unroll-3.c: New test.
* c-c++-common/gomp/loop-transforms/unroll-4.c: New test.
* c-c++-common/gomp/loop-transforms/unroll-5.c: New test.
* c-c++-common/gomp/loop-transforms/unroll-6.c: New test.
* g++.dg/gomp/loop-transforms/unroll-1.C: New test.
* g++.dg/gomp/loop-transforms/unroll-2.C: New test.
* g++.dg/gomp/loop-transforms/unroll-3.C: New test.
29 files changed:
gcc/c-family/ChangeLog.omp
gcc/c-family/c-gimplify.cc
gcc/c-family/c-omp.cc
gcc/c-family/c-pragma.cc
gcc/c-family/c-pragma.h
gcc/c/ChangeLog.omp
gcc/c/c-parser.cc
gcc/c/c-typeck.cc
gcc/cp/ChangeLog.omp
gcc/cp/cp-gimplify.cc
gcc/cp/parser.cc
gcc/cp/pt.cc
gcc/cp/semantics.cc
gcc/testsuite/ChangeLog.omp
gcc/testsuite/c-c++-common/gomp/loop-transforms/unroll-1.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/gomp/loop-transforms/unroll-2.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/gomp/loop-transforms/unroll-3.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/gomp/loop-transforms/unroll-4.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/gomp/loop-transforms/unroll-5.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/gomp/loop-transforms/unroll-6.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/gomp/loop-transforms/unroll-7.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/gomp/loop-transforms/unroll-simd-1.c [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/loop-transforms/unroll-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/loop-transforms/unroll-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/loop-transforms/unroll-3.C [new file with mode: 0644]
libgomp/ChangeLog.omp
libgomp/testsuite/libgomp.c++/loop-transforms/unroll-1.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c++/loop-transforms/unroll-2.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c-c++-common/loop-transforms/unroll-1.c [new file with mode: 0644]
This page took 0.073318 seconds and 6 git commands to generate.