From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id 907ED38356A6; Wed, 1 Jun 2022 18:39:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 907ED38356A6 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.91,269,1647331200"; d="scan'208";a="76666082" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 01 Jun 2022 10:39:35 -0800 IronPort-SDR: VdL9Yvfv/JKpdGsUdexVSK2t1PtP2I0BxTB/knUeMBwDYYbHUxG85TmPzKtmlr43+dOFvbOx5H QRWdU2CQVbb12ZzVjR9Bqo/vaE2eSh3gg1lnIJiro0vTlIyJfXXrfTluS1dJljClvdan7s687W H55mwSSmlgRqlhue44kKAcm8qgAfRIeJ+V1OfQRgDBkn9VEsflbI62KSyhwWP6cy2QIAnKASmj +7D17tXREbuIONCCYq30BvsbxTBx81sh96b80cGF/eVpzyHQxKA40Yw2iBrzsiMrm89WzEbzBE 75U= From: Julian Brown To: CC: , Tobias Burnus , Jakub Jelinek Subject: [PATCH 2/6] OpenMP: Templatize omp_mapper_list Date: Wed, 1 Jun 2022 11:39:20 -0700 Message-ID: <2d1ff582190fba0d5a684f7e05d36b2124f0ad68.1654107784.git.julian@codesourcery.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-05.mgc.mentorg.com (139.181.222.5) To svr-ies-mbx-11.mgc.mentorg.com (139.181.222.11) X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: fortran@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Fortran mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Jun 2022 18:39:39 -0000 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 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. gcc/c/ * c-decl.cc (c_omp_scan_mapper_bindings): Use omp_name_type and omp_mapper_list. 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. * omp-general.h (omp_name_type): Parameterize by T. (hash traits template): Use omp_name_type. (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 struct omp_mapper_list; +extern void c_omp_find_nested_mappers (struct omp_mapper_list *, 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 *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 *mlist = (omp_mapper_list *) 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 seen_types; + hash_set> seen_types; auto_vec mappers; - omp_mapper_list mlist (&seen_types, &mappers); + omp_mapper_list 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 local_decls; - omp_mapper_list *mappers; + omp_mapper_list *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 *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 seen_types; + hash_set > seen_types; auto_vec mapper_fns; - omp_mapper_list mlist (&seen_types, &mapper_fns); + omp_mapper_list 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 *implicit_mappers; + hash_map, tree> *implicit_mappers; hash_set *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; + c->implicit_mappers = new hash_map, tree>; c->privatized_types = new hash_set; 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 *implicit_mappers, +omp_instantiate_mapper (hash_map, 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 struct omp_name_type { tree name; - tree type; + T type; }; template <> -struct default_hash_traits - : typed_noop_remove +struct default_hash_traits > + : typed_noop_remove > { - GTY((skip)) typedef omp_name_type value_type; - GTY((skip)) typedef omp_name_type compare_type; + GTY((skip)) typedef omp_name_type value_type; + GTY((skip)) typedef omp_name_type compare_type; static hashval_t - hash (omp_name_type p) + hash (omp_name_type 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 static const bool empty_zero_p = true; static bool - is_empty (omp_name_type p) + is_empty (omp_name_type p) { return p.type == NULL; } static bool - is_deleted (omp_name_type) + is_deleted (omp_name_type) { return false; } static bool - equal (const omp_name_type &a, const omp_name_type &b) + equal (const omp_name_type &a, const omp_name_type &b) { if (a.name == NULL_TREE && b.name == NULL_TREE) return a.type == b.type; @@ -195,27 +196,28 @@ struct default_hash_traits } static void - mark_empty (omp_name_type &e) + mark_empty (omp_name_type &e) { e.type = NULL; } }; +template struct omp_mapper_list { - hash_set *seen_types; + hash_set> *seen_types; vec *mappers; - omp_mapper_list (hash_set *s, vec *m) + omp_mapper_list (hash_set> *s, vec *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 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