forked from OSchip/llvm-project
[flang] Remove some auto
This patch replaces some `auto` with proper type. This was done in fir-dev but not upstreamed yet. This patch is part of the upstreaming effort from fir-dev branch. Reviewed By: klausler Differential Revision: https://reviews.llvm.org/D128350
This commit is contained in:
parent
10b23ae880
commit
1c7889ca4d
|
@ -161,7 +161,7 @@ template <typename E>
|
|||
static mlir::func::FuncOp getIORuntimeFunc(mlir::Location loc,
|
||||
fir::FirOpBuilder &builder) {
|
||||
llvm::StringRef name = getName<E>();
|
||||
auto func = builder.getNamedFunction(name);
|
||||
mlir::func::FuncOp func = builder.getNamedFunction(name);
|
||||
if (func)
|
||||
return func;
|
||||
auto funTy = getTypeModel<E>()(builder.getContext());
|
||||
|
@ -179,7 +179,8 @@ static mlir::Value genEndIO(Fortran::lower::AbstractConverter &converter,
|
|||
Fortran::lower::StatementContext &stmtCtx) {
|
||||
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
||||
if (csi.ioMsg) {
|
||||
auto getIoMsg = getIORuntimeFunc<mkIOKey(GetIoMsg)>(loc, builder);
|
||||
mlir::func::FuncOp getIoMsg =
|
||||
getIORuntimeFunc<mkIOKey(GetIoMsg)>(loc, builder);
|
||||
builder.create<fir::CallOp>(
|
||||
loc, getIoMsg,
|
||||
mlir::ValueRange{
|
||||
|
@ -189,7 +190,8 @@ static mlir::Value genEndIO(Fortran::lower::AbstractConverter &converter,
|
|||
builder.createConvert(loc, getIoMsg.getFunctionType().getInput(2),
|
||||
fir::getLen(*csi.ioMsg))});
|
||||
}
|
||||
auto endIoStatement = getIORuntimeFunc<mkIOKey(EndIoStatement)>(loc, builder);
|
||||
mlir::func::FuncOp endIoStatement =
|
||||
getIORuntimeFunc<mkIOKey(EndIoStatement)>(loc, builder);
|
||||
auto call = builder.create<fir::CallOp>(loc, endIoStatement,
|
||||
mlir::ValueRange{cookie});
|
||||
mlir::Value iostat = call.getResult(0);
|
||||
|
@ -478,7 +480,8 @@ static void genOutputItemList(
|
|||
if (!expr)
|
||||
fir::emitFatalError(loc, "internal error: could not get evaluate::Expr");
|
||||
mlir::Type itemTy = converter.genType(*expr);
|
||||
auto outputFunc = getOutputFunc(loc, builder, itemTy, isFormatted);
|
||||
mlir::func::FuncOp outputFunc =
|
||||
getOutputFunc(loc, builder, itemTy, isFormatted);
|
||||
mlir::Type argType = outputFunc.getFunctionType().getInput(1);
|
||||
assert((isFormatted || argType.isa<fir::BoxType>()) &&
|
||||
"expect descriptor for unformatted IO runtime");
|
||||
|
@ -625,7 +628,7 @@ static void genInputItemList(Fortran::lower::AbstractConverter &converter,
|
|||
if (Fortran::evaluate::HasVectorSubscript(*expr)) {
|
||||
auto vectorSubscriptBox =
|
||||
Fortran::lower::genVectorSubscriptBox(loc, converter, stmtCtx, *expr);
|
||||
auto inputFunc = getInputFunc(
|
||||
mlir::func::FuncOp inputFunc = getInputFunc(
|
||||
loc, builder, vectorSubscriptBox.getElementType(), isFormatted);
|
||||
const bool mustBox =
|
||||
inputFunc.getFunctionType().getInput(1).isa<fir::BoxType>();
|
||||
|
@ -651,7 +654,8 @@ static void genInputItemList(Fortran::lower::AbstractConverter &converter,
|
|||
continue;
|
||||
}
|
||||
mlir::Type itemTy = converter.genType(*expr);
|
||||
auto inputFunc = getInputFunc(loc, builder, itemTy, isFormatted);
|
||||
mlir::func::FuncOp inputFunc =
|
||||
getInputFunc(loc, builder, itemTy, isFormatted);
|
||||
auto itemExv = inputFunc.getFunctionType().getInput(1).isa<fir::BoxType>()
|
||||
? converter.genExprBox(loc, *expr, stmtCtx)
|
||||
: converter.genExprAddr(loc, expr, stmtCtx);
|
||||
|
@ -873,7 +877,7 @@ mlir::Value genIntIOOption(Fortran::lower::AbstractConverter &converter,
|
|||
const B &spec) {
|
||||
Fortran::lower::StatementContext localStatementCtx;
|
||||
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
||||
auto ioFunc = getIORuntimeFunc<A>(loc, builder);
|
||||
mlir::func::FuncOp ioFunc = getIORuntimeFunc<A>(loc, builder);
|
||||
mlir::FunctionType ioFuncTy = ioFunc.getFunctionType();
|
||||
mlir::Value expr = fir::getBase(converter.genExprValue(
|
||||
loc, Fortran::semantics::GetExpr(spec.v), localStatementCtx));
|
||||
|
@ -890,7 +894,7 @@ mlir::Value genCharIOOption(Fortran::lower::AbstractConverter &converter,
|
|||
const B &spec) {
|
||||
Fortran::lower::StatementContext localStatementCtx;
|
||||
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
||||
auto ioFunc = getIORuntimeFunc<A>(loc, builder);
|
||||
mlir::func::FuncOp ioFunc = getIORuntimeFunc<A>(loc, builder);
|
||||
mlir::FunctionType ioFuncTy = ioFunc.getFunctionType();
|
||||
std::tuple<mlir::Value, mlir::Value, mlir::Value> tup =
|
||||
lowerStringLit(converter, loc, localStatementCtx, spec,
|
||||
|
@ -922,7 +926,7 @@ mlir::Value genIOOption<Fortran::parser::FileNameExpr>(
|
|||
Fortran::lower::StatementContext localStatementCtx;
|
||||
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
||||
// has an extra KIND argument
|
||||
auto ioFunc = getIORuntimeFunc<mkIOKey(SetFile)>(loc, builder);
|
||||
mlir::func::FuncOp ioFunc = getIORuntimeFunc<mkIOKey(SetFile)>(loc, builder);
|
||||
mlir::FunctionType ioFuncTy = ioFunc.getFunctionType();
|
||||
std::tuple<mlir::Value, mlir::Value, mlir::Value> tup =
|
||||
lowerStringLit(converter, loc, localStatementCtx, spec,
|
||||
|
@ -1093,7 +1097,8 @@ static void genIOReadSize(Fortran::lower::AbstractConverter &converter,
|
|||
std::get_if<Fortran::parser::IoControlSpec::Size>(&spec.u)) {
|
||||
|
||||
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
||||
auto ioFunc = getIORuntimeFunc<mkIOKey(GetSize)>(loc, builder);
|
||||
mlir::func::FuncOp ioFunc =
|
||||
getIORuntimeFunc<mkIOKey(GetSize)>(loc, builder);
|
||||
auto sizeValue =
|
||||
builder.create<fir::CallOp>(loc, ioFunc, mlir::ValueRange{cookie})
|
||||
.getResult(0);
|
||||
|
@ -1218,7 +1223,8 @@ genConditionHandlerCall(Fortran::lower::AbstractConverter &converter,
|
|||
if (!csi.hasAnyConditionSpec())
|
||||
return;
|
||||
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
||||
auto enableHandlers = getIORuntimeFunc<mkIOKey(EnableHandlers)>(loc, builder);
|
||||
mlir::func::FuncOp enableHandlers =
|
||||
getIORuntimeFunc<mkIOKey(EnableHandlers)>(loc, builder);
|
||||
mlir::Type boolType = enableHandlers.getFunctionType().getInput(1);
|
||||
auto boolValue = [&](bool specifierIsPresent) {
|
||||
return builder.create<mlir::arith::ConstantOp>(
|
||||
|
@ -1549,7 +1555,7 @@ static mlir::Value genIOUnitNumber(Fortran::lower::AbstractConverter &converter,
|
|||
// overflow when passed to the IO runtime, check that the unit number is
|
||||
// in range before calling the BeginXXX.
|
||||
if (rawUnitWidth > runtimeArgWidth) {
|
||||
auto check =
|
||||
mlir::func::FuncOp check =
|
||||
rawUnitWidth <= 64
|
||||
? getIORuntimeFunc<mkIOKey(CheckUnitNumberInRange64)>(loc, builder)
|
||||
: getIORuntimeFunc<mkIOKey(CheckUnitNumberInRange128)>(loc,
|
||||
|
@ -1625,7 +1631,7 @@ static mlir::Value genBasicIOStmt(Fortran::lower::AbstractConverter &converter,
|
|||
Fortran::lower::StatementContext stmtCtx;
|
||||
mlir::Location loc = converter.getCurrentLocation();
|
||||
ConditionSpecInfo csi = lowerErrorSpec(converter, loc, stmt.v);
|
||||
auto beginFunc = getIORuntimeFunc<K>(loc, builder);
|
||||
mlir::func::FuncOp beginFunc = getIORuntimeFunc<K>(loc, builder);
|
||||
mlir::FunctionType beginFuncTy = beginFunc.getFunctionType();
|
||||
mlir::Value unit = genIOUnitNumber(
|
||||
converter, loc, getExpr<Fortran::parser::FileUnitNumber>(stmt),
|
||||
|
@ -1678,7 +1684,8 @@ genNewunitSpec(Fortran::lower::AbstractConverter &converter, mlir::Location loc,
|
|||
std::get_if<Fortran::parser::ConnectSpec::Newunit>(&spec.u)) {
|
||||
Fortran::lower::StatementContext stmtCtx;
|
||||
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
||||
auto ioFunc = getIORuntimeFunc<mkIOKey(GetNewUnit)>(loc, builder);
|
||||
mlir::func::FuncOp ioFunc =
|
||||
getIORuntimeFunc<mkIOKey(GetNewUnit)>(loc, builder);
|
||||
mlir::FunctionType ioFuncTy = ioFunc.getFunctionType();
|
||||
const auto *var = Fortran::semantics::GetExpr(newunit->v);
|
||||
mlir::Value addr = builder.createConvert(
|
||||
|
@ -1745,9 +1752,9 @@ Fortran::lower::genWaitStatement(Fortran::lower::AbstractConverter &converter,
|
|||
mlir::Location loc = converter.getCurrentLocation();
|
||||
ConditionSpecInfo csi = lowerErrorSpec(converter, loc, stmt.v);
|
||||
bool hasId = hasSpec<Fortran::parser::IdExpr>(stmt);
|
||||
auto beginFunc = hasId
|
||||
? getIORuntimeFunc<mkIOKey(BeginWait)>(loc, builder)
|
||||
: getIORuntimeFunc<mkIOKey(BeginWaitAll)>(loc, builder);
|
||||
mlir::func::FuncOp beginFunc =
|
||||
hasId ? getIORuntimeFunc<mkIOKey(BeginWait)>(loc, builder)
|
||||
: getIORuntimeFunc<mkIOKey(BeginWaitAll)>(loc, builder);
|
||||
mlir::FunctionType beginFuncTy = beginFunc.getFunctionType();
|
||||
mlir::Value unit = genIOUnitNumber(
|
||||
converter, loc, getExpr<Fortran::parser::FileUnitNumber>(stmt),
|
||||
|
@ -1913,9 +1920,9 @@ genDataTransferStmt(Fortran::lower::AbstractConverter &converter,
|
|||
}
|
||||
|
||||
// Generate the begin data transfer function call.
|
||||
auto ioFunc = getBeginDataTransferFunc<isInput>(loc, builder, isFormatted,
|
||||
isList || isNml, isInternal,
|
||||
isInternalWithDesc, isAsync);
|
||||
mlir::func::FuncOp ioFunc = getBeginDataTransferFunc<isInput>(
|
||||
loc, builder, isFormatted, isList || isNml, isInternal,
|
||||
isInternalWithDesc, isAsync);
|
||||
llvm::SmallVector<mlir::Value> ioArgs;
|
||||
genBeginDataTransferCallArgs<hasIOCtrl>(
|
||||
ioArgs, converter, loc, stmt, ioFunc.getFunctionType(), isFormatted,
|
||||
|
@ -2026,7 +2033,8 @@ mlir::Value genInquireSpec<Fortran::parser::InquireSpec::CharVar>(
|
|||
Fortran::parser::InquireSpec::CharVar::Kind::Iomsg)
|
||||
return {};
|
||||
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
||||
auto specFunc = getIORuntimeFunc<mkIOKey(InquireCharacter)>(loc, builder);
|
||||
mlir::func::FuncOp specFunc =
|
||||
getIORuntimeFunc<mkIOKey(InquireCharacter)>(loc, builder);
|
||||
mlir::FunctionType specFuncTy = specFunc.getFunctionType();
|
||||
const auto *varExpr = Fortran::semantics::GetExpr(
|
||||
std::get<Fortran::parser::ScalarDefaultCharVariable>(var.t));
|
||||
|
@ -2055,7 +2063,8 @@ mlir::Value genInquireSpec<Fortran::parser::InquireSpec::IntVar>(
|
|||
Fortran::parser::InquireSpec::IntVar::Kind::Iostat)
|
||||
return {};
|
||||
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
||||
auto specFunc = getIORuntimeFunc<mkIOKey(InquireInteger64)>(loc, builder);
|
||||
mlir::func::FuncOp specFunc =
|
||||
getIORuntimeFunc<mkIOKey(InquireInteger64)>(loc, builder);
|
||||
mlir::FunctionType specFuncTy = specFunc.getFunctionType();
|
||||
const auto *varExpr = Fortran::semantics::GetExpr(
|
||||
std::get<Fortran::parser::ScalarIntVariable>(var.t));
|
||||
|
@ -2091,7 +2100,7 @@ mlir::Value genInquireSpec<Fortran::parser::InquireSpec::LogVar>(
|
|||
bool pendId =
|
||||
idExpr &&
|
||||
logVarKind == Fortran::parser::InquireSpec::LogVar::Kind::Pending;
|
||||
auto specFunc =
|
||||
mlir::func::FuncOp specFunc =
|
||||
pendId ? getIORuntimeFunc<mkIOKey(InquirePendingId)>(loc, builder)
|
||||
: getIORuntimeFunc<mkIOKey(InquireLogical)>(loc, builder);
|
||||
mlir::FunctionType specFuncTy = specFunc.getFunctionType();
|
||||
|
|
|
@ -57,12 +57,13 @@ hostName(const Fortran::semantics::Symbol &symbol) {
|
|||
|
||||
static const Fortran::semantics::Symbol *
|
||||
findInterfaceIfSeperateMP(const Fortran::semantics::Symbol &symbol) {
|
||||
const auto &scope = symbol.owner();
|
||||
const Fortran::semantics::Scope &scope = symbol.owner();
|
||||
if (symbol.attrs().test(Fortran::semantics::Attr::MODULE) &&
|
||||
scope.IsSubmodule()) {
|
||||
// FIXME symbol from MpSubprogramStmt do not seem to have
|
||||
// Attr::MODULE set.
|
||||
const auto *iface = scope.parent().FindSymbol(symbol.name());
|
||||
const Fortran::semantics::Symbol *iface =
|
||||
scope.parent().FindSymbol(symbol.name());
|
||||
assert(iface && "Separate module procedure must be declared");
|
||||
return iface;
|
||||
}
|
||||
|
@ -108,10 +109,11 @@ Fortran::lower::mangle::mangleName(const Fortran::semantics::Symbol &symbol,
|
|||
// Separate module subprograms must be mangled according to the
|
||||
// scope where they were declared (the symbol we have is the
|
||||
// definition).
|
||||
const auto *interface = &ultimateSymbol;
|
||||
const Fortran::semantics::Symbol *interface = &ultimateSymbol;
|
||||
if (const auto *mpIface = findInterfaceIfSeperateMP(ultimateSymbol))
|
||||
interface = mpIface;
|
||||
auto modNames = moduleNames(*interface);
|
||||
llvm::SmallVector<llvm::StringRef> modNames =
|
||||
moduleNames(*interface);
|
||||
return fir::NameUniquer::doProcedure(modNames, hostName(*interface),
|
||||
symbolName);
|
||||
},
|
||||
|
@ -129,16 +131,18 @@ Fortran::lower::mangle::mangleName(const Fortran::semantics::Symbol &symbol,
|
|||
symbolName);
|
||||
},
|
||||
[&](const Fortran::semantics::ObjectEntityDetails &) {
|
||||
auto modNames = moduleNames(ultimateSymbol);
|
||||
auto optHost = hostName(ultimateSymbol);
|
||||
llvm::SmallVector<llvm::StringRef> modNames =
|
||||
moduleNames(ultimateSymbol);
|
||||
llvm::Optional<llvm::StringRef> optHost = hostName(ultimateSymbol);
|
||||
if (Fortran::semantics::IsNamedConstant(ultimateSymbol))
|
||||
return fir::NameUniquer::doConstant(modNames, optHost,
|
||||
symbolName);
|
||||
return fir::NameUniquer::doVariable(modNames, optHost, symbolName);
|
||||
},
|
||||
[&](const Fortran::semantics::NamelistDetails &) {
|
||||
auto modNames = moduleNames(ultimateSymbol);
|
||||
auto optHost = hostName(ultimateSymbol);
|
||||
llvm::SmallVector<llvm::StringRef> modNames =
|
||||
moduleNames(ultimateSymbol);
|
||||
llvm::Optional<llvm::StringRef> optHost = hostName(ultimateSymbol);
|
||||
return fir::NameUniquer::doNamelistGroup(modNames, optHost,
|
||||
symbolName);
|
||||
},
|
||||
|
@ -159,21 +163,25 @@ Fortran::lower::mangle::mangleName(const Fortran::semantics::Symbol &symbol,
|
|||
std::string Fortran::lower::mangle::mangleName(
|
||||
const Fortran::semantics::DerivedTypeSpec &derivedType) {
|
||||
// Resolve host and module association before mangling
|
||||
const auto &ultimateSymbol = derivedType.typeSymbol().GetUltimate();
|
||||
auto symbolName = toStringRef(ultimateSymbol.name());
|
||||
auto modNames = moduleNames(ultimateSymbol);
|
||||
auto optHost = hostName(ultimateSymbol);
|
||||
const Fortran::semantics::Symbol &ultimateSymbol =
|
||||
derivedType.typeSymbol().GetUltimate();
|
||||
llvm::StringRef symbolName = toStringRef(ultimateSymbol.name());
|
||||
llvm::SmallVector<llvm::StringRef> modNames = moduleNames(ultimateSymbol);
|
||||
llvm::Optional<llvm::StringRef> optHost = hostName(ultimateSymbol);
|
||||
llvm::SmallVector<std::int64_t> kinds;
|
||||
for (const auto ¶m :
|
||||
Fortran::semantics::OrderParameterDeclarations(ultimateSymbol)) {
|
||||
const auto ¶mDetails =
|
||||
param->get<Fortran::semantics::TypeParamDetails>();
|
||||
if (paramDetails.attr() == Fortran::common::TypeParamAttr::Kind) {
|
||||
const auto *paramValue = derivedType.FindParameter(param->name());
|
||||
const Fortran::semantics::ParamValue *paramValue =
|
||||
derivedType.FindParameter(param->name());
|
||||
assert(paramValue && "derived type kind parameter value not found");
|
||||
auto paramExpr = paramValue->GetExplicit();
|
||||
const Fortran::semantics::MaybeIntExpr paramExpr =
|
||||
paramValue->GetExplicit();
|
||||
assert(paramExpr && "derived type kind param not explicit");
|
||||
auto init = Fortran::evaluate::ToInt64(paramValue->GetExplicit());
|
||||
std::optional<int64_t> init =
|
||||
Fortran::evaluate::ToInt64(paramValue->GetExplicit());
|
||||
assert(init && "derived type kind param is not constant");
|
||||
kinds.emplace_back(*init);
|
||||
}
|
||||
|
@ -273,7 +281,7 @@ std::string fir::mangleIntrinsicProcedure(llvm::StringRef intrinsic,
|
|||
name.append(intrinsic.str()).append(".");
|
||||
assert(funTy.getNumResults() == 1 && "only function mangling supported");
|
||||
name.append(typeToString(funTy.getResult(0)));
|
||||
auto e = funTy.getNumInputs();
|
||||
unsigned e = funTy.getNumInputs();
|
||||
for (decltype(e) i = 0; i < e; ++i)
|
||||
name.append(".").append(typeToString(funTy.getInput(i)));
|
||||
return name;
|
||||
|
|
Loading…
Reference in New Issue