Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b0b4e0a

Browse filesBrowse files
Rebase, Add unparse functions, tests
1 parent 6ffe446 commit b0b4e0a
Copy full SHA for b0b4e0a

File tree

Expand file treeCollapse file tree

6 files changed

+162
-3
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+162
-3
lines changed

‎flang/include/flang/Parser/parse-tree.h

Copy file name to clipboardExpand all lines: flang/include/flang/Parser/parse-tree.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4016,7 +4016,7 @@ struct OmpAbsentClause {
40164016
struct OmpAdjustArgsClause {
40174017
TUPLE_CLASS_BOILERPLATE(OmpAdjustArgsClause);
40184018
struct OmpAdjustOp {
4019-
ENUM_CLASS(Value, Nothing, NeedDevicePtr)
4019+
ENUM_CLASS(Value, Nothing, Need_Device_Ptr)
40204020
WRAPPER_CLASS_BOILERPLATE(OmpAdjustOp, Value);
40214021
};
40224022
std::tuple<OmpAdjustOp, OmpObjectList> t;

‎flang/lib/Parser/openmp-parsers.cpp

Copy file name to clipboardExpand all lines: flang/lib/Parser/openmp-parsers.cpp
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ TYPE_PARSER(construct<OmpAppendArgsClause::OmpAppendOp>(
617617
TYPE_PARSER(construct<OmpAdjustArgsClause::OmpAdjustOp>(
618618
"NOTHING" >> pure(OmpAdjustArgsClause::OmpAdjustOp::Value::Nothing) ||
619619
"NEED_DEVICE_PTR" >>
620-
pure(OmpAdjustArgsClause::OmpAdjustOp::Value::NeedDevicePtr)))
620+
pure(OmpAdjustArgsClause::OmpAdjustOp::Value::Need_Device_Ptr)))
621621

622622
// --- Parsers for clauses --------------------------------------------
623623

‎flang/lib/Parser/unparse.cpp

Copy file name to clipboardExpand all lines: flang/lib/Parser/unparse.cpp
+25-1Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2743,7 +2743,30 @@ class UnparseVisitor {
27432743
Put("\n");
27442744
EndOpenMP();
27452745
}
2746-
2746+
void Unparse(const OmpAppendArgsClause::OmpAppendOp &x) {
2747+
Put("INTEROP(");
2748+
Walk(x.v, ",");
2749+
Put(")");
2750+
}
2751+
void Unparse(const OmpAppendArgsClause &x) {
2752+
Walk(x.v, ",");
2753+
}
2754+
void Unparse(const OmpAdjustArgsClause &x) {
2755+
Walk(std::get<OmpAdjustArgsClause::OmpAdjustOp>(x.t).v);
2756+
Put(":");
2757+
Walk(std::get<parser::OmpObjectList>(x.t));
2758+
}
2759+
void Unparse(const OmpDeclareVariantDirective &x) {
2760+
BeginOpenMP();
2761+
Word("!$OMP DECLARE VARIANT ");
2762+
Put("(");
2763+
Walk(std::get<std::optional<Name>>(x.t), ":");
2764+
Walk(std::get<Name>(x.t));
2765+
Put(")");
2766+
Walk(std::get<OmpClauseList>(x.t));
2767+
Put("\n");
2768+
EndOpenMP();
2769+
}
27472770
void Unparse(const OpenMPInteropConstruct &x) {
27482771
BeginOpenMP();
27492772
Word("!$OMP INTEROP");
@@ -3042,6 +3065,7 @@ class UnparseVisitor {
30423065
WALK_NESTED_ENUM(InquireSpec::LogVar, Kind)
30433066
WALK_NESTED_ENUM(ProcedureStmt, Kind) // R1506
30443067
WALK_NESTED_ENUM(UseStmt, ModuleNature) // R1410
3068+
WALK_NESTED_ENUM(OmpAdjustArgsClause::OmpAdjustOp, Value) // OMP adjustop
30453069
WALK_NESTED_ENUM(OmpAtClause, ActionTime) // OMP at
30463070
WALK_NESTED_ENUM(OmpBindClause, Binding) // OMP bind
30473071
WALK_NESTED_ENUM(OmpProcBindClause, AffinityPolicy) // OMP proc_bind
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -fopenmp-version=51 -o - %s 2>&1 | FileCheck %s
2+
3+
! CHECK: not yet implemented: OpenMPDeclareVariantDirective
4+
5+
subroutine sb1
6+
integer :: x
7+
x = 1
8+
call sub(x)
9+
contains
10+
subroutine vsub (v1)
11+
integer, value :: v1
12+
end
13+
subroutine sub (v1)
14+
!$omp declare variant(vsub), match(construct={dispatch})
15+
integer, value :: v1
16+
end
17+
end subroutine
+104Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
! RUN: %flang_fc1 -fdebug-unparse-no-sema -fopenmp %s | FileCheck --ignore-case %s
2+
! RUN: %flang_fc1 -fdebug-dump-parse-tree-no-sema -fopenmp %s | FileCheck --check-prefix="PARSE-TREE" %s
3+
4+
subroutine sub0
5+
!CHECK: !$OMP DECLARE VARIANT (sub:vsub) MATCH(CONSTRUCT={PARALLEL})
6+
!PARSE-TREE: OpenMPDeclarativeConstruct -> OmpDeclareVariantDirective
7+
!PARSE-TREE: | Verbatim
8+
!PARSE-TREE: | Name = 'sub'
9+
!PARSE-TREE: | Name = 'vsub'
10+
!PARSE-TREE: | OmpClauseList -> OmpClause -> Match -> OmpMatchClause -> OmpContextSelectorSpecification -> OmpTraitSetSelector
11+
!PARSE-TREE: | | OmpTraitSetSelectorName -> Value = Construct
12+
!PARSE-TREE: | | OmpTraitSelector
13+
!PARSE-TREE: | | | OmpTraitSelectorName -> llvm::omp::Directive = parallel
14+
!$omp declare variant (sub:vsub) match (construct={parallel})
15+
contains
16+
subroutine vsub
17+
end subroutine
18+
19+
subroutine sub ()
20+
end subroutine
21+
end subroutine
22+
23+
subroutine sb1
24+
integer :: x
25+
x = 1
26+
!$omp dispatch device(1)
27+
call sub(x)
28+
contains
29+
subroutine vsub (v1)
30+
integer, value :: v1
31+
end
32+
subroutine sub (v1)
33+
!CHECK: !$OMP DECLARE VARIANT (vsub) MATCH(CONSTRUCT={DISPATCH}
34+
!PARSE-TREE: OpenMPDeclarativeConstruct -> OmpDeclareVariantDirective
35+
!PARSE-TREE: | Verbatim
36+
!PARSE-TREE: | Name = 'vsub'
37+
!PARSE-TREE: | OmpClauseList -> OmpClause -> Match -> OmpMatchClause -> OmpContextSelectorSpecification -> OmpTraitSetSelector
38+
!PARSE-TREE: | | OmpTraitSetSelectorName -> Value = Construct
39+
!PARSE-TREE: | | OmpTraitSelector
40+
!PARSE-TREE: | | | OmpTraitSelectorName -> llvm::omp::Directive = dispatch
41+
!$omp declare variant(vsub), match(construct={dispatch})
42+
integer, value :: v1
43+
end
44+
end subroutine
45+
46+
subroutine sb2 (x1, x2)
47+
use omp_lib, only: omp_interop_kind
48+
integer :: x
49+
x = 1
50+
!$omp dispatch device(1)
51+
call sub(x)
52+
contains
53+
subroutine vsub (v1, a1, a2)
54+
integer, value :: v1
55+
integer(omp_interop_kind) :: a1
56+
integer(omp_interop_kind), value :: a2
57+
end
58+
subroutine sub (v1)
59+
!CHECK: !$OMP DECLARE VARIANT (vsub) MATCH(CONSTRUCT={DISPATCH}) APPEND_ARGS(INTEROP(T&
60+
!CHECK: !$OMP&ARGET),INTEROP(TARGET))
61+
!PARSE-TREE: OpenMPDeclarativeConstruct -> OmpDeclareVariantDirective
62+
!PARSE-TREE: | Verbatim
63+
!PARSE-TREE: | Name = 'vsub'
64+
!PARSE-TREE: | OmpClauseList -> OmpClause -> Match -> OmpMatchClause -> OmpContextSelectorSpecification -> OmpTraitSetSelector
65+
!PARSE-TREE: | | OmpTraitSetSelectorName -> Value = Construct
66+
!PARSE-TREE: | | OmpTraitSelector
67+
!PARSE-TREE: | | | OmpTraitSelectorName -> llvm::omp::Directive = dispatch
68+
!PARSE-TREE: | OmpClause -> AppendArgs -> OmpAppendArgsClause -> OmpAppendOp -> OmpInteropType -> Value = Target
69+
!PARSE-TREE: | OmpAppendOp -> OmpInteropType -> Value = Target
70+
!$omp declare variant(vsub), match(construct={dispatch}), append_args (interop(target), interop(target))
71+
integer, value :: v1
72+
end
73+
end subroutine
74+
75+
subroutine sb3 (x1, x2)
76+
use iso_c_binding, only: c_ptr
77+
type(c_ptr), value :: x1, x2
78+
79+
!$omp dispatch device(1)
80+
call sub(x1, x2)
81+
contains
82+
subroutine sub (v1, v2)
83+
type(c_ptr), value :: v1, v2
84+
!CHECK: !$OMP DECLARE VARIANT (vsub) MATCH(CONSTRUCT={DISPATCH}) ADJUST_ARGS(NOTHING:v&
85+
!CHECK: !$OMP&1) ADJUST_ARGS(NEED_DEVICE_PTR:v2)
86+
!PARSE-TREE: DeclarationConstruct -> SpecificationConstruct -> OpenMPDeclarativeConstruct -> OmpDeclareVariantDirective
87+
!PARSE-TREE: | Verbatim
88+
!PARSE-TREE: | Name = 'vsub'
89+
!PARSE-TREE: | OmpClauseList -> OmpClause -> Match -> OmpMatchClause -> OmpContextSelectorSpecification -> OmpTraitSetSelector
90+
!PARSE-TREE: | | OmpTraitSetSelectorName -> Value = Construct
91+
!PARSE-TREE: | | OmpTraitSelector
92+
!PARSE-TREE: | | | OmpTraitSelectorName -> llvm::omp::Directive = dispatch
93+
!PARSE-TREE: | OmpClause -> AdjustArgs -> OmpAdjustArgsClause
94+
!PARSE-TREE: | | OmpAdjustOp -> Value = Nothing
95+
!PARSE-TREE: | | OmpObjectList -> OmpObject -> Designator -> DataRef -> Name = 'v1'
96+
!PARSE-TREE: | OmpClause -> AdjustArgs -> OmpAdjustArgsClause
97+
!PARSE-TREE: | | OmpAdjustOp -> Value = Need_Device_Ptr
98+
!PARSE-TREE: | | OmpObjectList -> OmpObject -> Designator -> DataRef -> Name = 'v2'
99+
!$omp declare variant(vsub) match ( construct = { dispatch } ) adjust_args(nothing : v1 ) adjust_args(need_device_ptr : v2)
100+
end
101+
subroutine vsub(v1, v2)
102+
type(c_ptr), value :: v1, v2
103+
end
104+
end subroutine
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
! RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=51
2+
3+
subroutine sub0
4+
!ERROR: Implicit subroutine declaration 'vsub1' in !$OMP DECLARE VARIANT
5+
!$omp declare variant (sub:vsub1) match (construct={parallel})
6+
!ERROR: Implicit subroutine declaration 'sub1' in !$OMP DECLARE VARIANT
7+
!$omp declare variant (sub1:vsub) match (construct={parallel})
8+
contains
9+
subroutine vsub
10+
end subroutine
11+
12+
subroutine sub ()
13+
end subroutine
14+
end subroutine

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.