76 changes: 38 additions & 38 deletions flang/lib/Lower/IO.cpp

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions flang/lib/Lower/IntrinsicCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ mlir::FuncOp IntrinsicLibrary::getWrapper(GeneratorType generator,
}
} 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;
Expand Down Expand Up @@ -1435,7 +1435,7 @@ IntrinsicLibrary::getRuntimeCallGenerator(llvm::StringRef name,
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");
Expand Down
22 changes: 11 additions & 11 deletions flang/lib/Lower/Runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void Fortran::lower::genStopStatement(
[&](const fir::CharBoxValue &x) {
callee = fir::runtime::getRuntimeFunc<mkRTKey(StopStatementText)>(
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()));
Expand All @@ -68,7 +68,7 @@ void Fortran::lower::genStopStatement(
[&](fir::UnboxedValue x) {
callee = fir::runtime::getRuntimeFunc<mkRTKey(StopStatement)>(
loc, builder);
calleeType = callee.getType();
calleeType = callee.getFunctionType();
mlir::Value cast =
builder.createConvert(loc, calleeType.getInput(0), x);
operands.push_back(cast);
Expand All @@ -79,7 +79,7 @@ void Fortran::lower::genStopStatement(
});
} else {
callee = fir::runtime::getRuntimeFunc<mkRTKey(StopStatement)>(loc, builder);
calleeType = callee.getType();
calleeType = callee.getFunctionType();
operands.push_back(
builder.createIntegerConstant(loc, calleeType.getInput(0), 0));
}
Expand Down Expand Up @@ -125,7 +125,7 @@ mlir::Value Fortran::lower::genAssociated(fir::FirOpBuilder &builder,
fir::runtime::getRuntimeFunc<mkRTKey(PointerIsAssociatedWith)>(loc,
builder);
llvm::SmallVector<mlir::Value> args = fir::runtime::createArguments(
builder, loc, func.getType(), pointer, target);
builder, loc, func.getFunctionType(), pointer, target);
return builder.create<fir::CallOp>(loc, func, args).getResult(0);
}

Expand All @@ -144,7 +144,7 @@ void Fortran::lower::genDateAndTime(fir::FirOpBuilder &builder,
mlir::Value values) {
mlir::FuncOp callee =
fir::runtime::getRuntimeFunc<mkRTKey(DateAndTime)>(loc, builder);
mlir::FunctionType funcTy = callee.getType();
mlir::FunctionType funcTy = callee.getFunctionType();
mlir::Type idxTy = builder.getIndexType();
mlir::Value zero;
auto splitArg = [&](llvm::Optional<fir::CharBoxValue> arg,
Expand Down Expand Up @@ -185,15 +185,15 @@ void Fortran::lower::genRandomInit(fir::FirOpBuilder &builder,
mlir::FuncOp func =
fir::runtime::getRuntimeFunc<mkRTKey(RandomInit)>(loc, builder);
llvm::SmallVector<mlir::Value> args = fir::runtime::createArguments(
builder, loc, func.getType(), repeatable, imageDistinct);
builder, loc, func.getFunctionType(), repeatable, imageDistinct);
builder.create<fir::CallOp>(loc, func, args);
}

void Fortran::lower::genRandomNumber(fir::FirOpBuilder &builder,
mlir::Location loc, mlir::Value harvest) {
mlir::FuncOp func =
fir::runtime::getRuntimeFunc<mkRTKey(RandomNumber)>(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));
Expand Down Expand Up @@ -226,7 +226,7 @@ void Fortran::lower::genRandomSeed(fir::FirOpBuilder &builder,
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));
Expand All @@ -242,7 +242,7 @@ void Fortran::lower::genTransfer(fir::FirOpBuilder &builder, mlir::Location loc,

mlir::FuncOp func =
fir::runtime::getRuntimeFunc<mkRTKey(Transfer)>(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));
Expand All @@ -258,7 +258,7 @@ void Fortran::lower::genTransferSize(fir::FirOpBuilder &builder,
mlir::Value size) {
mlir::FuncOp func =
fir::runtime::getRuntimeFunc<mkRTKey(TransferSize)>(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));
Expand All @@ -274,7 +274,7 @@ void Fortran::lower::genSystemClock(fir::FirOpBuilder &builder,
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<mlir::IntegerType>())
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Optimizer/Builder/Character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ void fir::factory::CharacterExprHelper::createCopy(
auto totalBytes = builder.create<arith::MulIOp>(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<fir::CallOp>(
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Optimizer/Builder/Runtime/Assign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ using namespace Fortran::runtime;
void fir::runtime::genAssign(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::Value destBox, mlir::Value sourceBox) {
auto func = fir::runtime::getRuntimeFunc<mkRTKey(Assign)>(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));
Expand Down
16 changes: 8 additions & 8 deletions flang/lib/Optimizer/Builder/Runtime/Character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static void genCharacterSearch(FN func, fir::FirOpBuilder &builder,
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));
Expand Down Expand Up @@ -66,7 +66,7 @@ static void genAdjust(fir::FirOpBuilder &builder, mlir::Location loc,
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);
Expand Down Expand Up @@ -111,7 +111,7 @@ fir::runtime::genCharCompare(fir::FirOpBuilder &builder, mlir::Location loc,
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<fir::CallOp>(loc, beginFunc, args).getResult(0);
Expand Down Expand Up @@ -161,7 +161,7 @@ mlir::Value fir::runtime::genIndex(fir::FirOpBuilder &builder,
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);
Expand All @@ -182,7 +182,7 @@ void fir::runtime::genRepeat(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::Value resultBox, mlir::Value stringBox,
mlir::Value ncopies) {
auto repeatFunc = fir::runtime::getRuntimeFunc<mkRTKey(Repeat)>(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));
Expand All @@ -195,7 +195,7 @@ void fir::runtime::genRepeat(fir::FirOpBuilder &builder, mlir::Location loc,
void fir::runtime::genTrim(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::Value resultBox, mlir::Value stringBox) {
auto trimFunc = fir::runtime::getRuntimeFunc<mkRTKey(Trim)>(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));
Expand Down Expand Up @@ -234,7 +234,7 @@ mlir::Value fir::runtime::genScan(fir::FirOpBuilder &builder,
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<fir::CallOp>(loc, func, args).getResult(0);
Expand Down Expand Up @@ -271,7 +271,7 @@ mlir::Value fir::runtime::genVerify(fir::FirOpBuilder &builder,
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<fir::CallOp>(loc, func, args).getResult(0);
Expand Down
17 changes: 9 additions & 8 deletions flang/lib/Optimizer/Builder/Runtime/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ void fir::runtime::genGetCommandArgument(fir::FirOpBuilder &builder,
// "STATUS" or "ERRMSG" parameters.
if (!isAbsent(value) || status || !isAbsent(errmsg)) {
llvm::SmallVector<mlir::Value> args = fir::runtime::createArguments(
builder, loc, argumentValueFunc.getType(), number, value, errmsg);
builder, loc, argumentValueFunc.getFunctionType(), number, value,
errmsg);
valueResult =
builder.create<fir::CallOp>(loc, argumentValueFunc, args).getResult(0);
}
Expand All @@ -63,7 +64,7 @@ void fir::runtime::genGetCommandArgument(fir::FirOpBuilder &builder,
// Only run `ArgumentLength` intrinsic if "LENGTH" parameter provided
if (length) {
llvm::SmallVector<mlir::Value> args = fir::runtime::createArguments(
builder, loc, argumentLengthFunc.getType(), number);
builder, loc, argumentLengthFunc.getFunctionType(), number);
mlir::Value result =
builder.create<fir::CallOp>(loc, argumentLengthFunc, args).getResult(0);
const mlir::Value valueLoaded = builder.create<fir::LoadOp>(loc, length);
Expand All @@ -89,16 +90,16 @@ void fir::runtime::genGetEnvironmentVariable(
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;
// Run `EnvVariableValue` intrinsic only if we have a "value" in either
// "VALUE", "STATUS" or "ERRMSG" parameters.
if (!isAbsent(value) || status || !isAbsent(errmsg)) {
llvm::SmallVector<mlir::Value> 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<fir::CallOp>(loc, valueFunc, args).getResult(0);
}
Expand All @@ -113,9 +114,9 @@ void fir::runtime::genGetEnvironmentVariable(

// Only run `EnvVariableLength` intrinsic if "LENGTH" parameter provided
if (length) {
llvm::SmallVector<mlir::Value> args =
fir::runtime::createArguments(builder, loc, lengthFunc.getType(), name,
trimName, sourceFile, sourceLine);
llvm::SmallVector<mlir::Value> args = fir::runtime::createArguments(
builder, loc, lengthFunc.getFunctionType(), name, trimName, sourceFile,
sourceLine);
mlir::Value result =
builder.create<fir::CallOp>(loc, lengthFunc, args).getResult(0);
const mlir::Value lengthLoaded = builder.create<fir::LoadOp>(loc, length);
Expand Down
4 changes: 2 additions & 2 deletions flang/lib/Optimizer/Builder/Runtime/Derived.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void fir::runtime::genDerivedTypeInitialize(fir::FirOpBuilder &builder,
mlir::Location loc,
mlir::Value box) {
auto func = fir::runtime::getRuntimeFunc<mkRTKey(Initialize)>(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));
Expand All @@ -29,7 +29,7 @@ void fir::runtime::genDerivedTypeInitialize(fir::FirOpBuilder &builder,
void fir::runtime::genDerivedTypeDestroy(fir::FirOpBuilder &builder,
mlir::Location loc, mlir::Value box) {
auto func = fir::runtime::getRuntimeFunc<mkRTKey(Destroy)>(loc, builder);
auto fTy = func.getType();
auto fTy = func.getFunctionType();
auto args = fir::runtime::createArguments(builder, loc, fTy, box);
builder.create<fir::CallOp>(loc, func, args);
}
8 changes: 4 additions & 4 deletions flang/lib/Optimizer/Builder/Runtime/Inquiry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ mlir::Value fir::runtime::genLboundDim(fir::FirOpBuilder &builder,
mlir::Value dim) {
mlir::FuncOp lboundFunc =
fir::runtime::getRuntimeFunc<mkRTKey(LboundDim)>(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));
Expand All @@ -36,7 +36,7 @@ void fir::runtime::genUbound(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::Value kind) {
mlir::FuncOp uboundFunc =
fir::runtime::getRuntimeFunc<mkRTKey(Ubound)>(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));
Expand All @@ -52,7 +52,7 @@ mlir::Value fir::runtime::genSizeDim(fir::FirOpBuilder &builder,
mlir::Value dim) {
mlir::FuncOp sizeFunc =
fir::runtime::getRuntimeFunc<mkRTKey(SizeDim)>(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));
Expand All @@ -67,7 +67,7 @@ mlir::Value fir::runtime::genSize(fir::FirOpBuilder &builder,
mlir::Location loc, mlir::Value array) {
mlir::FuncOp sizeFunc =
fir::runtime::getRuntimeFunc<mkRTKey(Size)>(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));
Expand Down
14 changes: 7 additions & 7 deletions flang/lib/Optimizer/Builder/Runtime/Numeric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ mlir::Value fir::runtime::genExponent(fir::FirOpBuilder &builder,
} else
fir::emitFatalError(loc, "unsupported real kind in Exponent lowering");

auto funcTy = func.getType();
auto funcTy = func.getFunctionType();
llvm::SmallVector<mlir::Value> args = {
builder.createConvert(loc, funcTy.getInput(0), x)};

Expand All @@ -259,7 +259,7 @@ mlir::Value fir::runtime::genFraction(fir::FirOpBuilder &builder,
else
fir::emitFatalError(loc, "unsupported real kind in Fraction lowering");

auto funcTy = func.getType();
auto funcTy = func.getFunctionType();
llvm::SmallVector<mlir::Value> args = {
builder.createConvert(loc, funcTy.getInput(0), x)};

Expand All @@ -284,7 +284,7 @@ mlir::Value fir::runtime::genNearest(fir::FirOpBuilder &builder,
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);
Expand Down Expand Up @@ -319,7 +319,7 @@ mlir::Value fir::runtime::genRRSpacing(fir::FirOpBuilder &builder,
else
fir::emitFatalError(loc, "unsupported real kind in RRSpacing lowering");

auto funcTy = func.getType();
auto funcTy = func.getFunctionType();
llvm::SmallVector<mlir::Value> args = {
builder.createConvert(loc, funcTy.getInput(0), x)};

Expand All @@ -344,7 +344,7 @@ mlir::Value fir::runtime::genScale(fir::FirOpBuilder &builder,
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<fir::CallOp>(loc, func, args).getResult(0);
Expand All @@ -368,7 +368,7 @@ mlir::Value fir::runtime::genSetExponent(fir::FirOpBuilder &builder,
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<fir::CallOp>(loc, func, args).getResult(0);
Expand All @@ -391,7 +391,7 @@ mlir::Value fir::runtime::genSpacing(fir::FirOpBuilder &builder,
else
fir::emitFatalError(loc, "unsupported real kind in Spacing lowering");

auto funcTy = func.getType();
auto funcTy = func.getFunctionType();
llvm::SmallVector<mlir::Value> args = {
builder.createConvert(loc, funcTy.getInput(0), x)};

Expand Down
4 changes: 2 additions & 2 deletions flang/lib/Optimizer/Builder/Runtime/Ragged.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void fir::runtime::genRaggedArrayAllocate(mlir::Location loc,
auto i64Ty = builder.getIntegerType(64);
auto func =
fir::runtime::getRuntimeFunc<mkRTKey(RaggedArrayAllocate)>(loc, builder);
auto fTy = func.getType();
auto fTy = func.getFunctionType();
auto i1Ty = builder.getIntegerType(1);
fir::SequenceType::Shape shape = {
static_cast<fir::SequenceType::Extent>(rank)};
Expand Down Expand Up @@ -61,7 +61,7 @@ void fir::runtime::genRaggedArrayDeallocate(mlir::Location loc,
mlir::Value header) {
auto func = fir::runtime::getRuntimeFunc<mkRTKey(RaggedArrayDeallocate)>(
loc, builder);
auto fTy = func.getType();
auto fTy = func.getFunctionType();
auto args = fir::runtime::createArguments(builder, loc, fTy, header);
builder.create<fir::CallOp>(loc, func, args);
}
26 changes: 13 additions & 13 deletions flang/lib/Optimizer/Builder/Runtime/Reduction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ template <typename FN>
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));
Expand All @@ -390,7 +390,7 @@ template <typename FN>
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));
Expand All @@ -407,7 +407,7 @@ static void genReduction3Args(FN func, fir::FirOpBuilder &builder,
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));
Expand All @@ -424,7 +424,7 @@ static void genReduction4Args(FN func, fir::FirOpBuilder &builder,
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));
Expand All @@ -441,7 +441,7 @@ static void
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));
Expand Down Expand Up @@ -503,7 +503,7 @@ void fir::runtime::genCountDim(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::Value resultBox, mlir::Value maskBox,
mlir::Value dim, mlir::Value kind) {
auto func = fir::runtime::getRuntimeFunc<mkRTKey(CountDim)>(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));
Expand Down Expand Up @@ -571,7 +571,7 @@ mlir::Value fir::runtime::genMaxval(fir::FirOpBuilder &builder,
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));
Expand All @@ -597,7 +597,7 @@ void fir::runtime::genMaxvalChar(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::Value maskBox) {
auto func =
fir::runtime::getRuntimeFunc<mkRTKey(MaxvalCharacter)>(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));
Expand Down Expand Up @@ -644,7 +644,7 @@ void fir::runtime::genMinvalChar(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::Value maskBox) {
auto func =
fir::runtime::getRuntimeFunc<mkRTKey(MinvalCharacter)>(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));
Expand Down Expand Up @@ -690,7 +690,7 @@ mlir::Value fir::runtime::genMinval(fir::FirOpBuilder &builder,
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));
Expand Down Expand Up @@ -757,7 +757,7 @@ mlir::Value fir::runtime::genProduct(fir::FirOpBuilder &builder,
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 =
Expand Down Expand Up @@ -834,7 +834,7 @@ mlir::Value fir::runtime::genDotProduct(fir::FirOpBuilder &builder,
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)) {
Expand Down Expand Up @@ -907,7 +907,7 @@ mlir::Value fir::runtime::genSum(fir::FirOpBuilder &builder, mlir::Location loc,
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 =
Expand Down
6 changes: 3 additions & 3 deletions flang/lib/Optimizer/Builder/Runtime/Stop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ using namespace Fortran::runtime;
void fir::runtime::genExit(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::Value status) {
auto exitFunc = fir::runtime::getRuntimeFunc<mkRTKey(Exit)>(loc, builder);
llvm::SmallVector<mlir::Value> args =
fir::runtime::createArguments(builder, loc, exitFunc.getType(), status);
llvm::SmallVector<mlir::Value> args = fir::runtime::createArguments(
builder, loc, exitFunc.getFunctionType(), status);
builder.create<fir::CallOp>(loc, exitFunc, args);
}

Expand All @@ -27,7 +27,7 @@ void fir::runtime::genReportFatalUserError(fir::FirOpBuilder &builder,
llvm::StringRef message) {
mlir::FuncOp crashFunc =
fir::runtime::getRuntimeFunc<mkRTKey(ReportFatalUserError)>(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 =
Expand Down
20 changes: 10 additions & 10 deletions flang/lib/Optimizer/Builder/Runtime/Transformational.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void fir::runtime::genCshift(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::Value resultBox, mlir::Value arrayBox,
mlir::Value shiftBox, mlir::Value dimBox) {
auto cshiftFunc = fir::runtime::getRuntimeFunc<mkRTKey(Cshift)>(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));
Expand All @@ -40,7 +40,7 @@ void fir::runtime::genCshiftVector(fir::FirOpBuilder &builder,
mlir::Value arrayBox, mlir::Value shiftBox) {
auto cshiftFunc =
fir::runtime::getRuntimeFunc<mkRTKey(CshiftVector)>(loc, builder);
auto fTy = cshiftFunc.getType();
auto fTy = cshiftFunc.getFunctionType();

auto sourceFile = fir::factory::locationToFilename(builder, loc);
auto sourceLine =
Expand All @@ -57,7 +57,7 @@ void fir::runtime::genEoshift(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::Value dimBox) {
auto eoshiftFunc =
fir::runtime::getRuntimeFunc<mkRTKey(Eoshift)>(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));
Expand All @@ -74,7 +74,7 @@ void fir::runtime::genEoshiftVector(fir::FirOpBuilder &builder,
mlir::Value boundBox) {
auto eoshiftFunc =
fir::runtime::getRuntimeFunc<mkRTKey(EoshiftVector)>(loc, builder);
auto fTy = eoshiftFunc.getType();
auto fTy = eoshiftFunc.getFunctionType();

auto sourceFile = fir::factory::locationToFilename(builder, loc);
auto sourceLine =
Expand All @@ -91,7 +91,7 @@ void fir::runtime::genMatmul(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::Value resultBox, mlir::Value matrixABox,
mlir::Value matrixBBox) {
auto func = fir::runtime::getRuntimeFunc<mkRTKey(Matmul)>(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));
Expand All @@ -106,7 +106,7 @@ void fir::runtime::genPack(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::Value resultBox, mlir::Value arrayBox,
mlir::Value maskBox, mlir::Value vectorBox) {
auto packFunc = fir::runtime::getRuntimeFunc<mkRTKey(Pack)>(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));
Expand All @@ -122,7 +122,7 @@ void fir::runtime::genReshape(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::Value shapeBox, mlir::Value padBox,
mlir::Value orderBox) {
auto func = fir::runtime::getRuntimeFunc<mkRTKey(Reshape)>(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));
Expand All @@ -137,7 +137,7 @@ void fir::runtime::genSpread(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::Value resultBox, mlir::Value sourceBox,
mlir::Value dim, mlir::Value ncopies) {
auto func = fir::runtime::getRuntimeFunc<mkRTKey(Spread)>(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));
Expand All @@ -151,7 +151,7 @@ void fir::runtime::genSpread(fir::FirOpBuilder &builder, mlir::Location loc,
void fir::runtime::genTranspose(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::Value resultBox, mlir::Value sourceBox) {
auto func = fir::runtime::getRuntimeFunc<mkRTKey(Transpose)>(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));
Expand All @@ -165,7 +165,7 @@ void fir::runtime::genUnpack(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::Value resultBox, mlir::Value vectorBox,
mlir::Value maskBox, mlir::Value fieldBox) {
auto unpackFunc = fir::runtime::getRuntimeFunc<mkRTKey(Unpack)>(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));
Expand Down
4 changes: 2 additions & 2 deletions flang/lib/Optimizer/CodeGen/TargetRewrite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ class TargetRewrite : public TargetRewriteBase<TargetRewrite> {
/// 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<mlir::FunctionType>();
auto funcTy = func.getFunctionType().cast<mlir::FunctionType>();
if (hasPortableSignature(funcTy))
return;
llvm::SmallVector<mlir::Type> newResTys;
Expand Down Expand Up @@ -543,7 +543,7 @@ class TargetRewrite : public TargetRewriteBase<TargetRewrite> {
// 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<decltype(fixupSize)> i = 0; i < fixupSize; ++i) {
const auto &fixup = fixups[i];
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Optimizer/Dialect/FIROps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ void fir::CallOp::build(mlir::OpBuilder &builder, mlir::OperationState &result,
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,
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Optimizer/Transforms/AbstractResult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class AbstractResultOpt : public fir::AbstractResultOptBase<AbstractResultOpt> {
/*newArg=*/{}};

// Convert function type itself if it has an abstract result
auto funcTy = func.getType().cast<mlir::FunctionType>();
auto funcTy = func.getFunctionType().cast<mlir::FunctionType>();
if (mustConvertCallOrFunc(funcTy)) {
func.setType(getNewFunctionType(funcTy, options));
unsigned zero = 0;
Expand Down
2 changes: 1 addition & 1 deletion flang/test/Fir/Todo/boxproc_host.fir
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Test that `fir.boxproc_host` fails conversion to llvm.
// At the moment this test fails since `fir.boxproc` type does not have a conversion.

// CHECK: failed to legalize operation 'builtin.func'
// CHECK: failed to legalize operation 'func.func'
func @test(%bproc: !fir.boxproc<(i32) -> ()>) {
%tuple = fir.boxproc_host %bproc : (!fir.boxproc<(i32) -> ()>) -> (!fir.ref<tuple<i32,f64>>)
return
Expand Down
2 changes: 1 addition & 1 deletion flang/test/Fir/Todo/unboxproc.fir
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Not implemented yet.
// Currently fails since coversion for boxproc type is not implemented.

// CHECK: failed to legalize operation 'builtin.func'
// CHECK: failed to legalize operation 'func.func'
func @boxing_match(%bproc: !fir.boxproc<(i32) -> ()>) {
%ubproc:2 = fir.unboxproc %bproc : (!fir.boxproc<(i32) -> ()>) -> ((i32) -> (), !fir.ref<tuple<i32,f64>>)
return
Expand Down
3 changes: 2 additions & 1 deletion flang/unittests/Optimizer/Builder/CharacterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
struct CharacterTest : public testing::Test {
public:
void SetUp() override {
fir::support::loadDialects(context);

kindMap = std::make_unique<fir::KindMapping>(&context,
"i10:80,l3:24,a1:8,r54:Double,c20:X86_FP80,r11:PPC_FP128,"
"r12:FP128,r13:X86_FP80,r14:Double,r15:Float,r16:Half,r23:BFloat");
Expand All @@ -31,7 +33,6 @@ struct CharacterTest : public testing::Test {
mod.push_back(mod);
builder.setInsertionPointToStart(entryBlock);

fir::support::loadDialects(context);
firBuilder = std::make_unique<fir::FirOpBuilder>(mod, *kindMap);
}

Expand Down
3 changes: 2 additions & 1 deletion flang/unittests/Optimizer/Builder/ComplexTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
struct ComplexTest : public testing::Test {
public:
void SetUp() override {
fir::support::loadDialects(context);

mlir::OpBuilder builder(&context);
auto loc = builder.getUnknownLoc();

Expand All @@ -27,7 +29,6 @@ struct ComplexTest : public testing::Test {
mod.push_back(mod);
builder.setInsertionPointToStart(entryBlock);

fir::support::loadDialects(context);
kindMap = std::make_unique<fir::KindMapping>(&context);
firBuilder = std::make_unique<fir::FirOpBuilder>(mod, *kindMap);
helper = std::make_unique<fir::factory::Complex>(*firBuilder, loc);
Expand Down
3 changes: 2 additions & 1 deletion flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ using namespace mlir;
struct FIRBuilderTest : public testing::Test {
public:
void SetUp() override {
fir::support::loadDialects(context);

llvm::ArrayRef<fir::KindTy> defs;
fir::KindMapping kindMap(&context, defs);
mlir::OpBuilder builder(&context);
Expand All @@ -31,7 +33,6 @@ struct FIRBuilderTest : public testing::Test {
mod.push_back(mod);
builder.setInsertionPointToStart(entryBlock);

fir::support::loadDialects(context);
firBuilder = std::make_unique<fir::FirOpBuilder>(mod, kindMap);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
struct RuntimeCallTest : public testing::Test {
public:
void SetUp() override {
fir::support::loadDialects(context);

mlir::OpBuilder builder(&context);
auto loc = builder.getUnknownLoc();

Expand All @@ -29,7 +31,6 @@ struct RuntimeCallTest : public testing::Test {
mod.push_back(mod);
builder.setInsertionPointToStart(entryBlock);

fir::support::loadDialects(context);
kindMap = std::make_unique<fir::KindMapping>(&context);
firBuilder = std::make_unique<fir::FirOpBuilder>(mod, *kindMap);

Expand Down
2 changes: 1 addition & 1 deletion mlir/benchmark/python/benchmark_sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def benchmark_sparse_mlir_multiplication():
param2_type = ir.RankedTensorType.get([1500, 2000], f64)
result_type = ir.RankedTensorType.get([1000, 2000], f64)
with ir.InsertionPoint(module.body):
@builtin.FuncOp.from_py_func(param1_type, param2_type, result_type)
@func.FuncOp.from_py_func(param1_type, param2_type, result_type)
def sparse_kernel(x, y, z):
return matmul_dsl(x, y, outs=[z])

Expand Down
8 changes: 4 additions & 4 deletions mlir/benchmark/python/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def create_sparse_np_tensor(dimensions, number_of_elements):
return tensor


def get_kernel_func_from_module(module: ir.Module) -> builtin.FuncOp:
def get_kernel_func_from_module(module: ir.Module) -> func.FuncOp:
"""Takes an mlir module object and extracts the function object out of it.
This function only works for a module with one region, one block, and one
operation.
Expand All @@ -55,12 +55,12 @@ def get_kernel_func_from_module(module: ir.Module) -> builtin.FuncOp:
return module.operation.regions[0].blocks[0].operations[0]


def emit_timer_func() -> builtin.FuncOp:
def emit_timer_func() -> func.FuncOp:
"""Returns the declaration of nano_time function. If nano_time function is
used, the `MLIR_RUNNER_UTILS` and `MLIR_C_RUNNER_UTILS` must be included.
"""
i64_type = ir.IntegerType.get_signless(64)
nano_time = builtin.FuncOp(
nano_time = func.FuncOp(
"nano_time", ([], [i64_type]), visibility="private")
nano_time.attributes["llvm.emit_c_interface"] = ir.UnitAttr.get()
return nano_time
Expand All @@ -76,7 +76,7 @@ def emit_benchmark_wrapped_main_func(func, timer_func):
"""
i64_type = ir.IntegerType.get_signless(64)
memref_of_i64_type = ir.MemRefType.get([-1], i64_type)
wrapped_func = builtin.FuncOp(
wrapped_func = func.FuncOp(
# Same signature and an extra buffer of indices to save timings.
"main",
(func.arguments.types + [memref_of_i64_type], func.type.results),
Expand Down
8 changes: 4 additions & 4 deletions mlir/docs/Bindings/Python.md
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ from mlir.dialects import builtin
with Context():
module = Module.create()
with InsertionPoint(module.body), Location.unknown():
func = builtin.FuncOp("main", ([], []))
func = func.FuncOp("main", ([], []))
```

Also see below for constructors generated from ODS.
Expand All @@ -660,12 +660,12 @@ with Context():
with InsertionPoint(module.body), Location.unknown():
# Operations can be created in a generic way.
func = Operation.create(
"builtin.func", results=[], operands=[],
attributes={"type":TypeAttr.get(FunctionType.get([], []))},
"func.func", results=[], operands=[],
attributes={"function_type":TypeAttr.get(FunctionType.get([], []))},
successors=None, regions=1)
# The result will be downcasted to the concrete `OpView` subclass if
# available.
assert isinstance(func, builtin.FuncOp)
assert isinstance(func, func.FuncOp)
```

Regions are created for an operation when constructing it on the C++ side. They
Expand Down
2 changes: 1 addition & 1 deletion mlir/docs/Dialects/ShapeDialect.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ below[^wip_form1]:
```mlir
shape.function_library @shplib {
builtin.func @matmul(%lhs: !shape.value_shape, %rhs: !shape.value_shape) -> !shape.shape {
func.func @matmul(%lhs: !shape.value_shape, %rhs: !shape.value_shape) -> !shape.shape {
%c1 = shape.const_size 1
%c2 = shape.const_size 2
// We could also allow rank etc operations directly on value_shape too, that
Expand Down
38 changes: 19 additions & 19 deletions mlir/docs/PassManagement.md
Original file line number Diff line number Diff line change
Expand Up @@ -532,12 +532,12 @@ A pipeline view that models the structure of the pass manager, this is the
default view:
```shell
$ mlir-opt -pass-pipeline='builtin.func(my-pass,my-pass)' foo.mlir -pass-statistics
$ mlir-opt -pass-pipeline='func.func(my-pass,my-pass)' foo.mlir -pass-statistics
===-------------------------------------------------------------------------===
... Pass statistics report ...
===-------------------------------------------------------------------------===
'builtin.func' Pipeline
'func.func' Pipeline
MyPass
(S) 15 exampleStat - An example statistic
VerifierPass
Expand All @@ -551,7 +551,7 @@ A list view that aggregates the statistics of all instances of a specific pass
together:

```shell
$ mlir-opt -pass-pipeline='builtin.func(my-pass, my-pass)' foo.mlir -pass-statistics -pass-statistics-display=list
$ mlir-opt -pass-pipeline='func.func(my-pass, my-pass)' foo.mlir -pass-statistics -pass-statistics-display=list

===-------------------------------------------------------------------------===
... Pass statistics report ...
Expand Down Expand Up @@ -657,7 +657,7 @@ options ::= '{' (key ('=' value)?)+ '}'

* `op-name`
* This corresponds to the mnemonic name of an operation to run passes on,
e.g. `builtin.func` or `builtin.module`.
e.g. `func.func` or `builtin.module`.
* `pass-name` | `pass-pipeline-name`
* This corresponds to the argument of a registered pass or pass pipeline,
e.g. `cse` or `canonicalize`.
Expand All @@ -676,7 +676,7 @@ $ mlir-opt foo.mlir -cse -canonicalize -convert-func-to-llvm='use-bare-ptr-memre
Can also be specified as (via the `-pass-pipeline` flag):

```shell
$ mlir-opt foo.mlir -pass-pipeline='builtin.func(cse,canonicalize),convert-func-to-llvm{use-bare-ptr-memref-call-conv=1}'
$ mlir-opt foo.mlir -pass-pipeline='func.func(cse,canonicalize),convert-func-to-llvm{use-bare-ptr-memref-call-conv=1}'
```

In order to support round-tripping a pass to the textual representation using
Expand Down Expand Up @@ -997,7 +997,7 @@ pipeline. This display mode is available in mlir-opt via
`-mlir-timing-display=list`.
```shell
$ mlir-opt foo.mlir -mlir-disable-threading -pass-pipeline='builtin.func(cse,canonicalize)' -convert-func-to-llvm -mlir-timing -mlir-timing-display=list
$ mlir-opt foo.mlir -mlir-disable-threading -pass-pipeline='func.func(cse,canonicalize)' -convert-func-to-llvm -mlir-timing -mlir-timing-display=list
===-------------------------------------------------------------------------===
... Pass execution timing report ...
Expand All @@ -1022,15 +1022,15 @@ the most time, and can also be used to identify when analyses are being
invalidated and recomputed. This is the default display mode.

```shell
$ mlir-opt foo.mlir -mlir-disable-threading -pass-pipeline='builtin.func(cse,canonicalize)' -convert-func-to-llvm -mlir-timing
$ mlir-opt foo.mlir -mlir-disable-threading -pass-pipeline='func.func(cse,canonicalize)' -convert-func-to-llvm -mlir-timing

===-------------------------------------------------------------------------===
... Pass execution timing report ...
===-------------------------------------------------------------------------===
Total Execution Time: 0.0249 seconds

---Wall Time--- --- Name ---
0.0058 ( 70.8%) 'builtin.func' Pipeline
0.0058 ( 70.8%) 'func.func' Pipeline
0.0004 ( 4.3%) CSE
0.0002 ( 2.6%) (A) DominanceInfo
0.0004 ( 4.8%) VerifierPass
Expand All @@ -1053,15 +1053,15 @@ perceived time, or clock time, whereas the `User Time` will display the total
cpu time.

```shell
$ mlir-opt foo.mlir -pass-pipeline='builtin.func(cse,canonicalize)' -convert-func-to-llvm -mlir-timing
$ mlir-opt foo.mlir -pass-pipeline='func.func(cse,canonicalize)' -convert-func-to-llvm -mlir-timing

===-------------------------------------------------------------------------===
... Pass execution timing report ...
===-------------------------------------------------------------------------===
Total Execution Time: 0.0078 seconds

---User Time--- ---Wall Time--- --- Name ---
0.0177 ( 88.5%) 0.0057 ( 71.3%) 'builtin.func' Pipeline
0.0177 ( 88.5%) 0.0057 ( 71.3%) 'func.func' Pipeline
0.0044 ( 22.0%) 0.0015 ( 18.9%) CSE
0.0029 ( 14.5%) 0.0012 ( 15.2%) (A) DominanceInfo
0.0038 ( 18.9%) 0.0015 ( 18.7%) VerifierPass
Expand Down Expand Up @@ -1089,7 +1089,7 @@ this instrumentation:
* Print the IR before every pass in the pipeline.

```shell
$ mlir-opt foo.mlir -pass-pipeline='builtin.func(cse)' -print-ir-before=cse
$ mlir-opt foo.mlir -pass-pipeline='func.func(cse)' -print-ir-before=cse

*** IR Dump Before CSE ***
func @simple_constant() -> (i32, i32) {
Expand All @@ -1105,7 +1105,7 @@ func @simple_constant() -> (i32, i32) {
* Print the IR after every pass in the pipeline.

```shell
$ mlir-opt foo.mlir -pass-pipeline='builtin.func(cse)' -print-ir-after=cse
$ mlir-opt foo.mlir -pass-pipeline='func.func(cse)' -print-ir-after=cse

*** IR Dump After CSE ***
func @simple_constant() -> (i32, i32) {
Expand All @@ -1126,7 +1126,7 @@ func @simple_constant() -> (i32, i32) {
printing.

```shell
$ mlir-opt foo.mlir -pass-pipeline='builtin.func(cse,cse)' -print-ir-after=cse -print-ir-after-change
$ mlir-opt foo.mlir -pass-pipeline='func.func(cse,cse)' -print-ir-after=cse -print-ir-after-change

*** IR Dump After CSE ***
func @simple_constant() -> (i32, i32) {
Expand All @@ -1141,7 +1141,7 @@ func @simple_constant() -> (i32, i32) {
above.

```shell
$ mlir-opt foo.mlir -pass-pipeline='builtin.func(cse,bad-pass)' -print-ir-failure
$ mlir-opt foo.mlir -pass-pipeline='func.func(cse,bad-pass)' -print-ir-failure

*** IR Dump After BadPass Failed ***
func @simple_constant() -> (i32, i32) {
Expand All @@ -1157,9 +1157,9 @@ func @simple_constant() -> (i32, i32) {
is disabled(`-mlir-disable-threading`)

```shell
$ mlir-opt foo.mlir -mlir-disable-threading -pass-pipeline='builtin.func(cse)' -print-ir-after=cse -print-ir-module-scope
$ mlir-opt foo.mlir -mlir-disable-threading -pass-pipeline='func.func(cse)' -print-ir-after=cse -print-ir-module-scope

*** IR Dump After CSE *** ('builtin.func' operation: @bar)
*** IR Dump After CSE *** ('func.func' operation: @bar)
func @bar(%arg0: f32, %arg1: f32) -> f32 {
...
}
Expand All @@ -1170,7 +1170,7 @@ func @simple_constant() -> (i32, i32) {
return %c1_i32, %c1_i32_0 : i32, i32
}

*** IR Dump After CSE *** ('builtin.func' operation: @simple_constant)
*** IR Dump After CSE *** ('func.func' operation: @simple_constant)
func @bar(%arg0: f32, %arg1: f32) -> f32 {
...
}
Expand All @@ -1194,7 +1194,7 @@ was executing, as well as the initial IR before any passes were run. A potential
reproducible may have the form:

```mlir
// configuration: -pass-pipeline='builtin.func(cse,canonicalize),inline' -verify-each
// configuration: -pass-pipeline='func.func(cse,canonicalize),inline' -verify-each

module {
func @foo() {
Expand Down Expand Up @@ -1229,7 +1229,7 @@ For example, if the failure in the previous example came from `canonicalize`,
the following reproducer will be generated:

```mlir
// configuration: -pass-pipeline='builtin.func(canonicalize)' -verify-each -mlir-disable-threading
// configuration: -pass-pipeline='func.func(canonicalize)' -verify-each -mlir-disable-threading
module {
func @foo() {
Expand Down
6 changes: 3 additions & 3 deletions mlir/docs/SymbolsAndSymbolTables.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ defines a [`SymbolTable`](#symbol-table). The name of a symbol *must* be unique
within the parent `SymbolTable`. This name is semantically similarly to an SSA
result value, and may be referred to by other operations to provide a symbolic
link, or use, to the symbol. An example of a `Symbol` operation is
[`builtin.func`](Dialects/Builtin.md/#func-mlirfuncop). `builtin.func` defines a
[`func.func`](Dialects/Builtin.md/#func-mlirfuncop). `func.func` defines a
symbol name, which is [referred to](#referencing-a-symbol) by operations like
[`func.call`](Dialects/Func.md/#funccall-callop).

Expand Down Expand Up @@ -77,7 +77,7 @@ operation that is also a [symbol table](#symbol-table).
Below is an example of how an operation can reference a symbol operation:

```mlir
// This `builtin.func` operation defines a symbol named `symbol`.
// This `func.func` operation defines a symbol named `symbol`.
func @symbol()
// Our `foo.user` operation contains a SymbolRefAttr with the name of the
Expand Down Expand Up @@ -106,7 +106,7 @@ module {
// Here we define another nested symbol table, except this time it also defines
// a symbol.
module @module_symbol {
// This `builtin.func` operation defines a symbol named `nested_symbol`.
// This `func.func` operation defines a symbol named `nested_symbol`.
func @nested_symbol()
}
Expand Down
2 changes: 1 addition & 1 deletion mlir/docs/TargetLLVMIR.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ individual scalar arguments.

Examples:

This convention is implemented in the conversion of `builtin.func` and `func.call` to
This convention is implemented in the conversion of `func.func` and `func.call` to
the LLVM dialect, with the former unpacking the descriptor into a set of
individual values and the latter packing those values back into a descriptor so
as to make it transparently usable by other operations. Conversions from other
Expand Down
6 changes: 3 additions & 3 deletions mlir/examples/toy/Ch2/include/toy/Ops.td
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def FuncOp : Toy_Op<"func", [

let arguments = (ins
SymbolNameAttr:$sym_name,
TypeAttrOf<FunctionType>:$type
TypeAttrOf<FunctionType>:$function_type
);
let regions = (region AnyRegion:$body);

Expand All @@ -149,10 +149,10 @@ def FuncOp : Toy_Op<"func", [
//===------------------------------------------------------------------===//

/// Returns the argument types of this function.
ArrayRef<Type> getArgumentTypes() { return getType().getInputs(); }
ArrayRef<Type> getArgumentTypes() { return getFunctionType().getInputs(); }

/// Returns the result types of this function.
ArrayRef<Type> getResultTypes() { return getType().getResults(); }
ArrayRef<Type> getResultTypes() { return getFunctionType().getResults(); }
}];
let hasCustomAssemblyFormat = 1;
let skipDefaultBuilders = 1;
Expand Down
2 changes: 1 addition & 1 deletion mlir/examples/toy/Ch2/mlir/Dialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ mlir::LogicalResult ReturnOp::verify() {
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 ("
Expand Down
4 changes: 2 additions & 2 deletions mlir/examples/toy/Ch2/mlir/MLIRGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ class MLIRGenImpl {
} 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;
Expand Down
6 changes: 3 additions & 3 deletions mlir/examples/toy/Ch3/include/toy/Ops.td
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def FuncOp : Toy_Op<"func", [

let arguments = (ins
SymbolNameAttr:$sym_name,
TypeAttrOf<FunctionType>:$type
TypeAttrOf<FunctionType>:$function_type
);
let regions = (region AnyRegion:$body);

Expand All @@ -148,10 +148,10 @@ def FuncOp : Toy_Op<"func", [
//===------------------------------------------------------------------===//

/// Returns the argument types of this function.
ArrayRef<Type> getArgumentTypes() { return getType().getInputs(); }
ArrayRef<Type> getArgumentTypes() { return getFunctionType().getInputs(); }

/// Returns the result types of this function.
ArrayRef<Type> getResultTypes() { return getType().getResults(); }
ArrayRef<Type> getResultTypes() { return getFunctionType().getResults(); }
}];
let hasCustomAssemblyFormat = 1;
let skipDefaultBuilders = 1;
Expand Down
2 changes: 1 addition & 1 deletion mlir/examples/toy/Ch3/mlir/Dialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ mlir::LogicalResult ReturnOp::verify() {
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 ("
Expand Down
4 changes: 2 additions & 2 deletions mlir/examples/toy/Ch3/mlir/MLIRGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ class MLIRGenImpl {
} 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;
Expand Down
6 changes: 3 additions & 3 deletions mlir/examples/toy/Ch4/include/toy/Ops.td
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def FuncOp : Toy_Op<"func", [

let arguments = (ins
SymbolNameAttr:$sym_name,
TypeAttrOf<FunctionType>:$type
TypeAttrOf<FunctionType>:$function_type
);
let regions = (region AnyRegion:$body);

Expand All @@ -178,10 +178,10 @@ def FuncOp : Toy_Op<"func", [
//===------------------------------------------------------------------===//

/// Returns the argument types of this function.
ArrayRef<Type> getArgumentTypes() { return getType().getInputs(); }
ArrayRef<Type> getArgumentTypes() { return getFunctionType().getInputs(); }

/// Returns the result types of this function.
ArrayRef<Type> getResultTypes() { return getType().getResults(); }
ArrayRef<Type> getResultTypes() { return getFunctionType().getResults(); }
}];
let hasCustomAssemblyFormat = 1;
let skipDefaultBuilders = 1;
Expand Down
4 changes: 2 additions & 2 deletions mlir/examples/toy/Ch4/mlir/Dialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ mlir::Region *FuncOp::getCallableRegion() { return &getBody(); }
/// Returns the results types that the callable region produces when
/// executed.
llvm::ArrayRef<mlir::Type> FuncOp::getCallableResults() {
return getType().getResults();
return getFunctionType().getResults();
}

//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -364,7 +364,7 @@ mlir::LogicalResult ReturnOp::verify() {
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 ("
Expand Down
4 changes: 2 additions & 2 deletions mlir/examples/toy/Ch4/mlir/MLIRGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ class MLIRGenImpl {
} 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.
Expand Down
6 changes: 3 additions & 3 deletions mlir/examples/toy/Ch5/include/toy/Ops.td
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def FuncOp : Toy_Op<"func", [

let arguments = (ins
SymbolNameAttr:$sym_name,
TypeAttrOf<FunctionType>:$type
TypeAttrOf<FunctionType>:$function_type
);
let regions = (region AnyRegion:$body);

Expand All @@ -178,10 +178,10 @@ def FuncOp : Toy_Op<"func", [
//===------------------------------------------------------------------===//

/// Returns the argument types of this function.
ArrayRef<Type> getArgumentTypes() { return getType().getInputs(); }
ArrayRef<Type> getArgumentTypes() { return getFunctionType().getInputs(); }

/// Returns the result types of this function.
ArrayRef<Type> getResultTypes() { return getType().getResults(); }
ArrayRef<Type> getResultTypes() { return getFunctionType().getResults(); }
}];
let hasCustomAssemblyFormat = 1;
let skipDefaultBuilders = 1;
Expand Down
4 changes: 2 additions & 2 deletions mlir/examples/toy/Ch5/mlir/Dialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ mlir::Region *FuncOp::getCallableRegion() { return &getBody(); }
/// Returns the results types that the callable region produces when
/// executed.
llvm::ArrayRef<mlir::Type> FuncOp::getCallableResults() {
return getType().getResults();
return getFunctionType().getResults();
}

//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -364,7 +364,7 @@ mlir::LogicalResult ReturnOp::verify() {
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 ("
Expand Down
6 changes: 3 additions & 3 deletions mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,15 @@ struct FuncOpLowering : public OpConversionPattern<toy::FuncOp> {
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<mlir::FuncOp>(op.getLoc(), op.getName(), op.getType());
auto func = rewriter.create<mlir::FuncOp>(op.getLoc(), op.getName(),
op.getFunctionType());
rewriter.inlineRegionBefore(op.getRegion(), func.getBody(), func.end());
rewriter.eraseOp(op);
return success();
Expand Down
4 changes: 2 additions & 2 deletions mlir/examples/toy/Ch5/mlir/MLIRGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ class MLIRGenImpl {
} 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.
Expand Down
6 changes: 3 additions & 3 deletions mlir/examples/toy/Ch6/include/toy/Ops.td
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def FuncOp : Toy_Op<"func", [

let arguments = (ins
SymbolNameAttr:$sym_name,
TypeAttrOf<FunctionType>:$type
TypeAttrOf<FunctionType>:$function_type
);
let regions = (region AnyRegion:$body);

Expand All @@ -178,10 +178,10 @@ def FuncOp : Toy_Op<"func", [
//===------------------------------------------------------------------===//

/// Returns the argument types of this function.
ArrayRef<Type> getArgumentTypes() { return getType().getInputs(); }
ArrayRef<Type> getArgumentTypes() { return getFunctionType().getInputs(); }

/// Returns the result types of this function.
ArrayRef<Type> getResultTypes() { return getType().getResults(); }
ArrayRef<Type> getResultTypes() { return getFunctionType().getResults(); }
}];
let hasCustomAssemblyFormat = 1;
let skipDefaultBuilders = 1;
Expand Down
4 changes: 2 additions & 2 deletions mlir/examples/toy/Ch6/mlir/Dialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ mlir::Region *FuncOp::getCallableRegion() { return &getBody(); }
/// Returns the results types that the callable region produces when
/// executed.
llvm::ArrayRef<mlir::Type> FuncOp::getCallableResults() {
return getType().getResults();
return getFunctionType().getResults();
}

//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -364,7 +364,7 @@ mlir::LogicalResult ReturnOp::verify() {
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 ("
Expand Down
6 changes: 3 additions & 3 deletions mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,15 @@ struct FuncOpLowering : public OpConversionPattern<toy::FuncOp> {
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<mlir::FuncOp>(op.getLoc(), op.getName(), op.getType());
auto func = rewriter.create<mlir::FuncOp>(op.getLoc(), op.getName(),
op.getFunctionType());
rewriter.inlineRegionBefore(op.getRegion(), func.getBody(), func.end());
rewriter.eraseOp(op);
return success();
Expand Down
4 changes: 2 additions & 2 deletions mlir/examples/toy/Ch6/mlir/MLIRGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ class MLIRGenImpl {
} 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.
Expand Down
6 changes: 3 additions & 3 deletions mlir/examples/toy/Ch7/include/toy/Ops.td
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def FuncOp : Toy_Op<"func", [

let arguments = (ins
SymbolNameAttr:$sym_name,
TypeAttrOf<FunctionType>:$type
TypeAttrOf<FunctionType>:$function_type
);
let regions = (region AnyRegion:$body);

Expand All @@ -197,10 +197,10 @@ def FuncOp : Toy_Op<"func", [
//===------------------------------------------------------------------===//

/// Returns the argument types of this function.
ArrayRef<Type> getArgumentTypes() { return getType().getInputs(); }
ArrayRef<Type> getArgumentTypes() { return getFunctionType().getInputs(); }

/// Returns the result types of this function.
ArrayRef<Type> getResultTypes() { return getType().getResults(); }
ArrayRef<Type> getResultTypes() { return getFunctionType().getResults(); }
}];
let hasCustomAssemblyFormat = 1;
let skipDefaultBuilders = 1;
Expand Down
4 changes: 2 additions & 2 deletions mlir/examples/toy/Ch7/mlir/Dialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ mlir::Region *FuncOp::getCallableRegion() { return &getBody(); }
/// Returns the results types that the callable region produces when
/// executed.
llvm::ArrayRef<mlir::Type> FuncOp::getCallableResults() {
return getType().getResults();
return getFunctionType().getResults();
}

//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -391,7 +391,7 @@ mlir::LogicalResult ReturnOp::verify() {
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 ("
Expand Down
6 changes: 3 additions & 3 deletions mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,15 @@ struct FuncOpLowering : public OpConversionPattern<toy::FuncOp> {
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<mlir::FuncOp>(op.getLoc(), op.getName(), op.getType());
auto func = rewriter.create<mlir::FuncOp>(op.getLoc(), op.getName(),
op.getFunctionType());
rewriter.inlineRegionBefore(op.getRegion(), func.getBody(), func.end());
rewriter.eraseOp(op);
return success();
Expand Down
7 changes: 4 additions & 3 deletions mlir/examples/toy/Ch7/mlir/MLIRGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,9 @@ class MLIRGenImpl {
} 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.
Expand Down Expand Up @@ -519,7 +520,7 @@ class MLIRGenImpl {
}
mlir::toy::FuncOp calledFunc = calledFuncIt->second;
return builder.create<GenericCallOp>(
location, calledFunc.getType().getResult(0),
location, calledFunc.getFunctionType().getResult(0),
mlir::SymbolRefAttr::get(builder.getContext(), callee), operands);
}

Expand Down
13 changes: 8 additions & 5 deletions mlir/include/mlir/Dialect/Affine/LoopUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@
namespace mlir {
class AffineForOp;
class AffineMap;
class FuncOp;
class LoopLikeOpInterface;
struct MemRefRegion;
class OpBuilder;
class Value;
class ValueRange;

namespace func {
class FuncOp;
} // namespace func

namespace scf {
class ForOp;
class ParallelOp;
Expand Down Expand Up @@ -79,7 +82,7 @@ LogicalResult promoteIfSingleIteration(AffineForOp forOp);

/// Promotes all single iteration AffineForOp's in the Function, i.e., moves
/// their body into the containing Block.
void promoteSingleIterationLoops(FuncOp f);
void promoteSingleIterationLoops(func::FuncOp f);

/// Skew the operations in an affine.for's body with the specified
/// operation-wise shifts. The shifts are with respect to the original execution
Expand All @@ -92,7 +95,7 @@ LogicalResult affineForOpBodySkew(AffineForOp forOp, ArrayRef<uint64_t> shifts,
/// Identify valid and profitable bands of loops to tile. This is currently just
/// a temporary placeholder to test the mechanics of tiled code generation.
/// Returns all maximal outermost perfect loop nests to tile.
void getTileableBands(FuncOp f,
void getTileableBands(func::FuncOp f,
std::vector<SmallVector<AffineForOp, 6>> *bands);

/// Tiles the specified band of perfectly nested loops creating tile-space loops
Expand Down Expand Up @@ -259,8 +262,8 @@ LogicalResult coalesceLoops(MutableArrayRef<AffineForOp> loops);
void mapLoopToProcessorIds(scf::ForOp forOp, ArrayRef<Value> processorId,
ArrayRef<Value> numProcessors);

/// Gathers all AffineForOps in 'builtin.func' grouped by loop depth.
void gatherLoops(FuncOp func,
/// Gathers all AffineForOps in 'func.func' grouped by loop depth.
void gatherLoops(func::FuncOp func,
std::vector<SmallVector<AffineForOp, 2>> &depthToLoops);

/// Creates an AffineForOp while ensuring that the lower and upper bounds are
Expand Down
38 changes: 22 additions & 16 deletions mlir/include/mlir/Dialect/Affine/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
#include <limits>

namespace mlir {
namespace func {
class FuncOp;
} // namespace func

class AffineForOp;

Expand All @@ -28,81 +31,84 @@ enum FusionMode { Greedy, ProducerConsumer, Sibling };
/// Creates a simplification pass for affine structures (maps and sets). In
/// addition, this pass also normalizes memrefs to have the trivial (identity)
/// layout map.
std::unique_ptr<OperationPass<FuncOp>> createSimplifyAffineStructuresPass();
std::unique_ptr<OperationPass<func::FuncOp>>
createSimplifyAffineStructuresPass();

/// Creates a loop invariant code motion pass that hoists loop invariant
/// operations out of affine loops.
std::unique_ptr<OperationPass<FuncOp>>
std::unique_ptr<OperationPass<func::FuncOp>>
createAffineLoopInvariantCodeMotionPass();

/// Creates a pass to convert all parallel affine.for's into 1-d affine.parallel
/// ops.
std::unique_ptr<OperationPass<FuncOp>> createAffineParallelizePass();
std::unique_ptr<OperationPass<func::FuncOp>> createAffineParallelizePass();

/// Apply normalization transformations to affine loop-like ops.
std::unique_ptr<OperationPass<FuncOp>> createAffineLoopNormalizePass();
std::unique_ptr<OperationPass<func::FuncOp>> createAffineLoopNormalizePass();

/// Performs packing (or explicit copying) of accessed memref regions into
/// buffers in the specified faster memory space through either pointwise copies
/// or DMA operations.
std::unique_ptr<OperationPass<FuncOp>> createAffineDataCopyGenerationPass(
std::unique_ptr<OperationPass<func::FuncOp>> createAffineDataCopyGenerationPass(
unsigned slowMemorySpace, unsigned fastMemorySpace,
unsigned tagMemorySpace = 0, int minDmaTransferSize = 1024,
uint64_t fastMemCapacityBytes = std::numeric_limits<uint64_t>::max());
/// Overload relying on pass options for initialization.
std::unique_ptr<OperationPass<FuncOp>> createAffineDataCopyGenerationPass();
std::unique_ptr<OperationPass<func::FuncOp>>
createAffineDataCopyGenerationPass();

/// Creates a pass to replace affine memref accesses by scalars using store to
/// load forwarding and redundant load elimination; consequently also eliminate
/// dead allocs.
std::unique_ptr<OperationPass<FuncOp>> createAffineScalarReplacementPass();
std::unique_ptr<OperationPass<func::FuncOp>>
createAffineScalarReplacementPass();

/// Creates a pass that transforms perfectly nested loops with independent
/// bounds into a single loop.
std::unique_ptr<OperationPass<FuncOp>> createLoopCoalescingPass();
std::unique_ptr<OperationPass<func::FuncOp>> createLoopCoalescingPass();

/// Creates a loop fusion pass which fuses loops according to type of fusion
/// specified in `fusionMode`. Buffers of size less than or equal to
/// `localBufSizeThreshold` are promoted to memory space `fastMemorySpace`.
std::unique_ptr<OperationPass<FuncOp>>
std::unique_ptr<OperationPass<func::FuncOp>>
createLoopFusionPass(unsigned fastMemorySpace = 0,
uint64_t localBufSizeThreshold = 0,
bool maximalFusion = false,
enum FusionMode fusionMode = FusionMode::Greedy);

/// Creates a pass to perform tiling on loop nests.
std::unique_ptr<OperationPass<FuncOp>>
std::unique_ptr<OperationPass<func::FuncOp>>
createLoopTilingPass(uint64_t cacheSizeBytes);
/// Overload relying on pass options for initialization.
std::unique_ptr<OperationPass<FuncOp>> createLoopTilingPass();
std::unique_ptr<OperationPass<func::FuncOp>> createLoopTilingPass();

/// Creates a loop unrolling pass with the provided parameters.
/// 'getUnrollFactor' is a function callback for clients to supply a function
/// that computes an unroll factor - the callback takes precedence over unroll
/// factors supplied through other means. If -1 is passed as the unrollFactor
/// and no callback is provided, anything passed from the command-line (if at
/// all) or the default unroll factor is used (LoopUnroll:kDefaultUnrollFactor).
std::unique_ptr<OperationPass<FuncOp>> createLoopUnrollPass(
std::unique_ptr<OperationPass<func::FuncOp>> createLoopUnrollPass(
int unrollFactor = -1, bool unrollUpToFactor = false,
bool unrollFull = false,
const std::function<unsigned(AffineForOp)> &getUnrollFactor = nullptr);

/// Creates a loop unroll jam pass to unroll jam by the specified factor. A
/// factor of -1 lets the pass use the default factor or the one on the command
/// line if provided.
std::unique_ptr<OperationPass<FuncOp>>
std::unique_ptr<OperationPass<func::FuncOp>>
createLoopUnrollAndJamPass(int unrollJamFactor = -1);

/// Creates a pass to pipeline explicit movement of data across levels of the
/// memory hierarchy.
std::unique_ptr<OperationPass<FuncOp>> createPipelineDataTransferPass();
std::unique_ptr<OperationPass<func::FuncOp>> createPipelineDataTransferPass();

/// Creates a pass to vectorize loops, operations and data types using a
/// target-independent, n-D super-vector abstraction.
std::unique_ptr<OperationPass<FuncOp>>
std::unique_ptr<OperationPass<func::FuncOp>>
createSuperVectorizePass(ArrayRef<int64_t> virtualVectorSize);
/// Overload relying on pass options for initialization.
std::unique_ptr<OperationPass<FuncOp>> createSuperVectorizePass();
std::unique_ptr<OperationPass<func::FuncOp>> createSuperVectorizePass();

//===----------------------------------------------------------------------===//
// Registration
Expand Down
7 changes: 5 additions & 2 deletions mlir/include/mlir/Dialect/Affine/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ class AffineForOp;
class AffineIfOp;
class AffineParallelOp;
class DominanceInfo;
class FuncOp;
class Operation;
class PostDominanceInfo;

namespace func {
class FuncOp;
} // namespace func

namespace memref {
class AllocOp;
} // namespace memref
Expand Down Expand Up @@ -96,7 +99,7 @@ struct VectorizationStrategy {
/// Replace affine store and load accesses by scalars by forwarding stores to
/// loads and eliminate invariant affine loads; consequently, eliminate dead
/// allocs.
void affineScalarReplace(FuncOp f, DominanceInfo &domInfo,
void affineScalarReplace(func::FuncOp f, DominanceInfo &domInfo,
PostDominanceInfo &postDomInfo);

/// Vectorizes affine loops in 'loops' using the n-D vectorization factors in
Expand Down
6 changes: 5 additions & 1 deletion mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#include "mlir/Pass/Pass.h"

namespace mlir {
namespace func {
class FuncOp;
} // namespace func

namespace bufferization {
struct OneShotBufferizationOptions;

Expand Down Expand Up @@ -31,7 +35,7 @@ std::unique_ptr<Pass> createBufferResultsToOutParamsPass();

/// Creates a pass that finalizes a partial bufferization by removing remaining
/// bufferization.to_tensor and bufferization.to_memref operations.
std::unique_ptr<OperationPass<FuncOp>> createFinalizingBufferizePass();
std::unique_ptr<OperationPass<func::FuncOp>> createFinalizingBufferizePass();

/// Create a pass that bufferizes all ops that implement BufferizableOpInterface
/// with One-Shot Bufferize.
Expand Down
10 changes: 5 additions & 5 deletions mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

include "mlir/Pass/PassBase.td"

def BufferDeallocation : Pass<"buffer-deallocation", "FuncOp"> {
def BufferDeallocation : Pass<"buffer-deallocation", "func::FuncOp"> {
let summary = "Adds all required dealloc operations for all allocations in "
"the input program";
let description = [{
Expand Down Expand Up @@ -88,7 +88,7 @@ def BufferDeallocation : Pass<"buffer-deallocation", "FuncOp"> {
let constructor = "mlir::bufferization::createBufferDeallocationPass()";
}

def BufferHoisting : Pass<"buffer-hoisting", "FuncOp"> {
def BufferHoisting : Pass<"buffer-hoisting", "func::FuncOp"> {
let summary = "Optimizes placement of allocation operations by moving them "
"into common dominators and out of nested regions";
let description = [{
Expand All @@ -98,7 +98,7 @@ def BufferHoisting : Pass<"buffer-hoisting", "FuncOp"> {
let constructor = "mlir::bufferization::createBufferHoistingPass()";
}

def BufferLoopHoisting : Pass<"buffer-loop-hoisting", "FuncOp"> {
def BufferLoopHoisting : Pass<"buffer-loop-hoisting", "func::FuncOp"> {
let summary = "Optimizes placement of allocation operations by moving them "
"out of loop nests";
let description = [{
Expand Down Expand Up @@ -133,7 +133,7 @@ def BufferResultsToOutParams : Pass<"buffer-results-to-out-params", "ModuleOp">
let dependentDialects = ["memref::MemRefDialect"];
}

def FinalizingBufferize : Pass<"finalizing-bufferize", "FuncOp"> {
def FinalizingBufferize : Pass<"finalizing-bufferize", "func::FuncOp"> {
let summary = "Finalize a partial bufferization";
let description = [{
A bufferize pass that finalizes a partial bufferization by removing
Expand Down Expand Up @@ -231,7 +231,7 @@ def OneShotBufferize : Pass<"one-shot-bufferize", "ModuleOp"> {
let constructor = "mlir::bufferization::createOneShotBufferizePass()";
}

def PromoteBuffersToStack : Pass<"promote-buffers-to-stack", "FuncOp"> {
def PromoteBuffersToStack : Pass<"promote-buffers-to-stack", "func::FuncOp"> {
let summary = "Promotes heap-based allocations to automatically managed "
"stack-based allocations";
let description = [{
Expand Down
24 changes: 23 additions & 1 deletion mlir/include/mlir/Dialect/Func/IR/FuncOps.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@

#include "mlir/Dialect/ControlFlow/IR/ControlFlow.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/FunctionInterfaces.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/IR/SymbolTable.h"
#include "mlir/Interfaces/CallInterfaces.h"
#include "mlir/Interfaces/ControlFlowInterfaces.h"
#include "mlir/Interfaces/InferTypeOpInterface.h"
Expand All @@ -29,4 +30,25 @@ class PatternRewriter;

#include "mlir/Dialect/Func/IR/FuncOpsDialect.h.inc"

namespace mlir {
/// FIXME: This is a temporary using directive to ease the transition of FuncOp
/// to the Func dialect. This will be removed after all uses are updated.
using FuncOp = func::FuncOp;
} // namespace mlir

namespace llvm {

/// Allow stealing the low bits of FuncOp.
template <>
struct PointerLikeTypeTraits<mlir::func::FuncOp> {
static inline void *getAsVoidPointer(mlir::func::FuncOp val) {
return const_cast<void *>(val.getAsOpaquePointer());
}
static inline mlir::func::FuncOp getFromVoidPointer(void *p) {
return mlir::func::FuncOp::getFromOpaquePointer(p);
}
static constexpr int numLowBitsAvailable = 3;
};
} // namespace llvm

#endif // MLIR_DIALECT_FUNC_IR_OPS_H
117 changes: 116 additions & 1 deletion mlir/include/mlir/Dialect/Func/IR/FuncOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ include "mlir/IR/OpAsmInterface.td"
include "mlir/IR/SymbolInterfaces.td"
include "mlir/Interfaces/CallInterfaces.td"
include "mlir/Interfaces/ControlFlowInterfaces.td"
include "mlir/IR/FunctionInterfaces.td"
include "mlir/Interfaces/InferTypeOpInterface.td"
include "mlir/Interfaces/SideEffectInterfaces.td"

Expand Down Expand Up @@ -56,7 +57,7 @@ def CallOp : Func_Op<"call",
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), [{
Expand Down Expand Up @@ -201,6 +202,120 @@ def ConstantOp : Func_Op<"constant",
let hasVerifier = 1;
}

//===----------------------------------------------------------------------===//
// FuncOp
//===----------------------------------------------------------------------===//

def FuncOp : Func_Op<"func", [
AffineScope, AutomaticAllocationScope, CallableOpInterface,
FunctionOpInterface, IsolatedFromAbove, Symbol
]> {
let summary = "An operation with a name containing a single `SSACFG` region";
let description = [{
Operations within the function cannot implicitly capture values defined
outside of the function, i.e. Functions are `IsolatedFromAbove`. All
external references must use function arguments or attributes that establish
a symbolic connection (e.g. symbols referenced by name via a string
attribute like SymbolRefAttr). An external function declaration (used when
referring to a function declared in some other module) has no body. While
the MLIR textual form provides a nice inline syntax for function arguments,
they are internally represented as “block arguments” to the first block in
the region.

Only dialect attribute names may be specified in the attribute dictionaries
for function arguments, results, or the function itself.

Example:

```mlir
// External function definitions.
func.func @abort()
func.func @scribble(i32, i64, memref<? x 128 x f32, #layout_map0>) -> f64

// A function that returns its argument twice:
func.func @count(%x: i64) -> (i64, i64)
attributes {fruit: "banana"} {
return %x, %x: i64, i64
}

// A function with an argument attribute
func.func @example_fn_arg(%x: i32 {swift.self = unit})

// A function with a result attribute
func.func @example_fn_result() -> (f64 {dialectName.attrName = 0 : i64})

// A function with an attribute
func.func @example_fn_attr() attributes {dialectName.attrName = false}
```
}];

let arguments = (ins SymbolNameAttr:$sym_name,
TypeAttrOf<FunctionType>:$function_type,
OptionalAttr<StrAttr>:$sym_visibility);
let regions = (region AnyRegion:$body);

let builders = [OpBuilder<(ins
"StringRef":$name, "FunctionType":$type,
CArg<"ArrayRef<NamedAttribute>", "{}">:$attrs,
CArg<"ArrayRef<DictionaryAttr>", "{}">:$argAttrs)
>];
let extraClassDeclaration = [{
static FuncOp create(Location location, StringRef name, FunctionType type,
ArrayRef<NamedAttribute> attrs = {});
static FuncOp create(Location location, StringRef name, FunctionType type,
Operation::dialect_attr_range attrs);
static FuncOp create(Location location, StringRef name, FunctionType type,
ArrayRef<NamedAttribute> attrs,
ArrayRef<DictionaryAttr> argAttrs);

/// Create a deep copy of this function and all of its blocks, remapping any
/// operands that use values outside of the function using the map that is
/// provided (leaving them alone if no entry is present). If the mapper
/// contains entries for function arguments, these arguments are not
/// included in the new function. Replaces references to cloned sub-values
/// with the corresponding value that is copied, and adds those mappings to
/// the mapper.
FuncOp clone(BlockAndValueMapping &mapper);
FuncOp clone();

/// Clone the internal blocks and attributes from this function into dest.
/// Any cloned blocks are appended to the back of dest. This function
/// asserts that the attributes of the current function and dest are
/// compatible.
void cloneInto(FuncOp dest, BlockAndValueMapping &mapper);

//===------------------------------------------------------------------===//
// CallableOpInterface
//===------------------------------------------------------------------===//

/// Returns the region on the current operation that is callable. This may
/// return null in the case of an external callable object, e.g. an external
/// function.
::mlir::Region *getCallableRegion() { return isExternal() ? nullptr : &getBody(); }

/// Returns the results types that the callable region produces when
/// executed.
ArrayRef<Type> getCallableResults() { return getFunctionType().getResults(); }

//===------------------------------------------------------------------===//
// FunctionOpInterface Methods
//===------------------------------------------------------------------===//

/// Returns the argument types of this function.
ArrayRef<Type> getArgumentTypes() { return getFunctionType().getInputs(); }

/// Returns the result types of this function.
ArrayRef<Type> getResultTypes() { return getFunctionType().getResults(); }

//===------------------------------------------------------------------===//
// SymbolOpInterface Methods
//===------------------------------------------------------------------===//

bool isDeclaration() { return isExternal(); }
}];
let hasCustomAssemblyFormat = 1;
}

//===----------------------------------------------------------------------===//
// ReturnOp
//===----------------------------------------------------------------------===//
Expand Down
4 changes: 2 additions & 2 deletions mlir/include/mlir/Dialect/Func/Transforms/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ include "mlir/Pass/PassBase.td"
def FuncBufferize : Pass<"func-bufferize", "ModuleOp"> {
let summary = "Bufferize func/call/return ops";
let description = [{
A bufferize pass that bufferizes builtin.func and func.call ops.
A bufferize pass that bufferizes func.func and func.call ops.

Because this pass updates builtin.func ops, it must be a module pass. It is
Because this pass updates func.func ops, it must be a module pass. It is
useful to keep this pass separate from other bufferizations so that the
other ones can be run at function-level in parallel.

Expand Down
17 changes: 8 additions & 9 deletions mlir/include/mlir/Dialect/GPU/GPUOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ def GPU_GPUFuncOp : GPU_Op<"func", [
attribution.
}];

let arguments = (ins TypeAttrOf<FunctionType>:$function_type);
let regions = (region AnyRegion:$body);

let skipDefaultBuilders = 1;
Expand Down Expand Up @@ -250,7 +251,7 @@ def GPU_GPUFuncOp : GPU_Op<"func", [
/// the workgroup memory
ArrayRef<BlockArgument> 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};
}
Expand All @@ -261,7 +262,7 @@ def GPU_GPUFuncOp : GPU_Op<"func", [

/// Returns the number of buffers located in the private memory.
unsigned getNumPrivateAttributions() {
return getBody().getNumArguments() - getType().getNumInputs() -
return getBody().getNumArguments() - getFunctionType().getNumInputs() -
getNumWorkgroupAttributions();
}

Expand All @@ -272,7 +273,7 @@ def GPU_GPUFuncOp : GPU_Op<"func", [
// memory.
auto begin =
std::next(getBody().args_begin(),
getType().getNumInputs() + getNumWorkgroupAttributions());
getFunctionType().getNumInputs() + getNumWorkgroupAttributions());
return {begin, getBody().args_end()};
}

Expand All @@ -287,16 +288,14 @@ def GPU_GPUFuncOp : GPU_Op<"func", [
}

/// Returns the type of this function.
/// FIXME: We should drive this via the ODS `type` param.
FunctionType getType() {
return getTypeAttr().getValue().cast<FunctionType>();
}
/// FIXME: Remove when GPU uses prefixed accessors.
FunctionType getFunctionType() { return function_type(); }

/// Returns the argument types of this function.
ArrayRef<Type> getArgumentTypes() { return getType().getInputs(); }
ArrayRef<Type> getArgumentTypes() { return getFunctionType().getInputs(); }

/// Returns the result types of this function.
ArrayRef<Type> getResultTypes() { return getType().getResults(); }
ArrayRef<Type> getResultTypes() { return getFunctionType().getResults(); }

/// Returns the keywords used in the custom syntax for this Op.
static StringRef getWorkgroupKeyword() { return "workgroup"; }
Expand Down
6 changes: 5 additions & 1 deletion mlir/include/mlir/Dialect/GPU/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class Module;
} // namespace llvm

namespace mlir {
namespace func {
class FuncOp;
} // namespace func

/// Pass that moves ops which are likely an index computation into gpu.launch
/// body.
std::unique_ptr<Pass> createGpuLauchSinkIndexComputationsPass();
Expand All @@ -33,7 +37,7 @@ std::unique_ptr<OperationPass<ModuleOp>>
createGpuKernelOutliningPass(StringRef dataLayoutStr = StringRef());

/// Rewrites a function region so that GPU ops execute asynchronously.
std::unique_ptr<OperationPass<FuncOp>> createGpuAsyncRegionPass();
std::unique_ptr<OperationPass<func::FuncOp>> createGpuAsyncRegionPass();

/// Collect a set of patterns to rewrite all-reduce ops within the GPU dialect.
void populateGpuAllReducePatterns(RewritePatternSet &patterns);
Expand Down
4 changes: 4 additions & 0 deletions mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ def LLVM_PrimitiveType : Type<
"::mlir::LLVM::LLVMFunctionType>()">]>,
"primitive LLVM type">;

// Type constraint accepting any LLVM function type.
def LLVM_FunctionType : Type<CPred<"$_self.isa<::mlir::LLVM::LLVMFunctionType>()">,
"LLVM function type", "::mlir::LLVM::LLVMFunctionType">;

// Type constraint accepting any LLVM floating point type.
def LLVM_AnyFloat : Type<
CPred<"::mlir::LLVM::isCompatibleFloatingPointType($_self)">,
Expand Down
31 changes: 13 additions & 18 deletions mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ def LLVM_CallOp : LLVM_Op<"call",
let builders = [
OpBuilder<(ins "LLVMFuncOp":$func, "ValueRange":$operands,
CArg<"ArrayRef<NamedAttribute>", "{}">:$attributes), [{
Type resultType = func.getType().getReturnType();
Type resultType = func.getFunctionType().getReturnType();
if (!resultType.isa<LLVM::LLVMVoidType>())
$_state.addTypes(resultType);
$_state.addAttribute("callee", SymbolRefAttr::get(func));
Expand Down Expand Up @@ -874,7 +874,7 @@ def LLVM_AddressOfOp : LLVM_Op<"mlir.addressof", [NoSideEffect]> {
CArg<"ArrayRef<NamedAttribute>", "{}">:$attrs),
[{
build($_builder, $_state,
LLVM::LLVMPointerType::get(func.getType()), func.getName());
LLVM::LLVMPointerType::get(func.getFunctionType()), func.getName());
$_state.addAttributes(attrs);
}]>
];
Expand Down Expand Up @@ -1236,11 +1236,14 @@ def LLVM_LLVMFuncOp : LLVM_Op<"func", [
```
}];

let arguments = (ins DefaultValuedAttr<Linkage, "Linkage::External">:$linkage,
UnitAttr:$dso_local,
OptionalAttr<FlatSymbolRefAttr>:$personality,
OptionalAttr<StrAttr>:$garbageCollector,
OptionalAttr<ArrayAttr>:$passthrough);
let arguments = (ins
TypeAttrOf<LLVM_FunctionType>:$function_type,
DefaultValuedAttr<Linkage, "Linkage::External">:$linkage,
UnitAttr:$dso_local,
OptionalAttr<FlatSymbolRefAttr>:$personality,
OptionalAttr<StrAttr>:$garbageCollector,
OptionalAttr<ArrayAttr>:$passthrough
);

let regions = (region AnyRegion:$body);

Expand All @@ -1259,21 +1262,13 @@ def LLVM_LLVMFuncOp : LLVM_Op<"func", [
// to match the signature of the function.
Block *addEntryBlock();

LLVMFunctionType getType() {
return getTypeAttr().getValue().cast<LLVMFunctionType>();
}
bool isVarArg() { return getType().isVarArg(); }
bool isVarArg() { return getFunctionType().isVarArg(); }

/// Returns the argument types of this function.
ArrayRef<Type> getArgumentTypes() { return getType().getParams(); }
ArrayRef<Type> getArgumentTypes() { return getFunctionType().getParams(); }

/// Returns the result types of this function.
ArrayRef<Type> 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<Type> getResultTypes() { return getFunctionType().getReturnTypes(); }
}];

let hasCustomAssemblyFormat = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
#include "mlir/IR/OpDefinition.h"

namespace mlir {
namespace func {
class FuncOp;
} // namespace func

namespace linalg {

Expand Down Expand Up @@ -155,7 +157,8 @@ class LinalgDependenceGraph {
static StringRef getDependenceTypeStr(DependenceType depType);

// Builds a linalg dependence graph for the ops of type LinalgOp under `f`.
static LinalgDependenceGraph buildDependenceGraph(Aliases &aliases, FuncOp f);
static LinalgDependenceGraph buildDependenceGraph(Aliases &aliases,
func::FuncOp f);
LinalgDependenceGraph(Aliases &aliases, ArrayRef<LinalgOp> ops);

/// Returns the X such that op -> X is a dependence of type dt.
Expand Down
54 changes: 34 additions & 20 deletions mlir/include/mlir/Dialect/Linalg/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
#include "mlir/Pass/Pass.h"

namespace mlir {
namespace func {
class FuncOp;
} // namespace func

// TODO: Remove when all references have been updated.
using FuncOp = func::FuncOp;

namespace bufferization {
struct OneShotBufferizationOptions;
} // namespace bufferization
Expand All @@ -31,29 +38,32 @@ std::unique_ptr<Pass> createFoldReshapeOpsByLinearizationPass();

std::unique_ptr<Pass> createLinalgNamedOpConversionPass();

std::unique_ptr<OperationPass<FuncOp>>
std::unique_ptr<OperationPass<func::FuncOp>>
createLinalgTilingPass(ArrayRef<int64_t> tileSizes = {},
linalg::LinalgTilingLoopType loopType =
linalg::LinalgTilingLoopType::Loops);

std::unique_ptr<OperationPass<FuncOp>>
std::unique_ptr<OperationPass<func::FuncOp>>
createLinalgPromotionPass(bool dynamicBuffers, bool useAlloca);
std::unique_ptr<OperationPass<FuncOp>> createLinalgPromotionPass();
std::unique_ptr<OperationPass<func::FuncOp>> createLinalgPromotionPass();

std::unique_ptr<OperationPass<FuncOp>> createLinalgInlineScalarOperandsPass();
std::unique_ptr<OperationPass<func::FuncOp>>
createLinalgInlineScalarOperandsPass();

/// Create a pass to convert Linalg operations to scf.for loops and
/// memref.load/memref.store accesses.
std::unique_ptr<OperationPass<FuncOp>> createConvertLinalgToLoopsPass();
std::unique_ptr<OperationPass<func::FuncOp>> createConvertLinalgToLoopsPass();

/// Create a pass to convert Linalg operations to scf.parallel loops and
/// memref.load/memref.store accesses.
std::unique_ptr<OperationPass<FuncOp>> createConvertLinalgToParallelLoopsPass();
std::unique_ptr<OperationPass<func::FuncOp>>
createConvertLinalgToParallelLoopsPass();

/// Create a pass to convert Linalg operations to affine.for loops and
/// affine_load/affine_store accesses.
/// Placeholder for now, this is NYI.
std::unique_ptr<OperationPass<FuncOp>> createConvertLinalgToAffineLoopsPass();
std::unique_ptr<OperationPass<func::FuncOp>>
createConvertLinalgToAffineLoopsPass();

/// This pass implements a cross-dialect bufferization approach and performs an
/// analysis to determine which op operands and results may be bufferized in the
Expand All @@ -68,11 +78,11 @@ std::unique_ptr<Pass> createLinalgComprehensiveModuleBufferizePass(

/// Create a pass to convert Linalg operations which work on tensors to use
/// buffers instead.
std::unique_ptr<OperationPass<FuncOp>> createLinalgBufferizePass();
std::unique_ptr<OperationPass<func::FuncOp>> createLinalgBufferizePass();

/// Create a pass to convert named Linalg operations to Linalg generic
/// operations.
std::unique_ptr<OperationPass<FuncOp>> createLinalgGeneralizationPass();
std::unique_ptr<OperationPass<func::FuncOp>> createLinalgGeneralizationPass();

/// Create a pass to convert Linalg operations to equivalent operations that
/// work on primitive types, if possible.
Expand All @@ -82,52 +92,54 @@ std::unique_ptr<Pass> createLinalgDetensorizePass();
/// Linalg strategy passes.
//===----------------------------------------------------------------------===//
/// Create a LinalgStrategyTileAndFusePass.
std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyTileAndFusePass(
std::unique_ptr<OperationPass<func::FuncOp>>
createLinalgStrategyTileAndFusePass(
StringRef opName = "", const linalg::LinalgTilingAndFusionOptions &opt = {},
const linalg::LinalgTransformationFilter &filter =
linalg::LinalgTransformationFilter());

/// Create a LinalgStrategyTilePass.
std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyTilePass(
std::unique_ptr<OperationPass<func::FuncOp>> createLinalgStrategyTilePass(
StringRef opName = "",
const linalg::LinalgTilingOptions &opt = linalg::LinalgTilingOptions(),
const linalg::LinalgTransformationFilter &filter =
linalg::LinalgTransformationFilter());

/// Create a LinalgStrategyPadPass.
std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyPadPass(
std::unique_ptr<OperationPass<func::FuncOp>> createLinalgStrategyPadPass(
StringRef opName = "",
const linalg::LinalgPaddingOptions &opt = linalg::LinalgPaddingOptions(),
const linalg::LinalgTransformationFilter &filter =
linalg::LinalgTransformationFilter());

/// Create a LinalgStrategyPromotePass.
std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyPromotePass(
std::unique_ptr<OperationPass<func::FuncOp>> createLinalgStrategyPromotePass(
StringRef opName = "",
const linalg::LinalgPromotionOptions &opt =
linalg::LinalgPromotionOptions(),
const linalg::LinalgTransformationFilter &filter =
linalg::LinalgTransformationFilter());

/// Create a LinalgStrategyGeneralizePass.
std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyGeneralizePass(
std::unique_ptr<OperationPass<func::FuncOp>> createLinalgStrategyGeneralizePass(
StringRef opName = "", const linalg::LinalgTransformationFilter &filter =
linalg::LinalgTransformationFilter());

/// Create a LinalgStrategyDecomposePass.
// TODO: if/when we need finer control add an `opName` parameter.
std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyDecomposePass(
std::unique_ptr<OperationPass<func::FuncOp>> createLinalgStrategyDecomposePass(
const linalg::LinalgTransformationFilter &filter =
linalg::LinalgTransformationFilter());

/// Create a LinalgStrategyInterchangePass.
std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyInterchangePass(
std::unique_ptr<OperationPass<func::FuncOp>>
createLinalgStrategyInterchangePass(
ArrayRef<int64_t> iteratorInterchange = {},
const linalg::LinalgTransformationFilter &filter =
linalg::LinalgTransformationFilter());

/// Create a LinalgStrategyVectorizePass.
std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyVectorizePass(
std::unique_ptr<OperationPass<func::FuncOp>> createLinalgStrategyVectorizePass(
StringRef opName = "",
linalg::LinalgVectorizationOptions opt =
linalg::LinalgVectorizationOptions(),
Expand All @@ -136,20 +148,22 @@ std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyVectorizePass(
bool padVectorize = false);

/// Create a LinalgStrategyEnablePass.
std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyEnablePass(
std::unique_ptr<OperationPass<func::FuncOp>> createLinalgStrategyEnablePass(
linalg::LinalgEnablingOptions opt = linalg::LinalgEnablingOptions(),
const linalg::LinalgTransformationFilter &filter =
linalg::LinalgTransformationFilter());

/// Create a LinalgStrategyLowerVectorsPass.
std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyLowerVectorsPass(
std::unique_ptr<OperationPass<func::FuncOp>>
createLinalgStrategyLowerVectorsPass(
linalg::LinalgVectorLoweringOptions opt =
linalg::LinalgVectorLoweringOptions(),
const linalg::LinalgTransformationFilter &filter =
linalg::LinalgTransformationFilter());

/// Create a LinalgStrategyRemoveMarkersPass.
std::unique_ptr<OperationPass<FuncOp>> createLinalgStrategyRemoveMarkersPass();
std::unique_ptr<OperationPass<func::FuncOp>>
createLinalgStrategyRemoveMarkersPass();

//===----------------------------------------------------------------------===//
// Registration
Expand Down
6 changes: 4 additions & 2 deletions mlir/include/mlir/Dialect/Linalg/Transforms/Hoisting.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
#define MLIR_DIALECT_LINALG_TRANSFORMS_HOISTING_H_

namespace mlir {
namespace func {
class FuncOp;
} // namespace func

namespace linalg {

Expand All @@ -27,11 +29,11 @@ namespace linalg {
/// results in scf::ForOp yielding the value that originally transited through
/// memory.
// TODO: generalize on a per-need basis.
void hoistRedundantVectorTransfers(FuncOp func);
void hoistRedundantVectorTransfers(func::FuncOp func);

/// Same behavior as `hoistRedundantVectorTransfers` but works on tensors
/// instead of buffers.
void hoistRedundantVectorTransfersOnTensor(FuncOp func);
void hoistRedundantVectorTransfersOnTensor(func::FuncOp func);

} // namespace linalg
} // namespace mlir
Expand Down
6 changes: 3 additions & 3 deletions mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ def PDLInterp_FuncOp : PDLInterp_Op<"func", [

let arguments = (ins
SymbolNameAttr:$sym_name,
TypeAttrOf<FunctionType>:$type
TypeAttrOf<FunctionType>:$function_type
);
let regions = (region MinSizedRegion<1>:$body);

Expand All @@ -673,10 +673,10 @@ def PDLInterp_FuncOp : PDLInterp_Op<"func", [
//===------------------------------------------------------------------===//

/// Returns the argument types of this function.
ArrayRef<Type> getArgumentTypes() { return getType().getInputs(); }
ArrayRef<Type> getArgumentTypes() { return getFunctionType().getInputs(); }

/// Returns the result types of this function.
ArrayRef<Type> getResultTypes() { return getType().getResults(); }
ArrayRef<Type> getResultTypes() { return getFunctionType().getResults(); }
}];
let hasCustomAssemblyFormat = 1;
let skipDefaultBuilders = 1;
Expand Down
8 changes: 6 additions & 2 deletions mlir/include/mlir/Dialect/Quant/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,22 @@
#include "mlir/Pass/Pass.h"

namespace mlir {
namespace func {
class FuncOp;
} // namespace func

namespace quant {

/// Creates a pass that converts quantization simulation operations (i.e.
/// FakeQuant and those like it) to casts into/out of supported QuantizedTypes.
std::unique_ptr<OperationPass<FuncOp>> createConvertSimulatedQuantPass();
std::unique_ptr<OperationPass<func::FuncOp>> createConvertSimulatedQuantPass();

/// Creates a pass that converts constants followed by a qbarrier to a
/// constant whose value is quantized. This is typically one of the last
/// passes done when lowering to express actual quantized arithmetic in a
/// low level representation. Because it modifies the constant, it is
/// destructive and cannot be undone.
std::unique_ptr<OperationPass<FuncOp>> createConvertConstPass();
std::unique_ptr<OperationPass<func::FuncOp>> createConvertConstPass();

//===----------------------------------------------------------------------===//
// Registration
Expand Down
Loading