diff options
author | Kwok Cheung Yeung <kcyeung@baylibre.com> | 2025-01-13 13:08:07 +0000 |
---|---|---|
committer | Sandra Loosemore <sloosemore@baylibre.com> | 2025-05-15 20:25:53 +0000 |
commit | 752ef8f4f5ddf9a3372e6d5dc08df6aa05a60ea3 (patch) | |
tree | b1b7c411ed2e11908955f8265441ac8f755d1905 /gcc | |
parent | bb8a5a0783a209512e8d814b4307e910fe141377 (diff) | |
download | gcc-752ef8f4f5ddf9a3372e6d5dc08df6aa05a60ea3.zip gcc-752ef8f4f5ddf9a3372e6d5dc08df6aa05a60ea3.tar.gz gcc-752ef8f4f5ddf9a3372e6d5dc08df6aa05a60ea3.tar.bz2 |
openmp: Add support for using custom mappers with iterators (C, C++)
gcc/c-family/
* c-omp.cc (omp_instantiate_mapper): Apply iterator to new clauses
generated from mapper.
gcc/c/
* c-parser.cc (c_parser_omp_clause_map): Apply iterator to push and
pop mapper clauses.
gcc/cp/
* parser.cc (cp_parser_omp_clause_map): Apply iterator to push and
pop mapper clauses.
* semantics.cc (cxx_omp_map_array_section): Allow array types for
base type of array sections.
libgomp/
* testsuite/libgomp.c-c++-common/mapper-iterators-1.c: New test.
* testsuite/libgomp.c-c++-common/mapper-iterators-2.c: New test.
* testsuite/libgomp.c-c++-common/mapper-iterators-3.c: New test.
Co-authored-by: Andrew Stubbs <ams@baylibre.com>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/c-family/c-omp.cc | 2 | ||||
-rw-r--r-- | gcc/c/c-parser.cc | 4 | ||||
-rw-r--r-- | gcc/cp/parser.cc | 4 | ||||
-rw-r--r-- | gcc/cp/semantics.cc | 3 |
4 files changed, 12 insertions, 1 deletions
diff --git a/gcc/c-family/c-omp.cc b/gcc/c-family/c-omp.cc index 7d33318..a3cd1ae 100644 --- a/gcc/c-family/c-omp.cc +++ b/gcc/c-family/c-omp.cc @@ -4761,6 +4761,7 @@ omp_instantiate_mapper (location_t loc, tree *outlist, tree mapper, tree expr, tree clauses = OMP_DECLARE_MAPPER_CLAUSES (mapper); tree dummy_var = OMP_DECLARE_MAPPER_DECL (mapper); tree mapper_name = NULL_TREE; + tree iterator = *outlist ? OMP_CLAUSE_ITERATORS (*outlist) : NULL_TREE; remap_mapper_decl_info map_info; map_info.dummy_var = dummy_var; @@ -4889,6 +4890,7 @@ omp_instantiate_mapper (location_t loc, tree *outlist, tree mapper, tree expr, } else { + OMP_CLAUSE_ITERATORS (unshared) = iterator; *outlist = unshared; outlist = &OMP_CLAUSE_CHAIN (unshared); } diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index 8a5b493..31ab7d0 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -20738,6 +20738,8 @@ c_parser_omp_clause_map (c_parser *parser, tree list, enum gomp_map_kind kind) tree name = build_omp_clause (input_location, OMP_CLAUSE_MAP); OMP_CLAUSE_SET_MAP_KIND (name, GOMP_MAP_PUSH_MAPPER_NAME); OMP_CLAUSE_DECL (name) = mapper_name; + if (iterators) + OMP_CLAUSE_ITERATORS (name) = iterators; OMP_CLAUSE_CHAIN (name) = nl; nl = name; @@ -20746,6 +20748,8 @@ c_parser_omp_clause_map (c_parser *parser, tree list, enum gomp_map_kind kind) name = build_omp_clause (input_location, OMP_CLAUSE_MAP); OMP_CLAUSE_SET_MAP_KIND (name, GOMP_MAP_POP_MAPPER_NAME); OMP_CLAUSE_DECL (name) = null_pointer_node; + if (iterators) + OMP_CLAUSE_ITERATORS (name) = iterators; OMP_CLAUSE_CHAIN (name) = OMP_CLAUSE_CHAIN (last_new); OMP_CLAUSE_CHAIN (last_new) = name; } diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 83e0220..f38a327 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -43344,6 +43344,8 @@ cp_parser_omp_clause_from_to (cp_parser *parser, enum omp_clause_code kind, name = build_omp_clause (input_location, OMP_CLAUSE_MAP); OMP_CLAUSE_SET_MAP_KIND (name, GOMP_MAP_POP_MAPPER_NAME); OMP_CLAUSE_DECL (name) = null_pointer_node; + if (iterators) + OMP_CLAUSE_ITERATORS (name) = iterators; OMP_CLAUSE_CHAIN (name) = OMP_CLAUSE_CHAIN (last_new); OMP_CLAUSE_CHAIN (last_new) = name; } @@ -43659,6 +43661,8 @@ cp_parser_omp_clause_map (cp_parser *parser, tree list, enum gomp_map_kind kind) tree name = build_omp_clause (input_location, OMP_CLAUSE_MAP); OMP_CLAUSE_SET_MAP_KIND (name, GOMP_MAP_PUSH_MAPPER_NAME); OMP_CLAUSE_DECL (name) = mapper_name; + if (iterators) + OMP_CLAUSE_ITERATORS (name) = iterators; OMP_CLAUSE_CHAIN (name) = nlist; nlist = name; diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index b80bf33..770872a 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -6998,7 +6998,8 @@ cxx_omp_map_array_section (location_t loc, tree t) if (TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE) t = convert_from_reference (t); - if (TYPE_PTR_P (TREE_TYPE (t))) + if (TYPE_PTR_P (TREE_TYPE (t)) + || TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE) t = build_array_ref (loc, t, low); else t = error_mark_node; |