Author: erichkeane
Date: 2023-11-17T11:26:22-08:00
New Revision: 9bd5f808ccacef0acc84529a0bdd22b448d06e4a

URL: 
https://github.com/llvm/llvm-project/commit/9bd5f808ccacef0acc84529a0bdd22b448d06e4a
DIFF: 
https://github.com/llvm/llvm-project/commit/9bd5f808ccacef0acc84529a0bdd22b448d06e4a.diff

LOG: [OpenACC] Implement 'trivial' construct/directive parsing.

Now that the `parallel` support has landed, add the other 'trivial' to
implement ones that don't require any additional work other than adding
them to the StringSwitch.

Added: 
    

Modified: 
    clang/include/clang/Basic/OpenACCKinds.h
    clang/lib/Parse/ParseOpenACC.cpp
    clang/test/ParserOpenACC/parse-constructs.c

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/OpenACCKinds.h 
b/clang/include/clang/Basic/OpenACCKinds.h
index 79780b7fe6835f3..8da02b93b2b974c 100644
--- a/clang/include/clang/Basic/OpenACCKinds.h
+++ b/clang/include/clang/Basic/OpenACCKinds.h
@@ -21,6 +21,34 @@ namespace clang {
 enum class OpenACCDirectiveKind {
   // Compute Constructs.
   Parallel,
+  Serial,
+  Kernels,
+
+  // Data Environment.
+  Data,
+  // FIXME: 'enter data', 'exit data'.
+  HostData,
+
+  // Misc.
+  Loop,
+  // FIXME: 'cache'
+
+  // FIXME: Combined Constructs.
+
+  // FIXME: atomic Construct variants.
+
+  // Declare Directive.
+  Declare,
+
+  // Executable Directives. "wait" is first referred to here, but ends up being
+  // in its own section after "routine".
+  Init,
+  Shutdown,
+  Set,
+  Update,
+  // FIXME: wait construct.
+
+  // FIXME: routine construct.
 
   // Invalid.
   Invalid,

diff  --git a/clang/lib/Parse/ParseOpenACC.cpp 
b/clang/lib/Parse/ParseOpenACC.cpp
index 9f13aadf92e4f66..ba29d75fe35a500 100644
--- a/clang/lib/Parse/ParseOpenACC.cpp
+++ b/clang/lib/Parse/ParseOpenACC.cpp
@@ -26,6 +26,16 @@ namespace {
 OpenACCDirectiveKind GetOpenACCDirectiveKind(StringRef Name) {
   return llvm::StringSwitch<OpenACCDirectiveKind>(Name)
       .Case("parallel", OpenACCDirectiveKind::Parallel)
+      .Case("serial", OpenACCDirectiveKind::Serial)
+      .Case("kernels", OpenACCDirectiveKind::Kernels)
+      .Case("data", OpenACCDirectiveKind::Data)
+      .Case("host_data", OpenACCDirectiveKind::HostData)
+      .Case("loop", OpenACCDirectiveKind::Loop)
+      .Case("declare", OpenACCDirectiveKind::Declare)
+      .Case("init", OpenACCDirectiveKind::Init)
+      .Case("shutdown", OpenACCDirectiveKind::Shutdown)
+      .Case("set", OpenACCDirectiveKind::Shutdown)
+      .Case("update", OpenACCDirectiveKind::Update)
       .Default(OpenACCDirectiveKind::Invalid);
 }
 

diff  --git a/clang/test/ParserOpenACC/parse-constructs.c 
b/clang/test/ParserOpenACC/parse-constructs.c
index 4c2188cc3cef11b..e0607e7cfe316ab 100644
--- a/clang/test/ParserOpenACC/parse-constructs.c
+++ b/clang/test/ParserOpenACC/parse-constructs.c
@@ -13,4 +13,62 @@ void func() {
   // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma 
ignored}}
 #pragma acc parallel() clause list
+  for(;;){}
+  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma 
ignored}}
+#pragma acc serial clause list
+  for(;;){}
+  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma 
ignored}}
+#pragma acc kernels clause list
+  for(;;){}
+  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma 
ignored}}
+#pragma acc data clause list
+  for(;;){}
+  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma 
ignored}}
+#pragma acc host_data clause list
+  for(;;){}
+  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma 
ignored}}
+#pragma acc loop clause list
+  for(;;){}
+  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma 
ignored}}
+#pragma acc parallel invalid clause list
+  for(;;){}
+  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma 
ignored}}
+#pragma acc parallel loop clause list
+  for(;;){}
+  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma 
ignored}}
+#pragma acc serial loop clause list
+  for(;;){}
+  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma 
ignored}}
+#pragma acc kernels loop clause list
+  for(;;){}
+
+  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma 
ignored}}
+#pragma acc declare clause list
+  for(;;){}
+  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma 
ignored}}
+#pragma acc init clause list
+  for(;;){}
+  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma 
ignored}}
+#pragma acc shutdown clause list
+  for(;;){}
+  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma 
ignored}}
+#pragma acc set clause list
+  for(;;){}
+  // expected-warning@+2{{OpenACC clause parsing not yet implemented}}
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma 
ignored}}
+#pragma acc update clause list
+  for(;;){}
 }


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to