From 9bd5f808ccacef0acc84529a0bdd22b448d06e4a Mon Sep 17 00:00:00 2001 From: erichkeane Date: Fri, 17 Nov 2023 11:10:55 -0800 Subject: [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. --- clang/include/clang/Basic/OpenACCKinds.h | 28 ++++++++++++++ clang/lib/Parse/ParseOpenACC.cpp | 10 +++++ clang/test/ParserOpenACC/parse-constructs.c | 58 +++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+) (limited to 'clang') diff --git a/clang/include/clang/Basic/OpenACCKinds.h b/clang/include/clang/Basic/OpenACCKinds.h index 79780b7..8da02b9 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 9f13aad..ba29d75 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(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 4c2188cc..e0607e7 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(;;){} } -- cgit v1.1