Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 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
3 changes: 0 additions & 3 deletions flang/examples/FeatureList/FeatureList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,9 +451,6 @@ struct NodeVisitor {
READ_FEATURE(OmpBlockConstruct)
READ_FEATURE(OmpClause)
READ_FEATURE(OmpClauseList)
READ_FEATURE(OmpDeclareTargetSpecifier)
READ_FEATURE(OmpDeclareTargetWithClause)
READ_FEATURE(OmpDeclareTargetWithList)
READ_FEATURE(OmpDefaultClause)
READ_FEATURE(OmpDefaultClause::DataSharingAttribute)
READ_FEATURE(OmpDefaultmapClause)
Expand Down
3 changes: 0 additions & 3 deletions flang/include/flang/Parser/dump-parse-tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -538,9 +538,6 @@ class ParseTreeDumper {
NODE_ENUM(OmpCloseModifier, Value)
NODE(parser, OmpContainsClause)
NODE(parser, OmpContextSelectorSpecification)
NODE(parser, OmpDeclareTargetSpecifier)
NODE(parser, OmpDeclareTargetWithClause)
NODE(parser, OmpDeclareTargetWithList)
NODE(parser, OmpDeclareVariantDirective)
NODE(parser, OmpDefaultClause)
NODE_ENUM(OmpDefaultClause, DataSharingAttribute)
Expand Down
4 changes: 0 additions & 4 deletions flang/include/flang/Parser/openmp-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ struct ConstructId {
}

MAKE_CONSTR_ID(OpenMPDeclarativeAllocate, D::OMPD_allocate);
MAKE_CONSTR_ID(OpenMPDeclarativeAssumes, D::OMPD_assumes);
MAKE_CONSTR_ID(OpenMPDeclareReductionConstruct, D::OMPD_declare_reduction);
MAKE_CONSTR_ID(OpenMPDeclareTargetConstruct, D::OMPD_declare_target);
MAKE_CONSTR_ID(OpenMPExecutableAllocate, D::OMPD_allocate);
MAKE_CONSTR_ID(OpenMPRequiresConstruct, D::OMPD_requires);

Expand Down Expand Up @@ -95,9 +93,7 @@ struct DirectiveNameScope {
if constexpr (std::is_base_of_v<OmpBlockConstruct, T>) {
return std::get<OmpBeginDirective>(x.t).DirName();
} else if constexpr (std::is_same_v<T, OpenMPDeclarativeAllocate> ||
std::is_same_v<T, OpenMPDeclarativeAssumes> ||
std::is_same_v<T, OpenMPDeclareReductionConstruct> ||
std::is_same_v<T, OpenMPDeclareTargetConstruct> ||
std::is_same_v<T, OpenMPExecutableAllocate> ||
std::is_same_v<T, OpenMPRequiresConstruct>) {
return MakeName(std::get<Verbatim>(x.t).source, ConstructId<T>::id);
Expand Down
32 changes: 10 additions & 22 deletions flang/include/flang/Parser/parse-tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -4877,8 +4877,8 @@ struct OpenMPUtilityConstruct {
// ASSUMES absent-clause | contains-clause | holds-clause | no-openmp-clause |
// no-openmp-routines-clause | no-parallelism-clause
struct OpenMPDeclarativeAssumes {
TUPLE_CLASS_BOILERPLATE(OpenMPDeclarativeAssumes);
std::tuple<Verbatim, OmpClauseList> t;
WRAPPER_CLASS_BOILERPLATE(
OpenMPDeclarativeAssumes, OmpDirectiveSpecification);
CharBlock source;
};

Expand Down Expand Up @@ -4943,28 +4943,16 @@ struct OmpDeclareVariantDirective {
CharBlock source;
};

// 2.10.6 declare-target -> DECLARE TARGET (extended-list) |
// DECLARE TARGET [declare-target-clause[ [,]
// declare-target-clause]...]
struct OmpDeclareTargetWithList {
WRAPPER_CLASS_BOILERPLATE(OmpDeclareTargetWithList, OmpObjectList);
CharBlock source;
};

struct OmpDeclareTargetWithClause {
WRAPPER_CLASS_BOILERPLATE(OmpDeclareTargetWithClause, OmpClauseList);
CharBlock source;
};

struct OmpDeclareTargetSpecifier {
UNION_CLASS_BOILERPLATE(OmpDeclareTargetSpecifier);
std::variant<OmpDeclareTargetWithList, OmpDeclareTargetWithClause> u;
};

// Ref: [4.5:110-113], [5.0:180-185], [5.1:210-216], [5.2:206-207],
// [6.0:346-348]
//
// declare-target-directive -> // since 4.5
// DECLARE_TARGET[(extended-list)] |
// DECLARE_TARGET clause-list
struct OpenMPDeclareTargetConstruct {
TUPLE_CLASS_BOILERPLATE(OpenMPDeclareTargetConstruct);
WRAPPER_CLASS_BOILERPLATE(
OpenMPDeclareTargetConstruct, OmpDirectiveSpecification);
CharBlock source;
std::tuple<Verbatim, OmpDeclareTargetSpecifier> t;
};

// OMP v5.2: 5.8.8
Expand Down
14 changes: 6 additions & 8 deletions flang/lib/Lower/OpenMP/OpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -761,19 +761,17 @@ static void promoteNonCPtrUseDevicePtrArgsToUseDeviceAddr(
static void getDeclareTargetInfo(
lower::AbstractConverter &converter, semantics::SemanticsContext &semaCtx,
lower::pft::Evaluation &eval,
const parser::OpenMPDeclareTargetConstruct &declareTargetConstruct,
const parser::OpenMPDeclareTargetConstruct &construct,
mlir::omp::DeclareTargetOperands &clauseOps,
llvm::SmallVectorImpl<DeclareTargetCaptureInfo> &symbolAndClause) {
const auto &spec =
std::get<parser::OmpDeclareTargetSpecifier>(declareTargetConstruct.t);
if (const auto *objectList{parser::Unwrap<parser::OmpObjectList>(spec.u)}) {
ObjectList objects{makeObjects(*objectList, semaCtx)};

if (!construct.v.Arguments().v.empty()) {
ObjectList objects{makeObjects(construct.v.Arguments(), semaCtx)};
// Case: declare target(func, var1, var2)
gatherFuncAndVarSyms(objects, mlir::omp::DeclareTargetCaptureClause::to,
symbolAndClause, /*automap=*/false);
} else if (const auto *clauseList{
parser::Unwrap<parser::OmpClauseList>(spec.u)}) {
List<Clause> clauses = makeClauses(*clauseList, semaCtx);
} else {
List<Clause> clauses = makeClauses(construct.v.Clauses(), semaCtx);
if (clauses.empty()) {
Fortran::lower::pft::FunctionLikeUnit *owningProc =
eval.getOwningProcedure();
Expand Down
22 changes: 6 additions & 16 deletions flang/lib/Parser/openmp-parsers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1773,23 +1773,11 @@ TYPE_PARSER(sourced(construct<OpenMPDeclareReductionConstruct>(
IsDirective(llvm::omp::Directive::OMPD_declare_reduction)) >=
Parser<OmpDirectiveSpecification>{})))

// declare-target with list
TYPE_PARSER(sourced(construct<OmpDeclareTargetWithList>(
parenthesized(Parser<OmpObjectList>{}))))

// declare-target with clause
TYPE_PARSER(
sourced(construct<OmpDeclareTargetWithClause>(Parser<OmpClauseList>{})))

// declare-target-specifier
TYPE_PARSER(
construct<OmpDeclareTargetSpecifier>(Parser<OmpDeclareTargetWithList>{}) ||
construct<OmpDeclareTargetSpecifier>(Parser<OmpDeclareTargetWithClause>{}))

// 2.10.6 Declare Target Construct
TYPE_PARSER(sourced(construct<OpenMPDeclareTargetConstruct>(
verbatim("DECLARE TARGET"_tok) || verbatim("DECLARE_TARGET"_tok),
Parser<OmpDeclareTargetSpecifier>{})))
predicated(Parser<OmpDirectiveName>{},
IsDirective(llvm::omp::Directive::OMPD_declare_target)) >=
Parser<OmpDirectiveSpecification>{})))

static OmpMapperSpecifier ConstructOmpMapperSpecifier(
std::optional<Name> &&mapperName, TypeSpec &&typeSpec, Name &&varName) {
Expand Down Expand Up @@ -1865,7 +1853,9 @@ TYPE_PARSER(

// Assumes Construct
TYPE_PARSER(sourced(construct<OpenMPDeclarativeAssumes>(
verbatim("ASSUMES"_tok), Parser<OmpClauseList>{})))
predicated(OmpDirectiveNameParser{},
IsDirective(llvm::omp::Directive::OMPD_assumes)) >=
Parser<OmpDirectiveSpecification>{})))

// Declarative constructs
TYPE_PARSER(
Expand Down
11 changes: 4 additions & 7 deletions flang/lib/Parser/unparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2492,9 +2492,6 @@ class UnparseVisitor {
void Unparse(const OpenMPCriticalConstruct &x) {
Unparse(static_cast<const OmpBlockConstruct &>(x));
}
void Unparse(const OmpDeclareTargetWithList &x) {
Put("("), Walk(x.v), Put(")");
}
void Unparse(const OmpInitializerProc &x) {
Walk(std::get<ProcedureDesignator>(x.t));
Put("(");
Expand Down Expand Up @@ -2561,8 +2558,8 @@ class UnparseVisitor {

void Unparse(const OpenMPDeclarativeAssumes &x) {
BeginOpenMP();
Word("!$OMP ASSUMES ");
Walk(std::get<OmpClauseList>(x.t));
Word("!$OMP ");
Walk(x.v);
Put("\n");
EndOpenMP();
}
Expand All @@ -2582,8 +2579,8 @@ class UnparseVisitor {
}
void Unparse(const OpenMPDeclareTargetConstruct &x) {
BeginOpenMP();
Word("!$OMP DECLARE TARGET ");
Walk(std::get<parser::OmpDeclareTargetSpecifier>(x.t));
Word("!$OMP ");
Walk(x.v);
Put("\n");
EndOpenMP();
}
Expand Down
Loading