mirror of
https://github.com/intel/llvm.git
synced 2026-01-13 11:02:04 +08:00
[flang][OpenMP] Rename some AST classes to follow spec naming, NFC (#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.
This commit is contained in:
committed by
GitHub
parent
2bb4226c7c
commit
b2c8b07f79
@@ -451,6 +451,7 @@ public:
|
||||
READ_FEATURE(OmpBlockConstruct)
|
||||
READ_FEATURE(OmpClause)
|
||||
READ_FEATURE(OmpClauseList)
|
||||
READ_FEATURE(OmpCombinerExpression)
|
||||
READ_FEATURE(OmpDefaultClause)
|
||||
READ_FEATURE(OmpDefaultClause::DataSharingAttribute)
|
||||
READ_FEATURE(OmpDefaultmapClause)
|
||||
@@ -496,7 +497,6 @@ public:
|
||||
READ_FEATURE(OmpProcBindClause::AffinityPolicy)
|
||||
READ_FEATURE(OmpReductionClause)
|
||||
READ_FEATURE(OmpInReductionClause)
|
||||
READ_FEATURE(OmpReductionCombiner)
|
||||
READ_FEATURE(OmpInitializerClause)
|
||||
READ_FEATURE(OmpReductionIdentifier)
|
||||
READ_FEATURE(OmpAllocateClause)
|
||||
|
||||
@@ -538,6 +538,7 @@ public:
|
||||
NODE(parser, OmpClauseList)
|
||||
NODE(parser, OmpCloseModifier)
|
||||
NODE_ENUM(OmpCloseModifier, Value)
|
||||
NODE(parser, OmpCombinerExpression)
|
||||
NODE(parser, OmpContainsClause)
|
||||
NODE(parser, OmpContextSelectorSpecification)
|
||||
NODE(parser, OmpDeclareVariantDirective)
|
||||
@@ -655,7 +656,6 @@ public:
|
||||
NODE_ENUM(OmpProcBindClause, AffinityPolicy)
|
||||
NODE(parser, OmpReductionClause)
|
||||
NODE(OmpReductionClause, Modifier)
|
||||
NODE(parser, OmpReductionCombiner)
|
||||
NODE(parser, OmpReductionIdentifier)
|
||||
NODE(parser, OmpReductionModifier)
|
||||
NODE_ENUM(OmpReductionModifier, Value)
|
||||
@@ -693,8 +693,8 @@ public:
|
||||
NODE(parser, OmpTraitSetSelectorName)
|
||||
NODE_ENUM(OmpTraitSetSelectorName, Value)
|
||||
NODE(parser, OmpTransparentClause)
|
||||
NODE(parser, OmpTypeName)
|
||||
NODE(parser, OmpTypeNameList)
|
||||
NODE(parser, OmpTypeSpecifier)
|
||||
NODE(parser, OmpUnifiedAddressClause)
|
||||
NODE(parser, OmpUnifiedSharedMemoryClause)
|
||||
NODE(parser, OmpUpdateClause)
|
||||
|
||||
@@ -3502,6 +3502,16 @@ struct OmpDirectiveName {
|
||||
llvm::omp::Directive v{llvm::omp::Directive::OMPD_unknown};
|
||||
};
|
||||
|
||||
// type-name list item
|
||||
struct OmpTypeName {
|
||||
UNION_CLASS_BOILERPLATE(OmpTypeName);
|
||||
std::variant<TypeSpec, DeclarationTypeSpec> u;
|
||||
};
|
||||
|
||||
struct OmpTypeNameList {
|
||||
WRAPPER_CLASS_BOILERPLATE(OmpTypeNameList, std::list<OmpTypeName>);
|
||||
};
|
||||
|
||||
// 2.1 Directives or clauses may accept a list or extended-list.
|
||||
// A list item is a variable, array section or common block name (enclosed
|
||||
// in slashes). An extended list item is a list item or a procedure Name.
|
||||
@@ -3539,21 +3549,12 @@ struct OmpReductionIdentifier {
|
||||
// combiner-expression -> // since 4.5
|
||||
// assignment-statement |
|
||||
// function-reference
|
||||
struct OmpReductionCombiner {
|
||||
UNION_CLASS_BOILERPLATE(OmpReductionCombiner);
|
||||
struct OmpCombinerExpression {
|
||||
UNION_CLASS_BOILERPLATE(OmpCombinerExpression);
|
||||
std::variant<AssignmentStmt, FunctionReference> u;
|
||||
};
|
||||
|
||||
inline namespace arguments {
|
||||
struct OmpTypeSpecifier {
|
||||
UNION_CLASS_BOILERPLATE(OmpTypeSpecifier);
|
||||
std::variant<TypeSpec, DeclarationTypeSpec> u;
|
||||
};
|
||||
|
||||
struct OmpTypeNameList {
|
||||
WRAPPER_CLASS_BOILERPLATE(OmpTypeNameList, std::list<OmpTypeSpecifier>);
|
||||
};
|
||||
|
||||
struct OmpLocator {
|
||||
UNION_CLASS_BOILERPLATE(OmpLocator);
|
||||
std::variant<OmpObject, FunctionReference> u;
|
||||
@@ -3596,7 +3597,7 @@ struct OmpMapperSpecifier {
|
||||
struct OmpReductionSpecifier {
|
||||
TUPLE_CLASS_BOILERPLATE(OmpReductionSpecifier);
|
||||
std::tuple<OmpReductionIdentifier, OmpTypeNameList,
|
||||
std::optional<OmpReductionCombiner>>
|
||||
std::optional<OmpCombinerExpression>>
|
||||
t;
|
||||
};
|
||||
|
||||
|
||||
@@ -367,8 +367,8 @@ struct OmpArgumentListParser {
|
||||
};
|
||||
|
||||
TYPE_PARSER( //
|
||||
construct<OmpTypeSpecifier>(Parser<DeclarationTypeSpec>{}) ||
|
||||
construct<OmpTypeSpecifier>(Parser<TypeSpec>{}))
|
||||
construct<OmpTypeName>(Parser<DeclarationTypeSpec>{}) ||
|
||||
construct<OmpTypeName>(Parser<TypeSpec>{}))
|
||||
|
||||
// 2.15.3.6 REDUCTION (reduction-identifier: variable-name-list)
|
||||
TYPE_PARSER(construct<OmpReductionIdentifier>(Parser<DefinedOperator>{}) ||
|
||||
@@ -376,8 +376,8 @@ TYPE_PARSER(construct<OmpReductionIdentifier>(Parser<DefinedOperator>{}) ||
|
||||
|
||||
TYPE_PARSER(construct<OmpReductionSpecifier>( //
|
||||
Parser<OmpReductionIdentifier>{},
|
||||
":"_tok >> nonemptyList(Parser<OmpTypeSpecifier>{}),
|
||||
maybe(":"_tok >> Parser<OmpReductionCombiner>{})))
|
||||
":"_tok >> nonemptyList(Parser<OmpTypeName>{}),
|
||||
maybe(":"_tok >> Parser<OmpCombinerExpression>{})))
|
||||
|
||||
// --- Parsers for context traits -------------------------------------
|
||||
|
||||
@@ -1832,8 +1832,8 @@ TYPE_PARSER(sourced(construct<OpenMPDeclareMapperConstruct>(
|
||||
IsDirective(llvm::omp::Directive::OMPD_declare_mapper)) >=
|
||||
Parser<OmpDirectiveSpecification>{})))
|
||||
|
||||
TYPE_PARSER(construct<OmpReductionCombiner>(Parser<AssignmentStmt>{}) ||
|
||||
construct<OmpReductionCombiner>(Parser<FunctionReference>{}))
|
||||
TYPE_PARSER(construct<OmpCombinerExpression>(Parser<AssignmentStmt>{}) ||
|
||||
construct<OmpCombinerExpression>(Parser<FunctionReference>{}))
|
||||
|
||||
TYPE_PARSER(sourced(construct<OpenMPCriticalConstruct>(
|
||||
OmpBlockConstructParser{llvm::omp::Directive::OMPD_critical})))
|
||||
|
||||
@@ -2111,7 +2111,7 @@ public:
|
||||
Walk(std::get<OmpReductionIdentifier>(x.t));
|
||||
Put(":");
|
||||
Walk(std::get<OmpTypeNameList>(x.t));
|
||||
Walk(": ", std::get<std::optional<OmpReductionCombiner>>(x.t));
|
||||
Walk(": ", std::get<std::optional<OmpCombinerExpression>>(x.t));
|
||||
}
|
||||
void Unparse(const llvm::omp::Directive &x) {
|
||||
unsigned ompVersion{langOpts_.OpenMPVersion};
|
||||
@@ -2519,7 +2519,7 @@ public:
|
||||
Walk(x.u);
|
||||
}
|
||||
}
|
||||
void Unparse(const OmpReductionCombiner &x) {
|
||||
void Unparse(const OmpCombinerExpression &x) {
|
||||
// Don't let the visitor go to the normal AssignmentStmt Unparse function,
|
||||
// it adds an extra newline that we don't want.
|
||||
if (const auto *assignment{std::get_if<AssignmentStmt>(&x.u)}) {
|
||||
|
||||
@@ -1772,11 +1772,11 @@ public:
|
||||
messageHandler().set_currStmtSource(std::nullopt);
|
||||
}
|
||||
|
||||
bool Pre(const parser::OmpTypeSpecifier &x) {
|
||||
bool Pre(const parser::OmpTypeName &x) {
|
||||
BeginDeclTypeSpec();
|
||||
return true;
|
||||
}
|
||||
void Post(const parser::OmpTypeSpecifier &x) { //
|
||||
void Post(const parser::OmpTypeName &x) { //
|
||||
EndDeclTypeSpec();
|
||||
}
|
||||
|
||||
@@ -2007,7 +2007,7 @@ void OmpVisitor::ProcessReductionSpecifier(
|
||||
}
|
||||
}
|
||||
EndDeclTypeSpec();
|
||||
Walk(std::get<std::optional<parser::OmpReductionCombiner>>(spec.t));
|
||||
Walk(std::get<std::optional<parser::OmpCombinerExpression>>(spec.t));
|
||||
Walk(clauses);
|
||||
PopScope();
|
||||
}
|
||||
|
||||
@@ -32,9 +32,9 @@ program omp_examples
|
||||
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = declare reduction
|
||||
!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpReductionSpecifier
|
||||
!PARSE-TREE: | | OmpReductionIdentifier -> DefinedOperator -> IntrinsicOperator = Add
|
||||
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeSpecifier -> TypeSpec -> DerivedTypeSpec
|
||||
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeName -> TypeSpec -> DerivedTypeSpec
|
||||
!PARSE-TREE: | | | Name = 'tt'
|
||||
!PARSE-TREE: | | OmpReductionCombiner -> AssignmentStmt = 'omp_out%r=omp_out%r+omp_in%r'
|
||||
!PARSE-TREE: | | OmpCombinerExpression -> AssignmentStmt = 'omp_out%r=omp_out%r+omp_in%r'
|
||||
!PARSE-TREE: | OmpClauseList -> OmpClause -> Initializer -> OmpInitializerClause -> AssignmentStmt = 'omp_priv%r=0._4'
|
||||
|
||||
!$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
|
||||
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = declare reduction
|
||||
!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpReductionSpecifier
|
||||
!PARSE-TREE: | | OmpReductionIdentifier -> DefinedOperator -> IntrinsicOperator = Multiply
|
||||
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeSpecifier -> TypeSpec -> DerivedTypeSpec
|
||||
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeName -> TypeSpec -> DerivedTypeSpec
|
||||
!PARSE-TREE: | | | Name = 'tt'
|
||||
!PARSE-TREE: | | OmpReductionCombiner -> AssignmentStmt = 'omp_out%r=omp_out%r*omp_in%r'
|
||||
!PARSE-TREE: | | OmpCombinerExpression -> AssignmentStmt = 'omp_out%r=omp_out%r*omp_in%r'
|
||||
!PARSE-TREE: | OmpClauseList -> OmpClause -> Initializer -> OmpInitializerClause -> AssignmentStmt = 'omp_priv%r=1._4'
|
||||
|
||||
!$omp declare reduction(max:tt:omp_out = mymax(omp_out, omp_in)) initializer(omp_priv%r = 0)
|
||||
@@ -56,9 +56,9 @@ program omp_examples
|
||||
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = declare reduction
|
||||
!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpReductionSpecifier
|
||||
!PARSE-TREE: | | OmpReductionIdentifier -> ProcedureDesignator -> Name = 'max'
|
||||
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeSpecifier -> TypeSpec -> DerivedTypeSpec
|
||||
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeName -> TypeSpec -> DerivedTypeSpec
|
||||
!PARSE-TREE: | | | Name = 'tt'
|
||||
!PARSE-TREE: | | OmpReductionCombiner -> AssignmentStmt = 'omp_out=mymax(omp_out,omp_in)'
|
||||
!PARSE-TREE: | | OmpCombinerExpression -> AssignmentStmt = 'omp_out=mymax(omp_out,omp_in)'
|
||||
!PARSE-TREE: | OmpClauseList -> OmpClause -> Initializer -> OmpInitializerClause -> AssignmentStmt = 'omp_priv%r=0._4'
|
||||
|
||||
!$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
|
||||
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = declare reduction
|
||||
!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpReductionSpecifier
|
||||
!PARSE-TREE: | | OmpReductionIdentifier -> ProcedureDesignator -> Name = 'min'
|
||||
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeSpecifier -> TypeSpec -> DerivedTypeSpec
|
||||
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeName -> TypeSpec -> DerivedTypeSpec
|
||||
!PARSE-TREE: | | | Name = 'tt'
|
||||
!PARSE-TREE: | | OmpReductionCombiner -> AssignmentStmt = 'omp_out%r=min(omp_out%r,omp_in%r)'
|
||||
!PARSE-TREE: | | OmpCombinerExpression -> AssignmentStmt = 'omp_out%r=min(omp_out%r,omp_in%r)'
|
||||
!PARSE-TREE: | OmpClauseList -> OmpClause -> Initializer -> OmpInitializerClause -> AssignmentStmt = 'omp_priv%r=1._4'
|
||||
|
||||
call random_number(values%r)
|
||||
|
||||
@@ -22,9 +22,9 @@ subroutine reduce_1 ( n, tts )
|
||||
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = declare reduction
|
||||
!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpReductionSpecifier
|
||||
!PARSE-TREE: | | OmpReductionIdentifier -> DefinedOperator -> IntrinsicOperator = Add
|
||||
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeSpecifier -> TypeSpec -> DerivedTypeSpec
|
||||
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeName -> TypeSpec -> DerivedTypeSpec
|
||||
!PARSE-TREE: | | | Name = 'tt'
|
||||
!PARSE-TREE: | | OmpReductionCombiner -> AssignmentStmt = 'omp_out=tt(x=omp_out%x-omp_in%x,y=omp_out%y-omp_in%y)'
|
||||
!PARSE-TREE: | | OmpCombinerExpression -> AssignmentStmt = 'omp_out=tt(x=omp_out%x-omp_in%x,y=omp_out%y-omp_in%y)'
|
||||
!PARSE-TREE: | OmpClauseList -> OmpClause -> Initializer -> OmpInitializerClause -> AssignmentStmt = 'omp_priv=tt(x=0_4,y=0_4)'
|
||||
|
||||
!$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 )
|
||||
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = declare reduction
|
||||
!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpReductionSpecifier
|
||||
!PARSE-TREE: | | OmpReductionIdentifier -> DefinedOperator -> IntrinsicOperator = Add
|
||||
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeSpecifier -> TypeSpec -> DerivedTypeSpec
|
||||
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeName -> TypeSpec -> DerivedTypeSpec
|
||||
!PARSE-TREE: | | | Name = 'tt2'
|
||||
!PARSE-TREE: | | OmpReductionCombiner -> AssignmentStmt = 'omp_out=tt2(x=omp_out%x-omp_in%x,y=omp_out%y-omp_in%y)'
|
||||
!PARSE-TREE: | | OmpCombinerExpression -> AssignmentStmt = 'omp_out=tt2(x=omp_out%x-omp_in%x,y=omp_out%y-omp_in%y)'
|
||||
!PARSE-TREE: | OmpClauseList -> OmpClause -> Initializer -> OmpInitializerClause -> AssignmentStmt = 'omp_priv=tt2(x=0._8,y=0._8)'
|
||||
|
||||
!$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))
|
||||
|
||||
@@ -25,9 +25,9 @@ function func(x, n, init)
|
||||
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = declare reduction
|
||||
!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpReductionSpecifier
|
||||
!PARSE-TREE: | | OmpReductionIdentifier -> ProcedureDesignator -> Name = 'red_add'
|
||||
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeSpecifier -> DeclarationTypeSpec -> IntrinsicTypeSpec -> IntegerTypeSpec -> KindSelector -> Scalar -> Integer -> Constant -> Expr = '4_4'
|
||||
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeName -> DeclarationTypeSpec -> IntrinsicTypeSpec -> IntegerTypeSpec -> KindSelector -> Scalar -> Integer -> Constant -> Expr = '4_4'
|
||||
!PARSE-TREE: | | | LiteralConstant -> IntLiteralConstant = '4'
|
||||
!PARSE-TREE: | | OmpReductionCombiner -> AssignmentStmt = 'omp_out=omp_out+omp_in'
|
||||
!PARSE-TREE: | | OmpCombinerExpression -> AssignmentStmt = 'omp_out=omp_out+omp_in'
|
||||
!PARSE-TREE: | OmpClauseList -> OmpClause -> Initializer -> OmpInitializerClause -> OmpInitializerProc
|
||||
!PARSE-TREE: | | ProcedureDesignator -> Name = 'initme'
|
||||
|
||||
@@ -73,6 +73,6 @@ end program main
|
||||
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = declare reduction
|
||||
!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpReductionSpecifier
|
||||
!PARSE-TREE: | | OmpReductionIdentifier -> ProcedureDesignator -> Name = 'my_add_red'
|
||||
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeSpecifier -> DeclarationTypeSpec -> IntrinsicTypeSpec -> IntegerTypeSpec ->
|
||||
!PARSE-TREE: | | OmpReductionCombiner -> AssignmentStmt = 'omp_out=omp_out+omp_in'
|
||||
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeName -> DeclarationTypeSpec -> IntrinsicTypeSpec -> IntegerTypeSpec ->
|
||||
!PARSE-TREE: | | OmpCombinerExpression -> AssignmentStmt = 'omp_out=omp_out+omp_in'
|
||||
!PARSE-TREE: | OmpClauseList -> OmpClause -> Initializer -> OmpInitializerClause -> AssignmentStmt = 'omp_priv=0_4'
|
||||
|
||||
@@ -123,11 +123,11 @@ end
|
||||
!PARSE-TREE: | | | OmpDirectiveName -> llvm::omp::Directive = declare reduction
|
||||
!PARSE-TREE: | | | OmpArgumentList -> OmpArgument -> OmpReductionSpecifier
|
||||
!PARSE-TREE: | | | | OmpReductionIdentifier -> DefinedOperator -> IntrinsicOperator = Add
|
||||
!PARSE-TREE: | | | | OmpTypeNameList -> OmpTypeSpecifier -> TypeSpec -> DerivedTypeSpec
|
||||
!PARSE-TREE: | | | | OmpTypeNameList -> OmpTypeName -> TypeSpec -> DerivedTypeSpec
|
||||
!PARSE-TREE: | | | | | Name = 'tt1'
|
||||
!PARSE-TREE: | | | | OmpTypeSpecifier -> TypeSpec -> DerivedTypeSpec
|
||||
!PARSE-TREE: | | | | OmpTypeName -> TypeSpec -> DerivedTypeSpec
|
||||
!PARSE-TREE: | | | | | Name = 'tt2'
|
||||
!PARSE-TREE: | | | | OmpReductionCombiner -> AssignmentStmt = 'omp_out%x=omp_in%x+omp_out%x'
|
||||
!PARSE-TREE: | | | | OmpCombinerExpression -> AssignmentStmt = 'omp_out%x=omp_in%x+omp_out%x'
|
||||
!PARSE-TREE: | | | | | | Designator -> DataRef -> StructureComponent
|
||||
!PARSE-TREE: | | | | | | | DataRef -> Name = 'omp_out'
|
||||
!PARSE-TREE: | | | | | | | Name = 'x'
|
||||
|
||||
@@ -86,9 +86,9 @@ end
|
||||
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = declare reduction
|
||||
!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpReductionSpecifier
|
||||
!PARSE-TREE: | | OmpReductionIdentifier -> DefinedOperator -> IntrinsicOperator = Add
|
||||
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeSpecifier -> TypeSpec -> DerivedTypeSpec
|
||||
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeName -> TypeSpec -> DerivedTypeSpec
|
||||
!PARSE-TREE: | | | Name = 't'
|
||||
!PARSE-TREE: | | OmpReductionCombiner -> AssignmentStmt = 'omp_out%x=omp_out%x+omp_in%x'
|
||||
!PARSE-TREE: | | OmpCombinerExpression -> AssignmentStmt = 'omp_out%x=omp_out%x+omp_in%x'
|
||||
!PARSE-TREE: | | | Variable = 'omp_out%x'
|
||||
!PARSE-TREE: | | | | Designator -> DataRef -> StructureComponent
|
||||
!PARSE-TREE: | | | | | DataRef -> Name = 'omp_out'
|
||||
|
||||
Reference in New Issue
Block a user