[llvm-branch-commits] [flang] [Flang][OpenMP][MLIR] Initial derived type member map support (PR #82853)
https://github.com/jsjodin approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/82853 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [flang] [Flang][OpenMP][MLIR] Initial derived type member map support (PR #82853)
https://github.com/jsjodin commented: Looks good, just some minor nits/comments. https://github.com/llvm/llvm-project/pull/82853 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [flang] [Flang][OpenMP][MLIR] Initial derived type member map support (PR #82853)
@@ -88,6 +91,196 @@ void gatherFuncAndVarSyms( symbolAndClause.emplace_back(clause, *object.id()); } +mlir::omp::MapInfoOp +createMapInfoOp(fir::FirOpBuilder , mlir::Location loc, +mlir::Value baseAddr, mlir::Value varPtrPtr, std::string name, +llvm::ArrayRef bounds, +llvm::ArrayRef members, +mlir::DenseIntElementsAttr membersIndex, uint64_t mapType, +mlir::omp::VariableCaptureKind mapCaptureType, mlir::Type retTy, +bool partialMap) { + if (auto boxTy = baseAddr.getType().dyn_cast()) { +baseAddr = builder.create(loc, baseAddr); +retTy = baseAddr.getType(); + } + + mlir::TypeAttr varType = mlir::TypeAttr::get( + llvm::cast(retTy).getElementType()); + + mlir::omp::MapInfoOp op = builder.create( + loc, retTy, baseAddr, varType, varPtrPtr, members, membersIndex, bounds, + builder.getIntegerAttr(builder.getIntegerType(64, false), mapType), + builder.getAttr(mapCaptureType), + builder.getStringAttr(name), builder.getBoolAttr(partialMap)); + + return op; +} + +static int +getComponentPlacementInParent(const Fortran::semantics::Symbol *componentSym) { + const auto *derived = + componentSym->owner() + .derivedTypeSpec() + ->typeSymbol() + .detailsIf(); + assert(derived && + "expected derived type details when processing component symbol"); + for (auto [placement, name] : llvm::enumerate(derived->componentNames())) +if (name == componentSym->name()) + return placement; + return -1; +} + +static std::optional +getComponentObject(std::optional object, + Fortran::semantics::SemanticsContext ) { + if (!object) +return std::nullopt; + + auto ref = evaluate::ExtractDataRef(*object.value().ref()); + if (!ref) +return std::nullopt; + + if (std::holds_alternative(ref->u)) +return object; + + auto baseObj = getBaseObject(object.value(), semaCtx); + if (!baseObj) +return std::nullopt; + + return getComponentObject(baseObj.value(), semaCtx); +} + +void generateMemberPlacementIndices( +const Object , llvm::SmallVectorImpl , +Fortran::semantics::SemanticsContext ) { + auto compObj = getComponentObject(object, semaCtx); + while (compObj) { +indices.push_back(getComponentPlacementInParent(compObj->id())); +compObj = +getComponentObject(getBaseObject(compObj.value(), semaCtx), semaCtx); + } + + indices = llvm::SmallVector{llvm::reverse(indices)}; +} + +static void calculateShapeAndFillIndices( +llvm::SmallVectorImpl , +llvm::SmallVectorImpl ) { + shape.push_back(memberPlacementData.size()); + size_t largestIndicesSize = + std::max_element(memberPlacementData.begin(), memberPlacementData.end(), + [](auto a, auto b) { + return a.memberPlacementIndices.size() < +b.memberPlacementIndices.size(); + }) + ->memberPlacementIndices.size(); + shape.push_back(largestIndicesSize); + + // DenseElementsAttr expects a rectangular shape for the data, so all + // index lists have to be of the same length, this emplaces -1 as filler + for (auto : memberPlacementData) { +if (v.memberPlacementIndices.size() < largestIndicesSize) { + auto *prevEnd = v.memberPlacementIndices.end(); + v.memberPlacementIndices.resize(largestIndicesSize); + std::fill(prevEnd, v.memberPlacementIndices.end(), -1); +} + } +} + +static mlir::DenseIntElementsAttr createDenseElementsAttrFromIndices( +llvm::SmallVectorImpl , +fir::FirOpBuilder ) { + llvm::SmallVector shape; + calculateShapeAndFillIndices(shape, memberPlacementData); + + llvm::SmallVector indicesFlattened = std::accumulate( + memberPlacementData.begin(), memberPlacementData.end(), + llvm::SmallVector(), + [](llvm::SmallVector , OmpMapMemberIndicesData y) { +x.insert(x.end(), y.memberPlacementIndices.begin(), + y.memberPlacementIndices.end()); +return x; + }); + + return mlir::DenseIntElementsAttr::get( + mlir::VectorType::get(shape, +mlir::IntegerType::get(builder.getContext(), 32)), + indicesFlattened); +} + +void insertChildMapInfoIntoParent( +Fortran::lower::AbstractConverter , +std::map> , +llvm::SmallVectorImpl , +llvm::SmallVectorImpl , +llvm::SmallVectorImpl *mapSymTypes, +llvm::SmallVectorImpl *mapSymLocs) { + for (auto indices : parentMemberIndices) { +bool parentExists = false; +size_t parentIdx; +for (parentIdx = 0; parentIdx < mapSyms.size(); ++parentIdx) { + if (mapSyms[parentIdx] == indices.first) { +parentExists = true; +break; + } +} + +if (parentExists) { + auto mapOp = llvm::cast( + mapOperands[parentIdx].getDefiningOp()); + + // NOTE: To maintain appropriate SSA ordering, we move
[llvm-branch-commits] [flang] [Flang][OpenMP][MLIR] Initial derived type member map support (PR #82853)
@@ -0,0 +1,260 @@ +//===- OMPMapInfoFinalization.cpp +//---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +//===--===// +/// \file +/// An OpenMP dialect related pass for FIR/HLFIR which performs some +/// pre-processing of MapInfoOp's after the module has been lowered to +/// finalize them. +/// +/// For example, it expands MapInfoOp's containing descriptor related +/// types (fir::BoxType's) into multiple MapInfoOp's containing the parent +/// descriptor and pointer member components for individual mapping, +/// treating the descriptor type as a record type for later lowering in the +/// OpenMP dialect. +/// +/// The pass also adds MapInfoOp's that are members of a parent object but are +/// not directly used in the body of a target region to its BlockArgument list +/// to maintain consistency across all MapInfoOp's tied to a region directly or +/// indirectly via an parent object. +//===--===// + +#include "flang/Optimizer/Builder/FIRBuilder.h" +#include "flang/Optimizer/Dialect/FIRType.h" +#include "flang/Optimizer/Dialect/Support/KindMapping.h" +#include "flang/Optimizer/Transforms/Passes.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" +#include "mlir/Dialect/OpenMP/OpenMPDialect.h" +#include "mlir/IR/BuiltinDialect.h" +#include "mlir/IR/BuiltinOps.h" +#include "mlir/IR/Operation.h" +#include "mlir/IR/SymbolTable.h" +#include "mlir/Pass/Pass.h" +#include "mlir/Support/LLVM.h" +#include "llvm/ADT/SmallPtrSet.h" +#include "llvm/Frontend/OpenMP/OMPConstants.h" +#include + +namespace fir { +#define GEN_PASS_DEF_OMPMAPINFOFINALIZATIONPASS +#include "flang/Optimizer/Transforms/Passes.h.inc" +} // namespace fir + +namespace { +class OMPMapInfoFinalizationPass +: public fir::impl::OMPMapInfoFinalizationPassBase< + OMPMapInfoFinalizationPass> { + + void genDescriptorMemberMaps(mlir::omp::MapInfoOp op, + fir::FirOpBuilder , + mlir::Operation *target) { +mlir::Location loc = op.getLoc(); +mlir::Value descriptor = op.getVarPtr(); + +// If we enter this function, but the mapped type itself is not the +// descriptor, then it's likely the address of the descriptor so we +// must retrieve the descriptor SSA. +if (!fir::isTypeWithDescriptor(op.getVarType())) { + if (auto addrOp = mlir::dyn_cast_if_present( + op.getVarPtr().getDefiningOp())) { +descriptor = addrOp.getVal(); + } +} + +// The fir::BoxOffsetOp only works with !fir.ref> types, as +// allowing it to access non-reference box operations can cause some +// problematic SSA IR. However, in the case of assumed shape's the type +// is not a !fir.ref, in these cases to retrieve the appropriate +// !fir.ref> to access the data we need to map we must +// perform an alloca and then store to it and retrieve the data from the new +// alloca. +if (mlir::isa(descriptor.getType())) { + mlir::OpBuilder::InsertPoint insPt = builder.saveInsertionPoint(); + builder.setInsertionPointToStart(builder.getAllocaBlock()); + auto alloca = builder.create(loc, descriptor.getType()); + builder.restoreInsertionPoint(insPt); + builder.create(loc, descriptor, alloca); + descriptor = alloca; +} + +mlir::Value baseAddrAddr = builder.create( +loc, descriptor, fir::BoxFieldAttr::base_addr); + +// Member of the descriptor pointing at the allocated data +mlir::Value baseAddr = builder.create( +loc, baseAddrAddr.getType(), descriptor, +mlir::TypeAttr::get(llvm::cast( +fir::unwrapRefType(baseAddrAddr.getType())) +.getElementType()), +baseAddrAddr, /*members=*/mlir::SmallVector{}, +/*member_index=*/mlir::DenseIntElementsAttr{}, op.getBounds(), +builder.getIntegerAttr(builder.getIntegerType(64, false), + op.getMapType().value()), +builder.getAttr( +mlir::omp::VariableCaptureKind::ByRef), +/*name=*/builder.getStringAttr(""), +/*partial_map=*/builder.getBoolAttr(false)); + +// TODO: map the addendum segment of the descriptor, similarly to the +// above base address/data pointer member. + +if (auto mapClauseOwner = +llvm::dyn_cast(target)) { + llvm::SmallVector newMapOps; + mlir::OperandRange mapOperandsArr = mapClauseOwner.getMapOperands(); + + for (size_t i = 0; i < mapOperandsArr.size(); ++i) { +if (mapOperandsArr[i] ==
[llvm-branch-commits] [flang] [Flang][OpenMP][MLIR] Initial derived type member map support (PR #82853)
@@ -88,6 +91,196 @@ void gatherFuncAndVarSyms( symbolAndClause.emplace_back(clause, *object.id()); } +mlir::omp::MapInfoOp +createMapInfoOp(fir::FirOpBuilder , mlir::Location loc, +mlir::Value baseAddr, mlir::Value varPtrPtr, std::string name, +llvm::ArrayRef bounds, +llvm::ArrayRef members, +mlir::DenseIntElementsAttr membersIndex, uint64_t mapType, +mlir::omp::VariableCaptureKind mapCaptureType, mlir::Type retTy, +bool partialMap) { + if (auto boxTy = baseAddr.getType().dyn_cast()) { +baseAddr = builder.create(loc, baseAddr); +retTy = baseAddr.getType(); + } + + mlir::TypeAttr varType = mlir::TypeAttr::get( + llvm::cast(retTy).getElementType()); + + mlir::omp::MapInfoOp op = builder.create( + loc, retTy, baseAddr, varType, varPtrPtr, members, membersIndex, bounds, + builder.getIntegerAttr(builder.getIntegerType(64, false), mapType), + builder.getAttr(mapCaptureType), + builder.getStringAttr(name), builder.getBoolAttr(partialMap)); + + return op; +} + +static int +getComponentPlacementInParent(const Fortran::semantics::Symbol *componentSym) { + const auto *derived = + componentSym->owner() + .derivedTypeSpec() + ->typeSymbol() + .detailsIf(); + assert(derived && + "expected derived type details when processing component symbol"); + for (auto [placement, name] : llvm::enumerate(derived->componentNames())) +if (name == componentSym->name()) + return placement; + return -1; +} + +static std::optional +getComponentObject(std::optional object, + Fortran::semantics::SemanticsContext ) { + if (!object) +return std::nullopt; + + auto ref = evaluate::ExtractDataRef(*object.value().ref()); + if (!ref) +return std::nullopt; + + if (std::holds_alternative(ref->u)) +return object; + + auto baseObj = getBaseObject(object.value(), semaCtx); + if (!baseObj) +return std::nullopt; + + return getComponentObject(baseObj.value(), semaCtx); +} + +void generateMemberPlacementIndices( +const Object , llvm::SmallVectorImpl , +Fortran::semantics::SemanticsContext ) { + auto compObj = getComponentObject(object, semaCtx); + while (compObj) { +indices.push_back(getComponentPlacementInParent(compObj->id())); +compObj = +getComponentObject(getBaseObject(compObj.value(), semaCtx), semaCtx); + } + + indices = llvm::SmallVector{llvm::reverse(indices)}; +} + +static void calculateShapeAndFillIndices( +llvm::SmallVectorImpl , +llvm::SmallVectorImpl ) { + shape.push_back(memberPlacementData.size()); + size_t largestIndicesSize = + std::max_element(memberPlacementData.begin(), memberPlacementData.end(), + [](auto a, auto b) { + return a.memberPlacementIndices.size() < +b.memberPlacementIndices.size(); + }) + ->memberPlacementIndices.size(); + shape.push_back(largestIndicesSize); + + // DenseElementsAttr expects a rectangular shape for the data, so all + // index lists have to be of the same length, this emplaces -1 as filler + for (auto : memberPlacementData) { +if (v.memberPlacementIndices.size() < largestIndicesSize) { + auto *prevEnd = v.memberPlacementIndices.end(); + v.memberPlacementIndices.resize(largestIndicesSize); + std::fill(prevEnd, v.memberPlacementIndices.end(), -1); +} + } +} + +static mlir::DenseIntElementsAttr createDenseElementsAttrFromIndices( +llvm::SmallVectorImpl , +fir::FirOpBuilder ) { + llvm::SmallVector shape; + calculateShapeAndFillIndices(shape, memberPlacementData); + + llvm::SmallVector indicesFlattened = std::accumulate( + memberPlacementData.begin(), memberPlacementData.end(), + llvm::SmallVector(), + [](llvm::SmallVector , OmpMapMemberIndicesData y) { +x.insert(x.end(), y.memberPlacementIndices.begin(), + y.memberPlacementIndices.end()); +return x; + }); + + return mlir::DenseIntElementsAttr::get( + mlir::VectorType::get(shape, +mlir::IntegerType::get(builder.getContext(), 32)), + indicesFlattened); +} + +void insertChildMapInfoIntoParent( +Fortran::lower::AbstractConverter , +std::map> , +llvm::SmallVectorImpl , +llvm::SmallVectorImpl , +llvm::SmallVectorImpl *mapSymTypes, +llvm::SmallVectorImpl *mapSymLocs) { + for (auto indices : parentMemberIndices) { +bool parentExists = false; +size_t parentIdx; +for (parentIdx = 0; parentIdx < mapSyms.size(); ++parentIdx) { + if (mapSyms[parentIdx] == indices.first) { +parentExists = true; +break; + } +} + +if (parentExists) { + auto mapOp = llvm::cast( + mapOperands[parentIdx].getDefiningOp()); + + // NOTE: To maintain appropriate SSA ordering, we move
[llvm-branch-commits] [flang] [Flang][OpenMP][MLIR] Initial derived type member map support (PR #82853)
@@ -0,0 +1,260 @@ +//===- OMPMapInfoFinalization.cpp +//---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +//===--===// +/// \file +/// An OpenMP dialect related pass for FIR/HLFIR which performs some +/// pre-processing of MapInfoOp's after the module has been lowered to +/// finalize them. +/// +/// For example, it expands MapInfoOp's containing descriptor related +/// types (fir::BoxType's) into multiple MapInfoOp's containing the parent +/// descriptor and pointer member components for individual mapping, +/// treating the descriptor type as a record type for later lowering in the +/// OpenMP dialect. +/// +/// The pass also adds MapInfoOp's that are members of a parent object but are +/// not directly used in the body of a target region to its BlockArgument list +/// to maintain consistency across all MapInfoOp's tied to a region directly or +/// indirectly via an parent object. +//===--===// + +#include "flang/Optimizer/Builder/FIRBuilder.h" +#include "flang/Optimizer/Dialect/FIRType.h" +#include "flang/Optimizer/Dialect/Support/KindMapping.h" +#include "flang/Optimizer/Transforms/Passes.h" +#include "mlir/Dialect/Func/IR/FuncOps.h" +#include "mlir/Dialect/OpenMP/OpenMPDialect.h" +#include "mlir/IR/BuiltinDialect.h" +#include "mlir/IR/BuiltinOps.h" +#include "mlir/IR/Operation.h" +#include "mlir/IR/SymbolTable.h" +#include "mlir/Pass/Pass.h" +#include "mlir/Support/LLVM.h" +#include "llvm/ADT/SmallPtrSet.h" +#include "llvm/Frontend/OpenMP/OMPConstants.h" +#include + +namespace fir { +#define GEN_PASS_DEF_OMPMAPINFOFINALIZATIONPASS +#include "flang/Optimizer/Transforms/Passes.h.inc" +} // namespace fir + +namespace { +class OMPMapInfoFinalizationPass +: public fir::impl::OMPMapInfoFinalizationPassBase< + OMPMapInfoFinalizationPass> { + + void genDescriptorMemberMaps(mlir::omp::MapInfoOp op, + fir::FirOpBuilder , + mlir::Operation *target) { +mlir::Location loc = op.getLoc(); +mlir::Value descriptor = op.getVarPtr(); + +// If we enter this function, but the mapped type itself is not the +// descriptor, then it's likely the address of the descriptor so we +// must retrieve the descriptor SSA. +if (!fir::isTypeWithDescriptor(op.getVarType())) { + if (auto addrOp = mlir::dyn_cast_if_present( + op.getVarPtr().getDefiningOp())) { +descriptor = addrOp.getVal(); + } +} + +// The fir::BoxOffsetOp only works with !fir.ref> types, as +// allowing it to access non-reference box operations can cause some +// problematic SSA IR. However, in the case of assumed shape's the type +// is not a !fir.ref, in these cases to retrieve the appropriate +// !fir.ref> to access the data we need to map we must +// perform an alloca and then store to it and retrieve the data from the new +// alloca. +if (mlir::isa(descriptor.getType())) { + mlir::OpBuilder::InsertPoint insPt = builder.saveInsertionPoint(); + builder.setInsertionPointToStart(builder.getAllocaBlock()); + auto alloca = builder.create(loc, descriptor.getType()); + builder.restoreInsertionPoint(insPt); + builder.create(loc, descriptor, alloca); + descriptor = alloca; +} + +mlir::Value baseAddrAddr = builder.create( +loc, descriptor, fir::BoxFieldAttr::base_addr); + +// Member of the descriptor pointing at the allocated data +mlir::Value baseAddr = builder.create( +loc, baseAddrAddr.getType(), descriptor, +mlir::TypeAttr::get(llvm::cast( +fir::unwrapRefType(baseAddrAddr.getType())) +.getElementType()), +baseAddrAddr, /*members=*/mlir::SmallVector{}, +/*member_index=*/mlir::DenseIntElementsAttr{}, op.getBounds(), +builder.getIntegerAttr(builder.getIntegerType(64, false), + op.getMapType().value()), +builder.getAttr( +mlir::omp::VariableCaptureKind::ByRef), +/*name=*/builder.getStringAttr(""), +/*partial_map=*/builder.getBoolAttr(false)); + +// TODO: map the addendum segment of the descriptor, similarly to the +// above base address/data pointer member. + +if (auto mapClauseOwner = +llvm::dyn_cast(target)) { + llvm::SmallVector newMapOps; + mlir::OperandRange mapOperandsArr = mapClauseOwner.getMapOperands(); + + for (size_t i = 0; i < mapOperandsArr.size(); ++i) { +if (mapOperandsArr[i] ==
[llvm-branch-commits] [flang] [Flang][OpenMP][MLIR] Initial derived type member map support (PR #82853)
@@ -218,17 +224,40 @@ bool ClauseProcessor::processMotionClauses( // Explicit map captures are captured ByRef by default, // optimisation passes may alter this to ByCopy or other capture // types to optimise - mlir::Value mapOp = createMapInfoOp( - firOpBuilder, clauseLocation, symAddr, mlir::Value{}, - asFortran.str(), bounds, {}, + mlir::omp::MapInfoOp mapOp = createMapInfoOp( + firOpBuilder, clauseLocation, symAddr, + /*varPtrPtr=*/mlir::Value{}, asFortran.str(), bounds, + /*members=*/{}, /*membersIndex=*/mlir::DenseIntElementsAttr{}, static_cast< std::underlying_type_t>( mapTypeBits), mlir::omp::VariableCaptureKind::ByRef, symAddr.getType()); - result.mapVars.push_back(mapOp); + if (object.id()->owner().IsDerivedType()) { +std::optional dataRef = jsjodin wrote: Would it be possible to create a function for the code inside the 'if'? It seems like the same code exists above. https://github.com/llvm/llvm-project/pull/82853 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [flang] [Flang][OpenMP][MLIR] Initial derived type member map support (PR #82853)
@@ -0,0 +1,260 @@ +//===- OMPMapInfoFinalization.cpp +//---===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +//===--===// +/// \file +/// An OpenMP dialect related pass for FIR/HLFIR which performs some +/// pre-processing of MapInfoOp's after the module has been lowered to +/// finalize them. +/// +/// For example, it expands MapInfoOp's containing descriptor related +/// types (fir::BoxType's) into multiple MapInfoOp's containing the parent +/// descriptor and pointer member components for individual mapping, +/// treating the descriptor type as a record type for later lowering in the +/// OpenMP dialect. +/// +/// The pass also adds MapInfoOp's that are members of a parent object but are +/// not directly used in the body of a target region to its BlockArgument list +/// to maintain consistency across all MapInfoOp's tied to a region directly or +/// indirectly via an parent object. jsjodin wrote: Nit: an -> a https://github.com/llvm/llvm-project/pull/82853 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [flang] [Flang][OpenMP][MLIR] Initial derived type member map support (PR #82853)
https://github.com/jsjodin edited https://github.com/llvm/llvm-project/pull/82853 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [OpenMP][MLIR] Add new arguments to map_info to help support record type maps (PR #82851)
https://github.com/jsjodin approved this pull request. https://github.com/llvm/llvm-project/pull/82851 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [OpenMP][MLIR] Add new arguments to map_info to help support record type maps (PR #82851)
@@ -990,6 +990,77 @@ static void printMapClause(OpAsmPrinter , Operation *op, } } +static ParseResult parseMembersIndex(OpAsmParser , + DenseIntElementsAttr ) { + SmallVector values; + int64_t value; + int64_t shape[2] = {0, 0}; + unsigned shapeTmp = 0; + auto parseIndices = [&]() -> ParseResult { +if (parser.parseInteger(value)) + return failure(); +shapeTmp++; +values.push_back(APInt(32, value)); +return success(); + }; + + do { +if (failed(parser.parseLSquare())) + return failure(); + +if (parser.parseCommaSeparatedList(parseIndices)) + return failure(); + +if (failed(parser.parseRSquare())) + return failure(); + +// Only set once, if any indices are not the same size +// we error out in the next check as that's unsupported +if (shape[1] == 0) + shape[1] = shapeTmp; + +// Verify that the recently parsed list is equal to the +// first one we parsed, they must be equal lengths to +// keep the rectangular shape DenseIntElementsAttr +// requires +if (shapeTmp != shape[1]) + return failure(); + +shapeTmp = 0; +shape[0]++; + } while (succeeded(parser.parseOptionalComma())); + + if (!values.empty()) { +ShapedType valueType = +VectorType::get(shape, IntegerType::get(parser.getContext(), 32)); +membersIdx = DenseIntElementsAttr::get(valueType, values); + } + + return success(); +} + +static void printMembersIndex(OpAsmPrinter , MapInfoOp op, + DenseIntElementsAttr membersIdx) { + assert(membersIdx.getShapedType().getShape().size() <= 2); jsjodin wrote: Using names for the local references might help also to make the code clearer. `i * membersIdx.getShapedType().getShape()[1]` can be hoisted out of the inner loop also. https://github.com/llvm/llvm-project/pull/82851 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [OpenMP][MLIR] Add new arguments to map_info to help support record type maps (PR #82851)
https://github.com/jsjodin edited https://github.com/llvm/llvm-project/pull/82851 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [OpenMP][MLIR] Extend record member map support for omp dialect to LLVM-IR (PR #82852)
https://github.com/jsjodin approved this pull request. Other than fixing some nits I think this looks good. https://github.com/llvm/llvm-project/pull/82852 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [OpenMP][MLIR] Extend record member map support for omp dialect to LLVM-IR (PR #82852)
https://github.com/jsjodin edited https://github.com/llvm/llvm-project/pull/82852 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [OpenMP][MLIR] Extend record member map support for omp dialect to LLVM-IR (PR #82852)
https://github.com/jsjodin edited https://github.com/llvm/llvm-project/pull/82852 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [OpenMP][MLIR] Extend record member map support for omp dialect to LLVM-IR (PR #82852)
@@ -2283,16 +2386,12 @@ static void processMapMembersWithParent( for (auto mappedMembers : parentClause.getMembers()) { auto memberClause = mlir::dyn_cast(mappedMembers.getDefiningOp()); jsjodin wrote: Another dyn_cast here that could be a cast. https://github.com/llvm/llvm-project/pull/82852 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits