diff options
Diffstat (limited to 'flang/lib/Lower/OpenMP/Clauses.cpp')
-rw-r--r-- | flang/lib/Lower/OpenMP/Clauses.cpp | 95 |
1 files changed, 65 insertions, 30 deletions
diff --git a/flang/lib/Lower/OpenMP/Clauses.cpp b/flang/lib/Lower/OpenMP/Clauses.cpp index 22a0721..686fba0 100644 --- a/flang/lib/Lower/OpenMP/Clauses.cpp +++ b/flang/lib/Lower/OpenMP/Clauses.cpp @@ -1001,19 +1001,21 @@ Map make(const parser::OmpClause::Map &inp, semantics::SemanticsContext &semaCtx) { // inp.v -> parser::OmpMapClause CLAUSET_ENUM_CONVERT( // - convert1, parser::OmpMapType::Value, Map::MapType, + convertMapType, parser::OmpMapType::Value, Map::MapType, // clang-format off - MS(Alloc, Alloc) - MS(Delete, Delete) - MS(From, From) - MS(Release, Release) - MS(To, To) - MS(Tofrom, Tofrom) + MS(Alloc, Storage) + MS(Delete, Storage) + MS(Release, Storage) + MS(Storage, Storage) + MS(From, From) + MS(To, To) + MS(Tofrom, Tofrom) // clang-format on ); CLAUSET_ENUM_CONVERT( // - convert2, parser::OmpMapTypeModifier::Value, Map::MapTypeModifier, + convertMapTypeMod, parser::OmpMapTypeModifier::Value, + Map::MapTypeModifier, // clang-format off MS(Always, Always) MS(Close, Close) @@ -1022,43 +1024,76 @@ Map make(const parser::OmpClause::Map &inp, // clang-format on ); + CLAUSET_ENUM_CONVERT( // + convertRefMod, parser::OmpRefModifier::Value, Map::RefModifier, + // clang-format off + MS(Ref_Ptee, RefPtee) + MS(Ref_Ptr, RefPtr) + MS(Ref_Ptr_Ptee, RefPtrPtee) + // clang-format on + ); + + // Treat always, close, present, self, delete modifiers as map-type- + // modifiers. auto &mods = semantics::OmpGetModifiers(inp.v); - auto *t1 = semantics::OmpGetUniqueModifier<parser::OmpMapper>(mods); - auto *t2 = semantics::OmpGetUniqueModifier<parser::OmpIterator>(mods); - auto *t3 = semantics::OmpGetUniqueModifier<parser::OmpMapType>(mods); - auto &t4 = std::get<parser::OmpObjectList>(inp.v.t); - auto mappers = [&]() -> std::optional<List<Mapper>> { + auto *t1 = semantics::OmpGetUniqueModifier<parser::OmpMapType>(mods); + auto &t2 = std::get<parser::OmpObjectList>(inp.v.t); + + auto type = [&]() -> std::optional<Map::MapType> { if (t1) - return List<Mapper>{Mapper{makeObject(t1->v, semaCtx)}}; + return convertMapType(t1->v); return std::nullopt; }(); - auto iterator = [&]() -> std::optional<Iterator> { - if (t2) - return makeIterator(*t2, semaCtx); + llvm::DenseSet<Map::MapTypeModifier> modSet; + if (t1 && t1->v == parser::OmpMapType::Value::Delete) + modSet.insert(Map::MapTypeModifier::Delete); + + for (auto *typeMod : + semantics::OmpGetRepeatableModifier<parser::OmpMapTypeModifier>(mods)) { + modSet.insert(convertMapTypeMod(typeMod->v)); + } + if (semantics::OmpGetUniqueModifier<parser::OmpAlwaysModifier>(mods)) + modSet.insert(Map::MapTypeModifier::Always); + if (semantics::OmpGetUniqueModifier<parser::OmpCloseModifier>(mods)) + modSet.insert(Map::MapTypeModifier::Close); + if (semantics::OmpGetUniqueModifier<parser::OmpDeleteModifier>(mods)) + modSet.insert(Map::MapTypeModifier::Delete); + if (semantics::OmpGetUniqueModifier<parser::OmpPresentModifier>(mods)) + modSet.insert(Map::MapTypeModifier::Present); + if (semantics::OmpGetUniqueModifier<parser::OmpSelfModifier>(mods)) + modSet.insert(Map::MapTypeModifier::Self); + if (semantics::OmpGetUniqueModifier<parser::OmpxHoldModifier>(mods)) + modSet.insert(Map::MapTypeModifier::OmpxHold); + + std::optional<Map::MapTypeModifiers> maybeTypeMods{}; + if (!modSet.empty()) + maybeTypeMods = Map::MapTypeModifiers(modSet.begin(), modSet.end()); + + auto refMod = [&]() -> std::optional<Map::RefModifier> { + if (auto *t = semantics::OmpGetUniqueModifier<parser::OmpRefModifier>(mods)) + return convertRefMod(t->v); return std::nullopt; }(); - auto type = [&]() -> std::optional<Map::MapType> { - if (t3) - return convert1(t3->v); + auto mappers = [&]() -> std::optional<List<Mapper>> { + if (auto *t = semantics::OmpGetUniqueModifier<parser::OmpMapper>(mods)) + return List<Mapper>{Mapper{makeObject(t->v, semaCtx)}}; return std::nullopt; }(); - Map::MapTypeModifiers typeMods; - for (auto *typeMod : - semantics::OmpGetRepeatableModifier<parser::OmpMapTypeModifier>(mods)) { - typeMods.push_back(convert2(typeMod->v)); - } - std::optional<Map::MapTypeModifiers> maybeTypeMods{}; - if (!typeMods.empty()) - maybeTypeMods = std::move(typeMods); + auto iterator = [&]() -> std::optional<Iterator> { + if (auto *t = semantics::OmpGetUniqueModifier<parser::OmpIterator>(mods)) + return makeIterator(*t, semaCtx); + return std::nullopt; + }(); return Map{{/*MapType=*/std::move(type), /*MapTypeModifiers=*/std::move(maybeTypeMods), - /*Mapper=*/std::move(mappers), /*Iterator=*/std::move(iterator), - /*LocatorList=*/makeObjects(t4, semaCtx)}}; + /*RefModifier=*/std::move(refMod), /*Mapper=*/std::move(mappers), + /*Iterator=*/std::move(iterator), + /*LocatorList=*/makeObjects(t2, semaCtx)}}; } Match make(const parser::OmpClause::Match &inp, |