[flang-commits] [flang] [OpenMP][Flang] Add "IsolatedFromAbove" trait to omp.target (PR #67164)
Kiran Chandramohan via flang-commits
flang-commits at lists.llvm.org
Mon Oct 30 04:49:21 PDT 2023
================
@@ -1691,39 +1701,44 @@ static mlir::omp::MapInfoOp
createMapInfoOp(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::Value baseAddr, std::stringstream &name,
mlir::SmallVector<mlir::Value> bounds, uint64_t mapType,
- mlir::omp::VariableCaptureKind mapCaptureType, bool implicit,
- mlir::Type retTy) {
- mlir::Value varPtrPtr;
+ mlir::omp::VariableCaptureKind mapCaptureType, mlir::Type retTy,
+ bool isVal = false) {
+ mlir::Value val, varPtr, varPtrPtr;
+ mlir::TypeAttr varType;
+
if (auto boxTy = baseAddr.getType().dyn_cast<fir::BaseBoxType>()) {
baseAddr = builder.create<fir::BoxAddrOp>(loc, baseAddr);
retTy = baseAddr.getType();
}
- mlir::omp::MapInfoOp op =
- builder.create<mlir::omp::MapInfoOp>(loc, retTy, baseAddr);
- op.setVarTypeAttr(mlir::TypeAttr::get(
- llvm::dyn_cast<mlir::omp::PointerLikeType>(retTy).getElementType()));
- op.setNameAttr(builder.getStringAttr(name.str()));
- op.setImplicit(implicit);
- op.setMapType(mapType);
- op.setMapCaptureType(mapCaptureType);
-
- unsigned insPos = 1;
- if (varPtrPtr)
- op->insertOperands(insPos++, varPtrPtr);
- if (bounds.size() > 0)
- op->insertOperands(insPos, bounds);
- op->setAttr(mlir::omp::MapInfoOp::getOperandSegmentSizeAttr(),
- builder.getDenseI32ArrayAttr(
- {1, varPtrPtr ? 1 : 0, static_cast<int32_t>(bounds.size())}));
+ if (isVal)
+ val = baseAddr;
+ else
+ varPtr = baseAddr;
+
+ if (auto ptrType = llvm::dyn_cast<mlir::omp::PointerLikeType>(retTy)) {
+ varType = mlir::TypeAttr::get(ptrType.getElementType());
+ } else {
+ varType = mlir::TypeAttr::get(retTy);
+ }
----------------
kiranchandramohan wrote:
Nit: Remove braces here.
https://github.com/llvm/llvm-project/pull/67164
More information about the flang-commits
mailing list