Author: erichkeane
Date: 2024-01-11T09:34:08-08:00
New Revision: dd5ce4572fb90323799f1bdf585c01d08613e277

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

LOG: [OpenACC] Implement 'use_device' clause parsing

'use_device' is effectively identical to the 'copy' parsing in that it
has required parens and no 'special' name, so this is a pretty trivial
impementation.  There are a number of other similar situation clauses
I'll do in a followup patch.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/OpenACCKinds.h 
b/clang/include/clang/Basic/OpenACCKinds.h
index 1e260cfde30b9e..cb775ba0d92873 100644
--- a/clang/include/clang/Basic/OpenACCKinds.h
+++ b/clang/include/clang/Basic/OpenACCKinds.h
@@ -101,6 +101,8 @@ enum class OpenACCClauseKind {
   /// 'copy' clause, allowed on Compute and Combined Constructs, plus 'data' 
and
   /// 'declare'.
   Copy,
+  /// 'use_device' clause, allowed on 'host_data' construct.
+  UseDevice,
   /// Represents an invalid clause, for the purposes of parsing.
   Invalid,
 };

diff  --git a/clang/lib/Parse/ParseOpenACC.cpp 
b/clang/lib/Parse/ParseOpenACC.cpp
index 0594a77aa77ac0..c94f48d3ec04f0 100644
--- a/clang/lib/Parse/ParseOpenACC.cpp
+++ b/clang/lib/Parse/ParseOpenACC.cpp
@@ -99,6 +99,7 @@ OpenACCClauseKind getOpenACCClauseKind(Token Tok) {
       .Case("nohost", OpenACCClauseKind::NoHost)
       .Case("self", OpenACCClauseKind::Self)
       .Case("seq", OpenACCClauseKind::Seq)
+      .Case("use_device", OpenACCClauseKind::UseDevice)
       .Case("vector", OpenACCClauseKind::Vector)
       .Case("worker", OpenACCClauseKind::Worker)
       .Default(OpenACCClauseKind::Invalid);
@@ -336,7 +337,8 @@ bool ClauseHasOptionalParens(OpenACCClauseKind Kind) {
 
 bool ClauseHasRequiredParens(OpenACCClauseKind Kind) {
   return Kind == OpenACCClauseKind::Default || Kind == OpenACCClauseKind::If ||
-         Kind == OpenACCClauseKind::Copy;
+         Kind == OpenACCClauseKind::Copy ||
+         Kind == OpenACCClauseKind::UseDevice;
 }
 
 ExprResult ParseOpenACCConditionalExpr(Parser &P) {
@@ -461,6 +463,7 @@ bool Parser::ParseOpenACCClauseParams(OpenACCClauseKind 
Kind) {
         return true;
       break;
     }
+    case OpenACCClauseKind::UseDevice:
     case OpenACCClauseKind::Copy:
       if (ParseOpenACCClauseVarList(Kind))
         return true;

diff  --git a/clang/test/ParserOpenACC/parse-clauses.c 
b/clang/test/ParserOpenACC/parse-clauses.c
index 8f2206ff247ec4..623136f76d0003 100644
--- a/clang/test/ParserOpenACC/parse-clauses.c
+++ b/clang/test/ParserOpenACC/parse-clauses.c
@@ -365,7 +365,7 @@ void VarListClauses() {
 #pragma acc serial copy(s.array[s.value]), seq
 
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma 
ignored}}
-#pragma acc serial copy(s.array[s.value : 5]), seq
+#pragma acc serial copy(s.array[s.value], s.array[s.value :5] ), seq
 
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma 
ignored}}
 #pragma acc serial copy(HasMem.MemArr[3].array[1]), seq
@@ -398,6 +398,13 @@ void VarListClauses() {
   // expected-error@+2{{expected expression}}
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma 
ignored}}
 #pragma acc serial copy(HasMem.MemArr[3:]), seq
+
+  // expected-error@+2{{expected ','}}
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma 
ignored}}
+#pragma acc serial use_device(s.array[s.value] s.array[s.value :5] ), seq
+
+  // expected-warning@+1{{OpenACC directives not yet implemented, pragma 
ignored}}
+#pragma acc serial use_device(s.array[s.value : 5]), seq
 }
 
   // expected-warning@+1{{OpenACC directives not yet implemented, pragma 
ignored}}


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

Reply via email to