From: Sandra Loosemore <sandra@codesourcery.com>
To: <gcc-patches@gcc.gnu.org>
Cc: <jakub@redhat.com>, <tobias@codesourcery.com>
Subject: [PATCH 2/3] OpenMP: Unify representation of name-list properties.
Date: Sun, 19 Nov 2023 02:21:50 -0700 [thread overview]
Message-ID: <20231119092151.1690294-3-sandra@codesourcery.com> (raw)
In-Reply-To: <20231119092151.1690294-1-sandra@codesourcery.com>
Previously, name-list properties specified as identifiers were stored
in the TREE_PURPOSE/OMP_TP_NAME slot, while those specified as strings
were stored in the TREE_VALUE/OMP_TP_VALUE slot. This patch puts both
representations in OMP_TP_VALUE with a magic cookie in OMP_TP_NAME.
gcc/ChangeLog
* omp-general.h (OMP_TP_NAMELIST_NODE): New.
* omp-general.cc (omp_context_name_list_prop): Move earlier
in the file, and adjust for new representation.
(omp_check_context_selector): Adjust this too.
(omp_context_selector_props_compare): Likewise.
gcc/c/ChangeLog
* c-parser.cc (c_parser_omp_context_selector): Adjust for new
namelist property representation.
gcc/cp/ChangeLog
* parser.cc (cp_parser_omp_context_selector): Adjust for new
namelist property representation.
* pt.cc (tsubst_attribute): Likewise.
gcc/fortran/ChangeLog
* trans-openmp.cc (gfc_trans_omp_declare_varaint): Adjust for
new namelist property representation.
---
gcc/c/c-parser.cc | 5 ++-
gcc/cp/parser.cc | 5 ++-
gcc/cp/pt.cc | 4 +-
gcc/fortran/trans-openmp.cc | 5 ++-
gcc/omp-general.cc | 84 +++++++++++++++++++++----------------
gcc/omp-general.h | 1 +
6 files changed, 61 insertions(+), 43 deletions(-)
diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc
index fcbacd461c7..a2ff381e0c1 100644
--- a/gcc/c/c-parser.cc
+++ b/gcc/c/c-parser.cc
@@ -24217,11 +24217,12 @@ c_parser_omp_context_selector (c_parser *parser, tree set, tree parms)
case CTX_PROPERTY_NAME_LIST:
do
{
- tree prop = NULL_TREE, value = NULL_TREE;
+ tree prop = OMP_TP_NAMELIST_NODE;
+ tree value = NULL_TREE;
if (c_parser_next_token_is (parser, CPP_KEYWORD)
|| c_parser_next_token_is (parser, CPP_NAME))
{
- prop = c_parser_peek_token (parser)->value;
+ value = c_parser_peek_token (parser)->value;
c_parser_consume_token (parser);
}
else if (c_parser_next_token_is (parser, CPP_STRING))
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index dd773570981..9030365644d 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -47469,11 +47469,12 @@ cp_parser_omp_context_selector (cp_parser *parser, tree set, bool has_parms_p)
case CTX_PROPERTY_NAME_LIST:
do
{
- tree prop = NULL_TREE, value = NULL_TREE;
+ tree prop = OMP_TP_NAMELIST_NODE;
+ tree value = NULL_TREE;
if (cp_lexer_next_token_is (parser->lexer, CPP_KEYWORD)
|| cp_lexer_next_token_is (parser->lexer, CPP_NAME))
{
- prop = cp_lexer_peek_token (parser->lexer)->u.value;
+ value = cp_lexer_peek_token (parser->lexer)->u.value;
cp_lexer_consume_token (parser->lexer);
}
else if (cp_lexer_next_token_is (parser->lexer, CPP_STRING))
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 3af793dfe20..c3815733651 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -11892,7 +11892,9 @@ tsubst_attribute (tree t, tree *decl_p, tree args,
}
properties = copy_list (OMP_TS_PROPERTIES (ts));
for (tree p = properties; p; p = TREE_CHAIN (p))
- if (OMP_TP_VALUE (p))
+ if (OMP_TP_NAME (p) == OMP_TP_NAMELIST_NODE)
+ continue;
+ else if (OMP_TP_VALUE (p))
{
bool allow_string
= (OMP_TS_ID (ts) != condition || set[0] != 'u');
diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc
index fe8044a57cd..60154ff3751 100644
--- a/gcc/fortran/trans-openmp.cc
+++ b/gcc/fortran/trans-openmp.cc
@@ -8235,9 +8235,10 @@ gfc_trans_omp_declare_variant (gfc_namespace *ns)
break;
case CTX_PROPERTY_NAME_LIST:
{
- tree prop = NULL_TREE, value = NULL_TREE;
+ tree prop = OMP_TP_NAMELIST_NODE;
+ tree value = NULL_TREE;
if (otp->is_name)
- prop = get_identifier (otp->name);
+ value = get_identifier (otp->name);
else
value = gfc_conv_constant_to_tree (otp->expr);
diff --git a/gcc/omp-general.cc b/gcc/omp-general.cc
index 4ea0d971273..e4e3890449e 100644
--- a/gcc/omp-general.cc
+++ b/gcc/omp-general.cc
@@ -1114,6 +1114,30 @@ omp_maybe_offloaded (void)
return false;
}
+/* Return a name from PROP, a property in selectors accepting
+ name lists. */
+
+static const char *
+omp_context_name_list_prop (tree prop)
+{
+ gcc_assert (OMP_TP_NAME (prop) == OMP_TP_NAMELIST_NODE);
+ tree val = OMP_TP_VALUE (prop);
+ switch (TREE_CODE (val))
+ {
+ case IDENTIFIER_NODE:
+ return IDENTIFIER_POINTER (val);
+ case STRING_CST:
+ {
+ const char *ret = TREE_STRING_POINTER (val);
+ if ((size_t) TREE_STRING_LENGTH (val)
+ == strlen (ret) + (lang_GNU_Fortran () ? 0 : 1))
+ return ret;
+ return NULL;
+ }
+ default:
+ return NULL;
+ }
+}
/* Diagnose errors in an OpenMP context selector, return CTX if
it is correct or error_mark_node otherwise. */
@@ -1198,23 +1222,29 @@ omp_check_context_selector (location_t loc, tree ctx)
"atomic_default_mem_order");
return error_mark_node;
}
+ else if (OMP_TP_NAME (p) == OMP_TP_NAMELIST_NODE
+ && (TREE_CODE (OMP_TP_VALUE (p)) == STRING_CST))
+ warning_at (loc, 0,
+ "unknown property %qE of %qs selector",
+ OMP_TP_VALUE (p),
+ props[i].selector);
+ else if (OMP_TP_NAME (p) == OMP_TP_NAMELIST_NODE)
+ warning_at (loc, 0,
+ "unknown property %qs of %qs selector",
+ omp_context_name_list_prop (p),
+ props[i].selector);
else if (OMP_TP_NAME (p))
warning_at (loc, 0,
"unknown property %qs of %qs selector",
IDENTIFIER_POINTER (OMP_TP_NAME (p)),
props[i].selector);
- else
- warning_at (loc, 0,
- "unknown property %qE of %qs selector",
- OMP_TP_VALUE (p), props[i].selector);
break;
}
- else if (OMP_TP_NAME (p) == NULL_TREE)
+ else if (OMP_TP_NAME (p) == OMP_TP_NAMELIST_NODE)
+ /* Property-list traits. */
{
- const char *str = TREE_STRING_POINTER (OMP_TP_VALUE (p));
- if (!strcmp (str, props[i].props[j])
- && ((size_t) TREE_STRING_LENGTH (OMP_TP_VALUE (p))
- == strlen (str) + (lang_GNU_Fortran () ? 0 : 1)))
+ const char *str = omp_context_name_list_prop (p);
+ if (str && !strcmp (str, props[i].props[j]))
break;
}
else if (!strcmp (IDENTIFIER_POINTER (OMP_TP_NAME (p)),
@@ -1277,24 +1307,6 @@ make_trait_property (tree name, tree value, tree chain)
return tree_cons (name, value, chain);
}
-/* Return a name from PROP, a property in selectors accepting
- name lists. */
-
-static const char *
-omp_context_name_list_prop (tree prop)
-{
- if (OMP_TP_NAME (prop))
- return IDENTIFIER_POINTER (OMP_TP_NAME (prop));
- else
- {
- const char *ret = TREE_STRING_POINTER (OMP_TP_VALUE (prop));
- if ((size_t) TREE_STRING_LENGTH (OMP_TP_VALUE (prop))
- == strlen (ret) + (lang_GNU_Fortran () ? 0 : 1))
- return ret;
- return NULL;
- }
-}
-
/* Return 1 if context selector matches the current OpenMP context, 0
if it does not and -1 if it is unknown and need to be determined later.
Some properties can be checked right away during parsing (this routine),
@@ -1793,18 +1805,18 @@ omp_context_selector_props_compare (const char *set, const char *sel,
if (simple_cst_equal (OMP_TP_VALUE (p1), OMP_TP_VALUE (p2)))
break;
}
+ else if (OMP_TP_NAME (p1) == OMP_TP_NAMELIST_NODE)
+ {
+ /* Handle string constant vs identifier comparison for
+ name-list properties. */
+ const char *n1 = omp_context_name_list_prop (p1);
+ const char *n2 = omp_context_name_list_prop (p2);
+ if (n1 && n2 && !strcmp (n1, n2))
+ break;
+ }
else
break;
}
- else
- {
- /* Handle string constant vs identifier comparison for
- name-list properties. */
- const char *n1 = omp_context_name_list_prop (p1);
- const char *n2 = omp_context_name_list_prop (p2);
- if (n1 && n2 && !strcmp (n1, n2))
- break;
- }
if (p2 == NULL_TREE)
{
int r = pass ? -1 : 1;
diff --git a/gcc/omp-general.h b/gcc/omp-general.h
index 28a9c0e6e17..dc5e5f6ba1f 100644
--- a/gcc/omp-general.h
+++ b/gcc/omp-general.h
@@ -112,6 +112,7 @@ struct omp_for_data
OMP_TS_SCORE_NODE. */
#define OMP_TS_SCORE_NODE integer_minus_one_node
+#define OMP_TP_NAMELIST_NODE integer_one_node
#define OMP_TSS_ID(NODE) \
TREE_PURPOSE (NODE)
--
2.31.1
next prev parent reply other threads:[~2023-11-19 9:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-19 9:21 [PATCH 0/3] OpenMP: Improve data abstractions for context selectors Sandra Loosemore
2023-11-19 9:21 ` [PATCH 1/3] OpenMP: Introduce accessor macros and constructors " Sandra Loosemore
2023-11-19 9:21 ` Sandra Loosemore [this message]
2023-11-19 9:21 ` [PATCH 3/3] OpenMP: Use enumerators for names of trait-sets and traits Sandra Loosemore
2023-11-21 20:48 ` Sandra Loosemore
2023-11-20 10:32 ` [PATCH 0/3] OpenMP: Improve data abstractions for context selectors Julian Brown
2023-11-22 16:22 ` [PATCH V2 3/3] OpenMP: Use enumerators for names of trait-sets and traits Sandra Loosemore
2023-11-27 17:19 ` Tobias Burnus
2023-11-27 18:18 ` Tobias Burnus
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=20231119092151.1690294-3-sandra@codesourcery.com \
--to=sandra@codesourcery.com \
--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).