[clang] 04952c5 - [OpenACC] Implement remaining 'simple' int-expr clauses.
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 22 10:43:18 PST 2024
Author: erichkeane
Date: 2024-01-22T10:43:13-08:00
New Revision: 04952c5bec69c197ea6ffb718ae80fcf78c7828a
URL: https://github.com/llvm/llvm-project/commit/04952c5bec69c197ea6ffb718ae80fcf78c7828a
DIFF: https://github.com/llvm/llvm-project/commit/04952c5bec69c197ea6ffb718ae80fcf78c7828a.diff
LOG: [OpenACC] Implement remaining 'simple' int-expr clauses.
'num_gangs', 'num_workers', 'device_num', and 'default_async' are all
exactly the same (for the purposes of parsing) as 'vector_length', so
implement these the same way.
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 a33daea2331aa3..3d3f128f7784fc 100644
--- a/clang/include/clang/Basic/OpenACCKinds.h
+++ b/clang/include/clang/Basic/OpenACCKinds.h
@@ -224,6 +224,16 @@ enum class OpenACCClauseKind {
/// 'vector_length' clause, allowed on 'parallel', 'kernels', 'parallel loop',
/// and 'kernels loop' constructs.
VectorLength,
+ /// 'num_gangs' clause, allowed on 'parallel', 'kernels', parallel loop', and
+ /// 'kernels loop' constructs.
+ NumGangs,
+ /// 'num_workers' clause, allowed on 'parallel', 'kernels', parallel loop',
+ /// and 'kernels loop' constructs.
+ NumWorkers,
+ /// 'device_num' clause, allowed on 'init', 'shutdown', and 'set' constructs.
+ DeviceNum,
+ /// 'default_async' clause, allowed on 'set' construct.
+ DefaultAsync,
/// Represents an invalid clause, for the purposes of parsing.
Invalid,
@@ -328,6 +338,18 @@ inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &Out,
case OpenACCClauseKind::VectorLength:
return Out << "vector_length";
+ case OpenACCClauseKind::NumGangs:
+ return Out << "num_gangs";
+
+ case OpenACCClauseKind::NumWorkers:
+ return Out << "num_workers";
+
+ case OpenACCClauseKind::DeviceNum:
+ return Out << "device_num";
+
+ case OpenACCClauseKind::DefaultAsync:
+ return Out << "default_async";
+
case OpenACCClauseKind::Invalid:
return Out << "<invalid>";
}
diff --git a/clang/lib/Parse/ParseOpenACC.cpp b/clang/lib/Parse/ParseOpenACC.cpp
index 9b0d7077670a7f..612ee5ef214c13 100644
--- a/clang/lib/Parse/ParseOpenACC.cpp
+++ b/clang/lib/Parse/ParseOpenACC.cpp
@@ -98,9 +98,11 @@ OpenACCClauseKind getOpenACCClauseKind(Token Tok) {
.Case("copyin", OpenACCClauseKind::CopyIn)
.Case("copyout", OpenACCClauseKind::CopyOut)
.Case("default", OpenACCClauseKind::Default)
+ .Case("default_async", OpenACCClauseKind::DefaultAsync)
.Case("delete", OpenACCClauseKind::Delete)
.Case("detach", OpenACCClauseKind::Detach)
.Case("device", OpenACCClauseKind::Device)
+ .Case("device_num", OpenACCClauseKind::DeviceNum)
.Case("device_resident", OpenACCClauseKind::DeviceResident)
.Case("deviceptr", OpenACCClauseKind::DevicePtr)
.Case("finalize", OpenACCClauseKind::Finalize)
@@ -111,6 +113,8 @@ OpenACCClauseKind getOpenACCClauseKind(Token Tok) {
.Case("independent", OpenACCClauseKind::Independent)
.Case("link", OpenACCClauseKind::Link)
.Case("no_create", OpenACCClauseKind::NoCreate)
+ .Case("num_gangs", OpenACCClauseKind::NumGangs)
+ .Case("num_workers", OpenACCClauseKind::NumWorkers)
.Case("nohost", OpenACCClauseKind::NoHost)
.Case("present", OpenACCClauseKind::Present)
.Case("private", OpenACCClauseKind::Private)
@@ -471,6 +475,10 @@ ClauseParensKind getClauseParensKind(OpenACCDirectiveKind DirKind,
case OpenACCClauseKind::Collapse:
case OpenACCClauseKind::Bind:
case OpenACCClauseKind::VectorLength:
+ case OpenACCClauseKind::NumGangs:
+ case OpenACCClauseKind::NumWorkers:
+ case OpenACCClauseKind::DeviceNum:
+ case OpenACCClauseKind::DefaultAsync:
return ClauseParensKind::Required;
case OpenACCClauseKind::Auto:
@@ -684,6 +692,10 @@ bool Parser::ParseOpenACCClauseParams(OpenACCDirectiveKind DirKind,
return true;
break;
}
+ case OpenACCClauseKind::NumGangs:
+ case OpenACCClauseKind::NumWorkers:
+ case OpenACCClauseKind::DeviceNum:
+ case OpenACCClauseKind::DefaultAsync:
case OpenACCClauseKind::VectorLength: {
ExprResult IntExpr = ParseOpenACCIntExpr();
if (IntExpr.isInvalid())
diff --git a/clang/test/ParserOpenACC/parse-clauses.c b/clang/test/ParserOpenACC/parse-clauses.c
index 31643073eb76a6..b6114c73f1b19e 100644
--- a/clang/test/ParserOpenACC/parse-clauses.c
+++ b/clang/test/ParserOpenACC/parse-clauses.c
@@ -725,6 +725,98 @@ void IntExprParsing() {
// expected-warning at +1{{OpenACC directives not yet implemented, pragma ignored}}
#pragma acc parallel vector_length(returns_int())
+
+ // expected-error at +2{{expected '('}}
+ // expected-warning at +1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc parallel num_gangs
+
+ // expected-error at +2{{expected expression}}
+ // expected-warning at +1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc parallel num_gangs()
+
+ // expected-error at +2{{use of undeclared identifier 'invalid'}}
+ // expected-warning at +1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc parallel num_gangs(invalid)
+
+ // expected-error at +3{{expected ')'}}
+ // expected-note at +2{{to match this '('}}
+ // expected-warning at +1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc parallel num_gangs(5, 4)
+
+ // expected-warning at +1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc parallel num_gangs(5)
+
+ // expected-warning at +1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc parallel num_gangs(returns_int())
+
+ // expected-error at +2{{expected '('}}
+ // expected-warning at +1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc parallel num_workers
+
+ // expected-error at +2{{expected expression}}
+ // expected-warning at +1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc parallel num_workers()
+
+ // expected-error at +2{{use of undeclared identifier 'invalid'}}
+ // expected-warning at +1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc parallel num_workers(invalid)
+
+ // expected-error at +3{{expected ')'}}
+ // expected-note at +2{{to match this '('}}
+ // expected-warning at +1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc parallel num_workers(5, 4)
+
+ // expected-warning at +1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc parallel num_workers(5)
+
+ // expected-warning at +1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc parallel num_workers(returns_int())
+
+ // expected-error at +2{{expected '('}}
+ // expected-warning at +1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc init device_num
+
+ // expected-error at +2{{expected expression}}
+ // expected-warning at +1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc init device_num()
+
+ // expected-error at +2{{use of undeclared identifier 'invalid'}}
+ // expected-warning at +1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc init device_num(invalid)
+
+ // expected-error at +3{{expected ')'}}
+ // expected-note at +2{{to match this '('}}
+ // expected-warning at +1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc init device_num(5, 4)
+
+ // expected-warning at +1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc init device_num(5)
+
+ // expected-warning at +1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc init device_num(returns_int())
+
+ // expected-error at +2{{expected '('}}
+ // expected-warning at +1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc set default_async
+
+ // expected-error at +2{{expected expression}}
+ // expected-warning at +1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc set default_async()
+
+ // expected-error at +2{{use of undeclared identifier 'invalid'}}
+ // expected-warning at +1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc set default_async(invalid)
+
+ // expected-error at +3{{expected ')'}}
+ // expected-note at +2{{to match this '('}}
+ // expected-warning at +1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc set default_async(5, 4)
+
+ // expected-warning at +1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc set default_async(5)
+
+ // expected-warning at +1{{OpenACC directives not yet implemented, pragma ignored}}
+#pragma acc set default_async(returns_int())
}
// expected-warning at +1{{OpenACC directives not yet implemented, pragma ignored}}
More information about the cfe-commits
mailing list