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,
|
llvm::SmallVector<mlir::Value> args{box.getAddr(), dimIndex, lowerBound,
|
||||||
upperBound};
|
upperBound};
|
||||||
llvm::SmallVector<mlir::Value> operands;
|
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));
|
operands.emplace_back(builder.createConvert(loc, snd, fst));
|
||||||
builder.create<fir::CallOp>(loc, callee, operands);
|
builder.create<fir::CallOp>(loc, callee, operands);
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ static void genRuntimeInitCharacter(fir::FirOpBuilder &builder,
|
||||||
loc, builder)
|
loc, builder)
|
||||||
: fir::runtime::getRuntimeFunc<mkRTKey(AllocatableInitCharacter)>(
|
: fir::runtime::getRuntimeFunc<mkRTKey(AllocatableInitCharacter)>(
|
||||||
loc, builder);
|
loc, builder);
|
||||||
llvm::ArrayRef<mlir::Type> inputTypes = callee.getType().getInputs();
|
llvm::ArrayRef<mlir::Type> inputTypes = callee.getFunctionType().getInputs();
|
||||||
if (inputTypes.size() != 5)
|
if (inputTypes.size() != 5)
|
||||||
fir::emitFatalError(
|
fir::emitFatalError(
|
||||||
loc, "AllocatableInitCharacter runtime interface not as expected");
|
loc, "AllocatableInitCharacter runtime interface not as expected");
|
||||||
|
@ -175,7 +175,7 @@ static mlir::Value genRuntimeAllocate(fir::FirOpBuilder &builder,
|
||||||
box.getAddr(), errorManager.hasStat, errorManager.errMsgAddr,
|
box.getAddr(), errorManager.hasStat, errorManager.errMsgAddr,
|
||||||
errorManager.sourceFile, errorManager.sourceLine};
|
errorManager.sourceFile, errorManager.sourceLine};
|
||||||
llvm::SmallVector<mlir::Value> operands;
|
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));
|
operands.emplace_back(builder.createConvert(loc, snd, fst));
|
||||||
return builder.create<fir::CallOp>(loc, callee, operands).getResult(0);
|
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,
|
boxAddress, errorManager.hasStat, errorManager.errMsgAddr,
|
||||||
errorManager.sourceFile, errorManager.sourceLine};
|
errorManager.sourceFile, errorManager.sourceLine};
|
||||||
llvm::SmallVector<mlir::Value> operands;
|
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));
|
operands.emplace_back(builder.createConvert(loc, snd, fst));
|
||||||
return builder.create<fir::CallOp>(loc, callee, operands).getResult(0);
|
return builder.create<fir::CallOp>(loc, callee, operands).getResult(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2050,15 +2050,17 @@ public:
|
||||||
auto stackSaveFn = fir::factory::getLlvmStackSave(builder);
|
auto stackSaveFn = fir::factory::getLlvmStackSave(builder);
|
||||||
auto stackSaveSymbol = bldr->getSymbolRefAttr(stackSaveFn.getName());
|
auto stackSaveSymbol = bldr->getSymbolRefAttr(stackSaveFn.getName());
|
||||||
mlir::Value sp =
|
mlir::Value sp =
|
||||||
bldr->create<fir::CallOp>(loc, stackSaveFn.getType().getResults(),
|
bldr->create<fir::CallOp>(
|
||||||
stackSaveSymbol, mlir::ValueRange{})
|
loc, stackSaveFn.getFunctionType().getResults(),
|
||||||
|
stackSaveSymbol, mlir::ValueRange{})
|
||||||
.getResult(0);
|
.getResult(0);
|
||||||
stmtCtx.attachCleanup([bldr, loc, sp]() {
|
stmtCtx.attachCleanup([bldr, loc, sp]() {
|
||||||
auto stackRestoreFn = fir::factory::getLlvmStackRestore(*bldr);
|
auto stackRestoreFn = fir::factory::getLlvmStackRestore(*bldr);
|
||||||
auto stackRestoreSymbol =
|
auto stackRestoreSymbol =
|
||||||
bldr->getSymbolRefAttr(stackRestoreFn.getName());
|
bldr->getSymbolRefAttr(stackRestoreFn.getName());
|
||||||
bldr->create<fir::CallOp>(loc, stackRestoreFn.getType().getResults(),
|
bldr->create<fir::CallOp>(
|
||||||
stackRestoreSymbol, mlir::ValueRange{sp});
|
loc, stackRestoreFn.getFunctionType().getResults(),
|
||||||
|
stackRestoreSymbol, mlir::ValueRange{sp});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
mlir::Value temp =
|
mlir::Value temp =
|
||||||
|
@ -2107,7 +2109,7 @@ public:
|
||||||
mlir::SymbolRefAttr funcSymbolAttr;
|
mlir::SymbolRefAttr funcSymbolAttr;
|
||||||
bool addHostAssociations = false;
|
bool addHostAssociations = false;
|
||||||
if (!funcPointer) {
|
if (!funcPointer) {
|
||||||
mlir::FunctionType funcOpType = caller.getFuncOp().getType();
|
mlir::FunctionType funcOpType = caller.getFuncOp().getFunctionType();
|
||||||
mlir::SymbolRefAttr symbolAttr =
|
mlir::SymbolRefAttr symbolAttr =
|
||||||
builder.getSymbolRefAttr(caller.getMangledName());
|
builder.getSymbolRefAttr(caller.getMangledName());
|
||||||
if (callSiteType.getNumResults() == funcOpType.getNumResults() &&
|
if (callSiteType.getNumResults() == funcOpType.getNumResults() &&
|
||||||
|
@ -2149,7 +2151,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
mlir::FunctionType funcType =
|
mlir::FunctionType funcType =
|
||||||
funcPointer ? callSiteType : caller.getFuncOp().getType();
|
funcPointer ? callSiteType : caller.getFuncOp().getFunctionType();
|
||||||
llvm::SmallVector<mlir::Value> operands;
|
llvm::SmallVector<mlir::Value> operands;
|
||||||
// First operand of indirect call is the function pointer. Cast it to
|
// First operand of indirect call is the function pointer. Cast it to
|
||||||
// required function type for the call to handle procedures that have a
|
// 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);
|
return builder.createConvert(loc, argType, from);
|
||||||
};
|
};
|
||||||
assert(func.getNumArguments() == 2);
|
assert(func.getNumArguments() == 2);
|
||||||
mlir::Type lhsType = func.getType().getInput(0);
|
mlir::Type lhsType = func.getFunctionType().getInput(0);
|
||||||
mlir::Type rhsType = func.getType().getInput(1);
|
mlir::Type rhsType = func.getFunctionType().getInput(1);
|
||||||
mlir::Value lhsArg = prepareUserDefinedArg(builder, loc, lhs, lhsType);
|
mlir::Value lhsArg = prepareUserDefinedArg(builder, loc, lhs, lhsType);
|
||||||
mlir::Value rhsArg = prepareUserDefinedArg(builder, loc, rhs, rhsType);
|
mlir::Value rhsArg = prepareUserDefinedArg(builder, loc, rhs, rhsType);
|
||||||
builder.create<fir::CallOp>(loc, func, mlir::ValueRange{lhsArg, rhsArg});
|
builder.create<fir::CallOp>(loc, func, mlir::ValueRange{lhsArg, rhsArg});
|
||||||
|
@ -4901,7 +4903,7 @@ public:
|
||||||
|
|
||||||
/// Get the function signature of the LLVM memcpy intrinsic.
|
/// Get the function signature of the LLVM memcpy intrinsic.
|
||||||
mlir::FunctionType memcpyType() {
|
mlir::FunctionType memcpyType() {
|
||||||
return fir::factory::getLlvmMemcpy(builder).getType();
|
return fir::factory::getLlvmMemcpy(builder).getFunctionType();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a call to the LLVM memcpy intrinsic.
|
/// Create a call to the LLVM memcpy intrinsic.
|
||||||
|
@ -4910,7 +4912,7 @@ public:
|
||||||
mlir::FuncOp memcpyFunc = fir::factory::getLlvmMemcpy(builder);
|
mlir::FuncOp memcpyFunc = fir::factory::getLlvmMemcpy(builder);
|
||||||
mlir::SymbolRefAttr funcSymAttr =
|
mlir::SymbolRefAttr funcSymAttr =
|
||||||
builder.getSymbolRefAttr(memcpyFunc.getName());
|
builder.getSymbolRefAttr(memcpyFunc.getName());
|
||||||
mlir::FunctionType funcTy = memcpyFunc.getType();
|
mlir::FunctionType funcTy = memcpyFunc.getFunctionType();
|
||||||
builder.create<fir::CallOp>(loc, funcTy.getResults(), funcSymAttr, args);
|
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::Value byteSz = builder.create<mlir::arith::MulIOp>(loc, newSz, eleSz);
|
||||||
mlir::SymbolRefAttr funcSymAttr =
|
mlir::SymbolRefAttr funcSymAttr =
|
||||||
builder.getSymbolRefAttr(reallocFunc.getName());
|
builder.getSymbolRefAttr(reallocFunc.getName());
|
||||||
mlir::FunctionType funcTy = reallocFunc.getType();
|
mlir::FunctionType funcTy = reallocFunc.getFunctionType();
|
||||||
auto newMem = builder.create<fir::CallOp>(
|
auto newMem = builder.create<fir::CallOp>(
|
||||||
loc, funcTy.getResults(), funcSymAttr,
|
loc, funcTy.getResults(), funcSymAttr,
|
||||||
llvm::ArrayRef<mlir::Value>{
|
llvm::ArrayRef<mlir::Value>{
|
||||||
|
|
|
@ -515,8 +515,8 @@ void Fortran::lower::HostAssociations::internalProcedureBindings(
|
||||||
mlir::Location loc = converter.getCurrentLocation();
|
mlir::Location loc = converter.getCurrentLocation();
|
||||||
mlir::FuncOp func = builder.getFunction();
|
mlir::FuncOp func = builder.getFunction();
|
||||||
mlir::Value tupleArg;
|
mlir::Value tupleArg;
|
||||||
for (auto [ty, arg] : llvm::reverse(
|
for (auto [ty, arg] : llvm::reverse(llvm::zip(
|
||||||
llvm::zip(func.getType().getInputs(), func.front().getArguments())))
|
func.getFunctionType().getInputs(), func.front().getArguments())))
|
||||||
if (ty == argTy) {
|
if (ty == argTy) {
|
||||||
tupleArg = arg;
|
tupleArg = arg;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -91,15 +91,14 @@ static constexpr std::tuple<
|
||||||
#ifdef __SIZEOF_INT128__
|
#ifdef __SIZEOF_INT128__
|
||||||
mkIOKey(OutputInteger128),
|
mkIOKey(OutputInteger128),
|
||||||
#endif
|
#endif
|
||||||
mkIOKey(InputInteger),
|
mkIOKey(InputInteger), mkIOKey(OutputReal32), mkIOKey(InputReal32),
|
||||||
mkIOKey(OutputReal32), mkIOKey(InputReal32), mkIOKey(OutputReal64),
|
mkIOKey(OutputReal64), mkIOKey(InputReal64), mkIOKey(OutputComplex32),
|
||||||
mkIOKey(InputReal64), mkIOKey(OutputComplex32), mkIOKey(InputComplex32),
|
mkIOKey(InputComplex32), mkIOKey(OutputComplex64), mkIOKey(InputComplex64),
|
||||||
mkIOKey(OutputComplex64), mkIOKey(InputComplex64), mkIOKey(OutputAscii),
|
mkIOKey(OutputAscii), mkIOKey(InputAscii), mkIOKey(OutputLogical),
|
||||||
mkIOKey(InputAscii), mkIOKey(OutputLogical), mkIOKey(InputLogical),
|
mkIOKey(InputLogical), mkIOKey(SetAccess), mkIOKey(SetAction),
|
||||||
mkIOKey(SetAccess), mkIOKey(SetAction), mkIOKey(SetAsynchronous),
|
mkIOKey(SetAsynchronous), mkIOKey(SetCarriagecontrol), mkIOKey(SetEncoding),
|
||||||
mkIOKey(SetCarriagecontrol), mkIOKey(SetEncoding), mkIOKey(SetForm),
|
mkIOKey(SetForm), mkIOKey(SetPosition), mkIOKey(SetRecl),
|
||||||
mkIOKey(SetPosition), mkIOKey(SetRecl), mkIOKey(SetStatus),
|
mkIOKey(SetStatus), mkIOKey(SetFile), mkIOKey(GetNewUnit), mkIOKey(GetSize),
|
||||||
mkIOKey(SetFile), mkIOKey(GetNewUnit), mkIOKey(GetSize),
|
|
||||||
mkIOKey(GetIoLength), mkIOKey(GetIoMsg), mkIOKey(InquireCharacter),
|
mkIOKey(GetIoLength), mkIOKey(GetIoMsg), mkIOKey(InquireCharacter),
|
||||||
mkIOKey(InquireLogical), mkIOKey(InquirePendingId),
|
mkIOKey(InquireLogical), mkIOKey(InquirePendingId),
|
||||||
mkIOKey(InquireInteger64), mkIOKey(EndIoStatement)>
|
mkIOKey(InquireInteger64), mkIOKey(EndIoStatement)>
|
||||||
|
@ -188,9 +187,9 @@ static mlir::Value genEndIO(Fortran::lower::AbstractConverter &converter,
|
||||||
loc, getIoMsg,
|
loc, getIoMsg,
|
||||||
mlir::ValueRange{
|
mlir::ValueRange{
|
||||||
cookie,
|
cookie,
|
||||||
builder.createConvert(loc, getIoMsg.getType().getInput(1),
|
builder.createConvert(loc, getIoMsg.getFunctionType().getInput(1),
|
||||||
fir::getBase(ioMsgVar)),
|
fir::getBase(ioMsgVar)),
|
||||||
builder.createConvert(loc, getIoMsg.getType().getInput(2),
|
builder.createConvert(loc, getIoMsg.getFunctionType().getInput(2),
|
||||||
fir::getLen(ioMsgVar))});
|
fir::getLen(ioMsgVar))});
|
||||||
}
|
}
|
||||||
mlir::FuncOp endIoStatement =
|
mlir::FuncOp endIoStatement =
|
||||||
|
@ -395,7 +394,7 @@ static void genNamelistIO(Fortran::lower::AbstractConverter &converter,
|
||||||
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
||||||
mlir::Location loc = converter.getCurrentLocation();
|
mlir::Location loc = converter.getCurrentLocation();
|
||||||
makeNextConditionalOn(builder, loc, checkResult, ok);
|
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);
|
mlir::Value groupAddr = getNamelistGroup(converter, symbol, stmtCtx);
|
||||||
groupAddr = builder.createConvert(loc, argType, groupAddr);
|
groupAddr = builder.createConvert(loc, argType, groupAddr);
|
||||||
llvm::SmallVector<mlir::Value> args = {cookie, 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");
|
fir::emitFatalError(loc, "internal error: could not get evaluate::Expr");
|
||||||
mlir::Type itemTy = converter.genType(*expr);
|
mlir::Type itemTy = converter.genType(*expr);
|
||||||
mlir::FuncOp outputFunc = getOutputFunc(loc, builder, itemTy, isFormatted);
|
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>()) &&
|
assert((isFormatted || argType.isa<fir::BoxType>()) &&
|
||||||
"expect descriptor for unformatted IO runtime");
|
"expect descriptor for unformatted IO runtime");
|
||||||
llvm::SmallVector<mlir::Value> outputFuncArgs = {cookie};
|
llvm::SmallVector<mlir::Value> outputFuncArgs = {cookie};
|
||||||
|
@ -496,9 +495,9 @@ genOutputItemList(Fortran::lower::AbstractConverter &converter,
|
||||||
llvm::report_fatal_error(
|
llvm::report_fatal_error(
|
||||||
"internal error: scalar character not in CharBox");
|
"internal error: scalar character not in CharBox");
|
||||||
outputFuncArgs.push_back(builder.createConvert(
|
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(
|
outputFuncArgs.push_back(builder.createConvert(
|
||||||
loc, outputFunc.getType().getInput(2), fir::getLen(exv)));
|
loc, outputFunc.getFunctionType().getInput(2), fir::getLen(exv)));
|
||||||
} else {
|
} else {
|
||||||
fir::ExtendedValue itemBox = converter.genExprValue(expr, stmtCtx, loc);
|
fir::ExtendedValue itemBox = converter.genExprValue(expr, stmtCtx, loc);
|
||||||
mlir::Value itemValue = fir::getBase(itemBox);
|
mlir::Value itemValue = fir::getBase(itemBox);
|
||||||
|
@ -573,7 +572,7 @@ static mlir::Value createIoRuntimeCallForItem(mlir::Location loc,
|
||||||
mlir::FuncOp inputFunc,
|
mlir::FuncOp inputFunc,
|
||||||
mlir::Value cookie,
|
mlir::Value cookie,
|
||||||
const fir::ExtendedValue &item) {
|
const fir::ExtendedValue &item) {
|
||||||
mlir::Type argType = inputFunc.getType().getInput(1);
|
mlir::Type argType = inputFunc.getFunctionType().getInput(1);
|
||||||
llvm::SmallVector<mlir::Value> inputFuncArgs = {cookie};
|
llvm::SmallVector<mlir::Value> inputFuncArgs = {cookie};
|
||||||
if (argType.isa<fir::BoxType>()) {
|
if (argType.isa<fir::BoxType>()) {
|
||||||
mlir::Value box = fir::getBase(item);
|
mlir::Value box = fir::getBase(item);
|
||||||
|
@ -586,8 +585,8 @@ static mlir::Value createIoRuntimeCallForItem(mlir::Location loc,
|
||||||
fir::factory::CharacterExprHelper charHelper{builder, loc};
|
fir::factory::CharacterExprHelper charHelper{builder, loc};
|
||||||
if (charHelper.isCharacterScalar(itemTy)) {
|
if (charHelper.isCharacterScalar(itemTy)) {
|
||||||
mlir::Value len = fir::getLen(item);
|
mlir::Value len = fir::getLen(item);
|
||||||
inputFuncArgs.push_back(
|
inputFuncArgs.push_back(builder.createConvert(
|
||||||
builder.createConvert(loc, inputFunc.getType().getInput(2), len));
|
loc, inputFunc.getFunctionType().getInput(2), len));
|
||||||
} else if (itemTy.isa<mlir::IntegerType>()) {
|
} else if (itemTy.isa<mlir::IntegerType>()) {
|
||||||
inputFuncArgs.push_back(builder.create<mlir::arith::ConstantOp>(
|
inputFuncArgs.push_back(builder.create<mlir::arith::ConstantOp>(
|
||||||
loc, builder.getI32IntegerAttr(
|
loc, builder.getI32IntegerAttr(
|
||||||
|
@ -627,7 +626,8 @@ static void genInputItemList(Fortran::lower::AbstractConverter &converter,
|
||||||
Fortran::lower::genVectorSubscriptBox(loc, converter, stmtCtx, *expr);
|
Fortran::lower::genVectorSubscriptBox(loc, converter, stmtCtx, *expr);
|
||||||
mlir::FuncOp inputFunc = getInputFunc(
|
mlir::FuncOp inputFunc = getInputFunc(
|
||||||
loc, builder, vectorSubscriptBox.getElementType(), isFormatted);
|
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) {
|
if (!checkResult) {
|
||||||
auto elementalGenerator = [&](const fir::ExtendedValue &element) {
|
auto elementalGenerator = [&](const fir::ExtendedValue &element) {
|
||||||
createIoRuntimeCallForItem(loc, builder, inputFunc, cookie,
|
createIoRuntimeCallForItem(loc, builder, inputFunc, cookie,
|
||||||
|
@ -651,7 +651,7 @@ static void genInputItemList(Fortran::lower::AbstractConverter &converter,
|
||||||
}
|
}
|
||||||
mlir::Type itemTy = converter.genType(*expr);
|
mlir::Type itemTy = converter.genType(*expr);
|
||||||
mlir::FuncOp inputFunc = getInputFunc(loc, builder, itemTy, isFormatted);
|
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.genExprBox(*expr, stmtCtx, loc)
|
||||||
: converter.genExprAddr(expr, stmtCtx, loc);
|
: converter.genExprAddr(expr, stmtCtx, loc);
|
||||||
ok = createIoRuntimeCallForItem(loc, builder, inputFunc, cookie, itemExv);
|
ok = createIoRuntimeCallForItem(loc, builder, inputFunc, cookie, itemExv);
|
||||||
|
@ -871,7 +871,7 @@ mlir::Value genIntIOOption(Fortran::lower::AbstractConverter &converter,
|
||||||
Fortran::lower::StatementContext localStatementCtx;
|
Fortran::lower::StatementContext localStatementCtx;
|
||||||
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
||||||
mlir::FuncOp ioFunc = getIORuntimeFunc<A>(loc, builder);
|
mlir::FuncOp ioFunc = getIORuntimeFunc<A>(loc, builder);
|
||||||
mlir::FunctionType ioFuncTy = ioFunc.getType();
|
mlir::FunctionType ioFuncTy = ioFunc.getFunctionType();
|
||||||
mlir::Value expr = fir::getBase(converter.genExprValue(
|
mlir::Value expr = fir::getBase(converter.genExprValue(
|
||||||
Fortran::semantics::GetExpr(spec.v), localStatementCtx, loc));
|
Fortran::semantics::GetExpr(spec.v), localStatementCtx, loc));
|
||||||
mlir::Value val = builder.createConvert(loc, ioFuncTy.getInput(1), expr);
|
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;
|
Fortran::lower::StatementContext localStatementCtx;
|
||||||
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
||||||
mlir::FuncOp ioFunc = getIORuntimeFunc<A>(loc, builder);
|
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 =
|
std::tuple<mlir::Value, mlir::Value, mlir::Value> tup =
|
||||||
lowerStringLit(converter, loc, localStatementCtx, spec,
|
lowerStringLit(converter, loc, localStatementCtx, spec,
|
||||||
ioFuncTy.getInput(1), ioFuncTy.getInput(2));
|
ioFuncTy.getInput(1), ioFuncTy.getInput(2));
|
||||||
|
@ -920,7 +920,7 @@ mlir::Value genIOOption<Fortran::parser::FileNameExpr>(
|
||||||
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
||||||
// has an extra KIND argument
|
// has an extra KIND argument
|
||||||
mlir::FuncOp ioFunc = getIORuntimeFunc<mkIOKey(SetFile)>(loc, builder);
|
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 =
|
std::tuple<mlir::Value, mlir::Value, mlir::Value> tup =
|
||||||
lowerStringLit(converter, loc, localStatementCtx, spec,
|
lowerStringLit(converter, loc, localStatementCtx, spec,
|
||||||
ioFuncTy.getInput(1), ioFuncTy.getInput(2));
|
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");
|
TODO(loc, "DISPOSE not part of the runtime::io interface");
|
||||||
}
|
}
|
||||||
Fortran::lower::StatementContext localStatementCtx;
|
Fortran::lower::StatementContext localStatementCtx;
|
||||||
mlir::FunctionType ioFuncTy = ioFunc.getType();
|
mlir::FunctionType ioFuncTy = ioFunc.getFunctionType();
|
||||||
std::tuple<mlir::Value, mlir::Value, mlir::Value> tup =
|
std::tuple<mlir::Value, mlir::Value, mlir::Value> tup =
|
||||||
lowerStringLit(converter, loc, localStatementCtx,
|
lowerStringLit(converter, loc, localStatementCtx,
|
||||||
std::get<Fortran::parser::ScalarDefaultCharExpr>(spec.t),
|
std::get<Fortran::parser::ScalarDefaultCharExpr>(spec.t),
|
||||||
|
@ -1035,7 +1035,7 @@ mlir::Value genIOOption<Fortran::parser::IoControlSpec::CharExpr>(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Fortran::lower::StatementContext localStatementCtx;
|
Fortran::lower::StatementContext localStatementCtx;
|
||||||
mlir::FunctionType ioFuncTy = ioFunc.getType();
|
mlir::FunctionType ioFuncTy = ioFunc.getFunctionType();
|
||||||
std::tuple<mlir::Value, mlir::Value, mlir::Value> tup =
|
std::tuple<mlir::Value, mlir::Value, mlir::Value> tup =
|
||||||
lowerStringLit(converter, loc, localStatementCtx,
|
lowerStringLit(converter, loc, localStatementCtx,
|
||||||
std::get<Fortran::parser::ScalarDefaultCharExpr>(spec.t),
|
std::get<Fortran::parser::ScalarDefaultCharExpr>(spec.t),
|
||||||
|
@ -1203,7 +1203,7 @@ genConditionHandlerCall(Fortran::lower::AbstractConverter &converter,
|
||||||
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
||||||
mlir::FuncOp enableHandlers =
|
mlir::FuncOp enableHandlers =
|
||||||
getIORuntimeFunc<mkIOKey(EnableHandlers)>(loc, builder);
|
getIORuntimeFunc<mkIOKey(EnableHandlers)>(loc, builder);
|
||||||
mlir::Type boolType = enableHandlers.getType().getInput(1);
|
mlir::Type boolType = enableHandlers.getFunctionType().getInput(1);
|
||||||
auto boolValue = [&](bool specifierIsPresent) {
|
auto boolValue = [&](bool specifierIsPresent) {
|
||||||
return builder.create<mlir::arith::ConstantOp>(
|
return builder.create<mlir::arith::ConstantOp>(
|
||||||
loc, builder.getIntegerAttr(boolType, specifierIsPresent));
|
loc, builder.getIntegerAttr(boolType, specifierIsPresent));
|
||||||
|
@ -1558,7 +1558,7 @@ static mlir::Value genBasicIOStmt(Fortran::lower::AbstractConverter &converter,
|
||||||
Fortran::lower::StatementContext stmtCtx;
|
Fortran::lower::StatementContext stmtCtx;
|
||||||
mlir::Location loc = converter.getCurrentLocation();
|
mlir::Location loc = converter.getCurrentLocation();
|
||||||
mlir::FuncOp beginFunc = getIORuntimeFunc<K>(loc, builder);
|
mlir::FuncOp beginFunc = getIORuntimeFunc<K>(loc, builder);
|
||||||
mlir::FunctionType beginFuncTy = beginFunc.getType();
|
mlir::FunctionType beginFuncTy = beginFunc.getFunctionType();
|
||||||
mlir::Value unit = fir::getBase(converter.genExprValue(
|
mlir::Value unit = fir::getBase(converter.genExprValue(
|
||||||
getExpr<Fortran::parser::FileUnitNumber>(stmt), stmtCtx, loc));
|
getExpr<Fortran::parser::FileUnitNumber>(stmt), stmtCtx, loc));
|
||||||
mlir::Value un = builder.createConvert(loc, beginFuncTy.getInput(0), unit);
|
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;
|
Fortran::lower::StatementContext stmtCtx;
|
||||||
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
||||||
mlir::FuncOp ioFunc = getIORuntimeFunc<mkIOKey(GetNewUnit)>(loc, builder);
|
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);
|
const auto *var = Fortran::semantics::GetExpr(newunit->v);
|
||||||
mlir::Value addr = builder.createConvert(
|
mlir::Value addr = builder.createConvert(
|
||||||
loc, ioFuncTy.getInput(1),
|
loc, ioFuncTy.getInput(1),
|
||||||
|
@ -1635,7 +1635,7 @@ Fortran::lower::genOpenStatement(Fortran::lower::AbstractConverter &converter,
|
||||||
bool hasNewunitSpec = false;
|
bool hasNewunitSpec = false;
|
||||||
if (hasSpec<Fortran::parser::FileUnitNumber>(stmt)) {
|
if (hasSpec<Fortran::parser::FileUnitNumber>(stmt)) {
|
||||||
beginFunc = getIORuntimeFunc<mkIOKey(BeginOpenUnit)>(loc, builder);
|
beginFunc = getIORuntimeFunc<mkIOKey(BeginOpenUnit)>(loc, builder);
|
||||||
mlir::FunctionType beginFuncTy = beginFunc.getType();
|
mlir::FunctionType beginFuncTy = beginFunc.getFunctionType();
|
||||||
mlir::Value unit = fir::getBase(converter.genExprValue(
|
mlir::Value unit = fir::getBase(converter.genExprValue(
|
||||||
getExpr<Fortran::parser::FileUnitNumber>(stmt), stmtCtx, loc));
|
getExpr<Fortran::parser::FileUnitNumber>(stmt), stmtCtx, loc));
|
||||||
beginArgs.push_back(
|
beginArgs.push_back(
|
||||||
|
@ -1646,7 +1646,7 @@ Fortran::lower::genOpenStatement(Fortran::lower::AbstractConverter &converter,
|
||||||
hasNewunitSpec = hasSpec<Fortran::parser::ConnectSpec::Newunit>(stmt);
|
hasNewunitSpec = hasSpec<Fortran::parser::ConnectSpec::Newunit>(stmt);
|
||||||
assert(hasNewunitSpec && "missing unit specifier");
|
assert(hasNewunitSpec && "missing unit specifier");
|
||||||
beginFunc = getIORuntimeFunc<mkIOKey(BeginOpenNewUnit)>(loc, builder);
|
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(locToFilename(converter, loc, beginFuncTy.getInput(0)));
|
||||||
beginArgs.push_back(locToLineNo(converter, loc, beginFuncTy.getInput(1)));
|
beginArgs.push_back(locToLineNo(converter, loc, beginFuncTy.getInput(1)));
|
||||||
}
|
}
|
||||||
|
@ -1679,7 +1679,7 @@ Fortran::lower::genWaitStatement(Fortran::lower::AbstractConverter &converter,
|
||||||
mlir::FuncOp beginFunc =
|
mlir::FuncOp beginFunc =
|
||||||
hasId ? getIORuntimeFunc<mkIOKey(BeginWait)>(loc, builder)
|
hasId ? getIORuntimeFunc<mkIOKey(BeginWait)>(loc, builder)
|
||||||
: getIORuntimeFunc<mkIOKey(BeginWaitAll)>(loc, builder);
|
: getIORuntimeFunc<mkIOKey(BeginWaitAll)>(loc, builder);
|
||||||
mlir::FunctionType beginFuncTy = beginFunc.getType();
|
mlir::FunctionType beginFuncTy = beginFunc.getFunctionType();
|
||||||
mlir::Value unit = fir::getBase(converter.genExprValue(
|
mlir::Value unit = fir::getBase(converter.genExprValue(
|
||||||
getExpr<Fortran::parser::FileUnitNumber>(stmt), stmtCtx, loc));
|
getExpr<Fortran::parser::FileUnitNumber>(stmt), stmtCtx, loc));
|
||||||
mlir::Value un = builder.createConvert(loc, beginFuncTy.getInput(0), unit);
|
mlir::Value un = builder.createConvert(loc, beginFuncTy.getInput(0), unit);
|
||||||
|
@ -1849,7 +1849,7 @@ genDataTransferStmt(Fortran::lower::AbstractConverter &converter,
|
||||||
isInternalWithDesc, isAsync);
|
isInternalWithDesc, isAsync);
|
||||||
llvm::SmallVector<mlir::Value> ioArgs;
|
llvm::SmallVector<mlir::Value> ioArgs;
|
||||||
genBeginDataTransferCallArgs<hasIOCtrl>(
|
genBeginDataTransferCallArgs<hasIOCtrl>(
|
||||||
ioArgs, converter, loc, stmt, ioFunc.getType(), isFormatted,
|
ioArgs, converter, loc, stmt, ioFunc.getFunctionType(), isFormatted,
|
||||||
isList || isNml, isInternal, isAsync, descRef, stmtCtx);
|
isList || isNml, isInternal, isAsync, descRef, stmtCtx);
|
||||||
mlir::Value cookie =
|
mlir::Value cookie =
|
||||||
builder.create<fir::CallOp>(loc, ioFunc, ioArgs).getResult(0);
|
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();
|
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
||||||
mlir::FuncOp specFunc =
|
mlir::FuncOp specFunc =
|
||||||
getIORuntimeFunc<mkIOKey(InquireCharacter)>(loc, builder);
|
getIORuntimeFunc<mkIOKey(InquireCharacter)>(loc, builder);
|
||||||
mlir::FunctionType specFuncTy = specFunc.getType();
|
mlir::FunctionType specFuncTy = specFunc.getFunctionType();
|
||||||
const auto *varExpr = Fortran::semantics::GetExpr(
|
const auto *varExpr = Fortran::semantics::GetExpr(
|
||||||
std::get<Fortran::parser::ScalarDefaultCharVariable>(var.t));
|
std::get<Fortran::parser::ScalarDefaultCharVariable>(var.t));
|
||||||
fir::ExtendedValue str = converter.genExprAddr(varExpr, stmtCtx, loc);
|
fir::ExtendedValue str = converter.genExprAddr(varExpr, stmtCtx, loc);
|
||||||
|
@ -1992,7 +1992,7 @@ mlir::Value genInquireSpec<Fortran::parser::InquireSpec::IntVar>(
|
||||||
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
||||||
mlir::FuncOp specFunc =
|
mlir::FuncOp specFunc =
|
||||||
getIORuntimeFunc<mkIOKey(InquireInteger64)>(loc, builder);
|
getIORuntimeFunc<mkIOKey(InquireInteger64)>(loc, builder);
|
||||||
mlir::FunctionType specFuncTy = specFunc.getType();
|
mlir::FunctionType specFuncTy = specFunc.getFunctionType();
|
||||||
const auto *varExpr = Fortran::semantics::GetExpr(
|
const auto *varExpr = Fortran::semantics::GetExpr(
|
||||||
std::get<Fortran::parser::ScalarIntVariable>(var.t));
|
std::get<Fortran::parser::ScalarIntVariable>(var.t));
|
||||||
mlir::Value addr = fir::getBase(converter.genExprAddr(varExpr, stmtCtx, loc));
|
mlir::Value addr = fir::getBase(converter.genExprAddr(varExpr, stmtCtx, loc));
|
||||||
|
@ -2030,7 +2030,7 @@ mlir::Value genInquireSpec<Fortran::parser::InquireSpec::LogVar>(
|
||||||
mlir::FuncOp specFunc =
|
mlir::FuncOp specFunc =
|
||||||
pendId ? getIORuntimeFunc<mkIOKey(InquirePendingId)>(loc, builder)
|
pendId ? getIORuntimeFunc<mkIOKey(InquirePendingId)>(loc, builder)
|
||||||
: getIORuntimeFunc<mkIOKey(InquireLogical)>(loc, builder);
|
: getIORuntimeFunc<mkIOKey(InquireLogical)>(loc, builder);
|
||||||
mlir::FunctionType specFuncTy = specFunc.getType();
|
mlir::FunctionType specFuncTy = specFunc.getFunctionType();
|
||||||
mlir::Value addr = fir::getBase(converter.genExprAddr(
|
mlir::Value addr = fir::getBase(converter.genExprAddr(
|
||||||
Fortran::semantics::GetExpr(
|
Fortran::semantics::GetExpr(
|
||||||
std::get<Fortran::parser::Scalar<
|
std::get<Fortran::parser::Scalar<
|
||||||
|
@ -2112,7 +2112,7 @@ mlir::Value Fortran::lower::genInquireStatement(
|
||||||
if (inquireFileUnit()) {
|
if (inquireFileUnit()) {
|
||||||
// Inquire by unit -- [UNIT=]file-unit-number.
|
// Inquire by unit -- [UNIT=]file-unit-number.
|
||||||
beginFunc = getIORuntimeFunc<mkIOKey(BeginInquireUnit)>(loc, builder);
|
beginFunc = getIORuntimeFunc<mkIOKey(BeginInquireUnit)>(loc, builder);
|
||||||
mlir::FunctionType beginFuncTy = beginFunc.getType();
|
mlir::FunctionType beginFuncTy = beginFunc.getFunctionType();
|
||||||
beginArgs = {builder.createConvert(loc, beginFuncTy.getInput(0),
|
beginArgs = {builder.createConvert(loc, beginFuncTy.getInput(0),
|
||||||
fir::getBase(converter.genExprValue(
|
fir::getBase(converter.genExprValue(
|
||||||
exprPair.first, stmtCtx, loc))),
|
exprPair.first, stmtCtx, loc))),
|
||||||
|
@ -2121,7 +2121,7 @@ mlir::Value Fortran::lower::genInquireStatement(
|
||||||
} else if (inquireFileName()) {
|
} else if (inquireFileName()) {
|
||||||
// Inquire by file -- FILE=file-name-expr.
|
// Inquire by file -- FILE=file-name-expr.
|
||||||
beginFunc = getIORuntimeFunc<mkIOKey(BeginInquireFile)>(loc, builder);
|
beginFunc = getIORuntimeFunc<mkIOKey(BeginInquireFile)>(loc, builder);
|
||||||
mlir::FunctionType beginFuncTy = beginFunc.getType();
|
mlir::FunctionType beginFuncTy = beginFunc.getFunctionType();
|
||||||
fir::ExtendedValue file =
|
fir::ExtendedValue file =
|
||||||
converter.genExprAddr(exprPair.first, stmtCtx, loc);
|
converter.genExprAddr(exprPair.first, stmtCtx, loc);
|
||||||
beginArgs = {
|
beginArgs = {
|
||||||
|
@ -2135,7 +2135,7 @@ mlir::Value Fortran::lower::genInquireStatement(
|
||||||
std::get_if<Fortran::parser::InquireStmt::Iolength>(&stmt.u);
|
std::get_if<Fortran::parser::InquireStmt::Iolength>(&stmt.u);
|
||||||
assert(ioLength && "must have an IOLENGTH specifier");
|
assert(ioLength && "must have an IOLENGTH specifier");
|
||||||
beginFunc = getIORuntimeFunc<mkIOKey(BeginInquireIoLength)>(loc, builder);
|
beginFunc = getIORuntimeFunc<mkIOKey(BeginInquireIoLength)>(loc, builder);
|
||||||
mlir::FunctionType beginFuncTy = beginFunc.getType();
|
mlir::FunctionType beginFuncTy = beginFunc.getFunctionType();
|
||||||
beginArgs = {locToFilename(converter, loc, beginFuncTy.getInput(0)),
|
beginArgs = {locToFilename(converter, loc, beginFuncTy.getInput(0)),
|
||||||
locToLineNo(converter, loc, beginFuncTy.getInput(1))};
|
locToLineNo(converter, loc, beginFuncTy.getInput(1))};
|
||||||
auto cookie =
|
auto cookie =
|
||||||
|
|
|
@ -1390,7 +1390,7 @@ mlir::FuncOp IntrinsicLibrary::getWrapper(GeneratorType generator,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Wrapper was already built, ensure it has the sought type
|
// Wrapper was already built, ensure it has the sought type
|
||||||
assert(function.getType() == funcType &&
|
assert(function.getFunctionType() == funcType &&
|
||||||
"conflict between intrinsic wrapper types");
|
"conflict between intrinsic wrapper types");
|
||||||
}
|
}
|
||||||
return function;
|
return function;
|
||||||
|
@ -1435,7 +1435,7 @@ IntrinsicLibrary::getRuntimeCallGenerator(llvm::StringRef name,
|
||||||
fir::emitFatalError(loc, buffer);
|
fir::emitFatalError(loc, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
mlir::FunctionType actualFuncType = funcOp.getType();
|
mlir::FunctionType actualFuncType = funcOp.getFunctionType();
|
||||||
assert(actualFuncType.getNumResults() == soughtFuncType.getNumResults() &&
|
assert(actualFuncType.getNumResults() == soughtFuncType.getNumResults() &&
|
||||||
actualFuncType.getNumInputs() == soughtFuncType.getNumInputs() &&
|
actualFuncType.getNumInputs() == soughtFuncType.getNumInputs() &&
|
||||||
actualFuncType.getNumResults() == 1 && "Bad intrinsic match");
|
actualFuncType.getNumResults() == 1 && "Bad intrinsic match");
|
||||||
|
|
|
@ -58,7 +58,7 @@ void Fortran::lower::genStopStatement(
|
||||||
[&](const fir::CharBoxValue &x) {
|
[&](const fir::CharBoxValue &x) {
|
||||||
callee = fir::runtime::getRuntimeFunc<mkRTKey(StopStatementText)>(
|
callee = fir::runtime::getRuntimeFunc<mkRTKey(StopStatementText)>(
|
||||||
loc, builder);
|
loc, builder);
|
||||||
calleeType = callee.getType();
|
calleeType = callee.getFunctionType();
|
||||||
// Creates a pair of operands for the CHARACTER and its LEN.
|
// Creates a pair of operands for the CHARACTER and its LEN.
|
||||||
operands.push_back(
|
operands.push_back(
|
||||||
builder.createConvert(loc, calleeType.getInput(0), x.getAddr()));
|
builder.createConvert(loc, calleeType.getInput(0), x.getAddr()));
|
||||||
|
@ -68,7 +68,7 @@ void Fortran::lower::genStopStatement(
|
||||||
[&](fir::UnboxedValue x) {
|
[&](fir::UnboxedValue x) {
|
||||||
callee = fir::runtime::getRuntimeFunc<mkRTKey(StopStatement)>(
|
callee = fir::runtime::getRuntimeFunc<mkRTKey(StopStatement)>(
|
||||||
loc, builder);
|
loc, builder);
|
||||||
calleeType = callee.getType();
|
calleeType = callee.getFunctionType();
|
||||||
mlir::Value cast =
|
mlir::Value cast =
|
||||||
builder.createConvert(loc, calleeType.getInput(0), x);
|
builder.createConvert(loc, calleeType.getInput(0), x);
|
||||||
operands.push_back(cast);
|
operands.push_back(cast);
|
||||||
|
@ -79,7 +79,7 @@ void Fortran::lower::genStopStatement(
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
callee = fir::runtime::getRuntimeFunc<mkRTKey(StopStatement)>(loc, builder);
|
callee = fir::runtime::getRuntimeFunc<mkRTKey(StopStatement)>(loc, builder);
|
||||||
calleeType = callee.getType();
|
calleeType = callee.getFunctionType();
|
||||||
operands.push_back(
|
operands.push_back(
|
||||||
builder.createIntegerConstant(loc, calleeType.getInput(0), 0));
|
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,
|
fir::runtime::getRuntimeFunc<mkRTKey(PointerIsAssociatedWith)>(loc,
|
||||||
builder);
|
builder);
|
||||||
llvm::SmallVector<mlir::Value> args = fir::runtime::createArguments(
|
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);
|
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::Value values) {
|
||||||
mlir::FuncOp callee =
|
mlir::FuncOp callee =
|
||||||
fir::runtime::getRuntimeFunc<mkRTKey(DateAndTime)>(loc, builder);
|
fir::runtime::getRuntimeFunc<mkRTKey(DateAndTime)>(loc, builder);
|
||||||
mlir::FunctionType funcTy = callee.getType();
|
mlir::FunctionType funcTy = callee.getFunctionType();
|
||||||
mlir::Type idxTy = builder.getIndexType();
|
mlir::Type idxTy = builder.getIndexType();
|
||||||
mlir::Value zero;
|
mlir::Value zero;
|
||||||
auto splitArg = [&](llvm::Optional<fir::CharBoxValue> arg,
|
auto splitArg = [&](llvm::Optional<fir::CharBoxValue> arg,
|
||||||
|
@ -185,7 +185,7 @@ void Fortran::lower::genRandomInit(fir::FirOpBuilder &builder,
|
||||||
mlir::FuncOp func =
|
mlir::FuncOp func =
|
||||||
fir::runtime::getRuntimeFunc<mkRTKey(RandomInit)>(loc, builder);
|
fir::runtime::getRuntimeFunc<mkRTKey(RandomInit)>(loc, builder);
|
||||||
llvm::SmallVector<mlir::Value> args = fir::runtime::createArguments(
|
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);
|
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::Location loc, mlir::Value harvest) {
|
||||||
mlir::FuncOp func =
|
mlir::FuncOp func =
|
||||||
fir::runtime::getRuntimeFunc<mkRTKey(RandomNumber)>(loc, builder);
|
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 sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
mlir::Value sourceLine =
|
mlir::Value sourceLine =
|
||||||
fir::factory::locationToLineNo(builder, loc, funcTy.getInput(2));
|
fir::factory::locationToLineNo(builder, loc, funcTy.getInput(2));
|
||||||
|
@ -226,7 +226,7 @@ void Fortran::lower::genRandomSeed(fir::FirOpBuilder &builder,
|
||||||
default:
|
default:
|
||||||
llvm::report_fatal_error("invalid RANDOM_SEED argument index");
|
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 sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
mlir::Value sourceLine =
|
mlir::Value sourceLine =
|
||||||
fir::factory::locationToLineNo(builder, loc, funcTy.getInput(2));
|
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 =
|
mlir::FuncOp func =
|
||||||
fir::runtime::getRuntimeFunc<mkRTKey(Transfer)>(loc, builder);
|
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 sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
mlir::Value sourceLine =
|
mlir::Value sourceLine =
|
||||||
fir::factory::locationToLineNo(builder, loc, fTy.getInput(4));
|
fir::factory::locationToLineNo(builder, loc, fTy.getInput(4));
|
||||||
|
@ -258,7 +258,7 @@ void Fortran::lower::genTransferSize(fir::FirOpBuilder &builder,
|
||||||
mlir::Value size) {
|
mlir::Value size) {
|
||||||
mlir::FuncOp func =
|
mlir::FuncOp func =
|
||||||
fir::runtime::getRuntimeFunc<mkRTKey(TransferSize)>(loc, builder);
|
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 sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
mlir::Value sourceLine =
|
mlir::Value sourceLine =
|
||||||
fir::factory::locationToLineNo(builder, loc, fTy.getInput(4));
|
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::Location loc, mlir::Value count,
|
||||||
mlir::Value rate, mlir::Value max) {
|
mlir::Value rate, mlir::Value max) {
|
||||||
auto makeCall = [&](mlir::FuncOp func, mlir::Value arg) {
|
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;
|
int integerKind = 8;
|
||||||
if (auto intType =
|
if (auto intType =
|
||||||
fir::unwrapRefType(arg.getType()).dyn_cast<mlir::IntegerType>())
|
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 totalBytes = builder.create<arith::MulIOp>(loc, kindBytes, castCount);
|
||||||
auto notVolatile = builder.createBool(loc, false);
|
auto notVolatile = builder.createBool(loc, false);
|
||||||
auto memmv = getLlvmMemmove(builder);
|
auto memmv = getLlvmMemmove(builder);
|
||||||
auto argTys = memmv.getType().getInputs();
|
auto argTys = memmv.getFunctionType().getInputs();
|
||||||
auto toPtr = builder.createConvert(loc, argTys[0], toBuff);
|
auto toPtr = builder.createConvert(loc, argTys[0], toBuff);
|
||||||
auto fromPtr = builder.createConvert(loc, argTys[1], fromBuff);
|
auto fromPtr = builder.createConvert(loc, argTys[1], fromBuff);
|
||||||
builder.create<fir::CallOp>(
|
builder.create<fir::CallOp>(
|
||||||
|
|
|
@ -16,7 +16,7 @@ using namespace Fortran::runtime;
|
||||||
void fir::runtime::genAssign(fir::FirOpBuilder &builder, mlir::Location loc,
|
void fir::runtime::genAssign(fir::FirOpBuilder &builder, mlir::Location loc,
|
||||||
mlir::Value destBox, mlir::Value sourceBox) {
|
mlir::Value destBox, mlir::Value sourceBox) {
|
||||||
auto func = fir::runtime::getRuntimeFunc<mkRTKey(Assign)>(loc, builder);
|
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 sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
auto sourceLine =
|
auto sourceLine =
|
||||||
fir::factory::locationToLineNo(builder, loc, fTy.getInput(3));
|
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 string1Box, mlir::Value string2Box,
|
||||||
mlir::Value backBox, mlir::Value kind) {
|
mlir::Value backBox, mlir::Value kind) {
|
||||||
|
|
||||||
auto fTy = func.getType();
|
auto fTy = func.getFunctionType();
|
||||||
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
auto sourceLine =
|
auto sourceLine =
|
||||||
fir::factory::locationToLineNo(builder, loc, fTy.getInput(6));
|
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::Value resultBox, mlir::Value stringBox,
|
||||||
mlir::FuncOp &adjustFunc) {
|
mlir::FuncOp &adjustFunc) {
|
||||||
|
|
||||||
auto fTy = adjustFunc.getType();
|
auto fTy = adjustFunc.getFunctionType();
|
||||||
auto sourceLine =
|
auto sourceLine =
|
||||||
fir::factory::locationToLineNo(builder, loc, fTy.getInput(3));
|
fir::factory::locationToLineNo(builder, loc, fTy.getInput(3));
|
||||||
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
|
@ -111,7 +111,7 @@ fir::runtime::genCharCompare(fir::FirOpBuilder &builder, mlir::Location loc,
|
||||||
default:
|
default:
|
||||||
llvm_unreachable("runtime does not support CHARACTER KIND");
|
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,
|
auto args = fir::runtime::createArguments(builder, loc, fTy, lhsBuff, rhsBuff,
|
||||||
lhsLen, rhsLen);
|
lhsLen, rhsLen);
|
||||||
auto tri = builder.create<fir::CallOp>(loc, beginFunc, args).getResult(0);
|
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(
|
fir::emitFatalError(
|
||||||
loc, "unsupported CHARACTER kind value. Runtime expects 1, 2, or 4.");
|
loc, "unsupported CHARACTER kind value. Runtime expects 1, 2, or 4.");
|
||||||
}
|
}
|
||||||
auto fTy = indexFunc.getType();
|
auto fTy = indexFunc.getFunctionType();
|
||||||
auto args =
|
auto args =
|
||||||
fir::runtime::createArguments(builder, loc, fTy, stringBase, stringLen,
|
fir::runtime::createArguments(builder, loc, fTy, stringBase, stringLen,
|
||||||
substringBase, substringLen, back);
|
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 resultBox, mlir::Value stringBox,
|
||||||
mlir::Value ncopies) {
|
mlir::Value ncopies) {
|
||||||
auto repeatFunc = fir::runtime::getRuntimeFunc<mkRTKey(Repeat)>(loc, builder);
|
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 sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
auto sourceLine =
|
auto sourceLine =
|
||||||
fir::factory::locationToLineNo(builder, loc, fTy.getInput(4));
|
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,
|
void fir::runtime::genTrim(fir::FirOpBuilder &builder, mlir::Location loc,
|
||||||
mlir::Value resultBox, mlir::Value stringBox) {
|
mlir::Value resultBox, mlir::Value stringBox) {
|
||||||
auto trimFunc = fir::runtime::getRuntimeFunc<mkRTKey(Trim)>(loc, builder);
|
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 sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
auto sourceLine =
|
auto sourceLine =
|
||||||
fir::factory::locationToLineNo(builder, loc, fTy.getInput(3));
|
fir::factory::locationToLineNo(builder, loc, fTy.getInput(3));
|
||||||
|
@ -234,7 +234,7 @@ mlir::Value fir::runtime::genScan(fir::FirOpBuilder &builder,
|
||||||
fir::emitFatalError(
|
fir::emitFatalError(
|
||||||
loc, "unsupported CHARACTER kind value. Runtime expects 1, 2, or 4.");
|
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,
|
auto args = fir::runtime::createArguments(builder, loc, fTy, stringBase,
|
||||||
stringLen, setBase, setLen, back);
|
stringLen, setBase, setLen, back);
|
||||||
return builder.create<fir::CallOp>(loc, func, args).getResult(0);
|
return builder.create<fir::CallOp>(loc, func, args).getResult(0);
|
||||||
|
@ -271,7 +271,7 @@ mlir::Value fir::runtime::genVerify(fir::FirOpBuilder &builder,
|
||||||
fir::emitFatalError(
|
fir::emitFatalError(
|
||||||
loc, "unsupported CHARACTER kind value. Runtime expects 1, 2, or 4.");
|
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,
|
auto args = fir::runtime::createArguments(builder, loc, fTy, stringBase,
|
||||||
stringLen, setBase, setLen, back);
|
stringLen, setBase, setLen, back);
|
||||||
return builder.create<fir::CallOp>(loc, func, args).getResult(0);
|
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.
|
// "STATUS" or "ERRMSG" parameters.
|
||||||
if (!isAbsent(value) || status || !isAbsent(errmsg)) {
|
if (!isAbsent(value) || status || !isAbsent(errmsg)) {
|
||||||
llvm::SmallVector<mlir::Value> args = fir::runtime::createArguments(
|
llvm::SmallVector<mlir::Value> args = fir::runtime::createArguments(
|
||||||
builder, loc, argumentValueFunc.getType(), number, value, errmsg);
|
builder, loc, argumentValueFunc.getFunctionType(), number, value,
|
||||||
|
errmsg);
|
||||||
valueResult =
|
valueResult =
|
||||||
builder.create<fir::CallOp>(loc, argumentValueFunc, args).getResult(0);
|
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
|
// Only run `ArgumentLength` intrinsic if "LENGTH" parameter provided
|
||||||
if (length) {
|
if (length) {
|
||||||
llvm::SmallVector<mlir::Value> args = fir::runtime::createArguments(
|
llvm::SmallVector<mlir::Value> args = fir::runtime::createArguments(
|
||||||
builder, loc, argumentLengthFunc.getType(), number);
|
builder, loc, argumentLengthFunc.getFunctionType(), number);
|
||||||
mlir::Value result =
|
mlir::Value result =
|
||||||
builder.create<fir::CallOp>(loc, argumentLengthFunc, args).getResult(0);
|
builder.create<fir::CallOp>(loc, argumentLengthFunc, args).getResult(0);
|
||||||
const mlir::Value valueLoaded = builder.create<fir::LoadOp>(loc, length);
|
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) {
|
if (!isAbsent(value) || status || !isAbsent(errmsg) || length) {
|
||||||
sourceFile = fir::factory::locationToFilename(builder, loc);
|
sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
sourceLine = fir::factory::locationToLineNo(
|
sourceLine = fir::factory::locationToLineNo(
|
||||||
builder, loc, valueFunc.getType().getInput(5));
|
builder, loc, valueFunc.getFunctionType().getInput(5));
|
||||||
}
|
}
|
||||||
|
|
||||||
mlir::Value valueResult;
|
mlir::Value valueResult;
|
||||||
|
@ -97,8 +98,8 @@ void fir::runtime::genGetEnvironmentVariable(
|
||||||
// "VALUE", "STATUS" or "ERRMSG" parameters.
|
// "VALUE", "STATUS" or "ERRMSG" parameters.
|
||||||
if (!isAbsent(value) || status || !isAbsent(errmsg)) {
|
if (!isAbsent(value) || status || !isAbsent(errmsg)) {
|
||||||
llvm::SmallVector<mlir::Value> args = fir::runtime::createArguments(
|
llvm::SmallVector<mlir::Value> args = fir::runtime::createArguments(
|
||||||
builder, loc, valueFunc.getType(), name, value, trimName, errmsg,
|
builder, loc, valueFunc.getFunctionType(), name, value, trimName,
|
||||||
sourceFile, sourceLine);
|
errmsg, sourceFile, sourceLine);
|
||||||
valueResult =
|
valueResult =
|
||||||
builder.create<fir::CallOp>(loc, valueFunc, args).getResult(0);
|
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
|
// Only run `EnvVariableLength` intrinsic if "LENGTH" parameter provided
|
||||||
if (length) {
|
if (length) {
|
||||||
llvm::SmallVector<mlir::Value> args =
|
llvm::SmallVector<mlir::Value> args = fir::runtime::createArguments(
|
||||||
fir::runtime::createArguments(builder, loc, lengthFunc.getType(), name,
|
builder, loc, lengthFunc.getFunctionType(), name, trimName, sourceFile,
|
||||||
trimName, sourceFile, sourceLine);
|
sourceLine);
|
||||||
mlir::Value result =
|
mlir::Value result =
|
||||||
builder.create<fir::CallOp>(loc, lengthFunc, args).getResult(0);
|
builder.create<fir::CallOp>(loc, lengthFunc, args).getResult(0);
|
||||||
const mlir::Value lengthLoaded = builder.create<fir::LoadOp>(loc, length);
|
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::Location loc,
|
||||||
mlir::Value box) {
|
mlir::Value box) {
|
||||||
auto func = fir::runtime::getRuntimeFunc<mkRTKey(Initialize)>(loc, builder);
|
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 sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
auto sourceLine =
|
auto sourceLine =
|
||||||
fir::factory::locationToLineNo(builder, loc, fTy.getInput(2));
|
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,
|
void fir::runtime::genDerivedTypeDestroy(fir::FirOpBuilder &builder,
|
||||||
mlir::Location loc, mlir::Value box) {
|
mlir::Location loc, mlir::Value box) {
|
||||||
auto func = fir::runtime::getRuntimeFunc<mkRTKey(Destroy)>(loc, builder);
|
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);
|
auto args = fir::runtime::createArguments(builder, loc, fTy, box);
|
||||||
builder.create<fir::CallOp>(loc, func, args);
|
builder.create<fir::CallOp>(loc, func, args);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ mlir::Value fir::runtime::genLboundDim(fir::FirOpBuilder &builder,
|
||||||
mlir::Value dim) {
|
mlir::Value dim) {
|
||||||
mlir::FuncOp lboundFunc =
|
mlir::FuncOp lboundFunc =
|
||||||
fir::runtime::getRuntimeFunc<mkRTKey(LboundDim)>(loc, builder);
|
fir::runtime::getRuntimeFunc<mkRTKey(LboundDim)>(loc, builder);
|
||||||
auto fTy = lboundFunc.getType();
|
auto fTy = lboundFunc.getFunctionType();
|
||||||
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
auto sourceLine =
|
auto sourceLine =
|
||||||
fir::factory::locationToLineNo(builder, loc, fTy.getInput(3));
|
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::Value kind) {
|
||||||
mlir::FuncOp uboundFunc =
|
mlir::FuncOp uboundFunc =
|
||||||
fir::runtime::getRuntimeFunc<mkRTKey(Ubound)>(loc, builder);
|
fir::runtime::getRuntimeFunc<mkRTKey(Ubound)>(loc, builder);
|
||||||
auto fTy = uboundFunc.getType();
|
auto fTy = uboundFunc.getFunctionType();
|
||||||
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
auto sourceLine =
|
auto sourceLine =
|
||||||
fir::factory::locationToLineNo(builder, loc, fTy.getInput(2));
|
fir::factory::locationToLineNo(builder, loc, fTy.getInput(2));
|
||||||
|
@ -52,7 +52,7 @@ mlir::Value fir::runtime::genSizeDim(fir::FirOpBuilder &builder,
|
||||||
mlir::Value dim) {
|
mlir::Value dim) {
|
||||||
mlir::FuncOp sizeFunc =
|
mlir::FuncOp sizeFunc =
|
||||||
fir::runtime::getRuntimeFunc<mkRTKey(SizeDim)>(loc, builder);
|
fir::runtime::getRuntimeFunc<mkRTKey(SizeDim)>(loc, builder);
|
||||||
auto fTy = sizeFunc.getType();
|
auto fTy = sizeFunc.getFunctionType();
|
||||||
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
auto sourceLine =
|
auto sourceLine =
|
||||||
fir::factory::locationToLineNo(builder, loc, fTy.getInput(3));
|
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::Location loc, mlir::Value array) {
|
||||||
mlir::FuncOp sizeFunc =
|
mlir::FuncOp sizeFunc =
|
||||||
fir::runtime::getRuntimeFunc<mkRTKey(Size)>(loc, builder);
|
fir::runtime::getRuntimeFunc<mkRTKey(Size)>(loc, builder);
|
||||||
auto fTy = sizeFunc.getType();
|
auto fTy = sizeFunc.getFunctionType();
|
||||||
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
auto sourceLine =
|
auto sourceLine =
|
||||||
fir::factory::locationToLineNo(builder, loc, fTy.getInput(2));
|
fir::factory::locationToLineNo(builder, loc, fTy.getInput(2));
|
||||||
|
|
|
@ -235,7 +235,7 @@ mlir::Value fir::runtime::genExponent(fir::FirOpBuilder &builder,
|
||||||
} else
|
} else
|
||||||
fir::emitFatalError(loc, "unsupported real kind in Exponent lowering");
|
fir::emitFatalError(loc, "unsupported real kind in Exponent lowering");
|
||||||
|
|
||||||
auto funcTy = func.getType();
|
auto funcTy = func.getFunctionType();
|
||||||
llvm::SmallVector<mlir::Value> args = {
|
llvm::SmallVector<mlir::Value> args = {
|
||||||
builder.createConvert(loc, funcTy.getInput(0), x)};
|
builder.createConvert(loc, funcTy.getInput(0), x)};
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@ mlir::Value fir::runtime::genFraction(fir::FirOpBuilder &builder,
|
||||||
else
|
else
|
||||||
fir::emitFatalError(loc, "unsupported real kind in Fraction lowering");
|
fir::emitFatalError(loc, "unsupported real kind in Fraction lowering");
|
||||||
|
|
||||||
auto funcTy = func.getType();
|
auto funcTy = func.getFunctionType();
|
||||||
llvm::SmallVector<mlir::Value> args = {
|
llvm::SmallVector<mlir::Value> args = {
|
||||||
builder.createConvert(loc, funcTy.getInput(0), x)};
|
builder.createConvert(loc, funcTy.getInput(0), x)};
|
||||||
|
|
||||||
|
@ -284,7 +284,7 @@ mlir::Value fir::runtime::genNearest(fir::FirOpBuilder &builder,
|
||||||
else
|
else
|
||||||
fir::emitFatalError(loc, "unsupported REAL kind in Nearest lowering");
|
fir::emitFatalError(loc, "unsupported REAL kind in Nearest lowering");
|
||||||
|
|
||||||
auto funcTy = func.getType();
|
auto funcTy = func.getFunctionType();
|
||||||
|
|
||||||
mlir::Type sTy = s.getType();
|
mlir::Type sTy = s.getType();
|
||||||
mlir::Value zero = builder.createRealZeroConstant(loc, sTy);
|
mlir::Value zero = builder.createRealZeroConstant(loc, sTy);
|
||||||
|
@ -319,7 +319,7 @@ mlir::Value fir::runtime::genRRSpacing(fir::FirOpBuilder &builder,
|
||||||
else
|
else
|
||||||
fir::emitFatalError(loc, "unsupported real kind in RRSpacing lowering");
|
fir::emitFatalError(loc, "unsupported real kind in RRSpacing lowering");
|
||||||
|
|
||||||
auto funcTy = func.getType();
|
auto funcTy = func.getFunctionType();
|
||||||
llvm::SmallVector<mlir::Value> args = {
|
llvm::SmallVector<mlir::Value> args = {
|
||||||
builder.createConvert(loc, funcTy.getInput(0), x)};
|
builder.createConvert(loc, funcTy.getInput(0), x)};
|
||||||
|
|
||||||
|
@ -344,7 +344,7 @@ mlir::Value fir::runtime::genScale(fir::FirOpBuilder &builder,
|
||||||
else
|
else
|
||||||
fir::emitFatalError(loc, "unsupported REAL kind in Scale lowering");
|
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);
|
auto args = fir::runtime::createArguments(builder, loc, funcTy, x, i);
|
||||||
|
|
||||||
return builder.create<fir::CallOp>(loc, func, args).getResult(0);
|
return builder.create<fir::CallOp>(loc, func, args).getResult(0);
|
||||||
|
@ -368,7 +368,7 @@ mlir::Value fir::runtime::genSetExponent(fir::FirOpBuilder &builder,
|
||||||
else
|
else
|
||||||
fir::emitFatalError(loc, "unsupported real kind in Fraction lowering");
|
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);
|
auto args = fir::runtime::createArguments(builder, loc, funcTy, x, i);
|
||||||
|
|
||||||
return builder.create<fir::CallOp>(loc, func, args).getResult(0);
|
return builder.create<fir::CallOp>(loc, func, args).getResult(0);
|
||||||
|
@ -391,7 +391,7 @@ mlir::Value fir::runtime::genSpacing(fir::FirOpBuilder &builder,
|
||||||
else
|
else
|
||||||
fir::emitFatalError(loc, "unsupported real kind in Spacing lowering");
|
fir::emitFatalError(loc, "unsupported real kind in Spacing lowering");
|
||||||
|
|
||||||
auto funcTy = func.getType();
|
auto funcTy = func.getFunctionType();
|
||||||
llvm::SmallVector<mlir::Value> args = {
|
llvm::SmallVector<mlir::Value> args = {
|
||||||
builder.createConvert(loc, funcTy.getInput(0), x)};
|
builder.createConvert(loc, funcTy.getInput(0), x)};
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ void fir::runtime::genRaggedArrayAllocate(mlir::Location loc,
|
||||||
auto i64Ty = builder.getIntegerType(64);
|
auto i64Ty = builder.getIntegerType(64);
|
||||||
auto func =
|
auto func =
|
||||||
fir::runtime::getRuntimeFunc<mkRTKey(RaggedArrayAllocate)>(loc, builder);
|
fir::runtime::getRuntimeFunc<mkRTKey(RaggedArrayAllocate)>(loc, builder);
|
||||||
auto fTy = func.getType();
|
auto fTy = func.getFunctionType();
|
||||||
auto i1Ty = builder.getIntegerType(1);
|
auto i1Ty = builder.getIntegerType(1);
|
||||||
fir::SequenceType::Shape shape = {
|
fir::SequenceType::Shape shape = {
|
||||||
static_cast<fir::SequenceType::Extent>(rank)};
|
static_cast<fir::SequenceType::Extent>(rank)};
|
||||||
|
@ -61,7 +61,7 @@ void fir::runtime::genRaggedArrayDeallocate(mlir::Location loc,
|
||||||
mlir::Value header) {
|
mlir::Value header) {
|
||||||
auto func = fir::runtime::getRuntimeFunc<mkRTKey(RaggedArrayDeallocate)>(
|
auto func = fir::runtime::getRuntimeFunc<mkRTKey(RaggedArrayDeallocate)>(
|
||||||
loc, builder);
|
loc, builder);
|
||||||
auto fTy = func.getType();
|
auto fTy = func.getFunctionType();
|
||||||
auto args = fir::runtime::createArguments(builder, loc, fTy, header);
|
auto args = fir::runtime::createArguments(builder, loc, fTy, header);
|
||||||
builder.create<fir::CallOp>(loc, func, args);
|
builder.create<fir::CallOp>(loc, func, args);
|
||||||
}
|
}
|
||||||
|
|
|
@ -374,7 +374,7 @@ template <typename FN>
|
||||||
mlir::Value genSpecial2Args(FN func, fir::FirOpBuilder &builder,
|
mlir::Value genSpecial2Args(FN func, fir::FirOpBuilder &builder,
|
||||||
mlir::Location loc, mlir::Value maskBox,
|
mlir::Location loc, mlir::Value maskBox,
|
||||||
mlir::Value dim) {
|
mlir::Value dim) {
|
||||||
auto fTy = func.getType();
|
auto fTy = func.getFunctionType();
|
||||||
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
auto sourceLine =
|
auto sourceLine =
|
||||||
fir::factory::locationToLineNo(builder, loc, fTy.getInput(2));
|
fir::factory::locationToLineNo(builder, loc, fTy.getInput(2));
|
||||||
|
@ -390,7 +390,7 @@ template <typename FN>
|
||||||
static void genReduction2Args(FN func, fir::FirOpBuilder &builder,
|
static void genReduction2Args(FN func, fir::FirOpBuilder &builder,
|
||||||
mlir::Location loc, mlir::Value resultBox,
|
mlir::Location loc, mlir::Value resultBox,
|
||||||
mlir::Value maskBox, mlir::Value dim) {
|
mlir::Value maskBox, mlir::Value dim) {
|
||||||
auto fTy = func.getType();
|
auto fTy = func.getFunctionType();
|
||||||
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
auto sourceLine =
|
auto sourceLine =
|
||||||
fir::factory::locationToLineNo(builder, loc, fTy.getInput(4));
|
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 arrayBox, mlir::Value dim,
|
||||||
mlir::Value maskBox) {
|
mlir::Value maskBox) {
|
||||||
|
|
||||||
auto fTy = func.getType();
|
auto fTy = func.getFunctionType();
|
||||||
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
auto sourceLine =
|
auto sourceLine =
|
||||||
fir::factory::locationToLineNo(builder, loc, fTy.getInput(4));
|
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::Location loc, mlir::Value resultBox,
|
||||||
mlir::Value arrayBox, mlir::Value maskBox,
|
mlir::Value arrayBox, mlir::Value maskBox,
|
||||||
mlir::Value kind, mlir::Value back) {
|
mlir::Value kind, mlir::Value back) {
|
||||||
auto fTy = func.getType();
|
auto fTy = func.getFunctionType();
|
||||||
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
auto sourceLine =
|
auto sourceLine =
|
||||||
fir::factory::locationToLineNo(builder, loc, fTy.getInput(4));
|
fir::factory::locationToLineNo(builder, loc, fTy.getInput(4));
|
||||||
|
@ -441,7 +441,7 @@ static void
|
||||||
genReduction5Args(FN func, fir::FirOpBuilder &builder, mlir::Location loc,
|
genReduction5Args(FN func, fir::FirOpBuilder &builder, mlir::Location loc,
|
||||||
mlir::Value resultBox, mlir::Value arrayBox, mlir::Value dim,
|
mlir::Value resultBox, mlir::Value arrayBox, mlir::Value dim,
|
||||||
mlir::Value maskBox, mlir::Value kind, mlir::Value back) {
|
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 sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
auto sourceLine =
|
auto sourceLine =
|
||||||
fir::factory::locationToLineNo(builder, loc, fTy.getInput(5));
|
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 resultBox, mlir::Value maskBox,
|
||||||
mlir::Value dim, mlir::Value kind) {
|
mlir::Value dim, mlir::Value kind) {
|
||||||
auto func = fir::runtime::getRuntimeFunc<mkRTKey(CountDim)>(loc, builder);
|
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 sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
auto sourceLine =
|
auto sourceLine =
|
||||||
fir::factory::locationToLineNo(builder, loc, fTy.getInput(5));
|
fir::factory::locationToLineNo(builder, loc, fTy.getInput(5));
|
||||||
|
@ -571,7 +571,7 @@ mlir::Value fir::runtime::genMaxval(fir::FirOpBuilder &builder,
|
||||||
else
|
else
|
||||||
fir::emitFatalError(loc, "invalid type in Maxval lowering");
|
fir::emitFatalError(loc, "invalid type in Maxval lowering");
|
||||||
|
|
||||||
auto fTy = func.getType();
|
auto fTy = func.getFunctionType();
|
||||||
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
auto sourceLine =
|
auto sourceLine =
|
||||||
fir::factory::locationToLineNo(builder, loc, fTy.getInput(2));
|
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) {
|
mlir::Value maskBox) {
|
||||||
auto func =
|
auto func =
|
||||||
fir::runtime::getRuntimeFunc<mkRTKey(MaxvalCharacter)>(loc, builder);
|
fir::runtime::getRuntimeFunc<mkRTKey(MaxvalCharacter)>(loc, builder);
|
||||||
auto fTy = func.getType();
|
auto fTy = func.getFunctionType();
|
||||||
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
auto sourceLine =
|
auto sourceLine =
|
||||||
fir::factory::locationToLineNo(builder, loc, fTy.getInput(3));
|
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) {
|
mlir::Value maskBox) {
|
||||||
auto func =
|
auto func =
|
||||||
fir::runtime::getRuntimeFunc<mkRTKey(MinvalCharacter)>(loc, builder);
|
fir::runtime::getRuntimeFunc<mkRTKey(MinvalCharacter)>(loc, builder);
|
||||||
auto fTy = func.getType();
|
auto fTy = func.getFunctionType();
|
||||||
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
auto sourceLine =
|
auto sourceLine =
|
||||||
fir::factory::locationToLineNo(builder, loc, fTy.getInput(3));
|
fir::factory::locationToLineNo(builder, loc, fTy.getInput(3));
|
||||||
|
@ -690,7 +690,7 @@ mlir::Value fir::runtime::genMinval(fir::FirOpBuilder &builder,
|
||||||
else
|
else
|
||||||
fir::emitFatalError(loc, "invalid type in Minval lowering");
|
fir::emitFatalError(loc, "invalid type in Minval lowering");
|
||||||
|
|
||||||
auto fTy = func.getType();
|
auto fTy = func.getFunctionType();
|
||||||
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
auto sourceLine =
|
auto sourceLine =
|
||||||
fir::factory::locationToLineNo(builder, loc, fTy.getInput(2));
|
fir::factory::locationToLineNo(builder, loc, fTy.getInput(2));
|
||||||
|
@ -757,7 +757,7 @@ mlir::Value fir::runtime::genProduct(fir::FirOpBuilder &builder,
|
||||||
else
|
else
|
||||||
fir::emitFatalError(loc, "invalid type in Product lowering");
|
fir::emitFatalError(loc, "invalid type in Product lowering");
|
||||||
|
|
||||||
auto fTy = func.getType();
|
auto fTy = func.getFunctionType();
|
||||||
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
if (fir::isa_complex(eleTy)) {
|
if (fir::isa_complex(eleTy)) {
|
||||||
auto sourceLine =
|
auto sourceLine =
|
||||||
|
@ -834,7 +834,7 @@ mlir::Value fir::runtime::genDotProduct(fir::FirOpBuilder &builder,
|
||||||
else
|
else
|
||||||
fir::emitFatalError(loc, "invalid type in DotProduct lowering");
|
fir::emitFatalError(loc, "invalid type in DotProduct lowering");
|
||||||
|
|
||||||
auto fTy = func.getType();
|
auto fTy = func.getFunctionType();
|
||||||
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
|
|
||||||
if (fir::isa_complex(eleTy)) {
|
if (fir::isa_complex(eleTy)) {
|
||||||
|
@ -907,7 +907,7 @@ mlir::Value fir::runtime::genSum(fir::FirOpBuilder &builder, mlir::Location loc,
|
||||||
else
|
else
|
||||||
fir::emitFatalError(loc, "invalid type in Sum lowering");
|
fir::emitFatalError(loc, "invalid type in Sum lowering");
|
||||||
|
|
||||||
auto fTy = func.getType();
|
auto fTy = func.getFunctionType();
|
||||||
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
if (fir::isa_complex(eleTy)) {
|
if (fir::isa_complex(eleTy)) {
|
||||||
auto sourceLine =
|
auto sourceLine =
|
||||||
|
|
|
@ -17,8 +17,8 @@ using namespace Fortran::runtime;
|
||||||
void fir::runtime::genExit(fir::FirOpBuilder &builder, mlir::Location loc,
|
void fir::runtime::genExit(fir::FirOpBuilder &builder, mlir::Location loc,
|
||||||
mlir::Value status) {
|
mlir::Value status) {
|
||||||
auto exitFunc = fir::runtime::getRuntimeFunc<mkRTKey(Exit)>(loc, builder);
|
auto exitFunc = fir::runtime::getRuntimeFunc<mkRTKey(Exit)>(loc, builder);
|
||||||
llvm::SmallVector<mlir::Value> args =
|
llvm::SmallVector<mlir::Value> args = fir::runtime::createArguments(
|
||||||
fir::runtime::createArguments(builder, loc, exitFunc.getType(), status);
|
builder, loc, exitFunc.getFunctionType(), status);
|
||||||
builder.create<fir::CallOp>(loc, exitFunc, args);
|
builder.create<fir::CallOp>(loc, exitFunc, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ void fir::runtime::genReportFatalUserError(fir::FirOpBuilder &builder,
|
||||||
llvm::StringRef message) {
|
llvm::StringRef message) {
|
||||||
mlir::FuncOp crashFunc =
|
mlir::FuncOp crashFunc =
|
||||||
fir::runtime::getRuntimeFunc<mkRTKey(ReportFatalUserError)>(loc, builder);
|
fir::runtime::getRuntimeFunc<mkRTKey(ReportFatalUserError)>(loc, builder);
|
||||||
mlir::FunctionType funcTy = crashFunc.getType();
|
mlir::FunctionType funcTy = crashFunc.getFunctionType();
|
||||||
mlir::Value msgVal = fir::getBase(
|
mlir::Value msgVal = fir::getBase(
|
||||||
fir::factory::createStringLiteral(builder, loc, message.str() + '\0'));
|
fir::factory::createStringLiteral(builder, loc, message.str() + '\0'));
|
||||||
mlir::Value sourceLine =
|
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 resultBox, mlir::Value arrayBox,
|
||||||
mlir::Value shiftBox, mlir::Value dimBox) {
|
mlir::Value shiftBox, mlir::Value dimBox) {
|
||||||
auto cshiftFunc = fir::runtime::getRuntimeFunc<mkRTKey(Cshift)>(loc, builder);
|
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 sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
auto sourceLine =
|
auto sourceLine =
|
||||||
fir::factory::locationToLineNo(builder, loc, fTy.getInput(5));
|
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) {
|
mlir::Value arrayBox, mlir::Value shiftBox) {
|
||||||
auto cshiftFunc =
|
auto cshiftFunc =
|
||||||
fir::runtime::getRuntimeFunc<mkRTKey(CshiftVector)>(loc, builder);
|
fir::runtime::getRuntimeFunc<mkRTKey(CshiftVector)>(loc, builder);
|
||||||
auto fTy = cshiftFunc.getType();
|
auto fTy = cshiftFunc.getFunctionType();
|
||||||
|
|
||||||
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
auto sourceLine =
|
auto sourceLine =
|
||||||
|
@ -57,7 +57,7 @@ void fir::runtime::genEoshift(fir::FirOpBuilder &builder, mlir::Location loc,
|
||||||
mlir::Value dimBox) {
|
mlir::Value dimBox) {
|
||||||
auto eoshiftFunc =
|
auto eoshiftFunc =
|
||||||
fir::runtime::getRuntimeFunc<mkRTKey(Eoshift)>(loc, builder);
|
fir::runtime::getRuntimeFunc<mkRTKey(Eoshift)>(loc, builder);
|
||||||
auto fTy = eoshiftFunc.getType();
|
auto fTy = eoshiftFunc.getFunctionType();
|
||||||
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
auto sourceLine =
|
auto sourceLine =
|
||||||
fir::factory::locationToLineNo(builder, loc, fTy.getInput(6));
|
fir::factory::locationToLineNo(builder, loc, fTy.getInput(6));
|
||||||
|
@ -74,7 +74,7 @@ void fir::runtime::genEoshiftVector(fir::FirOpBuilder &builder,
|
||||||
mlir::Value boundBox) {
|
mlir::Value boundBox) {
|
||||||
auto eoshiftFunc =
|
auto eoshiftFunc =
|
||||||
fir::runtime::getRuntimeFunc<mkRTKey(EoshiftVector)>(loc, builder);
|
fir::runtime::getRuntimeFunc<mkRTKey(EoshiftVector)>(loc, builder);
|
||||||
auto fTy = eoshiftFunc.getType();
|
auto fTy = eoshiftFunc.getFunctionType();
|
||||||
|
|
||||||
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
auto sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
auto sourceLine =
|
auto sourceLine =
|
||||||
|
@ -91,7 +91,7 @@ void fir::runtime::genMatmul(fir::FirOpBuilder &builder, mlir::Location loc,
|
||||||
mlir::Value resultBox, mlir::Value matrixABox,
|
mlir::Value resultBox, mlir::Value matrixABox,
|
||||||
mlir::Value matrixBBox) {
|
mlir::Value matrixBBox) {
|
||||||
auto func = fir::runtime::getRuntimeFunc<mkRTKey(Matmul)>(loc, builder);
|
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 sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
auto sourceLine =
|
auto sourceLine =
|
||||||
fir::factory::locationToLineNo(builder, loc, fTy.getInput(4));
|
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 resultBox, mlir::Value arrayBox,
|
||||||
mlir::Value maskBox, mlir::Value vectorBox) {
|
mlir::Value maskBox, mlir::Value vectorBox) {
|
||||||
auto packFunc = fir::runtime::getRuntimeFunc<mkRTKey(Pack)>(loc, builder);
|
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 sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
auto sourceLine =
|
auto sourceLine =
|
||||||
fir::factory::locationToLineNo(builder, loc, fTy.getInput(5));
|
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 shapeBox, mlir::Value padBox,
|
||||||
mlir::Value orderBox) {
|
mlir::Value orderBox) {
|
||||||
auto func = fir::runtime::getRuntimeFunc<mkRTKey(Reshape)>(loc, builder);
|
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 sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
auto sourceLine =
|
auto sourceLine =
|
||||||
fir::factory::locationToLineNo(builder, loc, fTy.getInput(6));
|
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 resultBox, mlir::Value sourceBox,
|
||||||
mlir::Value dim, mlir::Value ncopies) {
|
mlir::Value dim, mlir::Value ncopies) {
|
||||||
auto func = fir::runtime::getRuntimeFunc<mkRTKey(Spread)>(loc, builder);
|
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 sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
auto sourceLine =
|
auto sourceLine =
|
||||||
fir::factory::locationToLineNo(builder, loc, fTy.getInput(5));
|
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,
|
void fir::runtime::genTranspose(fir::FirOpBuilder &builder, mlir::Location loc,
|
||||||
mlir::Value resultBox, mlir::Value sourceBox) {
|
mlir::Value resultBox, mlir::Value sourceBox) {
|
||||||
auto func = fir::runtime::getRuntimeFunc<mkRTKey(Transpose)>(loc, builder);
|
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 sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
auto sourceLine =
|
auto sourceLine =
|
||||||
fir::factory::locationToLineNo(builder, loc, fTy.getInput(3));
|
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 resultBox, mlir::Value vectorBox,
|
||||||
mlir::Value maskBox, mlir::Value fieldBox) {
|
mlir::Value maskBox, mlir::Value fieldBox) {
|
||||||
auto unpackFunc = fir::runtime::getRuntimeFunc<mkRTKey(Unpack)>(loc, builder);
|
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 sourceFile = fir::factory::locationToFilename(builder, loc);
|
||||||
auto sourceLine =
|
auto sourceLine =
|
||||||
fir::factory::locationToLineNo(builder, loc, fTy.getInput(5));
|
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
|
/// Rewrite the signatures and body of the `FuncOp`s in the module for
|
||||||
/// the immediately subsequent target code gen.
|
/// the immediately subsequent target code gen.
|
||||||
void convertSignature(mlir::FuncOp func) {
|
void convertSignature(mlir::FuncOp func) {
|
||||||
auto funcTy = func.getType().cast<mlir::FunctionType>();
|
auto funcTy = func.getFunctionType().cast<mlir::FunctionType>();
|
||||||
if (hasPortableSignature(funcTy))
|
if (hasPortableSignature(funcTy))
|
||||||
return;
|
return;
|
||||||
llvm::SmallVector<mlir::Type> newResTys;
|
llvm::SmallVector<mlir::Type> newResTys;
|
||||||
|
@ -543,7 +543,7 @@ public:
|
||||||
// return ops as required. These fixups are done in place.
|
// return ops as required. These fixups are done in place.
|
||||||
auto loc = func.getLoc();
|
auto loc = func.getLoc();
|
||||||
const auto fixupSize = fixups.size();
|
const auto fixupSize = fixups.size();
|
||||||
const auto oldArgTys = func.getType().getInputs();
|
const auto oldArgTys = func.getFunctionType().getInputs();
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
for (std::remove_const_t<decltype(fixupSize)> i = 0; i < fixupSize; ++i) {
|
for (std::remove_const_t<decltype(fixupSize)> i = 0; i < fixupSize; ++i) {
|
||||||
const auto &fixup = fixups[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) {
|
mlir::FuncOp callee, mlir::ValueRange operands) {
|
||||||
result.addOperands(operands);
|
result.addOperands(operands);
|
||||||
result.addAttribute(getCalleeAttrNameStr(), SymbolRefAttr::get(callee));
|
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,
|
void fir::CallOp::build(mlir::OpBuilder &builder, mlir::OperationState &result,
|
||||||
|
|
|
@ -222,7 +222,7 @@ public:
|
||||||
/*newArg=*/{}};
|
/*newArg=*/{}};
|
||||||
|
|
||||||
// Convert function type itself if it has an abstract result
|
// 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)) {
|
if (mustConvertCallOrFunc(funcTy)) {
|
||||||
func.setType(getNewFunctionType(funcTy, options));
|
func.setType(getNewFunctionType(funcTy, options));
|
||||||
unsigned zero = 0;
|
unsigned zero = 0;
|
||||||
|
|
|
@ -661,7 +661,7 @@ with Context():
|
||||||
# Operations can be created in a generic way.
|
# Operations can be created in a generic way.
|
||||||
func = Operation.create(
|
func = Operation.create(
|
||||||
"func.func", results=[], operands=[],
|
"func.func", results=[], operands=[],
|
||||||
attributes={"type":TypeAttr.get(FunctionType.get([], []))},
|
attributes={"function_type":TypeAttr.get(FunctionType.get([], []))},
|
||||||
successors=None, regions=1)
|
successors=None, regions=1)
|
||||||
# The result will be downcasted to the concrete `OpView` subclass if
|
# The result will be downcasted to the concrete `OpView` subclass if
|
||||||
# available.
|
# available.
|
||||||
|
|
|
@ -135,7 +135,7 @@ def FuncOp : Toy_Op<"func", [
|
||||||
|
|
||||||
let arguments = (ins
|
let arguments = (ins
|
||||||
SymbolNameAttr:$sym_name,
|
SymbolNameAttr:$sym_name,
|
||||||
TypeAttrOf<FunctionType>:$type
|
TypeAttrOf<FunctionType>:$function_type
|
||||||
);
|
);
|
||||||
let regions = (region AnyRegion:$body);
|
let regions = (region AnyRegion:$body);
|
||||||
|
|
||||||
|
@ -149,10 +149,10 @@ def FuncOp : Toy_Op<"func", [
|
||||||
//===------------------------------------------------------------------===//
|
//===------------------------------------------------------------------===//
|
||||||
|
|
||||||
/// Returns the argument types of this function.
|
/// 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.
|
/// Returns the result types of this function.
|
||||||
ArrayRef<Type> getResultTypes() { return getType().getResults(); }
|
ArrayRef<Type> getResultTypes() { return getFunctionType().getResults(); }
|
||||||
}];
|
}];
|
||||||
let hasCustomAssemblyFormat = 1;
|
let hasCustomAssemblyFormat = 1;
|
||||||
let skipDefaultBuilders = 1;
|
let skipDefaultBuilders = 1;
|
||||||
|
|
|
@ -252,7 +252,7 @@ mlir::LogicalResult ReturnOp::verify() {
|
||||||
return emitOpError() << "expects at most 1 return operand";
|
return emitOpError() << "expects at most 1 return operand";
|
||||||
|
|
||||||
// The operand number and types must match the function signature.
|
// 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())
|
if (getNumOperands() != results.size())
|
||||||
return emitOpError() << "does not return the same number of values ("
|
return emitOpError() << "does not return the same number of values ("
|
||||||
<< getNumOperands() << ") as the enclosing function ("
|
<< getNumOperands() << ") as the enclosing function ("
|
||||||
|
|
|
@ -161,8 +161,8 @@ private:
|
||||||
} else if (returnOp.hasOperand()) {
|
} else if (returnOp.hasOperand()) {
|
||||||
// Otherwise, if this return operation has an operand then add a result to
|
// Otherwise, if this return operation has an operand then add a result to
|
||||||
// the function.
|
// the function.
|
||||||
function.setType(builder.getFunctionType(function.getType().getInputs(),
|
function.setType(builder.getFunctionType(
|
||||||
getType(VarType{})));
|
function.getFunctionType().getInputs(), getType(VarType{})));
|
||||||
}
|
}
|
||||||
|
|
||||||
return function;
|
return function;
|
||||||
|
|
|
@ -134,7 +134,7 @@ def FuncOp : Toy_Op<"func", [
|
||||||
|
|
||||||
let arguments = (ins
|
let arguments = (ins
|
||||||
SymbolNameAttr:$sym_name,
|
SymbolNameAttr:$sym_name,
|
||||||
TypeAttrOf<FunctionType>:$type
|
TypeAttrOf<FunctionType>:$function_type
|
||||||
);
|
);
|
||||||
let regions = (region AnyRegion:$body);
|
let regions = (region AnyRegion:$body);
|
||||||
|
|
||||||
|
@ -148,10 +148,10 @@ def FuncOp : Toy_Op<"func", [
|
||||||
//===------------------------------------------------------------------===//
|
//===------------------------------------------------------------------===//
|
||||||
|
|
||||||
/// Returns the argument types of this function.
|
/// 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.
|
/// Returns the result types of this function.
|
||||||
ArrayRef<Type> getResultTypes() { return getType().getResults(); }
|
ArrayRef<Type> getResultTypes() { return getFunctionType().getResults(); }
|
||||||
}];
|
}];
|
||||||
let hasCustomAssemblyFormat = 1;
|
let hasCustomAssemblyFormat = 1;
|
||||||
let skipDefaultBuilders = 1;
|
let skipDefaultBuilders = 1;
|
||||||
|
|
|
@ -252,7 +252,7 @@ mlir::LogicalResult ReturnOp::verify() {
|
||||||
return emitOpError() << "expects at most 1 return operand";
|
return emitOpError() << "expects at most 1 return operand";
|
||||||
|
|
||||||
// The operand number and types must match the function signature.
|
// 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())
|
if (getNumOperands() != results.size())
|
||||||
return emitOpError() << "does not return the same number of values ("
|
return emitOpError() << "does not return the same number of values ("
|
||||||
<< getNumOperands() << ") as the enclosing function ("
|
<< getNumOperands() << ") as the enclosing function ("
|
||||||
|
|
|
@ -161,8 +161,8 @@ private:
|
||||||
} else if (returnOp.hasOperand()) {
|
} else if (returnOp.hasOperand()) {
|
||||||
// Otherwise, if this return operation has an operand then add a result to
|
// Otherwise, if this return operation has an operand then add a result to
|
||||||
// the function.
|
// the function.
|
||||||
function.setType(builder.getFunctionType(function.getType().getInputs(),
|
function.setType(builder.getFunctionType(
|
||||||
getType(VarType{})));
|
function.getFunctionType().getInputs(), getType(VarType{})));
|
||||||
}
|
}
|
||||||
|
|
||||||
return function;
|
return function;
|
||||||
|
|
|
@ -164,7 +164,7 @@ def FuncOp : Toy_Op<"func", [
|
||||||
|
|
||||||
let arguments = (ins
|
let arguments = (ins
|
||||||
SymbolNameAttr:$sym_name,
|
SymbolNameAttr:$sym_name,
|
||||||
TypeAttrOf<FunctionType>:$type
|
TypeAttrOf<FunctionType>:$function_type
|
||||||
);
|
);
|
||||||
let regions = (region AnyRegion:$body);
|
let regions = (region AnyRegion:$body);
|
||||||
|
|
||||||
|
@ -178,10 +178,10 @@ def FuncOp : Toy_Op<"func", [
|
||||||
//===------------------------------------------------------------------===//
|
//===------------------------------------------------------------------===//
|
||||||
|
|
||||||
/// Returns the argument types of this function.
|
/// 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.
|
/// Returns the result types of this function.
|
||||||
ArrayRef<Type> getResultTypes() { return getType().getResults(); }
|
ArrayRef<Type> getResultTypes() { return getFunctionType().getResults(); }
|
||||||
}];
|
}];
|
||||||
let hasCustomAssemblyFormat = 1;
|
let hasCustomAssemblyFormat = 1;
|
||||||
let skipDefaultBuilders = 1;
|
let skipDefaultBuilders = 1;
|
||||||
|
|
|
@ -303,7 +303,7 @@ mlir::Region *FuncOp::getCallableRegion() { return &getBody(); }
|
||||||
/// Returns the results types that the callable region produces when
|
/// Returns the results types that the callable region produces when
|
||||||
/// executed.
|
/// executed.
|
||||||
llvm::ArrayRef<mlir::Type> FuncOp::getCallableResults() {
|
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";
|
return emitOpError() << "expects at most 1 return operand";
|
||||||
|
|
||||||
// The operand number and types must match the function signature.
|
// 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())
|
if (getNumOperands() != results.size())
|
||||||
return emitOpError() << "does not return the same number of values ("
|
return emitOpError() << "does not return the same number of values ("
|
||||||
<< getNumOperands() << ") as the enclosing function ("
|
<< getNumOperands() << ") as the enclosing function ("
|
||||||
|
|
|
@ -161,8 +161,8 @@ private:
|
||||||
} else if (returnOp.hasOperand()) {
|
} else if (returnOp.hasOperand()) {
|
||||||
// Otherwise, if this return operation has an operand then add a result to
|
// Otherwise, if this return operation has an operand then add a result to
|
||||||
// the function.
|
// the function.
|
||||||
function.setType(builder.getFunctionType(function.getType().getInputs(),
|
function.setType(builder.getFunctionType(
|
||||||
getType(VarType{})));
|
function.getFunctionType().getInputs(), getType(VarType{})));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this function isn't main, then set the visibility to private.
|
// If this function isn't main, then set the visibility to private.
|
||||||
|
|
|
@ -164,7 +164,7 @@ def FuncOp : Toy_Op<"func", [
|
||||||
|
|
||||||
let arguments = (ins
|
let arguments = (ins
|
||||||
SymbolNameAttr:$sym_name,
|
SymbolNameAttr:$sym_name,
|
||||||
TypeAttrOf<FunctionType>:$type
|
TypeAttrOf<FunctionType>:$function_type
|
||||||
);
|
);
|
||||||
let regions = (region AnyRegion:$body);
|
let regions = (region AnyRegion:$body);
|
||||||
|
|
||||||
|
@ -178,10 +178,10 @@ def FuncOp : Toy_Op<"func", [
|
||||||
//===------------------------------------------------------------------===//
|
//===------------------------------------------------------------------===//
|
||||||
|
|
||||||
/// Returns the argument types of this function.
|
/// 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.
|
/// Returns the result types of this function.
|
||||||
ArrayRef<Type> getResultTypes() { return getType().getResults(); }
|
ArrayRef<Type> getResultTypes() { return getFunctionType().getResults(); }
|
||||||
}];
|
}];
|
||||||
let hasCustomAssemblyFormat = 1;
|
let hasCustomAssemblyFormat = 1;
|
||||||
let skipDefaultBuilders = 1;
|
let skipDefaultBuilders = 1;
|
||||||
|
|
|
@ -303,7 +303,7 @@ mlir::Region *FuncOp::getCallableRegion() { return &getBody(); }
|
||||||
/// Returns the results types that the callable region produces when
|
/// Returns the results types that the callable region produces when
|
||||||
/// executed.
|
/// executed.
|
||||||
llvm::ArrayRef<mlir::Type> FuncOp::getCallableResults() {
|
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";
|
return emitOpError() << "expects at most 1 return operand";
|
||||||
|
|
||||||
// The operand number and types must match the function signature.
|
// 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())
|
if (getNumOperands() != results.size())
|
||||||
return emitOpError() << "does not return the same number of values ("
|
return emitOpError() << "does not return the same number of values ("
|
||||||
<< getNumOperands() << ") as the enclosing function ("
|
<< getNumOperands() << ") as the enclosing function ("
|
||||||
|
|
|
@ -214,15 +214,15 @@ struct FuncOpLowering : public OpConversionPattern<toy::FuncOp> {
|
||||||
return failure();
|
return failure();
|
||||||
|
|
||||||
// Verify that the given main has no inputs and results.
|
// 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) {
|
return rewriter.notifyMatchFailure(op, [](Diagnostic &diag) {
|
||||||
diag << "expected 'main' to have 0 inputs and 0 results";
|
diag << "expected 'main' to have 0 inputs and 0 results";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new non-toy function, with the same region.
|
// Create a new non-toy function, with the same region.
|
||||||
auto func =
|
auto func = rewriter.create<mlir::FuncOp>(op.getLoc(), op.getName(),
|
||||||
rewriter.create<mlir::FuncOp>(op.getLoc(), op.getName(), op.getType());
|
op.getFunctionType());
|
||||||
rewriter.inlineRegionBefore(op.getRegion(), func.getBody(), func.end());
|
rewriter.inlineRegionBefore(op.getRegion(), func.getBody(), func.end());
|
||||||
rewriter.eraseOp(op);
|
rewriter.eraseOp(op);
|
||||||
return success();
|
return success();
|
||||||
|
|
|
@ -161,8 +161,8 @@ private:
|
||||||
} else if (returnOp.hasOperand()) {
|
} else if (returnOp.hasOperand()) {
|
||||||
// Otherwise, if this return operation has an operand then add a result to
|
// Otherwise, if this return operation has an operand then add a result to
|
||||||
// the function.
|
// the function.
|
||||||
function.setType(builder.getFunctionType(function.getType().getInputs(),
|
function.setType(builder.getFunctionType(
|
||||||
getType(VarType{})));
|
function.getFunctionType().getInputs(), getType(VarType{})));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this function isn't main, then set the visibility to private.
|
// If this function isn't main, then set the visibility to private.
|
||||||
|
|
|
@ -164,7 +164,7 @@ def FuncOp : Toy_Op<"func", [
|
||||||
|
|
||||||
let arguments = (ins
|
let arguments = (ins
|
||||||
SymbolNameAttr:$sym_name,
|
SymbolNameAttr:$sym_name,
|
||||||
TypeAttrOf<FunctionType>:$type
|
TypeAttrOf<FunctionType>:$function_type
|
||||||
);
|
);
|
||||||
let regions = (region AnyRegion:$body);
|
let regions = (region AnyRegion:$body);
|
||||||
|
|
||||||
|
@ -178,10 +178,10 @@ def FuncOp : Toy_Op<"func", [
|
||||||
//===------------------------------------------------------------------===//
|
//===------------------------------------------------------------------===//
|
||||||
|
|
||||||
/// Returns the argument types of this function.
|
/// 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.
|
/// Returns the result types of this function.
|
||||||
ArrayRef<Type> getResultTypes() { return getType().getResults(); }
|
ArrayRef<Type> getResultTypes() { return getFunctionType().getResults(); }
|
||||||
}];
|
}];
|
||||||
let hasCustomAssemblyFormat = 1;
|
let hasCustomAssemblyFormat = 1;
|
||||||
let skipDefaultBuilders = 1;
|
let skipDefaultBuilders = 1;
|
||||||
|
|
|
@ -303,7 +303,7 @@ mlir::Region *FuncOp::getCallableRegion() { return &getBody(); }
|
||||||
/// Returns the results types that the callable region produces when
|
/// Returns the results types that the callable region produces when
|
||||||
/// executed.
|
/// executed.
|
||||||
llvm::ArrayRef<mlir::Type> FuncOp::getCallableResults() {
|
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";
|
return emitOpError() << "expects at most 1 return operand";
|
||||||
|
|
||||||
// The operand number and types must match the function signature.
|
// 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())
|
if (getNumOperands() != results.size())
|
||||||
return emitOpError() << "does not return the same number of values ("
|
return emitOpError() << "does not return the same number of values ("
|
||||||
<< getNumOperands() << ") as the enclosing function ("
|
<< getNumOperands() << ") as the enclosing function ("
|
||||||
|
|
|
@ -214,15 +214,15 @@ struct FuncOpLowering : public OpConversionPattern<toy::FuncOp> {
|
||||||
return failure();
|
return failure();
|
||||||
|
|
||||||
// Verify that the given main has no inputs and results.
|
// 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) {
|
return rewriter.notifyMatchFailure(op, [](Diagnostic &diag) {
|
||||||
diag << "expected 'main' to have 0 inputs and 0 results";
|
diag << "expected 'main' to have 0 inputs and 0 results";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new non-toy function, with the same region.
|
// Create a new non-toy function, with the same region.
|
||||||
auto func =
|
auto func = rewriter.create<mlir::FuncOp>(op.getLoc(), op.getName(),
|
||||||
rewriter.create<mlir::FuncOp>(op.getLoc(), op.getName(), op.getType());
|
op.getFunctionType());
|
||||||
rewriter.inlineRegionBefore(op.getRegion(), func.getBody(), func.end());
|
rewriter.inlineRegionBefore(op.getRegion(), func.getBody(), func.end());
|
||||||
rewriter.eraseOp(op);
|
rewriter.eraseOp(op);
|
||||||
return success();
|
return success();
|
||||||
|
|
|
@ -161,8 +161,8 @@ private:
|
||||||
} else if (returnOp.hasOperand()) {
|
} else if (returnOp.hasOperand()) {
|
||||||
// Otherwise, if this return operation has an operand then add a result to
|
// Otherwise, if this return operation has an operand then add a result to
|
||||||
// the function.
|
// the function.
|
||||||
function.setType(builder.getFunctionType(function.getType().getInputs(),
|
function.setType(builder.getFunctionType(
|
||||||
getType(VarType{})));
|
function.getFunctionType().getInputs(), getType(VarType{})));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this function isn't main, then set the visibility to private.
|
// If this function isn't main, then set the visibility to private.
|
||||||
|
|
|
@ -183,7 +183,7 @@ def FuncOp : Toy_Op<"func", [
|
||||||
|
|
||||||
let arguments = (ins
|
let arguments = (ins
|
||||||
SymbolNameAttr:$sym_name,
|
SymbolNameAttr:$sym_name,
|
||||||
TypeAttrOf<FunctionType>:$type
|
TypeAttrOf<FunctionType>:$function_type
|
||||||
);
|
);
|
||||||
let regions = (region AnyRegion:$body);
|
let regions = (region AnyRegion:$body);
|
||||||
|
|
||||||
|
@ -197,10 +197,10 @@ def FuncOp : Toy_Op<"func", [
|
||||||
//===------------------------------------------------------------------===//
|
//===------------------------------------------------------------------===//
|
||||||
|
|
||||||
/// Returns the argument types of this function.
|
/// 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.
|
/// Returns the result types of this function.
|
||||||
ArrayRef<Type> getResultTypes() { return getType().getResults(); }
|
ArrayRef<Type> getResultTypes() { return getFunctionType().getResults(); }
|
||||||
}];
|
}];
|
||||||
let hasCustomAssemblyFormat = 1;
|
let hasCustomAssemblyFormat = 1;
|
||||||
let skipDefaultBuilders = 1;
|
let skipDefaultBuilders = 1;
|
||||||
|
|
|
@ -330,7 +330,7 @@ mlir::Region *FuncOp::getCallableRegion() { return &getBody(); }
|
||||||
/// Returns the results types that the callable region produces when
|
/// Returns the results types that the callable region produces when
|
||||||
/// executed.
|
/// executed.
|
||||||
llvm::ArrayRef<mlir::Type> FuncOp::getCallableResults() {
|
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";
|
return emitOpError() << "expects at most 1 return operand";
|
||||||
|
|
||||||
// The operand number and types must match the function signature.
|
// 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())
|
if (getNumOperands() != results.size())
|
||||||
return emitOpError() << "does not return the same number of values ("
|
return emitOpError() << "does not return the same number of values ("
|
||||||
<< getNumOperands() << ") as the enclosing function ("
|
<< getNumOperands() << ") as the enclosing function ("
|
||||||
|
|
|
@ -214,15 +214,15 @@ struct FuncOpLowering : public OpConversionPattern<toy::FuncOp> {
|
||||||
return failure();
|
return failure();
|
||||||
|
|
||||||
// Verify that the given main has no inputs and results.
|
// 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) {
|
return rewriter.notifyMatchFailure(op, [](Diagnostic &diag) {
|
||||||
diag << "expected 'main' to have 0 inputs and 0 results";
|
diag << "expected 'main' to have 0 inputs and 0 results";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new non-toy function, with the same region.
|
// Create a new non-toy function, with the same region.
|
||||||
auto func =
|
auto func = rewriter.create<mlir::FuncOp>(op.getLoc(), op.getName(),
|
||||||
rewriter.create<mlir::FuncOp>(op.getLoc(), op.getName(), op.getType());
|
op.getFunctionType());
|
||||||
rewriter.inlineRegionBefore(op.getRegion(), func.getBody(), func.end());
|
rewriter.inlineRegionBefore(op.getRegion(), func.getBody(), func.end());
|
||||||
rewriter.eraseOp(op);
|
rewriter.eraseOp(op);
|
||||||
return success();
|
return success();
|
||||||
|
|
|
@ -216,8 +216,9 @@ private:
|
||||||
} else if (returnOp.hasOperand()) {
|
} else if (returnOp.hasOperand()) {
|
||||||
// Otherwise, if this return operation has an operand then add a result to
|
// Otherwise, if this return operation has an operand then add a result to
|
||||||
// the function.
|
// the function.
|
||||||
function.setType(builder.getFunctionType(function.getType().getInputs(),
|
function.setType(
|
||||||
*returnOp.operand_type_begin()));
|
builder.getFunctionType(function.getFunctionType().getInputs(),
|
||||||
|
*returnOp.operand_type_begin()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this function isn't main, then set the visibility to private.
|
// If this function isn't main, then set the visibility to private.
|
||||||
|
@ -519,7 +520,7 @@ private:
|
||||||
}
|
}
|
||||||
mlir::toy::FuncOp calledFunc = calledFuncIt->second;
|
mlir::toy::FuncOp calledFunc = calledFuncIt->second;
|
||||||
return builder.create<GenericCallOp>(
|
return builder.create<GenericCallOp>(
|
||||||
location, calledFunc.getType().getResult(0),
|
location, calledFunc.getFunctionType().getResult(0),
|
||||||
mlir::SymbolRefAttr::get(builder.getContext(), callee), operands);
|
mlir::SymbolRefAttr::get(builder.getContext(), callee), operands);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ def CallOp : Func_Op<"call",
|
||||||
OpBuilder<(ins "FuncOp":$callee, CArg<"ValueRange", "{}">:$operands), [{
|
OpBuilder<(ins "FuncOp":$callee, CArg<"ValueRange", "{}">:$operands), [{
|
||||||
$_state.addOperands(operands);
|
$_state.addOperands(operands);
|
||||||
$_state.addAttribute("callee", SymbolRefAttr::get(callee));
|
$_state.addAttribute("callee", SymbolRefAttr::get(callee));
|
||||||
$_state.addTypes(callee.getType().getResults());
|
$_state.addTypes(callee.getFunctionType().getResults());
|
||||||
}]>,
|
}]>,
|
||||||
OpBuilder<(ins "SymbolRefAttr":$callee, "TypeRange":$results,
|
OpBuilder<(ins "SymbolRefAttr":$callee, "TypeRange":$results,
|
||||||
CArg<"ValueRange", "{}">:$operands), [{
|
CArg<"ValueRange", "{}">:$operands), [{
|
||||||
|
@ -250,7 +250,7 @@ def FuncOp : Func_Op<"func", [
|
||||||
}];
|
}];
|
||||||
|
|
||||||
let arguments = (ins SymbolNameAttr:$sym_name,
|
let arguments = (ins SymbolNameAttr:$sym_name,
|
||||||
TypeAttrOf<FunctionType>:$type,
|
TypeAttrOf<FunctionType>:$function_type,
|
||||||
OptionalAttr<StrAttr>:$sym_visibility);
|
OptionalAttr<StrAttr>:$sym_visibility);
|
||||||
let regions = (region AnyRegion:$body);
|
let regions = (region AnyRegion:$body);
|
||||||
|
|
||||||
|
@ -295,17 +295,17 @@ def FuncOp : Func_Op<"func", [
|
||||||
|
|
||||||
/// Returns the results types that the callable region produces when
|
/// Returns the results types that the callable region produces when
|
||||||
/// executed.
|
/// executed.
|
||||||
ArrayRef<Type> getCallableResults() { return getType().getResults(); }
|
ArrayRef<Type> getCallableResults() { return getFunctionType().getResults(); }
|
||||||
|
|
||||||
//===------------------------------------------------------------------===//
|
//===------------------------------------------------------------------===//
|
||||||
// FunctionOpInterface Methods
|
// FunctionOpInterface Methods
|
||||||
//===------------------------------------------------------------------===//
|
//===------------------------------------------------------------------===//
|
||||||
|
|
||||||
/// Returns the argument types of this function.
|
/// 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.
|
/// Returns the result types of this function.
|
||||||
ArrayRef<Type> getResultTypes() { return getType().getResults(); }
|
ArrayRef<Type> getResultTypes() { return getFunctionType().getResults(); }
|
||||||
|
|
||||||
//===------------------------------------------------------------------===//
|
//===------------------------------------------------------------------===//
|
||||||
// SymbolOpInterface Methods
|
// SymbolOpInterface Methods
|
||||||
|
|
|
@ -221,6 +221,7 @@ def GPU_GPUFuncOp : GPU_Op<"func", [
|
||||||
attribution.
|
attribution.
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
let arguments = (ins TypeAttrOf<FunctionType>:$function_type);
|
||||||
let regions = (region AnyRegion:$body);
|
let regions = (region AnyRegion:$body);
|
||||||
|
|
||||||
let skipDefaultBuilders = 1;
|
let skipDefaultBuilders = 1;
|
||||||
|
@ -250,7 +251,7 @@ def GPU_GPUFuncOp : GPU_Op<"func", [
|
||||||
/// the workgroup memory
|
/// the workgroup memory
|
||||||
ArrayRef<BlockArgument> getWorkgroupAttributions() {
|
ArrayRef<BlockArgument> getWorkgroupAttributions() {
|
||||||
auto begin =
|
auto begin =
|
||||||
std::next(getBody().args_begin(), getType().getNumInputs());
|
std::next(getBody().args_begin(), getFunctionType().getNumInputs());
|
||||||
auto end = std::next(begin, getNumWorkgroupAttributions());
|
auto end = std::next(begin, getNumWorkgroupAttributions());
|
||||||
return {begin, end};
|
return {begin, end};
|
||||||
}
|
}
|
||||||
|
@ -261,7 +262,7 @@ def GPU_GPUFuncOp : GPU_Op<"func", [
|
||||||
|
|
||||||
/// Returns the number of buffers located in the private memory.
|
/// Returns the number of buffers located in the private memory.
|
||||||
unsigned getNumPrivateAttributions() {
|
unsigned getNumPrivateAttributions() {
|
||||||
return getBody().getNumArguments() - getType().getNumInputs() -
|
return getBody().getNumArguments() - getFunctionType().getNumInputs() -
|
||||||
getNumWorkgroupAttributions();
|
getNumWorkgroupAttributions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,7 +273,7 @@ def GPU_GPUFuncOp : GPU_Op<"func", [
|
||||||
// memory.
|
// memory.
|
||||||
auto begin =
|
auto begin =
|
||||||
std::next(getBody().args_begin(),
|
std::next(getBody().args_begin(),
|
||||||
getType().getNumInputs() + getNumWorkgroupAttributions());
|
getFunctionType().getNumInputs() + getNumWorkgroupAttributions());
|
||||||
return {begin, getBody().args_end()};
|
return {begin, getBody().args_end()};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,16 +288,14 @@ def GPU_GPUFuncOp : GPU_Op<"func", [
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the type of this function.
|
/// Returns the type of this function.
|
||||||
/// FIXME: We should drive this via the ODS `type` param.
|
/// FIXME: Remove when GPU uses prefixed accessors.
|
||||||
FunctionType getType() {
|
FunctionType getFunctionType() { return function_type(); }
|
||||||
return getTypeAttr().getValue().cast<FunctionType>();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the argument types of this function.
|
/// 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.
|
/// 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.
|
/// Returns the keywords used in the custom syntax for this Op.
|
||||||
static StringRef getWorkgroupKeyword() { return "workgroup"; }
|
static StringRef getWorkgroupKeyword() { return "workgroup"; }
|
||||||
|
|
|
@ -80,6 +80,10 @@ def LLVM_PrimitiveType : Type<
|
||||||
"::mlir::LLVM::LLVMFunctionType>()">]>,
|
"::mlir::LLVM::LLVMFunctionType>()">]>,
|
||||||
"primitive LLVM type">;
|
"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.
|
// Type constraint accepting any LLVM floating point type.
|
||||||
def LLVM_AnyFloat : Type<
|
def LLVM_AnyFloat : Type<
|
||||||
CPred<"::mlir::LLVM::isCompatibleFloatingPointType($_self)">,
|
CPred<"::mlir::LLVM::isCompatibleFloatingPointType($_self)">,
|
||||||
|
|
|
@ -537,7 +537,7 @@ def LLVM_CallOp : LLVM_Op<"call",
|
||||||
let builders = [
|
let builders = [
|
||||||
OpBuilder<(ins "LLVMFuncOp":$func, "ValueRange":$operands,
|
OpBuilder<(ins "LLVMFuncOp":$func, "ValueRange":$operands,
|
||||||
CArg<"ArrayRef<NamedAttribute>", "{}">:$attributes), [{
|
CArg<"ArrayRef<NamedAttribute>", "{}">:$attributes), [{
|
||||||
Type resultType = func.getType().getReturnType();
|
Type resultType = func.getFunctionType().getReturnType();
|
||||||
if (!resultType.isa<LLVM::LLVMVoidType>())
|
if (!resultType.isa<LLVM::LLVMVoidType>())
|
||||||
$_state.addTypes(resultType);
|
$_state.addTypes(resultType);
|
||||||
$_state.addAttribute("callee", SymbolRefAttr::get(func));
|
$_state.addAttribute("callee", SymbolRefAttr::get(func));
|
||||||
|
@ -874,7 +874,7 @@ def LLVM_AddressOfOp : LLVM_Op<"mlir.addressof", [NoSideEffect]> {
|
||||||
CArg<"ArrayRef<NamedAttribute>", "{}">:$attrs),
|
CArg<"ArrayRef<NamedAttribute>", "{}">:$attrs),
|
||||||
[{
|
[{
|
||||||
build($_builder, $_state,
|
build($_builder, $_state,
|
||||||
LLVM::LLVMPointerType::get(func.getType()), func.getName());
|
LLVM::LLVMPointerType::get(func.getFunctionType()), func.getName());
|
||||||
$_state.addAttributes(attrs);
|
$_state.addAttributes(attrs);
|
||||||
}]>
|
}]>
|
||||||
];
|
];
|
||||||
|
@ -1236,11 +1236,14 @@ def LLVM_LLVMFuncOp : LLVM_Op<"func", [
|
||||||
```
|
```
|
||||||
}];
|
}];
|
||||||
|
|
||||||
let arguments = (ins DefaultValuedAttr<Linkage, "Linkage::External">:$linkage,
|
let arguments = (ins
|
||||||
UnitAttr:$dso_local,
|
TypeAttrOf<LLVM_FunctionType>:$function_type,
|
||||||
OptionalAttr<FlatSymbolRefAttr>:$personality,
|
DefaultValuedAttr<Linkage, "Linkage::External">:$linkage,
|
||||||
OptionalAttr<StrAttr>:$garbageCollector,
|
UnitAttr:$dso_local,
|
||||||
OptionalAttr<ArrayAttr>:$passthrough);
|
OptionalAttr<FlatSymbolRefAttr>:$personality,
|
||||||
|
OptionalAttr<StrAttr>:$garbageCollector,
|
||||||
|
OptionalAttr<ArrayAttr>:$passthrough
|
||||||
|
);
|
||||||
|
|
||||||
let regions = (region AnyRegion:$body);
|
let regions = (region AnyRegion:$body);
|
||||||
|
|
||||||
|
@ -1259,21 +1262,13 @@ def LLVM_LLVMFuncOp : LLVM_Op<"func", [
|
||||||
// to match the signature of the function.
|
// to match the signature of the function.
|
||||||
Block *addEntryBlock();
|
Block *addEntryBlock();
|
||||||
|
|
||||||
LLVMFunctionType getType() {
|
bool isVarArg() { return getFunctionType().isVarArg(); }
|
||||||
return getTypeAttr().getValue().cast<LLVMFunctionType>();
|
|
||||||
}
|
|
||||||
bool isVarArg() { return getType().isVarArg(); }
|
|
||||||
|
|
||||||
/// Returns the argument types of this function.
|
/// 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.
|
/// Returns the result types of this function.
|
||||||
ArrayRef<Type> getResultTypes() { return getType().getReturnTypes(); }
|
ArrayRef<Type> getResultTypes() { return getFunctionType().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();
|
|
||||||
}];
|
}];
|
||||||
|
|
||||||
let hasCustomAssemblyFormat = 1;
|
let hasCustomAssemblyFormat = 1;
|
||||||
|
|
|
@ -657,7 +657,7 @@ def PDLInterp_FuncOp : PDLInterp_Op<"func", [
|
||||||
|
|
||||||
let arguments = (ins
|
let arguments = (ins
|
||||||
SymbolNameAttr:$sym_name,
|
SymbolNameAttr:$sym_name,
|
||||||
TypeAttrOf<FunctionType>:$type
|
TypeAttrOf<FunctionType>:$function_type
|
||||||
);
|
);
|
||||||
let regions = (region MinSizedRegion<1>:$body);
|
let regions = (region MinSizedRegion<1>:$body);
|
||||||
|
|
||||||
|
@ -673,10 +673,10 @@ def PDLInterp_FuncOp : PDLInterp_Op<"func", [
|
||||||
//===------------------------------------------------------------------===//
|
//===------------------------------------------------------------------===//
|
||||||
|
|
||||||
/// Returns the argument types of this function.
|
/// 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.
|
/// Returns the result types of this function.
|
||||||
ArrayRef<Type> getResultTypes() { return getType().getResults(); }
|
ArrayRef<Type> getResultTypes() { return getFunctionType().getResults(); }
|
||||||
}];
|
}];
|
||||||
let hasCustomAssemblyFormat = 1;
|
let hasCustomAssemblyFormat = 1;
|
||||||
let skipDefaultBuilders = 1;
|
let skipDefaultBuilders = 1;
|
||||||
|
|
|
@ -287,7 +287,7 @@ def SPV_FuncOp : SPV_Op<"func", [
|
||||||
}];
|
}];
|
||||||
|
|
||||||
let arguments = (ins
|
let arguments = (ins
|
||||||
TypeAttr:$type,
|
TypeAttrOf<FunctionType>:$function_type,
|
||||||
StrAttr:$sym_name,
|
StrAttr:$sym_name,
|
||||||
SPV_FunctionControlAttr:$function_control
|
SPV_FunctionControlAttr:$function_control
|
||||||
);
|
);
|
||||||
|
@ -309,16 +309,14 @@ def SPV_FuncOp : SPV_Op<"func", [
|
||||||
|
|
||||||
let extraClassDeclaration = [{
|
let extraClassDeclaration = [{
|
||||||
/// Returns the type of this function.
|
/// Returns the type of this function.
|
||||||
/// FIXME: We should drive this via the ODS `type` param.
|
/// FIXME: Remove when SPIRV uses prefixed accessors.
|
||||||
FunctionType getType() {
|
FunctionType getFunctionType() { return function_type(); }
|
||||||
return getTypeAttr().getValue().cast<FunctionType>();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the argument types of this function.
|
/// 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.
|
/// 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'
|
/// Hook for FunctionOpInterface, called after verifying that the 'type'
|
||||||
/// attribute is present and checks if it holds a function type. Ensures
|
/// attribute is present and checks if it holds a function type. Ensures
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace mlir {
|
||||||
namespace function_interface_impl {
|
namespace function_interface_impl {
|
||||||
|
|
||||||
/// Return the name of the attribute used for function types.
|
/// 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.
|
/// Return the name of the attribute used for function argument attributes.
|
||||||
inline StringRef getArgDictAttrName() { return "arg_attrs"; }
|
inline StringRef getArgDictAttrName() { return "arg_attrs"; }
|
||||||
|
@ -207,7 +207,7 @@ Attribute removeResultAttr(ConcreteType op, unsigned index, StringAttr name) {
|
||||||
/// method on FunctionOpInterface::Trait.
|
/// method on FunctionOpInterface::Trait.
|
||||||
template <typename ConcreteOp>
|
template <typename ConcreteOp>
|
||||||
LogicalResult verifyTrait(ConcreteOp op) {
|
LogicalResult verifyTrait(ConcreteOp op) {
|
||||||
if (!op.getTypeAttr())
|
if (!op.getFunctionTypeAttr())
|
||||||
return op.emitOpError("requires a type attribute '")
|
return op.emitOpError("requires a type attribute '")
|
||||||
<< function_interface_impl::getTypeAttrName() << '\'';
|
<< function_interface_impl::getTypeAttrName() << '\'';
|
||||||
|
|
||||||
|
|
|
@ -37,9 +37,8 @@ def FunctionOpInterface : OpInterface<"FunctionOpInterface"> {
|
||||||
The function, aside from implementing the various interface methods,
|
The function, aside from implementing the various interface methods,
|
||||||
should have the following ODS arguments:
|
should have the following ODS arguments:
|
||||||
|
|
||||||
- `type` (required)
|
- `function_type` (required)
|
||||||
* A TypeAttr that holds the signature type of the function.
|
* A TypeAttr that holds the signature type of the function.
|
||||||
* TODO: this field will soon be renamed to something less generic.
|
|
||||||
|
|
||||||
- `arg_attrs` (optional)
|
- `arg_attrs` (optional)
|
||||||
* An ArrayAttr of DictionaryAttr that contains attribute dictionaries
|
* An ArrayAttr of DictionaryAttr that contains attribute dictionaries
|
||||||
|
@ -73,7 +72,7 @@ def FunctionOpInterface : OpInterface<"FunctionOpInterface"> {
|
||||||
"::mlir::Type", "cloneTypeWith", (ins
|
"::mlir::Type", "cloneTypeWith", (ins
|
||||||
"::mlir::TypeRange":$inputs, "::mlir::TypeRange":$results
|
"::mlir::TypeRange":$inputs, "::mlir::TypeRange":$results
|
||||||
), /*methodBody=*/[{}], /*defaultImplementation=*/[{
|
), /*methodBody=*/[{}], /*defaultImplementation=*/[{
|
||||||
return $_op.getType().clone(inputs, results);
|
return $_op.getFunctionType().clone(inputs, results);
|
||||||
}]>,
|
}]>,
|
||||||
|
|
||||||
InterfaceMethod<[{
|
InterfaceMethod<[{
|
||||||
|
@ -258,13 +257,13 @@ def FunctionOpInterface : OpInterface<"FunctionOpInterface"> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the attribute containing the type of this function.
|
/// Return the attribute containing the type of this function.
|
||||||
TypeAttr getTypeAttr() {
|
TypeAttr getFunctionTypeAttr() {
|
||||||
return this->getOperation()->template getAttrOfType<TypeAttr>(
|
return this->getOperation()->template getAttrOfType<TypeAttr>(
|
||||||
getTypeAttrName());
|
getTypeAttrName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the type of this function.
|
/// Return the type of this function.
|
||||||
Type getType() { return getTypeAttr().getValue(); }
|
Type getFunctionType() { return getFunctionTypeAttr().getValue(); }
|
||||||
|
|
||||||
//===------------------------------------------------------------------===//
|
//===------------------------------------------------------------------===//
|
||||||
// Argument and Result Handling
|
// Argument and Result Handling
|
||||||
|
|
|
@ -1269,7 +1269,7 @@ def TypeAttr : TypeAttrBase<"::mlir::Type", "any type attribute"> {
|
||||||
}
|
}
|
||||||
|
|
||||||
class TypeAttrOf<Type ty>
|
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)";
|
let constBuilderCall = "::mlir::TypeAttr::get($0)";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1042,8 +1042,9 @@ void ConvertAsyncToLLVMPass::runOnOperation() {
|
||||||
target.addIllegalDialect<AsyncDialect>();
|
target.addIllegalDialect<AsyncDialect>();
|
||||||
|
|
||||||
// Add dynamic legality constraints to apply conversions defined above.
|
// Add dynamic legality constraints to apply conversions defined above.
|
||||||
target.addDynamicallyLegalOp<FuncOp>(
|
target.addDynamicallyLegalOp<FuncOp>([&](FuncOp op) {
|
||||||
[&](FuncOp op) { return converter.isSignatureLegal(op.getType()); });
|
return converter.isSignatureLegal(op.getFunctionType());
|
||||||
|
});
|
||||||
target.addDynamicallyLegalOp<func::ReturnOp>([&](func::ReturnOp op) {
|
target.addDynamicallyLegalOp<func::ReturnOp>([&](func::ReturnOp op) {
|
||||||
return converter.isLegal(op.getOperandTypes());
|
return converter.isLegal(op.getOperandTypes());
|
||||||
});
|
});
|
||||||
|
|
|
@ -127,7 +127,7 @@ prependResAttrsToArgAttrs(OpBuilder &builder,
|
||||||
static void wrapForExternalCallers(OpBuilder &rewriter, Location loc,
|
static void wrapForExternalCallers(OpBuilder &rewriter, Location loc,
|
||||||
LLVMTypeConverter &typeConverter,
|
LLVMTypeConverter &typeConverter,
|
||||||
FuncOp funcOp, LLVM::LLVMFuncOp newFuncOp) {
|
FuncOp funcOp, LLVM::LLVMFuncOp newFuncOp) {
|
||||||
auto type = funcOp.getType();
|
auto type = funcOp.getFunctionType();
|
||||||
SmallVector<NamedAttribute, 4> attributes;
|
SmallVector<NamedAttribute, 4> attributes;
|
||||||
filterFuncAttributes(funcOp->getAttrs(), /*filterArgAndResAttrs=*/false,
|
filterFuncAttributes(funcOp->getAttrs(), /*filterArgAndResAttrs=*/false,
|
||||||
attributes);
|
attributes);
|
||||||
|
@ -190,7 +190,7 @@ static void wrapExternalFunction(OpBuilder &builder, Location loc,
|
||||||
Type wrapperType;
|
Type wrapperType;
|
||||||
bool resultIsNowArg;
|
bool resultIsNowArg;
|
||||||
std::tie(wrapperType, 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
|
// 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
|
// 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.
|
// 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());
|
builder.setInsertionPointToStart(newFuncOp.addEntryBlock());
|
||||||
|
|
||||||
// Get a ValueRange containing arguments.
|
// Get a ValueRange containing arguments.
|
||||||
FunctionType type = funcOp.getType();
|
FunctionType type = funcOp.getFunctionType();
|
||||||
SmallVector<Value, 8> args;
|
SmallVector<Value, 8> args;
|
||||||
args.reserve(type.getNumInputs());
|
args.reserve(type.getNumInputs());
|
||||||
ValueRange wrapperArgsRange(newFuncOp.getArguments());
|
ValueRange wrapperArgsRange(newFuncOp.getArguments());
|
||||||
|
@ -288,7 +288,8 @@ protected:
|
||||||
auto varargsAttr = funcOp->getAttrOfType<BoolAttr>("func.varargs");
|
auto varargsAttr = funcOp->getAttrOfType<BoolAttr>("func.varargs");
|
||||||
TypeConverter::SignatureConversion result(funcOp.getNumArguments());
|
TypeConverter::SignatureConversion result(funcOp.getNumArguments());
|
||||||
auto llvmType = getTypeConverter()->convertFunctionSignature(
|
auto llvmType = getTypeConverter()->convertFunctionSignature(
|
||||||
funcOp.getType(), varargsAttr && varargsAttr.getValue(), result);
|
funcOp.getFunctionType(), varargsAttr && varargsAttr.getValue(),
|
||||||
|
result);
|
||||||
if (!llvmType)
|
if (!llvmType)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
@ -401,7 +402,7 @@ struct BarePtrFuncOpConversion : public FuncOpConversionBase {
|
||||||
// Store the type of memref-typed arguments before the conversion so that we
|
// 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.
|
// can promote them to MemRef descriptor at the beginning of the function.
|
||||||
SmallVector<Type, 8> oldArgTypes =
|
SmallVector<Type, 8> oldArgTypes =
|
||||||
llvm::to_vector<8>(funcOp.getType().getInputs());
|
llvm::to_vector<8>(funcOp.getFunctionType().getInputs());
|
||||||
|
|
||||||
auto newFuncOp = convertFuncOpToLLVMFuncOp(funcOp, rewriter);
|
auto newFuncOp = convertFuncOpToLLVMFuncOp(funcOp, rewriter);
|
||||||
if (!newFuncOp)
|
if (!newFuncOp)
|
||||||
|
|
|
@ -41,7 +41,7 @@ GPUFuncOpLowering::matchAndRewrite(gpu::GPUFuncOp gpuFuncOp, OpAdaptor adaptor,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rewrite the original GPU function to an LLVM function.
|
// 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>()
|
.template cast<LLVM::LLVMPointerType>()
|
||||||
.getElementType();
|
.getElementType();
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ GPUFuncOpLowering::matchAndRewrite(gpu::GPUFuncOp gpuFuncOp, OpAdaptor adaptor,
|
||||||
TypeConverter::SignatureConversion signatureConversion(
|
TypeConverter::SignatureConversion signatureConversion(
|
||||||
gpuFuncOp.front().getNumArguments());
|
gpuFuncOp.front().getNumArguments());
|
||||||
getTypeConverter()->convertFunctionSignature(
|
getTypeConverter()->convertFunctionSignature(
|
||||||
gpuFuncOp.getType(), /*isVariadic=*/false, signatureConversion);
|
gpuFuncOp.getFunctionType(), /*isVariadic=*/false, signatureConversion);
|
||||||
|
|
||||||
// Create the new function operation. Only copy those attributes that are
|
// Create the new function operation. Only copy those attributes that are
|
||||||
// not specific to function modeling.
|
// not specific to function modeling.
|
||||||
|
|
|
@ -184,7 +184,7 @@ lowerAsEntryFunction(gpu::GPUFuncOp funcOp, TypeConverter &typeConverter,
|
||||||
ConversionPatternRewriter &rewriter,
|
ConversionPatternRewriter &rewriter,
|
||||||
spirv::EntryPointABIAttr entryPointInfo,
|
spirv::EntryPointABIAttr entryPointInfo,
|
||||||
ArrayRef<spirv::InterfaceVarABIAttr> argABIInfo) {
|
ArrayRef<spirv::InterfaceVarABIAttr> argABIInfo) {
|
||||||
auto fnType = funcOp.getType();
|
auto fnType = funcOp.getFunctionType();
|
||||||
if (fnType.getNumResults()) {
|
if (fnType.getNumResults()) {
|
||||||
funcOp.emitError("SPIR-V lowering only supports entry functions"
|
funcOp.emitError("SPIR-V lowering only supports entry functions"
|
||||||
"with no return values right now");
|
"with no return values right now");
|
||||||
|
@ -201,7 +201,8 @@ lowerAsEntryFunction(gpu::GPUFuncOp funcOp, TypeConverter &typeConverter,
|
||||||
// LowerABIAttributesPass.
|
// LowerABIAttributesPass.
|
||||||
TypeConverter::SignatureConversion signatureConverter(fnType.getNumInputs());
|
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());
|
auto convertedType = typeConverter.convertType(argType.value());
|
||||||
signatureConverter.addInputs(argType.index(), convertedType);
|
signatureConverter.addInputs(argType.index(), convertedType);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ void LinalgToSPIRVPass::runOnOperation() {
|
||||||
// Allow builtin ops.
|
// Allow builtin ops.
|
||||||
target->addLegalOp<ModuleOp>();
|
target->addLegalOp<ModuleOp>();
|
||||||
target->addDynamicallyLegalOp<FuncOp>([&](FuncOp op) {
|
target->addDynamicallyLegalOp<FuncOp>([&](FuncOp op) {
|
||||||
return typeConverter.isSignatureLegal(op.getType()) &&
|
return typeConverter.isSignatureLegal(op.getFunctionType()) &&
|
||||||
typeConverter.isLegal(&op.getBody());
|
typeConverter.isLegal(&op.getBody());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1291,11 +1291,11 @@ public:
|
||||||
|
|
||||||
// Convert function signature. At the moment LLVMType converter is enough
|
// Convert function signature. At the moment LLVMType converter is enough
|
||||||
// for currently supported types.
|
// for currently supported types.
|
||||||
auto funcType = funcOp.getType();
|
auto funcType = funcOp.getFunctionType();
|
||||||
TypeConverter::SignatureConversion signatureConverter(
|
TypeConverter::SignatureConversion signatureConverter(
|
||||||
funcType.getNumInputs());
|
funcType.getNumInputs());
|
||||||
auto llvmType = typeConverter.convertFunctionSignature(
|
auto llvmType = typeConverter.convertFunctionSignature(
|
||||||
funcOp.getType(), /*isVariadic=*/false, signatureConverter);
|
funcType, /*isVariadic=*/false, signatureConverter);
|
||||||
if (!llvmType)
|
if (!llvmType)
|
||||||
return failure();
|
return failure();
|
||||||
|
|
||||||
|
|
|
@ -463,7 +463,8 @@ static FuncOp createAsyncDispatchFunction(ParallelComputeFunction &computeFunc,
|
||||||
|
|
||||||
ModuleOp module = computeFunc.func->getParentOfType<ModuleOp>();
|
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
|
// Compared to the parallel compute function async dispatch function takes
|
||||||
// additional !async.group argument. Also instead of a single `blockIndex` it
|
// 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());
|
resultTypes.reserve(func.getCallableResults().size());
|
||||||
llvm::transform(func.getCallableResults(), std::back_inserter(resultTypes),
|
llvm::transform(func.getCallableResults(), std::back_inserter(resultTypes),
|
||||||
[](Type type) { return ValueType::get(type); });
|
[](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), {});
|
func.insertResult(0, TokenType::get(ctx), {});
|
||||||
for (Block &block : func.getBlocks()) {
|
for (Block &block : func.getBlocks()) {
|
||||||
Operation *terminator = block.getTerminator();
|
Operation *terminator = block.getTerminator();
|
||||||
|
|
|
@ -20,7 +20,7 @@ using namespace mlir;
|
||||||
// Any args appended to the entry block are added to `appendedEntryArgs`.
|
// Any args appended to the entry block are added to `appendedEntryArgs`.
|
||||||
static void updateFuncOp(FuncOp func,
|
static void updateFuncOp(FuncOp func,
|
||||||
SmallVectorImpl<BlockArgument> &appendedEntryArgs) {
|
SmallVectorImpl<BlockArgument> &appendedEntryArgs) {
|
||||||
auto functionType = func.getType();
|
auto functionType = func.getFunctionType();
|
||||||
|
|
||||||
// Collect information about the results will become appended arguments.
|
// Collect information about the results will become appended arguments.
|
||||||
SmallVector<Type, 6> erasedResultTypes;
|
SmallVector<Type, 6> erasedResultTypes;
|
||||||
|
|
|
@ -134,7 +134,7 @@ LogicalResult CallOp::verifySymbolUses(SymbolTableCollection &symbolTable) {
|
||||||
<< "' does not reference a valid function";
|
<< "' does not reference a valid function";
|
||||||
|
|
||||||
// Verify that the operand and result types match the callee.
|
// Verify that the operand and result types match the callee.
|
||||||
auto fnType = fn.getType();
|
auto fnType = fn.getFunctionType();
|
||||||
if (fnType.getNumInputs() != getNumOperands())
|
if (fnType.getNumInputs() != getNumOperands())
|
||||||
return emitOpError("incorrect number of operands for callee");
|
return emitOpError("incorrect number of operands for callee");
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ LogicalResult ConstantOp::verify() {
|
||||||
<< "'";
|
<< "'";
|
||||||
|
|
||||||
// Check that the referenced function has the correct type.
|
// 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 emitOpError("reference to function with mismatched type");
|
||||||
|
|
||||||
return success();
|
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
|
// the function by specifying them in the mapper. If so, we don't add the
|
||||||
// argument to the input type vector.
|
// argument to the input type vector.
|
||||||
if (!isExternal()) {
|
if (!isExternal()) {
|
||||||
FunctionType oldType = getType();
|
FunctionType oldType = getFunctionType();
|
||||||
|
|
||||||
unsigned oldNumArgs = oldType.getNumInputs();
|
unsigned oldNumArgs = oldType.getNumInputs();
|
||||||
SmallVector<Type, 4> newInputs;
|
SmallVector<Type, 4> newInputs;
|
||||||
|
@ -347,7 +347,7 @@ LogicalResult ReturnOp::verify() {
|
||||||
auto function = cast<FuncOp>((*this)->getParentOp());
|
auto function = cast<FuncOp>((*this)->getParentOp());
|
||||||
|
|
||||||
// The operand number and types must match the function signature.
|
// 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())
|
if (getNumOperands() != results.size())
|
||||||
return emitOpError("has ")
|
return emitOpError("has ")
|
||||||
<< getNumOperands() << " operands, but enclosing function (@"
|
<< getNumOperands() << " operands, but enclosing function (@"
|
||||||
|
|
|
@ -64,7 +64,7 @@ struct DecomposeCallGraphTypesForFuncArgs
|
||||||
LogicalResult
|
LogicalResult
|
||||||
matchAndRewrite(FuncOp op, OpAdaptor adaptor,
|
matchAndRewrite(FuncOp op, OpAdaptor adaptor,
|
||||||
ConversionPatternRewriter &rewriter) const final {
|
ConversionPatternRewriter &rewriter) const final {
|
||||||
auto functionType = op.getType();
|
auto functionType = op.getFunctionType();
|
||||||
|
|
||||||
// Convert function arguments using the provided TypeConverter.
|
// Convert function arguments using the provided TypeConverter.
|
||||||
TypeConverter::SignatureConversion conversion(functionType.getNumInputs());
|
TypeConverter::SignatureConversion conversion(functionType.getNumInputs());
|
||||||
|
|
|
@ -35,7 +35,7 @@ struct FuncBufferizePass : public FuncBufferizeBase<FuncBufferizePass> {
|
||||||
populateFunctionOpInterfaceTypeConversionPattern<FuncOp>(patterns,
|
populateFunctionOpInterfaceTypeConversionPattern<FuncOp>(patterns,
|
||||||
typeConverter);
|
typeConverter);
|
||||||
target.addDynamicallyLegalOp<FuncOp>([&](FuncOp op) {
|
target.addDynamicallyLegalOp<FuncOp>([&](FuncOp op) {
|
||||||
return typeConverter.isSignatureLegal(op.getType()) &&
|
return typeConverter.isSignatureLegal(op.getFunctionType()) &&
|
||||||
typeConverter.isLegal(&op.getBody());
|
typeConverter.isLegal(&op.getBody());
|
||||||
});
|
});
|
||||||
populateCallOpTypeConversionPattern(patterns, typeConverter);
|
populateCallOpTypeConversionPattern(patterns, typeConverter);
|
||||||
|
|
|
@ -261,7 +261,7 @@ LogicalResult GPUDialect::verifyOperationAttribute(Operation *op,
|
||||||
<< actualNumArguments << " kernel operands but expected "
|
<< actualNumArguments << " kernel operands but expected "
|
||||||
<< expectedNumArguments;
|
<< expectedNumArguments;
|
||||||
|
|
||||||
auto functionType = kernelGPUFunction.getType();
|
auto functionType = kernelGPUFunction.getFunctionType();
|
||||||
for (unsigned i = 0; i < expectedNumArguments; ++i) {
|
for (unsigned i = 0; i < expectedNumArguments; ++i) {
|
||||||
if (launchOp.getKernelOperand(i).getType() != functionType.getInput(i)) {
|
if (launchOp.getKernelOperand(i).getType() != functionType.getInput(i)) {
|
||||||
return launchOp.emitOpError("type of function argument ")
|
return launchOp.emitOpError("type of function argument ")
|
||||||
|
@ -723,8 +723,8 @@ BlockArgument GPUFuncOp::addWorkgroupAttribution(Type type, Location loc) {
|
||||||
auto attr = (*this)->getAttrOfType<IntegerAttr>(attrName);
|
auto attr = (*this)->getAttrOfType<IntegerAttr>(attrName);
|
||||||
(*this)->setAttr(attrName,
|
(*this)->setAttr(attrName,
|
||||||
IntegerAttr::get(attr.getType(), attr.getValue() + 1));
|
IntegerAttr::get(attr.getType(), attr.getValue() + 1));
|
||||||
return getBody().insertArgument(getType().getNumInputs() + attr.getInt(),
|
return getBody().insertArgument(
|
||||||
type, loc);
|
getFunctionType().getNumInputs() + attr.getInt(), type, loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a new block argument that corresponds to buffers located in
|
/// Adds a new block argument that corresponds to buffers located in
|
||||||
|
@ -880,7 +880,7 @@ void GPUFuncOp::print(OpAsmPrinter &p) {
|
||||||
p << ' ';
|
p << ' ';
|
||||||
p.printSymbolName(getName());
|
p.printSymbolName(getName());
|
||||||
|
|
||||||
FunctionType type = getType();
|
FunctionType type = getFunctionType();
|
||||||
function_interface_impl::printFunctionSignature(p, *this, type.getInputs(),
|
function_interface_impl::printFunctionSignature(p, *this, type.getInputs(),
|
||||||
/*isVariadic=*/false,
|
/*isVariadic=*/false,
|
||||||
type.getResults());
|
type.getResults());
|
||||||
|
@ -899,12 +899,12 @@ void GPUFuncOp::print(OpAsmPrinter &p) {
|
||||||
}
|
}
|
||||||
|
|
||||||
LogicalResult GPUFuncOp::verifyType() {
|
LogicalResult GPUFuncOp::verifyType() {
|
||||||
Type type = getTypeAttr().getValue();
|
Type type = getFunctionTypeAttr().getValue();
|
||||||
if (!type.isa<FunctionType>())
|
if (!type.isa<FunctionType>())
|
||||||
return emitOpError("requires '" + getTypeAttrName() +
|
return emitOpError("requires '" + getTypeAttrName() +
|
||||||
"' attribute of function type");
|
"' attribute of function type");
|
||||||
|
|
||||||
if (isKernel() && getType().getNumResults() != 0)
|
if (isKernel() && getFunctionType().getNumResults() != 0)
|
||||||
return emitOpError() << "expected void return type for kernel function";
|
return emitOpError() << "expected void return type for kernel function";
|
||||||
|
|
||||||
return success();
|
return success();
|
||||||
|
@ -936,7 +936,7 @@ LogicalResult GPUFuncOp::verifyBody() {
|
||||||
<< numFuncArguments + numWorkgroupAttributions
|
<< numFuncArguments + numWorkgroupAttributions
|
||||||
<< " arguments to body region";
|
<< " arguments to body region";
|
||||||
|
|
||||||
ArrayRef<Type> funcArgTypes = getType().getInputs();
|
ArrayRef<Type> funcArgTypes = getFunctionType().getInputs();
|
||||||
for (unsigned i = 0; i < numFuncArguments; ++i) {
|
for (unsigned i = 0; i < numFuncArguments; ++i) {
|
||||||
Type blockArgType = front().getArgument(i).getType();
|
Type blockArgType = front().getArgument(i).getType();
|
||||||
if (funcArgTypes[i] != blockArgType)
|
if (funcArgTypes[i] != blockArgType)
|
||||||
|
@ -961,7 +961,7 @@ LogicalResult GPUFuncOp::verifyBody() {
|
||||||
LogicalResult gpu::ReturnOp::verify() {
|
LogicalResult gpu::ReturnOp::verify() {
|
||||||
GPUFuncOp function = (*this)->getParentOfType<GPUFuncOp>();
|
GPUFuncOp function = (*this)->getParentOfType<GPUFuncOp>();
|
||||||
|
|
||||||
FunctionType funType = function.getType();
|
FunctionType funType = function.getFunctionType();
|
||||||
|
|
||||||
if (funType.getNumResults() != operands().size())
|
if (funType.getNumResults() != operands().size())
|
||||||
return emitOpError()
|
return emitOpError()
|
||||||
|
@ -970,7 +970,7 @@ LogicalResult gpu::ReturnOp::verify() {
|
||||||
.append("return type declared here");
|
.append("return type declared here");
|
||||||
|
|
||||||
for (const auto &pair : llvm::enumerate(
|
for (const auto &pair : llvm::enumerate(
|
||||||
llvm::zip(function.getType().getResults(), operands()))) {
|
llvm::zip(function.getFunctionType().getResults(), operands()))) {
|
||||||
Type type;
|
Type type;
|
||||||
Value operand;
|
Value operand;
|
||||||
std::tie(type, operand) = pair.value();
|
std::tie(type, operand) = pair.value();
|
||||||
|
|
|
@ -1003,7 +1003,7 @@ LogicalResult CallOp::verify() {
|
||||||
return emitOpError() << "'" << calleeName.getValue()
|
return emitOpError() << "'" << calleeName.getValue()
|
||||||
<< "' does not reference a valid LLVM function";
|
<< "' does not reference a valid LLVM function";
|
||||||
|
|
||||||
fnType = fn.getType();
|
fnType = fn.getFunctionType();
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMFunctionType funcType = fnType.dyn_cast<LLVMFunctionType>();
|
LLVMFunctionType funcType = fnType.dyn_cast<LLVMFunctionType>();
|
||||||
|
@ -1499,7 +1499,7 @@ LogicalResult ReturnOp::verify() {
|
||||||
return emitOpError("expected at most 1 operand");
|
return emitOpError("expected at most 1 operand");
|
||||||
|
|
||||||
if (auto parent = (*this)->getParentOfType<LLVMFuncOp>()) {
|
if (auto parent = (*this)->getParentOfType<LLVMFuncOp>()) {
|
||||||
Type expectedType = parent.getType().getReturnType();
|
Type expectedType = parent.getFunctionType().getReturnType();
|
||||||
if (expectedType.isa<LLVMVoidType>()) {
|
if (expectedType.isa<LLVMVoidType>()) {
|
||||||
if (getNumOperands() == 0)
|
if (getNumOperands() == 0)
|
||||||
return success();
|
return success();
|
||||||
|
@ -1571,8 +1571,8 @@ LogicalResult AddressOfOp::verify() {
|
||||||
return emitOpError(
|
return emitOpError(
|
||||||
"the type must be a pointer to the type of the referenced global");
|
"the type must be a pointer to the type of the referenced global");
|
||||||
|
|
||||||
if (function &&
|
if (function && LLVM::LLVMPointerType::get(function.getFunctionType()) !=
|
||||||
LLVM::LLVMPointerType::get(function.getType()) != getResult().getType())
|
getResult().getType())
|
||||||
return emitOpError(
|
return emitOpError(
|
||||||
"the type must be a pointer to the type of the referenced function");
|
"the type must be a pointer to the type of the referenced function");
|
||||||
|
|
||||||
|
@ -1965,7 +1965,7 @@ Block *LLVMFuncOp::addEntryBlock() {
|
||||||
push_back(entry);
|
push_back(entry);
|
||||||
|
|
||||||
// FIXME: Allow passing in proper locations for the entry arguments.
|
// 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)
|
for (unsigned i = 0, e = type.getNumParams(); i < e; ++i)
|
||||||
entry->addArgument(type.getParamType(i), getLoc());
|
entry->addArgument(type.getParamType(i), getLoc());
|
||||||
return entry;
|
return entry;
|
||||||
|
@ -1978,7 +1978,8 @@ void LLVMFuncOp::build(OpBuilder &builder, OperationState &result,
|
||||||
result.addRegion();
|
result.addRegion();
|
||||||
result.addAttribute(SymbolTable::getSymbolAttrName(),
|
result.addAttribute(SymbolTable::getSymbolAttrName(),
|
||||||
builder.getStringAttr(name));
|
builder.getStringAttr(name));
|
||||||
result.addAttribute("type", TypeAttr::get(type));
|
result.addAttribute(getFunctionTypeAttrName(result.name),
|
||||||
|
TypeAttr::get(type));
|
||||||
result.addAttribute(::getLinkageAttrName(),
|
result.addAttribute(::getLinkageAttrName(),
|
||||||
LinkageAttr::get(builder.getContext(), linkage));
|
LinkageAttr::get(builder.getContext(), linkage));
|
||||||
result.attributes.append(attrs.begin(), attrs.end());
|
result.attributes.append(attrs.begin(), attrs.end());
|
||||||
|
@ -2089,7 +2090,7 @@ void LLVMFuncOp::print(OpAsmPrinter &p) {
|
||||||
p << stringifyLinkage(getLinkage()) << ' ';
|
p << stringifyLinkage(getLinkage()) << ' ';
|
||||||
p.printSymbolName(getName());
|
p.printSymbolName(getName());
|
||||||
|
|
||||||
LLVMFunctionType fnType = getType();
|
LLVMFunctionType fnType = getFunctionType();
|
||||||
SmallVector<Type, 8> argTypes;
|
SmallVector<Type, 8> argTypes;
|
||||||
SmallVector<Type, 1> resTypes;
|
SmallVector<Type, 1> resTypes;
|
||||||
argTypes.reserve(fnType.getNumParams());
|
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:
|
// Verifies LLVM- and implementation-specific properties of the LLVM func Op:
|
||||||
// - functions don't have 'common' linkage
|
// - functions don't have 'common' linkage
|
||||||
// - external functions have 'external' or 'extern_weak' 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
|
// 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.
|
// 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()) {
|
!getResultAttrs(0).empty()) {
|
||||||
return emitOpError()
|
return emitOpError()
|
||||||
<< "cannot attach result attributes to functions with a void return";
|
<< "cannot attach result attributes to functions with a void return";
|
||||||
|
@ -2164,7 +2156,7 @@ LogicalResult LLVMFuncOp::verifyRegions() {
|
||||||
if (isExternal())
|
if (isExternal())
|
||||||
return success();
|
return success();
|
||||||
|
|
||||||
unsigned numArguments = getType().getNumParams();
|
unsigned numArguments = getFunctionType().getNumParams();
|
||||||
Block &entryBlock = front();
|
Block &entryBlock = front();
|
||||||
for (unsigned i = 0; i < numArguments; ++i) {
|
for (unsigned i = 0; i < numArguments; ++i) {
|
||||||
Type argType = entryBlock.getArgument(i).getType();
|
Type argType = entryBlock.getArgument(i).getType();
|
||||||
|
|
|
@ -389,8 +389,8 @@ static LogicalResult bufferizeFuncOpBoundary(FuncOp funcOp,
|
||||||
getModuleAnalysisState(state.getAnalysisState());
|
getModuleAnalysisState(state.getAnalysisState());
|
||||||
|
|
||||||
// If nothing to do then we are done.
|
// If nothing to do then we are done.
|
||||||
if (!llvm::any_of(funcOp.getType().getInputs(), isaTensor) &&
|
if (!llvm::any_of(funcOp.getFunctionType().getInputs(), isaTensor) &&
|
||||||
!llvm::any_of(funcOp.getType().getResults(), isaTensor))
|
!llvm::any_of(funcOp.getFunctionType().getResults(), isaTensor))
|
||||||
return success();
|
return success();
|
||||||
|
|
||||||
// Get the bufferized FunctionType for funcOp or construct it if not yet
|
// 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.
|
// bufferization contract they want to enforce atm.
|
||||||
// As a consequence, only support functions that don't return any tensor atm.
|
// As a consequence, only support functions that don't return any tensor atm.
|
||||||
if (funcOp.getBody().empty()) {
|
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 "
|
return funcOp->emitError() << "cannot bufferize bodiless function that "
|
||||||
<< "returns a tensor";
|
<< "returns a tensor";
|
||||||
FunctionType bufferizedFuncType = getBufferizedFunctionType(
|
FunctionType bufferizedFuncType = getBufferizedFunctionType(
|
||||||
funcOp.getContext(), funcOp.getType().getInputs(), TypeRange{},
|
funcOp.getContext(), funcOp.getFunctionType().getInputs(), TypeRange{},
|
||||||
state.getOptions());
|
state.getOptions());
|
||||||
funcOp.setType(bufferizedFuncType);
|
funcOp.setType(bufferizedFuncType);
|
||||||
return success();
|
return success();
|
||||||
|
@ -451,8 +451,8 @@ static LogicalResult bufferizeFuncOpBoundary(FuncOp funcOp,
|
||||||
// 2. Rewrite the terminator without the inPlace bufferizable values.
|
// 2. Rewrite the terminator without the inPlace bufferizable values.
|
||||||
ValueRange retValues{returnValues};
|
ValueRange retValues{returnValues};
|
||||||
FunctionType bufferizedFuncType = getBufferizedFunctionType(
|
FunctionType bufferizedFuncType = getBufferizedFunctionType(
|
||||||
funcOp.getContext(), funcOp.getType().getInputs(), retValues.getTypes(),
|
funcOp.getContext(), funcOp.getFunctionType().getInputs(),
|
||||||
state.getOptions());
|
retValues.getTypes(), state.getOptions());
|
||||||
OpBuilder b(returnOp);
|
OpBuilder b(returnOp);
|
||||||
b.create<func::ReturnOp>(returnOp.getLoc(), returnValues);
|
b.create<func::ReturnOp>(returnOp.getLoc(), returnValues);
|
||||||
returnOp->erase();
|
returnOp->erase();
|
||||||
|
@ -598,7 +598,8 @@ static void layoutPostProcessing(ModuleOp moduleOp) {
|
||||||
SmallVector<Type> argumentTypes;
|
SmallVector<Type> argumentTypes;
|
||||||
// Iterate on each function argument and check it it was marked with a
|
// Iterate on each function argument and check it it was marked with a
|
||||||
// desired layout.
|
// desired layout.
|
||||||
for (const auto &it : llvm::enumerate(funcOp.getType().getInputs())) {
|
for (const auto &it :
|
||||||
|
llvm::enumerate(funcOp.getFunctionType().getInputs())) {
|
||||||
int argNumber = it.index();
|
int argNumber = it.index();
|
||||||
Type inputType = it.value();
|
Type inputType = it.value();
|
||||||
auto memrefType = inputType.dyn_cast<MemRefType>();
|
auto memrefType = inputType.dyn_cast<MemRefType>();
|
||||||
|
@ -661,7 +662,7 @@ static void layoutPostProcessing(ModuleOp moduleOp) {
|
||||||
|
|
||||||
// Finally set the funcOp type to update the arguments.
|
// Finally set the funcOp type to update the arguments.
|
||||||
auto newFuncType = FunctionType::get(moduleOp.getContext(), argumentTypes,
|
auto newFuncType = FunctionType::get(moduleOp.getContext(), argumentTypes,
|
||||||
funcOp.getType().getResults());
|
funcOp.getFunctionType().getResults());
|
||||||
funcOp.setType(newFuncType);
|
funcOp.setType(newFuncType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1046,7 +1047,7 @@ LogicalResult mlir::linalg::comprehensive_bufferize::runModuleBufferize(
|
||||||
return failure();
|
return failure();
|
||||||
|
|
||||||
if (!options.allowReturnAllocs &&
|
if (!options.allowReturnAllocs &&
|
||||||
llvm::any_of(funcOp.getType().getResults(), [](Type t) {
|
llvm::any_of(funcOp.getFunctionType().getResults(), [](Type t) {
|
||||||
return t.isa<MemRefType, UnrankedMemRefType>();
|
return t.isa<MemRefType, UnrankedMemRefType>();
|
||||||
})) {
|
})) {
|
||||||
funcOp->emitError("memref return type is unsupported");
|
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.
|
/// returned value is in turn used in ReturnOp of the calling function.
|
||||||
void NormalizeMemRefs::updateFunctionSignature(FuncOp funcOp,
|
void NormalizeMemRefs::updateFunctionSignature(FuncOp funcOp,
|
||||||
ModuleOp moduleOp) {
|
ModuleOp moduleOp) {
|
||||||
FunctionType functionType = funcOp.getType();
|
FunctionType functionType = funcOp.getFunctionType();
|
||||||
SmallVector<Type, 4> resultTypes;
|
SmallVector<Type, 4> resultTypes;
|
||||||
FunctionType newFuncType;
|
FunctionType newFuncType;
|
||||||
resultTypes = llvm::to_vector<4>(functionType.getResults());
|
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.
|
// We use this OpBuilder to create new memref layout later.
|
||||||
OpBuilder b(funcOp);
|
OpBuilder b(funcOp);
|
||||||
|
|
||||||
FunctionType functionType = funcOp.getType();
|
FunctionType functionType = funcOp.getFunctionType();
|
||||||
SmallVector<Location> functionArgLocs(llvm::map_range(
|
SmallVector<Location> functionArgLocs(llvm::map_range(
|
||||||
funcOp.getArguments(), [](BlockArgument arg) { return arg.getLoc(); }));
|
funcOp.getArguments(), [](BlockArgument arg) { return arg.getLoc(); }));
|
||||||
SmallVector<Type, 8> inputTypes;
|
SmallVector<Type, 8> inputTypes;
|
||||||
|
|
|
@ -2245,7 +2245,7 @@ void spirv::FuncOp::print(OpAsmPrinter &printer) {
|
||||||
// Print function name, signature, and control.
|
// Print function name, signature, and control.
|
||||||
printer << " ";
|
printer << " ";
|
||||||
printer.printSymbolName(sym_name());
|
printer.printSymbolName(sym_name());
|
||||||
auto fnType = getType();
|
auto fnType = getFunctionType();
|
||||||
function_interface_impl::printFunctionSignature(
|
function_interface_impl::printFunctionSignature(
|
||||||
printer, *this, fnType.getInputs(),
|
printer, *this, fnType.getInputs(),
|
||||||
/*isVariadic=*/false, fnType.getResults());
|
/*isVariadic=*/false, fnType.getResults());
|
||||||
|
@ -2265,17 +2265,17 @@ void spirv::FuncOp::print(OpAsmPrinter &printer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
LogicalResult spirv::FuncOp::verifyType() {
|
LogicalResult spirv::FuncOp::verifyType() {
|
||||||
auto type = getTypeAttr().getValue();
|
auto type = getFunctionTypeAttr().getValue();
|
||||||
if (!type.isa<FunctionType>())
|
if (!type.isa<FunctionType>())
|
||||||
return emitOpError("requires '" + getTypeAttrName() +
|
return emitOpError("requires '" + getTypeAttrName() +
|
||||||
"' attribute of function type");
|
"' attribute of function type");
|
||||||
if (getType().getNumResults() > 1)
|
if (getFunctionType().getNumResults() > 1)
|
||||||
return emitOpError("cannot have more than one result");
|
return emitOpError("cannot have more than one result");
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
LogicalResult spirv::FuncOp::verifyBody() {
|
LogicalResult spirv::FuncOp::verifyBody() {
|
||||||
FunctionType fnType = getType();
|
FunctionType fnType = getFunctionType();
|
||||||
|
|
||||||
auto walkResult = walk([fnType](Operation *op) -> WalkResult {
|
auto walkResult = walk([fnType](Operation *op) -> WalkResult {
|
||||||
if (auto retOp = dyn_cast<spirv::ReturnOp>(op)) {
|
if (auto retOp = dyn_cast<spirv::ReturnOp>(op)) {
|
||||||
|
@ -2322,7 +2322,7 @@ Region *spirv::FuncOp::getCallableRegion() {
|
||||||
|
|
||||||
// CallableOpInterface
|
// CallableOpInterface
|
||||||
ArrayRef<Type> spirv::FuncOp::getCallableResults() {
|
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";
|
<< fnName.getValue() << "' not found in nearest symbol table";
|
||||||
}
|
}
|
||||||
|
|
||||||
auto functionType = funcOp.getType();
|
auto functionType = funcOp.getFunctionType();
|
||||||
|
|
||||||
if (getNumResults() > 1) {
|
if (getNumResults() > 1) {
|
||||||
return emitOpError(
|
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
|
// 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
|
// info create a variable of type !spv.ptr<!spv.struct<elementType>>. If not
|
||||||
// it must already be a !spv.ptr<!spv.struct<...>>.
|
// 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()) {
|
if (varType.cast<spirv::SPIRVType>().isScalarOrVector()) {
|
||||||
auto storageClass = abiInfo.getStorageClass();
|
auto storageClass = abiInfo.getStorageClass();
|
||||||
if (!storageClass)
|
if (!storageClass)
|
||||||
|
@ -179,13 +179,14 @@ LogicalResult ProcessInterfaceVarABI::matchAndRewrite(
|
||||||
return failure();
|
return failure();
|
||||||
}
|
}
|
||||||
TypeConverter::SignatureConversion signatureConverter(
|
TypeConverter::SignatureConversion signatureConverter(
|
||||||
funcOp.getType().getNumInputs());
|
funcOp.getFunctionType().getNumInputs());
|
||||||
|
|
||||||
auto &typeConverter = *getTypeConverter<SPIRVTypeConverter>();
|
auto &typeConverter = *getTypeConverter<SPIRVTypeConverter>();
|
||||||
auto indexType = typeConverter.getIndexType();
|
auto indexType = typeConverter.getIndexType();
|
||||||
|
|
||||||
auto attrName = spirv::getInterfaceVarABIAttrName();
|
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>(
|
auto abiInfo = funcOp.getArgAttrOfType<spirv::InterfaceVarABIAttr>(
|
||||||
argType.index(), attrName);
|
argType.index(), attrName);
|
||||||
if (!abiInfo) {
|
if (!abiInfo) {
|
||||||
|
|
|
@ -553,7 +553,7 @@ public:
|
||||||
LogicalResult
|
LogicalResult
|
||||||
FuncOpConversion::matchAndRewrite(FuncOp funcOp, OpAdaptor adaptor,
|
FuncOpConversion::matchAndRewrite(FuncOp funcOp, OpAdaptor adaptor,
|
||||||
ConversionPatternRewriter &rewriter) const {
|
ConversionPatternRewriter &rewriter) const {
|
||||||
auto fnType = funcOp.getType();
|
auto fnType = funcOp.getFunctionType();
|
||||||
if (fnType.getNumResults() > 1)
|
if (fnType.getNumResults() > 1)
|
||||||
return failure();
|
return failure();
|
||||||
|
|
||||||
|
|
|
@ -83,8 +83,9 @@ struct SparseTensorConversionPass
|
||||||
// All dynamic rules below accept new function, call, return, and tensor
|
// All dynamic rules below accept new function, call, return, and tensor
|
||||||
// dim and cast operations as legal output of the rewriting provided that
|
// dim and cast operations as legal output of the rewriting provided that
|
||||||
// all sparse tensor types have been fully rewritten.
|
// all sparse tensor types have been fully rewritten.
|
||||||
target.addDynamicallyLegalOp<FuncOp>(
|
target.addDynamicallyLegalOp<FuncOp>([&](FuncOp op) {
|
||||||
[&](FuncOp op) { return converter.isSignatureLegal(op.getType()); });
|
return converter.isSignatureLegal(op.getFunctionType());
|
||||||
|
});
|
||||||
target.addDynamicallyLegalOp<func::CallOp>([&](func::CallOp op) {
|
target.addDynamicallyLegalOp<func::CallOp>([&](func::CallOp op) {
|
||||||
return converter.isSignatureLegal(op.getCalleeType());
|
return converter.isSignatureLegal(op.getCalleeType());
|
||||||
});
|
});
|
||||||
|
|
|
@ -293,7 +293,7 @@ public:
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rewriter.setInsertionPoint(op);
|
rewriter.setInsertionPoint(op);
|
||||||
FunctionType funcTy = func.getType();
|
FunctionType funcTy = func.getFunctionType();
|
||||||
auto resultTys = funcTy.getResults();
|
auto resultTys = funcTy.getResults();
|
||||||
|
|
||||||
bool castAdded = false;
|
bool castAdded = false;
|
||||||
|
|
|
@ -252,7 +252,7 @@ template <typename Type>
|
||||||
Error checkCompatibleReturnType(LLVM::LLVMFuncOp mainFunction);
|
Error checkCompatibleReturnType(LLVM::LLVMFuncOp mainFunction);
|
||||||
template <>
|
template <>
|
||||||
Error checkCompatibleReturnType<int32_t>(LLVM::LLVMFuncOp mainFunction) {
|
Error checkCompatibleReturnType<int32_t>(LLVM::LLVMFuncOp mainFunction) {
|
||||||
auto resultType = mainFunction.getType()
|
auto resultType = mainFunction.getFunctionType()
|
||||||
.cast<LLVM::LLVMFunctionType>()
|
.cast<LLVM::LLVMFunctionType>()
|
||||||
.getReturnType()
|
.getReturnType()
|
||||||
.dyn_cast<IntegerType>();
|
.dyn_cast<IntegerType>();
|
||||||
|
@ -262,7 +262,7 @@ Error checkCompatibleReturnType<int32_t>(LLVM::LLVMFuncOp mainFunction) {
|
||||||
}
|
}
|
||||||
template <>
|
template <>
|
||||||
Error checkCompatibleReturnType<int64_t>(LLVM::LLVMFuncOp mainFunction) {
|
Error checkCompatibleReturnType<int64_t>(LLVM::LLVMFuncOp mainFunction) {
|
||||||
auto resultType = mainFunction.getType()
|
auto resultType = mainFunction.getFunctionType()
|
||||||
.cast<LLVM::LLVMFunctionType>()
|
.cast<LLVM::LLVMFunctionType>()
|
||||||
.getReturnType()
|
.getReturnType()
|
||||||
.dyn_cast<IntegerType>();
|
.dyn_cast<IntegerType>();
|
||||||
|
@ -272,7 +272,7 @@ Error checkCompatibleReturnType<int64_t>(LLVM::LLVMFuncOp mainFunction) {
|
||||||
}
|
}
|
||||||
template <>
|
template <>
|
||||||
Error checkCompatibleReturnType<float>(LLVM::LLVMFuncOp mainFunction) {
|
Error checkCompatibleReturnType<float>(LLVM::LLVMFuncOp mainFunction) {
|
||||||
if (!mainFunction.getType()
|
if (!mainFunction.getFunctionType()
|
||||||
.cast<LLVM::LLVMFunctionType>()
|
.cast<LLVM::LLVMFunctionType>()
|
||||||
.getReturnType()
|
.getReturnType()
|
||||||
.isa<Float32Type>())
|
.isa<Float32Type>())
|
||||||
|
@ -287,7 +287,9 @@ Error compileAndExecuteSingleReturnFunction(Options &options, ModuleOp module,
|
||||||
if (!mainFunction || mainFunction.isExternal())
|
if (!mainFunction || mainFunction.isExternal())
|
||||||
return makeStringError("entry point not found");
|
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");
|
return makeStringError("function inputs not supported");
|
||||||
|
|
||||||
if (Error error = checkCompatibleReturnType<Type>(mainFunction))
|
if (Error error = checkCompatibleReturnType<Type>(mainFunction))
|
||||||
|
|
|
@ -585,7 +585,7 @@ static LogicalResult printOperation(CppEmitter &emitter, FuncOp functionOp) {
|
||||||
CppEmitter::Scope scope(emitter);
|
CppEmitter::Scope scope(emitter);
|
||||||
raw_indented_ostream &os = emitter.ostream();
|
raw_indented_ostream &os = emitter.ostream();
|
||||||
if (failed(emitter.emitTypes(functionOp.getLoc(),
|
if (failed(emitter.emitTypes(functionOp.getLoc(),
|
||||||
functionOp.getType().getResults())))
|
functionOp.getFunctionType().getResults())))
|
||||||
return failure();
|
return failure();
|
||||||
os << " " << functionOp.getName();
|
os << " " << functionOp.getName();
|
||||||
|
|
||||||
|
|
|
@ -912,7 +912,7 @@ LogicalResult ModuleTranslation::convertFunctionSignatures() {
|
||||||
for (auto function : getModuleBody(mlirModule).getOps<LLVMFuncOp>()) {
|
for (auto function : getModuleBody(mlirModule).getOps<LLVMFuncOp>()) {
|
||||||
llvm::FunctionCallee llvmFuncCst = llvmModule->getOrInsertFunction(
|
llvm::FunctionCallee llvmFuncCst = llvmModule->getOrInsertFunction(
|
||||||
function.getName(),
|
function.getName(),
|
||||||
cast<llvm::FunctionType>(convertType(function.getType())));
|
cast<llvm::FunctionType>(convertType(function.getFunctionType())));
|
||||||
llvm::Function *llvmFunc = cast<llvm::Function>(llvmFuncCst.getCallee());
|
llvm::Function *llvmFunc = cast<llvm::Function>(llvmFuncCst.getCallee());
|
||||||
llvmFunc->setLinkage(convertLinkageToLLVM(function.getLinkage()));
|
llvmFunc->setLinkage(convertLinkageToLLVM(function.getLinkage()));
|
||||||
mapFunction(function.getName(), llvmFunc);
|
mapFunction(function.getName(), llvmFunc);
|
||||||
|
|
|
@ -180,13 +180,13 @@ LogicalResult Serializer::processFuncOp(spirv::FuncOp op) {
|
||||||
|
|
||||||
uint32_t fnTypeID = 0;
|
uint32_t fnTypeID = 0;
|
||||||
// Generate type of the function.
|
// Generate type of the function.
|
||||||
if (failed(processType(op.getLoc(), op.getType(), fnTypeID)))
|
if (failed(processType(op.getLoc(), op.getFunctionType(), fnTypeID)))
|
||||||
return failure();
|
return failure();
|
||||||
|
|
||||||
// Add the function definition.
|
// Add the function definition.
|
||||||
SmallVector<uint32_t, 4> operands;
|
SmallVector<uint32_t, 4> operands;
|
||||||
uint32_t resTypeID = 0;
|
uint32_t resTypeID = 0;
|
||||||
auto resultTypes = op.getType().getResults();
|
auto resultTypes = op.getFunctionType().getResults();
|
||||||
if (resultTypes.size() > 1) {
|
if (resultTypes.size() > 1) {
|
||||||
return op.emitError("cannot serialize function with multiple return types");
|
return op.emitError("cannot serialize function with multiple return types");
|
||||||
}
|
}
|
||||||
|
|
|
@ -3074,7 +3074,7 @@ struct FunctionOpInterfaceSignatureConversion : public ConversionPattern {
|
||||||
matchAndRewrite(Operation *op, ArrayRef<Value> operands,
|
matchAndRewrite(Operation *op, ArrayRef<Value> operands,
|
||||||
ConversionPatternRewriter &rewriter) const override {
|
ConversionPatternRewriter &rewriter) const override {
|
||||||
FunctionOpInterface funcOp = cast<FunctionOpInterface>(op);
|
FunctionOpInterface funcOp = cast<FunctionOpInterface>(op);
|
||||||
FunctionType type = funcOp.getType().cast<FunctionType>();
|
FunctionType type = funcOp.getFunctionType().cast<FunctionType>();
|
||||||
|
|
||||||
// Convert the original function types.
|
// Convert the original function types.
|
||||||
TypeConverter::SignatureConversion result(type.getNumInputs());
|
TypeConverter::SignatureConversion result(type.getNumInputs());
|
||||||
|
|
|
@ -74,7 +74,7 @@ class FuncOp:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def type(self):
|
def type(self):
|
||||||
return FunctionType(TypeAttr(self.attributes["type"]).value)
|
return FunctionType(TypeAttr(self.attributes["function_type"]).value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def visibility(self):
|
def visibility(self):
|
||||||
|
@ -211,7 +211,7 @@ class FuncOp:
|
||||||
# Recompute the function type.
|
# Recompute the function type.
|
||||||
return_types = [v.type for v in return_values]
|
return_types = [v.type for v in return_values]
|
||||||
function_type = FunctionType.get(inputs=inputs, results=return_types)
|
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):
|
def emit_call_op(*call_args):
|
||||||
call_op = func.CallOp(return_types, FlatSymbolRefAttr.get(symbol_name),
|
call_op = func.CallOp(return_types, FlatSymbolRefAttr.get(symbol_name),
|
||||||
|
|
|
@ -95,7 +95,8 @@ MlirModule makeAndDumpAdd(MlirContext ctx, MlirLocation location) {
|
||||||
mlirAttributeParseGet(ctx, mlirStringRefCreateFromCString("\"add\""));
|
mlirAttributeParseGet(ctx, mlirStringRefCreateFromCString("\"add\""));
|
||||||
MlirNamedAttribute funcAttrs[] = {
|
MlirNamedAttribute funcAttrs[] = {
|
||||||
mlirNamedAttributeGet(
|
mlirNamedAttributeGet(
|
||||||
mlirIdentifierGet(ctx, mlirStringRefCreateFromCString("type")),
|
mlirIdentifierGet(ctx,
|
||||||
|
mlirStringRefCreateFromCString("function_type")),
|
||||||
funcTypeAttr),
|
funcTypeAttr),
|
||||||
mlirNamedAttributeGet(
|
mlirNamedAttributeGet(
|
||||||
mlirIdentifierGet(ctx, mlirStringRefCreateFromCString("sym_name")),
|
mlirIdentifierGet(ctx, mlirStringRefCreateFromCString("sym_name")),
|
||||||
|
|
|
@ -331,10 +331,10 @@ module {
|
||||||
|
|
||||||
module {
|
module {
|
||||||
gpu.module @gpu_funcs {
|
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.func"() ({
|
||||||
gpu.return
|
gpu.return
|
||||||
}) {sym_name="kernel_1", type=f32} : () -> ()
|
}) {sym_name="kernel_1", function_type=f32} : () -> ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,7 +415,7 @@ module {
|
||||||
"gpu.func"() ({
|
"gpu.func"() ({
|
||||||
^bb0(%arg0: f32, %arg1: memref<?xf32>, %arg2: memref<5xf32, 3>, %arg3: memref<5xf32, 5>):
|
^bb0(%arg0: f32, %arg1: memref<?xf32>, %arg2: memref<5xf32, 3>, %arg3: memref<5xf32, 5>):
|
||||||
"gpu.return"() : () -> ()
|
"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"() ({
|
"gpu.func"() ({
|
||||||
^bb0(%arg0: f32, %arg1: memref<?xf32>, %arg2: memref<5xf32, 3>, %arg3: memref<5xf32, 5>):
|
^bb0(%arg0: f32, %arg1: memref<?xf32>, %arg2: memref<5xf32, 3>, %arg3: memref<5xf32, 5>):
|
||||||
"gpu.return"() : () -> ()
|
"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() {
|
func @alloc() {
|
||||||
|
|
|
@ -3,20 +3,20 @@
|
||||||
|
|
||||||
module {
|
module {
|
||||||
// GENERIC: "llvm.func"
|
// GENERIC: "llvm.func"
|
||||||
// GENERIC: sym_name = "foo"
|
// GENERIC: function_type = !llvm.func<void ()>
|
||||||
// GENERIC-SAME: type = !llvm.func<void ()>
|
// GENERIC-SAME: sym_name = "foo"
|
||||||
// GENERIC-SAME: () -> ()
|
// GENERIC-SAME: () -> ()
|
||||||
// CHECK: llvm.func @foo()
|
// CHECK: llvm.func @foo()
|
||||||
"llvm.func"() ({
|
"llvm.func"() ({
|
||||||
}) {sym_name = "foo", type = !llvm.func<void ()>} : () -> ()
|
}) {sym_name = "foo", function_type = !llvm.func<void ()>} : () -> ()
|
||||||
|
|
||||||
// GENERIC: "llvm.func"
|
// GENERIC: "llvm.func"
|
||||||
// GENERIC: sym_name = "bar"
|
// GENERIC: function_type = !llvm.func<i64 (i64, i64)>
|
||||||
// GENERIC-SAME: type = !llvm.func<i64 (i64, i64)>
|
// GENERIC-SAME: sym_name = "bar"
|
||||||
// GENERIC-SAME: () -> ()
|
// GENERIC-SAME: () -> ()
|
||||||
// CHECK: llvm.func @bar(i64, i64) -> i64
|
// CHECK: llvm.func @bar(i64, i64) -> i64
|
||||||
"llvm.func"() ({
|
"llvm.func"() ({
|
||||||
}) {sym_name = "bar", type = !llvm.func<i64 (i64, i64)>} : () -> ()
|
}) {sym_name = "bar", function_type = !llvm.func<i64 (i64, i64)>} : () -> ()
|
||||||
|
|
||||||
// GENERIC: "llvm.func"
|
// GENERIC: "llvm.func"
|
||||||
// CHECK: llvm.func @baz(%{{.*}}: i64) -> i64
|
// CHECK: llvm.func @baz(%{{.*}}: i64) -> i64
|
||||||
|
@ -26,15 +26,15 @@ module {
|
||||||
// GENERIC: llvm.return
|
// GENERIC: llvm.return
|
||||||
llvm.return %arg0 : i64
|
llvm.return %arg0 : i64
|
||||||
|
|
||||||
// GENERIC: sym_name = "baz"
|
// GENERIC: function_type = !llvm.func<i64 (i64)>
|
||||||
// GENERIC-SAME: type = !llvm.func<i64 (i64)>
|
// GENERIC-SAME: sym_name = "baz"
|
||||||
// GENERIC-SAME: () -> ()
|
// 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: llvm.func @qux(!llvm.ptr<i64> {llvm.noalias}, i64)
|
||||||
// CHECK: attributes {xxx = {yyy = 42 : i64}}
|
// CHECK: attributes {xxx = {yyy = 42 : i64}}
|
||||||
"llvm.func"() ({
|
"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}} : () -> ()
|
arg_attrs = [{llvm.noalias}, {}], xxx = {yyy = 42}} : () -> ()
|
||||||
|
|
||||||
// CHECK: llvm.func @roundtrip1()
|
// CHECK: llvm.func @roundtrip1()
|
||||||
|
@ -143,28 +143,28 @@ module {
|
||||||
|
|
||||||
module {
|
module {
|
||||||
// expected-error@+1 {{requires one region}}
|
// 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 {
|
module {
|
||||||
// expected-error@+1 {{requires a type attribute 'type'}}
|
// expected-error@+1 {{requires attribute 'function_type'}}
|
||||||
"llvm.func"() ({}) {sym_name = "missing_type"} : () -> ()
|
"llvm.func"() ({}) {sym_name = "missing_type"} : () -> ()
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----
|
// -----
|
||||||
|
|
||||||
module {
|
module {
|
||||||
// expected-error@+1 {{requires 'type' attribute of wrapped LLVM function type}}
|
// expected-error@+1 {{attribute 'function_type' failed to satisfy constraint: type attribute of LLVM function type}}
|
||||||
"llvm.func"() ({}) {sym_name = "non_llvm_type", type = i64} : () -> ()
|
"llvm.func"() ({}) {sym_name = "non_llvm_type", function_type = i64} : () -> ()
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----
|
// -----
|
||||||
|
|
||||||
module {
|
module {
|
||||||
// expected-error@+1 {{requires 'type' attribute of wrapped LLVM function type}}
|
// expected-error@+1 {{attribute 'function_type' failed to satisfy constraint: type attribute of LLVM function type}}
|
||||||
"llvm.func"() ({}) {sym_name = "non_function_type", type = i64} : () -> ()
|
"llvm.func"() ({}) {sym_name = "non_function_type", function_type = i64} : () -> ()
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----
|
// -----
|
||||||
|
@ -174,7 +174,7 @@ module {
|
||||||
"llvm.func"() ({
|
"llvm.func"() ({
|
||||||
^bb0(%arg0: i64):
|
^bb0(%arg0: i64):
|
||||||
llvm.return
|
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"() ({
|
"llvm.func"() ({
|
||||||
^bb0(%arg0: tensor<*xf32>):
|
^bb0(%arg0: tensor<*xf32>):
|
||||||
llvm.return
|
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}}
|
// 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 { type = "x" }
|
func private @invalid_symbol_type_attr() attributes { function_type = "x" }
|
||||||
|
|
||||||
// -----
|
// -----
|
||||||
|
|
||||||
|
|
|
@ -1416,7 +1416,7 @@ test.graph_region {
|
||||||
%1 = "foo"(%1, %2) : (i64, i64) -> i64
|
%1 = "foo"(%1, %2) : (i64, i64) -> i64
|
||||||
%2 = "bar"(%1) : (i64) -> i64
|
%2 = "bar"(%1) : (i64) -> i64
|
||||||
"unregistered_terminator"() : () -> ()
|
"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.
|
// This is an unregister operation, the printing/parsing is handled by the dialect.
|
||||||
// CHECK: test.dialect_custom_printer custom_format
|
// CHECK: test.dialect_custom_printer custom_format
|
||||||
|
|
|
@ -49,7 +49,7 @@ struct TestDecomposeCallGraphTypes
|
||||||
target.addDynamicallyLegalOp<func::CallOp>(
|
target.addDynamicallyLegalOp<func::CallOp>(
|
||||||
[&](func::CallOp op) { return typeConverter.isLegal(op); });
|
[&](func::CallOp op) { return typeConverter.isLegal(op); });
|
||||||
target.addDynamicallyLegalOp<FuncOp>([&](FuncOp op) {
|
target.addDynamicallyLegalOp<FuncOp>([&](FuncOp op) {
|
||||||
return typeConverter.isSignatureLegal(op.getType());
|
return typeConverter.isSignatureLegal(op.getFunctionType());
|
||||||
});
|
});
|
||||||
|
|
||||||
typeConverter.addConversion([](Type type) { return type; });
|
typeConverter.addConversion([](Type type) { return type; });
|
||||||
|
|
|
@ -676,7 +676,7 @@ struct TestLegalizePatternDriver
|
||||||
[](Type type) { return type.isF32(); });
|
[](Type type) { return type.isF32(); });
|
||||||
});
|
});
|
||||||
target.addDynamicallyLegalOp<FuncOp>([&](FuncOp op) {
|
target.addDynamicallyLegalOp<FuncOp>([&](FuncOp op) {
|
||||||
return converter.isSignatureLegal(op.getType()) &&
|
return converter.isSignatureLegal(op.getFunctionType()) &&
|
||||||
converter.isLegal(&op.getBody());
|
converter.isLegal(&op.getBody());
|
||||||
});
|
});
|
||||||
target.addDynamicallyLegalOp<func::CallOp>(
|
target.addDynamicallyLegalOp<func::CallOp>(
|
||||||
|
@ -1106,7 +1106,7 @@ struct TestTypeConversionDriver
|
||||||
recursiveType.getName() == "outer_converted_type");
|
recursiveType.getName() == "outer_converted_type");
|
||||||
});
|
});
|
||||||
target.addDynamicallyLegalOp<FuncOp>([&](FuncOp op) {
|
target.addDynamicallyLegalOp<FuncOp>([&](FuncOp op) {
|
||||||
return converter.isSignatureLegal(op.getType()) &&
|
return converter.isSignatureLegal(op.getFunctionType()) &&
|
||||||
converter.isLegal(&op.getBody());
|
converter.isLegal(&op.getBody());
|
||||||
});
|
});
|
||||||
target.addDynamicallyLegalOp<TestCastOp>([&](TestCastOp op) {
|
target.addDynamicallyLegalOp<TestCastOp>([&](TestCastOp op) {
|
||||||
|
|
|
@ -134,8 +134,8 @@ struct TestFuncSetType
|
||||||
auto sym = func->getAttrOfType<FlatSymbolRefAttr>("test.set_type_from");
|
auto sym = func->getAttrOfType<FlatSymbolRefAttr>("test.set_type_from");
|
||||||
if (!sym)
|
if (!sym)
|
||||||
continue;
|
continue;
|
||||||
func.setType(
|
func.setType(symbolTable.lookup<FunctionOpInterface>(sym.getValue())
|
||||||
symbolTable.lookup<FunctionOpInterface>(sym.getValue()).getType());
|
.getFunctionType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -29,8 +29,8 @@ static LogicalResult createBackwardSliceFunction(Operation *op,
|
||||||
OpBuilder builder(parentFuncOp);
|
OpBuilder builder(parentFuncOp);
|
||||||
Location loc = op->getLoc();
|
Location loc = op->getLoc();
|
||||||
std::string clonedFuncOpName = parentFuncOp.getName().str() + suffix.str();
|
std::string clonedFuncOpName = parentFuncOp.getName().str() + suffix.str();
|
||||||
FuncOp clonedFuncOp =
|
FuncOp clonedFuncOp = builder.create<FuncOp>(loc, clonedFuncOpName,
|
||||||
builder.create<FuncOp>(loc, clonedFuncOpName, parentFuncOp.getType());
|
parentFuncOp.getFunctionType());
|
||||||
BlockAndValueMapping mapper;
|
BlockAndValueMapping mapper;
|
||||||
builder.setInsertionPointToEnd(clonedFuncOp.addEntryBlock());
|
builder.setInsertionPointToEnd(clonedFuncOp.addEntryBlock());
|
||||||
for (const auto &arg : enumerate(parentFuncOp.getArguments()))
|
for (const auto &arg : enumerate(parentFuncOp.getArguments()))
|
||||||
|
|
|
@ -114,7 +114,7 @@
|
||||||
// CHECK-NEXT: "result": {
|
// CHECK-NEXT: "result": {
|
||||||
// CHECK-NEXT: "contents": {
|
// CHECK-NEXT: "contents": {
|
||||||
// CHECK-NEXT: "kind": "markdown",
|
// 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: },
|
||||||
// CHECK-NEXT: "range": {
|
// CHECK-NEXT: "range": {
|
||||||
// CHECK-NEXT: "end": {
|
// CHECK-NEXT: "end": {
|
||||||
|
@ -138,7 +138,7 @@
|
||||||
// CHECK-NEXT: "result": {
|
// CHECK-NEXT: "result": {
|
||||||
// CHECK-NEXT: "contents": {
|
// CHECK-NEXT: "contents": {
|
||||||
// CHECK-NEXT: "kind": "markdown",
|
// 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: },
|
||||||
// CHECK-NEXT: "range": {
|
// CHECK-NEXT: "range": {
|
||||||
// CHECK-NEXT: "end": {
|
// CHECK-NEXT: "end": {
|
||||||
|
|
Loading…
Reference in New Issue