diff --git a/flang/lib/Lower/Allocatable.cpp b/flang/lib/Lower/Allocatable.cpp --- a/flang/lib/Lower/Allocatable.cpp +++ b/flang/lib/Lower/Allocatable.cpp @@ -127,7 +127,7 @@ llvm::SmallVector args{box.getAddr(), dimIndex, lowerBound, upperBound}; llvm::SmallVector operands; - for (auto [fst, snd] : llvm::zip(args, callee.getType().getInputs())) + for (auto [fst, snd] : llvm::zip(args, callee.getFunctionType().getInputs())) operands.emplace_back(builder.createConvert(loc, snd, fst)); builder.create(loc, callee, operands); } @@ -144,7 +144,7 @@ loc, builder) : fir::runtime::getRuntimeFunc( loc, builder); - llvm::ArrayRef inputTypes = callee.getType().getInputs(); + llvm::ArrayRef inputTypes = callee.getFunctionType().getInputs(); if (inputTypes.size() != 5) fir::emitFatalError( loc, "AllocatableInitCharacter runtime interface not as expected"); @@ -175,7 +175,7 @@ box.getAddr(), errorManager.hasStat, errorManager.errMsgAddr, errorManager.sourceFile, errorManager.sourceLine}; llvm::SmallVector operands; - for (auto [fst, snd] : llvm::zip(args, callee.getType().getInputs())) + for (auto [fst, snd] : llvm::zip(args, callee.getFunctionType().getInputs())) operands.emplace_back(builder.createConvert(loc, snd, fst)); return builder.create(loc, callee, operands).getResult(0); } @@ -197,7 +197,7 @@ boxAddress, errorManager.hasStat, errorManager.errMsgAddr, errorManager.sourceFile, errorManager.sourceLine}; llvm::SmallVector operands; - for (auto [fst, snd] : llvm::zip(args, callee.getType().getInputs())) + for (auto [fst, snd] : llvm::zip(args, callee.getFunctionType().getInputs())) operands.emplace_back(builder.createConvert(loc, snd, fst)); return builder.create(loc, callee, operands).getResult(0); } diff --git a/flang/lib/Lower/ConvertExpr.cpp b/flang/lib/Lower/ConvertExpr.cpp --- a/flang/lib/Lower/ConvertExpr.cpp +++ b/flang/lib/Lower/ConvertExpr.cpp @@ -2050,15 +2050,17 @@ auto stackSaveFn = fir::factory::getLlvmStackSave(builder); auto stackSaveSymbol = bldr->getSymbolRefAttr(stackSaveFn.getName()); mlir::Value sp = - bldr->create(loc, stackSaveFn.getType().getResults(), - stackSaveSymbol, mlir::ValueRange{}) + bldr->create( + loc, stackSaveFn.getFunctionType().getResults(), + stackSaveSymbol, mlir::ValueRange{}) .getResult(0); stmtCtx.attachCleanup([bldr, loc, sp]() { auto stackRestoreFn = fir::factory::getLlvmStackRestore(*bldr); auto stackRestoreSymbol = bldr->getSymbolRefAttr(stackRestoreFn.getName()); - bldr->create(loc, stackRestoreFn.getType().getResults(), - stackRestoreSymbol, mlir::ValueRange{sp}); + bldr->create( + loc, stackRestoreFn.getFunctionType().getResults(), + stackRestoreSymbol, mlir::ValueRange{sp}); }); } mlir::Value temp = @@ -2107,7 +2109,7 @@ mlir::SymbolRefAttr funcSymbolAttr; bool addHostAssociations = false; if (!funcPointer) { - mlir::FunctionType funcOpType = caller.getFuncOp().getType(); + mlir::FunctionType funcOpType = caller.getFuncOp().getFunctionType(); mlir::SymbolRefAttr symbolAttr = builder.getSymbolRefAttr(caller.getMangledName()); if (callSiteType.getNumResults() == funcOpType.getNumResults() && @@ -2149,7 +2151,7 @@ } mlir::FunctionType funcType = - funcPointer ? callSiteType : caller.getFuncOp().getType(); + funcPointer ? callSiteType : caller.getFuncOp().getFunctionType(); llvm::SmallVector operands; // First operand of indirect call is the function pointer. Cast it to // required function type for the call to handle procedures that have a @@ -2970,8 +2972,8 @@ return builder.createConvert(loc, argType, from); }; assert(func.getNumArguments() == 2); - mlir::Type lhsType = func.getType().getInput(0); - mlir::Type rhsType = func.getType().getInput(1); + mlir::Type lhsType = func.getFunctionType().getInput(0); + mlir::Type rhsType = func.getFunctionType().getInput(1); mlir::Value lhsArg = prepareUserDefinedArg(builder, loc, lhs, lhsType); mlir::Value rhsArg = prepareUserDefinedArg(builder, loc, rhs, rhsType); builder.create(loc, func, mlir::ValueRange{lhsArg, rhsArg}); @@ -4901,7 +4903,7 @@ /// Get the function signature of the LLVM memcpy intrinsic. mlir::FunctionType memcpyType() { - return fir::factory::getLlvmMemcpy(builder).getType(); + return fir::factory::getLlvmMemcpy(builder).getFunctionType(); } /// Create a call to the LLVM memcpy intrinsic. @@ -4910,7 +4912,7 @@ mlir::FuncOp memcpyFunc = fir::factory::getLlvmMemcpy(builder); mlir::SymbolRefAttr funcSymAttr = builder.getSymbolRefAttr(memcpyFunc.getName()); - mlir::FunctionType funcTy = memcpyFunc.getType(); + mlir::FunctionType funcTy = memcpyFunc.getFunctionType(); builder.create(loc, funcTy.getResults(), funcSymAttr, args); } @@ -4935,7 +4937,7 @@ mlir::Value byteSz = builder.create(loc, newSz, eleSz); mlir::SymbolRefAttr funcSymAttr = builder.getSymbolRefAttr(reallocFunc.getName()); - mlir::FunctionType funcTy = reallocFunc.getType(); + mlir::FunctionType funcTy = reallocFunc.getFunctionType(); auto newMem = builder.create( loc, funcTy.getResults(), funcSymAttr, llvm::ArrayRef{ diff --git a/flang/lib/Lower/HostAssociations.cpp b/flang/lib/Lower/HostAssociations.cpp --- a/flang/lib/Lower/HostAssociations.cpp +++ b/flang/lib/Lower/HostAssociations.cpp @@ -515,8 +515,8 @@ mlir::Location loc = converter.getCurrentLocation(); mlir::FuncOp func = builder.getFunction(); mlir::Value tupleArg; - for (auto [ty, arg] : llvm::reverse( - llvm::zip(func.getType().getInputs(), func.front().getArguments()))) + for (auto [ty, arg] : llvm::reverse(llvm::zip( + func.getFunctionType().getInputs(), func.front().getArguments()))) if (ty == argTy) { tupleArg = arg; break; diff --git a/flang/lib/Lower/IO.cpp b/flang/lib/Lower/IO.cpp --- a/flang/lib/Lower/IO.cpp +++ b/flang/lib/Lower/IO.cpp @@ -91,15 +91,14 @@ #ifdef __SIZEOF_INT128__ mkIOKey(OutputInteger128), #endif - mkIOKey(InputInteger), - mkIOKey(OutputReal32), mkIOKey(InputReal32), mkIOKey(OutputReal64), - mkIOKey(InputReal64), mkIOKey(OutputComplex32), mkIOKey(InputComplex32), - mkIOKey(OutputComplex64), mkIOKey(InputComplex64), mkIOKey(OutputAscii), - mkIOKey(InputAscii), mkIOKey(OutputLogical), mkIOKey(InputLogical), - mkIOKey(SetAccess), mkIOKey(SetAction), mkIOKey(SetAsynchronous), - mkIOKey(SetCarriagecontrol), mkIOKey(SetEncoding), mkIOKey(SetForm), - mkIOKey(SetPosition), mkIOKey(SetRecl), mkIOKey(SetStatus), - mkIOKey(SetFile), mkIOKey(GetNewUnit), mkIOKey(GetSize), + mkIOKey(InputInteger), mkIOKey(OutputReal32), mkIOKey(InputReal32), + mkIOKey(OutputReal64), mkIOKey(InputReal64), mkIOKey(OutputComplex32), + mkIOKey(InputComplex32), mkIOKey(OutputComplex64), mkIOKey(InputComplex64), + mkIOKey(OutputAscii), mkIOKey(InputAscii), mkIOKey(OutputLogical), + mkIOKey(InputLogical), mkIOKey(SetAccess), mkIOKey(SetAction), + mkIOKey(SetAsynchronous), mkIOKey(SetCarriagecontrol), mkIOKey(SetEncoding), + mkIOKey(SetForm), mkIOKey(SetPosition), mkIOKey(SetRecl), + mkIOKey(SetStatus), mkIOKey(SetFile), mkIOKey(GetNewUnit), mkIOKey(GetSize), mkIOKey(GetIoLength), mkIOKey(GetIoMsg), mkIOKey(InquireCharacter), mkIOKey(InquireLogical), mkIOKey(InquirePendingId), mkIOKey(InquireInteger64), mkIOKey(EndIoStatement)> @@ -188,9 +187,9 @@ loc, getIoMsg, mlir::ValueRange{ cookie, - builder.createConvert(loc, getIoMsg.getType().getInput(1), + builder.createConvert(loc, getIoMsg.getFunctionType().getInput(1), fir::getBase(ioMsgVar)), - builder.createConvert(loc, getIoMsg.getType().getInput(2), + builder.createConvert(loc, getIoMsg.getFunctionType().getInput(2), fir::getLen(ioMsgVar))}); } mlir::FuncOp endIoStatement = @@ -395,7 +394,7 @@ fir::FirOpBuilder &builder = converter.getFirOpBuilder(); mlir::Location loc = converter.getCurrentLocation(); makeNextConditionalOn(builder, loc, checkResult, ok); - mlir::Type argType = funcOp.getType().getInput(1); + mlir::Type argType = funcOp.getFunctionType().getInput(1); mlir::Value groupAddr = getNamelistGroup(converter, symbol, stmtCtx); groupAddr = builder.createConvert(loc, argType, groupAddr); llvm::SmallVector args = {cookie, groupAddr}; @@ -480,7 +479,7 @@ fir::emitFatalError(loc, "internal error: could not get evaluate::Expr"); mlir::Type itemTy = converter.genType(*expr); mlir::FuncOp outputFunc = getOutputFunc(loc, builder, itemTy, isFormatted); - mlir::Type argType = outputFunc.getType().getInput(1); + mlir::Type argType = outputFunc.getFunctionType().getInput(1); assert((isFormatted || argType.isa()) && "expect descriptor for unformatted IO runtime"); llvm::SmallVector outputFuncArgs = {cookie}; @@ -496,9 +495,9 @@ llvm::report_fatal_error( "internal error: scalar character not in CharBox"); outputFuncArgs.push_back(builder.createConvert( - loc, outputFunc.getType().getInput(1), fir::getBase(exv))); + loc, outputFunc.getFunctionType().getInput(1), fir::getBase(exv))); outputFuncArgs.push_back(builder.createConvert( - loc, outputFunc.getType().getInput(2), fir::getLen(exv))); + loc, outputFunc.getFunctionType().getInput(2), fir::getLen(exv))); } else { fir::ExtendedValue itemBox = converter.genExprValue(expr, stmtCtx, loc); mlir::Value itemValue = fir::getBase(itemBox); @@ -573,7 +572,7 @@ mlir::FuncOp inputFunc, mlir::Value cookie, const fir::ExtendedValue &item) { - mlir::Type argType = inputFunc.getType().getInput(1); + mlir::Type argType = inputFunc.getFunctionType().getInput(1); llvm::SmallVector inputFuncArgs = {cookie}; if (argType.isa()) { mlir::Value box = fir::getBase(item); @@ -586,8 +585,8 @@ fir::factory::CharacterExprHelper charHelper{builder, loc}; if (charHelper.isCharacterScalar(itemTy)) { mlir::Value len = fir::getLen(item); - inputFuncArgs.push_back( - builder.createConvert(loc, inputFunc.getType().getInput(2), len)); + inputFuncArgs.push_back(builder.createConvert( + loc, inputFunc.getFunctionType().getInput(2), len)); } else if (itemTy.isa()) { inputFuncArgs.push_back(builder.create( loc, builder.getI32IntegerAttr( @@ -627,7 +626,8 @@ Fortran::lower::genVectorSubscriptBox(loc, converter, stmtCtx, *expr); mlir::FuncOp inputFunc = getInputFunc( loc, builder, vectorSubscriptBox.getElementType(), isFormatted); - const bool mustBox = inputFunc.getType().getInput(1).isa(); + const bool mustBox = + inputFunc.getFunctionType().getInput(1).isa(); if (!checkResult) { auto elementalGenerator = [&](const fir::ExtendedValue &element) { createIoRuntimeCallForItem(loc, builder, inputFunc, cookie, @@ -651,7 +651,7 @@ } mlir::Type itemTy = converter.genType(*expr); mlir::FuncOp inputFunc = getInputFunc(loc, builder, itemTy, isFormatted); - auto itemExv = inputFunc.getType().getInput(1).isa() + auto itemExv = inputFunc.getFunctionType().getInput(1).isa() ? converter.genExprBox(*expr, stmtCtx, loc) : converter.genExprAddr(expr, stmtCtx, loc); ok = createIoRuntimeCallForItem(loc, builder, inputFunc, cookie, itemExv); @@ -871,7 +871,7 @@ Fortran::lower::StatementContext localStatementCtx; fir::FirOpBuilder &builder = converter.getFirOpBuilder(); mlir::FuncOp ioFunc = getIORuntimeFunc(loc, builder); - mlir::FunctionType ioFuncTy = ioFunc.getType(); + mlir::FunctionType ioFuncTy = ioFunc.getFunctionType(); mlir::Value expr = fir::getBase(converter.genExprValue( Fortran::semantics::GetExpr(spec.v), localStatementCtx, loc)); mlir::Value val = builder.createConvert(loc, ioFuncTy.getInput(1), expr); @@ -888,7 +888,7 @@ Fortran::lower::StatementContext localStatementCtx; fir::FirOpBuilder &builder = converter.getFirOpBuilder(); mlir::FuncOp ioFunc = getIORuntimeFunc(loc, builder); - mlir::FunctionType ioFuncTy = ioFunc.getType(); + mlir::FunctionType ioFuncTy = ioFunc.getFunctionType(); std::tuple tup = lowerStringLit(converter, loc, localStatementCtx, spec, ioFuncTy.getInput(1), ioFuncTy.getInput(2)); @@ -920,7 +920,7 @@ fir::FirOpBuilder &builder = converter.getFirOpBuilder(); // has an extra KIND argument mlir::FuncOp ioFunc = getIORuntimeFunc(loc, builder); - mlir::FunctionType ioFuncTy = ioFunc.getType(); + mlir::FunctionType ioFuncTy = ioFunc.getFunctionType(); std::tuple tup = lowerStringLit(converter, loc, localStatementCtx, spec, ioFuncTy.getInput(1), ioFuncTy.getInput(2)); @@ -981,7 +981,7 @@ TODO(loc, "DISPOSE not part of the runtime::io interface"); } Fortran::lower::StatementContext localStatementCtx; - mlir::FunctionType ioFuncTy = ioFunc.getType(); + mlir::FunctionType ioFuncTy = ioFunc.getFunctionType(); std::tuple tup = lowerStringLit(converter, loc, localStatementCtx, std::get(spec.t), @@ -1035,7 +1035,7 @@ break; } Fortran::lower::StatementContext localStatementCtx; - mlir::FunctionType ioFuncTy = ioFunc.getType(); + mlir::FunctionType ioFuncTy = ioFunc.getFunctionType(); std::tuple tup = lowerStringLit(converter, loc, localStatementCtx, std::get(spec.t), @@ -1203,7 +1203,7 @@ fir::FirOpBuilder &builder = converter.getFirOpBuilder(); mlir::FuncOp enableHandlers = getIORuntimeFunc(loc, builder); - mlir::Type boolType = enableHandlers.getType().getInput(1); + mlir::Type boolType = enableHandlers.getFunctionType().getInput(1); auto boolValue = [&](bool specifierIsPresent) { return builder.create( loc, builder.getIntegerAttr(boolType, specifierIsPresent)); @@ -1558,7 +1558,7 @@ Fortran::lower::StatementContext stmtCtx; mlir::Location loc = converter.getCurrentLocation(); mlir::FuncOp beginFunc = getIORuntimeFunc(loc, builder); - mlir::FunctionType beginFuncTy = beginFunc.getType(); + mlir::FunctionType beginFuncTy = beginFunc.getFunctionType(); mlir::Value unit = fir::getBase(converter.genExprValue( getExpr(stmt), stmtCtx, loc)); mlir::Value un = builder.createConvert(loc, beginFuncTy.getInput(0), unit); @@ -1611,7 +1611,7 @@ Fortran::lower::StatementContext stmtCtx; fir::FirOpBuilder &builder = converter.getFirOpBuilder(); mlir::FuncOp ioFunc = getIORuntimeFunc(loc, builder); - mlir::FunctionType ioFuncTy = ioFunc.getType(); + mlir::FunctionType ioFuncTy = ioFunc.getFunctionType(); const auto *var = Fortran::semantics::GetExpr(newunit->v); mlir::Value addr = builder.createConvert( loc, ioFuncTy.getInput(1), @@ -1635,7 +1635,7 @@ bool hasNewunitSpec = false; if (hasSpec(stmt)) { beginFunc = getIORuntimeFunc(loc, builder); - mlir::FunctionType beginFuncTy = beginFunc.getType(); + mlir::FunctionType beginFuncTy = beginFunc.getFunctionType(); mlir::Value unit = fir::getBase(converter.genExprValue( getExpr(stmt), stmtCtx, loc)); beginArgs.push_back( @@ -1646,7 +1646,7 @@ hasNewunitSpec = hasSpec(stmt); assert(hasNewunitSpec && "missing unit specifier"); beginFunc = getIORuntimeFunc(loc, builder); - mlir::FunctionType beginFuncTy = beginFunc.getType(); + mlir::FunctionType beginFuncTy = beginFunc.getFunctionType(); beginArgs.push_back(locToFilename(converter, loc, beginFuncTy.getInput(0))); beginArgs.push_back(locToLineNo(converter, loc, beginFuncTy.getInput(1))); } @@ -1679,7 +1679,7 @@ mlir::FuncOp beginFunc = hasId ? getIORuntimeFunc(loc, builder) : getIORuntimeFunc(loc, builder); - mlir::FunctionType beginFuncTy = beginFunc.getType(); + mlir::FunctionType beginFuncTy = beginFunc.getFunctionType(); mlir::Value unit = fir::getBase(converter.genExprValue( getExpr(stmt), stmtCtx, loc)); mlir::Value un = builder.createConvert(loc, beginFuncTy.getInput(0), unit); @@ -1849,7 +1849,7 @@ isInternalWithDesc, isAsync); llvm::SmallVector ioArgs; genBeginDataTransferCallArgs( - ioArgs, converter, loc, stmt, ioFunc.getType(), isFormatted, + ioArgs, converter, loc, stmt, ioFunc.getFunctionType(), isFormatted, isList || isNml, isInternal, isAsync, descRef, stmtCtx); mlir::Value cookie = builder.create(loc, ioFunc, ioArgs).getResult(0); @@ -1962,7 +1962,7 @@ fir::FirOpBuilder &builder = converter.getFirOpBuilder(); mlir::FuncOp specFunc = getIORuntimeFunc(loc, builder); - mlir::FunctionType specFuncTy = specFunc.getType(); + mlir::FunctionType specFuncTy = specFunc.getFunctionType(); const auto *varExpr = Fortran::semantics::GetExpr( std::get(var.t)); fir::ExtendedValue str = converter.genExprAddr(varExpr, stmtCtx, loc); @@ -1992,7 +1992,7 @@ fir::FirOpBuilder &builder = converter.getFirOpBuilder(); mlir::FuncOp specFunc = getIORuntimeFunc(loc, builder); - mlir::FunctionType specFuncTy = specFunc.getType(); + mlir::FunctionType specFuncTy = specFunc.getFunctionType(); const auto *varExpr = Fortran::semantics::GetExpr( std::get(var.t)); mlir::Value addr = fir::getBase(converter.genExprAddr(varExpr, stmtCtx, loc)); @@ -2030,7 +2030,7 @@ mlir::FuncOp specFunc = pendId ? getIORuntimeFunc(loc, builder) : getIORuntimeFunc(loc, builder); - mlir::FunctionType specFuncTy = specFunc.getType(); + mlir::FunctionType specFuncTy = specFunc.getFunctionType(); mlir::Value addr = fir::getBase(converter.genExprAddr( Fortran::semantics::GetExpr( std::get(loc, builder); - mlir::FunctionType beginFuncTy = beginFunc.getType(); + mlir::FunctionType beginFuncTy = beginFunc.getFunctionType(); beginArgs = {builder.createConvert(loc, beginFuncTy.getInput(0), fir::getBase(converter.genExprValue( exprPair.first, stmtCtx, loc))), @@ -2121,7 +2121,7 @@ } else if (inquireFileName()) { // Inquire by file -- FILE=file-name-expr. beginFunc = getIORuntimeFunc(loc, builder); - mlir::FunctionType beginFuncTy = beginFunc.getType(); + mlir::FunctionType beginFuncTy = beginFunc.getFunctionType(); fir::ExtendedValue file = converter.genExprAddr(exprPair.first, stmtCtx, loc); beginArgs = { @@ -2135,7 +2135,7 @@ std::get_if(&stmt.u); assert(ioLength && "must have an IOLENGTH specifier"); beginFunc = getIORuntimeFunc(loc, builder); - mlir::FunctionType beginFuncTy = beginFunc.getType(); + mlir::FunctionType beginFuncTy = beginFunc.getFunctionType(); beginArgs = {locToFilename(converter, loc, beginFuncTy.getInput(0)), locToLineNo(converter, loc, beginFuncTy.getInput(1))}; auto cookie = diff --git a/flang/lib/Lower/IntrinsicCall.cpp b/flang/lib/Lower/IntrinsicCall.cpp --- a/flang/lib/Lower/IntrinsicCall.cpp +++ b/flang/lib/Lower/IntrinsicCall.cpp @@ -1390,7 +1390,7 @@ } } else { // Wrapper was already built, ensure it has the sought type - assert(function.getType() == funcType && + assert(function.getFunctionType() == funcType && "conflict between intrinsic wrapper types"); } return function; @@ -1435,7 +1435,7 @@ fir::emitFatalError(loc, buffer); } - mlir::FunctionType actualFuncType = funcOp.getType(); + mlir::FunctionType actualFuncType = funcOp.getFunctionType(); assert(actualFuncType.getNumResults() == soughtFuncType.getNumResults() && actualFuncType.getNumInputs() == soughtFuncType.getNumInputs() && actualFuncType.getNumResults() == 1 && "Bad intrinsic match"); diff --git a/flang/lib/Lower/Runtime.cpp b/flang/lib/Lower/Runtime.cpp --- a/flang/lib/Lower/Runtime.cpp +++ b/flang/lib/Lower/Runtime.cpp @@ -58,7 +58,7 @@ [&](const fir::CharBoxValue &x) { callee = fir::runtime::getRuntimeFunc( loc, builder); - calleeType = callee.getType(); + calleeType = callee.getFunctionType(); // Creates a pair of operands for the CHARACTER and its LEN. operands.push_back( builder.createConvert(loc, calleeType.getInput(0), x.getAddr())); @@ -68,7 +68,7 @@ [&](fir::UnboxedValue x) { callee = fir::runtime::getRuntimeFunc( loc, builder); - calleeType = callee.getType(); + calleeType = callee.getFunctionType(); mlir::Value cast = builder.createConvert(loc, calleeType.getInput(0), x); operands.push_back(cast); @@ -79,7 +79,7 @@ }); } else { callee = fir::runtime::getRuntimeFunc(loc, builder); - calleeType = callee.getType(); + calleeType = callee.getFunctionType(); operands.push_back( builder.createIntegerConstant(loc, calleeType.getInput(0), 0)); } @@ -125,7 +125,7 @@ fir::runtime::getRuntimeFunc(loc, builder); llvm::SmallVector args = fir::runtime::createArguments( - builder, loc, func.getType(), pointer, target); + builder, loc, func.getFunctionType(), pointer, target); return builder.create(loc, func, args).getResult(0); } @@ -144,7 +144,7 @@ mlir::Value values) { mlir::FuncOp callee = fir::runtime::getRuntimeFunc(loc, builder); - mlir::FunctionType funcTy = callee.getType(); + mlir::FunctionType funcTy = callee.getFunctionType(); mlir::Type idxTy = builder.getIndexType(); mlir::Value zero; auto splitArg = [&](llvm::Optional arg, @@ -185,7 +185,7 @@ mlir::FuncOp func = fir::runtime::getRuntimeFunc(loc, builder); llvm::SmallVector args = fir::runtime::createArguments( - builder, loc, func.getType(), repeatable, imageDistinct); + builder, loc, func.getFunctionType(), repeatable, imageDistinct); builder.create(loc, func, args); } @@ -193,7 +193,7 @@ mlir::Location loc, mlir::Value harvest) { mlir::FuncOp func = fir::runtime::getRuntimeFunc(loc, builder); - mlir::FunctionType funcTy = func.getType(); + mlir::FunctionType funcTy = func.getFunctionType(); mlir::Value sourceFile = fir::factory::locationToFilename(builder, loc); mlir::Value sourceLine = fir::factory::locationToLineNo(builder, loc, funcTy.getInput(2)); @@ -226,7 +226,7 @@ default: llvm::report_fatal_error("invalid RANDOM_SEED argument index"); } - mlir::FunctionType funcTy = func.getType(); + mlir::FunctionType funcTy = func.getFunctionType(); mlir::Value sourceFile = fir::factory::locationToFilename(builder, loc); mlir::Value sourceLine = fir::factory::locationToLineNo(builder, loc, funcTy.getInput(2)); @@ -242,7 +242,7 @@ mlir::FuncOp func = fir::runtime::getRuntimeFunc(loc, builder); - mlir::FunctionType fTy = func.getType(); + mlir::FunctionType fTy = func.getFunctionType(); mlir::Value sourceFile = fir::factory::locationToFilename(builder, loc); mlir::Value sourceLine = fir::factory::locationToLineNo(builder, loc, fTy.getInput(4)); @@ -258,7 +258,7 @@ mlir::Value size) { mlir::FuncOp func = fir::runtime::getRuntimeFunc(loc, builder); - mlir::FunctionType fTy = func.getType(); + mlir::FunctionType fTy = func.getFunctionType(); mlir::Value sourceFile = fir::factory::locationToFilename(builder, loc); mlir::Value sourceLine = fir::factory::locationToLineNo(builder, loc, fTy.getInput(4)); @@ -274,7 +274,7 @@ mlir::Location loc, mlir::Value count, mlir::Value rate, mlir::Value max) { auto makeCall = [&](mlir::FuncOp func, mlir::Value arg) { - mlir::Type kindTy = func.getType().getInput(0); + mlir::Type kindTy = func.getFunctionType().getInput(0); int integerKind = 8; if (auto intType = fir::unwrapRefType(arg.getType()).dyn_cast()) diff --git a/flang/lib/Optimizer/Builder/Character.cpp b/flang/lib/Optimizer/Builder/Character.cpp --- a/flang/lib/Optimizer/Builder/Character.cpp +++ b/flang/lib/Optimizer/Builder/Character.cpp @@ -365,7 +365,7 @@ auto totalBytes = builder.create(loc, kindBytes, castCount); auto notVolatile = builder.createBool(loc, false); auto memmv = getLlvmMemmove(builder); - auto argTys = memmv.getType().getInputs(); + auto argTys = memmv.getFunctionType().getInputs(); auto toPtr = builder.createConvert(loc, argTys[0], toBuff); auto fromPtr = builder.createConvert(loc, argTys[1], fromBuff); builder.create( diff --git a/flang/lib/Optimizer/Builder/Runtime/Assign.cpp b/flang/lib/Optimizer/Builder/Runtime/Assign.cpp --- a/flang/lib/Optimizer/Builder/Runtime/Assign.cpp +++ b/flang/lib/Optimizer/Builder/Runtime/Assign.cpp @@ -16,7 +16,7 @@ void fir::runtime::genAssign(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value destBox, mlir::Value sourceBox) { auto func = fir::runtime::getRuntimeFunc(loc, builder); - auto fTy = func.getType(); + auto fTy = func.getFunctionType(); auto sourceFile = fir::factory::locationToFilename(builder, loc); auto sourceLine = fir::factory::locationToLineNo(builder, loc, fTy.getInput(3)); diff --git a/flang/lib/Optimizer/Builder/Runtime/Character.cpp b/flang/lib/Optimizer/Builder/Runtime/Character.cpp --- a/flang/lib/Optimizer/Builder/Runtime/Character.cpp +++ b/flang/lib/Optimizer/Builder/Runtime/Character.cpp @@ -26,7 +26,7 @@ mlir::Value string1Box, mlir::Value string2Box, mlir::Value backBox, mlir::Value kind) { - auto fTy = func.getType(); + auto fTy = func.getFunctionType(); auto sourceFile = fir::factory::locationToFilename(builder, loc); auto sourceLine = fir::factory::locationToLineNo(builder, loc, fTy.getInput(6)); @@ -66,7 +66,7 @@ mlir::Value resultBox, mlir::Value stringBox, mlir::FuncOp &adjustFunc) { - auto fTy = adjustFunc.getType(); + auto fTy = adjustFunc.getFunctionType(); auto sourceLine = fir::factory::locationToLineNo(builder, loc, fTy.getInput(3)); auto sourceFile = fir::factory::locationToFilename(builder, loc); @@ -111,7 +111,7 @@ default: llvm_unreachable("runtime does not support CHARACTER KIND"); } - auto fTy = beginFunc.getType(); + auto fTy = beginFunc.getFunctionType(); auto args = fir::runtime::createArguments(builder, loc, fTy, lhsBuff, rhsBuff, lhsLen, rhsLen); auto tri = builder.create(loc, beginFunc, args).getResult(0); @@ -161,7 +161,7 @@ fir::emitFatalError( loc, "unsupported CHARACTER kind value. Runtime expects 1, 2, or 4."); } - auto fTy = indexFunc.getType(); + auto fTy = indexFunc.getFunctionType(); auto args = fir::runtime::createArguments(builder, loc, fTy, stringBase, stringLen, substringBase, substringLen, back); @@ -182,7 +182,7 @@ mlir::Value resultBox, mlir::Value stringBox, mlir::Value ncopies) { auto repeatFunc = fir::runtime::getRuntimeFunc(loc, builder); - auto fTy = repeatFunc.getType(); + auto fTy = repeatFunc.getFunctionType(); auto sourceFile = fir::factory::locationToFilename(builder, loc); auto sourceLine = fir::factory::locationToLineNo(builder, loc, fTy.getInput(4)); @@ -195,7 +195,7 @@ void fir::runtime::genTrim(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value resultBox, mlir::Value stringBox) { auto trimFunc = fir::runtime::getRuntimeFunc(loc, builder); - auto fTy = trimFunc.getType(); + auto fTy = trimFunc.getFunctionType(); auto sourceFile = fir::factory::locationToFilename(builder, loc); auto sourceLine = fir::factory::locationToLineNo(builder, loc, fTy.getInput(3)); @@ -234,7 +234,7 @@ fir::emitFatalError( loc, "unsupported CHARACTER kind value. Runtime expects 1, 2, or 4."); } - auto fTy = func.getType(); + auto fTy = func.getFunctionType(); auto args = fir::runtime::createArguments(builder, loc, fTy, stringBase, stringLen, setBase, setLen, back); return builder.create(loc, func, args).getResult(0); @@ -271,7 +271,7 @@ fir::emitFatalError( loc, "unsupported CHARACTER kind value. Runtime expects 1, 2, or 4."); } - auto fTy = func.getType(); + auto fTy = func.getFunctionType(); auto args = fir::runtime::createArguments(builder, loc, fTy, stringBase, stringLen, setBase, setLen, back); return builder.create(loc, func, args).getResult(0); diff --git a/flang/lib/Optimizer/Builder/Runtime/Command.cpp b/flang/lib/Optimizer/Builder/Runtime/Command.cpp --- a/flang/lib/Optimizer/Builder/Runtime/Command.cpp +++ b/flang/lib/Optimizer/Builder/Runtime/Command.cpp @@ -47,7 +47,8 @@ // "STATUS" or "ERRMSG" parameters. if (!isAbsent(value) || status || !isAbsent(errmsg)) { llvm::SmallVector args = fir::runtime::createArguments( - builder, loc, argumentValueFunc.getType(), number, value, errmsg); + builder, loc, argumentValueFunc.getFunctionType(), number, value, + errmsg); valueResult = builder.create(loc, argumentValueFunc, args).getResult(0); } @@ -63,7 +64,7 @@ // Only run `ArgumentLength` intrinsic if "LENGTH" parameter provided if (length) { llvm::SmallVector args = fir::runtime::createArguments( - builder, loc, argumentLengthFunc.getType(), number); + builder, loc, argumentLengthFunc.getFunctionType(), number); mlir::Value result = builder.create(loc, argumentLengthFunc, args).getResult(0); const mlir::Value valueLoaded = builder.create(loc, length); @@ -89,7 +90,7 @@ if (!isAbsent(value) || status || !isAbsent(errmsg) || length) { sourceFile = fir::factory::locationToFilename(builder, loc); sourceLine = fir::factory::locationToLineNo( - builder, loc, valueFunc.getType().getInput(5)); + builder, loc, valueFunc.getFunctionType().getInput(5)); } mlir::Value valueResult; @@ -97,8 +98,8 @@ // "VALUE", "STATUS" or "ERRMSG" parameters. if (!isAbsent(value) || status || !isAbsent(errmsg)) { llvm::SmallVector args = fir::runtime::createArguments( - builder, loc, valueFunc.getType(), name, value, trimName, errmsg, - sourceFile, sourceLine); + builder, loc, valueFunc.getFunctionType(), name, value, trimName, + errmsg, sourceFile, sourceLine); valueResult = builder.create(loc, valueFunc, args).getResult(0); } @@ -113,9 +114,9 @@ // Only run `EnvVariableLength` intrinsic if "LENGTH" parameter provided if (length) { - llvm::SmallVector args = - fir::runtime::createArguments(builder, loc, lengthFunc.getType(), name, - trimName, sourceFile, sourceLine); + llvm::SmallVector args = fir::runtime::createArguments( + builder, loc, lengthFunc.getFunctionType(), name, trimName, sourceFile, + sourceLine); mlir::Value result = builder.create(loc, lengthFunc, args).getResult(0); const mlir::Value lengthLoaded = builder.create(loc, length); diff --git a/flang/lib/Optimizer/Builder/Runtime/Derived.cpp b/flang/lib/Optimizer/Builder/Runtime/Derived.cpp --- a/flang/lib/Optimizer/Builder/Runtime/Derived.cpp +++ b/flang/lib/Optimizer/Builder/Runtime/Derived.cpp @@ -17,7 +17,7 @@ mlir::Location loc, mlir::Value box) { auto func = fir::runtime::getRuntimeFunc(loc, builder); - auto fTy = func.getType(); + auto fTy = func.getFunctionType(); auto sourceFile = fir::factory::locationToFilename(builder, loc); auto sourceLine = fir::factory::locationToLineNo(builder, loc, fTy.getInput(2)); @@ -29,7 +29,7 @@ void fir::runtime::genDerivedTypeDestroy(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value box) { auto func = fir::runtime::getRuntimeFunc(loc, builder); - auto fTy = func.getType(); + auto fTy = func.getFunctionType(); auto args = fir::runtime::createArguments(builder, loc, fTy, box); builder.create(loc, func, args); } diff --git a/flang/lib/Optimizer/Builder/Runtime/Inquiry.cpp b/flang/lib/Optimizer/Builder/Runtime/Inquiry.cpp --- a/flang/lib/Optimizer/Builder/Runtime/Inquiry.cpp +++ b/flang/lib/Optimizer/Builder/Runtime/Inquiry.cpp @@ -19,7 +19,7 @@ mlir::Value dim) { mlir::FuncOp lboundFunc = fir::runtime::getRuntimeFunc(loc, builder); - auto fTy = lboundFunc.getType(); + auto fTy = lboundFunc.getFunctionType(); auto sourceFile = fir::factory::locationToFilename(builder, loc); auto sourceLine = fir::factory::locationToLineNo(builder, loc, fTy.getInput(3)); @@ -36,7 +36,7 @@ mlir::Value kind) { mlir::FuncOp uboundFunc = fir::runtime::getRuntimeFunc(loc, builder); - auto fTy = uboundFunc.getType(); + auto fTy = uboundFunc.getFunctionType(); auto sourceFile = fir::factory::locationToFilename(builder, loc); auto sourceLine = fir::factory::locationToLineNo(builder, loc, fTy.getInput(2)); @@ -52,7 +52,7 @@ mlir::Value dim) { mlir::FuncOp sizeFunc = fir::runtime::getRuntimeFunc(loc, builder); - auto fTy = sizeFunc.getType(); + auto fTy = sizeFunc.getFunctionType(); auto sourceFile = fir::factory::locationToFilename(builder, loc); auto sourceLine = fir::factory::locationToLineNo(builder, loc, fTy.getInput(3)); @@ -67,7 +67,7 @@ mlir::Location loc, mlir::Value array) { mlir::FuncOp sizeFunc = fir::runtime::getRuntimeFunc(loc, builder); - auto fTy = sizeFunc.getType(); + auto fTy = sizeFunc.getFunctionType(); auto sourceFile = fir::factory::locationToFilename(builder, loc); auto sourceLine = fir::factory::locationToLineNo(builder, loc, fTy.getInput(2)); diff --git a/flang/lib/Optimizer/Builder/Runtime/Numeric.cpp b/flang/lib/Optimizer/Builder/Runtime/Numeric.cpp --- a/flang/lib/Optimizer/Builder/Runtime/Numeric.cpp +++ b/flang/lib/Optimizer/Builder/Runtime/Numeric.cpp @@ -235,7 +235,7 @@ } else fir::emitFatalError(loc, "unsupported real kind in Exponent lowering"); - auto funcTy = func.getType(); + auto funcTy = func.getFunctionType(); llvm::SmallVector args = { builder.createConvert(loc, funcTy.getInput(0), x)}; @@ -259,7 +259,7 @@ else fir::emitFatalError(loc, "unsupported real kind in Fraction lowering"); - auto funcTy = func.getType(); + auto funcTy = func.getFunctionType(); llvm::SmallVector args = { builder.createConvert(loc, funcTy.getInput(0), x)}; @@ -284,7 +284,7 @@ else fir::emitFatalError(loc, "unsupported REAL kind in Nearest lowering"); - auto funcTy = func.getType(); + auto funcTy = func.getFunctionType(); mlir::Type sTy = s.getType(); mlir::Value zero = builder.createRealZeroConstant(loc, sTy); @@ -319,7 +319,7 @@ else fir::emitFatalError(loc, "unsupported real kind in RRSpacing lowering"); - auto funcTy = func.getType(); + auto funcTy = func.getFunctionType(); llvm::SmallVector args = { builder.createConvert(loc, funcTy.getInput(0), x)}; @@ -344,7 +344,7 @@ else fir::emitFatalError(loc, "unsupported REAL kind in Scale lowering"); - auto funcTy = func.getType(); + auto funcTy = func.getFunctionType(); auto args = fir::runtime::createArguments(builder, loc, funcTy, x, i); return builder.create(loc, func, args).getResult(0); @@ -368,7 +368,7 @@ else fir::emitFatalError(loc, "unsupported real kind in Fraction lowering"); - auto funcTy = func.getType(); + auto funcTy = func.getFunctionType(); auto args = fir::runtime::createArguments(builder, loc, funcTy, x, i); return builder.create(loc, func, args).getResult(0); @@ -391,7 +391,7 @@ else fir::emitFatalError(loc, "unsupported real kind in Spacing lowering"); - auto funcTy = func.getType(); + auto funcTy = func.getFunctionType(); llvm::SmallVector args = { builder.createConvert(loc, funcTy.getInput(0), x)}; diff --git a/flang/lib/Optimizer/Builder/Runtime/Ragged.cpp b/flang/lib/Optimizer/Builder/Runtime/Ragged.cpp --- a/flang/lib/Optimizer/Builder/Runtime/Ragged.cpp +++ b/flang/lib/Optimizer/Builder/Runtime/Ragged.cpp @@ -23,7 +23,7 @@ auto i64Ty = builder.getIntegerType(64); auto func = fir::runtime::getRuntimeFunc(loc, builder); - auto fTy = func.getType(); + auto fTy = func.getFunctionType(); auto i1Ty = builder.getIntegerType(1); fir::SequenceType::Shape shape = { static_cast(rank)}; @@ -61,7 +61,7 @@ mlir::Value header) { auto func = fir::runtime::getRuntimeFunc( loc, builder); - auto fTy = func.getType(); + auto fTy = func.getFunctionType(); auto args = fir::runtime::createArguments(builder, loc, fTy, header); builder.create(loc, func, args); } diff --git a/flang/lib/Optimizer/Builder/Runtime/Reduction.cpp b/flang/lib/Optimizer/Builder/Runtime/Reduction.cpp --- a/flang/lib/Optimizer/Builder/Runtime/Reduction.cpp +++ b/flang/lib/Optimizer/Builder/Runtime/Reduction.cpp @@ -374,7 +374,7 @@ mlir::Value genSpecial2Args(FN func, fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value maskBox, mlir::Value dim) { - auto fTy = func.getType(); + auto fTy = func.getFunctionType(); auto sourceFile = fir::factory::locationToFilename(builder, loc); auto sourceLine = fir::factory::locationToLineNo(builder, loc, fTy.getInput(2)); @@ -390,7 +390,7 @@ static void genReduction2Args(FN func, fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value resultBox, mlir::Value maskBox, mlir::Value dim) { - auto fTy = func.getType(); + auto fTy = func.getFunctionType(); auto sourceFile = fir::factory::locationToFilename(builder, loc); auto sourceLine = fir::factory::locationToLineNo(builder, loc, fTy.getInput(4)); @@ -407,7 +407,7 @@ mlir::Value arrayBox, mlir::Value dim, mlir::Value maskBox) { - auto fTy = func.getType(); + auto fTy = func.getFunctionType(); auto sourceFile = fir::factory::locationToFilename(builder, loc); auto sourceLine = fir::factory::locationToLineNo(builder, loc, fTy.getInput(4)); @@ -424,7 +424,7 @@ mlir::Location loc, mlir::Value resultBox, mlir::Value arrayBox, mlir::Value maskBox, mlir::Value kind, mlir::Value back) { - auto fTy = func.getType(); + auto fTy = func.getFunctionType(); auto sourceFile = fir::factory::locationToFilename(builder, loc); auto sourceLine = fir::factory::locationToLineNo(builder, loc, fTy.getInput(4)); @@ -441,7 +441,7 @@ genReduction5Args(FN func, fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value resultBox, mlir::Value arrayBox, mlir::Value dim, mlir::Value maskBox, mlir::Value kind, mlir::Value back) { - auto fTy = func.getType(); + auto fTy = func.getFunctionType(); auto sourceFile = fir::factory::locationToFilename(builder, loc); auto sourceLine = fir::factory::locationToLineNo(builder, loc, fTy.getInput(5)); @@ -503,7 +503,7 @@ mlir::Value resultBox, mlir::Value maskBox, mlir::Value dim, mlir::Value kind) { auto func = fir::runtime::getRuntimeFunc(loc, builder); - auto fTy = func.getType(); + auto fTy = func.getFunctionType(); auto sourceFile = fir::factory::locationToFilename(builder, loc); auto sourceLine = fir::factory::locationToLineNo(builder, loc, fTy.getInput(5)); @@ -571,7 +571,7 @@ else fir::emitFatalError(loc, "invalid type in Maxval lowering"); - auto fTy = func.getType(); + auto fTy = func.getFunctionType(); auto sourceFile = fir::factory::locationToFilename(builder, loc); auto sourceLine = fir::factory::locationToLineNo(builder, loc, fTy.getInput(2)); @@ -597,7 +597,7 @@ mlir::Value maskBox) { auto func = fir::runtime::getRuntimeFunc(loc, builder); - auto fTy = func.getType(); + auto fTy = func.getFunctionType(); auto sourceFile = fir::factory::locationToFilename(builder, loc); auto sourceLine = fir::factory::locationToLineNo(builder, loc, fTy.getInput(3)); @@ -644,7 +644,7 @@ mlir::Value maskBox) { auto func = fir::runtime::getRuntimeFunc(loc, builder); - auto fTy = func.getType(); + auto fTy = func.getFunctionType(); auto sourceFile = fir::factory::locationToFilename(builder, loc); auto sourceLine = fir::factory::locationToLineNo(builder, loc, fTy.getInput(3)); @@ -690,7 +690,7 @@ else fir::emitFatalError(loc, "invalid type in Minval lowering"); - auto fTy = func.getType(); + auto fTy = func.getFunctionType(); auto sourceFile = fir::factory::locationToFilename(builder, loc); auto sourceLine = fir::factory::locationToLineNo(builder, loc, fTy.getInput(2)); @@ -757,7 +757,7 @@ else fir::emitFatalError(loc, "invalid type in Product lowering"); - auto fTy = func.getType(); + auto fTy = func.getFunctionType(); auto sourceFile = fir::factory::locationToFilename(builder, loc); if (fir::isa_complex(eleTy)) { auto sourceLine = @@ -834,7 +834,7 @@ else fir::emitFatalError(loc, "invalid type in DotProduct lowering"); - auto fTy = func.getType(); + auto fTy = func.getFunctionType(); auto sourceFile = fir::factory::locationToFilename(builder, loc); if (fir::isa_complex(eleTy)) { @@ -907,7 +907,7 @@ else fir::emitFatalError(loc, "invalid type in Sum lowering"); - auto fTy = func.getType(); + auto fTy = func.getFunctionType(); auto sourceFile = fir::factory::locationToFilename(builder, loc); if (fir::isa_complex(eleTy)) { auto sourceLine = diff --git a/flang/lib/Optimizer/Builder/Runtime/Stop.cpp b/flang/lib/Optimizer/Builder/Runtime/Stop.cpp --- a/flang/lib/Optimizer/Builder/Runtime/Stop.cpp +++ b/flang/lib/Optimizer/Builder/Runtime/Stop.cpp @@ -17,8 +17,8 @@ void fir::runtime::genExit(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value status) { auto exitFunc = fir::runtime::getRuntimeFunc(loc, builder); - llvm::SmallVector args = - fir::runtime::createArguments(builder, loc, exitFunc.getType(), status); + llvm::SmallVector args = fir::runtime::createArguments( + builder, loc, exitFunc.getFunctionType(), status); builder.create(loc, exitFunc, args); } @@ -27,7 +27,7 @@ llvm::StringRef message) { mlir::FuncOp crashFunc = fir::runtime::getRuntimeFunc(loc, builder); - mlir::FunctionType funcTy = crashFunc.getType(); + mlir::FunctionType funcTy = crashFunc.getFunctionType(); mlir::Value msgVal = fir::getBase( fir::factory::createStringLiteral(builder, loc, message.str() + '\0')); mlir::Value sourceLine = diff --git a/flang/lib/Optimizer/Builder/Runtime/Transformational.cpp b/flang/lib/Optimizer/Builder/Runtime/Transformational.cpp --- a/flang/lib/Optimizer/Builder/Runtime/Transformational.cpp +++ b/flang/lib/Optimizer/Builder/Runtime/Transformational.cpp @@ -24,7 +24,7 @@ mlir::Value resultBox, mlir::Value arrayBox, mlir::Value shiftBox, mlir::Value dimBox) { auto cshiftFunc = fir::runtime::getRuntimeFunc(loc, builder); - auto fTy = cshiftFunc.getType(); + auto fTy = cshiftFunc.getFunctionType(); auto sourceFile = fir::factory::locationToFilename(builder, loc); auto sourceLine = fir::factory::locationToLineNo(builder, loc, fTy.getInput(5)); @@ -40,7 +40,7 @@ mlir::Value arrayBox, mlir::Value shiftBox) { auto cshiftFunc = fir::runtime::getRuntimeFunc(loc, builder); - auto fTy = cshiftFunc.getType(); + auto fTy = cshiftFunc.getFunctionType(); auto sourceFile = fir::factory::locationToFilename(builder, loc); auto sourceLine = @@ -57,7 +57,7 @@ mlir::Value dimBox) { auto eoshiftFunc = fir::runtime::getRuntimeFunc(loc, builder); - auto fTy = eoshiftFunc.getType(); + auto fTy = eoshiftFunc.getFunctionType(); auto sourceFile = fir::factory::locationToFilename(builder, loc); auto sourceLine = fir::factory::locationToLineNo(builder, loc, fTy.getInput(6)); @@ -74,7 +74,7 @@ mlir::Value boundBox) { auto eoshiftFunc = fir::runtime::getRuntimeFunc(loc, builder); - auto fTy = eoshiftFunc.getType(); + auto fTy = eoshiftFunc.getFunctionType(); auto sourceFile = fir::factory::locationToFilename(builder, loc); auto sourceLine = @@ -91,7 +91,7 @@ mlir::Value resultBox, mlir::Value matrixABox, mlir::Value matrixBBox) { auto func = fir::runtime::getRuntimeFunc(loc, builder); - auto fTy = func.getType(); + auto fTy = func.getFunctionType(); auto sourceFile = fir::factory::locationToFilename(builder, loc); auto sourceLine = fir::factory::locationToLineNo(builder, loc, fTy.getInput(4)); @@ -106,7 +106,7 @@ mlir::Value resultBox, mlir::Value arrayBox, mlir::Value maskBox, mlir::Value vectorBox) { auto packFunc = fir::runtime::getRuntimeFunc(loc, builder); - auto fTy = packFunc.getType(); + auto fTy = packFunc.getFunctionType(); auto sourceFile = fir::factory::locationToFilename(builder, loc); auto sourceLine = fir::factory::locationToLineNo(builder, loc, fTy.getInput(5)); @@ -122,7 +122,7 @@ mlir::Value shapeBox, mlir::Value padBox, mlir::Value orderBox) { auto func = fir::runtime::getRuntimeFunc(loc, builder); - auto fTy = func.getType(); + auto fTy = func.getFunctionType(); auto sourceFile = fir::factory::locationToFilename(builder, loc); auto sourceLine = fir::factory::locationToLineNo(builder, loc, fTy.getInput(6)); @@ -137,7 +137,7 @@ mlir::Value resultBox, mlir::Value sourceBox, mlir::Value dim, mlir::Value ncopies) { auto func = fir::runtime::getRuntimeFunc(loc, builder); - auto fTy = func.getType(); + auto fTy = func.getFunctionType(); auto sourceFile = fir::factory::locationToFilename(builder, loc); auto sourceLine = fir::factory::locationToLineNo(builder, loc, fTy.getInput(5)); @@ -151,7 +151,7 @@ void fir::runtime::genTranspose(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Value resultBox, mlir::Value sourceBox) { auto func = fir::runtime::getRuntimeFunc(loc, builder); - auto fTy = func.getType(); + auto fTy = func.getFunctionType(); auto sourceFile = fir::factory::locationToFilename(builder, loc); auto sourceLine = fir::factory::locationToLineNo(builder, loc, fTy.getInput(3)); @@ -165,7 +165,7 @@ mlir::Value resultBox, mlir::Value vectorBox, mlir::Value maskBox, mlir::Value fieldBox) { auto unpackFunc = fir::runtime::getRuntimeFunc(loc, builder); - auto fTy = unpackFunc.getType(); + auto fTy = unpackFunc.getFunctionType(); auto sourceFile = fir::factory::locationToFilename(builder, loc); auto sourceLine = fir::factory::locationToLineNo(builder, loc, fTy.getInput(5)); diff --git a/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp b/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp --- a/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp +++ b/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp @@ -454,7 +454,7 @@ /// Rewrite the signatures and body of the `FuncOp`s in the module for /// the immediately subsequent target code gen. void convertSignature(mlir::FuncOp func) { - auto funcTy = func.getType().cast(); + auto funcTy = func.getFunctionType().cast(); if (hasPortableSignature(funcTy)) return; llvm::SmallVector newResTys; @@ -543,7 +543,7 @@ // return ops as required. These fixups are done in place. auto loc = func.getLoc(); const auto fixupSize = fixups.size(); - const auto oldArgTys = func.getType().getInputs(); + const auto oldArgTys = func.getFunctionType().getInputs(); int offset = 0; for (std::remove_const_t i = 0; i < fixupSize; ++i) { const auto &fixup = fixups[i]; diff --git a/flang/lib/Optimizer/Dialect/FIROps.cpp b/flang/lib/Optimizer/Dialect/FIROps.cpp --- a/flang/lib/Optimizer/Dialect/FIROps.cpp +++ b/flang/lib/Optimizer/Dialect/FIROps.cpp @@ -669,7 +669,7 @@ mlir::FuncOp callee, mlir::ValueRange operands) { result.addOperands(operands); result.addAttribute(getCalleeAttrNameStr(), SymbolRefAttr::get(callee)); - result.addTypes(callee.getType().getResults()); + result.addTypes(callee.getFunctionType().getResults()); } void fir::CallOp::build(mlir::OpBuilder &builder, mlir::OperationState &result, diff --git a/flang/lib/Optimizer/Transforms/AbstractResult.cpp b/flang/lib/Optimizer/Transforms/AbstractResult.cpp --- a/flang/lib/Optimizer/Transforms/AbstractResult.cpp +++ b/flang/lib/Optimizer/Transforms/AbstractResult.cpp @@ -222,7 +222,7 @@ /*newArg=*/{}}; // Convert function type itself if it has an abstract result - auto funcTy = func.getType().cast(); + auto funcTy = func.getFunctionType().cast(); if (mustConvertCallOrFunc(funcTy)) { func.setType(getNewFunctionType(funcTy, options)); unsigned zero = 0; diff --git a/mlir/docs/Bindings/Python.md b/mlir/docs/Bindings/Python.md --- a/mlir/docs/Bindings/Python.md +++ b/mlir/docs/Bindings/Python.md @@ -661,7 +661,7 @@ # Operations can be created in a generic way. func = Operation.create( "func.func", results=[], operands=[], - attributes={"type":TypeAttr.get(FunctionType.get([], []))}, + attributes={"function_type":TypeAttr.get(FunctionType.get([], []))}, successors=None, regions=1) # The result will be downcasted to the concrete `OpView` subclass if # available. diff --git a/mlir/examples/toy/Ch2/include/toy/Ops.td b/mlir/examples/toy/Ch2/include/toy/Ops.td --- a/mlir/examples/toy/Ch2/include/toy/Ops.td +++ b/mlir/examples/toy/Ch2/include/toy/Ops.td @@ -135,7 +135,7 @@ let arguments = (ins SymbolNameAttr:$sym_name, - TypeAttrOf:$type + TypeAttrOf:$function_type ); let regions = (region AnyRegion:$body); @@ -149,10 +149,10 @@ //===------------------------------------------------------------------===// /// Returns the argument types of this function. - ArrayRef getArgumentTypes() { return getType().getInputs(); } + ArrayRef getArgumentTypes() { return getFunctionType().getInputs(); } /// Returns the result types of this function. - ArrayRef getResultTypes() { return getType().getResults(); } + ArrayRef getResultTypes() { return getFunctionType().getResults(); } }]; let hasCustomAssemblyFormat = 1; let skipDefaultBuilders = 1; diff --git a/mlir/examples/toy/Ch2/mlir/Dialect.cpp b/mlir/examples/toy/Ch2/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch2/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch2/mlir/Dialect.cpp @@ -252,7 +252,7 @@ return emitOpError() << "expects at most 1 return operand"; // The operand number and types must match the function signature. - const auto &results = function.getType().getResults(); + const auto &results = function.getFunctionType().getResults(); if (getNumOperands() != results.size()) return emitOpError() << "does not return the same number of values (" << getNumOperands() << ") as the enclosing function (" diff --git a/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp --- a/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp @@ -161,8 +161,8 @@ } else if (returnOp.hasOperand()) { // Otherwise, if this return operation has an operand then add a result to // the function. - function.setType(builder.getFunctionType(function.getType().getInputs(), - getType(VarType{}))); + function.setType(builder.getFunctionType( + function.getFunctionType().getInputs(), getType(VarType{}))); } return function; diff --git a/mlir/examples/toy/Ch3/include/toy/Ops.td b/mlir/examples/toy/Ch3/include/toy/Ops.td --- a/mlir/examples/toy/Ch3/include/toy/Ops.td +++ b/mlir/examples/toy/Ch3/include/toy/Ops.td @@ -134,7 +134,7 @@ let arguments = (ins SymbolNameAttr:$sym_name, - TypeAttrOf:$type + TypeAttrOf:$function_type ); let regions = (region AnyRegion:$body); @@ -148,10 +148,10 @@ //===------------------------------------------------------------------===// /// Returns the argument types of this function. - ArrayRef getArgumentTypes() { return getType().getInputs(); } + ArrayRef getArgumentTypes() { return getFunctionType().getInputs(); } /// Returns the result types of this function. - ArrayRef getResultTypes() { return getType().getResults(); } + ArrayRef getResultTypes() { return getFunctionType().getResults(); } }]; let hasCustomAssemblyFormat = 1; let skipDefaultBuilders = 1; diff --git a/mlir/examples/toy/Ch3/mlir/Dialect.cpp b/mlir/examples/toy/Ch3/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch3/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch3/mlir/Dialect.cpp @@ -252,7 +252,7 @@ return emitOpError() << "expects at most 1 return operand"; // The operand number and types must match the function signature. - const auto &results = function.getType().getResults(); + const auto &results = function.getFunctionType().getResults(); if (getNumOperands() != results.size()) return emitOpError() << "does not return the same number of values (" << getNumOperands() << ") as the enclosing function (" diff --git a/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp --- a/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp @@ -161,8 +161,8 @@ } else if (returnOp.hasOperand()) { // Otherwise, if this return operation has an operand then add a result to // the function. - function.setType(builder.getFunctionType(function.getType().getInputs(), - getType(VarType{}))); + function.setType(builder.getFunctionType( + function.getFunctionType().getInputs(), getType(VarType{}))); } return function; diff --git a/mlir/examples/toy/Ch4/include/toy/Ops.td b/mlir/examples/toy/Ch4/include/toy/Ops.td --- a/mlir/examples/toy/Ch4/include/toy/Ops.td +++ b/mlir/examples/toy/Ch4/include/toy/Ops.td @@ -164,7 +164,7 @@ let arguments = (ins SymbolNameAttr:$sym_name, - TypeAttrOf:$type + TypeAttrOf:$function_type ); let regions = (region AnyRegion:$body); @@ -178,10 +178,10 @@ //===------------------------------------------------------------------===// /// Returns the argument types of this function. - ArrayRef getArgumentTypes() { return getType().getInputs(); } + ArrayRef getArgumentTypes() { return getFunctionType().getInputs(); } /// Returns the result types of this function. - ArrayRef getResultTypes() { return getType().getResults(); } + ArrayRef getResultTypes() { return getFunctionType().getResults(); } }]; let hasCustomAssemblyFormat = 1; let skipDefaultBuilders = 1; diff --git a/mlir/examples/toy/Ch4/mlir/Dialect.cpp b/mlir/examples/toy/Ch4/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch4/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch4/mlir/Dialect.cpp @@ -303,7 +303,7 @@ /// Returns the results types that the callable region produces when /// executed. llvm::ArrayRef FuncOp::getCallableResults() { - return getType().getResults(); + return getFunctionType().getResults(); } //===----------------------------------------------------------------------===// @@ -364,7 +364,7 @@ return emitOpError() << "expects at most 1 return operand"; // The operand number and types must match the function signature. - const auto &results = function.getType().getResults(); + const auto &results = function.getFunctionType().getResults(); if (getNumOperands() != results.size()) return emitOpError() << "does not return the same number of values (" << getNumOperands() << ") as the enclosing function (" diff --git a/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp --- a/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp @@ -161,8 +161,8 @@ } else if (returnOp.hasOperand()) { // Otherwise, if this return operation has an operand then add a result to // the function. - function.setType(builder.getFunctionType(function.getType().getInputs(), - getType(VarType{}))); + function.setType(builder.getFunctionType( + function.getFunctionType().getInputs(), getType(VarType{}))); } // If this function isn't main, then set the visibility to private. diff --git a/mlir/examples/toy/Ch5/include/toy/Ops.td b/mlir/examples/toy/Ch5/include/toy/Ops.td --- a/mlir/examples/toy/Ch5/include/toy/Ops.td +++ b/mlir/examples/toy/Ch5/include/toy/Ops.td @@ -164,7 +164,7 @@ let arguments = (ins SymbolNameAttr:$sym_name, - TypeAttrOf:$type + TypeAttrOf:$function_type ); let regions = (region AnyRegion:$body); @@ -178,10 +178,10 @@ //===------------------------------------------------------------------===// /// Returns the argument types of this function. - ArrayRef getArgumentTypes() { return getType().getInputs(); } + ArrayRef getArgumentTypes() { return getFunctionType().getInputs(); } /// Returns the result types of this function. - ArrayRef getResultTypes() { return getType().getResults(); } + ArrayRef getResultTypes() { return getFunctionType().getResults(); } }]; let hasCustomAssemblyFormat = 1; let skipDefaultBuilders = 1; diff --git a/mlir/examples/toy/Ch5/mlir/Dialect.cpp b/mlir/examples/toy/Ch5/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch5/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch5/mlir/Dialect.cpp @@ -303,7 +303,7 @@ /// Returns the results types that the callable region produces when /// executed. llvm::ArrayRef FuncOp::getCallableResults() { - return getType().getResults(); + return getFunctionType().getResults(); } //===----------------------------------------------------------------------===// @@ -364,7 +364,7 @@ return emitOpError() << "expects at most 1 return operand"; // The operand number and types must match the function signature. - const auto &results = function.getType().getResults(); + const auto &results = function.getFunctionType().getResults(); if (getNumOperands() != results.size()) return emitOpError() << "does not return the same number of values (" << getNumOperands() << ") as the enclosing function (" diff --git a/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp --- a/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp @@ -214,15 +214,15 @@ return failure(); // Verify that the given main has no inputs and results. - if (op.getNumArguments() || op.getType().getNumResults()) { + if (op.getNumArguments() || op.getFunctionType().getNumResults()) { return rewriter.notifyMatchFailure(op, [](Diagnostic &diag) { diag << "expected 'main' to have 0 inputs and 0 results"; }); } // Create a new non-toy function, with the same region. - auto func = - rewriter.create(op.getLoc(), op.getName(), op.getType()); + auto func = rewriter.create(op.getLoc(), op.getName(), + op.getFunctionType()); rewriter.inlineRegionBefore(op.getRegion(), func.getBody(), func.end()); rewriter.eraseOp(op); return success(); diff --git a/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp --- a/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp @@ -161,8 +161,8 @@ } else if (returnOp.hasOperand()) { // Otherwise, if this return operation has an operand then add a result to // the function. - function.setType(builder.getFunctionType(function.getType().getInputs(), - getType(VarType{}))); + function.setType(builder.getFunctionType( + function.getFunctionType().getInputs(), getType(VarType{}))); } // If this function isn't main, then set the visibility to private. diff --git a/mlir/examples/toy/Ch6/include/toy/Ops.td b/mlir/examples/toy/Ch6/include/toy/Ops.td --- a/mlir/examples/toy/Ch6/include/toy/Ops.td +++ b/mlir/examples/toy/Ch6/include/toy/Ops.td @@ -164,7 +164,7 @@ let arguments = (ins SymbolNameAttr:$sym_name, - TypeAttrOf:$type + TypeAttrOf:$function_type ); let regions = (region AnyRegion:$body); @@ -178,10 +178,10 @@ //===------------------------------------------------------------------===// /// Returns the argument types of this function. - ArrayRef getArgumentTypes() { return getType().getInputs(); } + ArrayRef getArgumentTypes() { return getFunctionType().getInputs(); } /// Returns the result types of this function. - ArrayRef getResultTypes() { return getType().getResults(); } + ArrayRef getResultTypes() { return getFunctionType().getResults(); } }]; let hasCustomAssemblyFormat = 1; let skipDefaultBuilders = 1; diff --git a/mlir/examples/toy/Ch6/mlir/Dialect.cpp b/mlir/examples/toy/Ch6/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch6/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch6/mlir/Dialect.cpp @@ -303,7 +303,7 @@ /// Returns the results types that the callable region produces when /// executed. llvm::ArrayRef FuncOp::getCallableResults() { - return getType().getResults(); + return getFunctionType().getResults(); } //===----------------------------------------------------------------------===// @@ -364,7 +364,7 @@ return emitOpError() << "expects at most 1 return operand"; // The operand number and types must match the function signature. - const auto &results = function.getType().getResults(); + const auto &results = function.getFunctionType().getResults(); if (getNumOperands() != results.size()) return emitOpError() << "does not return the same number of values (" << getNumOperands() << ") as the enclosing function (" diff --git a/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp --- a/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp @@ -214,15 +214,15 @@ return failure(); // Verify that the given main has no inputs and results. - if (op.getNumArguments() || op.getType().getNumResults()) { + if (op.getNumArguments() || op.getFunctionType().getNumResults()) { return rewriter.notifyMatchFailure(op, [](Diagnostic &diag) { diag << "expected 'main' to have 0 inputs and 0 results"; }); } // Create a new non-toy function, with the same region. - auto func = - rewriter.create(op.getLoc(), op.getName(), op.getType()); + auto func = rewriter.create(op.getLoc(), op.getName(), + op.getFunctionType()); rewriter.inlineRegionBefore(op.getRegion(), func.getBody(), func.end()); rewriter.eraseOp(op); return success(); diff --git a/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp --- a/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp @@ -161,8 +161,8 @@ } else if (returnOp.hasOperand()) { // Otherwise, if this return operation has an operand then add a result to // the function. - function.setType(builder.getFunctionType(function.getType().getInputs(), - getType(VarType{}))); + function.setType(builder.getFunctionType( + function.getFunctionType().getInputs(), getType(VarType{}))); } // If this function isn't main, then set the visibility to private. diff --git a/mlir/examples/toy/Ch7/include/toy/Ops.td b/mlir/examples/toy/Ch7/include/toy/Ops.td --- a/mlir/examples/toy/Ch7/include/toy/Ops.td +++ b/mlir/examples/toy/Ch7/include/toy/Ops.td @@ -183,7 +183,7 @@ let arguments = (ins SymbolNameAttr:$sym_name, - TypeAttrOf:$type + TypeAttrOf:$function_type ); let regions = (region AnyRegion:$body); @@ -197,10 +197,10 @@ //===------------------------------------------------------------------===// /// Returns the argument types of this function. - ArrayRef getArgumentTypes() { return getType().getInputs(); } + ArrayRef getArgumentTypes() { return getFunctionType().getInputs(); } /// Returns the result types of this function. - ArrayRef getResultTypes() { return getType().getResults(); } + ArrayRef getResultTypes() { return getFunctionType().getResults(); } }]; let hasCustomAssemblyFormat = 1; let skipDefaultBuilders = 1; diff --git a/mlir/examples/toy/Ch7/mlir/Dialect.cpp b/mlir/examples/toy/Ch7/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch7/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch7/mlir/Dialect.cpp @@ -330,7 +330,7 @@ /// Returns the results types that the callable region produces when /// executed. llvm::ArrayRef FuncOp::getCallableResults() { - return getType().getResults(); + return getFunctionType().getResults(); } //===----------------------------------------------------------------------===// @@ -391,7 +391,7 @@ return emitOpError() << "expects at most 1 return operand"; // The operand number and types must match the function signature. - const auto &results = function.getType().getResults(); + const auto &results = function.getFunctionType().getResults(); if (getNumOperands() != results.size()) return emitOpError() << "does not return the same number of values (" << getNumOperands() << ") as the enclosing function (" diff --git a/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp --- a/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp @@ -214,15 +214,15 @@ return failure(); // Verify that the given main has no inputs and results. - if (op.getNumArguments() || op.getType().getNumResults()) { + if (op.getNumArguments() || op.getFunctionType().getNumResults()) { return rewriter.notifyMatchFailure(op, [](Diagnostic &diag) { diag << "expected 'main' to have 0 inputs and 0 results"; }); } // Create a new non-toy function, with the same region. - auto func = - rewriter.create(op.getLoc(), op.getName(), op.getType()); + auto func = rewriter.create(op.getLoc(), op.getName(), + op.getFunctionType()); rewriter.inlineRegionBefore(op.getRegion(), func.getBody(), func.end()); rewriter.eraseOp(op); return success(); diff --git a/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp --- a/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp @@ -216,8 +216,9 @@ } else if (returnOp.hasOperand()) { // Otherwise, if this return operation has an operand then add a result to // the function. - function.setType(builder.getFunctionType(function.getType().getInputs(), - *returnOp.operand_type_begin())); + function.setType( + builder.getFunctionType(function.getFunctionType().getInputs(), + *returnOp.operand_type_begin())); } // If this function isn't main, then set the visibility to private. @@ -519,7 +520,7 @@ } mlir::toy::FuncOp calledFunc = calledFuncIt->second; return builder.create( - location, calledFunc.getType().getResult(0), + location, calledFunc.getFunctionType().getResult(0), mlir::SymbolRefAttr::get(builder.getContext(), callee), operands); } diff --git a/mlir/include/mlir/Dialect/Func/IR/FuncOps.td b/mlir/include/mlir/Dialect/Func/IR/FuncOps.td --- a/mlir/include/mlir/Dialect/Func/IR/FuncOps.td +++ b/mlir/include/mlir/Dialect/Func/IR/FuncOps.td @@ -57,7 +57,7 @@ OpBuilder<(ins "FuncOp":$callee, CArg<"ValueRange", "{}">:$operands), [{ $_state.addOperands(operands); $_state.addAttribute("callee", SymbolRefAttr::get(callee)); - $_state.addTypes(callee.getType().getResults()); + $_state.addTypes(callee.getFunctionType().getResults()); }]>, OpBuilder<(ins "SymbolRefAttr":$callee, "TypeRange":$results, CArg<"ValueRange", "{}">:$operands), [{ @@ -250,7 +250,7 @@ }]; let arguments = (ins SymbolNameAttr:$sym_name, - TypeAttrOf:$type, + TypeAttrOf:$function_type, OptionalAttr:$sym_visibility); let regions = (region AnyRegion:$body); @@ -295,17 +295,17 @@ /// Returns the results types that the callable region produces when /// executed. - ArrayRef getCallableResults() { return getType().getResults(); } + ArrayRef getCallableResults() { return getFunctionType().getResults(); } //===------------------------------------------------------------------===// // FunctionOpInterface Methods //===------------------------------------------------------------------===// /// Returns the argument types of this function. - ArrayRef getArgumentTypes() { return getType().getInputs(); } + ArrayRef getArgumentTypes() { return getFunctionType().getInputs(); } /// Returns the result types of this function. - ArrayRef getResultTypes() { return getType().getResults(); } + ArrayRef getResultTypes() { return getFunctionType().getResults(); } //===------------------------------------------------------------------===// // SymbolOpInterface Methods diff --git a/mlir/include/mlir/Dialect/GPU/GPUOps.td b/mlir/include/mlir/Dialect/GPU/GPUOps.td --- a/mlir/include/mlir/Dialect/GPU/GPUOps.td +++ b/mlir/include/mlir/Dialect/GPU/GPUOps.td @@ -221,6 +221,7 @@ attribution. }]; + let arguments = (ins TypeAttrOf:$function_type); let regions = (region AnyRegion:$body); let skipDefaultBuilders = 1; @@ -250,7 +251,7 @@ /// the workgroup memory ArrayRef getWorkgroupAttributions() { auto begin = - std::next(getBody().args_begin(), getType().getNumInputs()); + std::next(getBody().args_begin(), getFunctionType().getNumInputs()); auto end = std::next(begin, getNumWorkgroupAttributions()); return {begin, end}; } @@ -261,7 +262,7 @@ /// Returns the number of buffers located in the private memory. unsigned getNumPrivateAttributions() { - return getBody().getNumArguments() - getType().getNumInputs() - + return getBody().getNumArguments() - getFunctionType().getNumInputs() - getNumWorkgroupAttributions(); } @@ -272,7 +273,7 @@ // memory. auto begin = std::next(getBody().args_begin(), - getType().getNumInputs() + getNumWorkgroupAttributions()); + getFunctionType().getNumInputs() + getNumWorkgroupAttributions()); return {begin, getBody().args_end()}; } @@ -287,16 +288,14 @@ } /// Returns the type of this function. - /// FIXME: We should drive this via the ODS `type` param. - FunctionType getType() { - return getTypeAttr().getValue().cast(); - } + /// FIXME: Remove when GPU uses prefixed accessors. + FunctionType getFunctionType() { return function_type(); } /// Returns the argument types of this function. - ArrayRef getArgumentTypes() { return getType().getInputs(); } + ArrayRef getArgumentTypes() { return getFunctionType().getInputs(); } /// Returns the result types of this function. - ArrayRef getResultTypes() { return getType().getResults(); } + ArrayRef getResultTypes() { return getFunctionType().getResults(); } /// Returns the keywords used in the custom syntax for this Op. static StringRef getWorkgroupKeyword() { return "workgroup"; } diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td @@ -80,6 +80,10 @@ "::mlir::LLVM::LLVMFunctionType>()">]>, "primitive LLVM type">; +// Type constraint accepting any LLVM function type. +def LLVM_FunctionType : Type()">, + "LLVM function type", "::mlir::LLVM::LLVMFunctionType">; + // Type constraint accepting any LLVM floating point type. def LLVM_AnyFloat : Type< CPred<"::mlir::LLVM::isCompatibleFloatingPointType($_self)">, diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td @@ -537,7 +537,7 @@ let builders = [ OpBuilder<(ins "LLVMFuncOp":$func, "ValueRange":$operands, CArg<"ArrayRef", "{}">:$attributes), [{ - Type resultType = func.getType().getReturnType(); + Type resultType = func.getFunctionType().getReturnType(); if (!resultType.isa()) $_state.addTypes(resultType); $_state.addAttribute("callee", SymbolRefAttr::get(func)); @@ -874,7 +874,7 @@ CArg<"ArrayRef", "{}">:$attrs), [{ build($_builder, $_state, - LLVM::LLVMPointerType::get(func.getType()), func.getName()); + LLVM::LLVMPointerType::get(func.getFunctionType()), func.getName()); $_state.addAttributes(attrs); }]> ]; @@ -1236,11 +1236,14 @@ ``` }]; - let arguments = (ins DefaultValuedAttr:$linkage, - UnitAttr:$dso_local, - OptionalAttr:$personality, - OptionalAttr:$garbageCollector, - OptionalAttr:$passthrough); + let arguments = (ins + TypeAttrOf:$function_type, + DefaultValuedAttr:$linkage, + UnitAttr:$dso_local, + OptionalAttr:$personality, + OptionalAttr:$garbageCollector, + OptionalAttr:$passthrough + ); let regions = (region AnyRegion:$body); @@ -1259,21 +1262,13 @@ // to match the signature of the function. Block *addEntryBlock(); - LLVMFunctionType getType() { - return getTypeAttr().getValue().cast(); - } - bool isVarArg() { return getType().isVarArg(); } + bool isVarArg() { return getFunctionType().isVarArg(); } /// Returns the argument types of this function. - ArrayRef getArgumentTypes() { return getType().getParams(); } + ArrayRef getArgumentTypes() { return getFunctionType().getParams(); } /// Returns the result types of this function. - ArrayRef getResultTypes() { return getType().getReturnTypes(); } - - /// Hook for FunctionOpInterface, called after verifying that the 'type' - /// attribute is present. This can check for preconditions of the - /// getNumArguments hook not failing. - LogicalResult verifyType(); + ArrayRef getResultTypes() { return getFunctionType().getReturnTypes(); } }]; let hasCustomAssemblyFormat = 1; diff --git a/mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td b/mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td --- a/mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td +++ b/mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td @@ -657,7 +657,7 @@ let arguments = (ins SymbolNameAttr:$sym_name, - TypeAttrOf:$type + TypeAttrOf:$function_type ); let regions = (region MinSizedRegion<1>:$body); @@ -673,10 +673,10 @@ //===------------------------------------------------------------------===// /// Returns the argument types of this function. - ArrayRef getArgumentTypes() { return getType().getInputs(); } + ArrayRef getArgumentTypes() { return getFunctionType().getInputs(); } /// Returns the result types of this function. - ArrayRef getResultTypes() { return getType().getResults(); } + ArrayRef getResultTypes() { return getFunctionType().getResults(); } }]; let hasCustomAssemblyFormat = 1; let skipDefaultBuilders = 1; diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVStructureOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVStructureOps.td --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVStructureOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVStructureOps.td @@ -287,7 +287,7 @@ }]; let arguments = (ins - TypeAttr:$type, + TypeAttrOf:$function_type, StrAttr:$sym_name, SPV_FunctionControlAttr:$function_control ); @@ -309,16 +309,14 @@ let extraClassDeclaration = [{ /// Returns the type of this function. - /// FIXME: We should drive this via the ODS `type` param. - FunctionType getType() { - return getTypeAttr().getValue().cast(); - } + /// FIXME: Remove when SPIRV uses prefixed accessors. + FunctionType getFunctionType() { return function_type(); } /// Returns the argument types of this function. - ArrayRef getArgumentTypes() { return getType().getInputs(); } + ArrayRef getArgumentTypes() { return getFunctionType().getInputs(); } /// Returns the result types of this function. - ArrayRef getResultTypes() { return getType().getResults(); } + ArrayRef getResultTypes() { return getFunctionType().getResults(); } /// Hook for FunctionOpInterface, called after verifying that the 'type' /// attribute is present and checks if it holds a function type. Ensures diff --git a/mlir/include/mlir/IR/FunctionInterfaces.h b/mlir/include/mlir/IR/FunctionInterfaces.h --- a/mlir/include/mlir/IR/FunctionInterfaces.h +++ b/mlir/include/mlir/IR/FunctionInterfaces.h @@ -26,7 +26,7 @@ namespace function_interface_impl { /// Return the name of the attribute used for function types. -inline StringRef getTypeAttrName() { return "type"; } +inline StringRef getTypeAttrName() { return "function_type"; } /// Return the name of the attribute used for function argument attributes. inline StringRef getArgDictAttrName() { return "arg_attrs"; } @@ -207,7 +207,7 @@ /// method on FunctionOpInterface::Trait. template LogicalResult verifyTrait(ConcreteOp op) { - if (!op.getTypeAttr()) + if (!op.getFunctionTypeAttr()) return op.emitOpError("requires a type attribute '") << function_interface_impl::getTypeAttrName() << '\''; diff --git a/mlir/include/mlir/IR/FunctionInterfaces.td b/mlir/include/mlir/IR/FunctionInterfaces.td --- a/mlir/include/mlir/IR/FunctionInterfaces.td +++ b/mlir/include/mlir/IR/FunctionInterfaces.td @@ -37,9 +37,8 @@ The function, aside from implementing the various interface methods, should have the following ODS arguments: - - `type` (required) + - `function_type` (required) * A TypeAttr that holds the signature type of the function. - * TODO: this field will soon be renamed to something less generic. - `arg_attrs` (optional) * An ArrayAttr of DictionaryAttr that contains attribute dictionaries @@ -73,7 +72,7 @@ "::mlir::Type", "cloneTypeWith", (ins "::mlir::TypeRange":$inputs, "::mlir::TypeRange":$results ), /*methodBody=*/[{}], /*defaultImplementation=*/[{ - return $_op.getType().clone(inputs, results); + return $_op.getFunctionType().clone(inputs, results); }]>, InterfaceMethod<[{ @@ -258,13 +257,13 @@ } /// Return the attribute containing the type of this function. - TypeAttr getTypeAttr() { + TypeAttr getFunctionTypeAttr() { return this->getOperation()->template getAttrOfType( getTypeAttrName()); } /// Return the type of this function. - Type getType() { return getTypeAttr().getValue(); } + Type getFunctionType() { return getFunctionTypeAttr().getValue(); } //===------------------------------------------------------------------===// // Argument and Result Handling diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -1269,7 +1269,7 @@ } class TypeAttrOf - : TypeAttrBase { + : TypeAttrBase { let constBuilderCall = "::mlir::TypeAttr::get($0)"; } diff --git a/mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp b/mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp --- a/mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp +++ b/mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp @@ -1042,8 +1042,9 @@ target.addIllegalDialect(); // Add dynamic legality constraints to apply conversions defined above. - target.addDynamicallyLegalOp( - [&](FuncOp op) { return converter.isSignatureLegal(op.getType()); }); + target.addDynamicallyLegalOp([&](FuncOp op) { + return converter.isSignatureLegal(op.getFunctionType()); + }); target.addDynamicallyLegalOp([&](func::ReturnOp op) { return converter.isLegal(op.getOperandTypes()); }); diff --git a/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp b/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp --- a/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp +++ b/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp @@ -127,7 +127,7 @@ static void wrapForExternalCallers(OpBuilder &rewriter, Location loc, LLVMTypeConverter &typeConverter, FuncOp funcOp, LLVM::LLVMFuncOp newFuncOp) { - auto type = funcOp.getType(); + auto type = funcOp.getFunctionType(); SmallVector attributes; filterFuncAttributes(funcOp->getAttrs(), /*filterArgAndResAttrs=*/false, attributes); @@ -190,7 +190,7 @@ Type wrapperType; bool resultIsNowArg; std::tie(wrapperType, resultIsNowArg) = - typeConverter.convertFunctionTypeCWrapper(funcOp.getType()); + typeConverter.convertFunctionTypeCWrapper(funcOp.getFunctionType()); // This conversion can only fail if it could not convert one of the argument // types. But since it has been applied to a non-wrapper function before, it // should have failed earlier and not reach this point at all. @@ -210,7 +210,7 @@ builder.setInsertionPointToStart(newFuncOp.addEntryBlock()); // Get a ValueRange containing arguments. - FunctionType type = funcOp.getType(); + FunctionType type = funcOp.getFunctionType(); SmallVector args; args.reserve(type.getNumInputs()); ValueRange wrapperArgsRange(newFuncOp.getArguments()); @@ -288,7 +288,8 @@ auto varargsAttr = funcOp->getAttrOfType("func.varargs"); TypeConverter::SignatureConversion result(funcOp.getNumArguments()); auto llvmType = getTypeConverter()->convertFunctionSignature( - funcOp.getType(), varargsAttr && varargsAttr.getValue(), result); + funcOp.getFunctionType(), varargsAttr && varargsAttr.getValue(), + result); if (!llvmType) return nullptr; @@ -401,7 +402,7 @@ // Store the type of memref-typed arguments before the conversion so that we // can promote them to MemRef descriptor at the beginning of the function. SmallVector oldArgTypes = - llvm::to_vector<8>(funcOp.getType().getInputs()); + llvm::to_vector<8>(funcOp.getFunctionType().getInputs()); auto newFuncOp = convertFuncOpToLLVMFuncOp(funcOp, rewriter); if (!newFuncOp) diff --git a/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp b/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp --- a/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp +++ b/mlir/lib/Conversion/GPUCommon/GPUOpsLowering.cpp @@ -41,7 +41,7 @@ } // Rewrite the original GPU function to an LLVM function. - auto funcType = typeConverter->convertType(gpuFuncOp.getType()) + auto funcType = typeConverter->convertType(gpuFuncOp.getFunctionType()) .template cast() .getElementType(); @@ -49,7 +49,7 @@ TypeConverter::SignatureConversion signatureConversion( gpuFuncOp.front().getNumArguments()); getTypeConverter()->convertFunctionSignature( - gpuFuncOp.getType(), /*isVariadic=*/false, signatureConversion); + gpuFuncOp.getFunctionType(), /*isVariadic=*/false, signatureConversion); // Create the new function operation. Only copy those attributes that are // not specific to function modeling. diff --git a/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp b/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp --- a/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp +++ b/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp @@ -184,7 +184,7 @@ ConversionPatternRewriter &rewriter, spirv::EntryPointABIAttr entryPointInfo, ArrayRef argABIInfo) { - auto fnType = funcOp.getType(); + auto fnType = funcOp.getFunctionType(); if (fnType.getNumResults()) { funcOp.emitError("SPIR-V lowering only supports entry functions" "with no return values right now"); @@ -201,7 +201,8 @@ // LowerABIAttributesPass. TypeConverter::SignatureConversion signatureConverter(fnType.getNumInputs()); { - for (const auto &argType : enumerate(funcOp.getType().getInputs())) { + for (const auto &argType : + enumerate(funcOp.getFunctionType().getInputs())) { auto convertedType = typeConverter.convertType(argType.value()); signatureConverter.addInputs(argType.index(), convertedType); } diff --git a/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.cpp b/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.cpp --- a/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.cpp +++ b/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.cpp @@ -38,7 +38,7 @@ // Allow builtin ops. target->addLegalOp(); target->addDynamicallyLegalOp([&](FuncOp op) { - return typeConverter.isSignatureLegal(op.getType()) && + return typeConverter.isSignatureLegal(op.getFunctionType()) && typeConverter.isLegal(&op.getBody()); }); diff --git a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp --- a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp +++ b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp @@ -1291,11 +1291,11 @@ // Convert function signature. At the moment LLVMType converter is enough // for currently supported types. - auto funcType = funcOp.getType(); + auto funcType = funcOp.getFunctionType(); TypeConverter::SignatureConversion signatureConverter( funcType.getNumInputs()); auto llvmType = typeConverter.convertFunctionSignature( - funcOp.getType(), /*isVariadic=*/false, signatureConverter); + funcType, /*isVariadic=*/false, signatureConverter); if (!llvmType) return failure(); diff --git a/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp b/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp --- a/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp +++ b/mlir/lib/Dialect/Async/Transforms/AsyncParallelFor.cpp @@ -463,7 +463,8 @@ ModuleOp module = computeFunc.func->getParentOfType(); - ArrayRef computeFuncInputTypes = computeFunc.func.getType().getInputs(); + ArrayRef computeFuncInputTypes = + computeFunc.func.getFunctionType().getInputs(); // Compared to the parallel compute function async dispatch function takes // additional !async.group argument. Also instead of a single `blockIndex` it diff --git a/mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp b/mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp --- a/mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp +++ b/mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp @@ -614,7 +614,8 @@ resultTypes.reserve(func.getCallableResults().size()); llvm::transform(func.getCallableResults(), std::back_inserter(resultTypes), [](Type type) { return ValueType::get(type); }); - func.setType(FunctionType::get(ctx, func.getType().getInputs(), resultTypes)); + func.setType( + FunctionType::get(ctx, func.getFunctionType().getInputs(), resultTypes)); func.insertResult(0, TokenType::get(ctx), {}); for (Block &block : func.getBlocks()) { Operation *terminator = block.getTerminator(); diff --git a/mlir/lib/Dialect/Bufferization/Transforms/BufferResultsToOutParams.cpp b/mlir/lib/Dialect/Bufferization/Transforms/BufferResultsToOutParams.cpp --- a/mlir/lib/Dialect/Bufferization/Transforms/BufferResultsToOutParams.cpp +++ b/mlir/lib/Dialect/Bufferization/Transforms/BufferResultsToOutParams.cpp @@ -20,7 +20,7 @@ // Any args appended to the entry block are added to `appendedEntryArgs`. static void updateFuncOp(FuncOp func, SmallVectorImpl &appendedEntryArgs) { - auto functionType = func.getType(); + auto functionType = func.getFunctionType(); // Collect information about the results will become appended arguments. SmallVector erasedResultTypes; diff --git a/mlir/lib/Dialect/Func/IR/FuncOps.cpp b/mlir/lib/Dialect/Func/IR/FuncOps.cpp --- a/mlir/lib/Dialect/Func/IR/FuncOps.cpp +++ b/mlir/lib/Dialect/Func/IR/FuncOps.cpp @@ -134,7 +134,7 @@ << "' does not reference a valid function"; // Verify that the operand and result types match the callee. - auto fnType = fn.getType(); + auto fnType = fn.getFunctionType(); if (fnType.getNumInputs() != getNumOperands()) return emitOpError("incorrect number of operands for callee"); @@ -196,7 +196,7 @@ << "'"; // Check that the referenced function has the correct type. - if (fn.getType() != type) + if (fn.getFunctionType() != type) return emitOpError("reference to function with mismatched type"); return success(); @@ -304,7 +304,7 @@ // the function by specifying them in the mapper. If so, we don't add the // argument to the input type vector. if (!isExternal()) { - FunctionType oldType = getType(); + FunctionType oldType = getFunctionType(); unsigned oldNumArgs = oldType.getNumInputs(); SmallVector newInputs; @@ -347,7 +347,7 @@ auto function = cast((*this)->getParentOp()); // The operand number and types must match the function signature. - const auto &results = function.getType().getResults(); + const auto &results = function.getFunctionType().getResults(); if (getNumOperands() != results.size()) return emitOpError("has ") << getNumOperands() << " operands, but enclosing function (@" diff --git a/mlir/lib/Dialect/Func/Transforms/DecomposeCallGraphTypes.cpp b/mlir/lib/Dialect/Func/Transforms/DecomposeCallGraphTypes.cpp --- a/mlir/lib/Dialect/Func/Transforms/DecomposeCallGraphTypes.cpp +++ b/mlir/lib/Dialect/Func/Transforms/DecomposeCallGraphTypes.cpp @@ -64,7 +64,7 @@ LogicalResult matchAndRewrite(FuncOp op, OpAdaptor adaptor, ConversionPatternRewriter &rewriter) const final { - auto functionType = op.getType(); + auto functionType = op.getFunctionType(); // Convert function arguments using the provided TypeConverter. TypeConverter::SignatureConversion conversion(functionType.getNumInputs()); diff --git a/mlir/lib/Dialect/Func/Transforms/FuncBufferize.cpp b/mlir/lib/Dialect/Func/Transforms/FuncBufferize.cpp --- a/mlir/lib/Dialect/Func/Transforms/FuncBufferize.cpp +++ b/mlir/lib/Dialect/Func/Transforms/FuncBufferize.cpp @@ -35,7 +35,7 @@ populateFunctionOpInterfaceTypeConversionPattern(patterns, typeConverter); target.addDynamicallyLegalOp([&](FuncOp op) { - return typeConverter.isSignatureLegal(op.getType()) && + return typeConverter.isSignatureLegal(op.getFunctionType()) && typeConverter.isLegal(&op.getBody()); }); populateCallOpTypeConversionPattern(patterns, typeConverter); diff --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp --- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp +++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp @@ -261,7 +261,7 @@ << actualNumArguments << " kernel operands but expected " << expectedNumArguments; - auto functionType = kernelGPUFunction.getType(); + auto functionType = kernelGPUFunction.getFunctionType(); for (unsigned i = 0; i < expectedNumArguments; ++i) { if (launchOp.getKernelOperand(i).getType() != functionType.getInput(i)) { return launchOp.emitOpError("type of function argument ") @@ -723,8 +723,8 @@ auto attr = (*this)->getAttrOfType(attrName); (*this)->setAttr(attrName, IntegerAttr::get(attr.getType(), attr.getValue() + 1)); - return getBody().insertArgument(getType().getNumInputs() + attr.getInt(), - type, loc); + return getBody().insertArgument( + getFunctionType().getNumInputs() + attr.getInt(), type, loc); } /// Adds a new block argument that corresponds to buffers located in @@ -880,7 +880,7 @@ p << ' '; p.printSymbolName(getName()); - FunctionType type = getType(); + FunctionType type = getFunctionType(); function_interface_impl::printFunctionSignature(p, *this, type.getInputs(), /*isVariadic=*/false, type.getResults()); @@ -899,12 +899,12 @@ } LogicalResult GPUFuncOp::verifyType() { - Type type = getTypeAttr().getValue(); + Type type = getFunctionTypeAttr().getValue(); if (!type.isa()) return emitOpError("requires '" + getTypeAttrName() + "' attribute of function type"); - if (isKernel() && getType().getNumResults() != 0) + if (isKernel() && getFunctionType().getNumResults() != 0) return emitOpError() << "expected void return type for kernel function"; return success(); @@ -936,7 +936,7 @@ << numFuncArguments + numWorkgroupAttributions << " arguments to body region"; - ArrayRef funcArgTypes = getType().getInputs(); + ArrayRef funcArgTypes = getFunctionType().getInputs(); for (unsigned i = 0; i < numFuncArguments; ++i) { Type blockArgType = front().getArgument(i).getType(); if (funcArgTypes[i] != blockArgType) @@ -961,7 +961,7 @@ LogicalResult gpu::ReturnOp::verify() { GPUFuncOp function = (*this)->getParentOfType(); - FunctionType funType = function.getType(); + FunctionType funType = function.getFunctionType(); if (funType.getNumResults() != operands().size()) return emitOpError() @@ -970,7 +970,7 @@ .append("return type declared here"); for (const auto &pair : llvm::enumerate( - llvm::zip(function.getType().getResults(), operands()))) { + llvm::zip(function.getFunctionType().getResults(), operands()))) { Type type; Value operand; std::tie(type, operand) = pair.value(); diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -1003,7 +1003,7 @@ return emitOpError() << "'" << calleeName.getValue() << "' does not reference a valid LLVM function"; - fnType = fn.getType(); + fnType = fn.getFunctionType(); } LLVMFunctionType funcType = fnType.dyn_cast(); @@ -1499,7 +1499,7 @@ return emitOpError("expected at most 1 operand"); if (auto parent = (*this)->getParentOfType()) { - Type expectedType = parent.getType().getReturnType(); + Type expectedType = parent.getFunctionType().getReturnType(); if (expectedType.isa()) { if (getNumOperands() == 0) return success(); @@ -1571,8 +1571,8 @@ return emitOpError( "the type must be a pointer to the type of the referenced global"); - if (function && - LLVM::LLVMPointerType::get(function.getType()) != getResult().getType()) + if (function && LLVM::LLVMPointerType::get(function.getFunctionType()) != + getResult().getType()) return emitOpError( "the type must be a pointer to the type of the referenced function"); @@ -1965,7 +1965,7 @@ push_back(entry); // FIXME: Allow passing in proper locations for the entry arguments. - LLVMFunctionType type = getType(); + LLVMFunctionType type = getFunctionType(); for (unsigned i = 0, e = type.getNumParams(); i < e; ++i) entry->addArgument(type.getParamType(i), getLoc()); return entry; @@ -1978,7 +1978,8 @@ result.addRegion(); result.addAttribute(SymbolTable::getSymbolAttrName(), builder.getStringAttr(name)); - result.addAttribute("type", TypeAttr::get(type)); + result.addAttribute(getFunctionTypeAttrName(result.name), + TypeAttr::get(type)); result.addAttribute(::getLinkageAttrName(), LinkageAttr::get(builder.getContext(), linkage)); result.attributes.append(attrs.begin(), attrs.end()); @@ -2089,7 +2090,7 @@ p << stringifyLinkage(getLinkage()) << ' '; p.printSymbolName(getName()); - LLVMFunctionType fnType = getType(); + LLVMFunctionType fnType = getFunctionType(); SmallVector argTypes; SmallVector resTypes; argTypes.reserve(fnType.getNumParams()); @@ -2114,15 +2115,6 @@ } } -LogicalResult LLVMFuncOp::verifyType() { - auto llvmType = getTypeAttr().getValue().dyn_cast_or_null(); - if (!llvmType) - return emitOpError("requires '" + getTypeAttrName() + - "' attribute of wrapped LLVM function type"); - - return success(); -} - // Verifies LLVM- and implementation-specific properties of the LLVM func Op: // - functions don't have 'common' linkage // - external functions have 'external' or 'extern_weak' linkage; @@ -2135,7 +2127,7 @@ // Check to see if this function has a void return with a result attribute to // it. It isn't clear what semantics we would assign to that. - if (getType().getReturnType().isa() && + if (getFunctionType().getReturnType().isa() && !getResultAttrs(0).empty()) { return emitOpError() << "cannot attach result attributes to functions with a void return"; @@ -2164,7 +2156,7 @@ if (isExternal()) return success(); - unsigned numArguments = getType().getNumParams(); + unsigned numArguments = getFunctionType().getNumParams(); Block &entryBlock = front(); for (unsigned i = 0; i < numArguments; ++i) { Type argType = entryBlock.getArgument(i).getType(); diff --git a/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/ModuleBufferization.cpp b/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/ModuleBufferization.cpp --- a/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/ModuleBufferization.cpp +++ b/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/ModuleBufferization.cpp @@ -389,8 +389,8 @@ getModuleAnalysisState(state.getAnalysisState()); // If nothing to do then we are done. - if (!llvm::any_of(funcOp.getType().getInputs(), isaTensor) && - !llvm::any_of(funcOp.getType().getResults(), isaTensor)) + if (!llvm::any_of(funcOp.getFunctionType().getInputs(), isaTensor) && + !llvm::any_of(funcOp.getFunctionType().getResults(), isaTensor)) return success(); // Get the bufferized FunctionType for funcOp or construct it if not yet @@ -412,11 +412,11 @@ // bufferization contract they want to enforce atm. // As a consequence, only support functions that don't return any tensor atm. if (funcOp.getBody().empty()) { - if (llvm::any_of(funcOp.getType().getResults(), isaTensor)) + if (llvm::any_of(funcOp.getFunctionType().getResults(), isaTensor)) return funcOp->emitError() << "cannot bufferize bodiless function that " << "returns a tensor"; FunctionType bufferizedFuncType = getBufferizedFunctionType( - funcOp.getContext(), funcOp.getType().getInputs(), TypeRange{}, + funcOp.getContext(), funcOp.getFunctionType().getInputs(), TypeRange{}, state.getOptions()); funcOp.setType(bufferizedFuncType); return success(); @@ -451,8 +451,8 @@ // 2. Rewrite the terminator without the inPlace bufferizable values. ValueRange retValues{returnValues}; FunctionType bufferizedFuncType = getBufferizedFunctionType( - funcOp.getContext(), funcOp.getType().getInputs(), retValues.getTypes(), - state.getOptions()); + funcOp.getContext(), funcOp.getFunctionType().getInputs(), + retValues.getTypes(), state.getOptions()); OpBuilder b(returnOp); b.create(returnOp.getLoc(), returnValues); returnOp->erase(); @@ -598,7 +598,8 @@ SmallVector argumentTypes; // Iterate on each function argument and check it it was marked with a // desired layout. - for (const auto &it : llvm::enumerate(funcOp.getType().getInputs())) { + for (const auto &it : + llvm::enumerate(funcOp.getFunctionType().getInputs())) { int argNumber = it.index(); Type inputType = it.value(); auto memrefType = inputType.dyn_cast(); @@ -661,7 +662,7 @@ // Finally set the funcOp type to update the arguments. auto newFuncType = FunctionType::get(moduleOp.getContext(), argumentTypes, - funcOp.getType().getResults()); + funcOp.getFunctionType().getResults()); funcOp.setType(newFuncType); } } @@ -1046,7 +1047,7 @@ return failure(); if (!options.allowReturnAllocs && - llvm::any_of(funcOp.getType().getResults(), [](Type t) { + llvm::any_of(funcOp.getFunctionType().getResults(), [](Type t) { return t.isa(); })) { funcOp->emitError("memref return type is unsupported"); diff --git a/mlir/lib/Dialect/MemRef/Transforms/NormalizeMemRefs.cpp b/mlir/lib/Dialect/MemRef/Transforms/NormalizeMemRefs.cpp --- a/mlir/lib/Dialect/MemRef/Transforms/NormalizeMemRefs.cpp +++ b/mlir/lib/Dialect/MemRef/Transforms/NormalizeMemRefs.cpp @@ -193,7 +193,7 @@ /// returned value is in turn used in ReturnOp of the calling function. void NormalizeMemRefs::updateFunctionSignature(FuncOp funcOp, ModuleOp moduleOp) { - FunctionType functionType = funcOp.getType(); + FunctionType functionType = funcOp.getFunctionType(); SmallVector resultTypes; FunctionType newFuncType; resultTypes = llvm::to_vector<4>(functionType.getResults()); @@ -333,7 +333,7 @@ // We use this OpBuilder to create new memref layout later. OpBuilder b(funcOp); - FunctionType functionType = funcOp.getType(); + FunctionType functionType = funcOp.getFunctionType(); SmallVector functionArgLocs(llvm::map_range( funcOp.getArguments(), [](BlockArgument arg) { return arg.getLoc(); })); SmallVector inputTypes; diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp --- a/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp @@ -2245,7 +2245,7 @@ // Print function name, signature, and control. printer << " "; printer.printSymbolName(sym_name()); - auto fnType = getType(); + auto fnType = getFunctionType(); function_interface_impl::printFunctionSignature( printer, *this, fnType.getInputs(), /*isVariadic=*/false, fnType.getResults()); @@ -2265,17 +2265,17 @@ } LogicalResult spirv::FuncOp::verifyType() { - auto type = getTypeAttr().getValue(); + auto type = getFunctionTypeAttr().getValue(); if (!type.isa()) return emitOpError("requires '" + getTypeAttrName() + "' attribute of function type"); - if (getType().getNumResults() > 1) + if (getFunctionType().getNumResults() > 1) return emitOpError("cannot have more than one result"); return success(); } LogicalResult spirv::FuncOp::verifyBody() { - FunctionType fnType = getType(); + FunctionType fnType = getFunctionType(); auto walkResult = walk([fnType](Operation *op) -> WalkResult { if (auto retOp = dyn_cast(op)) { @@ -2322,7 +2322,7 @@ // CallableOpInterface ArrayRef spirv::FuncOp::getCallableResults() { - return getType().getResults(); + return getFunctionType().getResults(); } //===----------------------------------------------------------------------===// @@ -2339,7 +2339,7 @@ << fnName.getValue() << "' not found in nearest symbol table"; } - auto functionType = funcOp.getType(); + auto functionType = funcOp.getFunctionType(); if (getNumResults() > 1) { return emitOpError( diff --git a/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp --- a/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp @@ -39,7 +39,7 @@ // Get the type of variable. If this is a scalar/vector type and has an ABI // info create a variable of type !spv.ptr>. If not // it must already be a !spv.ptr>. - auto varType = funcOp.getType().getInput(argIndex); + auto varType = funcOp.getFunctionType().getInput(argIndex); if (varType.cast().isScalarOrVector()) { auto storageClass = abiInfo.getStorageClass(); if (!storageClass) @@ -179,13 +179,14 @@ return failure(); } TypeConverter::SignatureConversion signatureConverter( - funcOp.getType().getNumInputs()); + funcOp.getFunctionType().getNumInputs()); auto &typeConverter = *getTypeConverter(); auto indexType = typeConverter.getIndexType(); auto attrName = spirv::getInterfaceVarABIAttrName(); - for (const auto &argType : llvm::enumerate(funcOp.getType().getInputs())) { + for (const auto &argType : + llvm::enumerate(funcOp.getFunctionType().getInputs())) { auto abiInfo = funcOp.getArgAttrOfType( argType.index(), attrName); if (!abiInfo) { diff --git a/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp b/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp --- a/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp @@ -553,7 +553,7 @@ LogicalResult FuncOpConversion::matchAndRewrite(FuncOp funcOp, OpAdaptor adaptor, ConversionPatternRewriter &rewriter) const { - auto fnType = funcOp.getType(); + auto fnType = funcOp.getFunctionType(); if (fnType.getNumResults() > 1) return failure(); diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorPasses.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorPasses.cpp --- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorPasses.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorPasses.cpp @@ -83,8 +83,9 @@ // All dynamic rules below accept new function, call, return, and tensor // dim and cast operations as legal output of the rewriting provided that // all sparse tensor types have been fully rewritten. - target.addDynamicallyLegalOp( - [&](FuncOp op) { return converter.isSignatureLegal(op.getType()); }); + target.addDynamicallyLegalOp([&](FuncOp op) { + return converter.isSignatureLegal(op.getFunctionType()); + }); target.addDynamicallyLegalOp([&](func::CallOp op) { return converter.isSignatureLegal(op.getCalleeType()); }); diff --git a/mlir/lib/Dialect/Tosa/Transforms/TosaInferShapes.cpp b/mlir/lib/Dialect/Tosa/Transforms/TosaInferShapes.cpp --- a/mlir/lib/Dialect/Tosa/Transforms/TosaInferShapes.cpp +++ b/mlir/lib/Dialect/Tosa/Transforms/TosaInferShapes.cpp @@ -293,7 +293,7 @@ return; rewriter.setInsertionPoint(op); - FunctionType funcTy = func.getType(); + FunctionType funcTy = func.getFunctionType(); auto resultTys = funcTy.getResults(); bool castAdded = false; diff --git a/mlir/lib/ExecutionEngine/JitRunner.cpp b/mlir/lib/ExecutionEngine/JitRunner.cpp --- a/mlir/lib/ExecutionEngine/JitRunner.cpp +++ b/mlir/lib/ExecutionEngine/JitRunner.cpp @@ -252,7 +252,7 @@ Error checkCompatibleReturnType(LLVM::LLVMFuncOp mainFunction); template <> Error checkCompatibleReturnType(LLVM::LLVMFuncOp mainFunction) { - auto resultType = mainFunction.getType() + auto resultType = mainFunction.getFunctionType() .cast() .getReturnType() .dyn_cast(); @@ -262,7 +262,7 @@ } template <> Error checkCompatibleReturnType(LLVM::LLVMFuncOp mainFunction) { - auto resultType = mainFunction.getType() + auto resultType = mainFunction.getFunctionType() .cast() .getReturnType() .dyn_cast(); @@ -272,7 +272,7 @@ } template <> Error checkCompatibleReturnType(LLVM::LLVMFuncOp mainFunction) { - if (!mainFunction.getType() + if (!mainFunction.getFunctionType() .cast() .getReturnType() .isa()) @@ -287,7 +287,9 @@ if (!mainFunction || mainFunction.isExternal()) return makeStringError("entry point not found"); - if (mainFunction.getType().cast().getNumParams() != 0) + if (mainFunction.getFunctionType() + .cast() + .getNumParams() != 0) return makeStringError("function inputs not supported"); if (Error error = checkCompatibleReturnType(mainFunction)) diff --git a/mlir/lib/Target/Cpp/TranslateToCpp.cpp b/mlir/lib/Target/Cpp/TranslateToCpp.cpp --- a/mlir/lib/Target/Cpp/TranslateToCpp.cpp +++ b/mlir/lib/Target/Cpp/TranslateToCpp.cpp @@ -585,7 +585,7 @@ CppEmitter::Scope scope(emitter); raw_indented_ostream &os = emitter.ostream(); if (failed(emitter.emitTypes(functionOp.getLoc(), - functionOp.getType().getResults()))) + functionOp.getFunctionType().getResults()))) return failure(); os << " " << functionOp.getName(); diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp --- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp @@ -912,7 +912,7 @@ for (auto function : getModuleBody(mlirModule).getOps()) { llvm::FunctionCallee llvmFuncCst = llvmModule->getOrInsertFunction( function.getName(), - cast(convertType(function.getType()))); + cast(convertType(function.getFunctionType()))); llvm::Function *llvmFunc = cast(llvmFuncCst.getCallee()); llvmFunc->setLinkage(convertLinkageToLLVM(function.getLinkage())); mapFunction(function.getName(), llvmFunc); diff --git a/mlir/lib/Target/SPIRV/Serialization/SerializeOps.cpp b/mlir/lib/Target/SPIRV/Serialization/SerializeOps.cpp --- a/mlir/lib/Target/SPIRV/Serialization/SerializeOps.cpp +++ b/mlir/lib/Target/SPIRV/Serialization/SerializeOps.cpp @@ -180,13 +180,13 @@ uint32_t fnTypeID = 0; // Generate type of the function. - if (failed(processType(op.getLoc(), op.getType(), fnTypeID))) + if (failed(processType(op.getLoc(), op.getFunctionType(), fnTypeID))) return failure(); // Add the function definition. SmallVector operands; uint32_t resTypeID = 0; - auto resultTypes = op.getType().getResults(); + auto resultTypes = op.getFunctionType().getResults(); if (resultTypes.size() > 1) { return op.emitError("cannot serialize function with multiple return types"); } diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp --- a/mlir/lib/Transforms/Utils/DialectConversion.cpp +++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp @@ -3074,7 +3074,7 @@ matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { FunctionOpInterface funcOp = cast(op); - FunctionType type = funcOp.getType().cast(); + FunctionType type = funcOp.getFunctionType().cast(); // Convert the original function types. TypeConverter::SignatureConversion result(type.getNumInputs()); diff --git a/mlir/python/mlir/dialects/_func_ops_ext.py b/mlir/python/mlir/dialects/_func_ops_ext.py --- a/mlir/python/mlir/dialects/_func_ops_ext.py +++ b/mlir/python/mlir/dialects/_func_ops_ext.py @@ -74,7 +74,7 @@ @property def type(self): - return FunctionType(TypeAttr(self.attributes["type"]).value) + return FunctionType(TypeAttr(self.attributes["function_type"]).value) @property def visibility(self): @@ -211,7 +211,7 @@ # Recompute the function type. return_types = [v.type for v in return_values] function_type = FunctionType.get(inputs=inputs, results=return_types) - func_op.attributes["type"] = TypeAttr.get(function_type) + func_op.attributes["function_type"] = TypeAttr.get(function_type) def emit_call_op(*call_args): call_op = func.CallOp(return_types, FlatSymbolRefAttr.get(symbol_name), diff --git a/mlir/test/CAPI/ir.c b/mlir/test/CAPI/ir.c --- a/mlir/test/CAPI/ir.c +++ b/mlir/test/CAPI/ir.c @@ -95,7 +95,8 @@ mlirAttributeParseGet(ctx, mlirStringRefCreateFromCString("\"add\"")); MlirNamedAttribute funcAttrs[] = { mlirNamedAttributeGet( - mlirIdentifierGet(ctx, mlirStringRefCreateFromCString("type")), + mlirIdentifierGet(ctx, + mlirStringRefCreateFromCString("function_type")), funcTypeAttr), mlirNamedAttributeGet( mlirIdentifierGet(ctx, mlirStringRefCreateFromCString("sym_name")), diff --git a/mlir/test/Dialect/GPU/invalid.mlir b/mlir/test/Dialect/GPU/invalid.mlir --- a/mlir/test/Dialect/GPU/invalid.mlir +++ b/mlir/test/Dialect/GPU/invalid.mlir @@ -331,10 +331,10 @@ module { gpu.module @gpu_funcs { - // expected-error @+1 {{requires 'type' attribute of function type}} + // expected-error @+1 {{attribute 'function_type' failed to satisfy constraint: type attribute of function type}} "gpu.func"() ({ gpu.return - }) {sym_name="kernel_1", type=f32} : () -> () + }) {sym_name="kernel_1", function_type=f32} : () -> () } } @@ -415,7 +415,7 @@ "gpu.func"() ({ ^bb0(%arg0: f32, %arg1: memref, %arg2: memref<5xf32, 3>, %arg3: memref<5xf32, 5>): "gpu.return"() : () -> () - } ) {gpu.kernel, sym_name = "kernel_1", type = (f32, memref) -> (), workgroup_attributions = 3: i64} : () -> () + } ) {function_type = (f32, memref) -> (), gpu.kernel, sym_name = "kernel_1", workgroup_attributions = 3: i64} : () -> () } } diff --git a/mlir/test/Dialect/GPU/ops.mlir b/mlir/test/Dialect/GPU/ops.mlir --- a/mlir/test/Dialect/GPU/ops.mlir +++ b/mlir/test/Dialect/GPU/ops.mlir @@ -162,7 +162,7 @@ "gpu.func"() ({ ^bb0(%arg0: f32, %arg1: memref, %arg2: memref<5xf32, 3>, %arg3: memref<5xf32, 5>): "gpu.return"() : () -> () - } ) {gpu.kernel, sym_name = "kernel_1", type = (f32, memref) -> (), workgroup_attributions = 1: i64} : () -> () + } ) {function_type = (f32, memref) -> (), gpu.kernel, sym_name = "kernel_1", workgroup_attributions = 1: i64} : () -> () } func @alloc() { diff --git a/mlir/test/Dialect/LLVMIR/func.mlir b/mlir/test/Dialect/LLVMIR/func.mlir --- a/mlir/test/Dialect/LLVMIR/func.mlir +++ b/mlir/test/Dialect/LLVMIR/func.mlir @@ -3,20 +3,20 @@ module { // GENERIC: "llvm.func" - // GENERIC: sym_name = "foo" - // GENERIC-SAME: type = !llvm.func + // GENERIC: function_type = !llvm.func + // GENERIC-SAME: sym_name = "foo" // GENERIC-SAME: () -> () // CHECK: llvm.func @foo() "llvm.func"() ({ - }) {sym_name = "foo", type = !llvm.func} : () -> () + }) {sym_name = "foo", function_type = !llvm.func} : () -> () // GENERIC: "llvm.func" - // GENERIC: sym_name = "bar" - // GENERIC-SAME: type = !llvm.func + // GENERIC: function_type = !llvm.func + // GENERIC-SAME: sym_name = "bar" // GENERIC-SAME: () -> () // CHECK: llvm.func @bar(i64, i64) -> i64 "llvm.func"() ({ - }) {sym_name = "bar", type = !llvm.func} : () -> () + }) {sym_name = "bar", function_type = !llvm.func} : () -> () // GENERIC: "llvm.func" // CHECK: llvm.func @baz(%{{.*}}: i64) -> i64 @@ -26,15 +26,15 @@ // GENERIC: llvm.return llvm.return %arg0 : i64 - // GENERIC: sym_name = "baz" - // GENERIC-SAME: type = !llvm.func + // GENERIC: function_type = !llvm.func + // GENERIC-SAME: sym_name = "baz" // GENERIC-SAME: () -> () - }) {sym_name = "baz", type = !llvm.func} : () -> () + }) {sym_name = "baz", function_type = !llvm.func} : () -> () // CHECK: llvm.func @qux(!llvm.ptr {llvm.noalias}, i64) // CHECK: attributes {xxx = {yyy = 42 : i64}} "llvm.func"() ({ - }) {sym_name = "qux", type = !llvm.func, i64)>, + }) {sym_name = "qux", function_type = !llvm.func, i64)>, arg_attrs = [{llvm.noalias}, {}], xxx = {yyy = 42}} : () -> () // CHECK: llvm.func @roundtrip1() @@ -143,28 +143,28 @@ module { // expected-error@+1 {{requires one region}} - "llvm.func"() {sym_name = "no_region", type = !llvm.func} : () -> () + "llvm.func"() {function_type = !llvm.func, sym_name = "no_region"} : () -> () } // ----- module { - // expected-error@+1 {{requires a type attribute 'type'}} + // expected-error@+1 {{requires attribute 'function_type'}} "llvm.func"() ({}) {sym_name = "missing_type"} : () -> () } // ----- module { - // expected-error@+1 {{requires 'type' attribute of wrapped LLVM function type}} - "llvm.func"() ({}) {sym_name = "non_llvm_type", type = i64} : () -> () + // expected-error@+1 {{attribute 'function_type' failed to satisfy constraint: type attribute of LLVM function type}} + "llvm.func"() ({}) {sym_name = "non_llvm_type", function_type = i64} : () -> () } // ----- module { - // expected-error@+1 {{requires 'type' attribute of wrapped LLVM function type}} - "llvm.func"() ({}) {sym_name = "non_function_type", type = i64} : () -> () + // expected-error@+1 {{attribute 'function_type' failed to satisfy constraint: type attribute of LLVM function type}} + "llvm.func"() ({}) {sym_name = "non_function_type", function_type = i64} : () -> () } // ----- @@ -174,7 +174,7 @@ "llvm.func"() ({ ^bb0(%arg0: i64): llvm.return - }) {sym_name = "wrong_arg_number", type = !llvm.func} : () -> () + }) {function_type = !llvm.func, sym_name = "wrong_arg_number"} : () -> () } // ----- @@ -184,7 +184,7 @@ "llvm.func"() ({ ^bb0(%arg0: tensor<*xf32>): llvm.return - }) {sym_name = "wrong_arg_number", type = !llvm.func} : () -> () + }) {function_type = !llvm.func, sym_name = "wrong_arg_number"} : () -> () } // ----- diff --git a/mlir/test/IR/invalid-func-op.mlir b/mlir/test/IR/invalid-func-op.mlir --- a/mlir/test/IR/invalid-func-op.mlir +++ b/mlir/test/IR/invalid-func-op.mlir @@ -91,8 +91,8 @@ // ----- -// expected-error@+1 {{'type' is an inferred attribute and should not be specified in the explicit attribute dictionary}} -func private @invalid_symbol_type_attr() attributes { type = "x" } +// expected-error@+1 {{'function_type' is an inferred attribute and should not be specified in the explicit attribute dictionary}} +func private @invalid_symbol_type_attr() attributes { function_type = "x" } // ----- diff --git a/mlir/test/IR/parser.mlir b/mlir/test/IR/parser.mlir --- a/mlir/test/IR/parser.mlir +++ b/mlir/test/IR/parser.mlir @@ -1416,7 +1416,7 @@ %1 = "foo"(%1, %2) : (i64, i64) -> i64 %2 = "bar"(%1) : (i64) -> i64 "unregistered_terminator"() : () -> () -}) {sym_name = "unregistered_op_dominance_violation_ok", type = () -> i1} : () -> () +}) {sym_name = "unregistered_op_dominance_violation_ok", function_type = () -> i1} : () -> () // This is an unregister operation, the printing/parsing is handled by the dialect. // CHECK: test.dialect_custom_printer custom_format diff --git a/mlir/test/lib/Dialect/Func/TestDecomposeCallGraphTypes.cpp b/mlir/test/lib/Dialect/Func/TestDecomposeCallGraphTypes.cpp --- a/mlir/test/lib/Dialect/Func/TestDecomposeCallGraphTypes.cpp +++ b/mlir/test/lib/Dialect/Func/TestDecomposeCallGraphTypes.cpp @@ -49,7 +49,7 @@ target.addDynamicallyLegalOp( [&](func::CallOp op) { return typeConverter.isLegal(op); }); target.addDynamicallyLegalOp([&](FuncOp op) { - return typeConverter.isSignatureLegal(op.getType()); + return typeConverter.isSignatureLegal(op.getFunctionType()); }); typeConverter.addConversion([](Type type) { return type; }); diff --git a/mlir/test/lib/Dialect/Test/TestPatterns.cpp b/mlir/test/lib/Dialect/Test/TestPatterns.cpp --- a/mlir/test/lib/Dialect/Test/TestPatterns.cpp +++ b/mlir/test/lib/Dialect/Test/TestPatterns.cpp @@ -676,7 +676,7 @@ [](Type type) { return type.isF32(); }); }); target.addDynamicallyLegalOp([&](FuncOp op) { - return converter.isSignatureLegal(op.getType()) && + return converter.isSignatureLegal(op.getFunctionType()) && converter.isLegal(&op.getBody()); }); target.addDynamicallyLegalOp( @@ -1106,7 +1106,7 @@ recursiveType.getName() == "outer_converted_type"); }); target.addDynamicallyLegalOp([&](FuncOp op) { - return converter.isSignatureLegal(op.getType()) && + return converter.isSignatureLegal(op.getFunctionType()) && converter.isLegal(&op.getBody()); }); target.addDynamicallyLegalOp([&](TestCastOp op) { diff --git a/mlir/test/lib/IR/TestFunc.cpp b/mlir/test/lib/IR/TestFunc.cpp --- a/mlir/test/lib/IR/TestFunc.cpp +++ b/mlir/test/lib/IR/TestFunc.cpp @@ -134,8 +134,8 @@ auto sym = func->getAttrOfType("test.set_type_from"); if (!sym) continue; - func.setType( - symbolTable.lookup(sym.getValue()).getType()); + func.setType(symbolTable.lookup(sym.getValue()) + .getFunctionType()); } } }; diff --git a/mlir/test/lib/IR/TestSlicing.cpp b/mlir/test/lib/IR/TestSlicing.cpp --- a/mlir/test/lib/IR/TestSlicing.cpp +++ b/mlir/test/lib/IR/TestSlicing.cpp @@ -29,8 +29,8 @@ OpBuilder builder(parentFuncOp); Location loc = op->getLoc(); std::string clonedFuncOpName = parentFuncOp.getName().str() + suffix.str(); - FuncOp clonedFuncOp = - builder.create(loc, clonedFuncOpName, parentFuncOp.getType()); + FuncOp clonedFuncOp = builder.create(loc, clonedFuncOpName, + parentFuncOp.getFunctionType()); BlockAndValueMapping mapper; builder.setInsertionPointToEnd(clonedFuncOp.addEntryBlock()); for (const auto &arg : enumerate(parentFuncOp.getArguments())) diff --git a/mlir/test/mlir-lsp-server/hover.test b/mlir/test/mlir-lsp-server/hover.test --- a/mlir/test/mlir-lsp-server/hover.test +++ b/mlir/test/mlir-lsp-server/hover.test @@ -114,7 +114,7 @@ // CHECK-NEXT: "result": { // CHECK-NEXT: "contents": { // CHECK-NEXT: "kind": "markdown", -// CHECK-NEXT: "value": "\"func.func\" : public @foo\n\nGeneric Form:\n\n```mlir\n\"func.func\"() ({\n}) {sym_name = \"foo\", type = (i1) -> ()} : () -> ()\n```\n" +// CHECK-NEXT: "value": "\"func.func\" : public @foo\n\nGeneric Form:\n\n```mlir\n\"func.func\"() ({\n}) {function_type = (i1) -> (), sym_name = \"foo\"} : () -> ()\n```\n" // CHECK-NEXT: }, // CHECK-NEXT: "range": { // CHECK-NEXT: "end": { @@ -138,7 +138,7 @@ // CHECK-NEXT: "result": { // CHECK-NEXT: "contents": { // CHECK-NEXT: "kind": "markdown", -// CHECK-NEXT: "value": "\"func.func\" : public @foo\n\nGeneric Form:\n\n```mlir\n\"func.func\"() ({\n}) {sym_name = \"foo\", type = (i1) -> ()} : () -> ()\n```\n" +// CHECK-NEXT: "value": "\"func.func\" : public @foo\n\nGeneric Form:\n\n```mlir\n\"func.func\"() ({\n}) {function_type = (i1) -> (), sym_name = \"foo\"} : () -> ()\n```\n" // CHECK-NEXT: }, // CHECK-NEXT: "range": { // CHECK-NEXT: "end": {