-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[flang][OpenMP] Resolve names for declare simd uniform clause #142160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[flang][OpenMP] Resolve names for declare simd uniform clause #142160
Conversation
Add a visitor for OmpClause::Uniform to resolve its parameter names. Fixes issue llvm#140741. Signed-off-by: Kajetan Puchalski <[email protected]>
@llvm/pr-subscribers-flang-openmp Author: Kajetan Puchalski (mrkajetanp) ChangesAdd a visitor for OmpClause::Uniform to resolve its parameter names. Full diff: https://github.com/llvm/llvm-project/pull/142160.diff 4 Files Affected:
diff --git a/flang/include/flang/Semantics/symbol.h b/flang/include/flang/Semantics/symbol.h
index 4cded64d170cd..9ebdd3a8081ed 100644
--- a/flang/include/flang/Semantics/symbol.h
+++ b/flang/include/flang/Semantics/symbol.h
@@ -786,7 +786,7 @@ class Symbol {
OmpExecutableAllocateDirective, OmpDeclareSimd, OmpDeclareTarget,
OmpThreadprivate, OmpDeclareReduction, OmpFlushed, OmpCriticalLock,
OmpIfSpecified, OmpNone, OmpPreDetermined, OmpImplicit, OmpDependObject,
- OmpInclusiveScan, OmpExclusiveScan, OmpInScanReduction);
+ OmpInclusiveScan, OmpExclusiveScan, OmpInScanReduction, OmpUniform);
using Flags = common::EnumSet<Flag, Flag_enumSize>;
const Scope &owner() const { return *owner_; }
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 9fa7bc8964854..ecb4f02732a4b 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -550,6 +550,13 @@ class OmpAttributeVisitor : DirectiveAttributeVisitor<llvm::omp::Directive> {
return false;
}
+ bool Pre(const parser::OmpClause::Uniform &x) {
+ for (const auto &name : x.v) {
+ ResolveOmpName(name, Symbol::Flag::OmpUniform);
+ }
+ return false;
+ }
+
bool Pre(const parser::OmpInReductionClause &x) {
auto &objects{std::get<parser::OmpObjectList>(x.t)};
ResolveOmpObjectList(objects, Symbol::Flag::OmpInReduction);
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 57035c57ee16f..7bea6fdb00e55 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -1511,6 +1511,11 @@ class OmpVisitor : public virtual DeclarationVisitor {
return false;
}
+ bool Pre(const parser::OpenMPDeclareSimdConstruct &x) {
+ AddOmpSourceRange(x.source);
+ return true;
+ }
+
bool Pre(const parser::OmpInitializerProc &x) {
auto &procDes = std::get<parser::ProcedureDesignator>(x.t);
auto &name = std::get<parser::Name>(procDes.u);
diff --git a/flang/test/Semantics/OpenMP/declare-simd-uniform.f90 b/flang/test/Semantics/OpenMP/declare-simd-uniform.f90
new file mode 100644
index 0000000000000..3a0c52b8e7b0e
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/declare-simd-uniform.f90
@@ -0,0 +1,13 @@
+! RUN: %python %S/../test_errors.py %s %flang -fopenmp
+! Test declare simd with uniform clause
+
+function add2(a,b,i,fact,alc) result(c)
+ !$omp declare simd(add2) uniform(a,b,fact)
+ integer :: i
+ integer,pointer::alc
+ double precision :: a(*),b(*),fact,c
+ c = a(i) + b(i) + fact
+end function
+
+end
+
|
@llvm/pr-subscribers-flang-semantics Author: Kajetan Puchalski (mrkajetanp) ChangesAdd a visitor for OmpClause::Uniform to resolve its parameter names. Full diff: https://github.com/llvm/llvm-project/pull/142160.diff 4 Files Affected:
diff --git a/flang/include/flang/Semantics/symbol.h b/flang/include/flang/Semantics/symbol.h
index 4cded64d170cd..9ebdd3a8081ed 100644
--- a/flang/include/flang/Semantics/symbol.h
+++ b/flang/include/flang/Semantics/symbol.h
@@ -786,7 +786,7 @@ class Symbol {
OmpExecutableAllocateDirective, OmpDeclareSimd, OmpDeclareTarget,
OmpThreadprivate, OmpDeclareReduction, OmpFlushed, OmpCriticalLock,
OmpIfSpecified, OmpNone, OmpPreDetermined, OmpImplicit, OmpDependObject,
- OmpInclusiveScan, OmpExclusiveScan, OmpInScanReduction);
+ OmpInclusiveScan, OmpExclusiveScan, OmpInScanReduction, OmpUniform);
using Flags = common::EnumSet<Flag, Flag_enumSize>;
const Scope &owner() const { return *owner_; }
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 9fa7bc8964854..ecb4f02732a4b 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -550,6 +550,13 @@ class OmpAttributeVisitor : DirectiveAttributeVisitor<llvm::omp::Directive> {
return false;
}
+ bool Pre(const parser::OmpClause::Uniform &x) {
+ for (const auto &name : x.v) {
+ ResolveOmpName(name, Symbol::Flag::OmpUniform);
+ }
+ return false;
+ }
+
bool Pre(const parser::OmpInReductionClause &x) {
auto &objects{std::get<parser::OmpObjectList>(x.t)};
ResolveOmpObjectList(objects, Symbol::Flag::OmpInReduction);
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 57035c57ee16f..7bea6fdb00e55 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -1511,6 +1511,11 @@ class OmpVisitor : public virtual DeclarationVisitor {
return false;
}
+ bool Pre(const parser::OpenMPDeclareSimdConstruct &x) {
+ AddOmpSourceRange(x.source);
+ return true;
+ }
+
bool Pre(const parser::OmpInitializerProc &x) {
auto &procDes = std::get<parser::ProcedureDesignator>(x.t);
auto &name = std::get<parser::Name>(procDes.u);
diff --git a/flang/test/Semantics/OpenMP/declare-simd-uniform.f90 b/flang/test/Semantics/OpenMP/declare-simd-uniform.f90
new file mode 100644
index 0000000000000..3a0c52b8e7b0e
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/declare-simd-uniform.f90
@@ -0,0 +1,13 @@
+! RUN: %python %S/../test_errors.py %s %flang -fopenmp
+! Test declare simd with uniform clause
+
+function add2(a,b,i,fact,alc) result(c)
+ !$omp declare simd(add2) uniform(a,b,fact)
+ integer :: i
+ integer,pointer::alc
+ double precision :: a(*),b(*),fact,c
+ c = a(i) + b(i) + fact
+end function
+
+end
+
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG. Please wait for @tblah
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
…42160) Add a visitor for OmpClause::Uniform to resolve its parameter names. Add Symbol::Flag::OmpUniform to attach it to the resolved symbols. Fixes issue llvm#140741. --------- Signed-off-by: Kajetan Puchalski <[email protected]>
…42160) Add a visitor for OmpClause::Uniform to resolve its parameter names. Add Symbol::Flag::OmpUniform to attach it to the resolved symbols. Fixes issue llvm#140741. --------- Signed-off-by: Kajetan Puchalski <[email protected]>
Add a visitor for OmpClause::Uniform to resolve its parameter names.
Fixes issue #140741.