aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.cc
diff options
context:
space:
mode:
authorThomas Schwinge <thomas@codesourcery.com>2022-02-17 12:46:57 +0100
committerThomas Schwinge <thomas@codesourcery.com>2022-03-12 11:05:29 +0100
commit828335beb77676acffb5911e575672cb55beb2e9 (patch)
treefc053dc2a1bb8517efff2aa6c4377278644e2a17 /gcc/tree.cc
parent72c243017dee611bf3c32ea7bfad6ac538021aaf (diff)
downloadgcc-828335beb77676acffb5911e575672cb55beb2e9.zip
gcc-828335beb77676acffb5911e575672cb55beb2e9.tar.gz
gcc-828335beb77676acffb5911e575672cb55beb2e9.tar.bz2
Add 'gcc/tree.cc:user_omp_clause_code_name' [PR65095]
Re PR65095 "Adapt OpenMP diagnostic messages for OpenACC", move C/C++ front end 'gcc/c-family/c-omp.cc:c_omp_map_clause_name' to generic 'gcc/tree.cc:user_omp_clause_code_name' . No functional change. PR other/65095 gcc/ * tree-core.h (user_omp_claus_code_name): Declare function. * tree.cc (user_omp_clause_code_name): New function. gcc/c/ * c-typeck.cc (handle_omp_array_sections_1) (c_oacc_check_attachments): Call 'user_omp_clause_code_name' instead of 'c_omp_map_clause_name'. gcc/cp/ * semantics.cc (handle_omp_array_sections_1) (cp_oacc_check_attachments): Call 'user_omp_clause_code_name' instead of 'c_omp_map_clause_name'. gcc/c-family/ * c-common.h (c_omp_map_clause_name): Remove. * c-omp.cc (c_omp_map_clause_name): Remove.
Diffstat (limited to 'gcc/tree.cc')
-rw-r--r--gcc/tree.cc36
1 files changed, 36 insertions, 0 deletions
diff --git a/gcc/tree.cc b/gcc/tree.cc
index d6f900c..b8017af 100644
--- a/gcc/tree.cc
+++ b/gcc/tree.cc
@@ -69,6 +69,7 @@ along with GCC; see the file COPYING3. If not see
#include "gimple-fold.h"
#include "escaped_string.h"
#include "gimple-range.h"
+#include "gomp-constants.h"
/* Tree code classes. */
@@ -439,6 +440,41 @@ const char * const omp_clause_code_name[] =
"nohost",
};
+/* Unless specific to OpenACC, we tend to internally maintain OpenMP-centric
+ clause names, but for use in diagnostics etc. would like to use the "user"
+ clause names. */
+
+const char *
+user_omp_clause_code_name (tree clause, bool oacc)
+{
+ /* For OpenACC, the 'OMP_CLAUSE_MAP_KIND' of an 'OMP_CLAUSE_MAP' is used to
+ distinguish clauses as seen by the user. See also where front ends do
+ 'build_omp_clause' with 'OMP_CLAUSE_MAP'. */
+ if (oacc && OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP)
+ switch (OMP_CLAUSE_MAP_KIND (clause))
+ {
+ case GOMP_MAP_FORCE_ALLOC:
+ case GOMP_MAP_ALLOC: return "create";
+ case GOMP_MAP_FORCE_TO:
+ case GOMP_MAP_TO: return "copyin";
+ case GOMP_MAP_FORCE_FROM:
+ case GOMP_MAP_FROM: return "copyout";
+ case GOMP_MAP_FORCE_TOFROM:
+ case GOMP_MAP_TOFROM: return "copy";
+ case GOMP_MAP_RELEASE: return "delete";
+ case GOMP_MAP_FORCE_PRESENT: return "present";
+ case GOMP_MAP_ATTACH: return "attach";
+ case GOMP_MAP_FORCE_DETACH:
+ case GOMP_MAP_DETACH: return "detach";
+ case GOMP_MAP_DEVICE_RESIDENT: return "device_resident";
+ case GOMP_MAP_LINK: return "link";
+ case GOMP_MAP_FORCE_DEVICEPTR: return "deviceptr";
+ default: break;
+ }
+
+ return omp_clause_code_name[OMP_CLAUSE_CODE (clause)];
+}
+
/* Return the tree node structure used by tree code CODE. */