This patch is part of the upstreaming effort from fir-dev branch.
This is the last patch for the upstreaming effort.
Reviewed By: jeanPerier
Differential Revision: https://reviews.llvm.org/D129187
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
sym.GetType()->characterTypeSpec().length();
if (Fortran::semantics::MaybeIntExpr expr = lenParam.GetExplicit())
return {Fortran::evaluate::AsGenericExpr(std::move(*expr))};
- // For assumed length parameters, the length comes from the initialization
+ // For assumed LEN parameters, the length comes from the initialization
// expression.
if (sym.attrs().test(Fortran::semantics::Attr::PARAMETER))
if (const auto *objectDetails =
/// available without having to read any fir.box values). Empty if \p exv has no
/// LEN parameters or if they are all deferred.
llvm::SmallVector<mlir::Value>
-getNonDeferredLengthParams(const fir::ExtendedValue &exv);
+getNonDeferredLenParams(const fir::ExtendedValue &exv);
//===----------------------------------------------------------------------===//
// String literal helper helpers
mlir::Location loc,
const fir::MutableBoxValue &box,
mlir::ValueRange shape,
- mlir::ValueRange lengthParams);
+ mlir::ValueRange lenParams);
void finalizeRealloc(fir::FirOpBuilder &builder, mlir::Location loc,
const fir::MutableBoxValue &box, mlir::ValueRange lbounds,
[&](const auto &) -> fir::ExtendedValue {
mlir::Value temp =
allocate(fir::factory::getExtents(loc, *builder, hexv),
- fir::getTypeParams(hexv));
+ fir::factory::getTypeParams(loc, *builder, hexv));
return fir::substBase(hexv, temp);
});
// 3) Perform the assignment.
builder->setInsertionPointAfter(fir::getBase(exv).getDefiningOp());
- mlir::Location loc = getCurrentLocation();
+ mlir::Location loc = genLocation(sym.name());
mlir::Type symType = genType(sym);
if (auto seqTy = symType.dyn_cast<fir::SequenceType>()) {
Fortran::lower::StatementContext stmtCtx;
}
static bool
- isDerivedTypeWithLengthParameters(const Fortran::semantics::Symbol &sym) {
+ isDerivedTypeWithLenParameters(const Fortran::semantics::Symbol &sym) {
if (const Fortran::semantics::DeclTypeSpec *declTy = sym.GetType())
if (const Fortran::semantics::DerivedTypeSpec *derived =
declTy->AsDerived())
continue;
}
- if (isDerivedTypeWithLengthParameters(sym))
+ if (isDerivedTypeWithLenParameters(sym))
TODO(loc, "component with length parameters in structure constructor");
if (isBuiltinCPtr(sym)) {
if (sym.test(Fortran::semantics::Symbol::Flag::ParentComp))
TODO(loc, "parent component in structure constructor");
- if (isDerivedTypeWithLengthParameters(sym))
+ if (isDerivedTypeWithLenParameters(sym))
TODO(loc, "component with length parameters in structure constructor");
llvm::StringRef name = toStringRef(sym.name());
mlir::Value box = builder.createBox(loc, exv);
return fir::BoxValue(
box, fir::factory::getNonDefaultLowerBounds(builder, loc, exv),
- fir::factory::getNonDeferredLengthParams(exv));
+ fir::factory::getNonDeferredLenParams(exv));
}
/// Generate a call to a Fortran intrinsic or intrinsic module procedure.
return fir::getBase(Fortran::lower::createSomeExtendedExpression(
loc, converter, expr, symMap, context));
}
-
/// Does this variable have a default initialization?
static bool hasDefaultInitialization(const Fortran::semantics::Symbol &sym) {
if (sym.has<Fortran::semantics::ObjectEntityDetails>() && sym.size())
llvm::StringRef globalName,
mlir::StringAttr linkage);
+static mlir::Location genLocation(Fortran::lower::AbstractConverter &converter,
+ const Fortran::semantics::Symbol &sym) {
+ // Compiler generated name cannot be used as source location, their name
+ // is not pointing to the source files.
+ if (!sym.test(Fortran::semantics::Symbol::Flag::CompilerCreated))
+ return converter.genLocation(sym.name());
+ return converter.getCurrentLocation();
+}
+
/// Create the global op declaration without any initializer
static fir::GlobalOp declareGlobal(Fortran::lower::AbstractConverter &converter,
const Fortran::lower::pft::Variable &var,
linkage == builder.createLinkOnceLinkage())
return defineGlobal(converter, var, globalName, linkage);
const Fortran::semantics::Symbol &sym = var.getSymbol();
- mlir::Location loc = converter.genLocation(sym.name());
+ mlir::Location loc = genLocation(converter, sym);
// Resolve potential host and module association before checking that this
// symbol is an object of a function pointer.
const Fortran::semantics::Symbol &ultimate = sym.GetUltimate();
mlir::StringAttr linkage) {
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
const Fortran::semantics::Symbol &sym = var.getSymbol();
- mlir::Location loc = converter.genLocation(sym.name());
+ mlir::Location loc = genLocation(converter, sym);
bool isConst = isConstant(sym);
fir::GlobalOp global = builder.getNamedGlobal(globalName);
mlir::Type symTy = converter.genType(var);
assert(!var.isAlias() && "must be handled in instantiateAlias");
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
std::string globalName = Fortran::lower::mangle::mangleName(sym);
- mlir::Location loc = converter.genLocation(sym.name());
+ mlir::Location loc = genLocation(converter, sym);
fir::GlobalOp global = builder.getNamedGlobal(globalName);
mlir::StringAttr linkage = getLinkageAttribute(builder, var);
if (var.isModuleVariable()) {
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
assert(var.isAlias());
const Fortran::semantics::Symbol &sym = var.getSymbol();
- const mlir::Location loc = converter.genLocation(sym.name());
+ const mlir::Location loc = genLocation(converter, sym);
mlir::IndexType idxTy = builder.getIndexType();
std::size_t aliasOffset = var.getAlias();
mlir::Value store = getAggregateStore(storeMap, var);
mlir::Value preAlloc) {
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
const Fortran::semantics::Symbol &sym = var.getSymbol();
- const mlir::Location loc = converter.genLocation(sym.name());
+ const mlir::Location loc = genLocation(converter, sym);
mlir::IndexType idxTy = builder.getIndexType();
const bool isDeclaredDummy = Fortran::semantics::IsDummy(sym);
// An active dummy from the current entry point.
};
/// Is \p sym a derived type entity with length parameters ?
-static bool
-isDerivedWithLengthParameters(const Fortran::semantics::Symbol &sym) {
+static bool isDerivedWithLenParameters(const Fortran::semantics::Symbol &sym) {
if (const auto *declTy = sym.GetType())
if (const auto *derived = declTy->AsDerived())
return Fortran::semantics::CountLenParameters(*derived) != 0;
nonDeferredLenParams.push_back(readLength());
}
}
- } else if (isDerivedWithLengthParameters(sym)) {
+ } else if (isDerivedWithLenParameters(sym)) {
TODO(loc, "host associated derived type allocatable or pointer with "
"length parameters");
}
const Fortran::semantics::DeclTypeSpec *type = sym.GetType();
bool isPolymorphic = type && type->IsPolymorphic();
return isScalarOrContiguous && !isPolymorphic &&
- !isDerivedWithLengthParameters(sym);
+ !isDerivedWithLenParameters(sym);
}
};
typename T::Result
walkCaptureCategories(T visitor, Fortran::lower::AbstractConverter &converter,
const Fortran::semantics::Symbol &sym) {
- if (isDerivedWithLengthParameters(sym))
+ if (isDerivedWithLenParameters(sym))
// Should be boxed.
TODO(converter.genLocation(sym.name()),
"host associated derived type with length parameters");
}
llvm::SmallVector<mlir::Value>
-fir::factory::getNonDeferredLengthParams(const fir::ExtendedValue &exv) {
+fir::factory::getNonDeferredLenParams(const fir::ExtendedValue &exv) {
return exv.match(
[&](const fir::CharArrayBoxValue &character)
-> llvm::SmallVector<mlir::Value> { return {character.getLen()}; },
operands[coor.lenParamsOffset()]);
offset =
rewriter.create<mlir::LLVM::MulOp>(loc, idxTy, offset, length);
-
} else {
TODO(loc, "compute size of derived type with type parameters");
}