This is an archive of the discontinued LLVM Phabricator instance.

[openacc] Use TableGen enum for default clause value
ClosedPublic

Authored by clementval on Dec 18 2020, 7:24 PM.

Details

Summary

Use the TableGen feature to have enum values for clauses.
Next step will be to extend the MLIR part used currently by OpenMP
to use the same enum on the dialect side.

This patch also add function that convert the enum to StringRef to be
used on the dump-parse-tree from flang.

Diff Detail

Event Timeline

clementval created this revision.Dec 18 2020, 7:24 PM
clementval requested review of this revision.Dec 18 2020, 7:24 PM
clementval added a project: Restricted Project.Dec 18 2020, 7:27 PM
jdoerfert accepted this revision.Dec 21 2020, 11:26 AM

Typo in the commit message, otherwise LGTM.

This revision is now accepted and ready to land.Dec 21 2020, 11:26 AM
clementval edited the summary of this revision. (Show Details)Dec 21 2020, 12:06 PM
This revision was landed with ongoing or failed builds.Dec 21 2020, 12:07 PM
This revision was automatically updated to reflect the committed changes.
sameeranjoshi added inline comments.Dec 22 2020, 1:02 AM
llvm/include/llvm/Frontend/OpenACC/ACC.td
84

Trying to understand -
class ClauseVal<string n, int v, bit uv> mentions second parameter (i.e v)as value of clause.

Is there are reason to start the numbering from 0?
In OMP.td as well I see they always start with index 2, any defined pattern used here?

clementval added inline comments.Dec 22 2020, 6:55 AM
llvm/include/llvm/Frontend/OpenACC/ACC.td
84

The enum in OMP.td starts at 2 to follow the one already defined for Clang here: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def In the long term the OMPKinds.def file is supposed to go away gradually.

This is my guess but @kiranchandramohan can confirm since he introduced those change for OpenMP.

llvm/include/llvm/Frontend/OpenACC/ACC.td
84

What @clementval says and also The standard sometimes defines values for the clauses which are constants. For e.g. for proc_bind.
integer (kind=omp_proc_bind_kind), parameter :: omp_proc_bind_false = 0
integer (kind=omp_proc_bind_kind), parameter :: omp_proc_bind_true = 1
integer (kind=omp_proc_bind_kind), parameter :: omp_proc_bind_master = 2
integer (kind=omp_proc_bind_kind), parameter :: omp_proc_bind_close = 3
integer (kind=omp_proc_bind_kind), parameter :: omp_proc_bind_spread = 4