[llvm-branch-commits] [flang] [MLIR][OpenMP] Add Lowering support for OpenMP Declare Mapper directive (PR #117046)

Tom Eccles via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Nov 21 08:20:02 PST 2024


================
@@ -2701,7 +2702,39 @@ static void
 genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
        semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
        const parser::OpenMPDeclareMapperConstruct &declareMapperConstruct) {
-  TODO(converter.getCurrentLocation(), "OpenMPDeclareMapperConstruct");
+  fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
+  lower::StatementContext stmtCtx;
+  const auto &spec =
+      std::get<parser::OmpDeclareMapperSpecifier>(declareMapperConstruct.t);
+  const auto &mapperName{std::get<std::optional<parser::Name>>(spec.t)};
+  const auto &varType{std::get<parser::TypeSpec>(spec.t)};
+  const auto &varName{std::get<parser::Name>(spec.t)};
+  std::stringstream mapperNameStr;
+  if (mapperName.has_value()) {
+    mapperNameStr << mapperName->ToString();
+  } else {
+    mapperNameStr << "default_"
+                  << varType.declTypeSpec->derivedTypeSpec().name().ToString();
+  }
----------------
tblah wrote:

Two nits. Feel free to ignore number 2.
1. Flang **lowering** follows the MLIR style guide, which in this case matches LLVM: https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements
2. To me, a `std::stringstream` feels like overkill here. You could use a `std::string` with the concatenation in the else branch handled  by an implicit `Twine` (https://llvm.org/docs/ProgrammersManual.html#llvm-adt-twine-h)

https://github.com/llvm/llvm-project/pull/117046


More information about the llvm-branch-commits mailing list