[llvm-branch-commits] [clang] [llvm] [mlir] [MLIR][OpenMP] Add LLVM translation support for OpenMP UserDefinedMappers (PR #124746)
Sergio Afonso via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Feb 17 05:22:18 PST 2025
================
@@ -3529,6 +3549,86 @@ static void genMapInfos(llvm::IRBuilderBase &builder,
}
}
+static llvm::Expected<llvm::Function *>
+emitUserDefinedMapper(Operation *declMapperOp, llvm::IRBuilderBase &builder,
+ LLVM::ModuleTranslation &moduleTranslation);
+
+static llvm::Expected<llvm::Function *>
+getOrCreateUserDefinedMapperFunc(Operation *op, llvm::IRBuilderBase &builder,
+ LLVM::ModuleTranslation &moduleTranslation) {
+ auto declMapperOp = cast<omp::DeclareMapperOp>(op);
+ std::string mapperFuncName =
+ moduleTranslation.getOpenMPBuilder()->createPlatformSpecificName(
+ {"omp_mapper", declMapperOp.getSymName()});
+ if (auto *lookupFunc = moduleTranslation.lookupFunction(mapperFuncName))
+ return lookupFunc;
+
+ llvm::Expected<llvm::Function *> mapperFunc =
+ emitUserDefinedMapper(declMapperOp, builder, moduleTranslation);
+ if (!mapperFunc)
+ return mapperFunc.takeError();
+ moduleTranslation.mapFunction(mapperFuncName, *mapperFunc);
----------------
skatrak wrote:
I think this should be moved to `emitUserDefinedMapper`. Even though it looks unlikely that there would be any callers to that function from anywhere else, I think the right place to register the new function is where it's created.
That way, this can also be simplified by returning directly the result of the `emitUserDefinedMapper` call.
https://github.com/llvm/llvm-project/pull/124746
More information about the llvm-branch-commits
mailing list