aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimplify.c
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2021-06-15 16:06:38 +0200
committerTobias Burnus <tobias@codesourcery.com>2021-06-15 16:07:11 +0200
commit1de31913d20a467b78904c0e96efd5fbd6facd2c (patch)
tree56187de4669a2701ebd347a3a794d99419250b05 /gcc/gimplify.c
parent9a2c9579fdbf5d24dfe27fb961286ad7a9c3a98b (diff)
downloadgcc-1de31913d20a467b78904c0e96efd5fbd6facd2c.zip
gcc-1de31913d20a467b78904c0e96efd5fbd6facd2c.tar.gz
gcc-1de31913d20a467b78904c0e96efd5fbd6facd2c.tar.bz2
Fortran/OpenMP: Extend defaultmap clause for OpenMP 5 [PR92568]
PR fortran/92568 gcc/fortran/ChangeLog: * dump-parse-tree.c (show_omp_clauses): Update for defaultmap. * f95-lang.c (LANG_HOOKS_OMP_ALLOCATABLE_P, LANG_HOOKS_OMP_SCALAR_TARGET_P): New. * gfortran.h (enum gfc_omp_defaultmap, enum gfc_omp_defaultmap_category): New. * openmp.c (gfc_match_omp_clauses): Update defaultmap matching. * trans-decl.c (gfc_finish_decl_attrs): Set GFC_DECL_SCALAR_TARGET. * trans-openmp.c (gfc_omp_allocatable_p, gfc_omp_scalar_target_p): New. (gfc_omp_scalar_p): Take 'ptr_alloc_ok' argument. (gfc_trans_omp_clauses, gfc_split_omp_clauses): Update for defaultmap changes. * trans.h (gfc_omp_scalar_p): Update prototype. (gfc_omp_allocatable_p, gfc_omp_scalar_target_p): New. (struct lang_decl): Add scalar_target. (GFC_DECL_SCALAR_TARGET, GFC_DECL_GET_SCALAR_TARGET): New. gcc/ChangeLog: * gimplify.c (enum gimplify_defaultmap_kind): Add GDMK_SCALAR_TARGET. (struct gimplify_omp_ctx): Extend defaultmap array by one. (new_omp_context): Init defaultmap[GDMK_SCALAR_TARGET]. (omp_notice_variable): Update type classification for Fortran. (gimplify_scan_omp_clauses): Update calls for new argument; handle GDMK_SCALAR_TARGET; for Fortran, GDMK_POINTER avoid GOVD_MAP_0LEN_ARRAY. * langhooks-def.h (lhd_omp_scalar_p): Add 'ptr_ok' argument. * langhooks.c (lhd_omp_scalar_p): Likewise. (LANG_HOOKS_OMP_ALLOCATABLE_P, LANG_HOOKS_OMP_SCALAR_TARGET_P): New. (LANG_HOOKS_DECLS): Add them. * langhooks.h (struct lang_hooks_for_decls): Add new hooks, update omp_scalar_p pointer type to include the new bool argument. libgomp/ChangeLog: * testsuite/libgomp.fortran/defaultmap-8.f90: New test. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/pr99928-1.f90: Uncomment 'defaultmap(none)'. * gfortran.dg/gomp/pr99928-2.f90: Uncomment 'defaultmap(none)'. * gfortran.dg/gomp/pr99928-3.f90: Uncomment 'defaultmap(none)'. * gfortran.dg/gomp/pr99928-4.f90: Uncomment 'defaultmap(none)'. * gfortran.dg/gomp/pr99928-5.f90: Uncomment 'defaultmap(none)'. * gfortran.dg/gomp/pr99928-6.f90: Uncomment 'defaultmap(none)'. * gfortran.dg/gomp/pr99928-8.f90: Uncomment 'defaultmap(none)'. * gfortran.dg/gomp/defaultmap-1.f90: New test. * gfortran.dg/gomp/defaultmap-2.f90: New test. * gfortran.dg/gomp/defaultmap-3.f90: New test. * gfortran.dg/gomp/defaultmap-4.f90: New test. * gfortran.dg/gomp/defaultmap-5.f90: New test. * gfortran.dg/gomp/defaultmap-6.f90: New test. * gfortran.dg/gomp/defaultmap-7.f90: New test.
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r--gcc/gimplify.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index c96d611..2606998 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -212,6 +212,7 @@ struct gimplify_ctx
enum gimplify_defaultmap_kind
{
GDMK_SCALAR,
+ GDMK_SCALAR_TARGET, /* w/ Fortran's target attr, implicit mapping, only. */
GDMK_AGGREGATE,
GDMK_ALLOCATABLE,
GDMK_POINTER
@@ -236,7 +237,7 @@ struct gimplify_omp_ctx
bool order_concurrent;
bool has_depend;
bool in_for_exprs;
- int defaultmap[4];
+ int defaultmap[5];
};
static struct gimplify_ctx *gimplify_ctxp;
@@ -461,6 +462,7 @@ new_omp_context (enum omp_region_type region_type)
else
c->default_kind = OMP_CLAUSE_DEFAULT_UNSPECIFIED;
c->defaultmap[GDMK_SCALAR] = GOVD_MAP;
+ c->defaultmap[GDMK_SCALAR_TARGET] = GOVD_MAP;
c->defaultmap[GDMK_AGGREGATE] = GOVD_MAP;
c->defaultmap[GDMK_ALLOCATABLE] = GOVD_MAP;
c->defaultmap[GDMK_POINTER] = GOVD_MAP;
@@ -7503,13 +7505,17 @@ omp_notice_variable (struct gimplify_omp_ctx *ctx, tree decl, bool in_code)
{
int gdmk;
enum omp_clause_defaultmap_kind kind;
- if (TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE
- || (TREE_CODE (TREE_TYPE (decl)) == REFERENCE_TYPE
- && (TREE_CODE (TREE_TYPE (TREE_TYPE (decl)))
- == POINTER_TYPE)))
- gdmk = GDMK_POINTER;
- else if (lang_hooks.decls.omp_scalar_p (decl))
+ if (lang_hooks.decls.omp_allocatable_p (decl))
+ gdmk = GDMK_ALLOCATABLE;
+ else if (lang_hooks.decls.omp_scalar_target_p (decl))
+ gdmk = GDMK_SCALAR_TARGET;
+ else if (lang_hooks.decls.omp_scalar_p (decl, false))
gdmk = GDMK_SCALAR;
+ else if (TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE
+ || (TREE_CODE (TREE_TYPE (decl)) == REFERENCE_TYPE
+ && (TREE_CODE (TREE_TYPE (TREE_TYPE (decl)))
+ == POINTER_TYPE)))
+ gdmk = GDMK_POINTER;
else
gdmk = GDMK_AGGREGATE;
kind = lang_hooks.decls.omp_predetermined_mapping (decl);
@@ -8746,6 +8752,8 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p,
if (!lang_GNU_Fortran ())
ctx->defaultmap[GDMK_POINTER] = GOVD_MAP | GOVD_MAP_0LEN_ARRAY;
ctx->defaultmap[GDMK_SCALAR] = GOVD_FIRSTPRIVATE;
+ ctx->defaultmap[GDMK_SCALAR_TARGET] = (lang_GNU_Fortran ()
+ ? GOVD_MAP : GOVD_FIRSTPRIVATE);
}
if (!lang_GNU_Fortran ())
switch (code)
@@ -8827,7 +8835,7 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p,
if (error_operand_p (decl))
goto do_add;
if (OMP_CLAUSE_LASTPRIVATE_CONDITIONAL (c)
- && !lang_hooks.decls.omp_scalar_p (decl))
+ && !lang_hooks.decls.omp_scalar_p (decl, true))
{
error_at (OMP_CLAUSE_LOCATION (c),
"non-scalar variable %qD in conditional "
@@ -10025,7 +10033,8 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p,
gdmkmax = GDMK_POINTER;
break;
case OMP_CLAUSE_DEFAULTMAP_CATEGORY_SCALAR:
- gdmkmin = gdmkmax = GDMK_SCALAR;
+ gdmkmin = GDMK_SCALAR;
+ gdmkmax = GDMK_SCALAR_TARGET;
break;
case OMP_CLAUSE_DEFAULTMAP_CATEGORY_AGGREGATE:
gdmkmin = gdmkmax = GDMK_AGGREGATE;
@@ -10066,12 +10075,18 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p,
case GDMK_SCALAR:
ctx->defaultmap[gdmk] = GOVD_FIRSTPRIVATE;
break;
+ case GDMK_SCALAR_TARGET:
+ ctx->defaultmap[gdmk] = (lang_GNU_Fortran ()
+ ? GOVD_MAP : GOVD_FIRSTPRIVATE);
+ break;
case GDMK_AGGREGATE:
case GDMK_ALLOCATABLE:
ctx->defaultmap[gdmk] = GOVD_MAP;
break;
case GDMK_POINTER:
- ctx->defaultmap[gdmk] = GOVD_MAP | GOVD_MAP_0LEN_ARRAY;
+ ctx->defaultmap[gdmk] = GOVD_MAP;
+ if (!lang_GNU_Fortran ())
+ ctx->defaultmap[gdmk] |= GOVD_MAP_0LEN_ARRAY;
break;
default:
gcc_unreachable ();