forked from OSchip/llvm-project
[mlir:FunctionOpInterface] Rename the "type" attribute to "function_type"
This removes any potential confusion with the `getType` accessors which correspond to SSA results of an operation, and makes it clear what the intent is (i.e. to represent the type of the function). Differential Revision: https://reviews.llvm.org/D121762
This commit is contained in:
parent
3655069234
commit
4a3460a791
|
@ -127,7 +127,7 @@ static void genRuntimeSetBounds(fir::FirOpBuilder &builder, mlir::Location loc,
|
|||
llvm::SmallVector<mlir::Value> args{box.getAddr(), dimIndex, lowerBound,
|
||||
upperBound};
|
||||
llvm::SmallVector<mlir::Value> operands;
|
||||
for (auto [fst, snd] : llvm::zip(args, callee.getType().getInputs()))
|
||||
for (auto [fst, snd] : llvm::zip(args, callee.getFunctionType().getInputs()))
|
||||
operands.emplace_back(builder.createConvert(loc, snd, fst));
|
||||
builder.create<fir::CallOp>(loc, callee, operands);
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ static void genRuntimeInitCharacter(fir::FirOpBuilder &builder,
|
|||
loc, builder)
|
||||
: fir::runtime::getRuntimeFunc<mkRTKey(AllocatableInitCharacter)>(
|
||||
loc, builder);
|
||||
llvm::ArrayRef<mlir::Type> inputTypes = callee.getType().getInputs();
|
||||
llvm::ArrayRef<mlir::Type> inputTypes = callee.getFunctionType().getInputs();
|
||||
if (inputTypes.size() != 5)
|
||||
fir::emitFatalError(
|
||||
loc, "AllocatableInitCharacter runtime interface not as expected");
|
||||
|
@ -175,7 +175,7 @@ static mlir::Value genRuntimeAllocate(fir::FirOpBuilder &builder,
|
|||
box.getAddr(), errorManager.hasStat, errorManager.errMsgAddr,
|
||||
errorManager.sourceFile, errorManager.sourceLine};
|
||||
llvm::SmallVector<mlir::Value> operands;
|
||||
for (auto [fst, snd] : llvm::zip(args, callee.getType().getInputs()))
|
||||
for (auto [fst, snd] : llvm::zip(args, callee.getFunctionType().getInputs()))
|
||||
operands.emplace_back(builder.createConvert(loc, snd, fst));
|
||||
return builder.create<fir::CallOp>(loc, callee, operands).getResult(0);
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ static mlir::Value genRuntimeDeallocate(fir::FirOpBuilder &builder,
|
|||
boxAddress, errorManager.hasStat, errorManager.errMsgAddr,
|
||||
errorManager.sourceFile, errorManager.sourceLine};
|
||||
llvm::SmallVector<mlir::Value> operands;
|
||||
for (auto [fst, snd] : llvm::zip(args, callee.getType().getInputs()))
|
||||
for (auto [fst, snd] : llvm::zip(args, callee.getFunctionType().getInputs()))
|
||||
operands.emplace_back(builder.createConvert(loc, snd, fst));
|
||||
return builder.create<fir::CallOp>(loc, callee, operands).getResult(0);
|
||||
}
|
||||
|
|
|
@ -2050,15 +2050,17 @@ public:
|
|||
auto stackSaveFn = fir::factory::getLlvmStackSave(builder);
|
||||
auto stackSaveSymbol = bldr->getSymbolRefAttr(stackSaveFn.getName());
|
||||
mlir::Value sp =
|
||||
bldr->create<fir::CallOp>(loc, stackSaveFn.getType().getResults(),
|
||||
stackSaveSymbol, mlir::ValueRange{})
|
||||
bldr->create<fir::CallOp>(
|
||||
loc, stackSaveFn.getFunctionType().getResults(),
|
||||
stackSaveSymbol, mlir::ValueRange{})
|
||||
.getResult(0);
|
||||
stmtCtx.attachCleanup([bldr, loc, sp]() {
|
||||
auto stackRestoreFn = fir::factory::getLlvmStackRestore(*bldr);
|
||||
auto stackRestoreSymbol =
|
||||
bldr->getSymbolRefAttr(stackRestoreFn.getName());
|
||||
bldr->create<fir::CallOp>(loc, stackRestoreFn.getType().getResults(),
|
||||
stackRestoreSymbol, mlir::ValueRange{sp});
|
||||
bldr->create<fir::CallOp>(
|
||||
loc, stackRestoreFn.getFunctionType().getResults(),
|
||||
stackRestoreSymbol, mlir::ValueRange{sp});
|
||||
});
|
||||
}
|
||||
mlir::Value temp =
|
||||
|
@ -2107,7 +2109,7 @@ public:
|
|||
mlir::SymbolRefAttr funcSymbolAttr;
|
||||
bool addHostAssociations = false;
|
||||
if (!funcPointer) {
|
||||
mlir::FunctionType funcOpType = caller.getFuncOp().getType();
|
||||
mlir::FunctionType funcOpType = caller.getFuncOp().getFunctionType();
|
||||
mlir::SymbolRefAttr symbolAttr =
|
||||
builder.getSymbolRefAttr(caller.getMangledName());
|
||||
if (callSiteType.getNumResults() == funcOpType.getNumResults() &&
|
||||
|
@ -2149,7 +2151,7 @@ public:
|
|||
}
|
||||
|
||||
mlir::FunctionType funcType =
|
||||
funcPointer ? callSiteType : caller.getFuncOp().getType();
|
||||
funcPointer ? callSiteType : caller.getFuncOp().getFunctionType();
|
||||
llvm::SmallVector<mlir::Value> operands;
|
||||
// First operand of indirect call is the function pointer. Cast it to
|
||||
// required function type for the call to handle procedures that have a
|
||||
|
@ -2970,8 +2972,8 @@ static void genScalarUserDefinedAssignmentCall(fir::FirOpBuilder &builder,
|
|||
return builder.createConvert(loc, argType, from);
|
||||
};
|
||||
assert(func.getNumArguments() == 2);
|
||||
mlir::Type lhsType = func.getType().getInput(0);
|
||||
mlir::Type rhsType = func.getType().getInput(1);
|
||||
mlir::Type lhsType = func.getFunctionType().getInput(0);
|
||||
mlir::Type rhsType = func.getFunctionType().getInput(1);
|
||||
mlir::Value lhsArg = prepareUserDefinedArg(builder, loc, lhs, lhsType);
|
||||
mlir::Value rhsArg = prepareUserDefinedArg(builder, loc, rhs, rhsType);
|
||||
builder.create<fir::CallOp>(loc, func, mlir::ValueRange{lhsArg, rhsArg});
|
||||
|
@ -4901,7 +4903,7 @@ public:
|
|||
|
||||
/// Get the function signature of the LLVM memcpy intrinsic.
|
||||
mlir::FunctionType memcpyType() {
|
||||
return fir::factory::getLlvmMemcpy(builder).getType();
|
||||
return fir::factory::getLlvmMemcpy(builder).getFunctionType();
|
||||
}
|
||||
|
||||
/// Create a call to the LLVM memcpy intrinsic.
|
||||
|
@ -4910,7 +4912,7 @@ public:
|
|||
mlir::FuncOp memcpyFunc = fir::factory::getLlvmMemcpy(builder);
|
||||
mlir::SymbolRefAttr funcSymAttr =
|
||||
builder.getSymbolRefAttr(memcpyFunc.getName());
|
||||
mlir::FunctionType funcTy = memcpyFunc.getType();
|
||||
mlir::FunctionType funcTy = memcpyFunc.getFunctionType();
|
||||
builder.create<fir::CallOp>(loc, funcTy.getResults(), funcSymAttr, args);
|
||||
}
|
||||
|
||||
|
@ -4935,7 +4937,7 @@ public:
|
|||
mlir::Value byteSz = builder.create<mlir::arith::MulIOp>(loc, newSz, eleSz);
|
||||
mlir::SymbolRefAttr funcSymAttr =
|
||||
builder.getSymbolRefAttr(reallocFunc.getName());
|
||||
mlir::FunctionType funcTy = reallocFunc.getType();
|
||||
mlir::FunctionType funcTy = reallocFunc.getFunctionType();
|
||||
auto newMem = builder.create<fir::CallOp>(
|
||||
loc, funcTy.getResults(), funcSymAttr,
|
||||
llvm::ArrayRef<mlir::Value>{
|
||||
|
|
|
@ -515,8 +515,8 @@ void Fortran::lower::HostAssociations::internalProcedureBindings(
|
|||
mlir::Location loc = converter.getCurrentLocation();
|
||||
mlir::FuncOp func = builder.getFunction();
|
||||
mlir::Value tupleArg;
|
||||
for (auto [ty, arg] : llvm::reverse(
|
||||
llvm::zip(func.getType().getInputs(), func.front().getArguments())))
|
||||
for (auto [ty, arg] : llvm::reverse(llvm::zip(
|
||||
func.getFunctionType().getInputs(), func.front().getArguments())))
|
||||
if (ty == argTy) {
|
||||
tupleArg = arg;
|
||||
break;
|
||||
|
|
|
@ -91,15 +91,14 @@ static constexpr std::tuple<
|
|||
#ifdef __SIZEOF_INT128__
|
||||
mkIOKey(OutputInteger128),
|
||||
#endif
|
||||
mkIOKey(InputInteger),
|
||||
mkIOKey(OutputReal32), mkIOKey(InputReal32), mkIOKey(OutputReal64),
|
||||
mkIOKey(InputReal64), mkIOKey(OutputComplex32), mkIOKey(InputComplex32),
|
||||
mkIOKey(OutputComplex64), mkIOKey(InputComplex64), mkIOKey(OutputAscii),
|
||||
mkIOKey(InputAscii), mkIOKey(OutputLogical), mkIOKey(InputLogical),
|
||||
mkIOKey(SetAccess), mkIOKey(SetAction), mkIOKey(SetAsynchronous),
|
||||
mkIOKey(SetCarriagecontrol), mkIOKey(SetEncoding), mkIOKey(SetForm),
|
||||
mkIOKey(SetPosition), mkIOKey(SetRecl), mkIOKey(SetStatus),
|
||||
mkIOKey(SetFile), mkIOKey(GetNewUnit), mkIOKey(GetSize),
|
||||
mkIOKey(InputInteger), mkIOKey(OutputReal32), mkIOKey(InputReal32),
|
||||
mkIOKey(OutputReal64), mkIOKey(InputReal64), mkIOKey(OutputComplex32),
|
||||
mkIOKey(InputComplex32), mkIOKey(OutputComplex64), mkIOKey(InputComplex64),
|
||||
mkIOKey(OutputAscii), mkIOKey(InputAscii), mkIOKey(OutputLogical),
|
||||
mkIOKey(InputLogical), mkIOKey(SetAccess), mkIOKey(SetAction),
|
||||
mkIOKey(SetAsynchronous), mkIOKey(SetCarriagecontrol), mkIOKey(SetEncoding),
|
||||
mkIOKey(SetForm), mkIOKey(SetPosition), mkIOKey(SetRecl),
|
||||
mkIOKey(SetStatus), mkIOKey(SetFile), mkIOKey(GetNewUnit), mkIOKey(GetSize),
|
||||
mkIOKey(GetIoLength), mkIOKey(GetIoMsg), mkIOKey(InquireCharacter),
|
||||
mkIOKey(InquireLogical), mkIOKey(InquirePendingId),
|
||||
mkIOKey(InquireInteger64), mkIOKey(EndIoStatement)>
|
||||
|
@ -188,9 +187,9 @@ static mlir::Value genEndIO(Fortran::lower::AbstractConverter &converter,
|
|||
loc, getIoMsg,
|
||||
mlir::ValueRange{
|
||||
cookie,
|
||||
builder.createConvert(loc, getIoMsg.getType().getInput(1),
|
||||
builder.createConvert(loc, getIoMsg.getFunctionType().getInput(1),
|
||||
fir::getBase(ioMsgVar)),
|
||||
builder.createConvert(loc, getIoMsg.getType().getInput(2),
|
||||
builder.createConvert(loc, getIoMsg.getFunctionType().getInput(2),
|
||||
fir::getLen(ioMsgVar))});
|
||||
}
|
||||
mlir::FuncOp endIoStatement =
|
||||
|
@ -395,7 +394,7 @@ static void genNamelistIO(Fortran::lower::AbstractConverter &converter,
|
|||
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
||||
mlir::Location loc = converter.getCurrentLocation();
|
||||
makeNextConditionalOn(builder, loc, checkResult, ok);
|
||||
mlir::Type argType = funcOp.getType().getInput(1);
|
||||
mlir::Type argType = funcOp.getFunctionType().getInput(1);
|
||||
mlir::Value groupAddr = getNamelistGroup(converter, symbol, stmtCtx);
|
||||
groupAddr = builder.createConvert(loc, argType, groupAddr);
|
||||
llvm::SmallVector<mlir::Value> args = {cookie, groupAddr};
|
||||
|
@ -480,7 +479,7 @@ genOutputItemList(Fortran::lower::AbstractConverter &converter,
|
|||
fir::emitFatalError(loc, "internal error: could not get evaluate::Expr");
|
||||
mlir::Type itemTy = converter.genType(*expr);
|
||||
mlir::FuncOp outputFunc = getOutputFunc(loc, builder, itemTy, isFormatted);
|
||||
mlir::Type argType = outputFunc.getType().getInput(1);
|
||||
mlir::Type argType = outputFunc.getFunctionType().getInput(1);
|
||||
assert((isFormatted || argType.isa<fir::BoxType>()) &&
|
||||
"expect descriptor for unformatted IO runtime");
|
||||
llvm::SmallVector<mlir::Value> outputFuncArgs = {cookie};
|
||||
|
@ -496,9 +495,9 @@ genOutputItemList(Fortran::lower::AbstractConverter &converter,
|
|||
llvm::report_fatal_error(
|
||||
"internal error: scalar character not in CharBox");
|
||||
outputFuncArgs.push_back(builder.createConvert(
|
||||
loc, outputFunc.getType().getInput(1), fir::getBase(exv)));
|
||||
loc, outputFunc.getFunctionType().getInput(1), fir::getBase(exv)));
|
||||
outputFuncArgs.push_back(builder.createConvert(
|
||||
loc, outputFunc.getType().getInput(2), fir::getLen(exv)));
|
||||
loc, outputFunc.getFunctionType().getInput(2), fir::getLen(exv)));
|
||||
} else {
|
||||
fir::ExtendedValue itemBox = converter.genExprValue(expr, stmtCtx, loc);
|
||||
mlir::Value itemValue = fir::getBase(itemBox);
|
||||
|
@ -573,7 +572,7 @@ static mlir::Value createIoRuntimeCallForItem(mlir::Location loc,
|
|||
mlir::FuncOp inputFunc,
|
||||
mlir::Value cookie,
|
||||
const fir::ExtendedValue &item) {
|
||||
mlir::Type argType = inputFunc.getType().getInput(1);
|
||||
mlir::Type argType = inputFunc.getFunctionType().getInput(1);
|
||||
llvm::SmallVector<mlir::Value> inputFuncArgs = {cookie};
|
||||
if (argType.isa<fir::BoxType>()) {
|
||||
mlir::Value box = fir::getBase(item);
|
||||
|
@ -586,8 +585,8 @@ static mlir::Value createIoRuntimeCallForItem(mlir::Location loc,
|
|||
fir::factory::CharacterExprHelper charHelper{builder, loc};
|
||||
if (charHelper.isCharacterScalar(itemTy)) {
|
||||
mlir::Value len = fir::getLen(item);
|
||||
inputFuncArgs.push_back(
|
||||
builder.createConvert(loc, inputFunc.getType().getInput(2), len));
|
||||
inputFuncArgs.push_back(builder.createConvert(
|
||||
loc, inputFunc.getFunctionType().getInput(2), len));
|
||||
} else if (itemTy.isa<mlir::IntegerType>()) {
|
||||
inputFuncArgs.push_back(builder.create<mlir::arith::ConstantOp>(
|
||||
loc, builder.getI32IntegerAttr(
|
||||
|
@ -627,7 +626,8 @@ static void genInputItemList(Fortran::lower::AbstractConverter &converter,
|
|||
Fortran::lower::genVectorSubscriptBox(loc, converter, stmtCtx, *expr);
|
||||
mlir::FuncOp inputFunc = getInputFunc(
|
||||
loc, builder, vectorSubscriptBox.getElementType(), isFormatted);
|
||||
const bool mustBox = inputFunc.getType().getInput(1).isa<fir::BoxType>();
|
||||
const bool mustBox =
|
||||
inputFunc.getFunctionType().getInput(1).isa<fir::BoxType>();
|
||||
if (!checkResult) {
|
||||
auto elementalGenerator = [&](const fir::ExtendedValue &element) {
|
||||
createIoRuntimeCallForItem(loc, builder, inputFunc, cookie,
|
||||
|
@ -651,7 +651,7 @@ static void genInputItemList(Fortran::lower::AbstractConverter &converter,
|
|||
}
|
||||
mlir::Type itemTy = converter.genType(*expr);
|
||||
mlir::FuncOp inputFunc = getInputFunc(loc, builder, itemTy, isFormatted);
|
||||
auto itemExv = inputFunc.getType().getInput(1).isa<fir::BoxType>()
|
||||
auto itemExv = inputFunc.getFunctionType().getInput(1).isa<fir::BoxType>()
|
||||
? converter.genExprBox(*expr, stmtCtx, loc)
|
||||
: converter.genExprAddr(expr, stmtCtx, loc);
|
||||
ok = createIoRuntimeCallForItem(loc, builder, inputFunc, cookie, itemExv);
|
||||
|
@ -871,7 +871,7 @@ mlir::Value genIntIOOption(Fortran::lower::AbstractConverter &converter,
|
|||
Fortran::lower::StatementContext localStatementCtx;
|
||||
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
||||
mlir::FuncOp ioFunc = getIORuntimeFunc<A>(loc, builder);
|
||||
mlir::FunctionType ioFuncTy = ioFunc.getType();
|
||||
mlir::FunctionType ioFuncTy = ioFunc.getFunctionType();
|
||||
mlir::Value expr = fir::getBase(converter.genExprValue(
|
||||
Fortran::semantics::GetExpr(spec.v), localStatementCtx, loc));
|
||||
mlir::Value val = builder.createConvert(loc, ioFuncTy.getInput(1), expr);
|
||||
|
@ -888,7 +888,7 @@ mlir::Value genCharIOOption(Fortran::lower::AbstractConverter &converter,
|
|||
Fortran::lower::StatementContext localStatementCtx;
|
||||
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
||||
mlir::FuncOp ioFunc = getIORuntimeFunc<A>(loc, builder);
|
||||
mlir::FunctionType ioFuncTy = ioFunc.getType();
|
||||
mlir::FunctionType ioFuncTy = ioFunc.getFunctionType();
|
||||
std::tuple<mlir::Value, mlir::Value, mlir::Value> tup =
|
||||
lowerStringLit(converter, loc, localStatementCtx, spec,
|
||||
ioFuncTy.getInput(1), ioFuncTy.getInput(2));
|
||||
|
@ -920,7 +920,7 @@ mlir::Value genIOOption<Fortran::parser::FileNameExpr>(
|
|||
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
||||
// has an extra KIND argument
|
||||
mlir::FuncOp ioFunc = getIORuntimeFunc<mkIOKey(SetFile)>(loc, builder);
|
||||
mlir::FunctionType ioFuncTy = ioFunc.getType();
|
||||
mlir::FunctionType ioFuncTy = ioFunc.getFunctionType();
|
||||
std::tuple<mlir::Value, mlir::Value, mlir::Value> tup =
|
||||
lowerStringLit(converter, loc, localStatementCtx, spec,
|
||||
ioFuncTy.getInput(1), ioFuncTy.getInput(2));
|
||||
|
@ -981,7 +981,7 @@ mlir::Value genIOOption<Fortran::parser::ConnectSpec::CharExpr>(
|
|||
TODO(loc, "DISPOSE not part of the runtime::io interface");
|
||||
}
|
||||
Fortran::lower::StatementContext localStatementCtx;
|
||||
mlir::FunctionType ioFuncTy = ioFunc.getType();
|
||||
mlir::FunctionType ioFuncTy = ioFunc.getFunctionType();
|
||||
std::tuple<mlir::Value, mlir::Value, mlir::Value> tup =
|
||||
lowerStringLit(converter, loc, localStatementCtx,
|
||||
std::get<Fortran::parser::ScalarDefaultCharExpr>(spec.t),
|
||||
|
@ -1035,7 +1035,7 @@ mlir::Value genIOOption<Fortran::parser::IoControlSpec::CharExpr>(
|
|||
break;
|
||||
}
|
||||
Fortran::lower::StatementContext localStatementCtx;
|
||||
mlir::FunctionType ioFuncTy = ioFunc.getType();
|
||||
mlir::FunctionType ioFuncTy = ioFunc.getFunctionType();
|
||||
std::tuple<mlir::Value, mlir::Value, mlir::Value> tup =
|
||||
lowerStringLit(converter, loc, localStatementCtx,
|
||||
std::get<Fortran::parser::ScalarDefaultCharExpr>(spec.t),
|
||||
|
@ -1203,7 +1203,7 @@ genConditionHandlerCall(Fortran::lower::AbstractConverter &converter,
|
|||
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
||||
mlir::FuncOp enableHandlers =
|
||||
getIORuntimeFunc<mkIOKey(EnableHandlers)>(loc, builder);
|
||||
mlir::Type boolType = enableHandlers.getType().getInput(1);
|
||||
mlir::Type boolType = enableHandlers.getFunctionType().getInput(1);
|
||||
auto boolValue = [&](bool specifierIsPresent) {
|
||||
return builder.create<mlir::arith::ConstantOp>(
|
||||
loc, builder.getIntegerAttr(boolType, specifierIsPresent));
|
||||
|
@ -1558,7 +1558,7 @@ static mlir::Value genBasicIOStmt(Fortran::lower::AbstractConverter &converter,
|
|||
Fortran::lower::StatementContext stmtCtx;
|
||||
mlir::Location loc = converter.getCurrentLocation();
|
||||
mlir::FuncOp beginFunc = getIORuntimeFunc<K>(loc, builder);
|
||||
mlir::FunctionType beginFuncTy = beginFunc.getType();
|
||||
mlir::FunctionType beginFuncTy = beginFunc.getFunctionType();
|
||||
mlir::Value unit = fir::getBase(converter.genExprValue(
|
||||
getExpr<Fortran::parser::FileUnitNumber>(stmt), stmtCtx, loc));
|
||||
mlir::Value un = builder.createConvert(loc, beginFuncTy.getInput(0), unit);
|
||||
|
@ -1611,7 +1611,7 @@ genNewunitSpec(Fortran::lower::AbstractConverter &converter, mlir::Location loc,
|
|||
Fortran::lower::StatementContext stmtCtx;
|
||||
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
||||
mlir::FuncOp ioFunc = getIORuntimeFunc<mkIOKey(GetNewUnit)>(loc, builder);
|
||||
mlir::FunctionType ioFuncTy = ioFunc.getType();
|
||||
mlir::FunctionType ioFuncTy = ioFunc.getFunctionType();
|
||||
const auto *var = Fortran::semantics::GetExpr(newunit->v);
|
||||
mlir::Value addr = builder.createConvert(
|
||||
loc, ioFuncTy.getInput(1),
|
||||
|
@ -1635,7 +1635,7 @@ Fortran::lower::genOpenStatement(Fortran::lower::AbstractConverter &converter,
|
|||
bool hasNewunitSpec = false;
|
||||
if (hasSpec<Fortran::parser::FileUnitNumber>(stmt)) {
|
||||
beginFunc = getIORuntimeFunc<mkIOKey(BeginOpenUnit)>(loc, builder);
|
||||
mlir::FunctionType beginFuncTy = beginFunc.getType();
|
||||
mlir::FunctionType beginFuncTy = beginFunc.getFunctionType();
|
||||
mlir::Value unit = fir::getBase(converter.genExprValue(
|
||||
getExpr<Fortran::parser::FileUnitNumber>(stmt), stmtCtx, loc));
|
||||
beginArgs.push_back(
|
||||
|
@ -1646,7 +1646,7 @@ Fortran::lower::genOpenStatement(Fortran::lower::AbstractConverter &converter,
|
|||
hasNewunitSpec = hasSpec<Fortran::parser::ConnectSpec::Newunit>(stmt);
|
||||
assert(hasNewunitSpec && "missing unit specifier");
|
||||
beginFunc = getIORuntimeFunc<mkIOKey(BeginOpenNewUnit)>(loc, builder);
|
||||
mlir::FunctionType beginFuncTy = beginFunc.getType();
|
||||
mlir::FunctionType beginFuncTy = beginFunc.getFunctionType();
|
||||
beginArgs.push_back(locToFilename(converter, loc, beginFuncTy.getInput(0)));
|
||||
beginArgs.push_back(locToLineNo(converter, loc, beginFuncTy.getInput(1)));
|
||||
}
|
||||
|
@ -1679,7 +1679,7 @@ Fortran::lower::genWaitStatement(Fortran::lower::AbstractConverter &converter,
|
|||
mlir::FuncOp beginFunc =
|
||||
hasId ? getIORuntimeFunc<mkIOKey(BeginWait)>(loc, builder)
|
||||
: getIORuntimeFunc<mkIOKey(BeginWaitAll)>(loc, builder);
|
||||
mlir::FunctionType beginFuncTy = beginFunc.getType();
|
||||
mlir::FunctionType beginFuncTy = beginFunc.getFunctionType();
|
||||
mlir::Value unit = fir::getBase(converter.genExprValue(
|
||||
getExpr<Fortran::parser::FileUnitNumber>(stmt), stmtCtx, loc));
|
||||
mlir::Value un = builder.createConvert(loc, beginFuncTy.getInput(0), unit);
|
||||
|
@ -1849,7 +1849,7 @@ genDataTransferStmt(Fortran::lower::AbstractConverter &converter,
|
|||
isInternalWithDesc, isAsync);
|
||||
llvm::SmallVector<mlir::Value> ioArgs;
|
||||
genBeginDataTransferCallArgs<hasIOCtrl>(
|
||||
ioArgs, converter, loc, stmt, ioFunc.getType(), isFormatted,
|
||||
ioArgs, converter, loc, stmt, ioFunc.getFunctionType(), isFormatted,
|
||||
isList || isNml, isInternal, isAsync, descRef, stmtCtx);
|
||||
mlir::Value cookie =
|
||||
builder.create<fir::CallOp>(loc, ioFunc, ioArgs).getResult(0);
|
||||
|
@ -1962,7 +1962,7 @@ mlir::Value genInquireSpec<Fortran::parser::InquireSpec::CharVar>(
|
|||
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
||||
mlir::FuncOp specFunc =
|
||||
getIORuntimeFunc<mkIOKey(InquireCharacter)>(loc, builder);
|
||||
mlir::FunctionType specFuncTy = specFunc.getType();
|
||||
mlir::FunctionType specFuncTy = specFunc.getFunctionType();
|
||||
const auto *varExpr = Fortran::semantics::GetExpr(
|
||||
std::get<Fortran::parser::ScalarDefaultCharVariable>(var.t));
|
||||
fir::ExtendedValue str = converter.genExprAddr(varExpr, stmtCtx, loc);
|
||||
|
@ -1992,7 +1992,7 @@ mlir::Value genInquireSpec<Fortran::parser::InquireSpec::IntVar>(
|
|||
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
||||
mlir::FuncOp specFunc =
|
||||
getIORuntimeFunc<mkIOKey(InquireInteger64)>(loc, builder);
|
||||
mlir::FunctionType specFuncTy = specFunc.getType();
|
||||
mlir::FunctionType specFuncTy = specFunc.getFunctionType();
|
||||
const auto *varExpr = Fortran::semantics::GetExpr(
|
||||
std::get<Fortran::parser::ScalarIntVariable>(var.t));
|
||||
mlir::Value addr = fir::getBase(converter.genExprAddr(varExpr, stmtCtx, loc));
|
||||
|
@ -2030,7 +2030,7 @@ mlir::Value genInquireSpec<Fortran::parser::InquireSpec::LogVar>(
|
|||
mlir::FuncOp specFunc =
|
||||
pendId ? getIORuntimeFunc<mkIOKey(InquirePendingId)>(loc, builder)
|
||||
: getIORuntimeFunc<mkIOKey(InquireLogical)>(loc, builder);
|
||||
mlir::FunctionType specFuncTy = specFunc.getType();
|
||||
mlir::FunctionType specFuncTy = specFunc.getFunctionType();
|
||||
mlir::Value addr = fir::getBase(converter.genExprAddr(
|
||||
Fortran::semantics::GetExpr(
|
||||
std::get<Fortran::parser::Scalar<
|
||||
|
@ -2112,7 +2112,7 @@ mlir::Value Fortran::lower::genInquireStatement(
|
|||
if (inquireFileUnit()) {
|
||||
// Inquire by unit -- [UNIT=]file-unit-number.
|
||||
beginFunc = getIORuntimeFunc<mkIOKey(BeginInquireUnit)>(loc, builder);
|
||||
mlir::FunctionType beginFuncTy = beginFunc.getType();
|
||||
mlir::FunctionType beginFuncTy = beginFunc.getFunctionType();
|
||||
beginArgs = {builder.createConvert(loc, beginFuncTy.getInput(0),
|
||||
fir::getBase(converter.genExprValue(
|
||||
exprPair.first, stmtCtx, loc))),
|
||||
|
@ -2121,7 +2121,7 @@ mlir::Value Fortran::lower::genInquireStatement(
|
|||
} else if (inquireFileName()) {
|
||||
// Inquire by file -- FILE=file-name-expr.
|
||||
beginFunc = getIORuntimeFunc<mkIOKey(BeginInquireFile)>(loc, builder);
|
||||
mlir::FunctionType beginFuncTy = beginFunc.getType();
|
||||
mlir::FunctionType beginFuncTy = beginFunc.getFunctionType();
|
||||
fir::ExtendedValue file =
|
||||
converter.genExprAddr(exprPair.first, stmtCtx, loc);
|
||||
beginArgs = {
|
||||
|
@ -2135,7 +2135,7 @@ mlir::Value Fortran::lower::genInquireStatement(
|
|||
std::get_if<Fortran::parser::InquireStmt::Iolength>(&stmt.u);
|
||||
assert(ioLength && "must have an IOLENGTH specifier");
|
||||
beginFunc = getIORuntimeFunc<mkIOKey(BeginInquireIoLength)>(loc, builder);
|
||||
mlir::FunctionType beginFuncTy = beginFunc.getType();
|
||||
mlir::FunctionType beginFuncTy = beginFunc.getFunctionType();
|
||||
beginArgs = {locToFilename(converter, loc, beginFuncTy.getInput(0)),
|
||||
locToLineNo(converter, loc, beginFuncTy.getInput(1))};
|
||||
auto cookie =
|
||||
|
|
|
@ -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;
|
||||
|
@ -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");
|
||||
|
|
|
@ -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()));
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
@ -185,7 +185,7 @@ 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);
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ 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));
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
|
@ -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>())
|
||||
|
|
|
@ -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>(
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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));
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -89,7 +90,7 @@ 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;
|
||||
|
@ -97,8 +98,8 @@ void fir::runtime::genGetEnvironmentVariable(
|
|||
// "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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
|
|
|
@ -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)};
|
||||
|
||||
|
@ -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)};
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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)};
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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)};
|
||||
|
||||
|
|
|
@ -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)};
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
|
@ -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 =
|
||||
|
@ -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)) {
|
||||
|
@ -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 =
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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 =
|
||||
|
|
|
@ -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));
|
||||
|
@ -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 =
|
||||
|
@ -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));
|
||||
|
@ -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 =
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
|
|
|
@ -454,7 +454,7 @@ public:
|
|||
/// 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;
|
||||
|
@ -543,7 +543,7 @@ public:
|
|||
// 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];
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -222,7 +222,7 @@ public:
|
|||
/*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;
|
||||
|
|
|
@ -661,7 +661,7 @@ with Context():
|
|||
# Operations can be created in a generic way.
|
||||
func = Operation.create(
|
||||
"func.func", results=[], operands=[],
|
||||
attributes={"type":TypeAttr.get(FunctionType.get([], []))},
|
||||
attributes={"function_type":TypeAttr.get(FunctionType.get([], []))},
|
||||
successors=None, regions=1)
|
||||
# The result will be downcasted to the concrete `OpView` subclass if
|
||||
# available.
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
|
|
@ -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 ("
|
||||
|
|
|
@ -161,8 +161,8 @@ private:
|
|||
} 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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
|
|
@ -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 ("
|
||||
|
|
|
@ -161,8 +161,8 @@ private:
|
|||
} 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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -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 ("
|
||||
|
|
|
@ -161,8 +161,8 @@ private:
|
|||
} 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.
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -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 ("
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -161,8 +161,8 @@ private:
|
|||
} 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.
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -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 ("
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -161,8 +161,8 @@ private:
|
|||
} 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.
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -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 ("
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -216,8 +216,9 @@ private:
|
|||
} else if (returnOp.hasOperand()) {
|
||||
// Otherwise, if this return operation has an operand then add a result to
|
||||
// the function.
|
||||
function.setType(builder.getFunctionType(function.getType().getInputs(),
|
||||
*returnOp.operand_type_begin()));
|
||||
function.setType(
|
||||
builder.getFunctionType(function.getFunctionType().getInputs(),
|
||||
*returnOp.operand_type_begin()));
|
||||
}
|
||||
|
||||
// If this function isn't main, then set the visibility to private.
|
||||
|
@ -519,7 +520,7 @@ private:
|
|||
}
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -57,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), [{
|
||||
|
@ -250,7 +250,7 @@ def FuncOp : Func_Op<"func", [
|
|||
}];
|
||||
|
||||
let arguments = (ins SymbolNameAttr:$sym_name,
|
||||
TypeAttrOf<FunctionType>:$type,
|
||||
TypeAttrOf<FunctionType>:$function_type,
|
||||
OptionalAttr<StrAttr>:$sym_visibility);
|
||||
let regions = (region AnyRegion:$body);
|
||||
|
||||
|
@ -295,17 +295,17 @@ def FuncOp : Func_Op<"func", [
|
|||
|
||||
/// Returns the results types that the callable region produces when
|
||||
/// executed.
|
||||
ArrayRef<Type> getCallableResults() { return getType().getResults(); }
|
||||
ArrayRef<Type> getCallableResults() { return getFunctionType().getResults(); }
|
||||
|
||||
//===------------------------------------------------------------------===//
|
||||
// FunctionOpInterface Methods
|
||||
//===------------------------------------------------------------------===//
|
||||
|
||||
/// 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(); }
|
||||
|
||||
//===------------------------------------------------------------------===//
|
||||
// SymbolOpInterface Methods
|
||||
|
|
|
@ -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;
|
||||
|
@ -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};
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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()};
|
||||
}
|
||||
|
||||
|
@ -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"; }
|
||||
|
|
|
@ -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)">,
|
||||
|
|
|
@ -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));
|
||||
|
@ -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);
|
||||
}]>
|
||||
];
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
|
|
@ -287,7 +287,7 @@ def SPV_FuncOp : SPV_Op<"func", [
|
|||
}];
|
||||
|
||||
let arguments = (ins
|
||||
TypeAttr:$type,
|
||||
TypeAttrOf<FunctionType>:$function_type,
|
||||
StrAttr:$sym_name,
|
||||
SPV_FunctionControlAttr:$function_control
|
||||
);
|
||||
|
@ -309,16 +309,14 @@ def SPV_FuncOp : SPV_Op<"func", [
|
|||
|
||||
let extraClassDeclaration = [{
|
||||
/// 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 SPIRV 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(); }
|
||||
|
||||
/// Hook for FunctionOpInterface, called after verifying that the 'type'
|
||||
/// attribute is present and checks if it holds a function type. Ensures
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace mlir {
|
|||
namespace function_interface_impl {
|
||||
|
||||
/// Return the name of the attribute used for function types.
|
||||
inline StringRef getTypeAttrName() { return "type"; }
|
||||
inline StringRef getTypeAttrName() { return "function_type"; }
|
||||
|
||||
/// Return the name of the attribute used for function argument attributes.
|
||||
inline StringRef getArgDictAttrName() { return "arg_attrs"; }
|
||||
|
@ -207,7 +207,7 @@ Attribute removeResultAttr(ConcreteType op, unsigned index, StringAttr name) {
|
|||
/// method on FunctionOpInterface::Trait.
|
||||
template <typename ConcreteOp>
|
||||
LogicalResult verifyTrait(ConcreteOp op) {
|
||||
if (!op.getTypeAttr())
|
||||
if (!op.getFunctionTypeAttr())
|
||||
return op.emitOpError("requires a type attribute '")
|
||||
<< function_interface_impl::getTypeAttrName() << '\'';
|
||||
|
||||
|
|
|
@ -37,9 +37,8 @@ def FunctionOpInterface : OpInterface<"FunctionOpInterface"> {
|
|||
The function, aside from implementing the various interface methods,
|
||||
should have the following ODS arguments:
|
||||
|
||||
- `type` (required)
|
||||
- `function_type` (required)
|
||||
* A TypeAttr that holds the signature type of the function.
|
||||
* TODO: this field will soon be renamed to something less generic.
|
||||
|
||||
- `arg_attrs` (optional)
|
||||
* An ArrayAttr of DictionaryAttr that contains attribute dictionaries
|
||||
|
@ -73,7 +72,7 @@ def FunctionOpInterface : OpInterface<"FunctionOpInterface"> {
|
|||
"::mlir::Type", "cloneTypeWith", (ins
|
||||
"::mlir::TypeRange":$inputs, "::mlir::TypeRange":$results
|
||||
), /*methodBody=*/[{}], /*defaultImplementation=*/[{
|
||||
return $_op.getType().clone(inputs, results);
|
||||
return $_op.getFunctionType().clone(inputs, results);
|
||||
}]>,
|
||||
|
||||
InterfaceMethod<[{
|
||||
|
@ -258,13 +257,13 @@ def FunctionOpInterface : OpInterface<"FunctionOpInterface"> {
|
|||
}
|
||||
|
||||
/// Return the attribute containing the type of this function.
|
||||
TypeAttr getTypeAttr() {
|
||||
TypeAttr getFunctionTypeAttr() {
|
||||
return this->getOperation()->template getAttrOfType<TypeAttr>(
|
||||
getTypeAttrName());
|
||||
}
|
||||
|
||||
/// Return the type of this function.
|
||||
Type getType() { return getTypeAttr().getValue(); }
|
||||
Type getFunctionType() { return getFunctionTypeAttr().getValue(); }
|
||||
|
||||
//===------------------------------------------------------------------===//
|
||||
// Argument and Result Handling
|
||||
|
|
|
@ -1269,7 +1269,7 @@ def TypeAttr : TypeAttrBase<"::mlir::Type", "any type attribute"> {
|
|||
}
|
||||
|
||||
class TypeAttrOf<Type ty>
|
||||
: TypeAttrBase<ty.cppClassName, "type attribute of " # ty.description> {
|
||||
: TypeAttrBase<ty.cppClassName, "type attribute of " # ty.summary> {
|
||||
let constBuilderCall = "::mlir::TypeAttr::get($0)";
|
||||
}
|
||||
|
||||
|
|
|
@ -1042,8 +1042,9 @@ void ConvertAsyncToLLVMPass::runOnOperation() {
|
|||
target.addIllegalDialect<AsyncDialect>();
|
||||
|
||||
// Add dynamic legality constraints to apply conversions defined above.
|
||||
target.addDynamicallyLegalOp<FuncOp>(
|
||||
[&](FuncOp op) { return converter.isSignatureLegal(op.getType()); });
|
||||
target.addDynamicallyLegalOp<FuncOp>([&](FuncOp op) {
|
||||
return converter.isSignatureLegal(op.getFunctionType());
|
||||
});
|
||||
target.addDynamicallyLegalOp<func::ReturnOp>([&](func::ReturnOp op) {
|
||||
return converter.isLegal(op.getOperandTypes());
|
||||
});
|
||||
|
|
|
@ -127,7 +127,7 @@ prependResAttrsToArgAttrs(OpBuilder &builder,
|
|||
static void wrapForExternalCallers(OpBuilder &rewriter, Location loc,
|
||||
LLVMTypeConverter &typeConverter,
|
||||
FuncOp funcOp, LLVM::LLVMFuncOp newFuncOp) {
|
||||
auto type = funcOp.getType();
|
||||
auto type = funcOp.getFunctionType();
|
||||
SmallVector<NamedAttribute, 4> attributes;
|
||||
filterFuncAttributes(funcOp->getAttrs(), /*filterArgAndResAttrs=*/false,
|
||||
attributes);
|
||||
|
@ -190,7 +190,7 @@ static void wrapExternalFunction(OpBuilder &builder, Location loc,
|
|||
Type wrapperType;
|
||||
bool resultIsNowArg;
|
||||
std::tie(wrapperType, resultIsNowArg) =
|
||||
typeConverter.convertFunctionTypeCWrapper(funcOp.getType());
|
||||
typeConverter.convertFunctionTypeCWrapper(funcOp.getFunctionType());
|
||||
// This conversion can only fail if it could not convert one of the argument
|
||||
// types. But since it has been applied to a non-wrapper function before, it
|
||||
// should have failed earlier and not reach this point at all.
|
||||
|
@ -210,7 +210,7 @@ static void wrapExternalFunction(OpBuilder &builder, Location loc,
|
|||
builder.setInsertionPointToStart(newFuncOp.addEntryBlock());
|
||||
|
||||
// Get a ValueRange containing arguments.
|
||||
FunctionType type = funcOp.getType();
|
||||
FunctionType type = funcOp.getFunctionType();
|
||||
SmallVector<Value, 8> args;
|
||||
args.reserve(type.getNumInputs());
|
||||
ValueRange wrapperArgsRange(newFuncOp.getArguments());
|
||||
|
@ -288,7 +288,8 @@ protected:
|
|||
auto varargsAttr = funcOp->getAttrOfType<BoolAttr>("func.varargs");
|
||||
TypeConverter::SignatureConversion result(funcOp.getNumArguments());
|
||||
auto llvmType = getTypeConverter()->convertFunctionSignature(
|
||||
funcOp.getType(), varargsAttr && varargsAttr.getValue(), result);
|
||||
funcOp.getFunctionType(), varargsAttr && varargsAttr.getValue(),
|
||||
result);
|
||||
if (!llvmType)
|
||||
return nullptr;
|
||||
|
||||
|
@ -401,7 +402,7 @@ struct BarePtrFuncOpConversion : public FuncOpConversionBase {
|
|||
// Store the type of memref-typed arguments before the conversion so that we
|
||||
// can promote them to MemRef descriptor at the beginning of the function.
|
||||
SmallVector<Type, 8> oldArgTypes =
|
||||
llvm::to_vector<8>(funcOp.getType().getInputs());
|
||||
llvm::to_vector<8>(funcOp.getFunctionType().getInputs());
|
||||
|
||||
auto newFuncOp = convertFuncOpToLLVMFuncOp(funcOp, rewriter);
|
||||
if (!newFuncOp)
|
||||
|
|
|
@ -41,7 +41,7 @@ GPUFuncOpLowering::matchAndRewrite(gpu::GPUFuncOp gpuFuncOp, OpAdaptor adaptor,
|
|||
}
|
||||
|
||||
// Rewrite the original GPU function to an LLVM function.
|
||||
auto funcType = typeConverter->convertType(gpuFuncOp.getType())
|
||||
auto funcType = typeConverter->convertType(gpuFuncOp.getFunctionType())
|
||||
.template cast<LLVM::LLVMPointerType>()
|
||||
.getElementType();
|
||||
|
||||
|
@ -49,7 +49,7 @@ GPUFuncOpLowering::matchAndRewrite(gpu::GPUFuncOp gpuFuncOp, OpAdaptor adaptor,
|
|||
TypeConverter::SignatureConversion signatureConversion(
|
||||
gpuFuncOp.front().getNumArguments());
|
||||
getTypeConverter()->convertFunctionSignature(
|
||||
gpuFuncOp.getType(), /*isVariadic=*/false, signatureConversion);
|
||||
gpuFuncOp.getFunctionType(), /*isVariadic=*/false, signatureConversion);
|
||||
|
||||
// Create the new function operation. Only copy those attributes that are
|
||||
// not specific to function modeling.
|
||||
|
|
|
@ -184,7 +184,7 @@ lowerAsEntryFunction(gpu::GPUFuncOp funcOp, TypeConverter &typeConverter,
|
|||
ConversionPatternRewriter &rewriter,
|
||||
spirv::EntryPointABIAttr entryPointInfo,
|
||||
ArrayRef<spirv::InterfaceVarABIAttr> argABIInfo) {
|
||||
auto fnType = funcOp.getType();
|
||||
auto fnType = funcOp.getFunctionType();
|
||||
if (fnType.getNumResults()) {
|
||||
funcOp.emitError("SPIR-V lowering only supports entry functions"
|
||||
"with no return values right now");
|
||||
|
@ -201,7 +201,8 @@ lowerAsEntryFunction(gpu::GPUFuncOp funcOp, TypeConverter &typeConverter,
|
|||
// LowerABIAttributesPass.
|
||||
TypeConverter::SignatureConversion signatureConverter(fnType.getNumInputs());
|
||||
{
|
||||
for (const auto &argType : enumerate(funcOp.getType().getInputs())) {
|
||||
for (const auto &argType :
|
||||
enumerate(funcOp.getFunctionType().getInputs())) {
|
||||
auto convertedType = typeConverter.convertType(argType.value());
|
||||
signatureConverter.addInputs(argType.index(), convertedType);
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ void LinalgToSPIRVPass::runOnOperation() {
|
|||
// Allow builtin ops.
|
||||
target->addLegalOp<ModuleOp>();
|
||||
target->addDynamicallyLegalOp<FuncOp>([&](FuncOp op) {
|
||||
return typeConverter.isSignatureLegal(op.getType()) &&
|
||||
return typeConverter.isSignatureLegal(op.getFunctionType()) &&
|
||||
typeConverter.isLegal(&op.getBody());
|
||||
});
|
||||
|
||||
|
|
|
@ -1291,11 +1291,11 @@ public:
|
|||
|
||||
// Convert function signature. At the moment LLVMType converter is enough
|
||||
// for currently supported types.
|
||||
auto funcType = funcOp.getType();
|
||||
auto funcType = funcOp.getFunctionType();
|
||||
TypeConverter::SignatureConversion signatureConverter(
|
||||
funcType.getNumInputs());
|
||||
auto llvmType = typeConverter.convertFunctionSignature(
|
||||
funcOp.getType(), /*isVariadic=*/false, signatureConverter);
|
||||
funcType, /*isVariadic=*/false, signatureConverter);
|
||||
if (!llvmType)
|
||||
return failure();
|
||||
|
||||
|
|
|
@ -463,7 +463,8 @@ static FuncOp createAsyncDispatchFunction(ParallelComputeFunction &computeFunc,
|
|||
|
||||
ModuleOp module = computeFunc.func->getParentOfType<ModuleOp>();
|
||||
|
||||
ArrayRef<Type> computeFuncInputTypes = computeFunc.func.getType().getInputs();
|
||||
ArrayRef<Type> computeFuncInputTypes =
|
||||
computeFunc.func.getFunctionType().getInputs();
|
||||
|
||||
// Compared to the parallel compute function async dispatch function takes
|
||||
// additional !async.group argument. Also instead of a single `blockIndex` it
|
||||
|
|
|
@ -614,7 +614,8 @@ static CoroMachinery rewriteFuncAsCoroutine(FuncOp func) {
|
|||
resultTypes.reserve(func.getCallableResults().size());
|
||||
llvm::transform(func.getCallableResults(), std::back_inserter(resultTypes),
|
||||
[](Type type) { return ValueType::get(type); });
|
||||
func.setType(FunctionType::get(ctx, func.getType().getInputs(), resultTypes));
|
||||
func.setType(
|
||||
FunctionType::get(ctx, func.getFunctionType().getInputs(), resultTypes));
|
||||
func.insertResult(0, TokenType::get(ctx), {});
|
||||
for (Block &block : func.getBlocks()) {
|
||||
Operation *terminator = block.getTerminator();
|
||||
|
|
|
@ -20,7 +20,7 @@ using namespace mlir;
|
|||
// Any args appended to the entry block are added to `appendedEntryArgs`.
|
||||
static void updateFuncOp(FuncOp func,
|
||||
SmallVectorImpl<BlockArgument> &appendedEntryArgs) {
|
||||
auto functionType = func.getType();
|
||||
auto functionType = func.getFunctionType();
|
||||
|
||||
// Collect information about the results will become appended arguments.
|
||||
SmallVector<Type, 6> erasedResultTypes;
|
||||
|
|
|
@ -134,7 +134,7 @@ LogicalResult CallOp::verifySymbolUses(SymbolTableCollection &symbolTable) {
|
|||
<< "' does not reference a valid function";
|
||||
|
||||
// Verify that the operand and result types match the callee.
|
||||
auto fnType = fn.getType();
|
||||
auto fnType = fn.getFunctionType();
|
||||
if (fnType.getNumInputs() != getNumOperands())
|
||||
return emitOpError("incorrect number of operands for callee");
|
||||
|
||||
|
@ -196,7 +196,7 @@ LogicalResult ConstantOp::verify() {
|
|||
<< "'";
|
||||
|
||||
// Check that the referenced function has the correct type.
|
||||
if (fn.getType() != type)
|
||||
if (fn.getFunctionType() != type)
|
||||
return emitOpError("reference to function with mismatched type");
|
||||
|
||||
return success();
|
||||
|
@ -304,7 +304,7 @@ FuncOp FuncOp::clone(BlockAndValueMapping &mapper) {
|
|||
// the function by specifying them in the mapper. If so, we don't add the
|
||||
// argument to the input type vector.
|
||||
if (!isExternal()) {
|
||||
FunctionType oldType = getType();
|
||||
FunctionType oldType = getFunctionType();
|
||||
|
||||
unsigned oldNumArgs = oldType.getNumInputs();
|
||||
SmallVector<Type, 4> newInputs;
|
||||
|
@ -347,7 +347,7 @@ LogicalResult ReturnOp::verify() {
|
|||
auto function = cast<FuncOp>((*this)->getParentOp());
|
||||
|
||||
// The operand number and types must match the function signature.
|
||||
const auto &results = function.getType().getResults();
|
||||
const auto &results = function.getFunctionType().getResults();
|
||||
if (getNumOperands() != results.size())
|
||||
return emitOpError("has ")
|
||||
<< getNumOperands() << " operands, but enclosing function (@"
|
||||
|
|
|
@ -64,7 +64,7 @@ struct DecomposeCallGraphTypesForFuncArgs
|
|||
LogicalResult
|
||||
matchAndRewrite(FuncOp op, OpAdaptor adaptor,
|
||||
ConversionPatternRewriter &rewriter) const final {
|
||||
auto functionType = op.getType();
|
||||
auto functionType = op.getFunctionType();
|
||||
|
||||
// Convert function arguments using the provided TypeConverter.
|
||||
TypeConverter::SignatureConversion conversion(functionType.getNumInputs());
|
||||
|
|
|
@ -35,7 +35,7 @@ struct FuncBufferizePass : public FuncBufferizeBase<FuncBufferizePass> {
|
|||
populateFunctionOpInterfaceTypeConversionPattern<FuncOp>(patterns,
|
||||
typeConverter);
|
||||
target.addDynamicallyLegalOp<FuncOp>([&](FuncOp op) {
|
||||
return typeConverter.isSignatureLegal(op.getType()) &&
|
||||
return typeConverter.isSignatureLegal(op.getFunctionType()) &&
|
||||
typeConverter.isLegal(&op.getBody());
|
||||
});
|
||||
populateCallOpTypeConversionPattern(patterns, typeConverter);
|
||||
|
|
|
@ -261,7 +261,7 @@ LogicalResult GPUDialect::verifyOperationAttribute(Operation *op,
|
|||
<< actualNumArguments << " kernel operands but expected "
|
||||
<< expectedNumArguments;
|
||||
|
||||
auto functionType = kernelGPUFunction.getType();
|
||||
auto functionType = kernelGPUFunction.getFunctionType();
|
||||
for (unsigned i = 0; i < expectedNumArguments; ++i) {
|
||||
if (launchOp.getKernelOperand(i).getType() != functionType.getInput(i)) {
|
||||
return launchOp.emitOpError("type of function argument ")
|
||||
|
@ -723,8 +723,8 @@ BlockArgument GPUFuncOp::addWorkgroupAttribution(Type type, Location loc) {
|
|||
auto attr = (*this)->getAttrOfType<IntegerAttr>(attrName);
|
||||
(*this)->setAttr(attrName,
|
||||
IntegerAttr::get(attr.getType(), attr.getValue() + 1));
|
||||
return getBody().insertArgument(getType().getNumInputs() + attr.getInt(),
|
||||
type, loc);
|
||||
return getBody().insertArgument(
|
||||
getFunctionType().getNumInputs() + attr.getInt(), type, loc);
|
||||
}
|
||||
|
||||
/// Adds a new block argument that corresponds to buffers located in
|
||||
|
@ -880,7 +880,7 @@ void GPUFuncOp::print(OpAsmPrinter &p) {
|
|||
p << ' ';
|
||||
p.printSymbolName(getName());
|
||||
|
||||
FunctionType type = getType();
|
||||
FunctionType type = getFunctionType();
|
||||
function_interface_impl::printFunctionSignature(p, *this, type.getInputs(),
|
||||
/*isVariadic=*/false,
|
||||
type.getResults());
|
||||
|
@ -899,12 +899,12 @@ void GPUFuncOp::print(OpAsmPrinter &p) {
|
|||
}
|
||||
|
||||
LogicalResult GPUFuncOp::verifyType() {
|
||||
Type type = getTypeAttr().getValue();
|
||||
Type type = getFunctionTypeAttr().getValue();
|
||||
if (!type.isa<FunctionType>())
|
||||
return emitOpError("requires '" + getTypeAttrName() +
|
||||
"' attribute of function type");
|
||||
|
||||
if (isKernel() && getType().getNumResults() != 0)
|
||||
if (isKernel() && getFunctionType().getNumResults() != 0)
|
||||
return emitOpError() << "expected void return type for kernel function";
|
||||
|
||||
return success();
|
||||
|
@ -936,7 +936,7 @@ LogicalResult GPUFuncOp::verifyBody() {
|
|||
<< numFuncArguments + numWorkgroupAttributions
|
||||
<< " arguments to body region";
|
||||
|
||||
ArrayRef<Type> funcArgTypes = getType().getInputs();
|
||||
ArrayRef<Type> funcArgTypes = getFunctionType().getInputs();
|
||||
for (unsigned i = 0; i < numFuncArguments; ++i) {
|
||||
Type blockArgType = front().getArgument(i).getType();
|
||||
if (funcArgTypes[i] != blockArgType)
|
||||
|
@ -961,7 +961,7 @@ LogicalResult GPUFuncOp::verifyBody() {
|
|||
LogicalResult gpu::ReturnOp::verify() {
|
||||
GPUFuncOp function = (*this)->getParentOfType<GPUFuncOp>();
|
||||
|
||||
FunctionType funType = function.getType();
|
||||
FunctionType funType = function.getFunctionType();
|
||||
|
||||
if (funType.getNumResults() != operands().size())
|
||||
return emitOpError()
|
||||
|
@ -970,7 +970,7 @@ LogicalResult gpu::ReturnOp::verify() {
|
|||
.append("return type declared here");
|
||||
|
||||
for (const auto &pair : llvm::enumerate(
|
||||
llvm::zip(function.getType().getResults(), operands()))) {
|
||||
llvm::zip(function.getFunctionType().getResults(), operands()))) {
|
||||
Type type;
|
||||
Value operand;
|
||||
std::tie(type, operand) = pair.value();
|
||||
|
|
|
@ -1003,7 +1003,7 @@ LogicalResult CallOp::verify() {
|
|||
return emitOpError() << "'" << calleeName.getValue()
|
||||
<< "' does not reference a valid LLVM function";
|
||||
|
||||
fnType = fn.getType();
|
||||
fnType = fn.getFunctionType();
|
||||
}
|
||||
|
||||
LLVMFunctionType funcType = fnType.dyn_cast<LLVMFunctionType>();
|
||||
|
@ -1499,7 +1499,7 @@ LogicalResult ReturnOp::verify() {
|
|||
return emitOpError("expected at most 1 operand");
|
||||
|
||||
if (auto parent = (*this)->getParentOfType<LLVMFuncOp>()) {
|
||||
Type expectedType = parent.getType().getReturnType();
|
||||
Type expectedType = parent.getFunctionType().getReturnType();
|
||||
if (expectedType.isa<LLVMVoidType>()) {
|
||||
if (getNumOperands() == 0)
|
||||
return success();
|
||||
|
@ -1571,8 +1571,8 @@ LogicalResult AddressOfOp::verify() {
|
|||
return emitOpError(
|
||||
"the type must be a pointer to the type of the referenced global");
|
||||
|
||||
if (function &&
|
||||
LLVM::LLVMPointerType::get(function.getType()) != getResult().getType())
|
||||
if (function && LLVM::LLVMPointerType::get(function.getFunctionType()) !=
|
||||
getResult().getType())
|
||||
return emitOpError(
|
||||
"the type must be a pointer to the type of the referenced function");
|
||||
|
||||
|
@ -1965,7 +1965,7 @@ Block *LLVMFuncOp::addEntryBlock() {
|
|||
push_back(entry);
|
||||
|
||||
// FIXME: Allow passing in proper locations for the entry arguments.
|
||||
LLVMFunctionType type = getType();
|
||||
LLVMFunctionType type = getFunctionType();
|
||||
for (unsigned i = 0, e = type.getNumParams(); i < e; ++i)
|
||||
entry->addArgument(type.getParamType(i), getLoc());
|
||||
return entry;
|
||||
|
@ -1978,7 +1978,8 @@ void LLVMFuncOp::build(OpBuilder &builder, OperationState &result,
|
|||
result.addRegion();
|
||||
result.addAttribute(SymbolTable::getSymbolAttrName(),
|
||||
builder.getStringAttr(name));
|
||||
result.addAttribute("type", TypeAttr::get(type));
|
||||
result.addAttribute(getFunctionTypeAttrName(result.name),
|
||||
TypeAttr::get(type));
|
||||
result.addAttribute(::getLinkageAttrName(),
|
||||
LinkageAttr::get(builder.getContext(), linkage));
|
||||
result.attributes.append(attrs.begin(), attrs.end());
|
||||
|
@ -2089,7 +2090,7 @@ void LLVMFuncOp::print(OpAsmPrinter &p) {
|
|||
p << stringifyLinkage(getLinkage()) << ' ';
|
||||
p.printSymbolName(getName());
|
||||
|
||||
LLVMFunctionType fnType = getType();
|
||||
LLVMFunctionType fnType = getFunctionType();
|
||||
SmallVector<Type, 8> argTypes;
|
||||
SmallVector<Type, 1> resTypes;
|
||||
argTypes.reserve(fnType.getNumParams());
|
||||
|
@ -2114,15 +2115,6 @@ void LLVMFuncOp::print(OpAsmPrinter &p) {
|
|||
}
|
||||
}
|
||||
|
||||
LogicalResult LLVMFuncOp::verifyType() {
|
||||
auto llvmType = getTypeAttr().getValue().dyn_cast_or_null<LLVMFunctionType>();
|
||||
if (!llvmType)
|
||||
return emitOpError("requires '" + getTypeAttrName() +
|
||||
"' attribute of wrapped LLVM function type");
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
// Verifies LLVM- and implementation-specific properties of the LLVM func Op:
|
||||
// - functions don't have 'common' linkage
|
||||
// - external functions have 'external' or 'extern_weak' linkage;
|
||||
|
@ -2135,7 +2127,7 @@ LogicalResult LLVMFuncOp::verify() {
|
|||
|
||||
// Check to see if this function has a void return with a result attribute to
|
||||
// it. It isn't clear what semantics we would assign to that.
|
||||
if (getType().getReturnType().isa<LLVMVoidType>() &&
|
||||
if (getFunctionType().getReturnType().isa<LLVMVoidType>() &&
|
||||
!getResultAttrs(0).empty()) {
|
||||
return emitOpError()
|
||||
<< "cannot attach result attributes to functions with a void return";
|
||||
|
@ -2164,7 +2156,7 @@ LogicalResult LLVMFuncOp::verifyRegions() {
|
|||
if (isExternal())
|
||||
return success();
|
||||
|
||||
unsigned numArguments = getType().getNumParams();
|
||||
unsigned numArguments = getFunctionType().getNumParams();
|
||||
Block &entryBlock = front();
|
||||
for (unsigned i = 0; i < numArguments; ++i) {
|
||||
Type argType = entryBlock.getArgument(i).getType();
|
||||
|
|
|
@ -389,8 +389,8 @@ static LogicalResult bufferizeFuncOpBoundary(FuncOp funcOp,
|
|||
getModuleAnalysisState(state.getAnalysisState());
|
||||
|
||||
// If nothing to do then we are done.
|
||||
if (!llvm::any_of(funcOp.getType().getInputs(), isaTensor) &&
|
||||
!llvm::any_of(funcOp.getType().getResults(), isaTensor))
|
||||
if (!llvm::any_of(funcOp.getFunctionType().getInputs(), isaTensor) &&
|
||||
!llvm::any_of(funcOp.getFunctionType().getResults(), isaTensor))
|
||||
return success();
|
||||
|
||||
// Get the bufferized FunctionType for funcOp or construct it if not yet
|
||||
|
@ -412,11 +412,11 @@ static LogicalResult bufferizeFuncOpBoundary(FuncOp funcOp,
|
|||
// bufferization contract they want to enforce atm.
|
||||
// As a consequence, only support functions that don't return any tensor atm.
|
||||
if (funcOp.getBody().empty()) {
|
||||
if (llvm::any_of(funcOp.getType().getResults(), isaTensor))
|
||||
if (llvm::any_of(funcOp.getFunctionType().getResults(), isaTensor))
|
||||
return funcOp->emitError() << "cannot bufferize bodiless function that "
|
||||
<< "returns a tensor";
|
||||
FunctionType bufferizedFuncType = getBufferizedFunctionType(
|
||||
funcOp.getContext(), funcOp.getType().getInputs(), TypeRange{},
|
||||
funcOp.getContext(), funcOp.getFunctionType().getInputs(), TypeRange{},
|
||||
state.getOptions());
|
||||
funcOp.setType(bufferizedFuncType);
|
||||
return success();
|
||||
|
@ -451,8 +451,8 @@ static LogicalResult bufferizeFuncOpBoundary(FuncOp funcOp,
|
|||
// 2. Rewrite the terminator without the inPlace bufferizable values.
|
||||
ValueRange retValues{returnValues};
|
||||
FunctionType bufferizedFuncType = getBufferizedFunctionType(
|
||||
funcOp.getContext(), funcOp.getType().getInputs(), retValues.getTypes(),
|
||||
state.getOptions());
|
||||
funcOp.getContext(), funcOp.getFunctionType().getInputs(),
|
||||
retValues.getTypes(), state.getOptions());
|
||||
OpBuilder b(returnOp);
|
||||
b.create<func::ReturnOp>(returnOp.getLoc(), returnValues);
|
||||
returnOp->erase();
|
||||
|
@ -598,7 +598,8 @@ static void layoutPostProcessing(ModuleOp moduleOp) {
|
|||
SmallVector<Type> argumentTypes;
|
||||
// Iterate on each function argument and check it it was marked with a
|
||||
// desired layout.
|
||||
for (const auto &it : llvm::enumerate(funcOp.getType().getInputs())) {
|
||||
for (const auto &it :
|
||||
llvm::enumerate(funcOp.getFunctionType().getInputs())) {
|
||||
int argNumber = it.index();
|
||||
Type inputType = it.value();
|
||||
auto memrefType = inputType.dyn_cast<MemRefType>();
|
||||
|
@ -661,7 +662,7 @@ static void layoutPostProcessing(ModuleOp moduleOp) {
|
|||
|
||||
// Finally set the funcOp type to update the arguments.
|
||||
auto newFuncType = FunctionType::get(moduleOp.getContext(), argumentTypes,
|
||||
funcOp.getType().getResults());
|
||||
funcOp.getFunctionType().getResults());
|
||||
funcOp.setType(newFuncType);
|
||||
}
|
||||
}
|
||||
|
@ -1046,7 +1047,7 @@ LogicalResult mlir::linalg::comprehensive_bufferize::runModuleBufferize(
|
|||
return failure();
|
||||
|
||||
if (!options.allowReturnAllocs &&
|
||||
llvm::any_of(funcOp.getType().getResults(), [](Type t) {
|
||||
llvm::any_of(funcOp.getFunctionType().getResults(), [](Type t) {
|
||||
return t.isa<MemRefType, UnrankedMemRefType>();
|
||||
})) {
|
||||
funcOp->emitError("memref return type is unsupported");
|
||||
|
|
|
@ -193,7 +193,7 @@ bool NormalizeMemRefs::areMemRefsNormalizable(FuncOp funcOp) {
|
|||
/// returned value is in turn used in ReturnOp of the calling function.
|
||||
void NormalizeMemRefs::updateFunctionSignature(FuncOp funcOp,
|
||||
ModuleOp moduleOp) {
|
||||
FunctionType functionType = funcOp.getType();
|
||||
FunctionType functionType = funcOp.getFunctionType();
|
||||
SmallVector<Type, 4> resultTypes;
|
||||
FunctionType newFuncType;
|
||||
resultTypes = llvm::to_vector<4>(functionType.getResults());
|
||||
|
@ -333,7 +333,7 @@ void NormalizeMemRefs::normalizeFuncOpMemRefs(FuncOp funcOp,
|
|||
// We use this OpBuilder to create new memref layout later.
|
||||
OpBuilder b(funcOp);
|
||||
|
||||
FunctionType functionType = funcOp.getType();
|
||||
FunctionType functionType = funcOp.getFunctionType();
|
||||
SmallVector<Location> functionArgLocs(llvm::map_range(
|
||||
funcOp.getArguments(), [](BlockArgument arg) { return arg.getLoc(); }));
|
||||
SmallVector<Type, 8> inputTypes;
|
||||
|
|
|
@ -2245,7 +2245,7 @@ void spirv::FuncOp::print(OpAsmPrinter &printer) {
|
|||
// Print function name, signature, and control.
|
||||
printer << " ";
|
||||
printer.printSymbolName(sym_name());
|
||||
auto fnType = getType();
|
||||
auto fnType = getFunctionType();
|
||||
function_interface_impl::printFunctionSignature(
|
||||
printer, *this, fnType.getInputs(),
|
||||
/*isVariadic=*/false, fnType.getResults());
|
||||
|
@ -2265,17 +2265,17 @@ void spirv::FuncOp::print(OpAsmPrinter &printer) {
|
|||
}
|
||||
|
||||
LogicalResult spirv::FuncOp::verifyType() {
|
||||
auto type = getTypeAttr().getValue();
|
||||
auto type = getFunctionTypeAttr().getValue();
|
||||
if (!type.isa<FunctionType>())
|
||||
return emitOpError("requires '" + getTypeAttrName() +
|
||||
"' attribute of function type");
|
||||
if (getType().getNumResults() > 1)
|
||||
if (getFunctionType().getNumResults() > 1)
|
||||
return emitOpError("cannot have more than one result");
|
||||
return success();
|
||||
}
|
||||
|
||||
LogicalResult spirv::FuncOp::verifyBody() {
|
||||
FunctionType fnType = getType();
|
||||
FunctionType fnType = getFunctionType();
|
||||
|
||||
auto walkResult = walk([fnType](Operation *op) -> WalkResult {
|
||||
if (auto retOp = dyn_cast<spirv::ReturnOp>(op)) {
|
||||
|
@ -2322,7 +2322,7 @@ Region *spirv::FuncOp::getCallableRegion() {
|
|||
|
||||
// CallableOpInterface
|
||||
ArrayRef<Type> spirv::FuncOp::getCallableResults() {
|
||||
return getType().getResults();
|
||||
return getFunctionType().getResults();
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -2339,7 +2339,7 @@ LogicalResult spirv::FunctionCallOp::verify() {
|
|||
<< fnName.getValue() << "' not found in nearest symbol table";
|
||||
}
|
||||
|
||||
auto functionType = funcOp.getType();
|
||||
auto functionType = funcOp.getFunctionType();
|
||||
|
||||
if (getNumResults() > 1) {
|
||||
return emitOpError(
|
||||
|
|
|
@ -39,7 +39,7 @@ createGlobalVarForEntryPointArgument(OpBuilder &builder, spirv::FuncOp funcOp,
|
|||
// Get the type of variable. If this is a scalar/vector type and has an ABI
|
||||
// info create a variable of type !spv.ptr<!spv.struct<elementType>>. If not
|
||||
// it must already be a !spv.ptr<!spv.struct<...>>.
|
||||
auto varType = funcOp.getType().getInput(argIndex);
|
||||
auto varType = funcOp.getFunctionType().getInput(argIndex);
|
||||
if (varType.cast<spirv::SPIRVType>().isScalarOrVector()) {
|
||||
auto storageClass = abiInfo.getStorageClass();
|
||||
if (!storageClass)
|
||||
|
@ -179,13 +179,14 @@ LogicalResult ProcessInterfaceVarABI::matchAndRewrite(
|
|||
return failure();
|
||||
}
|
||||
TypeConverter::SignatureConversion signatureConverter(
|
||||
funcOp.getType().getNumInputs());
|
||||
funcOp.getFunctionType().getNumInputs());
|
||||
|
||||
auto &typeConverter = *getTypeConverter<SPIRVTypeConverter>();
|
||||
auto indexType = typeConverter.getIndexType();
|
||||
|
||||
auto attrName = spirv::getInterfaceVarABIAttrName();
|
||||
for (const auto &argType : llvm::enumerate(funcOp.getType().getInputs())) {
|
||||
for (const auto &argType :
|
||||
llvm::enumerate(funcOp.getFunctionType().getInputs())) {
|
||||
auto abiInfo = funcOp.getArgAttrOfType<spirv::InterfaceVarABIAttr>(
|
||||
argType.index(), attrName);
|
||||
if (!abiInfo) {
|
||||
|
|
|
@ -553,7 +553,7 @@ public:
|
|||
LogicalResult
|
||||
FuncOpConversion::matchAndRewrite(FuncOp funcOp, OpAdaptor adaptor,
|
||||
ConversionPatternRewriter &rewriter) const {
|
||||
auto fnType = funcOp.getType();
|
||||
auto fnType = funcOp.getFunctionType();
|
||||
if (fnType.getNumResults() > 1)
|
||||
return failure();
|
||||
|
||||
|
|
|
@ -83,8 +83,9 @@ struct SparseTensorConversionPass
|
|||
// All dynamic rules below accept new function, call, return, and tensor
|
||||
// dim and cast operations as legal output of the rewriting provided that
|
||||
// all sparse tensor types have been fully rewritten.
|
||||
target.addDynamicallyLegalOp<FuncOp>(
|
||||
[&](FuncOp op) { return converter.isSignatureLegal(op.getType()); });
|
||||
target.addDynamicallyLegalOp<FuncOp>([&](FuncOp op) {
|
||||
return converter.isSignatureLegal(op.getFunctionType());
|
||||
});
|
||||
target.addDynamicallyLegalOp<func::CallOp>([&](func::CallOp op) {
|
||||
return converter.isSignatureLegal(op.getCalleeType());
|
||||
});
|
||||
|
|
|
@ -293,7 +293,7 @@ public:
|
|||
return;
|
||||
|
||||
rewriter.setInsertionPoint(op);
|
||||
FunctionType funcTy = func.getType();
|
||||
FunctionType funcTy = func.getFunctionType();
|
||||
auto resultTys = funcTy.getResults();
|
||||
|
||||
bool castAdded = false;
|
||||
|
|
|
@ -252,7 +252,7 @@ template <typename Type>
|
|||
Error checkCompatibleReturnType(LLVM::LLVMFuncOp mainFunction);
|
||||
template <>
|
||||
Error checkCompatibleReturnType<int32_t>(LLVM::LLVMFuncOp mainFunction) {
|
||||
auto resultType = mainFunction.getType()
|
||||
auto resultType = mainFunction.getFunctionType()
|
||||
.cast<LLVM::LLVMFunctionType>()
|
||||
.getReturnType()
|
||||
.dyn_cast<IntegerType>();
|
||||
|
@ -262,7 +262,7 @@ Error checkCompatibleReturnType<int32_t>(LLVM::LLVMFuncOp mainFunction) {
|
|||
}
|
||||
template <>
|
||||
Error checkCompatibleReturnType<int64_t>(LLVM::LLVMFuncOp mainFunction) {
|
||||
auto resultType = mainFunction.getType()
|
||||
auto resultType = mainFunction.getFunctionType()
|
||||
.cast<LLVM::LLVMFunctionType>()
|
||||
.getReturnType()
|
||||
.dyn_cast<IntegerType>();
|
||||
|
@ -272,7 +272,7 @@ Error checkCompatibleReturnType<int64_t>(LLVM::LLVMFuncOp mainFunction) {
|
|||
}
|
||||
template <>
|
||||
Error checkCompatibleReturnType<float>(LLVM::LLVMFuncOp mainFunction) {
|
||||
if (!mainFunction.getType()
|
||||
if (!mainFunction.getFunctionType()
|
||||
.cast<LLVM::LLVMFunctionType>()
|
||||
.getReturnType()
|
||||
.isa<Float32Type>())
|
||||
|
@ -287,7 +287,9 @@ Error compileAndExecuteSingleReturnFunction(Options &options, ModuleOp module,
|
|||
if (!mainFunction || mainFunction.isExternal())
|
||||
return makeStringError("entry point not found");
|
||||
|
||||
if (mainFunction.getType().cast<LLVM::LLVMFunctionType>().getNumParams() != 0)
|
||||
if (mainFunction.getFunctionType()
|
||||
.cast<LLVM::LLVMFunctionType>()
|
||||
.getNumParams() != 0)
|
||||
return makeStringError("function inputs not supported");
|
||||
|
||||
if (Error error = checkCompatibleReturnType<Type>(mainFunction))
|
||||
|
|
|
@ -585,7 +585,7 @@ static LogicalResult printOperation(CppEmitter &emitter, FuncOp functionOp) {
|
|||
CppEmitter::Scope scope(emitter);
|
||||
raw_indented_ostream &os = emitter.ostream();
|
||||
if (failed(emitter.emitTypes(functionOp.getLoc(),
|
||||
functionOp.getType().getResults())))
|
||||
functionOp.getFunctionType().getResults())))
|
||||
return failure();
|
||||
os << " " << functionOp.getName();
|
||||
|
||||
|
|
|
@ -912,7 +912,7 @@ LogicalResult ModuleTranslation::convertFunctionSignatures() {
|
|||
for (auto function : getModuleBody(mlirModule).getOps<LLVMFuncOp>()) {
|
||||
llvm::FunctionCallee llvmFuncCst = llvmModule->getOrInsertFunction(
|
||||
function.getName(),
|
||||
cast<llvm::FunctionType>(convertType(function.getType())));
|
||||
cast<llvm::FunctionType>(convertType(function.getFunctionType())));
|
||||
llvm::Function *llvmFunc = cast<llvm::Function>(llvmFuncCst.getCallee());
|
||||
llvmFunc->setLinkage(convertLinkageToLLVM(function.getLinkage()));
|
||||
mapFunction(function.getName(), llvmFunc);
|
||||
|
|
|
@ -180,13 +180,13 @@ LogicalResult Serializer::processFuncOp(spirv::FuncOp op) {
|
|||
|
||||
uint32_t fnTypeID = 0;
|
||||
// Generate type of the function.
|
||||
if (failed(processType(op.getLoc(), op.getType(), fnTypeID)))
|
||||
if (failed(processType(op.getLoc(), op.getFunctionType(), fnTypeID)))
|
||||
return failure();
|
||||
|
||||
// Add the function definition.
|
||||
SmallVector<uint32_t, 4> operands;
|
||||
uint32_t resTypeID = 0;
|
||||
auto resultTypes = op.getType().getResults();
|
||||
auto resultTypes = op.getFunctionType().getResults();
|
||||
if (resultTypes.size() > 1) {
|
||||
return op.emitError("cannot serialize function with multiple return types");
|
||||
}
|
||||
|
|
|
@ -3074,7 +3074,7 @@ struct FunctionOpInterfaceSignatureConversion : public ConversionPattern {
|
|||
matchAndRewrite(Operation *op, ArrayRef<Value> operands,
|
||||
ConversionPatternRewriter &rewriter) const override {
|
||||
FunctionOpInterface funcOp = cast<FunctionOpInterface>(op);
|
||||
FunctionType type = funcOp.getType().cast<FunctionType>();
|
||||
FunctionType type = funcOp.getFunctionType().cast<FunctionType>();
|
||||
|
||||
// Convert the original function types.
|
||||
TypeConverter::SignatureConversion result(type.getNumInputs());
|
||||
|
|
|
@ -74,7 +74,7 @@ class FuncOp:
|
|||
|
||||
@property
|
||||
def type(self):
|
||||
return FunctionType(TypeAttr(self.attributes["type"]).value)
|
||||
return FunctionType(TypeAttr(self.attributes["function_type"]).value)
|
||||
|
||||
@property
|
||||
def visibility(self):
|
||||
|
@ -211,7 +211,7 @@ class FuncOp:
|
|||
# Recompute the function type.
|
||||
return_types = [v.type for v in return_values]
|
||||
function_type = FunctionType.get(inputs=inputs, results=return_types)
|
||||
func_op.attributes["type"] = TypeAttr.get(function_type)
|
||||
func_op.attributes["function_type"] = TypeAttr.get(function_type)
|
||||
|
||||
def emit_call_op(*call_args):
|
||||
call_op = func.CallOp(return_types, FlatSymbolRefAttr.get(symbol_name),
|
||||
|
|
|
@ -95,7 +95,8 @@ MlirModule makeAndDumpAdd(MlirContext ctx, MlirLocation location) {
|
|||
mlirAttributeParseGet(ctx, mlirStringRefCreateFromCString("\"add\""));
|
||||
MlirNamedAttribute funcAttrs[] = {
|
||||
mlirNamedAttributeGet(
|
||||
mlirIdentifierGet(ctx, mlirStringRefCreateFromCString("type")),
|
||||
mlirIdentifierGet(ctx,
|
||||
mlirStringRefCreateFromCString("function_type")),
|
||||
funcTypeAttr),
|
||||
mlirNamedAttributeGet(
|
||||
mlirIdentifierGet(ctx, mlirStringRefCreateFromCString("sym_name")),
|
||||
|
|
|
@ -331,10 +331,10 @@ module {
|
|||
|
||||
module {
|
||||
gpu.module @gpu_funcs {
|
||||
// expected-error @+1 {{requires 'type' attribute of function type}}
|
||||
// expected-error @+1 {{attribute 'function_type' failed to satisfy constraint: type attribute of function type}}
|
||||
"gpu.func"() ({
|
||||
gpu.return
|
||||
}) {sym_name="kernel_1", type=f32} : () -> ()
|
||||
}) {sym_name="kernel_1", function_type=f32} : () -> ()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -415,7 +415,7 @@ module {
|
|||
"gpu.func"() ({
|
||||
^bb0(%arg0: f32, %arg1: memref<?xf32>, %arg2: memref<5xf32, 3>, %arg3: memref<5xf32, 5>):
|
||||
"gpu.return"() : () -> ()
|
||||
} ) {gpu.kernel, sym_name = "kernel_1", type = (f32, memref<?xf32>) -> (), workgroup_attributions = 3: i64} : () -> ()
|
||||
} ) {function_type = (f32, memref<?xf32>) -> (), gpu.kernel, sym_name = "kernel_1", workgroup_attributions = 3: i64} : () -> ()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -162,7 +162,7 @@ module attributes {gpu.container_module} {
|
|||
"gpu.func"() ({
|
||||
^bb0(%arg0: f32, %arg1: memref<?xf32>, %arg2: memref<5xf32, 3>, %arg3: memref<5xf32, 5>):
|
||||
"gpu.return"() : () -> ()
|
||||
} ) {gpu.kernel, sym_name = "kernel_1", type = (f32, memref<?xf32>) -> (), workgroup_attributions = 1: i64} : () -> ()
|
||||
} ) {function_type = (f32, memref<?xf32>) -> (), gpu.kernel, sym_name = "kernel_1", workgroup_attributions = 1: i64} : () -> ()
|
||||
}
|
||||
|
||||
func @alloc() {
|
||||
|
|
|
@ -3,20 +3,20 @@
|
|||
|
||||
module {
|
||||
// GENERIC: "llvm.func"
|
||||
// GENERIC: sym_name = "foo"
|
||||
// GENERIC-SAME: type = !llvm.func<void ()>
|
||||
// GENERIC: function_type = !llvm.func<void ()>
|
||||
// GENERIC-SAME: sym_name = "foo"
|
||||
// GENERIC-SAME: () -> ()
|
||||
// CHECK: llvm.func @foo()
|
||||
"llvm.func"() ({
|
||||
}) {sym_name = "foo", type = !llvm.func<void ()>} : () -> ()
|
||||
}) {sym_name = "foo", function_type = !llvm.func<void ()>} : () -> ()
|
||||
|
||||
// GENERIC: "llvm.func"
|
||||
// GENERIC: sym_name = "bar"
|
||||
// GENERIC-SAME: type = !llvm.func<i64 (i64, i64)>
|
||||
// GENERIC: function_type = !llvm.func<i64 (i64, i64)>
|
||||
// GENERIC-SAME: sym_name = "bar"
|
||||
// GENERIC-SAME: () -> ()
|
||||
// CHECK: llvm.func @bar(i64, i64) -> i64
|
||||
"llvm.func"() ({
|
||||
}) {sym_name = "bar", type = !llvm.func<i64 (i64, i64)>} : () -> ()
|
||||
}) {sym_name = "bar", function_type = !llvm.func<i64 (i64, i64)>} : () -> ()
|
||||
|
||||
// GENERIC: "llvm.func"
|
||||
// CHECK: llvm.func @baz(%{{.*}}: i64) -> i64
|
||||
|
@ -26,15 +26,15 @@ module {
|
|||
// GENERIC: llvm.return
|
||||
llvm.return %arg0 : i64
|
||||
|
||||
// GENERIC: sym_name = "baz"
|
||||
// GENERIC-SAME: type = !llvm.func<i64 (i64)>
|
||||
// GENERIC: function_type = !llvm.func<i64 (i64)>
|
||||
// GENERIC-SAME: sym_name = "baz"
|
||||
// GENERIC-SAME: () -> ()
|
||||
}) {sym_name = "baz", type = !llvm.func<i64 (i64)>} : () -> ()
|
||||
}) {sym_name = "baz", function_type = !llvm.func<i64 (i64)>} : () -> ()
|
||||
|
||||
// CHECK: llvm.func @qux(!llvm.ptr<i64> {llvm.noalias}, i64)
|
||||
// CHECK: attributes {xxx = {yyy = 42 : i64}}
|
||||
"llvm.func"() ({
|
||||
}) {sym_name = "qux", type = !llvm.func<void (ptr<i64>, i64)>,
|
||||
}) {sym_name = "qux", function_type = !llvm.func<void (ptr<i64>, i64)>,
|
||||
arg_attrs = [{llvm.noalias}, {}], xxx = {yyy = 42}} : () -> ()
|
||||
|
||||
// CHECK: llvm.func @roundtrip1()
|
||||
|
@ -143,28 +143,28 @@ module {
|
|||
|
||||
module {
|
||||
// expected-error@+1 {{requires one region}}
|
||||
"llvm.func"() {sym_name = "no_region", type = !llvm.func<void ()>} : () -> ()
|
||||
"llvm.func"() {function_type = !llvm.func<void ()>, sym_name = "no_region"} : () -> ()
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
module {
|
||||
// expected-error@+1 {{requires a type attribute 'type'}}
|
||||
// expected-error@+1 {{requires attribute 'function_type'}}
|
||||
"llvm.func"() ({}) {sym_name = "missing_type"} : () -> ()
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
module {
|
||||
// expected-error@+1 {{requires 'type' attribute of wrapped LLVM function type}}
|
||||
"llvm.func"() ({}) {sym_name = "non_llvm_type", type = i64} : () -> ()
|
||||
// expected-error@+1 {{attribute 'function_type' failed to satisfy constraint: type attribute of LLVM function type}}
|
||||
"llvm.func"() ({}) {sym_name = "non_llvm_type", function_type = i64} : () -> ()
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
module {
|
||||
// expected-error@+1 {{requires 'type' attribute of wrapped LLVM function type}}
|
||||
"llvm.func"() ({}) {sym_name = "non_function_type", type = i64} : () -> ()
|
||||
// expected-error@+1 {{attribute 'function_type' failed to satisfy constraint: type attribute of LLVM function type}}
|
||||
"llvm.func"() ({}) {sym_name = "non_function_type", function_type = i64} : () -> ()
|
||||
}
|
||||
|
||||
// -----
|
||||
|
@ -174,7 +174,7 @@ module {
|
|||
"llvm.func"() ({
|
||||
^bb0(%arg0: i64):
|
||||
llvm.return
|
||||
}) {sym_name = "wrong_arg_number", type = !llvm.func<void ()>} : () -> ()
|
||||
}) {function_type = !llvm.func<void ()>, sym_name = "wrong_arg_number"} : () -> ()
|
||||
}
|
||||
|
||||
// -----
|
||||
|
@ -184,7 +184,7 @@ module {
|
|||
"llvm.func"() ({
|
||||
^bb0(%arg0: tensor<*xf32>):
|
||||
llvm.return
|
||||
}) {sym_name = "wrong_arg_number", type = !llvm.func<void (i64)>} : () -> ()
|
||||
}) {function_type = !llvm.func<void (i64)>, sym_name = "wrong_arg_number"} : () -> ()
|
||||
}
|
||||
|
||||
// -----
|
||||
|
|
|
@ -91,8 +91,8 @@ func private @invalid_symbol_name_attr() attributes { sym_name = "x" }
|
|||
|
||||
// -----
|
||||
|
||||
// expected-error@+1 {{'type' is an inferred attribute and should not be specified in the explicit attribute dictionary}}
|
||||
func private @invalid_symbol_type_attr() attributes { type = "x" }
|
||||
// expected-error@+1 {{'function_type' is an inferred attribute and should not be specified in the explicit attribute dictionary}}
|
||||
func private @invalid_symbol_type_attr() attributes { function_type = "x" }
|
||||
|
||||
// -----
|
||||
|
||||
|
|
|
@ -1416,7 +1416,7 @@ test.graph_region {
|
|||
%1 = "foo"(%1, %2) : (i64, i64) -> i64
|
||||
%2 = "bar"(%1) : (i64) -> i64
|
||||
"unregistered_terminator"() : () -> ()
|
||||
}) {sym_name = "unregistered_op_dominance_violation_ok", type = () -> i1} : () -> ()
|
||||
}) {sym_name = "unregistered_op_dominance_violation_ok", function_type = () -> i1} : () -> ()
|
||||
|
||||
// This is an unregister operation, the printing/parsing is handled by the dialect.
|
||||
// CHECK: test.dialect_custom_printer custom_format
|
||||
|
|
|
@ -49,7 +49,7 @@ struct TestDecomposeCallGraphTypes
|
|||
target.addDynamicallyLegalOp<func::CallOp>(
|
||||
[&](func::CallOp op) { return typeConverter.isLegal(op); });
|
||||
target.addDynamicallyLegalOp<FuncOp>([&](FuncOp op) {
|
||||
return typeConverter.isSignatureLegal(op.getType());
|
||||
return typeConverter.isSignatureLegal(op.getFunctionType());
|
||||
});
|
||||
|
||||
typeConverter.addConversion([](Type type) { return type; });
|
||||
|
|
|
@ -676,7 +676,7 @@ struct TestLegalizePatternDriver
|
|||
[](Type type) { return type.isF32(); });
|
||||
});
|
||||
target.addDynamicallyLegalOp<FuncOp>([&](FuncOp op) {
|
||||
return converter.isSignatureLegal(op.getType()) &&
|
||||
return converter.isSignatureLegal(op.getFunctionType()) &&
|
||||
converter.isLegal(&op.getBody());
|
||||
});
|
||||
target.addDynamicallyLegalOp<func::CallOp>(
|
||||
|
@ -1106,7 +1106,7 @@ struct TestTypeConversionDriver
|
|||
recursiveType.getName() == "outer_converted_type");
|
||||
});
|
||||
target.addDynamicallyLegalOp<FuncOp>([&](FuncOp op) {
|
||||
return converter.isSignatureLegal(op.getType()) &&
|
||||
return converter.isSignatureLegal(op.getFunctionType()) &&
|
||||
converter.isLegal(&op.getBody());
|
||||
});
|
||||
target.addDynamicallyLegalOp<TestCastOp>([&](TestCastOp op) {
|
||||
|
|
|
@ -134,8 +134,8 @@ struct TestFuncSetType
|
|||
auto sym = func->getAttrOfType<FlatSymbolRefAttr>("test.set_type_from");
|
||||
if (!sym)
|
||||
continue;
|
||||
func.setType(
|
||||
symbolTable.lookup<FunctionOpInterface>(sym.getValue()).getType());
|
||||
func.setType(symbolTable.lookup<FunctionOpInterface>(sym.getValue())
|
||||
.getFunctionType());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -29,8 +29,8 @@ static LogicalResult createBackwardSliceFunction(Operation *op,
|
|||
OpBuilder builder(parentFuncOp);
|
||||
Location loc = op->getLoc();
|
||||
std::string clonedFuncOpName = parentFuncOp.getName().str() + suffix.str();
|
||||
FuncOp clonedFuncOp =
|
||||
builder.create<FuncOp>(loc, clonedFuncOpName, parentFuncOp.getType());
|
||||
FuncOp clonedFuncOp = builder.create<FuncOp>(loc, clonedFuncOpName,
|
||||
parentFuncOp.getFunctionType());
|
||||
BlockAndValueMapping mapper;
|
||||
builder.setInsertionPointToEnd(clonedFuncOp.addEntryBlock());
|
||||
for (const auto &arg : enumerate(parentFuncOp.getArguments()))
|
||||
|
|
|
@ -114,7 +114,7 @@
|
|||
// CHECK-NEXT: "result": {
|
||||
// CHECK-NEXT: "contents": {
|
||||
// CHECK-NEXT: "kind": "markdown",
|
||||
// CHECK-NEXT: "value": "\"func.func\" : public @foo\n\nGeneric Form:\n\n```mlir\n\"func.func\"() ({\n}) {sym_name = \"foo\", type = (i1) -> ()} : () -> ()\n```\n"
|
||||
// CHECK-NEXT: "value": "\"func.func\" : public @foo\n\nGeneric Form:\n\n```mlir\n\"func.func\"() ({\n}) {function_type = (i1) -> (), sym_name = \"foo\"} : () -> ()\n```\n"
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: "range": {
|
||||
// CHECK-NEXT: "end": {
|
||||
|
@ -138,7 +138,7 @@
|
|||
// CHECK-NEXT: "result": {
|
||||
// CHECK-NEXT: "contents": {
|
||||
// CHECK-NEXT: "kind": "markdown",
|
||||
// CHECK-NEXT: "value": "\"func.func\" : public @foo\n\nGeneric Form:\n\n```mlir\n\"func.func\"() ({\n}) {sym_name = \"foo\", type = (i1) -> ()} : () -> ()\n```\n"
|
||||
// CHECK-NEXT: "value": "\"func.func\" : public @foo\n\nGeneric Form:\n\n```mlir\n\"func.func\"() ({\n}) {function_type = (i1) -> (), sym_name = \"foo\"} : () -> ()\n```\n"
|
||||
// CHECK-NEXT: },
|
||||
// CHECK-NEXT: "range": {
|
||||
// CHECK-NEXT: "end": {
|
||||
|
|
Loading…
Reference in New Issue