@@ -186,53 +186,23 @@ class MapsForPrivatizedSymbolsPass
186186 return fir::hasDynamicSize (t);
187187 }
188188
189- // TODO: Remove this in favor of fir::factory::genImplicitBoundsOps
190- // in a subsequent PR.
191189 void genBoundsOps (fir::FirOpBuilder &builder, mlir::Value var,
192190 llvm::SmallVector<mlir::Value> &boundsOps) {
193- if (fir::isBoxAddress (var.getType ())) {
194- unsigned int rank = 0 ;
195- rank = fir::getBoxRank (fir::unwrapRefType (var.getType ()));
196- mlir::Location loc = var.getLoc ();
197- mlir::Type idxTy = builder.getIndexType ();
198- mlir::Value one = builder.createIntegerConstant (loc, idxTy, 1 );
199- mlir::Value zero = builder.createIntegerConstant (loc, idxTy, 0 );
200- mlir::Type boundTy = builder.getType <omp::MapBoundsType>();
201- mlir::Value box = builder.create <fir::LoadOp>(loc, var);
202- for (unsigned int i = 0 ; i < rank; ++i) {
203- mlir::Value dimNo = builder.createIntegerConstant (loc, idxTy, i);
204- auto dimInfo = builder.create <fir::BoxDimsOp>(loc, idxTy, idxTy, idxTy,
205- box, dimNo);
206- mlir::Value lb = dimInfo.getLowerBound ();
207- mlir::Value extent = dimInfo.getExtent ();
208- mlir::Value byteStride = dimInfo.getByteStride ();
209- mlir::Value ub = builder.create <mlir::arith::SubIOp>(loc, extent, one);
210-
211- mlir::Value boundsOp = builder.create <omp::MapBoundsOp>(
212- loc, boundTy, /* lower_bound=*/ zero,
213- /* upper_bound=*/ ub, /* extent=*/ extent, /* stride=*/ byteStride,
214- /* stride_in_bytes = */ true , /* start_idx=*/ lb);
215- LLVM_DEBUG (PDBGS () << " Created BoundsOp " << boundsOp << " \n " );
216- boundsOps.push_back (boundsOp);
217- }
218- } else {
219- mlir::Location loc = var.getLoc ();
220- fir::factory::AddrAndBoundsInfo info =
221- fir::factory::getDataOperandBaseAddr (builder, var,
222- /* isOptional=*/ false , loc);
223- fir::ExtendedValue extendedValue =
224- hlfir::translateToExtendedValue (loc, builder,
225- hlfir::Entity{info.addr },
226- /* continguousHint=*/ true )
227- .first ;
228- llvm::SmallVector<mlir::Value> boundsOpsVec =
229- fir::factory::genImplicitBoundsOps<mlir::omp::MapBoundsOp,
230- mlir::omp::MapBoundsType>(
231- builder, info, extendedValue,
232- /* dataExvIsAssumedSize=*/ false , loc);
233- for (auto bounds : boundsOpsVec)
234- boundsOps.push_back (bounds);
235- }
191+ mlir::Location loc = var.getLoc ();
192+ fir::factory::AddrAndBoundsInfo info =
193+ fir::factory::getDataOperandBaseAddr (builder, var,
194+ /* isOptional=*/ false , loc);
195+ fir::ExtendedValue extendedValue =
196+ hlfir::translateToExtendedValue (loc, builder, hlfir::Entity{info.addr },
197+ /* continguousHint=*/ true )
198+ .first ;
199+ llvm::SmallVector<mlir::Value> boundsOpsVec =
200+ fir::factory::genImplicitBoundsOps<mlir::omp::MapBoundsOp,
201+ mlir::omp::MapBoundsType>(
202+ builder, info, extendedValue,
203+ /* dataExvIsAssumedSize=*/ false , loc);
204+ for (auto bounds : boundsOpsVec)
205+ boundsOps.push_back (bounds);
236206 }
237207};
238208} // namespace
0 commit comments