[llvm-branch-commits] [flang] [Flang][OpenMP][MLIR] Initial derived type member map support (PR #82853)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Apr 24 15:07:02 PDT 2024
================
@@ -88,6 +91,175 @@ void gatherFuncAndVarSyms(
symbolAndClause.emplace_back(clause, *object.id());
}
+int getComponentPlacementInParent(
+ const Fortran::semantics::Symbol *componentSym) {
+ const auto *derived =
+ componentSym->owner()
+ .derivedTypeSpec()
+ ->typeSymbol()
+ .detailsIf<Fortran::semantics::DerivedTypeDetails>();
+ assert(derived &&
+ "expected derived type details when processing component symbol");
+ int placement = 0;
+ for (auto t : derived->componentNames()) {
+ if (t == componentSym->name())
+ return placement;
+ placement++;
+ }
+ return -1;
+}
+
+std::optional<Object>
+getCompObjOrNull(std::optional<Object> object,
+ Fortran::semantics::SemanticsContext &semaCtx) {
+ if (!object)
+ return std::nullopt;
+
+ auto ref = evaluate::ExtractDataRef(*object.value().ref());
+ if (!ref)
+ return std::nullopt;
+
+ if (std::get_if<evaluate::Component>(&ref->u))
+ return object;
+
+ auto baseObj = getBaseObject(object.value(), semaCtx);
+ if (!baseObj)
+ return std::nullopt;
+
+ return getCompObjOrNull(baseObj.value(), semaCtx);
+}
+
+llvm::SmallVector<int>
----------------
agozillon wrote:
Opted to take it in as an argument as opposed to a return type, as returning a local SmallVector to a SmallVectorImpl doesn't seem like it's allowed (perhaps I tried it incorrectly however, but I couldn't grep a case where it seemed done in LLVM, my grep capabilities are possibly lacking though)
https://github.com/llvm/llvm-project/pull/82853
More information about the llvm-branch-commits
mailing list