[llvm-branch-commits] [flang] [MLIR][OpenMP] Add Lowering support for OpenMP Declare Mapper directive (PR #117046)
Akash Banerjee via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Dec 11 10:11:02 PST 2024
TIFitis wrote:
@kiranchandramohan @kparzysz I guess I must be using the name mangler in an incorrect way then. I've added the code snippets I am using when lowering and later performing a lookup. Please let me know what would be the correct way of doing this.
When lowering DeclMapperOp:
```
static void
genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
const parser::OpenMPDeclareMapperConstruct &declareMapperConstruct) {
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
const auto &spec =
std::get<parser::OmpDeclareMapperSpecifier>(declareMapperConstruct.t);
const auto &mapperName{std::get<std::optional<parser::Name>>(spec.t)};
std::string mapperNameStr;
if (mapperName.has_value())
mapperNameStr = mapperName->ToString();
else
mapperNameStr =
"default_" + varType.declTypeSpec->derivedTypeSpec().name().ToString();
// This is my current implementation.
// It returns _QQFmy_mapper as mapperNameStr.
mapperNameStr = converter.mangleName(*mapperName->symbol);
auto declMapperOp = firOpBuilder.create<mlir::omp::DeclareMapperOp>(
loc, mapperNameStr, mlirType);
converter.getMLIRSymbolTable()->insert(declMapperOp);
// This code produces the error:
// LLVM ERROR: /home/akash/Documents/llvm-project/flang/lib/Lower/Mangler.cpp:184: not yet implemented: symbol mangling
// mapperNameStr = converter.mangleName(*mapperName->symbol);
// This code produces the error:
// ** symbol not properly mapped **
// symTable.lookupSymbol(mapperName->symbol).dump();
```
When trying to lookup DeclareMapper from the mapClause mapper:
```
auto mapperIdName = mappers->front().v.id().symbol->name().ToString();
mapperIdName = converter.mangleName(mapperIdName);
// Here mapperIdName returns _QQFFtestmy_mapper which fails the
// lookup inside the asser.
// assert(converter.getMLIRSymbolTable()->lookup(mapperIdName) &&
// "mapper not found");
mapperId = mlir::FlatSymbolRefAttr::get(&converter.getMLIRContext(),
mapperIdName);
```
https://github.com/llvm/llvm-project/pull/117046
More information about the llvm-branch-commits
mailing list