Skip to content

[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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion flang/include/flang/Semantics/symbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_; }
Expand Down
8 changes: 7 additions & 1 deletion flang/lib/Semantics/resolve-directives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,11 @@ class OmpAttributeVisitor : DirectiveAttributeVisitor<llvm::omp::Directive> {
return false;
}

bool Pre(const parser::OmpClause::Uniform &x) {
ResolveOmpNameList(x.v, Symbol::Flag::OmpUniform);
return false;
}

bool Pre(const parser::OmpInReductionClause &x) {
auto &objects{std::get<parser::OmpObjectList>(x.t)};
ResolveOmpObjectList(objects, Symbol::Flag::OmpInReduction);
Expand Down Expand Up @@ -752,7 +757,8 @@ class OmpAttributeVisitor : DirectiveAttributeVisitor<llvm::omp::Directive> {
Symbol::Flag::OmpLastPrivate, Symbol::Flag::OmpReduction,
Symbol::Flag::OmpCriticalLock, Symbol::Flag::OmpCopyIn,
Symbol::Flag::OmpUseDevicePtr, Symbol::Flag::OmpUseDeviceAddr,
Symbol::Flag::OmpIsDevicePtr, Symbol::Flag::OmpHasDeviceAddr};
Symbol::Flag::OmpIsDevicePtr, Symbol::Flag::OmpHasDeviceAddr,
Symbol::Flag::OmpUniform};

Symbol::Flags ompFlagsRequireMark{Symbol::Flag::OmpThreadprivate,
Symbol::Flag::OmpDeclareTarget, Symbol::Flag::OmpExclusiveScan,
Expand Down
5 changes: 5 additions & 0 deletions flang/lib/Semantics/resolve-names.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions flang/lib/Semantics/symbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,9 @@ std::string Symbol::OmpFlagToClauseName(Symbol::Flag ompFlag) {
case Symbol::Flag::OmpLinear:
clauseName = "LINEAR";
break;
case Symbol::Flag::OmpUniform:
clauseName = "UNIFORM";
break;
case Symbol::Flag::OmpFirstPrivate:
clauseName = "FIRSTPRIVATE";
break;
Expand Down
22 changes: 22 additions & 0 deletions flang/test/Semantics/OpenMP/declare-simd-uniform.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
! RUN: %python %S/../test_errors.py %s %flang -fopenmp
! RUN: %flang_fc1 -fopenmp -fdebug-dump-symbols %s | FileCheck %s
! 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

! CHECK-LABEL: Subprogram scope: add2 size=48 alignment=8 sourceRange=189 bytes
! CHECK-NEXT: a (OmpUniform): ObjectEntity dummy type: REAL(8) shape: 1_8:*
! CHECK-NEXT: add2 (Function): HostAssoc
! CHECK-NEXT: alc, POINTER size=24 offset=8: ObjectEntity dummy type: INTEGER(4)
! CHECK-NEXT: b (OmpUniform): ObjectEntity dummy type: REAL(8) shape: 1_8:*
! CHECK-NEXT: c size=8 offset=40: ObjectEntity funcResult type: REAL(8)
! CHECK-NEXT: fact (OmpUniform) size=8 offset=32: ObjectEntity dummy type: REAL(8)
! CHECK-NEXT: i size=4 offset=0: ObjectEntity dummy type: INTEGER(4)
Loading