aboutsummaryrefslogtreecommitdiff
path: root/gcc/omp-general.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-11-14 09:12:10 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2019-11-14 09:12:10 +0100
commitb2417b59d4be2e5e882dec5ae3b373f69331d6e2 (patch)
treeb3d7af488c90ecd3476ef6b9d1f9e4cbfc00051b /gcc/omp-general.c
parentf14713178d25db56903458432b0e3dbf35dbe840 (diff)
downloadgcc-b2417b59d4be2e5e882dec5ae3b373f69331d6e2.zip
gcc-b2417b59d4be2e5e882dec5ae3b373f69331d6e2.tar.gz
gcc-b2417b59d4be2e5e882dec5ae3b373f69331d6e2.tar.bz2
omp-general.c (omp_context_name_list_prop): New function.
* omp-general.c (omp_context_name_list_prop): New function. (omp_context_selector_matches): Use it. Return 0 if it returns NULL. (omp_context_selector_props_compare): Allow equivalency of an identifier and a string literal containing no embedded zeros. c-family/ * c-omp.c (c_omp_check_context_selector): Handle name lists containing string literals. Don't diagnose atomic_default_mem_order with multiple props. c/ * c-parser.c (c_parser_omp_context_selector): Rename CTX_PROPERTY_IDLIST to CTX_PROPERTY_NAME_LIST, add CTX_PROPERTY_ID. Use CTX_PROPERTY_ID for atomic_default_mem_order, only allow a single identifier in that. For CTX_PROPERTY_NAME_LIST, allow identifiers and string literals. cp/ * parser.c (cp_parser_omp_context_selector): Rename CTX_PROPERTY_IDLIST to CTX_PROPERTY_NAME_LIST, add CTX_PROPERTY_ID. Use CTX_PROPERTY_ID for atomic_default_mem_order, only allow a single identifier in that. For CTX_PROPERTY_NAME_LIST, allow identifiers and string literals. * pt.c (tsubst_attribute): Fix up STRING_CST handling if allow_string. testsuite/ * c-c++-common/gomp/declare-variant-2.c: Adjust expected diagnostics, add a test for atomic_default_mem_order with a string literal. * c-c++-common/gomp/declare-variant-3.c: Use string literal props in a few random places, add a few string literal prop related tests. * c-c++-common/gomp/declare-variant-8.c: Likewise. * c-c++-common/gomp/declare-variant-9.c: Use string literal props in a few random places. * c-c++-common/gomp/declare-variant-10.c: Likewise. * c-c++-common/gomp/declare-variant-11.c: Likewise. * c-c++-common/gomp/declare-variant-12.c: Likewise. * g++.dg/gomp/declare-variant-7.C: Likewise. From-SVN: r278202
Diffstat (limited to 'gcc/omp-general.c')
-rw-r--r--gcc/omp-general.c58
1 files changed, 53 insertions, 5 deletions
diff --git a/gcc/omp-general.c b/gcc/omp-general.c
index fd074a3..67ed345 100644
--- a/gcc/omp-general.c
+++ b/gcc/omp-general.c
@@ -652,6 +652,23 @@ 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)
+{
+ if (TREE_PURPOSE (prop))
+ return IDENTIFIER_POINTER (TREE_PURPOSE (prop));
+ else
+ {
+ const char *ret = TREE_STRING_POINTER (TREE_VALUE (prop));
+ if ((size_t) TREE_STRING_LENGTH (TREE_VALUE (prop)) == strlen (ret) + 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),
@@ -701,8 +718,11 @@ omp_context_selector_matches (tree ctx)
if (set == 'i' && !strcmp (sel, "vendor"))
for (tree t3 = TREE_VALUE (t2); t3; t3 = TREE_CHAIN (t3))
{
- const char *prop = IDENTIFIER_POINTER (TREE_PURPOSE (t3));
- if (!strcmp (prop, " score") || !strcmp (prop, "gnu"))
+ const char *prop = omp_context_name_list_prop (t3);
+ if (prop == NULL)
+ return 0;
+ if ((!strcmp (prop, " score") && TREE_PURPOSE (t3))
+ || !strcmp (prop, "gnu"))
continue;
return 0;
}
@@ -750,7 +770,9 @@ omp_context_selector_matches (tree ctx)
if (set == 'd' && !strcmp (sel, "arch"))
for (tree t3 = TREE_VALUE (t2); t3; t3 = TREE_CHAIN (t3))
{
- const char *arch = IDENTIFIER_POINTER (TREE_PURPOSE (t3));
+ const char *arch = omp_context_name_list_prop (t3);
+ if (arch == NULL)
+ return 0;
int r = 0;
if (targetm.omp.device_kind_arch_isa != NULL)
r = targetm.omp.device_kind_arch_isa (omp_device_arch,
@@ -844,7 +866,9 @@ omp_context_selector_matches (tree ctx)
if (set == 'd' && !strcmp (sel, "kind"))
for (tree t3 = TREE_VALUE (t2); t3; t3 = TREE_CHAIN (t3))
{
- const char *prop = IDENTIFIER_POINTER (TREE_PURPOSE (t3));
+ const char *prop = omp_context_name_list_prop (t3);
+ if (prop == NULL)
+ return 0;
if (!strcmp (prop, "any"))
continue;
if (!strcmp (prop, "host"))
@@ -903,7 +927,9 @@ omp_context_selector_matches (tree ctx)
if (set == 'd' && !strcmp (sel, "isa"))
for (tree t3 = TREE_VALUE (t2); t3; t3 = TREE_CHAIN (t3))
{
- const char *isa = IDENTIFIER_POINTER (TREE_PURPOSE (t3));
+ const char *isa = omp_context_name_list_prop (t3);
+ if (isa == NULL)
+ return 0;
int r = 0;
if (targetm.omp.device_kind_arch_isa != NULL)
r = targetm.omp.device_kind_arch_isa (omp_device_isa,
@@ -1109,6 +1135,28 @@ omp_context_selector_props_compare (const char *set, const char *sel,
else
break;
}
+ else if (TREE_PURPOSE (t1)
+ && TREE_PURPOSE (t2) == NULL_TREE
+ && TREE_CODE (TREE_VALUE (t2)) == STRING_CST)
+ {
+ const char *p1 = omp_context_name_list_prop (t1);
+ const char *p2 = omp_context_name_list_prop (t2);
+ if (p2
+ && strcmp (p1, p2) == 0
+ && strcmp (p1, " score"))
+ break;
+ }
+ else if (TREE_PURPOSE (t1) == NULL_TREE
+ && TREE_PURPOSE (t2)
+ && TREE_CODE (TREE_VALUE (t1)) == STRING_CST)
+ {
+ const char *p1 = omp_context_name_list_prop (t1);
+ const char *p2 = omp_context_name_list_prop (t2);
+ if (p1
+ && strcmp (p1, p2) == 0
+ && strcmp (p1, " score"))
+ break;
+ }
if (t2 == NULL_TREE)
{
int r = pass ? -1 : 1;