Index: flang/lib/Lower/CharacterExpr.cpp =================================================================== --- flang/lib/Lower/CharacterExpr.cpp +++ flang/lib/Lower/CharacterExpr.cpp @@ -352,8 +352,7 @@ auto blank = createBlankConstantCode(getCharacterType(str)); mlir::Value lastChar = builder.create(loc, len, one); - auto iterWhile = builder.create( - loc, lastChar, zero, minusOne, trueVal, lastChar); + fir::IterWhileOp iterWhile; auto insPt = builder.saveInsertionPoint(); builder.setInsertionPointToStart(iterWhile.getBody()); auto index = iterWhile.getInductionVar(); Index: flang/lib/Lower/ComplexExpr.cpp =================================================================== --- flang/lib/Lower/ComplexExpr.cpp +++ flang/lib/Lower/ComplexExpr.cpp @@ -16,7 +16,7 @@ mlir::Type Fortran::lower::ComplexExprHelper::getComplexPartType(mlir::Type complexType) { return Fortran::lower::convertReal( - builder.getContext(), complexType.cast().getFKind()); + builder.getContext(), complexType.cast().getFKind()); } mlir::Type @@ -27,7 +27,7 @@ mlir::Value Fortran::lower::ComplexExprHelper::createComplex(fir::KindTy kind, mlir::Value real, mlir::Value imag) { - auto complexTy = fir::CplxType::get(builder.getContext(), kind); + auto complexTy = fir::ComplexType::get(builder.getContext(), kind); mlir::Value und = builder.create(loc, complexTy); return insert(insert(und, real), imag); } Index: flang/lib/Lower/ConvertType.cpp =================================================================== --- flang/lib/Lower/ConvertType.cpp +++ flang/lib/Lower/ConvertType.cpp @@ -155,9 +155,6 @@ mlir::Type genFIRType(mlir::MLIRContext *context, int KIND) { - if (Fortran::evaluate::IsValidKindOfIntrinsicType( - Fortran::common::TypeCategory::Character, KIND)) - return fir::CharacterType::get(context, KIND); return {}; } @@ -167,7 +164,7 @@ int KIND) { if (Fortran::evaluate::IsValidKindOfIntrinsicType( Fortran::common::TypeCategory::Complex, KIND)) - return fir::CplxType::get(context, KIND); + return fir::ComplexType::get(context, KIND); return {}; } Index: flang/lib/Lower/DoLoopHelper.cpp =================================================================== --- flang/lib/Lower/DoLoopHelper.cpp +++ flang/lib/Lower/DoLoopHelper.cpp @@ -19,7 +19,7 @@ auto ubi = builder.convertToIndexType(loc, ub); assert(step && "step must be an actual Value"); auto inc = builder.convertToIndexType(loc, step); - auto loop = builder.create(loc, lbi, ubi, inc); + fir::DoLoopOp loop; auto insertPt = builder.saveInsertionPoint(); builder.setInsertionPointToStart(loop.getBody()); auto index = loop.getInductionVar(); Index: flang/lib/Lower/FIRBuilder.cpp =================================================================== --- flang/lib/Lower/FIRBuilder.cpp +++ flang/lib/Lower/FIRBuilder.cpp @@ -149,7 +149,7 @@ auto eleTy = helper.getComplexPartType(toTy); auto cast = createConvert(loc, eleTy, val); llvm::APFloat zero{ - kindMap.getFloatSemantics(toTy.cast().getFKind()), 0}; + kindMap.getFloatSemantics(toTy.cast().getFKind()), 0}; auto imag = createRealConstant(loc, eleTy, zero); return helper.createComplex(toTy, cast, imag); } Index: flang/lib/Lower/IO.cpp =================================================================== --- flang/lib/Lower/IO.cpp +++ flang/lib/Lower/IO.cpp @@ -178,11 +178,11 @@ // loop scope. That is done in genIoLoop, but it is enabled here. auto whereOp = inIterWhileLoop - ? builder.create(loc, builder.getI1Type(), ok, true) - : builder.create(loc, ok, /*withOtherwise=*/false); + ? builder.create(loc, builder.getI1Type(), ok, true) + : builder.create(loc, ok, /*withOtherwise=*/false); if (!insertPt.isSet()) insertPt = builder.saveInsertionPoint(); - builder.setInsertionPointToStart(&whereOp.whereRegion().front()); + builder.setInsertionPointToStart(&whereOp.thenRegion().front()); } template @@ -202,7 +202,7 @@ return ty.getWidth() <= 32 ? getIORuntimeFunc(loc, builder) : getIORuntimeFunc(loc, builder); - if (auto ty = type.dyn_cast()) + if (auto ty = type.dyn_cast()) return ty.getFKind() <= 4 ? getIORuntimeFunc(loc, builder) : getIORuntimeFunc(loc, builder); @@ -274,7 +274,7 @@ return ty.getWidth() <= 32 ? getIORuntimeFunc(loc, builder) : getIORuntimeFunc(loc, builder); - if (auto ty = type.dyn_cast()) + if (auto ty = type.dyn_cast()) return ty.getFKind() <= 4 ? getIORuntimeFunc(loc, builder) : getIORuntimeFunc(loc, builder); @@ -314,7 +314,7 @@ auto argType = inputFunc.getType().getInput(1); auto originalItemAddr = itemAddr; mlir::Type complexPartType; - if (itemType.isa()) + if (itemType.isa()) complexPartType = builder.getRefType( Fortran::lower::ComplexExprHelper{builder, loc}.getComplexPartType( itemType)); @@ -386,8 +386,7 @@ }; if (!checkResult) { // No I/O call result checks - the loop is a fir.do_loop op. - auto loopOp = - builder.create(loc, lowerValue, upperValue, stepValue); + fir::DoLoopOp loopOp; builder.setInsertionPointToStart(loopOp.getBody()); auto lcv = builder.createConvert(loc, converter.genType(loopSym), loopOp.getInductionVar()); @@ -411,13 +410,13 @@ auto falseValue = builder.createIntegerConstant(loc, builder.getI1Type(), 0); genItemList(ioImpliedDo, true); // Unwind nested I/O call scopes, filling in true and false ResultOp's. - for (auto *op = builder.getBlock()->getParentOp(); isa(op); + for (auto *op = builder.getBlock()->getParentOp(); isa(op); op = op->getBlock()->getParentOp()) { - auto whereOp = dyn_cast(op); - auto *lastOp = &whereOp.whereRegion().front().back(); + auto whereOp = dyn_cast(op); + auto *lastOp = &whereOp.thenRegion().front().back(); builder.setInsertionPointAfter(lastOp); builder.create(loc, lastOp->getResult(0)); // runtime result - builder.setInsertionPointToStart(&whereOp.otherRegion().front()); + builder.setInsertionPointToStart(&whereOp.elseRegion().front()); builder.create(loc, falseValue); // known false result } builder.restoreInsertionPoint(insertPt); @@ -489,8 +488,7 @@ text = text.drop_front(text.find('(')); text = text.take_front(text.rfind(')') + 1); auto &builder = converter.getFirOpBuilder(); - auto lit = builder.createStringLit( - loc, /*FIXME*/ fir::CharacterType::get(builder.getContext(), 1), text); + mlir::Value lit; auto data = Fortran::lower::CharacterExprHelper{builder, loc}.materializeCharacter( lit); Index: flang/lib/Lower/IntrinsicCall.cpp =================================================================== --- flang/lib/Lower/IntrinsicCall.cpp +++ flang/lib/Lower/IntrinsicCall.cpp @@ -439,7 +439,7 @@ // - or use evaluate/type.h if (auto r{t.dyn_cast()}) return r.getFKind() * 4; - if (auto cplx{t.dyn_cast()}) + if (auto cplx{t.dyn_cast()}) return cplx.getFKind() * 4; llvm_unreachable("not a floating-point type"); } @@ -459,8 +459,8 @@ ? Conversion::Narrow : Conversion::Extend; } - if (auto fromCplxTy{from.dyn_cast()}) { - if (auto toCplxTy{to.dyn_cast()}) { + if (auto fromCplxTy{from.dyn_cast()}) { + if (auto toCplxTy{to.dyn_cast()}) { return getFloatingPointWidth(fromCplxTy) > getFloatingPointWidth(toCplxTy) ? Conversion::Narrow @@ -1084,8 +1084,7 @@ auto arg = args[0]; Fortran::lower::CharacterExprHelper helper{builder, loc}; auto dataAndLen = helper.createUnboxChar(arg); - auto charType = fir::CharacterType::get( - builder.getContext(), helper.getCharacterKind(arg.getType())); + fir::CharacterType charType; auto refType = builder.getRefType(charType); auto charAddr = builder.createConvert(loc, refType, dataAndLen.first); auto charVal = builder.create(loc, charType, charAddr); Index: flang/lib/Lower/Mangler.cpp =================================================================== --- flang/lib/Lower/Mangler.cpp +++ flang/lib/Lower/Mangler.cpp @@ -134,7 +134,7 @@ if (auto i{t.dyn_cast()}) { return "i" + std::to_string(i.getWidth()); } - if (auto cplx{t.dyn_cast()}) { + if (auto cplx{t.dyn_cast()}) { return "z" + std::to_string(cplx.getFKind()); } if (auto real{t.dyn_cast()}) {