From: Julian Brown <julian@codesourcery.com>
To: <gcc-patches@gcc.gnu.org>
Cc: <fortran@gcc.gnu.org>, Tobias Burnus <tobias@codesourcery.com>,
Jakub Jelinek <jakub@redhat.com>
Subject: [PATCH 2/6] OpenMP: Templatize omp_mapper_list
Date: Wed, 1 Jun 2022 11:39:20 -0700 [thread overview]
Message-ID: <2d1ff582190fba0d5a684f7e05d36b2124f0ad68.1654107784.git.julian@codesourcery.com> (raw)
In-Reply-To: <cover.1654107784.git.julian@codesourcery.com>
This patch parameterizes the omp_mapper_list class to allow it to use
different representations for the types of mappers -- e.g., to allow
Fortran to gather mappers by "gfc_typespec *" instead of tree type
(in a later patch in the series).
There should be no behavioural changes introduced by this patch.
OK?
Julian
2022-06-01 Julian Brown <julian@codesourcery.com>
gcc/c-family/
* c-common.h (omp_mapper_list): Add T type parameter.
(c_omp_find_nested_mappers): Update prototype.
* c-omp.cc (c_omp_find_nested_mappers): Use omp_mapper_list<tree>.
gcc/c/
* c-decl.cc (c_omp_scan_mapper_bindings): Use omp_name_type<tree> and
omp_mapper_list<tree>.
gcc/cp/
* semantics.cc (omp_target_walk_data, finish_omp_target_clauses_r):
Likewise.
gcc/
* gimplify.cc (gimplify_omp_ctx, new_omp_context,
omp_instantiate_mapper): Use omp_name_type<tree>.
* omp-general.h (omp_name_type): Parameterize by T.
(hash traits template): Use omp_name_type<tree>.
(omp_mapper_list): Parameterize by T.
---
gcc/c-family/c-common.h | 4 ++--
gcc/c-family/c-omp.cc | 2 +-
gcc/c/c-decl.cc | 6 +++---
gcc/cp/semantics.cc | 8 ++++----
gcc/gimplify.cc | 6 +++---
gcc/omp-general.h | 32 +++++++++++++++++---------------
6 files changed, 30 insertions(+), 28 deletions(-)
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index adebd0a2605..fe493fb3916 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -1252,8 +1252,8 @@ extern tree c_omp_check_context_selector (location_t, tree);
extern void c_omp_mark_declare_variant (location_t, tree, tree);
extern const char *c_omp_map_clause_name (tree, bool);
extern void c_omp_adjust_map_clauses (tree, bool);
-struct omp_mapper_list;
-extern void c_omp_find_nested_mappers (struct omp_mapper_list *, tree);
+template<typename T> struct omp_mapper_list;
+extern void c_omp_find_nested_mappers (struct omp_mapper_list<tree> *, tree);
extern tree c_omp_instantiate_mappers (tree);
class c_omp_address_inspector
diff --git a/gcc/c-family/c-omp.cc b/gcc/c-family/c-omp.cc
index 789da097bb0..ee02121f1d5 100644
--- a/gcc/c-family/c-omp.cc
+++ b/gcc/c-family/c-omp.cc
@@ -3401,7 +3401,7 @@ c_omp_address_inspector::get_attachment_point (tree expr)
themselves, add it to MLIST. */
void
-c_omp_find_nested_mappers (omp_mapper_list *mlist, tree mapper_fn)
+c_omp_find_nested_mappers (omp_mapper_list<tree> *mlist, tree mapper_fn)
{
tree mapper = lang_hooks.decls.omp_extract_mapper_directive (mapper_fn);
tree mapper_name = NULL_TREE;
diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc
index 64e5faf7137..ea920e5c452 100644
--- a/gcc/c/c-decl.cc
+++ b/gcc/c/c-decl.cc
@@ -12562,7 +12562,7 @@ static tree
c_omp_scan_mapper_bindings_r (tree *tp, int *walk_subtrees, void *ptr)
{
tree t = *tp;
- omp_mapper_list *mlist = (omp_mapper_list *) ptr;
+ omp_mapper_list<tree> *mlist = (omp_mapper_list<tree> *) ptr;
tree aggr_type = NULL_TREE;
if (TREE_CODE (t) == SIZEOF_EXPR
@@ -12600,9 +12600,9 @@ c_omp_scan_mapper_bindings_r (tree *tp, int *walk_subtrees, void *ptr)
void
c_omp_scan_mapper_bindings (location_t loc, tree *clauses_ptr, tree body)
{
- hash_set<omp_name_type> seen_types;
+ hash_set<omp_name_type<tree>> seen_types;
auto_vec<tree> mappers;
- omp_mapper_list mlist (&seen_types, &mappers);
+ omp_mapper_list<tree> mlist (&seen_types, &mappers);
walk_tree_without_duplicates (&body, c_omp_scan_mapper_bindings_r, &mlist);
diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc
index 21234be3c31..4e19872c246 100644
--- a/gcc/cp/semantics.cc
+++ b/gcc/cp/semantics.cc
@@ -9455,7 +9455,7 @@ struct omp_target_walk_data
variables when recording lambda_objects_accessed. */
hash_set<tree> local_decls;
- omp_mapper_list *mappers;
+ omp_mapper_list<tree> *mappers;
};
/* Helper function of finish_omp_target_clauses, called via
@@ -9469,7 +9469,7 @@ finish_omp_target_clauses_r (tree *tp, int *walk_subtrees, void *ptr)
struct omp_target_walk_data *data = (struct omp_target_walk_data *) ptr;
tree current_object = data->current_object;
tree current_closure = data->current_closure;
- omp_mapper_list *mlist = data->mappers;
+ omp_mapper_list<tree> *mlist = data->mappers;
tree aggr_type = NULL_TREE;
/* References inside of these expression codes shouldn't incur any
@@ -9603,9 +9603,9 @@ finish_omp_target_clauses (location_t loc, tree body, tree *clauses_ptr)
else
data.current_closure = NULL_TREE;
- hash_set<omp_name_type> seen_types;
+ hash_set<omp_name_type<tree> > seen_types;
auto_vec<tree> mapper_fns;
- omp_mapper_list mlist (&seen_types, &mapper_fns);
+ omp_mapper_list<tree> mlist (&seen_types, &mapper_fns);
data.mappers = &mlist;
cp_walk_tree_without_duplicates (&body, finish_omp_target_clauses_r, &data);
diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index 861159687a7..cb6877b5009 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -219,7 +219,7 @@ struct gimplify_omp_ctx
{
struct gimplify_omp_ctx *outer_context;
splay_tree variables;
- hash_map<omp_name_type, tree> *implicit_mappers;
+ hash_map<omp_name_type<tree>, tree> *implicit_mappers;
hash_set<tree> *privatized_types;
tree clauses;
/* Iteration variables in an OMP_FOR. */
@@ -452,7 +452,7 @@ new_omp_context (enum omp_region_type region_type)
c = XCNEW (struct gimplify_omp_ctx);
c->outer_context = gimplify_omp_ctxp;
c->variables = splay_tree_new (splay_tree_compare_decl_uid, 0, 0);
- c->implicit_mappers = new hash_map<omp_name_type, tree>;
+ c->implicit_mappers = new hash_map<omp_name_type<tree>, tree>;
c->privatized_types = new hash_set<tree>;
c->location = input_location;
c->region_type = region_type;
@@ -10434,7 +10434,7 @@ remap_mapper_decl_1 (tree *tp, int *walk_subtrees, void *data)
}
static tree *
-omp_instantiate_mapper (hash_map<omp_name_type, tree> *implicit_mappers,
+omp_instantiate_mapper (hash_map<omp_name_type<tree>, tree> *implicit_mappers,
tree mapper, tree expr, enum gomp_map_kind outer_kind,
tree *mapper_clauses_p)
{
diff --git a/gcc/omp-general.h b/gcc/omp-general.h
index 242212b652c..a11a99b75f9 100644
--- a/gcc/omp-general.h
+++ b/gcc/omp-general.h
@@ -149,21 +149,22 @@ get_openacc_privatization_dump_flags ()
return l_dump_flags;
}
+template <typename T>
struct omp_name_type
{
tree name;
- tree type;
+ T type;
};
template <>
-struct default_hash_traits <omp_name_type>
- : typed_noop_remove <omp_name_type>
+struct default_hash_traits <omp_name_type<tree> >
+ : typed_noop_remove <omp_name_type<tree> >
{
- GTY((skip)) typedef omp_name_type value_type;
- GTY((skip)) typedef omp_name_type compare_type;
+ GTY((skip)) typedef omp_name_type<tree> value_type;
+ GTY((skip)) typedef omp_name_type<tree> compare_type;
static hashval_t
- hash (omp_name_type p)
+ hash (omp_name_type<tree> p)
{
return p.name ? iterative_hash_expr (p.name, TYPE_UID (p.type))
: TYPE_UID (p.type);
@@ -172,19 +173,19 @@ struct default_hash_traits <omp_name_type>
static const bool empty_zero_p = true;
static bool
- is_empty (omp_name_type p)
+ is_empty (omp_name_type<tree> p)
{
return p.type == NULL;
}
static bool
- is_deleted (omp_name_type)
+ is_deleted (omp_name_type<tree>)
{
return false;
}
static bool
- equal (const omp_name_type &a, const omp_name_type &b)
+ equal (const omp_name_type<tree> &a, const omp_name_type<tree> &b)
{
if (a.name == NULL_TREE && b.name == NULL_TREE)
return a.type == b.type;
@@ -195,27 +196,28 @@ struct default_hash_traits <omp_name_type>
}
static void
- mark_empty (omp_name_type &e)
+ mark_empty (omp_name_type<tree> &e)
{
e.type = NULL;
}
};
+template <typename T>
struct omp_mapper_list
{
- hash_set<omp_name_type> *seen_types;
+ hash_set<omp_name_type<T>> *seen_types;
vec<tree> *mappers;
- omp_mapper_list (hash_set<omp_name_type> *s, vec<tree> *m)
+ omp_mapper_list (hash_set<omp_name_type<T>> *s, vec<tree> *m)
: seen_types (s), mappers (m) { }
- void add_mapper (tree name, tree type, tree mapperfn)
+ void add_mapper (tree name, T type, tree mapperfn)
{
/* We can't hash a NULL_TREE... */
if (!name)
name = void_node;
- omp_name_type n_t = { name, type };
+ omp_name_type<T> n_t = { name, type };
if (seen_types->contains (n_t))
return;
@@ -224,7 +226,7 @@ struct omp_mapper_list
mappers->safe_push (mapperfn);
}
- bool contains (tree name, tree type)
+ bool contains (tree name, T type)
{
if (!name)
name = void_node;
--
2.29.2
next prev parent reply other threads:[~2022-06-01 18:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-01 18:39 [PATCH 0/6] OpenMP 5.0: Fortran "declare mapper" support Julian Brown
2022-06-01 18:39 ` [PATCH 1/6] Fortran: Typo/unicode-o fixes Julian Brown
2022-12-23 10:53 ` Julian Brown
2022-06-01 18:39 ` Julian Brown [this message]
2022-06-01 18:39 ` [PATCH 3/6] OpenMP: Rename strip_components_and_deref to omp_get_root_term Julian Brown
2022-06-01 18:39 ` [PATCH 4/6] OpenMP: Tweak NOP handling in in omp_get_root_term and accumulate_sibling_list Julian Brown
2022-06-01 18:40 ` [PATCH 5/6] OpenMP: Pointers and member mappings Julian Brown
2022-06-01 18:40 ` [PATCH 6/6] OpenMP: Fortran "!$omp declare mapper" support Julian Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2d1ff582190fba0d5a684f7e05d36b2124f0ad68.1654107784.git.julian@codesourcery.com \
--to=julian@codesourcery.com \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=tobias@codesourcery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).