Lines Matching refs:builder
25 static mlir::Value createNewFirBox(fir::FirOpBuilder &builder, in createNewFirBox() argument
33 return builder.createConvert(loc, box.getBoxTy(), addr); in createNewFirBox()
39 fir::ShapeType::get(builder.getContext(), extents.size()); in createNewFirBox()
40 shape = builder.create<fir::ShapeOp>(loc, shapeType, extents); in createNewFirBox()
48 fir::ShapeShiftType::get(builder.getContext(), extents.size()); in createNewFirBox()
49 shape = builder.create<fir::ShapeShiftOp>(loc, shapeShiftType, in createNewFirBox()
65 : builder.getRefType(bt); in createNewFirBox()
66 cleanedAddr = builder.createConvert(loc, type, addr); in createNewFirBox()
74 return builder.create<fir::EmboxOp>(loc, box.getBoxTy(), cleanedAddr, shape, in createNewFirBox()
97 MutablePropertyReader(fir::FirOpBuilder &builder, mlir::Location loc, in MutablePropertyReader() argument
100 : builder{builder}, loc{loc}, box{box} { in MutablePropertyReader()
102 irBox = builder.create<fir::LoadOp>(loc, box.getAddr());
109 memrefTy = builder.getRefType(memrefTy); in readBaseAddress()
110 return builder.create<fir::BoxAddrOp>(loc, memrefTy, irBox); in readBaseAddress()
113 return builder.create<fir::LoadOp>(loc, addrVar); in readBaseAddress()
118 auto idxTy = builder.getIndexType(); in readShape()
120 auto dimVal = builder.createIntegerConstant(loc, idxTy, dim); in readShape()
121 auto dimInfo = builder.create<fir::BoxDimsOp>(loc, idxTy, idxTy, idxTy, in readShape()
126 auto lb = builder.create<fir::LoadOp>(loc, mutableProperties.lbounds[dim]); in readShape()
127 auto ext = builder.create<fir::LoadOp>(loc, mutableProperties.extents[dim]); in readShape()
137 return fir::factory::CharacterExprHelper{builder, loc}.readLengthFromBox( in readCharacterLength()
142 return builder.create<fir::LoadOp>(loc, deferred[0]); in readCharacterLength()
186 fir::FirOpBuilder &builder; member in __anone969b6080111::MutablePropertyReader
195 MutablePropertyWriter(fir::FirOpBuilder &builder, mlir::Location loc, in MutablePropertyWriter() argument
197 : builder{builder}, loc{loc}, box{box} {} in MutablePropertyWriter()
216 builder.create<fir::StoreOp>(loc, newBox, box.getAddr()); in updateWithIrBox()
224 builder.create<fir::StoreOp>(loc, builder.createNullConstant(loc, nullTy), in setUnallocatedStatus()
237 builder, loc, box.getBoxTy(), box.nonDeferredLenParams()); in setUnallocatedStatus()
238 builder.create<fir::StoreOp>(loc, deallocatedBox, box.getAddr()); in setUnallocatedStatus()
250 MutablePropertyReader{builder, loc, box, /*forceIRBoxRead=*/true}.read( in syncMutablePropertiesFromIRBox()
262 auto addr = MutablePropertyReader{builder, loc, box}.read(lbounds, extents, in syncIRBoxFromMutableProperties()
272 createNewFirBox(builder, loc, box, addr, lbounds, extents, lengths); in updateIRBox()
273 builder.create<fir::StoreOp>(loc, irBox, box.getAddr()); in updateIRBox()
282 builder.create<fir::StoreOp>(loc, builder.createConvert(loc, type, val), in updateMutableProperties()
293 builder.createIntegerConstant(loc, builder.getIndexType(), 1); in updateMutableProperties()
312 fir::FirOpBuilder &builder; member in __anone969b6080111::MutablePropertyWriter
320 fir::factory::createUnallocatedBox(fir::FirOpBuilder &builder, in createUnallocatedBox() argument
325 baseAddrType = builder.getRefType(baseAddrType); in createUnallocatedBox()
332 auto nullAddr = builder.createNullConstant(loc, baseAddrType); in createUnallocatedBox()
335 auto zero = builder.createIntegerConstant(loc, builder.getIndexType(), 0); in createUnallocatedBox()
337 shape = builder.createShape( in createUnallocatedBox()
348 auto zero = builder.createIntegerConstant( in createUnallocatedBox()
349 loc, builder.getCharacterLengthType(), 0); in createUnallocatedBox()
355 return builder.create<fir::EmboxOp>(loc, boxType, nullAddr, shape, emptySlice, in createUnallocatedBox()
360 fir::factory::createTempMutableBox(fir::FirOpBuilder &builder, in createTempMutableBox() argument
364 auto boxAddr = builder.createTemporary(loc, boxType, name); in createTempMutableBox()
368 MutablePropertyWriter{builder, loc, box}.setUnallocatedStatus(); in createTempMutableBox()
395 fir::factory::genMutableBoxRead(fir::FirOpBuilder &builder, mlir::Location loc, in genMutableBoxRead() argument
404 auto reader = MutablePropertyReader(builder, loc, box); in genMutableBoxRead()
412 MutablePropertyReader(builder, loc, box).read(lbounds, extents, lengths); in genMutableBoxRead()
426 fir::factory::genIsAllocatedOrAssociatedTest(fir::FirOpBuilder &builder, in genIsAllocatedOrAssociatedTest() argument
429 auto addr = MutablePropertyReader(builder, loc, box).readBaseAddress(); in genIsAllocatedOrAssociatedTest()
430 return builder.genIsNotNullAddr(loc, addr); in genIsAllocatedOrAssociatedTest()
435 static void genFinalizeAndFree(fir::FirOpBuilder &builder, mlir::Location loc, in genFinalizeAndFree() argument
441 auto cast = builder.createConvert( in genFinalizeAndFree()
443 builder.create<fir::FreeMemOp>(loc, cast); in genFinalizeAndFree()
446 void fir::factory::genFinalization(fir::FirOpBuilder &builder, in genFinalization() argument
449 auto addr = MutablePropertyReader(builder, loc, box).readBaseAddress(); in genFinalization()
450 auto isAllocated = builder.genIsNotNullAddr(loc, addr); in genFinalization()
451 auto ifOp = builder.create<fir::IfOp>(loc, isAllocated, in genFinalization()
453 auto insPt = builder.saveInsertionPoint(); in genFinalization()
454 builder.setInsertionPointToStart(&ifOp.getThenRegion().front()); in genFinalization()
455 genFinalizeAndFree(builder, loc, addr); in genFinalization()
456 builder.restoreInsertionPoint(insPt); in genFinalization()
463 void fir::factory::associateMutableBox(fir::FirOpBuilder &builder, in associateMutableBox() argument
468 MutablePropertyWriter writer(builder, loc, box); in associateMutableBox()
497 auto rawAddr = builder.create<fir::BoxAddrOp>(loc, arr.getMemTy(), in associateMutableBox()
499 auto extents = fir::factory::getExtents(loc, builder, source); in associateMutableBox()
503 fir::factory::readCharLen(builder, loc, source)); in associateMutableBox()
512 fir::ShiftType::get(builder.getContext(), newLbounds.size()); in associateMutableBox()
513 shift = builder.create<fir::ShiftOp>(loc, shiftType, newLbounds); in associateMutableBox()
516 builder.create<fir::ReboxOp>(loc, box.getBoxTy(), arr.getAddr(), in associateMutableBox()
534 fir::FirOpBuilder &builder, mlir::Location loc, in associateMutableBoxWithRemap() argument
539 auto idxTy = builder.getIndexType(); in associateMutableBoxWithRemap()
541 auto one = builder.createIntegerConstant(loc, idxTy, 1); in associateMutableBoxWithRemap()
543 auto lbi = builder.createConvert(loc, idxTy, lb); in associateMutableBoxWithRemap()
544 auto ubi = builder.createConvert(loc, idxTy, ub); in associateMutableBoxWithRemap()
545 auto diff = builder.create<mlir::arith::SubIOp>(loc, idxTy, ubi, lbi); in associateMutableBoxWithRemap()
547 builder.create<mlir::arith::AddIOp>(loc, idxTy, diff, one)); in associateMutableBoxWithRemap()
552 auto cast = builder.createConvert(loc, idxTy, ub); in associateMutableBoxWithRemap()
565 return builder.createConvert(loc, builder.getRefType(ty), addr); in associateMutableBoxWithRemap()
567 MutablePropertyWriter writer(builder, loc, box); in associateMutableBoxWithRemap()
590 auto rawAddr = builder.create<fir::BoxAddrOp>(loc, arr.getMemTy(), in associateMutableBoxWithRemap()
595 fir::factory::readCharLen(builder, loc, source)); in associateMutableBoxWithRemap()
602 fir::ShapeShiftType::get(builder.getContext(), extents.size()); in associateMutableBoxWithRemap()
604 auto idxTy = builder.getIndexType(); in associateMutableBoxWithRemap()
606 auto lb = builder.createConvert(loc, idxTy, lbnd); in associateMutableBoxWithRemap()
611 builder.create<fir::ShapeShiftOp>(loc, shapeType, shapeArgs); in associateMutableBoxWithRemap()
613 builder.create<fir::ReboxOp>(loc, box.getBoxTy(), arr.getAddr(), in associateMutableBoxWithRemap()
630 void fir::factory::disassociateMutableBox(fir::FirOpBuilder &builder, in disassociateMutableBox() argument
633 MutablePropertyWriter{builder, loc, box}.setUnallocatedStatus(); in disassociateMutableBox()
637 getNewLengths(fir::FirOpBuilder &builder, mlir::Location loc, in getNewLengths() argument
640 auto idxTy = builder.getIndexType(); in getNewLengths()
645 builder.createConvert(loc, idxTy, box.nonDeferredLenParams()[0])); in getNewLengths()
648 fir::factory::genMaxWithZero(builder, loc, lenParams[0]); in getNewLengths()
649 lengths.emplace_back(builder.createConvert(loc, idxTy, len)); in getNewLengths()
659 static mlir::Value allocateAndInitNewStorage(fir::FirOpBuilder &builder, in allocateAndInitNewStorage() argument
665 auto lengths = getNewLengths(builder, loc, box, lenParams); in allocateAndInitNewStorage()
666 auto newStorage = builder.create<fir::AllocMemOp>( in allocateAndInitNewStorage()
673 mlir::Value irBox = createNewFirBox(builder, loc, box, newStorage, in allocateAndInitNewStorage()
675 fir::runtime::genDerivedTypeInitialize(builder, loc, irBox); in allocateAndInitNewStorage()
680 void fir::factory::genInlinedAllocation(fir::FirOpBuilder &builder, in genInlinedAllocation() argument
687 auto lengths = getNewLengths(builder, loc, box, lenParams); in genInlinedAllocation()
690 safeExtents.push_back(fir::factory::genMaxWithZero(builder, loc, extent)); in genInlinedAllocation()
691 auto heap = builder.create<fir::AllocMemOp>(loc, box.getBaseTy(), allocName, in genInlinedAllocation()
693 MutablePropertyWriter{builder, loc, box}.updateMutableBox( in genInlinedAllocation()
700 mlir::Value irBox = fir::factory::getMutableIRBox(builder, loc, box); in genInlinedAllocation()
701 fir::runtime::genDerivedTypeInitialize(builder, loc, irBox); in genInlinedAllocation()
705 void fir::factory::genInlinedDeallocate(fir::FirOpBuilder &builder, in genInlinedDeallocate() argument
708 auto addr = MutablePropertyReader(builder, loc, box).readBaseAddress(); in genInlinedDeallocate()
709 genFinalizeAndFree(builder, loc, addr); in genInlinedDeallocate()
710 MutablePropertyWriter{builder, loc, box}.setUnallocatedStatus(); in genInlinedDeallocate()
714 fir::FirOpBuilder &builder, mlir::Location loc, in genReallocIfNeeded() argument
719 auto reader = MutablePropertyReader(builder, loc, box); in genReallocIfNeeded()
721 auto i1Type = builder.getI1Type(); in genReallocIfNeeded()
723 auto isAllocated = builder.genIsNotNullAddr(loc, addr); in genReallocIfNeeded()
746 builder in genReallocIfNeeded()
752 auto mustReallocate = builder.createBool(loc, false); in genReallocIfNeeded()
756 builder.createConvert(loc, required.getType(), previous); in genReallocIfNeeded()
757 auto cmp = builder.create<mlir::arith::CmpIOp>( in genReallocIfNeeded()
759 mustReallocate = builder.create<mlir::arith::SelectOp>( in genReallocIfNeeded()
780 builder in genReallocIfNeeded()
790 builder, loc, box, extents, lengthParams, in genReallocIfNeeded()
794 builder.create<fir::ResultOp>(loc, heap); in genReallocIfNeeded()
799 builder.create<fir::ResultOp>(loc, addr); in genReallocIfNeeded()
803 builder.create<fir::ResultOp>( in genReallocIfNeeded()
807 auto trueValue = builder.createBool(loc, true); in genReallocIfNeeded()
812 builder, loc, in genReallocIfNeeded()
815 builder.create<fir::ResultOp>(loc, in genReallocIfNeeded()
819 builder, loc, box, shape, lengthParams, ".auto.alloc"); in genReallocIfNeeded()
822 builder.create<fir::ResultOp>(loc, in genReallocIfNeeded()
834 void fir::factory::finalizeRealloc(fir::FirOpBuilder &builder, in finalizeRealloc() argument
840 builder.genIfThen(loc, realloc.wasReallocated) in finalizeRealloc()
842 auto reader = MutablePropertyReader(builder, loc, box); in finalizeRealloc()
854 auto lengths = getNewLengths(builder, loc, box, lenParams); in finalizeRealloc()
856 auto extents = fir::factory::getExtents(loc, builder, realloc.newValue); in finalizeRealloc()
857 builder.genIfThen(loc, realloc.oldAddressWasAllocated) in finalizeRealloc()
859 [&]() { genFinalizeAndFree(builder, loc, realloc.oldAddress); }) in finalizeRealloc()
861 MutablePropertyWriter{builder, loc, box}.updateMutableBox( in finalizeRealloc()
874 mlir::Value fir::factory::getMutableIRBox(fir::FirOpBuilder &builder, in getMutableIRBox() argument
877 MutablePropertyWriter{builder, loc, box}.syncIRBoxFromMutableProperties(); in getMutableIRBox()
880 void fir::factory::syncMutableBoxFromIRBox(fir::FirOpBuilder &builder, in syncMutableBoxFromIRBox() argument
883 MutablePropertyWriter{builder, loc, box}.syncMutablePropertiesFromIRBox(); in syncMutableBoxFromIRBox()