[flang] [llvm] [flang][openmp] Adds Parser and Semantic Support for Interop Construct, and Init and Use Clauses. (PR #120584)
Kiran Chandramohan via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 14 08:12:56 PDT 2025
================
@@ -5578,6 +5578,92 @@ void OmpStructureChecker::Leave(const parser::DoConstruct &x) {
Base::Leave(x);
}
+void OmpStructureChecker::Enter(const parser::OpenMPInteropConstruct &x) {
+ bool isDependClauseOccured{false};
+ int targetCount{0}, targetSyncCount{0};
+ const auto &dir{std::get<parser::Verbatim>(x.t)};
+ std::set<const Symbol *> objectSymbolList;
+ PushContextAndClauseSets(dir.source, llvm::omp::Directive::OMPD_interop);
+ const auto &clauseList{std::get<parser::OmpClauseList>(x.t)};
+ for (const auto &clause : clauseList.v) {
+ common::visit(
+ common::visitors{
+ [&](const parser::OmpClause::Init &initClause) {
+ if (OmpVerifyModifiers(initClause.v, llvm::omp::OMPC_init,
+ GetContext().directiveSource, context_)) {
+
+ auto &modifiers{OmpGetModifiers(initClause.v)};
+ auto &&interopTypeModifier{
+ OmpGetRepeatableModifier<parser::OmpInteropType>(
+ modifiers)};
+ for (const auto &it : interopTypeModifier) {
+ if (it->v == parser::OmpInteropType::Value::TargetSync) {
+ ++targetSyncCount;
+ } else {
+ ++targetCount;
+ }
+ }
+ }
+ const auto &interopVar{parser::Unwrap<parser::OmpObject>(
+ std::get<parser::OmpObject>(initClause.v.t))};
+ const auto *name{parser::Unwrap<parser::Name>(interopVar)};
+ const auto *objectSymbol{name->symbol};
+ if (llvm::is_contained(objectSymbolList, objectSymbol)) {
+ context_.Say(
+ GetContext().directiveSource,
+ "Each interop-var may be specified for at most one action-clause of each interop construct."_err_en_US);
+ } else {
+ objectSymbolList.insert(objectSymbol);
+ }
+ },
+ [&](const parser::OmpClause::Depend &dependClause) {
+ isDependClauseOccured = true;
+ },
+ [&](const parser::OmpClause::Destroy &destroyClause) {
+ const auto &interopVar{
+ parser::Unwrap<parser::OmpObject>(destroyClause.v)};
+ const auto *name{parser::Unwrap<parser::Name>(interopVar)};
+ const auto *objectSymbol{name->symbol};
+ if (llvm::is_contained(objectSymbolList, objectSymbol)) {
+ context_.Say(
+ GetContext().directiveSource,
+ "Each interop-var may be specified for at most one action-clause of each interop construct."_err_en_US);
+ } else {
+ objectSymbolList.insert(objectSymbol);
+ }
+ },
+ [&](const parser::OmpClause::Use &useClause) {
+ const auto &interopVar{
+ parser::Unwrap<parser::OmpObject>(useClause.v)};
+ const auto *name{parser::Unwrap<parser::Name>(interopVar)};
+ const auto *objectSymbol{name->symbol};
+ if (llvm::is_contained(objectSymbolList, objectSymbol)) {
+ context_.Say(
+ GetContext().directiveSource,
+ "Each interop-var may be specified for at most one action-clause of each interop construct."_err_en_US);
----------------
kiranchandramohan wrote:
```suggestion
"Each interop-var may be specified for at most one action-clause of each INTEROP construct."_err_en_US);
```
https://github.com/llvm/llvm-project/pull/120584
More information about the llvm-commits
mailing list