Skip to content

Commit b2c8b07

Browse files
authored
[flang][OpenMP] Rename some AST classes to follow spec naming, NFC (llvm#164870)
Rename OmpTypeSpecifier to OmpTypeName, since it represents a type-name list item. Also, OpenMP 6.0 introduced type-specifier with a different meaning. Rename OmpReductionCombiner to OmpCombinerExpression.
1 parent 2bb4226 commit b2c8b07

File tree

11 files changed

+48
-47
lines changed

11 files changed

+48
-47
lines changed

flang/examples/FeatureList/FeatureList.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ struct NodeVisitor {
451451
READ_FEATURE(OmpBlockConstruct)
452452
READ_FEATURE(OmpClause)
453453
READ_FEATURE(OmpClauseList)
454+
READ_FEATURE(OmpCombinerExpression)
454455
READ_FEATURE(OmpDefaultClause)
455456
READ_FEATURE(OmpDefaultClause::DataSharingAttribute)
456457
READ_FEATURE(OmpDefaultmapClause)
@@ -496,7 +497,6 @@ struct NodeVisitor {
496497
READ_FEATURE(OmpProcBindClause::AffinityPolicy)
497498
READ_FEATURE(OmpReductionClause)
498499
READ_FEATURE(OmpInReductionClause)
499-
READ_FEATURE(OmpReductionCombiner)
500500
READ_FEATURE(OmpInitializerClause)
501501
READ_FEATURE(OmpReductionIdentifier)
502502
READ_FEATURE(OmpAllocateClause)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ class ParseTreeDumper {
538538
NODE(parser, OmpClauseList)
539539
NODE(parser, OmpCloseModifier)
540540
NODE_ENUM(OmpCloseModifier, Value)
541+
NODE(parser, OmpCombinerExpression)
541542
NODE(parser, OmpContainsClause)
542543
NODE(parser, OmpContextSelectorSpecification)
543544
NODE(parser, OmpDeclareVariantDirective)
@@ -655,7 +656,6 @@ class ParseTreeDumper {
655656
NODE_ENUM(OmpProcBindClause, AffinityPolicy)
656657
NODE(parser, OmpReductionClause)
657658
NODE(OmpReductionClause, Modifier)
658-
NODE(parser, OmpReductionCombiner)
659659
NODE(parser, OmpReductionIdentifier)
660660
NODE(parser, OmpReductionModifier)
661661
NODE_ENUM(OmpReductionModifier, Value)
@@ -693,8 +693,8 @@ class ParseTreeDumper {
693693
NODE(parser, OmpTraitSetSelectorName)
694694
NODE_ENUM(OmpTraitSetSelectorName, Value)
695695
NODE(parser, OmpTransparentClause)
696+
NODE(parser, OmpTypeName)
696697
NODE(parser, OmpTypeNameList)
697-
NODE(parser, OmpTypeSpecifier)
698698
NODE(parser, OmpUnifiedAddressClause)
699699
NODE(parser, OmpUnifiedSharedMemoryClause)
700700
NODE(parser, OmpUpdateClause)

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

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3502,6 +3502,16 @@ struct OmpDirectiveName {
35023502
llvm::omp::Directive v{llvm::omp::Directive::OMPD_unknown};
35033503
};
35043504

3505+
// type-name list item
3506+
struct OmpTypeName {
3507+
UNION_CLASS_BOILERPLATE(OmpTypeName);
3508+
std::variant<TypeSpec, DeclarationTypeSpec> u;
3509+
};
3510+
3511+
struct OmpTypeNameList {
3512+
WRAPPER_CLASS_BOILERPLATE(OmpTypeNameList, std::list<OmpTypeName>);
3513+
};
3514+
35053515
// 2.1 Directives or clauses may accept a list or extended-list.
35063516
// A list item is a variable, array section or common block name (enclosed
35073517
// in slashes). An extended list item is a list item or a procedure Name.
@@ -3539,21 +3549,12 @@ struct OmpReductionIdentifier {
35393549
// combiner-expression -> // since 4.5
35403550
// assignment-statement |
35413551
// function-reference
3542-
struct OmpReductionCombiner {
3543-
UNION_CLASS_BOILERPLATE(OmpReductionCombiner);
3552+
struct OmpCombinerExpression {
3553+
UNION_CLASS_BOILERPLATE(OmpCombinerExpression);
35443554
std::variant<AssignmentStmt, FunctionReference> u;
35453555
};
35463556

35473557
inline namespace arguments {
3548-
struct OmpTypeSpecifier {
3549-
UNION_CLASS_BOILERPLATE(OmpTypeSpecifier);
3550-
std::variant<TypeSpec, DeclarationTypeSpec> u;
3551-
};
3552-
3553-
struct OmpTypeNameList {
3554-
WRAPPER_CLASS_BOILERPLATE(OmpTypeNameList, std::list<OmpTypeSpecifier>);
3555-
};
3556-
35573558
struct OmpLocator {
35583559
UNION_CLASS_BOILERPLATE(OmpLocator);
35593560
std::variant<OmpObject, FunctionReference> u;
@@ -3596,7 +3597,7 @@ struct OmpMapperSpecifier {
35963597
struct OmpReductionSpecifier {
35973598
TUPLE_CLASS_BOILERPLATE(OmpReductionSpecifier);
35983599
std::tuple<OmpReductionIdentifier, OmpTypeNameList,
3599-
std::optional<OmpReductionCombiner>>
3600+
std::optional<OmpCombinerExpression>>
36003601
t;
36013602
};
36023603

flang/lib/Parser/openmp-parsers.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -367,17 +367,17 @@ struct OmpArgumentListParser {
367367
};
368368

369369
TYPE_PARSER( //
370-
construct<OmpTypeSpecifier>(Parser<DeclarationTypeSpec>{}) ||
371-
construct<OmpTypeSpecifier>(Parser<TypeSpec>{}))
370+
construct<OmpTypeName>(Parser<DeclarationTypeSpec>{}) ||
371+
construct<OmpTypeName>(Parser<TypeSpec>{}))
372372

373373
// 2.15.3.6 REDUCTION (reduction-identifier: variable-name-list)
374374
TYPE_PARSER(construct<OmpReductionIdentifier>(Parser<DefinedOperator>{}) ||
375375
construct<OmpReductionIdentifier>(Parser<ProcedureDesignator>{}))
376376

377377
TYPE_PARSER(construct<OmpReductionSpecifier>( //
378378
Parser<OmpReductionIdentifier>{},
379-
":"_tok >> nonemptyList(Parser<OmpTypeSpecifier>{}),
380-
maybe(":"_tok >> Parser<OmpReductionCombiner>{})))
379+
":"_tok >> nonemptyList(Parser<OmpTypeName>{}),
380+
maybe(":"_tok >> Parser<OmpCombinerExpression>{})))
381381

382382
// --- Parsers for context traits -------------------------------------
383383

@@ -1832,8 +1832,8 @@ TYPE_PARSER(sourced(construct<OpenMPDeclareMapperConstruct>(
18321832
IsDirective(llvm::omp::Directive::OMPD_declare_mapper)) >=
18331833
Parser<OmpDirectiveSpecification>{})))
18341834

1835-
TYPE_PARSER(construct<OmpReductionCombiner>(Parser<AssignmentStmt>{}) ||
1836-
construct<OmpReductionCombiner>(Parser<FunctionReference>{}))
1835+
TYPE_PARSER(construct<OmpCombinerExpression>(Parser<AssignmentStmt>{}) ||
1836+
construct<OmpCombinerExpression>(Parser<FunctionReference>{}))
18371837

18381838
TYPE_PARSER(sourced(construct<OpenMPCriticalConstruct>(
18391839
OmpBlockConstructParser{llvm::omp::Directive::OMPD_critical})))

flang/lib/Parser/unparse.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2111,7 +2111,7 @@ class UnparseVisitor {
21112111
Walk(std::get<OmpReductionIdentifier>(x.t));
21122112
Put(":");
21132113
Walk(std::get<OmpTypeNameList>(x.t));
2114-
Walk(": ", std::get<std::optional<OmpReductionCombiner>>(x.t));
2114+
Walk(": ", std::get<std::optional<OmpCombinerExpression>>(x.t));
21152115
}
21162116
void Unparse(const llvm::omp::Directive &x) {
21172117
unsigned ompVersion{langOpts_.OpenMPVersion};
@@ -2519,7 +2519,7 @@ class UnparseVisitor {
25192519
Walk(x.u);
25202520
}
25212521
}
2522-
void Unparse(const OmpReductionCombiner &x) {
2522+
void Unparse(const OmpCombinerExpression &x) {
25232523
// Don't let the visitor go to the normal AssignmentStmt Unparse function,
25242524
// it adds an extra newline that we don't want.
25252525
if (const auto *assignment{std::get_if<AssignmentStmt>(&x.u)}) {

flang/lib/Semantics/resolve-names.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,11 +1772,11 @@ class OmpVisitor : public virtual DeclarationVisitor {
17721772
messageHandler().set_currStmtSource(std::nullopt);
17731773
}
17741774

1775-
bool Pre(const parser::OmpTypeSpecifier &x) {
1775+
bool Pre(const parser::OmpTypeName &x) {
17761776
BeginDeclTypeSpec();
17771777
return true;
17781778
}
1779-
void Post(const parser::OmpTypeSpecifier &x) { //
1779+
void Post(const parser::OmpTypeName &x) { //
17801780
EndDeclTypeSpec();
17811781
}
17821782

@@ -2007,7 +2007,7 @@ void OmpVisitor::ProcessReductionSpecifier(
20072007
}
20082008
}
20092009
EndDeclTypeSpec();
2010-
Walk(std::get<std::optional<parser::OmpReductionCombiner>>(spec.t));
2010+
Walk(std::get<std::optional<parser::OmpCombinerExpression>>(spec.t));
20112011
Walk(clauses);
20122012
PopScope();
20132013
}

flang/test/Parser/OpenMP/declare-reduction-multi.f90

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ program omp_examples
3232
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = declare reduction
3333
!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpReductionSpecifier
3434
!PARSE-TREE: | | OmpReductionIdentifier -> DefinedOperator -> IntrinsicOperator = Add
35-
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeSpecifier -> TypeSpec -> DerivedTypeSpec
35+
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeName -> TypeSpec -> DerivedTypeSpec
3636
!PARSE-TREE: | | | Name = 'tt'
37-
!PARSE-TREE: | | OmpReductionCombiner -> AssignmentStmt = 'omp_out%r=omp_out%r+omp_in%r'
37+
!PARSE-TREE: | | OmpCombinerExpression -> AssignmentStmt = 'omp_out%r=omp_out%r+omp_in%r'
3838
!PARSE-TREE: | OmpClauseList -> OmpClause -> Initializer -> OmpInitializerClause -> AssignmentStmt = 'omp_priv%r=0._4'
3939

4040
!$omp declare reduction(*:tt:omp_out%r = omp_out%r * omp_in%r) initializer(omp_priv%r = 1)
@@ -44,9 +44,9 @@ program omp_examples
4444
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = declare reduction
4545
!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpReductionSpecifier
4646
!PARSE-TREE: | | OmpReductionIdentifier -> DefinedOperator -> IntrinsicOperator = Multiply
47-
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeSpecifier -> TypeSpec -> DerivedTypeSpec
47+
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeName -> TypeSpec -> DerivedTypeSpec
4848
!PARSE-TREE: | | | Name = 'tt'
49-
!PARSE-TREE: | | OmpReductionCombiner -> AssignmentStmt = 'omp_out%r=omp_out%r*omp_in%r'
49+
!PARSE-TREE: | | OmpCombinerExpression -> AssignmentStmt = 'omp_out%r=omp_out%r*omp_in%r'
5050
!PARSE-TREE: | OmpClauseList -> OmpClause -> Initializer -> OmpInitializerClause -> AssignmentStmt = 'omp_priv%r=1._4'
5151

5252
!$omp declare reduction(max:tt:omp_out = mymax(omp_out, omp_in)) initializer(omp_priv%r = 0)
@@ -56,9 +56,9 @@ program omp_examples
5656
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = declare reduction
5757
!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpReductionSpecifier
5858
!PARSE-TREE: | | OmpReductionIdentifier -> ProcedureDesignator -> Name = 'max'
59-
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeSpecifier -> TypeSpec -> DerivedTypeSpec
59+
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeName -> TypeSpec -> DerivedTypeSpec
6060
!PARSE-TREE: | | | Name = 'tt'
61-
!PARSE-TREE: | | OmpReductionCombiner -> AssignmentStmt = 'omp_out=mymax(omp_out,omp_in)'
61+
!PARSE-TREE: | | OmpCombinerExpression -> AssignmentStmt = 'omp_out=mymax(omp_out,omp_in)'
6262
!PARSE-TREE: | OmpClauseList -> OmpClause -> Initializer -> OmpInitializerClause -> AssignmentStmt = 'omp_priv%r=0._4'
6363

6464
!$omp declare reduction(min:tt:omp_out%r = min(omp_out%r, omp_in%r)) initializer(omp_priv%r = 1)
@@ -68,9 +68,9 @@ program omp_examples
6868
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = declare reduction
6969
!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpReductionSpecifier
7070
!PARSE-TREE: | | OmpReductionIdentifier -> ProcedureDesignator -> Name = 'min'
71-
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeSpecifier -> TypeSpec -> DerivedTypeSpec
71+
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeName -> TypeSpec -> DerivedTypeSpec
7272
!PARSE-TREE: | | | Name = 'tt'
73-
!PARSE-TREE: | | OmpReductionCombiner -> AssignmentStmt = 'omp_out%r=min(omp_out%r,omp_in%r)'
73+
!PARSE-TREE: | | OmpCombinerExpression -> AssignmentStmt = 'omp_out%r=min(omp_out%r,omp_in%r)'
7474
!PARSE-TREE: | OmpClauseList -> OmpClause -> Initializer -> OmpInitializerClause -> AssignmentStmt = 'omp_priv%r=1._4'
7575

7676
call random_number(values%r)

flang/test/Parser/OpenMP/declare-reduction-operator.f90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ subroutine reduce_1 ( n, tts )
2222
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = declare reduction
2323
!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpReductionSpecifier
2424
!PARSE-TREE: | | OmpReductionIdentifier -> DefinedOperator -> IntrinsicOperator = Add
25-
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeSpecifier -> TypeSpec -> DerivedTypeSpec
25+
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeName -> TypeSpec -> DerivedTypeSpec
2626
!PARSE-TREE: | | | Name = 'tt'
27-
!PARSE-TREE: | | OmpReductionCombiner -> AssignmentStmt = 'omp_out=tt(x=omp_out%x-omp_in%x,y=omp_out%y-omp_in%y)'
27+
!PARSE-TREE: | | OmpCombinerExpression -> AssignmentStmt = 'omp_out=tt(x=omp_out%x-omp_in%x,y=omp_out%y-omp_in%y)'
2828
!PARSE-TREE: | OmpClauseList -> OmpClause -> Initializer -> OmpInitializerClause -> AssignmentStmt = 'omp_priv=tt(x=0_4,y=0_4)'
2929

3030
!$omp declare reduction(+ : tt : omp_out = tt(omp_out%x - omp_in%x , omp_out%y - omp_in%y)) initializer(omp_priv = tt(0,0))
@@ -36,9 +36,9 @@ subroutine reduce_1 ( n, tts )
3636
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = declare reduction
3737
!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpReductionSpecifier
3838
!PARSE-TREE: | | OmpReductionIdentifier -> DefinedOperator -> IntrinsicOperator = Add
39-
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeSpecifier -> TypeSpec -> DerivedTypeSpec
39+
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeName -> TypeSpec -> DerivedTypeSpec
4040
!PARSE-TREE: | | | Name = 'tt2'
41-
!PARSE-TREE: | | OmpReductionCombiner -> AssignmentStmt = 'omp_out=tt2(x=omp_out%x-omp_in%x,y=omp_out%y-omp_in%y)'
41+
!PARSE-TREE: | | OmpCombinerExpression -> AssignmentStmt = 'omp_out=tt2(x=omp_out%x-omp_in%x,y=omp_out%y-omp_in%y)'
4242
!PARSE-TREE: | OmpClauseList -> OmpClause -> Initializer -> OmpInitializerClause -> AssignmentStmt = 'omp_priv=tt2(x=0._8,y=0._8)'
4343

4444
!$omp declare reduction(+ :tt2 : omp_out = tt2(omp_out%x - omp_in%x , omp_out%y - omp_in%y)) initializer(omp_priv = tt2(0,0))

flang/test/Parser/OpenMP/declare-reduction-unparse.f90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ end subroutine initme
2525
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = declare reduction
2626
!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpReductionSpecifier
2727
!PARSE-TREE: | | OmpReductionIdentifier -> ProcedureDesignator -> Name = 'red_add'
28-
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeSpecifier -> DeclarationTypeSpec -> IntrinsicTypeSpec -> IntegerTypeSpec -> KindSelector -> Scalar -> Integer -> Constant -> Expr = '4_4'
28+
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeName -> DeclarationTypeSpec -> IntrinsicTypeSpec -> IntegerTypeSpec -> KindSelector -> Scalar -> Integer -> Constant -> Expr = '4_4'
2929
!PARSE-TREE: | | | LiteralConstant -> IntLiteralConstant = '4'
30-
!PARSE-TREE: | | OmpReductionCombiner -> AssignmentStmt = 'omp_out=omp_out+omp_in'
30+
!PARSE-TREE: | | OmpCombinerExpression -> AssignmentStmt = 'omp_out=omp_out+omp_in'
3131
!PARSE-TREE: | OmpClauseList -> OmpClause -> Initializer -> OmpInitializerClause -> OmpInitializerProc
3232
!PARSE-TREE: | | ProcedureDesignator -> Name = 'initme'
3333

@@ -73,6 +73,6 @@ end program main
7373
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = declare reduction
7474
!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpReductionSpecifier
7575
!PARSE-TREE: | | OmpReductionIdentifier -> ProcedureDesignator -> Name = 'my_add_red'
76-
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeSpecifier -> DeclarationTypeSpec -> IntrinsicTypeSpec -> IntegerTypeSpec ->
77-
!PARSE-TREE: | | OmpReductionCombiner -> AssignmentStmt = 'omp_out=omp_out+omp_in'
76+
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeName -> DeclarationTypeSpec -> IntrinsicTypeSpec -> IntegerTypeSpec ->
77+
!PARSE-TREE: | | OmpCombinerExpression -> AssignmentStmt = 'omp_out=omp_out+omp_in'
7878
!PARSE-TREE: | OmpClauseList -> OmpClause -> Initializer -> OmpInitializerClause -> AssignmentStmt = 'omp_priv=0_4'

flang/test/Parser/OpenMP/metadirective-dirspec.f90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ subroutine f03
123123
!PARSE-TREE: | | | OmpDirectiveName -> llvm::omp::Directive = declare reduction
124124
!PARSE-TREE: | | | OmpArgumentList -> OmpArgument -> OmpReductionSpecifier
125125
!PARSE-TREE: | | | | OmpReductionIdentifier -> DefinedOperator -> IntrinsicOperator = Add
126-
!PARSE-TREE: | | | | OmpTypeNameList -> OmpTypeSpecifier -> TypeSpec -> DerivedTypeSpec
126+
!PARSE-TREE: | | | | OmpTypeNameList -> OmpTypeName -> TypeSpec -> DerivedTypeSpec
127127
!PARSE-TREE: | | | | | Name = 'tt1'
128-
!PARSE-TREE: | | | | OmpTypeSpecifier -> TypeSpec -> DerivedTypeSpec
128+
!PARSE-TREE: | | | | OmpTypeName -> TypeSpec -> DerivedTypeSpec
129129
!PARSE-TREE: | | | | | Name = 'tt2'
130-
!PARSE-TREE: | | | | OmpReductionCombiner -> AssignmentStmt = 'omp_out%x=omp_in%x+omp_out%x'
130+
!PARSE-TREE: | | | | OmpCombinerExpression -> AssignmentStmt = 'omp_out%x=omp_in%x+omp_out%x'
131131
!PARSE-TREE: | | | | | | Designator -> DataRef -> StructureComponent
132132
!PARSE-TREE: | | | | | | | DataRef -> Name = 'omp_out'
133133
!PARSE-TREE: | | | | | | | Name = 'x'

0 commit comments

Comments
 (0)