Lines Matching full:loc
177 static mlir::func::FuncOp getIORuntimeFunc(mlir::Location loc,
184 func = builder.createFunction(loc, name, funTy);
194 mlir::Location loc, mlir::Value cookie,
200 getIORuntimeFunc<mkIOKey(GetIoMsg)>(loc, builder);
202 loc, getIoMsg,
205 builder.createConvert(loc, getIoMsg.getFunctionType().getInput(1),
207 builder.createConvert(loc, getIoMsg.getFunctionType().getInput(2),
211 getIORuntimeFunc<mkIOKey(EndIoStatement)>(loc, builder);
212 auto call = builder.create<fir::CallOp>(loc, endIoStatement,
217 builder.create<fir::ResultOp>(loc, iostat);
223 fir::getBase(converter.genExprAddr(loc, csi.ioStatExpr, stmtCtx));
225 builder.createConvert(loc, converter.genType(*csi.ioStatExpr), iostat);
226 builder.create<fir::StoreOp>(loc, ioStatResult, ioStatVar);
236 mlir::Location loc, bool checkResult,
251 auto ifOp = builder.create<fir::IfOp>(loc, resTy, ok,
299 mlir::Location loc = converter.getCurrentLocation();
308 loc, refTy,
309 builder.create<fir::AddrOfOp>(loc, table.resultType(),
328 tableIsLocal ? builder.create<fir::AllocaOp>(loc, listTy) : mlir::Value{};
331 mlir::Value list = builder.create<fir::UndefOp>(loc, listTy);
340 list = builder.create<fir::InsertValueOp>(loc, listTy, list, val,
350 loc, refTy,
352 loc, fir::ReferenceType::get(converter.genType(dtSym)),
359 TODO(loc, "defined IO procedure pointers");
363 loc, refTy,
365 loc,
375 loc, refTy,
376 builder.create<fir::AddrOfOp>(loc, procDef.getFunctionType(),
380 insert(builder.createNullConstant(loc, refTy));
385 loc, intTy, static_cast<int>(iface.second.definedIo)));
388 insert(builder.createIntegerConstant(loc, boolTy,
392 builder.create<fir::StoreOp>(loc, list, listAddr);
394 builder.create<fir::HasValueOp>(loc, list);
400 builder.createGlobalConstant(loc, listTy, listMangleName, listFunc,
406 ? builder.create<fir::AllocaOp>(loc, tableTy)
409 mlir::Value table = builder.create<fir::UndefOp>(loc, tableTy);
412 loc, tableTy, table,
413 builder.createIntegerConstant(loc, sizeTy, definedIoProcMap.size()),
417 listAddr = builder.createNullConstant(loc, builder.getRefType(listTy));
419 listAddr = builder.create<fir::AddrOfOp>(loc, list.resultType(),
423 loc, tableTy, table, listAddr,
427 loc, tableTy, table, builder.createIntegerConstant(loc, boolTy, true),
430 builder.create<fir::StoreOp>(loc, table, tableAddr);
432 builder.create<fir::HasValueOp>(loc, table);
438 loc, tableTy, tableMangleName,
441 loc, fir::ReferenceType::get(tableTy), table.getSymbol());
444 return builder.createConvert(loc, refTy, tableAddr);
463 mlir::Location loc = converter.getCurrentLocation();
466 return builder.create<fir::AddrOfOp>(loc, group.resultType(),
486 return fir::factory::createStringLiteral(builder, loc,
513 converter, loc, boxTy, *expr, /*couldBeInEquivalence=*/true);
514 b.create<fir::HasValueOp>(loc, box);
516 builder.createGlobalConstant(loc, boxTy, mangleName, descFunc, linkOnce);
522 groupIsLocal ? builder.create<fir::AllocaOp>(loc, listTy) : mlir::Value{};
525 mlir::Value list = builder.create<fir::UndefOp>(loc, listTy);
535 builder.createConvert(loc, charRefTy, fir::getBase(stringAddress(s)));
536 list = builder.create<fir::InsertValueOp>(loc, listTy, list, nameAddr,
542 descAddr = builder.create<fir::AddrOfOp>(loc, desc.resultType(),
552 loc, commonGlobal.resultType(), commonGlobal.getSymbol());
556 mlir::Value base = builder.createConvert(loc, seqTy, commonBlockAddr);
559 loc, builder.getIndexType(), byteOffset);
561 loc, i8Ptr, base, mlir::ValueRange{offs});
563 builder.createConvert(loc, builder.getRefType(symType), varAddr);
571 descAddr = builder.createTemporary(loc, boxType);
573 fir::factory::associateMutableBox(builder, loc, box, exv,
576 descAddr = builder.createConvert(loc, descRefTy, descAddr);
577 list = builder.create<fir::InsertValueOp>(loc, listTy, list, descAddr,
581 builder.create<fir::StoreOp>(loc, list, listAddr);
583 builder.create<fir::HasValueOp>(loc, list);
588 builder.createGlobalConstant(loc, listTy, listMangleName, listFunc,
593 ? builder.create<fir::AllocaOp>(loc, groupTy)
596 mlir::Value group = builder.create<fir::UndefOp>(loc, groupTy);
599 loc, groupTy, group,
600 builder.createConvert(loc, charRefTy,
605 loc, groupTy, group,
606 builder.createIntegerConstant(loc, sizeTy, details.objects().size()),
610 listAddr = builder.create<fir::AddrOfOp>(loc, list.resultType(),
614 loc, groupTy, group, listAddr,
619 loc, groupTy, group,
623 builder.create<fir::StoreOp>(loc, group, groupAddr);
625 builder.create<fir::HasValueOp>(loc, group);
631 loc, groupTy, groupMangleName,
633 groupAddr = builder.create<fir::AddrOfOp>(loc, group.resultType(),
647 mlir::Location loc = converter.getCurrentLocation();
648 makeNextConditionalOn(builder, loc, checkResult, ok);
652 groupAddr = builder.createConvert(loc, argType, groupAddr);
654 ok = builder.create<fir::CallOp>(loc, funcOp, args).getResult(0);
658 static mlir::func::FuncOp getOutputFunc(mlir::Location loc,
662 return getIORuntimeFunc<mkIOKey(OutputDerivedType)>(loc, builder);
664 return getIORuntimeFunc<mkIOKey(OutputDescriptor)>(loc, builder);
669 return getIORuntimeFunc<mkIOKey(OutputLogical)>(loc, builder);
671 return getIORuntimeFunc<mkIOKey(OutputInteger8)>(loc, builder);
673 return getIORuntimeFunc<mkIOKey(OutputInteger16)>(loc, builder);
675 return getIORuntimeFunc<mkIOKey(OutputInteger32)>(loc, builder);
677 return getIORuntimeFunc<mkIOKey(OutputInteger64)>(loc, builder);
679 return getIORuntimeFunc<mkIOKey(OutputInteger128)>(loc, builder);
686 return getIORuntimeFunc<mkIOKey(OutputReal32)>(loc, builder);
688 return getIORuntimeFunc<mkIOKey(OutputReal64)>(loc, builder);
695 return getIORuntimeFunc<mkIOKey(OutputComplex32)>(loc, builder);
697 return getIORuntimeFunc<mkIOKey(OutputComplex64)>(loc, builder);
700 return getIORuntimeFunc<mkIOKey(OutputLogical)>(loc, builder);
709 return getIORuntimeFunc<mkIOKey(OutputAscii)>(loc, builder);
711 return getIORuntimeFunc<mkIOKey(OutputDescriptor)>(loc, builder);
727 mlir::Location loc = converter.genLocation(pExpr.source);
728 makeNextConditionalOn(builder, loc, checkResult, ok, inLoop);
733 fir::emitFatalError(loc, "internal error: could not get evaluate::Expr");
736 getOutputFunc(loc, builder, itemTy, isFormatted);
741 fir::factory::CharacterExprHelper helper{builder, loc};
743 mlir::Value box = fir::getBase(converter.genExprBox(loc, *expr, stmtCtx));
744 outputFuncArgs.push_back(builder.createConvert(loc, argType, box));
748 fir::ExtendedValue exv = converter.genExprAddr(loc, expr, stmtCtx);
755 loc, outputFunc.getFunctionType().getInput(1), fir::getBase(exv)));
757 loc, outputFunc.getFunctionType().getInput(2), fir::getLen(exv)));
759 fir::ExtendedValue itemBox = converter.genExprValue(loc, expr, stmtCtx);
763 fir::factory::Complex{builder, loc}.extractParts(itemValue);
767 itemValue = builder.createConvert(loc, argType, itemValue);
771 ok = builder.create<fir::CallOp>(loc, outputFunc, outputFuncArgs)
777 static mlir::func::FuncOp getInputFunc(mlir::Location loc,
781 return getIORuntimeFunc<mkIOKey(InputDerivedType)>(loc, builder);
783 return getIORuntimeFunc<mkIOKey(InputDescriptor)>(loc, builder);
786 return getIORuntimeFunc<mkIOKey(InputDescriptor)>(loc, builder);
788 ? getIORuntimeFunc<mkIOKey(InputLogical)>(loc, builder)
789 : getIORuntimeFunc<mkIOKey(InputInteger)>(loc, builder);
793 return getIORuntimeFunc<mkIOKey(InputReal32)>(loc, builder);
795 return getIORuntimeFunc<mkIOKey(InputReal64)>(loc, builder);
801 return getIORuntimeFunc<mkIOKey(InputComplex32)>(loc, builder);
803 return getIORuntimeFunc<mkIOKey(InputComplex64)>(loc, builder);
806 return getIORuntimeFunc<mkIOKey(InputLogical)>(loc, builder);
811 return getIORuntimeFunc<mkIOKey(InputAscii)>(loc, builder);
813 return getIORuntimeFunc<mkIOKey(InputDescriptor)>(loc, builder);
821 static void boolRefToLogical(mlir::Location loc, fir::FirOpBuilder &builder,
824 auto boolAddr = builder.createConvert(loc, boolType, addr);
825 auto boolValue = builder.create<fir::LoadOp>(loc, boolAddr);
829 auto logicalValue = builder.createConvert(loc, logicalType, boolValue);
830 builder.create<fir::StoreOp>(loc, logicalValue, addr);
835 mlir::Location loc, mlir::func::FuncOp inputFunc,
844 inputFuncArgs.push_back(builder.createConvert(loc, argType, box));
850 inputFuncArgs.push_back(builder.createConvert(loc, argType, itemAddr));
851 fir::factory::CharacterExprHelper charHelper{builder, loc};
855 loc, inputFunc.getFunctionType().getInput(2), len));
858 loc, builder.getI32IntegerAttr(
862 auto call = builder.create<fir::CallOp>(loc, inputFunc, inputFuncArgs);
866 boolRefToLogical(loc, builder, itemAddr);
884 mlir::Location loc = converter.genLocation(pVar.GetSource());
885 makeNextConditionalOn(builder, loc, checkResult, ok, inLoop);
889 fir::emitFatalError(loc, "internal error: could not get evaluate::Expr");
892 Fortran::lower::genVectorSubscriptBox(loc, converter, stmtCtx, *expr);
894 loc, builder, vectorSubscriptBox.getElementType(), isFormatted);
899 createIoRuntimeCallForItem(converter, loc, inputFunc, cookie,
900 mustBox ? builder.createBox(loc, element)
903 vectorSubscriptBox.loopOverElements(builder, loc, elementalGenerator);
908 converter, loc, inputFunc, cookie,
909 mustBox ? builder.createBox(loc, element) : element);
912 ok = builder.createBool(loc, true);
913 ok = vectorSubscriptBox.loopOverElementsWhile(builder, loc,
920 getInputFunc(loc, builder, itemTy, isFormatted);
923 ? converter.genExprBox(loc, *expr, stmtCtx)
924 : converter.genExprAddr(loc, expr, stmtCtx);
925 ok = createIoRuntimeCallForItem(converter, loc, inputFunc, cookie, itemExv);
937 mlir::Location loc = converter.getCurrentLocation();
943 makeNextConditionalOn(builder, loc, checkResult, ok, inLoop);
952 return builder.createConvert(loc, builder.getIndexType(), v);
959 : builder.create<mlir::arith::ConstantIndexOp>(loc, 1);
971 loc, lowerValue, upperValue, stepValue, /*unordered=*/false,
975 loc, fir::unwrapRefType(loopVar.getType()), doLoopOp.getInductionVar());
976 builder.create<fir::StoreOp>(loc, lcv, loopVar);
980 loc, doLoopOp.getInductionVar(), doLoopOp.getStep(), iofAttr);
981 builder.create<fir::ResultOp>(loc, result);
984 lcv = builder.createConvert(loc, fir::unwrapRefType(loopVar.getType()),
986 builder.create<fir::StoreOp>(loc, lcv, loopVar);
991 ok = builder.createBool(loc, true);
993 loc, lowerValue, upperValue, stepValue, ok, /*finalCountValue*/ true);
996 builder.createConvert(loc, fir::unwrapRefType(loopVar.getType()),
998 builder.create<fir::StoreOp>(loc, lcv, loopVar);
1001 builder.createIntegerConstant(loc, builder.getI1Type(), 0);
1011 builder.create<fir::ResultOp>(loc, lastOp->getResult(0));
1013 builder.create<fir::ResultOp>(loc, ok); // loop result
1016 builder.create<fir::ResultOp>(loc, falseValue);
1022 loc, inductionResult0, iterWhileOp.getStep(), iofAttr);
1024 loc, iterateResult, inductionResult1, inductionResult0);
1026 builder.create<fir::ResultOp>(loc, results);
1030 lcv = builder.createConvert(loc, fir::unwrapRefType(loopVar.getType()),
1032 builder.create<fir::StoreOp>(loc, lcv, loopVar);
1040 mlir::Location loc, mlir::Type toType) {
1042 return builder.createConvert(loc, toType,
1043 fir::factory::locationToFilename(builder, loc));
1047 mlir::Location loc, mlir::Type toType) {
1048 return fir::factory::locationToLineNo(converter.getFirOpBuilder(), loc,
1053 mlir::Location loc, mlir::Type toType) {
1055 loc, builder.getI64IntegerAttr(0));
1056 return builder.createConvert(loc, toType, null);
1060 mlir::Location loc, mlir::Type toType) {
1062 loc, builder.getIntegerAttr(toType, 0));
1069 genBuffer(Fortran::lower::AbstractConverter &converter, mlir::Location loc,
1074 fir::factory::CharacterExprHelper helper(builder, loc);
1087 TODO(loc, "character descriptor to contiguous buffer");
1093 buff = builder.createConvert(loc, strTy, buff);
1094 len = builder.createConvert(loc, lenTy, len);
1102 lowerStringLit(Fortran::lower::AbstractConverter &converter, mlir::Location loc,
1108 fir::emitFatalError(loc, "internal error: null semantic expr in IO");
1109 auto [buff, len] = genBuffer(converter, loc, *expr, strTy, lenTy, stmtCtx);
1114 loc, builder.getIntegerAttr(ty2, kindVal));
1124 mlir::Location loc, llvm::StringRef text,
1130 fir::getBase(fir::factory::createStringLiteral(builder, loc, text));
1131 mlir::Value buff = builder.createConvert(loc, strTy, addrGlobalStringLit);
1132 mlir::Value len = builder.createIntegerConstant(loc, lenTy, text.size());
1144 mlir::Location loc, mlir::Value cookie,
1148 mlir::func::FuncOp ioFunc = getIORuntimeFunc<A>(loc, builder);
1151 loc, Fortran::semantics::GetExpr(spec.v), localStatementCtx));
1152 mlir::Value val = builder.createConvert(loc, ioFuncTy.getInput(1), expr);
1154 return builder.create<fir::CallOp>(loc, ioFunc, ioArgs).getResult(0);
1161 mlir::Location loc, mlir::Value cookie,
1165 mlir::func::FuncOp ioFunc = getIORuntimeFunc<A>(loc, builder);
1168 lowerStringLit(converter, loc, localStatementCtx, spec,
1172 return builder.create<fir::CallOp>(loc, ioFunc, ioArgs).getResult(0);
1177 mlir::Location loc, mlir::Value cookie, const A &spec) {
1192 Fortran::lower::AbstractConverter &converter, mlir::Location loc,
1197 mlir::func::FuncOp ioFunc = getIORuntimeFunc<mkIOKey(SetFile)>(loc, builder);
1200 lowerStringLit(converter, loc, localStatementCtx, spec,
1204 return builder.create<fir::CallOp>(loc, ioFunc, ioArgs).getResult(0);
1209 Fortran::lower::AbstractConverter &converter, mlir::Location loc,
1215 ioFunc = getIORuntimeFunc<mkIOKey(SetAccess)>(loc, builder);
1218 ioFunc = getIORuntimeFunc<mkIOKey(SetAction)>(loc, builder);
1221 ioFunc = getIORuntimeFunc<mkIOKey(SetAsynchronous)>(loc, builder);
1224 ioFunc = getIORuntimeFunc<mkIOKey(SetBlank)>(loc, builder);
1227 ioFunc = getIORuntimeFunc<mkIOKey(SetDecimal)>(loc, builder);
1230 ioFunc = getIORuntimeFunc<mkIOKey(SetDelim)>(loc, builder);
1233 ioFunc = getIORuntimeFunc<mkIOKey(SetEncoding)>(loc, builder);
1236 ioFunc = getIORuntimeFunc<mkIOKey(SetForm)>(loc, builder);
1239 ioFunc = getIORuntimeFunc<mkIOKey(SetPad)>(loc, builder);
1242 ioFunc = getIORuntimeFunc<mkIOKey(SetPosition)>(loc, builder);
1245 ioFunc = getIORuntimeFunc<mkIOKey(SetRound)>(loc, builder);
1248 ioFunc = getIORuntimeFunc<mkIOKey(SetSign)>(loc, builder);
1251 ioFunc = getIORuntimeFunc<mkIOKey(SetCarriagecontrol)>(loc, builder);
1254 ioFunc = getIORuntimeFunc<mkIOKey(SetConvert)>(loc, builder);
1257 TODO(loc, "DISPOSE not part of the runtime::io interface");
1262 lowerStringLit(converter, loc, localStatementCtx,
1267 return builder.create<fir::CallOp>(loc, ioFunc, ioArgs).getResult(0);
1272 Fortran::lower::AbstractConverter &converter, mlir::Location loc,
1274 return genIntIOOption<mkIOKey(SetRecl)>(converter, loc, cookie, spec);
1279 Fortran::lower::AbstractConverter &converter, mlir::Location loc,
1281 return genCharIOOption<mkIOKey(SetStatus)>(converter, loc, cookie, spec.v);
1286 Fortran::lower::AbstractConverter &converter, mlir::Location loc,
1292 ioFunc = getIORuntimeFunc<mkIOKey(SetAdvance)>(loc, builder);
1295 ioFunc = getIORuntimeFunc<mkIOKey(SetBlank)>(loc, builder);
1298 ioFunc = getIORuntimeFunc<mkIOKey(SetDecimal)>(loc, builder);
1301 ioFunc = getIORuntimeFunc<mkIOKey(SetDelim)>(loc, builder);
1304 ioFunc = getIORuntimeFunc<mkIOKey(SetPad)>(loc, builder);
1307 ioFunc = getIORuntimeFunc<mkIOKey(SetRound)>(loc, builder);
1310 ioFunc = getIORuntimeFunc<mkIOKey(SetSign)>(loc, builder);
1316 lowerStringLit(converter, loc, localStatementCtx,
1321 return builder.create<fir::CallOp>(loc, ioFunc, ioArgs).getResult(0);
1326 Fortran::lower::AbstractConverter &converter, mlir::Location loc,
1329 return genCharIOOption<mkIOKey(SetAsynchronous)>(converter, loc, cookie,
1335 Fortran::lower::AbstractConverter &converter, mlir::Location loc,
1337 return genIntIOOption<mkIOKey(SetPos)>(converter, loc, cookie, spec);
1342 Fortran::lower::AbstractConverter &converter, mlir::Location loc,
1344 return genIntIOOption<mkIOKey(SetRec)>(converter, loc, cookie, spec);
1351 mlir::Location loc, mlir::Value cookie,
1354 mlir::func::FuncOp ioFunc = getIORuntimeFunc<IoRuntimeKey>(loc, builder);
1356 builder.create<fir::CallOp>(loc, ioFunc, mlir::ValueRange{cookie})
1360 loc, Fortran::semantics::GetExpr(parserVar.v), localStatementCtx);
1361 builder.createStoreWithConvert(loc, value, fir::getBase(var));
1393 mlir::Location loc, mlir::Value cookie,
1397 makeNextConditionalOn(builder, loc, checkResult, ok);
1418 return genIOOption(converter, loc, cookie, x);
1431 mlir::Location loc, const A &specList) {
1467 csi.ioMsg = converter.genExprAddr(loc, ioMsgExpr, stmtCtx);
1475 mlir::Location loc, mlir::Value cookie,
1481 getIORuntimeFunc<mkIOKey(EnableHandlers)>(loc, builder);
1485 loc, builder.getIntegerAttr(boolType, specifierIsPresent));
1493 builder.create<fir::CallOp>(loc, enableHandlers, ioArgs);
1571 Fortran::lower::AbstractConverter &converter, mlir::Location loc,
1575 converter.genExprBox(loc, var.typedExpr->v.value(), stmtCtx);
1589 mlir::Location loc, const A &stmt,
1593 return getVariableBufferRequiredDescriptor(converter, loc, *var, stmtCtx);
1596 return getVariableBufferRequiredDescriptor(converter, loc, *var, stmtCtx);
1602 Fortran::lower::AbstractConverter &, mlir::Location loc,
1623 mlir::Location loc,
1653 lowerSourceTextAsStringLit(converter, loc, text, strTy, lenTy);
1659 loc, strTy,
1660 builder.createIntegerConstant(loc, builder.getIndexType(), 0));
1661 stringLen = builder.createIntegerConstant(loc, lenTy, 0);
1667 builder.create<mlir::cf::BranchOp>(loc, endBlock, args);
1679 builder, loc,
1682 builder.create<fir::UnreachableOp>(loc);
1687 auto label = fir::getBase(converter.genExprValue(loc, &expr, stmtCtx));
1688 builder.create<fir::SelectOp>(loc, label, indexList, blockList);
1691 endBlock->addArgument(strTy, loc);
1692 endBlock->addArgument(lenTy, loc);
1706 genFormat(Fortran::lower::AbstractConverter &converter, mlir::Location loc,
1714 converter, loc, toStringRef(eval->position), strTy, lenTy);
1724 return {fir::getBase(converter.genExprBox(loc, *e, stmtCtx)),
1727 return lowerStringLit(converter, loc, stmtCtx, *pExpr, strTy, lenTy);
1734 return lowerReferenceAsStringSelect(converter, loc, *e, strTy, lenTy,
1741 TODO(loc, "io-control-spec contains a reference to a non-integer, "
1747 getFormat(Fortran::lower::AbstractConverter &converter, mlir::Location loc,
1751 return genFormat(converter, loc, *stmt.format, strTy, lenTy, stmtCtx);
1752 return genFormat(converter, loc, *getIOControl<Fortran::parser::Format>(stmt),
1758 Fortran::lower::AbstractConverter &converter, mlir::Location loc,
1761 return genFormat(converter, loc, std::get<Fortran::parser::Format>(stmt.t),
1768 getBuffer(Fortran::lower::AbstractConverter &converter, mlir::Location loc,
1776 return genBuffer(converter, loc, *expr, strTy, lenTy, stmtCtx);
1781 mlir::Location loc,
1786 auto rawUnit = fir::getBase(converter.genExprValue(loc, iounit, stmtCtx));
1796 ? getIORuntimeFunc<mkIOKey(CheckUnitNumberInRange64)>(loc, builder)
1797 : getIORuntimeFunc<mkIOKey(CheckUnitNumberInRange128)>(loc,
1801 args.push_back(builder.createConvert(loc, funcTy.getInput(0), rawUnit));
1802 args.push_back(builder.createBool(loc, csi.hasErrorConditionSpec()));
1804 args.push_back(builder.createConvert(loc, funcTy.getInput(2),
1806 args.push_back(builder.createConvert(loc, funcTy.getInput(3),
1809 args.push_back(builder.createNullConstant(loc, funcTy.getInput(2)));
1811 fir::factory::createZeroValue(builder, loc, funcTy.getInput(3)));
1813 mlir::Value file = locToFilename(converter, loc, funcTy.getInput(4));
1814 mlir::Value line = locToLineNo(converter, loc, funcTy.getInput(5));
1817 auto checkCall = builder.create<fir::CallOp>(loc, check, args);
1821 mlir::Value zero = fir::factory::createZeroValue(builder, loc, iostatTy);
1823 loc, mlir::arith::CmpIPredicate::eq, iostat, zero);
1824 auto ifOp = builder.create<fir::IfOp>(loc, iostatTy, unitIsOK,
1827 builder.create<fir::ResultOp>(loc, iostat);
1833 return builder.createConvert(loc, ty, rawUnit);
1837 mlir::Location loc,
1845 return genIOUnitNumber(converter, loc, Fortran::semantics::GetExpr(*e),
1848 loc, builder.getIntegerAttr(ty, defaultUnitNumber));
1853 getIOUnit(Fortran::lower::AbstractConverter &converter, mlir::Location loc,
1858 return genIOUnit(converter, loc, iounit, ty, csi, stmtCtx, defaultUnitNumber);
1869 mlir::Location loc = converter.getCurrentLocation();
1870 ConditionSpecInfo csi = lowerErrorSpec(converter, loc, stmt.v);
1871 mlir::func::FuncOp beginFunc = getIORuntimeFunc<K>(loc, builder);
1874 converter, loc, getExpr<Fortran::parser::FileUnitNumber>(stmt),
1876 mlir::Value un = builder.createConvert(loc, beginFuncTy.getInput(0), unit);
1877 mlir::Value file = locToFilename(converter, loc, beginFuncTy.getInput(1));
1878 mlir::Value line = locToLineNo(converter, loc, beginFuncTy.getInput(2));
1879 auto call = builder.create<fir::CallOp>(loc, beginFunc,
1882 genConditionHandlerCall(converter, loc, cookie, stmt.v, csi);
1885 threadSpecs(converter, loc, cookie, stmt.v, csi.hasErrorConditionSpec(), ok);
1916 genNewunitSpec(Fortran::lower::AbstractConverter &converter, mlir::Location loc,
1925 getIORuntimeFunc<mkIOKey(GetNewUnit)>(loc, builder);
1929 loc, ioFuncTy.getInput(1),
1930 fir::getBase(converter.genExprAddr(loc, var, stmtCtx)));
1931 auto kind = builder.createIntegerConstant(loc, ioFuncTy.getInput(2),
1934 return builder.create<fir::CallOp>(loc, ioFunc, ioArgs).getResult(0);
1946 mlir::Location loc = converter.getCurrentLocation();
1947 ConditionSpecInfo csi = lowerErrorSpec(converter, loc, stmt.v);
1950 beginFunc = getIORuntimeFunc<mkIOKey(BeginOpenUnit)>(loc, builder);
1953 converter, loc, getExpr<Fortran::parser::FileUnitNumber>(stmt),
1956 beginArgs.push_back(locToFilename(converter, loc, beginFuncTy.getInput(1)));
1957 beginArgs.push_back(locToLineNo(converter, loc, beginFuncTy.getInput(2)));
1961 beginFunc = getIORuntimeFunc<mkIOKey(BeginOpenNewUnit)>(loc, builder);
1963 beginArgs.push_back(locToFilename(converter, loc, beginFuncTy.getInput(0)));
1964 beginArgs.push_back(locToLineNo(converter, loc, beginFuncTy.getInput(1)));
1967 builder.create<fir::CallOp>(loc, beginFunc, beginArgs).getResult(0);
1968 genConditionHandlerCall(converter, loc, cookie, stmt.v, csi);
1971 threadSpecs(converter, loc, cookie, stmt.v, csi.hasErrorConditionSpec(), ok);
1973 genNewunitSpec(converter, loc, cookie, stmt.v);
1975 return genEndIO(converter, loc, cookie, csi, stmtCtx);
1989 mlir::Location loc = converter.getCurrentLocation();
1990 ConditionSpecInfo csi = lowerErrorSpec(converter, loc, stmt.v);
1993 hasId ? getIORuntimeFunc<mkIOKey(BeginWait)>(loc, builder)
1994 : getIORuntimeFunc<mkIOKey(BeginWaitAll)>(loc, builder);
1997 converter, loc, getExpr<Fortran::parser::FileUnitNumber>(stmt),
2002 loc, getExpr<Fortran::parser::IdExpr>(stmt), stmtCtx));
2003 args.push_back(builder.createConvert(loc, beginFuncTy.getInput(1), id));
2004 args.push_back(locToFilename(converter, loc, beginFuncTy.getInput(2)));
2005 args.push_back(locToLineNo(converter, loc, beginFuncTy.getInput(3)));
2007 args.push_back(locToFilename(converter, loc, beginFuncTy.getInput(1)));
2008 args.push_back(locToLineNo(converter, loc, beginFuncTy.getInput(2)));
2010 auto cookie = builder.create<fir::CallOp>(loc, beginFunc, args).getResult(0);
2011 genConditionHandlerCall(converter, loc, cookie, stmt.v, csi);
2031 getBeginDataTransferFunc(mlir::Location loc, fir::FirOpBuilder &builder,
2040 loc, builder);
2042 loc, builder);
2045 return getIORuntimeFunc<mkIOKey(BeginInternalListInput)>(loc,
2047 return getIORuntimeFunc<mkIOKey(BeginInternalFormattedInput)>(loc,
2051 return getIORuntimeFunc<mkIOKey(BeginExternalListInput)>(loc, builder);
2052 return getIORuntimeFunc<mkIOKey(BeginExternalFormattedInput)>(loc,
2055 return getIORuntimeFunc<mkIOKey(BeginUnformattedInput)>(loc, builder);
2062 loc, builder);
2064 loc, builder);
2067 return getIORuntimeFunc<mkIOKey(BeginInternalListOutput)>(loc,
2069 return getIORuntimeFunc<mkIOKey(BeginInternalFormattedOutput)>(loc,
2073 return getIORuntimeFunc<mkIOKey(BeginExternalListOutput)>(loc, builder);
2074 return getIORuntimeFunc<mkIOKey(BeginExternalFormattedOutput)>(loc,
2077 return getIORuntimeFunc<mkIOKey(BeginUnformattedOutput)>(loc, builder);
2085 Fortran::lower::AbstractConverter &converter, mlir::Location loc,
2095 getFormat(converter, loc, stmt, ioFuncTy.getInput(ioArgs.size()),
2104 builder.createNullConstant(loc, ioFuncTy.getInput(ioArgs.size())));
2109 builder.createNullConstant(loc, ioFuncTy.getInput(ioArgs.size())));
2111 builder.createNullConstant(loc, ioFuncTy.getInput(ioArgs.size())));
2113 builder.createConvert(loc, ioFuncTy.getInput(ioArgs.size()), address));
2119 mlir::Value desc = builder.createBox(loc, *descRef);
2121 builder.createConvert(loc, ioFuncTy.getInput(ioArgs.size()), desc));
2124 getBuffer(converter, loc, stmt, ioFuncTy.getInput(ioArgs.size()),
2131 getDefaultScratch(builder, loc, ioFuncTy.getInput(ioArgs.size())));
2133 getDefaultScratchLen(builder, loc, ioFuncTy.getInput(ioArgs.size())));
2136 ioArgs.push_back(getIOUnit(converter, loc, stmt,
2143 loc, builder.getIntegerAttr(ioFuncTy.getInput(ioArgs.size()),
2148 locToFilename(converter, loc, ioFuncTy.getInput(ioArgs.size())));
2150 locToLineNo(converter, loc, ioFuncTy.getInput(ioArgs.size())));
2159 mlir::Location loc = converter.getCurrentLocation();
2164 isInternal ? maybeGetInternalIODescriptor(converter, loc, stmt, stmtCtx)
2177 csi = lowerErrorSpec(converter, loc, stmt.controls);
2182 loc, builder, isFormatted, isList || isNml, isInternal,
2188 ioArgs, converter, loc, stmt, ioFunc.getFunctionType(), isFormatted,
2191 builder.create<fir::CallOp>(loc, ioFunc, ioArgs).getResult(0);
2196 genConditionHandlerCall(converter, loc, cookie, stmt.controls, csi);
2197 threadSpecs(converter, loc, cookie, stmt.controls,
2205 getIORuntimeFunc<mkIOKey(InputNamelist)>(loc, builder),
2214 getIORuntimeFunc<mkIOKey(OutputNamelist)>(loc, builder),
2236 genIOGetVar<mkIOKey(GetSize)>(converter, loc, cookie, *size);
2239 genIOGetVar<mkIOKey(GetAsynchronousId)>(converter, loc, cookie, *idVar);
2243 mlir::Value result = genEndIO(converter, loc, cookie, csi, stmtCtx);
2289 mlir::Location loc, mlir::Value cookie,
2298 Fortran::lower::AbstractConverter &converter, mlir::Location loc,
2308 getIORuntimeFunc<mkIOKey(InquireCharacter)>(loc, builder);
2312 fir::ExtendedValue str = converter.genExprAddr(loc, varExpr, stmtCtx);
2314 builder.createConvert(loc, specFuncTy.getInput(0), cookie),
2316 loc, specFuncTy.getInput(1),
2321 builder.createConvert(loc, specFuncTy.getInput(2), fir::getBase(str)),
2322 builder.createConvert(loc, specFuncTy.getInput(3), fir::getLen(str))};
2323 return builder.create<fir::CallOp>(loc, specFunc, args).getResult(0);
2328 Fortran::lower::AbstractConverter &converter, mlir::Location loc,
2338 getIORuntimeFunc<mkIOKey(InquireInteger64)>(loc, builder);
2342 mlir::Value addr = fir::getBase(converter.genExprAddr(loc, varExpr, stmtCtx));
2345 fir::emitFatalError(loc,
2349 mlir::Value kind = builder.createIntegerConstant(loc, idxTy, width / 8);
2351 builder.createConvert(loc, specFuncTy.getInput(0), cookie),
2353 loc, specFuncTy.getInput(1),
2358 builder.createConvert(loc, specFuncTy.getInput(2), addr),
2359 builder.createConvert(loc, specFuncTy.getInput(3), kind)};
2360 return builder.create<fir::CallOp>(loc, specFunc, args).getResult(0);
2365 Fortran::lower::AbstractConverter &converter, mlir::Location loc,
2375 pendId ? getIORuntimeFunc<mkIOKey(InquirePendingId)>(loc, builder)
2376 : getIORuntimeFunc<mkIOKey(InquireLogical)>(loc, builder);
2379 loc,
2385 builder.createConvert(loc, specFuncTy.getInput(0), cookie)};
2387 args.push_back(builder.createConvert(loc, specFuncTy.getInput(1), idExpr));
2390 loc, specFuncTy.getInput(1),
2394 args.push_back(builder.createConvert(loc, specFuncTy.getInput(2), addr));
2395 auto call = builder.create<fir::CallOp>(loc, specFunc, args);
2396 boolRefToLogical(loc, builder, addr);
2403 lowerIdExpr(Fortran::lower::AbstractConverter &converter, mlir::Location loc,
2411 loc, Fortran::semantics::GetExpr(idExpr), stmtCtx));
2421 mlir::Location loc, mlir::Value cookie,
2426 mlir::Value idExpr = lowerIdExpr(converter, loc, ispecs, stmtCtx);
2428 makeNextConditionalOn(builder, loc, checkResult, ok);
2430 return genInquireSpec(converter, loc, cookie,
2442 mlir::Location loc = converter.getCurrentLocation();
2456 list ? lowerErrorSpec(converter, loc, *list) : ConditionSpecInfo{};
2461 beginFunc = getIORuntimeFunc<mkIOKey(BeginInquireUnit)>(loc, builder);
2463 mlir::Value unit = genIOUnitNumber(converter, loc, exprPair.first,
2465 beginArgs = {unit, locToFilename(converter, loc, beginFuncTy.getInput(1)),
2466 locToLineNo(converter, loc, beginFuncTy.getInput(2))};
2469 beginFunc = getIORuntimeFunc<mkIOKey(BeginInquireFile)>(loc, builder);
2472 converter.genExprAddr(loc, exprPair.first, stmtCtx);
2474 builder.createConvert(loc, beginFuncTy.getInput(0), fir::getBase(file)),
2475 builder.createConvert(loc, beginFuncTy.getInput(1), fir::getLen(file)),
2476 locToFilename(converter, loc, beginFuncTy.getInput(2)),
2477 locToLineNo(converter, loc, beginFuncTy.getInput(3))};
2483 beginFunc = getIORuntimeFunc<mkIOKey(BeginInquireIoLength)>(loc, builder);
2485 beginArgs = {locToFilename(converter, loc, beginFuncTy.getInput(0)),
2486 locToLineNo(converter, loc, beginFuncTy.getInput(1))};
2488 builder.create<fir::CallOp>(loc, beginFunc, beginArgs).getResult(0);
2497 fir::getBase(converter.genExprAddr(loc, ioLengthVar, stmtCtx));
2502 loc, getIORuntimeFunc<mkIOKey(GetIoLength)>(loc, builder), args)
2505 builder.createConvert(loc, converter.genType(*ioLengthVar), length);
2506 builder.create<fir::StoreOp>(loc, length1, ioLengthVarAddr);
2507 return genEndIO(converter, loc, cookie, csi, stmtCtx);
2513 builder.create<fir::CallOp>(loc, beginFunc, beginArgs).getResult(0);
2514 genConditionHandlerCall(converter, loc, cookie, *list, csi);
2518 threadInquire(converter, loc, cookie, *list, csi.hasErrorConditionSpec(), ok,
2522 return genEndIO(converter, loc, cookie, csi, stmtCtx);