ScalarDynamicChar(const Fortran::semantics::Symbol &sym)
: ScalarSym{sym}, len{FromBox{}} {}
- llvm::Optional<Fortran::lower::SomeExpr> charLen() const {
+ std::optional<Fortran::lower::SomeExpr> charLen() const {
if (auto *l = std::get_if<Fortran::lower::SomeExpr>(&len))
return {*l};
return std::nullopt;
[](const auto &x) { return x.staticSize(); });
}
- llvm::Optional<int64_t> getCharLenConst() const {
- using A = llvm::Optional<int64_t>;
+ std::optional<int64_t> getCharLenConst() const {
+ using A = std::optional<int64_t>;
return match(
[](const ScalarStaticChar &x) -> A { return {x.charLen()}; },
[](const StaticArrayStaticChar &x) -> A { return {x.charLen()}; },
[](const auto &) -> A { return std::nullopt; });
}
- llvm::Optional<Fortran::lower::SomeExpr> getCharLenExpr() const {
- using A = llvm::Optional<Fortran::lower::SomeExpr>;
+ std::optional<Fortran::lower::SomeExpr> getCharLenExpr() const {
+ using A = std::optional<Fortran::lower::SomeExpr>;
return match([](const ScalarDynamicChar &x) { return x.charLen(); },
[](const StaticArrayDynamicChar &x) { return x.charLen(); },
[](const DynamicArrayDynamicChar &x) { return x.charLen(); },
}
// Get the constant LEN of a CHARACTER, if it exists.
- llvm::Optional<int64_t>
+ std::optional<int64_t>
charLenConstant(const Fortran::semantics::Symbol &sym) {
- if (llvm::Optional<Fortran::lower::SomeExpr> expr = charLenVariable(sym))
+ if (std::optional<Fortran::lower::SomeExpr> expr = charLenVariable(sym))
if (std::optional<int64_t> asInt = Fortran::evaluate::ToInt64(*expr)) {
// Length is max(0, *asInt) (F2018 7.4.4.2 point 5.).
if (*asInt < 0)
}
// Get the `SomeExpr` that describes the CHARACTER's LEN.
- llvm::Optional<Fortran::lower::SomeExpr>
+ std::optional<Fortran::lower::SomeExpr>
charLenVariable(const Fortran::semantics::Symbol &sym) {
const Fortran::semantics::ParamValue &lenParam =
sym.GetType()->characterTypeSpec().length();
/// This optional continuation allows the generation of those dereferences.
/// These accesses are always on Fortran entities of record types, which are
/// implicitly in-memory objects.
- llvm::Optional<ExtendRefFunc> extendCoorRef = std::nullopt;
+ std::optional<ExtendRefFunc> extendCoorRef = std::nullopt;
private:
void setPC(bool isImplicit);
mlir::Location loc, Fortran::lower::AbstractConverter &converter,
Fortran::lower::SymMap &symMap, Fortran::lower::StatementContext &stmtCtx,
Fortran::lower::CallerInterface &caller, mlir::FunctionType callSiteType,
- llvm::Optional<mlir::Type> resultType);
+ std::optional<mlir::Type> resultType);
/// If \p arg is the address of a function with a denoted host-association tuple
/// argument, then return the host-associations tuple value of the current
/// Lower a ProcedureRef to HLFIR. If this is a function call, return the
/// lowered result value. Return nothing otherwise.
-llvm::Optional<hlfir::EntityWithAttributes> convertCallToHLFIR(
+std::optional<hlfir::EntityWithAttributes> convertCallToHLFIR(
mlir::Location loc, Fortran::lower::AbstractConverter &converter,
- const evaluate::ProcedureRef &procRef,
- llvm::Optional<mlir::Type> resultType, Fortran::lower::SymMap &symMap,
- Fortran::lower::StatementContext &stmtCtx);
+ const evaluate::ProcedureRef &procRef, std::optional<mlir::Type> resultType,
+ Fortran::lower::SymMap &symMap, Fortran::lower::StatementContext &stmtCtx);
} // namespace Fortran::lower
#endif // FORTRAN_LOWER_CONVERTCALL_H
AbstractConverter &converter, const SomeExpr &lhs, const SomeExpr &rhs,
ExplicitIterSpace &explicitIterSpace, ImplicitIterSpace &implicitIterSpace,
const llvm::SmallVector<mlir::Value> &lbounds,
- llvm::Optional<llvm::SmallVector<mlir::Value>> ubounds, SymMap &symMap,
+ std::optional<llvm::SmallVector<mlir::Value>> ubounds, SymMap &symMap,
StatementContext &stmtCtx);
/// Lower an array expression with "parallel" semantics. Such a rhs expression
/// preparation was done. An absent optional means the argument is statically
/// present. An mlir::Value means the presence must be checked at runtime, and
/// that the value contains the "is present" boolean value.
-using OperandPresent = std::function<llvm::Optional<mlir::Value>(std::size_t)>;
+using OperandPresent = std::function<std::optional<mlir::Value>(std::size_t)>;
/// Type of the callback to generate an argument reference after the call
/// preparation was done. For optional arguments, the utility guarantees
void prepareCustomIntrinsicArgument(
const Fortran::evaluate::ProcedureRef &procRef,
const Fortran::evaluate::SpecificIntrinsic &intrinsic,
- llvm::Optional<mlir::Type> retTy,
+ std::optional<mlir::Type> retTy,
const OperandPrepare &prepareOptionalArgument,
const OperandPrepare &prepareOtherArgument, AbstractConverter &converter);
/// not generate any implicit loop nest on its own).
fir::ExtendedValue
lowerCustomIntrinsic(fir::FirOpBuilder &builder, mlir::Location loc,
- llvm::StringRef name, llvm::Optional<mlir::Type> retTy,
+ llvm::StringRef name, std::optional<mlir::Type> retTy,
const OperandPresent &isPresentCheck,
const OperandGetter &getOperand, std::size_t numOperands,
Fortran::lower::StatementContext &stmtCtx);
/// Returned mlir::Value is the returned Fortran intrinsic value.
fir::ExtendedValue genIntrinsicCall(fir::FirOpBuilder &, mlir::Location,
llvm::StringRef name,
- llvm::Optional<mlir::Type> resultType,
+ std::optional<mlir::Type> resultType,
llvm::ArrayRef<fir::ExtendedValue> args,
StatementContext &);
}
/// `load` must be a LHS array_load. Returns `std::nullopt` on error.
- llvm::Optional<size_t> findArgPosition(fir::ArrayLoadOp load);
+ std::optional<size_t> findArgPosition(fir::ArrayLoadOp load);
bool isLHS(fir::ArrayLoadOp load) {
return findArgPosition(load).has_value();
llvm_unreachable("inner argument value was not found");
}
- llvm::Optional<fir::ArrayLoadOp> getLhsLoad(size_t i) {
+ std::optional<fir::ArrayLoadOp> getLhsLoad(size_t i) {
assert(i < lhsBases.size());
if (lhsBases[counter])
return findBinding(*lhsBases[counter]);
// A stack of lists of front-end symbols.
llvm::SmallVector<llvm::SmallVector<FrontEndSymbol>> symbolStack;
- llvm::SmallVector<llvm::Optional<ArrayBases>> lhsBases;
+ llvm::SmallVector<std::optional<ArrayBases>> lhsBases;
llvm::SmallVector<llvm::SmallVector<ArrayBases>> rhsBases;
llvm::DenseMap<ArrayBases, fir::ArrayLoadOp> loadBindings;
StatementContext stmtCtx;
llvm::SmallVector<mlir::Value> innerArgs;
llvm::SmallVector<mlir::Value> initialArgs;
- llvm::Optional<fir::DoLoopOp> outerLoop;
+ std::optional<fir::DoLoopOp> outerLoop;
llvm::SmallVector<llvm::SmallVector<fir::DoLoopOp>> loopStack;
- llvm::Optional<std::function<void(fir::FirOpBuilder &)>> loopCleanup;
+ std::optional<std::function<void(fir::FirOpBuilder &)>> loopCleanup;
std::size_t forallContextOpen = 0;
std::size_t counter = 0;
};
mlir::Value genCpuTime(fir::FirOpBuilder &, mlir::Location);
void genDateAndTime(fir::FirOpBuilder &, mlir::Location,
- llvm::Optional<fir::CharBoxValue> date,
- llvm::Optional<fir::CharBoxValue> time,
- llvm::Optional<fir::CharBoxValue> zone, mlir::Value values);
+ std::optional<fir::CharBoxValue> date,
+ std::optional<fir::CharBoxValue> time,
+ std::optional<fir::CharBoxValue> zone, mlir::Value values);
void genRandomInit(fir::FirOpBuilder &, mlir::Location, mlir::Value repeatable,
mlir::Value imageDistinct);
symbolMapStack.back().try_emplace(sym, definingOp);
}
- llvm::Optional<fir::FortranVariableOpInterface>
+ std::optional<fir::FortranVariableOpInterface>
lookupVariableDefinition(semantics::SymbolRef sym);
private:
mlir::Type type);
/// Get the integer constants of triplet and compute the extent.
-llvm::Optional<std::int64_t>
-getExtentFromTriplet(mlir::Value lb, mlir::Value ub, mlir::Value stride);
+std::optional<std::int64_t> getExtentFromTriplet(mlir::Value lb, mlir::Value ub,
+ mlir::Value stride);
/// Generate max(\p value, 0) where \p value is a scalar integer.
mlir::Value genMaxWithZero(fir::FirOpBuilder &builder, mlir::Location loc,
/// In that case, a cleanup function is provided to generate the finalization
/// code after the end of the fir::ExtendedValue use.
using CleanupFunction = std::function<void()>;
-std::pair<fir::ExtendedValue, llvm::Optional<CleanupFunction>>
+std::pair<fir::ExtendedValue, std::optional<CleanupFunction>>
translateToExtendedValue(mlir::Location loc, fir::FirOpBuilder &builder,
Entity entity);
if (const llvm::opt::Arg *A =
args.getLastArg(clang::driver::options::OPT_mrelocation_model)) {
llvm::StringRef ModelName = A->getValue();
- auto RM = llvm::StringSwitch<llvm::Optional<llvm::Reloc::Model>>(ModelName)
+ auto RM = llvm::StringSwitch<std::optional<llvm::Reloc::Model>>(ModelName)
.Case("static", llvm::Reloc::Static)
.Case("pic", llvm::Reloc::PIC_)
.Case("dynamic-no-pic", llvm::Reloc::DynamicNoPIC)
Fortran::lower::SymbolBox
lookupSymbol(const Fortran::semantics::Symbol &sym) {
if (bridge.getLoweringOptions().getLowerToHighLevelFIR()) {
- if (llvm::Optional<fir::FortranVariableOpInterface> var =
+ if (std::optional<fir::FortranVariableOpInterface> var =
localSymbols.lookupVariableDefinition(sym)) {
auto exv =
hlfir::translateToExtendedValue(toLocation(), *builder, *var);
assert(stmt.typedCall && "Call was not analyzed");
mlir::Value res{};
if (bridge.getLoweringOptions().getLowerToHighLevelFIR()) {
- llvm::Optional<mlir::Type> resultType = std::nullopt;
+ std::optional<mlir::Type> resultType = std::nullopt;
if (stmt.typedCall->hasAlternateReturns())
resultType = builder->getIndexType();
auto hlfirRes = Fortran::lower::convertCallToHLFIR(
void genArrayAssignment(
const Fortran::evaluate::Assignment &assign,
Fortran::lower::StatementContext &localStmtCtx,
- llvm::Optional<llvm::SmallVector<mlir::Value>> lbounds = std::nullopt,
- llvm::Optional<llvm::SmallVector<mlir::Value>> ubounds = std::nullopt) {
+ std::optional<llvm::SmallVector<mlir::Value>> lbounds = std::nullopt,
+ std::optional<llvm::SmallVector<mlir::Value>> ubounds = std::nullopt) {
Fortran::lower::StatementContext &stmtCtx =
explicitIterationSpace()
: genExprAddr(assign.rhs, stmtCtx);
const bool lhsIsWholeAllocatable =
Fortran::lower::isWholeAllocatable(assign.lhs);
- llvm::Optional<fir::factory::MutableBoxReallocation> lhsRealloc;
- llvm::Optional<fir::MutableBoxValue> lhsMutableBox;
+ std::optional<fir::factory::MutableBoxReallocation> lhsRealloc;
+ std::optional<fir::MutableBoxValue> lhsMutableBox;
auto lhs = [&]() -> fir::ExtendedValue {
if (lhsIsWholeAllocatable) {
lhsMutableBox = genExprMutableBox(loc, assign.lhs);
interface.side().getHostAssociatedTuple(), emptyValue()});
}
- static llvm::Optional<Fortran::evaluate::DynamicType> getResultDynamicType(
+ static std::optional<Fortran::evaluate::DynamicType> getResultDynamicType(
const Fortran::evaluate::characteristics::Procedure &procedure) {
if (const std::optional<Fortran::evaluate::characteristics::FunctionResult>
&result = procedure.functionResult)
// array function with assumed length (f18 forbides defining such
// interfaces). Hence, passing the length is most likely useless, but stick
// with ifort/nag/xlf interface here.
- if (llvm::Optional<Fortran::evaluate::DynamicType> type =
+ if (std::optional<Fortran::evaluate::DynamicType> type =
getResultDynamicType(procedure))
return type->category() == Fortran::common::TypeCategory::Character;
return false;
proc.procedure.value();
mlir::Type funcType =
getProcedureDesignatorType(&procedure, interface.converter);
- llvm::Optional<Fortran::evaluate::DynamicType> resultTy =
+ std::optional<Fortran::evaluate::DynamicType> resultTy =
getResultDynamicType(procedure);
if (resultTy && mustPassLengthWithDummyProcedure(procedure)) {
// The result length of dummy procedures that are character functions must
mlir::Location loc, Fortran::lower::AbstractConverter &converter,
Fortran::lower::SymMap &symMap, Fortran::lower::StatementContext &stmtCtx,
Fortran::lower::CallerInterface &caller, mlir::FunctionType callSiteType,
- llvm::Optional<mlir::Type> resultType) {
+ std::optional<mlir::Type> resultType) {
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
using PassBy = Fortran::lower::CallerInterface::PassEntityBy;
// Handle cases where caller must allocate the result or a fir.box for it.
return fir::factory::genMaxWithZero(builder, loc, convertExpr);
};
llvm::SmallVector<mlir::Value> resultLengths;
- auto allocatedResult = [&]() -> llvm::Optional<fir::ExtendedValue> {
+ auto allocatedResult = [&]() -> std::optional<fir::ExtendedValue> {
llvm::SmallVector<mlir::Value> extents;
llvm::SmallVector<mlir::Value> lengths;
if (!caller.callerAllocateResult())
bool handleDynamicOptional;
};
using PreparedActualArguments =
- llvm::SmallVector<llvm::Optional<PreparedActualArgument>>;
+ llvm::SmallVector<std::optional<PreparedActualArgument>>;
using PassBy = Fortran::lower::CallerInterface::PassEntityBy;
public:
Fortran::lower::StatementContext &stmtCtx)
: converter{converter}, symMap{symMap}, stmtCtx{stmtCtx}, loc{loc} {}
- llvm::Optional<hlfir::EntityWithAttributes>
+ std::optional<hlfir::EntityWithAttributes>
gen(const Fortran::evaluate::ProcedureRef &procRef,
- llvm::Optional<mlir::Type> resultType) {
+ std::optional<mlir::Type> resultType) {
mlir::Location loc = getLoc();
if (auto *specific = procRef.proc().GetSpecificIntrinsic()) {
if (isElementalProcWithArrayArgs(procRef))
}
private:
- llvm::Optional<hlfir::EntityWithAttributes>
+ std::optional<hlfir::EntityWithAttributes>
genUserCall(PreparedActualArguments &loweredActuals,
Fortran::lower::CallerInterface &caller,
- llvm::Optional<mlir::Type> resultType,
+ std::optional<mlir::Type> resultType,
mlir::FunctionType callSiteType) {
mlir::Location loc = getLoc();
fir::FirOpBuilder &builder = getBuilder();
return extendedValueToHlfirEntity(result, ".tmp.func_result");
}
- llvm::Optional<hlfir::EntityWithAttributes>
+ std::optional<hlfir::EntityWithAttributes>
genElementalUserCall(PreparedActualArguments &loweredActuals,
Fortran::lower::CallerInterface &caller,
- llvm::Optional<mlir::Type> resultType,
+ std::optional<mlir::Type> resultType,
mlir::FunctionType callSiteType, bool isImpure) {
mlir::Location loc = getLoc();
fir::FirOpBuilder &builder = getBuilder();
hlfir::EntityWithAttributes
genIntrinsicRef(const Fortran::evaluate::ProcedureRef &procRef,
- llvm::Optional<mlir::Type> resultType,
+ std::optional<mlir::Type> resultType,
const Fortran::evaluate::SpecificIntrinsic &intrinsic) {
mlir::Location loc = getLoc();
if (Fortran::lower::intrinsicRequiresCustomOptionalHandling(
};
} // namespace
-llvm::Optional<hlfir::EntityWithAttributes> Fortran::lower::convertCallToHLFIR(
+std::optional<hlfir::EntityWithAttributes> Fortran::lower::convertCallToHLFIR(
mlir::Location loc, Fortran::lower::AbstractConverter &converter,
- const evaluate::ProcedureRef &procRef,
- llvm::Optional<mlir::Type> resultType, Fortran::lower::SymMap &symMap,
- Fortran::lower::StatementContext &stmtCtx) {
+ const evaluate::ProcedureRef &procRef, std::optional<mlir::Type> resultType,
+ Fortran::lower::SymMap &symMap, Fortran::lower::StatementContext &stmtCtx) {
return CallBuilder(loc, converter, symMap, stmtCtx).gen(procRef, resultType);
}
/// Generate a call to a Fortran intrinsic or intrinsic module procedure.
ExtValue genIntrinsicRef(
const Fortran::evaluate::ProcedureRef &procRef,
- llvm::Optional<mlir::Type> resultType,
- llvm::Optional<const Fortran::evaluate::SpecificIntrinsic> intrinsic =
+ std::optional<mlir::Type> resultType,
+ std::optional<const Fortran::evaluate::SpecificIntrinsic> intrinsic =
std::nullopt) {
llvm::SmallVector<ExtValue> operands;
mlir::Location loc = getLoc();
if (intrinsic && Fortran::lower::intrinsicRequiresCustomOptionalHandling(
procRef, *intrinsic, converter)) {
- using ExvAndPresence = std::pair<ExtValue, llvm::Optional<mlir::Value>>;
+ using ExvAndPresence = std::pair<ExtValue, std::optional<mlir::Value>>;
llvm::SmallVector<ExvAndPresence, 4> operands;
auto prepareOptionalArg = [&](const Fortran::lower::SomeExpr &expr) {
ExtValue optionalArg = lowerIntrinsicArgumentAsInquired(expr);
return genLoad(operands[i].first);
return operands[i].first;
};
- auto isPresent = [&](std::size_t i) -> llvm::Optional<mlir::Value> {
+ auto isPresent = [&](std::size_t i) -> std::optional<mlir::Value> {
return operands[i].second;
};
return Fortran::lower::lowerCustomIntrinsic(
/// Lower a non-elemental procedure reference and read allocatable and pointer
/// results into normal values.
ExtValue genProcedureRef(const Fortran::evaluate::ProcedureRef &procRef,
- llvm::Optional<mlir::Type> resultType) {
+ std::optional<mlir::Type> resultType) {
ExtValue res = genRawProcedureRef(procRef, resultType);
// In most contexts, pointers and allocatable do not appear as allocatable
// or pointer variable on the caller side (see 8.5.3 note 1 for
bool argMayBeModifiedByCall;
// Optional boolean value that, if present and false, prevents
// the copy-out and temp deallocation.
- llvm::Optional<mlir::Value> restrictCopyAndFreeAtRuntime;
+ std::optional<mlir::Value> restrictCopyAndFreeAtRuntime;
};
using CopyOutPairs = llvm::SmallVector<CopyOutPair, 4>;
ExtValue genCopyIn(const ExtValue &actualArg,
const Fortran::lower::CallerInterface::PassedEntity &arg,
CopyOutPairs ©OutPairs,
- llvm::Optional<mlir::Value> restrictCopyAtRuntime,
+ std::optional<mlir::Value> restrictCopyAtRuntime,
bool byValue) {
const bool doCopyOut = !byValue && arg.mayBeModifiedByCall();
llvm::StringRef tempName = byValue ? ".copy" : ".copyinout";
/// If the actual argument may be dynamically absent, return an additional
/// boolean mlir::Value that if true means that the actual argument is
/// present.
- std::pair<ExtValue, llvm::Optional<mlir::Value>>
+ std::pair<ExtValue, std::optional<mlir::Value>>
prepareActualToBaseAddressLike(
const Fortran::lower::SomeExpr &expr,
const Fortran::lower::CallerInterface::PassedEntity &arg,
expr, converter.getFoldingContext())));
const bool needsCopy = isStaticConstantByValue || variableNeedsCopy;
auto [argAddr, isPresent] =
- [&]() -> std::pair<ExtValue, llvm::Optional<mlir::Value>> {
+ [&]() -> std::pair<ExtValue, std::optional<mlir::Value>> {
if (!actualArgIsVariable && !needsCopy)
// Actual argument is not a variable. Make sure a variable address is
// not passed.
/// Lower a non-elemental procedure reference.
ExtValue genRawProcedureRef(const Fortran::evaluate::ProcedureRef &procRef,
- llvm::Optional<mlir::Type> resultType) {
+ std::optional<mlir::Type> resultType) {
mlir::Location loc = getLoc();
if (isElementalProcWithArrayArgs(procRef))
fir::emitFatalError(loc, "trying to lower elemental procedure with array "
}
ExtValue genval(const Fortran::evaluate::ProcedureRef &procRef) {
- llvm::Optional<mlir::Type> resTy;
+ std::optional<mlir::Type> resTy;
if (procRef.hasAlternateReturns())
resTy = builder.getIndexType();
return genProcedureRef(procRef, resTy);
Fortran::lower::ExplicitIterSpace &explicitSpace,
Fortran::lower::ImplicitIterSpace &implicitSpace,
const llvm::SmallVector<mlir::Value> &lbounds,
- llvm::Optional<llvm::SmallVector<mlir::Value>> ubounds) {
+ std::optional<llvm::SmallVector<mlir::Value>> ubounds) {
ArrayExprLowering ael(converter, stmtCtx, symMap,
ConstituentSemantics::CopyInCopyOut, &explicitSpace,
&implicitSpace);
void lowerArrayOfPointerAssignment(
const Fortran::lower::SomeExpr &lhs, const Fortran::lower::SomeExpr &rhs,
const llvm::SmallVector<mlir::Value> &lbounds,
- llvm::Optional<llvm::SmallVector<mlir::Value>> ubounds) {
+ std::optional<llvm::SmallVector<mlir::Value>> ubounds) {
setPointerAssignmentBounds(lbounds, ubounds);
if (rhs.Rank() == 0 ||
(Fortran::evaluate::UnwrapWholeSymbolOrComponentDataRef(rhs) &&
// A reference to a Fortran elemental intrinsic or intrinsic module procedure.
CC genElementalIntrinsicProcRef(
const Fortran::evaluate::ProcedureRef &procRef,
- llvm::Optional<mlir::Type> retTy,
- llvm::Optional<const Fortran::evaluate::SpecificIntrinsic> intrinsic =
+ std::optional<mlir::Type> retTy,
+ std::optional<const Fortran::evaluate::SpecificIntrinsic> intrinsic =
std::nullopt) {
llvm::SmallVector<CC> operands;
mlir::Location loc = getLoc();
if (intrinsic && Fortran::lower::intrinsicRequiresCustomOptionalHandling(
procRef, *intrinsic, converter)) {
- using CcPairT = std::pair<CC, llvm::Optional<mlir::Value>>;
+ using CcPairT = std::pair<CC, std::optional<mlir::Value>>;
llvm::SmallVector<CcPairT> operands;
auto prepareOptionalArg = [&](const Fortran::lower::SomeExpr &expr) {
if (expr.Rank() == 0) {
auto getArgument = [&](std::size_t i) -> ExtValue {
return operands[i].first(iters);
};
- auto isPresent = [&](std::size_t i) -> llvm::Optional<mlir::Value> {
+ auto isPresent = [&](std::size_t i) -> std::optional<mlir::Value> {
return operands[i].second;
};
return Fortran::lower::lowerCustomIntrinsic(
/// Lower a procedure reference to a user-defined elemental procedure.
CC genElementalUserDefinedProcRef(
const Fortran::evaluate::ProcedureRef &procRef,
- llvm::Optional<mlir::Type> retTy) {
+ std::optional<mlir::Type> retTy) {
using PassBy = Fortran::lower::CallerInterface::PassEntityBy;
// 10.1.4 p5. Impure elemental procedures must be called in element order.
/// Generate a procedure reference. This code is shared for both functions and
/// subroutines, the difference being reflected by `retTy`.
CC genProcRef(const Fortran::evaluate::ProcedureRef &procRef,
- llvm::Optional<mlir::Type> retTy) {
+ std::optional<mlir::Type> retTy) {
mlir::Location loc = getLoc();
setLoweredProcRef(&procRef);
// Any temps created in the loop body must be freed inside the loop body.
stmtCtx.pushScope();
- llvm::Optional<mlir::Value> charLen;
+ std::optional<mlir::Value> charLen;
for (const Fortran::evaluate::ArrayConstructorValue<A> &acv : x.values()) {
auto [exv, copyNeeded] = std::visit(
[&](const auto &v) {
mlir::Type eleRefTy = builder.getRefType(eleTy);
// Populate the buffer with the elements, growing as necessary.
- llvm::Optional<mlir::Value> charLen;
+ std::optional<mlir::Value> charLen;
for (const auto &expr : x) {
auto [exv, copyNeeded] = std::visit(
[&](const auto &e) {
void setPointerAssignmentBounds(
const llvm::SmallVector<mlir::Value> &lbs,
- llvm::Optional<llvm::SmallVector<mlir::Value>> ubs) {
+ std::optional<llvm::SmallVector<mlir::Value>> ubs) {
lbounds = lbs;
ubounds = ubs;
}
bool elementCtx = false;
Fortran::lower::SymMap &symMap;
/// The continuation to generate code to update the destination.
- llvm::Optional<CC> ccStoreToDest;
- llvm::Optional<std::function<void(llvm::ArrayRef<mlir::Value>)>> ccPrelude;
- llvm::Optional<std::function<fir::ArrayLoadOp(llvm::ArrayRef<mlir::Value>)>>
+ std::optional<CC> ccStoreToDest;
+ std::optional<std::function<void(llvm::ArrayRef<mlir::Value>)>> ccPrelude;
+ std::optional<std::function<fir::ArrayLoadOp(llvm::ArrayRef<mlir::Value>)>>
ccLoadDest;
/// The destination is the loaded array into which the results will be
/// merged.
ConstituentSemantics semant = ConstituentSemantics::RefTransparent;
/// `lbounds`, `ubounds` are used in POINTER value assignments, which may only
/// occur in an explicit iteration space.
- llvm::Optional<llvm::SmallVector<mlir::Value>> lbounds;
- llvm::Optional<llvm::SmallVector<mlir::Value>> ubounds;
+ std::optional<llvm::SmallVector<mlir::Value>> lbounds;
+ std::optional<llvm::SmallVector<mlir::Value>> ubounds;
// Can the array expression be evaluated in any order?
// Will be set to false if any of the expression parts prevent this.
bool unordered = true;
Fortran::lower::ExplicitIterSpace &explicitSpace,
Fortran::lower::ImplicitIterSpace &implicitSpace,
const llvm::SmallVector<mlir::Value> &lbounds,
- llvm::Optional<llvm::SmallVector<mlir::Value>> ubounds,
+ std::optional<llvm::SmallVector<mlir::Value>> ubounds,
Fortran::lower::SymMap &symMap, Fortran::lower::StatementContext &stmtCtx) {
LLVM_DEBUG(lhs.AsFortran(llvm::dbgs() << "defining pointer: ") << '\n';
rhs.AsFortran(llvm::dbgs() << "assign expression: ")
builder.setInsertionPointAfter(esp.getOuterLoop());
// Gen the fir.array_merge_store ops for all LHS arrays.
for (auto i : llvm::enumerate(esp.getOuterLoop().getResults()))
- if (llvm::Optional<fir::ArrayLoadOp> ldOpt = esp.getLhsLoad(i.index())) {
+ if (std::optional<fir::ArrayLoadOp> ldOpt = esp.getLhsLoad(i.index())) {
fir::ArrayLoadOp load = *ldOpt;
builder.create<fir::ArrayMergeStoreOp>(loc, load, i.value(),
load.getMemref(), load.getSlice(),
fir::FortranVariableOpInterface
gen(const Fortran::evaluate::SymbolRef &symbolRef) {
- if (llvm::Optional<fir::FortranVariableOpInterface> varDef =
+ if (std::optional<fir::FortranVariableOpInterface> varDef =
getSymMap().lookupVariableDefinition(symbolRef))
return *varDef;
TODO(getLoc(), "lowering symbol to HLFIR");
return mlir::Value{};
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
mlir::Type lenTy = builder.getCharacterLengthType();
- if (llvm::Optional<int64_t> len = box.getCharLenConst())
+ if (std::optional<int64_t> len = box.getCharLenConst())
return builder.createIntegerConstant(loc, lenTy, *len);
- if (llvm::Optional<Fortran::lower::SomeExpr> lenExpr = box.getCharLenExpr())
+ if (std::optional<Fortran::lower::SomeExpr> lenExpr = box.getCharLenExpr())
// If the length expression is negative, the length is zero. See F2018
// 7.4.4.2 point 5.
return fir::factory::genMaxWithZero(
if (arg.getType().isa<fir::BoxCharType>())
std::tie(addr, len) = charHelp.createUnboxChar(arg);
}
- if (llvm::Optional<int64_t> cstLen = ba.getCharLenConst()) {
+ if (std::optional<int64_t> cstLen = ba.getCharLenConst()) {
// Static length
len = builder.createIntegerConstant(loc, idxTy, *cstLen);
} else {
// Dynamic length
if (genUnusedEntryPointBox())
return;
- if (llvm::Optional<Fortran::lower::SomeExpr> charLenExpr =
+ if (std::optional<Fortran::lower::SomeExpr> charLenExpr =
ba.getCharLenExpr()) {
// Explicit length
mlir::Value rawLen = genValue(*charLenExpr);
static void prepareMinOrMaxArguments(
const Fortran::evaluate::ProcedureRef &procRef,
const Fortran::evaluate::SpecificIntrinsic &intrinsic,
- llvm::Optional<mlir::Type> retTy,
+ std::optional<mlir::Type> retTy,
const Fortran::lower::OperandPrepare &prepareOptionalArgument,
const Fortran::lower::OperandPrepare &prepareOtherArgument,
Fortran::lower::AbstractConverter &converter) {
static fir::ExtendedValue
lowerMinOrMax(fir::FirOpBuilder &builder, mlir::Location loc,
- llvm::StringRef name, llvm::Optional<mlir::Type> retTy,
+ llvm::StringRef name, std::optional<mlir::Type> retTy,
const Fortran::lower::OperandPresent &isPresentCheck,
const Fortran::lower::OperandGetter &getOperand,
std::size_t numOperands,
builder, loc, name, resultType, args, stmtCtx));
for (std::size_t opIndex = 2; opIndex < numOperands; ++opIndex) {
- if (llvm::Optional<mlir::Value> isPresentRuntimeCheck =
+ if (std::optional<mlir::Value> isPresentRuntimeCheck =
isPresentCheck(opIndex)) {
// Argument is dynamically optional.
extremum =
static void prepareIshftcArguments(
const Fortran::evaluate::ProcedureRef &procRef,
const Fortran::evaluate::SpecificIntrinsic &intrinsic,
- llvm::Optional<mlir::Type> retTy,
+ std::optional<mlir::Type> retTy,
const Fortran::lower::OperandPrepare &prepareOptionalArgument,
const Fortran::lower::OperandPrepare &prepareOtherArgument,
Fortran::lower::AbstractConverter &converter) {
static fir::ExtendedValue
lowerIshftc(fir::FirOpBuilder &builder, mlir::Location loc,
- llvm::StringRef name, llvm::Optional<mlir::Type> retTy,
+ llvm::StringRef name, std::optional<mlir::Type> retTy,
const Fortran::lower::OperandPresent &isPresentCheck,
const Fortran::lower::OperandGetter &getOperand,
std::size_t numOperands,
void Fortran::lower::prepareCustomIntrinsicArgument(
const Fortran::evaluate::ProcedureRef &procRef,
const Fortran::evaluate::SpecificIntrinsic &intrinsic,
- llvm::Optional<mlir::Type> retTy,
+ std::optional<mlir::Type> retTy,
const OperandPrepare &prepareOptionalArgument,
const OperandPrepare &prepareOtherArgument, AbstractConverter &converter) {
llvm::StringRef name = intrinsic.name;
fir::ExtendedValue Fortran::lower::lowerCustomIntrinsic(
fir::FirOpBuilder &builder, mlir::Location loc, llvm::StringRef name,
- llvm::Optional<mlir::Type> retTy, const OperandPresent &isPresentCheck,
+ std::optional<mlir::Type> retTy, const OperandPresent &isPresentCheck,
const OperandGetter &getOperand, std::size_t numOperands,
Fortran::lower::StatementContext &stmtCtx) {
if (name == "min" || name == "max")
llvm::SmallVector<mlir::Value> nonDeferredLenParams;
if (ba.isChar()) {
mlir::IndexType idxTy = builder.getIndexType();
- if (llvm::Optional<int64_t> len = ba.getCharLenConst()) {
+ if (std::optional<int64_t> len = ba.getCharLenConst()) {
nonDeferredLenParams.push_back(
builder.createIntegerConstant(loc, idxTy, *len));
} else if (Fortran::semantics::IsAssumedLengthCharacter(sym) ||
/// and an IOMSG specifier variable may be set to a description of a condition.
struct ConditionSpecInfo {
const Fortran::lower::SomeExpr *ioStatExpr{};
- llvm::Optional<fir::ExtendedValue> ioMsg;
+ std::optional<fir::ExtendedValue> ioMsg;
bool hasErr{};
bool hasEnd{};
bool hasEor{};
/// If the variable `var` is an array or of a KIND other than the default
/// (normally 1), then a descriptor is required by the runtime IO API. This
/// condition holds even in F77 sources.
-static llvm::Optional<fir::ExtendedValue> getVariableBufferRequiredDescriptor(
+static std::optional<fir::ExtendedValue> getVariableBufferRequiredDescriptor(
Fortran::lower::AbstractConverter &converter, mlir::Location loc,
const Fortran::parser::Variable &var,
Fortran::lower::StatementContext &stmtCtx) {
}
template <typename A>
-static llvm::Optional<fir::ExtendedValue>
+static std::optional<fir::ExtendedValue>
maybeGetInternalIODescriptor(Fortran::lower::AbstractConverter &converter,
mlir::Location loc, const A &stmt,
Fortran::lower::StatementContext &stmtCtx) {
return std::nullopt;
}
template <>
-inline llvm::Optional<fir::ExtendedValue>
+inline std::optional<fir::ExtendedValue>
maybeGetInternalIODescriptor<Fortran::parser::PrintStmt>(
Fortran::lower::AbstractConverter &, mlir::Location loc,
const Fortran::parser::PrintStmt &, Fortran::lower::StatementContext &) {
const A &stmt, mlir::FunctionType ioFuncTy, bool isFormatted,
bool isListOrNml, [[maybe_unused]] bool isInternal,
[[maybe_unused]] bool isAsync,
- const llvm::Optional<fir::ExtendedValue> &descRef, ConditionSpecInfo &csi,
+ const std::optional<fir::ExtendedValue> &descRef, ConditionSpecInfo &csi,
Fortran::lower::StatementContext &stmtCtx) {
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
auto maybeGetFormatArgs = [&]() {
const bool isFormatted = isDataTransferFormatted(stmt);
const bool isList = isFormatted ? isDataTransferList(stmt) : false;
const bool isInternal = isDataTransferInternal(stmt);
- llvm::Optional<fir::ExtendedValue> descRef =
+ std::optional<fir::ExtendedValue> descRef =
isInternal ? maybeGetInternalIODescriptor(converter, loc, stmt, stmtCtx)
: std::nullopt;
const bool isInternalWithDesc = descRef.has_value();
/// Generate FIR for call to Fortran intrinsic \p name with arguments \p arg
/// and expected result type \p resultType.
fir::ExtendedValue genIntrinsicCall(llvm::StringRef name,
- llvm::Optional<mlir::Type> resultType,
+ std::optional<mlir::Type> resultType,
llvm::ArrayRef<fir::ExtendedValue> arg);
/// Search a runtime function that is associated to the generic intrinsic name
template <typename GeneratorType>
fir::ExtendedValue
outlineInExtendedWrapper(GeneratorType, llvm::StringRef name,
- llvm::Optional<mlir::Type> resultType,
+ std::optional<mlir::Type> resultType,
llvm::ArrayRef<fir::ExtendedValue> args);
template <typename GeneratorType>
}
/// Helpers to get function type from arguments and result type.
-static mlir::FunctionType getFunctionType(llvm::Optional<mlir::Type> resultType,
+static mlir::FunctionType getFunctionType(std::optional<mlir::Type> resultType,
llvm::ArrayRef<mlir::Value> arguments,
fir::FirOpBuilder &builder) {
llvm::SmallVector<mlir::Type> argTypes;
static fir::ExtendedValue
invokeHandler(IntrinsicLibrary::ElementalGenerator generator,
const IntrinsicHandler &handler,
- llvm::Optional<mlir::Type> resultType,
+ std::optional<mlir::Type> resultType,
llvm::ArrayRef<fir::ExtendedValue> args, bool outline,
IntrinsicLibrary &lib) {
assert(resultType && "expect elemental intrinsic to be functions");
static fir::ExtendedValue
invokeHandler(IntrinsicLibrary::ExtendedGenerator generator,
const IntrinsicHandler &handler,
- llvm::Optional<mlir::Type> resultType,
+ std::optional<mlir::Type> resultType,
llvm::ArrayRef<fir::ExtendedValue> args, bool outline,
IntrinsicLibrary &lib) {
assert(resultType && "expect intrinsic function");
static fir::ExtendedValue
invokeHandler(IntrinsicLibrary::SubroutineGenerator generator,
const IntrinsicHandler &handler,
- llvm::Optional<mlir::Type> resultType,
+ std::optional<mlir::Type> resultType,
llvm::ArrayRef<fir::ExtendedValue> args, bool outline,
IntrinsicLibrary &lib) {
if (handler.isElemental)
fir::ExtendedValue
IntrinsicLibrary::genIntrinsicCall(llvm::StringRef specificName,
- llvm::Optional<mlir::Type> resultType,
+ std::optional<mlir::Type> resultType,
llvm::ArrayRef<fir::ExtendedValue> args) {
llvm::StringRef name = genericName(specificName);
if (const IntrinsicHandler *handler = findIntrinsicHandler(name)) {
template <typename GeneratorType>
fir::ExtendedValue IntrinsicLibrary::outlineInExtendedWrapper(
GeneratorType generator, llvm::StringRef name,
- llvm::Optional<mlir::Type> resultType,
+ std::optional<mlir::Type> resultType,
llvm::ArrayRef<fir::ExtendedValue> args) {
if (hasAbsentOptional(args))
TODO(loc, "cannot outline call to intrinsic " + llvm::Twine(name) +
// DATE_AND_TIME
void IntrinsicLibrary::genDateAndTime(llvm::ArrayRef<fir::ExtendedValue> args) {
assert(args.size() == 4 && "date_and_time has 4 args");
- llvm::SmallVector<llvm::Optional<fir::CharBoxValue>> charArgs(3);
+ llvm::SmallVector<std::optional<fir::CharBoxValue>> charArgs(3);
for (unsigned i = 0; i < 3; ++i)
if (const fir::CharBoxValue *charBox = args[i].getCharBox())
charArgs[i] = *charBox;
fir::ExtendedValue
Fortran::lower::genIntrinsicCall(fir::FirOpBuilder &builder, mlir::Location loc,
llvm::StringRef name,
- llvm::Optional<mlir::Type> resultType,
+ std::optional<mlir::Type> resultType,
llvm::ArrayRef<fir::ExtendedValue> args,
Fortran::lower::StatementContext &stmtCtx) {
return IntrinsicLibrary{builder, loc, &stmtCtx}.genIntrinsicCall(
}
}
-llvm::Optional<size_t>
+std::optional<size_t>
Fortran::lower::ExplicitIterSpace::findArgPosition(fir::ArrayLoadOp load) {
if (lhsBases[counter]) {
auto ld = loadBindings.find(*lhsBases[counter]);
- llvm::Optional<size_t> optPos;
+ std::optional<size_t> optPos;
if (ld != loadBindings.end() && ld->second == load)
optPos = static_cast<size_t>(0u);
assert(optPos.has_value() && "load does not correspond to lhs");
u);
};
s << "LHS bases:\n";
- for (const llvm::Optional<Fortran::lower::ExplicitIterSpace::ArrayBases> &u :
+ for (const std::optional<Fortran::lower::ExplicitIterSpace::ArrayBases> &u :
e.lhsBases)
if (u)
dump(*u);
return result;
}
-static llvm::Optional<llvm::StringRef>
+static std::optional<llvm::StringRef>
hostName(const Fortran::semantics::Symbol &symbol) {
const Fortran::semantics::Scope &scope = symbol.owner();
if (scope.kind() == Fortran::semantics::Scope::Kind::Subprogram) {
[&](const Fortran::semantics::ObjectEntityDetails &) {
llvm::SmallVector<llvm::StringRef> modNames =
moduleNames(ultimateSymbol);
- llvm::Optional<llvm::StringRef> optHost = hostName(ultimateSymbol);
+ std::optional<llvm::StringRef> optHost = hostName(ultimateSymbol);
if (Fortran::semantics::IsNamedConstant(ultimateSymbol))
return fir::NameUniquer::doConstant(modNames, optHost,
symbolName);
[&](const Fortran::semantics::NamelistDetails &) {
llvm::SmallVector<llvm::StringRef> modNames =
moduleNames(ultimateSymbol);
- llvm::Optional<llvm::StringRef> optHost = hostName(ultimateSymbol);
+ std::optional<llvm::StringRef> optHost = hostName(ultimateSymbol);
return fir::NameUniquer::doNamelistGroup(modNames, optHost,
symbolName);
},
derivedType.typeSymbol().GetUltimate();
llvm::StringRef symbolName = toStringRef(ultimateSymbol.name());
llvm::SmallVector<llvm::StringRef> modNames = moduleNames(ultimateSymbol);
- llvm::Optional<llvm::StringRef> optHost = hostName(ultimateSymbol);
+ std::optional<llvm::StringRef> optHost = hostName(ultimateSymbol);
llvm::SmallVector<std::int64_t> kinds;
for (const auto ¶m :
Fortran::semantics::OrderParameterDeclarations(ultimateSymbol)) {
void Fortran::lower::genDateAndTime(fir::FirOpBuilder &builder,
mlir::Location loc,
- llvm::Optional<fir::CharBoxValue> date,
- llvm::Optional<fir::CharBoxValue> time,
- llvm::Optional<fir::CharBoxValue> zone,
+ std::optional<fir::CharBoxValue> date,
+ std::optional<fir::CharBoxValue> time,
+ std::optional<fir::CharBoxValue> zone,
mlir::Value values) {
mlir::func::FuncOp callee =
fir::runtime::getRuntimeFunc<mkRTKey(DateAndTime)>(loc, builder);
mlir::FunctionType funcTy = callee.getFunctionType();
mlir::Type idxTy = builder.getIndexType();
mlir::Value zero;
- auto splitArg = [&](llvm::Optional<fir::CharBoxValue> arg,
- mlir::Value &buffer, mlir::Value &len) {
+ auto splitArg = [&](std::optional<fir::CharBoxValue> arg, mlir::Value &buffer,
+ mlir::Value &len) {
if (arg) {
buffer = arg->getBuffer();
len = arg->getLen();
return {};
}
-llvm::Optional<fir::FortranVariableOpInterface>
+std::optional<fir::FortranVariableOpInterface>
Fortran::lower::SymMap::lookupVariableDefinition(semantics::SymbolRef symRef) {
Fortran::semantics::SymbolRef sym = symRef.get().GetUltimate();
for (auto jmap = symbolMapStack.rbegin(), jend = symbolMapStack.rend();
auto fieldRefType = builder.getRefType(lFieldTy);
mlir::Value toCoor = builder.create<fir::CoordinateOp>(
loc, fieldRefType, fir::getBase(lhs), field);
- llvm::Optional<fir::DoLoopOp> outerLoop;
+ std::optional<fir::DoLoopOp> outerLoop;
if (auto sequenceType = lFieldTy.dyn_cast<fir::SequenceType>()) {
// Create loops to assign array components elements by elements.
// Note that, since these are components, they either do not overlap,
"numeric or logical type");
}
-llvm::Optional<std::int64_t>
+std::optional<std::int64_t>
fir::factory::getExtentFromTriplet(mlir::Value lb, mlir::Value ub,
mlir::Value stride) {
- std::function<llvm::Optional<std::int64_t>(mlir::Value)> getConstantValue =
- [&](mlir::Value value) -> llvm::Optional<std::int64_t> {
+ std::function<std::optional<std::int64_t>(mlir::Value)> getConstantValue =
+ [&](mlir::Value value) -> std::optional<std::int64_t> {
if (auto valInt = fir::getIntIfConstant(value))
return *valInt;
auto *definingOp = value.getDefiningOp();
return res;
}
-std::pair<fir::ExtendedValue, llvm::Optional<hlfir::CleanupFunction>>
+std::pair<fir::ExtendedValue, std::optional<hlfir::CleanupFunction>>
hlfir::translateToExtendedValue(mlir::Location loc, fir::FirOpBuilder &builder,
hlfir::Entity entity) {
if (auto variable = entity.getIfVariableInterface())
Codes code;
std::size_t index;
std::size_t second{};
- llvm::Optional<std::function<void(mlir::func::FuncOp)>> finalizer{};
+ std::optional<std::function<void(mlir::func::FuncOp)>> finalizer{};
}; // namespace
/// Target-specific rewriting of the FIR. This is a prerequisite pass to code
}
// Determine the rewrite function, `wrap`, for the result value.
- llvm::Optional<std::function<mlir::Value(mlir::Operation *)>> wrap;
+ std::optional<std::function<mlir::Value(mlir::Operation *)>> wrap;
if (fnTy.getResults().size() == 1) {
mlir::Type ty = fnTy.getResult(0);
llvm::TypeSwitch<mlir::Type>(ty)
return hlfir::getFortranElementType(t).cast<fir::CharacterType>().getFKind();
}
-static llvm::Optional<fir::CharacterType::LenType>
+static std::optional<fir::CharacterType::LenType>
getCharacterLengthIfStatic(mlir::Type t) {
if (auto charType =
hlfir::getFortranElementType(t).dyn_cast<fir::CharacterType>())
}
static std::string doModulesHost(llvm::ArrayRef<llvm::StringRef> mods,
- llvm::Optional<llvm::StringRef> host) {
+ std::optional<llvm::StringRef> host) {
std::string result = doModules(mods);
if (host)
result.append("F").append(host->lower());
return {from.begin(), from.end()};
}
-inline llvm::Optional<llvm::StringRef>
-convertToStringRef(const llvm::Optional<std::string> &from) {
- llvm::Optional<llvm::StringRef> to;
+inline std::optional<llvm::StringRef>
+convertToStringRef(const std::optional<std::string> &from) {
+ std::optional<llvm::StringRef> to;
if (from)
to = *from;
return to;
std::string
fir::NameUniquer::doConstant(llvm::ArrayRef<llvm::StringRef> modules,
- llvm::Optional<llvm::StringRef> host,
+ std::optional<llvm::StringRef> host,
llvm::StringRef name) {
std::string result = prefix();
result.append(doModulesHost(modules, host)).append("EC");
std::string
fir::NameUniquer::doDispatchTable(llvm::ArrayRef<llvm::StringRef> modules,
- llvm::Optional<llvm::StringRef> host,
+ std::optional<llvm::StringRef> host,
llvm::StringRef name,
llvm::ArrayRef<std::int64_t> kinds) {
std::string result = prefix();
std::string fir::NameUniquer::doIntrinsicTypeDescriptor(
llvm::ArrayRef<llvm::StringRef> modules,
- llvm::Optional<llvm::StringRef> host, IntrinsicType type,
+ std::optional<llvm::StringRef> host, IntrinsicType type,
std::int64_t kind) {
const char *name = nullptr;
switch (type) {
std::string
fir::NameUniquer::doProcedure(llvm::ArrayRef<llvm::StringRef> modules,
- llvm::Optional<llvm::StringRef> host,
+ std::optional<llvm::StringRef> host,
llvm::StringRef name) {
std::string result = prefix();
result.append(doModulesHost(modules, host)).append("P");
}
std::string fir::NameUniquer::doType(llvm::ArrayRef<llvm::StringRef> modules,
- llvm::Optional<llvm::StringRef> host,
+ std::optional<llvm::StringRef> host,
llvm::StringRef name,
llvm::ArrayRef<std::int64_t> kinds) {
std::string result = prefix();
std::string
fir::NameUniquer::doTypeDescriptor(llvm::ArrayRef<llvm::StringRef> modules,
- llvm::Optional<llvm::StringRef> host,
+ std::optional<llvm::StringRef> host,
llvm::StringRef name,
llvm::ArrayRef<std::int64_t> kinds) {
std::string result = prefix();
}
std::string fir::NameUniquer::doTypeDescriptor(
- llvm::ArrayRef<std::string> modules, llvm::Optional<std::string> host,
+ llvm::ArrayRef<std::string> modules, std::optional<std::string> host,
llvm::StringRef name, llvm::ArrayRef<std::int64_t> kinds) {
auto rmodules = convertToStringRef(modules);
auto rhost = convertToStringRef(host);
std::string
fir::NameUniquer::doVariable(llvm::ArrayRef<llvm::StringRef> modules,
- llvm::Optional<llvm::StringRef> host,
+ std::optional<llvm::StringRef> host,
llvm::StringRef name) {
std::string result = prefix();
result.append(doModulesHost(modules, host)).append("E");
std::string
fir::NameUniquer::doNamelistGroup(llvm::ArrayRef<llvm::StringRef> modules,
- llvm::Optional<llvm::StringRef> host,
+ std::optional<llvm::StringRef> host,
llvm::StringRef name) {
std::string result = prefix();
result.append(doModulesHost(modules, host)).append("G");
fir::NameUniquer::deconstruct(llvm::StringRef uniq) {
if (uniq.startswith("_Q")) {
llvm::SmallVector<std::string> modules;
- llvm::Optional<std::string> host;
+ std::optional<std::string> host;
std::string name;
llvm::SmallVector<std::int64_t> kinds;
NameKind nk = NameKind::NOT_UNIQUED;
llvm::SmallVector<llvm::StringRef> modules;
for (const std::string &mod : result.second.modules)
modules.push_back(mod);
- llvm::Optional<llvm::StringRef> host;
+ std::optional<llvm::StringRef> host;
if (result.second.host)
host = *result.second.host;
return fir::NameUniquer::doVariable(modules, host, varName);
/// final number of symbols and dimensions of the affine map. Integer set if
/// possible is in Optional IntegerSet.
struct AffineIfCondition {
- using MaybeAffineExpr = llvm::Optional<mlir::AffineExpr>;
+ using MaybeAffineExpr = std::optional<mlir::AffineExpr>;
explicit AffineIfCondition(mlir::Value fc) : firCondition(fc) {
if (auto condDef = firCondition.getDefiningOp<mlir::arith::CmpIOp>())
dimCount, symCount, {constraintPair->first}, {constraintPair->second});
}
- llvm::Optional<std::pair<AffineExpr, bool>>
+ std::optional<std::pair<AffineExpr, bool>>
constraint(mlir::arith::CmpIPredicate predicate, mlir::AffineExpr basic) {
switch (predicate) {
case mlir::arith::CmpIPredicate::slt:
}
llvm::SmallVector<mlir::Value> affineArgs;
- llvm::Optional<mlir::IntegerSet> integerSet;
+ std::optional<mlir::IntegerSet> integerSet;
mlir::Value firCondition;
unsigned symCount{0u};
unsigned dimCount{0u};
return mlir::AffineMap::get(dimensions, dimensions * 3, index);
}
-static Optional<int64_t> constantIntegerLike(const mlir::Value value) {
+static std::optional<int64_t> constantIntegerLike(const mlir::Value value) {
if (auto definition = value.getDefiningOp<mlir::arith::ConstantOp>())
if (auto stepAttr = definition.getValue().dyn_cast<IntegerAttr>())
return stepAttr.getInt();
// FIXME: This algorithm has a bug. It ignores escaping references between a
// store and a load.
- llvm::Optional<WriteOp> findStoreToForward(ReadOp loadOp,
- std::vector<WriteOp> &&storeOps) {
+ std::optional<WriteOp> findStoreToForward(ReadOp loadOp,
+ std::vector<WriteOp> &&storeOps) {
llvm::SmallVector<WriteOp> candidateSet;
for (auto storeOp : storeOps)
if (candidateSet.empty())
return {};
- llvm::Optional<WriteOp> nearestStore;
+ std::optional<WriteOp> nearestStore;
for (auto candidate : candidateSet) {
auto nearerThan = [&](WriteOp otherStore) {
if (candidate == otherStore)
return nearestStore;
}
- llvm::Optional<ReadOp> findReadForWrite(WriteOp storeOp,
- std::vector<ReadOp> &&loadOps) {
+ std::optional<ReadOp> findReadForWrite(WriteOp storeOp,
+ std::vector<ReadOp> &&loadOps) {
for (auto &loadOp : loadOps) {
if (domInfo->dominates(storeOp, loadOp))
return loadOp;
/// be reliably found.
/// We expect that the argument is a result of fir.convert
/// with the destination type of !fir.box<none>.
-static llvm::Optional<mlir::Type> getArgElementType(mlir::Value val) {
+static std::optional<mlir::Type> getArgElementType(mlir::Value val) {
mlir::Operation *defOp;
do {
defOp = val.getDefiningOp();