From caee66cf2abd0bea3ee99b460a108ae0d69d599f Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Fri, 30 Jul 2021 16:15:25 +0200
Subject: [PATCH] Re-unify 'omp_build_component_ref' and
'oacc_build_component_ref'
gcc/
* omp-general.c (omp_build_component_ref): New function,
renamed/moved from...
* omp-oacc-neuter-broadcast.cc (oacc_build_component_ref):
... here.
(build_receiver_ref, build_sender_ref): Update.
* omp-low.c (omp_build_component_ref): Remove function.
* omp-general.h (omp_build_component_ref): Declare function.
---
gcc/omp-general.c | 21 +++++++++++++++++++++
gcc/omp-general.h | 2 ++
gcc/omp-low.c | 15 ---------------
gcc/omp-oacc-neuter-broadcast.cc | 26 ++------------------------
4 files changed, 25 insertions(+), 39 deletions(-)
@@ -2815,4 +2815,25 @@ oacc_get_ifn_dim_arg (const gimple *stmt)
return (int) axis;
}
+/* Build COMPONENT_REF and set TREE_THIS_VOLATILE and TREE_READONLY on it
+ as appropriate. */
+
+tree
+omp_build_component_ref (tree obj, tree field)
+{
+ tree field_type = TREE_TYPE (field);
+ tree obj_type = TREE_TYPE (obj);
+ if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (obj_type)))
+ field_type
+ = build_qualified_type (field_type,
+ KEEP_QUAL_ADDR_SPACE (TYPE_QUALS (obj_type)));
+
+ tree ret = build3 (COMPONENT_REF, field_type, obj, field, NULL);
+ if (TREE_THIS_VOLATILE (field))
+ TREE_THIS_VOLATILE (ret) |= 1;
+ if (TREE_READONLY (field))
+ TREE_READONLY (ret) |= 1;
+ return ret;
+}
+
#include "gt-omp-general.h"
@@ -145,4 +145,6 @@ get_openacc_privatization_dump_flags ()
return l_dump_flags;
}
+extern tree omp_build_component_ref (tree obj, tree field);
+
#endif /* GCC_OMP_GENERAL_H */
@@ -613,21 +613,6 @@ omp_copy_decl_1 (tree var, omp_context *ctx)
return omp_copy_decl_2 (var, DECL_NAME (var), TREE_TYPE (var), ctx);
}
-/* Build COMPONENT_REF and set TREE_THIS_VOLATILE and TREE_READONLY on it
- as appropriate. */
-/* See also 'gcc/omp-oacc-neuter-broadcast.cc:oacc_build_component_ref'. */
-
-static tree
-omp_build_component_ref (tree obj, tree field)
-{
- tree ret = build3 (COMPONENT_REF, TREE_TYPE (field), obj, field, NULL);
- if (TREE_THIS_VOLATILE (field))
- TREE_THIS_VOLATILE (ret) |= 1;
- if (TREE_READONLY (field))
- TREE_READONLY (ret) |= 1;
- return ret;
-}
-
/* Build tree nodes to access the field for VAR on the receiver side. */
static tree
@@ -936,28 +936,6 @@ worker_single_simple (basic_block from, basic_block to,
update_stmt (acc_bar);
}
-/* Build COMPONENT_REF and set TREE_THIS_VOLATILE and TREE_READONLY on it
- as appropriate. */
-/* Adapted from 'gcc/omp-low.c:omp_build_component_ref'. */
-
-static tree
-oacc_build_component_ref (tree obj, tree field)
-{
- tree field_type = TREE_TYPE (field);
- tree obj_type = TREE_TYPE (obj);
- if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (obj_type)))
- field_type = build_qualified_type
- (field_type,
- KEEP_QUAL_ADDR_SPACE (TYPE_QUALS (obj_type)));
-
- tree ret = build3 (COMPONENT_REF, field_type, obj, field, NULL);
- if (TREE_THIS_VOLATILE (field))
- TREE_THIS_VOLATILE (ret) |= 1;
- if (TREE_READONLY (field))
- TREE_READONLY (ret) |= 1;
- return ret;
-}
-
static tree
build_receiver_ref (tree record_type, tree var, tree receiver_decl)
{
@@ -965,7 +943,7 @@ build_receiver_ref (tree record_type, tree var, tree receiver_decl)
tree x = build_simple_mem_ref (receiver_decl);
tree field = *fields->get (var);
TREE_THIS_NOTRAP (x) = 1;
- x = oacc_build_component_ref (x, field);
+ x = omp_build_component_ref (x, field);
return x;
}
@@ -974,7 +952,7 @@ build_sender_ref (tree record_type, tree var, tree sender_decl)
{
field_map_t *fields = *field_map->get (record_type);
tree field = *fields->get (var);
- return oacc_build_component_ref (sender_decl, field);
+ return omp_build_component_ref (sender_decl, field);
}
static int
--
2.30.2