diff options
author | Jakub Jelinek <jakub@redhat.com> | 2021-09-22 09:29:13 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2021-09-22 09:29:13 +0200 |
commit | 059b819e3c94aae3dd0be55bd512ee6ee4e28798 (patch) | |
tree | bb8b074085f64d452820b382f51a65c04cf26448 /gcc/cp/semantics.c | |
parent | 578b76873383784841f5478573f4ac5d251aa0ba (diff) | |
download | gcc-059b819e3c94aae3dd0be55bd512ee6ee4e28798.zip gcc-059b819e3c94aae3dd0be55bd512ee6ee4e28798.tar.gz gcc-059b819e3c94aae3dd0be55bd512ee6ee4e28798.tar.bz2 |
openmp: Add support for allocator and align modifiers on allocate clauses
As the allocate-2.c testcase shows, this change isn't 100% backwards compatible,
one could have allocate and/or align functions that return an OpenMP allocator
handle and previously it would call those functions and now would use those
names as keywords for the modifiers. But it allows specify extra alignment
requirements for the allocations.
2021-09-22 Jakub Jelinek <jakub@redhat.com>
gcc/
* tree.h (OMP_CLAUSE_ALLOCATE_ALIGN): Define.
* tree.c (omp_clause_num_ops): Change number of OMP_CLAUSE_ALLOCATE
arguments from 2 to 3.
* tree-pretty-print.c (dump_omp_clause): Print allocator() around
allocate clause allocator and print align if present.
* omp-low.c (scan_sharing_clauses): Force allocate_map entry even
for omp_default_mem_alloc if align modifier is present. If align
modifier is present, use TREE_LIST to encode both allocator and
align.
(lower_private_allocate, lower_rec_input_clauses, create_task_copyfn):
Handle align modifier on allocator clause if present.
gcc/c-family/
* c-omp.c (c_omp_split_clauses): Copy over OMP_CLAUSE_ALLOCATE_ALIGN.
gcc/c/
* c-parser.c (c_parser_omp_clause_allocate): Parse allocate clause
modifiers.
gcc/cp/
* parser.c (cp_parser_omp_clause_allocate): Parse allocate clause
modifiers.
* semantics.c (finish_omp_clauses) <OMP_CLAUSE_ALLOCATE>: Perform
semantic analysis of OMP_CLAUSE_ALLOCATE_ALIGN.
* pt.c (tsubst_omp_clauses) <case OMP_CLAUSE_ALLOCATE>: Handle
also OMP_CLAUSE_ALLOCATE_ALIGN.
gcc/testsuite/
* c-c++-common/gomp/allocate-6.c: New test.
* c-c++-common/gomp/allocate-7.c: New test.
* g++.dg/gomp/allocate-4.C: New test.
libgomp/
* testsuite/libgomp.c-c++-common/allocate-2.c: New test.
* testsuite/libgomp.c-c++-common/allocate-3.c: New test.
Diffstat (limited to 'gcc/cp/semantics.c')
-rw-r--r-- | gcc/cp/semantics.c | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 35a7b9f..0d8e5fd 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -7527,7 +7527,44 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort) bitmap_set_bit (&aligned_head, DECL_UID (t)); allocate_seen = true; } - tree allocator; + tree allocator, align; + align = OMP_CLAUSE_ALLOCATE_ALIGN (c); + if (error_operand_p (align)) + { + remove = true; + break; + } + if (align) + { + if (!type_dependent_expression_p (align) + && !INTEGRAL_TYPE_P (TREE_TYPE (align))) + { + error_at (OMP_CLAUSE_LOCATION (c), + "%<allocate%> clause %<align%> modifier " + "argument needs to be positive constant " + "power of two integer expression"); + remove = true; + } + else + { + align = mark_rvalue_use (align); + if (!processing_template_decl) + { + align = maybe_constant_value (align); + if (TREE_CODE (align) != INTEGER_CST + || !tree_fits_uhwi_p (align) + || !integer_pow2p (align)) + { + error_at (OMP_CLAUSE_LOCATION (c), + "%<allocate%> clause %<align%> modifier " + "argument needs to be positive constant " + "power of two integer expression"); + remove = true; + } + } + } + OMP_CLAUSE_ALLOCATE_ALIGN (c) = align; + } allocator = OMP_CLAUSE_ALLOCATE_ALLOCATOR (c); if (error_operand_p (allocator)) { @@ -7552,6 +7589,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort) "type %qT rather than %<omp_allocator_handle_t%>", TREE_TYPE (allocator)); remove = true; + break; } else { |