[Flang] Switch to common::visit more call sites (#90018)
Switch to common::visit more call sites. Test plan: ninja check-all
This commit is contained in:
parent
8043356380
commit
77d8cfb3c5
@ -450,12 +450,12 @@ struct ExtractSubstringHelper {
|
||||
|
||||
template <typename T>
|
||||
static std::optional<Substring> visit(const Designator<T> &e) {
|
||||
return std::visit([](auto &&s) { return visit(s); }, e.u);
|
||||
return common::visit([](auto &&s) { return visit(s); }, e.u);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static std::optional<Substring> visit(const Expr<T> &e) {
|
||||
return std::visit([](auto &&s) { return visit(s); }, e.u);
|
||||
return common::visit([](auto &&s) { return visit(s); }, e.u);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -68,7 +68,7 @@ private:
|
||||
}
|
||||
template <typename... A>
|
||||
void show(const std::variant<A...> &u) {
|
||||
std::visit([&](const auto &v) { show(v); }, u);
|
||||
Fortran::common::visit([&](const auto &v) { show(v); }, u);
|
||||
}
|
||||
template <typename A>
|
||||
void show(const std::vector<A> &x) {
|
||||
|
||||
@ -76,7 +76,7 @@ public:
|
||||
}
|
||||
template <typename VISITOR>
|
||||
constexpr auto visit(VISITOR &&visitor) const {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
common::visitors{[&visitor](auto ref) { return visitor(ref.get()); }},
|
||||
u);
|
||||
}
|
||||
@ -494,7 +494,8 @@ struct Variable {
|
||||
|
||||
/// Is this variable a global?
|
||||
bool isGlobal() const {
|
||||
return std::visit([](const auto &x) { return x.isGlobal(); }, var);
|
||||
return Fortran::common::visit([](const auto &x) { return x.isGlobal(); },
|
||||
var);
|
||||
}
|
||||
|
||||
/// Is this a module or submodule variable?
|
||||
@ -504,7 +505,7 @@ struct Variable {
|
||||
}
|
||||
|
||||
const Fortran::semantics::Scope *getOwningScope() const {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
common::visitors{
|
||||
[](const Nominal &x) { return &x.symbol->GetUltimate().owner(); },
|
||||
[](const AggregateStore &agg) { return &agg.getOwningScope(); }},
|
||||
|
||||
@ -69,7 +69,8 @@ static Fortran::lower::SomeExpr ignoreEvConvert(const A &x) {
|
||||
inline Fortran::lower::SomeExpr
|
||||
ignoreEvConvert(const Fortran::evaluate::Expr<Fortran::evaluate::Type<
|
||||
Fortran::common::TypeCategory::Integer, 8>> &x) {
|
||||
return std::visit([](const auto &v) { return ignoreEvConvert(v); }, x.u);
|
||||
return Fortran::common::visit(
|
||||
[](const auto &v) { return ignoreEvConvert(v); }, x.u);
|
||||
}
|
||||
|
||||
/// Zip two containers of the same size together and flatten the pairs. `flatZip
|
||||
@ -119,7 +120,8 @@ public:
|
||||
return 0u;
|
||||
}
|
||||
static unsigned getHashValue(const Fortran::evaluate::Subscript &x) {
|
||||
return std::visit([&](const auto &v) { return getHashValue(v); }, x.u);
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &v) { return getHashValue(v); }, x.u);
|
||||
}
|
||||
static unsigned getHashValue(const Fortran::evaluate::Triplet &x) {
|
||||
return getHashValue(x.lower()) - getHashValue(x.upper()) * 5u -
|
||||
@ -154,7 +156,8 @@ public:
|
||||
return getHashValue(x.GetComponent()) * 13u;
|
||||
}
|
||||
static unsigned getHashValue(const Fortran::evaluate::DataRef &x) {
|
||||
return std::visit([&](const auto &v) { return getHashValue(v); }, x.u);
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &v) { return getHashValue(v); }, x.u);
|
||||
}
|
||||
static unsigned getHashValue(const Fortran::evaluate::ComplexPart &x) {
|
||||
return getHashValue(x.complex()) - static_cast<unsigned>(x.part());
|
||||
@ -247,8 +250,9 @@ public:
|
||||
return getHashValue(sym.get());
|
||||
}
|
||||
static unsigned getHashValue(const Fortran::evaluate::Substring &x) {
|
||||
return 61u * std::visit([&](const auto &p) { return getHashValue(p); },
|
||||
x.parent()) -
|
||||
return 61u *
|
||||
Fortran::common::visit(
|
||||
[&](const auto &p) { return getHashValue(p); }, x.parent()) -
|
||||
getHashValue(x.lower()) - (getHashValue(x.lower()) + 1u);
|
||||
}
|
||||
static unsigned
|
||||
@ -270,7 +274,8 @@ public:
|
||||
}
|
||||
static unsigned
|
||||
getHashValue(const Fortran::evaluate::ProcedureDesignator &x) {
|
||||
return std::visit([&](const auto &v) { return getHashValue(v); }, x.u);
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &v) { return getHashValue(v); }, x.u);
|
||||
}
|
||||
static unsigned getHashValue(const Fortran::evaluate::ProcedureRef &x) {
|
||||
unsigned args = 13u;
|
||||
@ -321,15 +326,18 @@ public:
|
||||
}
|
||||
template <typename A>
|
||||
static unsigned getHashValue(const Fortran::evaluate::Expr<A> &x) {
|
||||
return std::visit([&](const auto &v) { return getHashValue(v); }, x.u);
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &v) { return getHashValue(v); }, x.u);
|
||||
}
|
||||
static unsigned getHashValue(
|
||||
const Fortran::evaluate::Relational<Fortran::evaluate::SomeType> &x) {
|
||||
return std::visit([&](const auto &v) { return getHashValue(v); }, x.u);
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &v) { return getHashValue(v); }, x.u);
|
||||
}
|
||||
template <typename A>
|
||||
static unsigned getHashValue(const Fortran::evaluate::Designator<A> &x) {
|
||||
return std::visit([&](const auto &v) { return getHashValue(v); }, x.u);
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &v) { return getHashValue(v); }, x.u);
|
||||
}
|
||||
template <int BITS>
|
||||
static unsigned
|
||||
@ -378,7 +386,7 @@ public:
|
||||
}
|
||||
static bool isEqual(const Fortran::evaluate::Subscript &x,
|
||||
const Fortran::evaluate::Subscript &y) {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &v, const auto &w) { return isEqual(v, w); }, x.u, y.u);
|
||||
}
|
||||
static bool isEqual(const Fortran::evaluate::Triplet &x,
|
||||
@ -411,7 +419,7 @@ public:
|
||||
}
|
||||
static bool isEqual(const Fortran::evaluate::DataRef &x,
|
||||
const Fortran::evaluate::DataRef &y) {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &v, const auto &w) { return isEqual(v, w); }, x.u, y.u);
|
||||
}
|
||||
static bool isEqual(const Fortran::evaluate::ComplexPart &x,
|
||||
@ -499,7 +507,7 @@ public:
|
||||
}
|
||||
static bool isEqual(const Fortran::evaluate::Substring &x,
|
||||
const Fortran::evaluate::Substring &y) {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &p, const auto &q) { return isEqual(p, q); },
|
||||
x.parent(), y.parent()) &&
|
||||
isEqual(x.lower(), y.lower()) && isEqual(x.upper(), y.upper());
|
||||
@ -529,7 +537,7 @@ public:
|
||||
}
|
||||
static bool isEqual(const Fortran::evaluate::ProcedureDesignator &x,
|
||||
const Fortran::evaluate::ProcedureDesignator &y) {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &v, const auto &w) { return isEqual(v, w); }, x.u, y.u);
|
||||
}
|
||||
static bool isEqual(const Fortran::evaluate::ProcedureRef &x,
|
||||
@ -591,19 +599,19 @@ public:
|
||||
template <typename A>
|
||||
static bool isEqual(const Fortran::evaluate::Expr<A> &x,
|
||||
const Fortran::evaluate::Expr<A> &y) {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &v, const auto &w) { return isEqual(v, w); }, x.u, y.u);
|
||||
}
|
||||
static bool
|
||||
isEqual(const Fortran::evaluate::Relational<Fortran::evaluate::SomeType> &x,
|
||||
const Fortran::evaluate::Relational<Fortran::evaluate::SomeType> &y) {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &v, const auto &w) { return isEqual(v, w); }, x.u, y.u);
|
||||
}
|
||||
template <typename A>
|
||||
static bool isEqual(const Fortran::evaluate::Designator<A> &x,
|
||||
const Fortran::evaluate::Designator<A> &y) {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &v, const auto &w) { return isEqual(v, w); }, x.u, y.u);
|
||||
}
|
||||
template <int BITS>
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
#ifndef FORTRAN_OPTIMIZER_SUPPORT_MATCHER_H
|
||||
#define FORTRAN_OPTIMIZER_SUPPORT_MATCHER_H
|
||||
|
||||
#include "flang/Common/idioms.h"
|
||||
#include <variant>
|
||||
|
||||
// Boilerplate CRTP class for a simplified type-casing syntactic sugar. This
|
||||
@ -23,10 +24,10 @@ template<class... Ts> struct matches : Ts... { using Ts::operator()...; };
|
||||
template<class... Ts> matches(Ts...) -> matches<Ts...>;
|
||||
template<typename N> struct matcher {
|
||||
template<typename... Ts> auto match(Ts... ts) {
|
||||
return std::visit(matches{ts...}, static_cast<N*>(this)->matchee());
|
||||
return Fortran::common::visit(matches{ts...}, static_cast<N*>(this)->matchee());
|
||||
}
|
||||
template<typename... Ts> auto match(Ts... ts) const {
|
||||
return std::visit(matches{ts...}, static_cast<N const*>(this)->matchee());
|
||||
return Fortran::common::visit(matches{ts...}, static_cast<N const*>(this)->matchee());
|
||||
}
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
@ -2936,7 +2936,7 @@ static bool CheckForNonPositiveValues(FoldingContext &context,
|
||||
if (arg.Rank() > 0) {
|
||||
if (const Expr<SomeType> *expr{arg.UnwrapExpr()}) {
|
||||
if (const auto *intExpr{std::get_if<Expr<SomeInteger>>(&expr->u)}) {
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
[&](const auto &kindExpr) {
|
||||
using IntType = typename std::decay_t<decltype(kindExpr)>::Result;
|
||||
if (const auto *constArray{
|
||||
|
||||
@ -350,10 +350,10 @@ private:
|
||||
void visitAllocateOptions() {
|
||||
for (const auto &allocOption :
|
||||
std::get<std::list<Fortran::parser::AllocOpt>>(stmt.t))
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::parser::StatOrErrmsg &statOrErr) {
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::parser::StatVariable &statVar) {
|
||||
statExpr = Fortran::semantics::GetExpr(statVar);
|
||||
@ -898,15 +898,16 @@ void Fortran::lower::genDeallocateStmt(
|
||||
const Fortran::lower::SomeExpr *errMsgExpr = nullptr;
|
||||
for (const Fortran::parser::StatOrErrmsg &statOrErr :
|
||||
std::get<std::list<Fortran::parser::StatOrErrmsg>>(stmt.t))
|
||||
std::visit(Fortran::common::visitors{
|
||||
[&](const Fortran::parser::StatVariable &statVar) {
|
||||
statExpr = Fortran::semantics::GetExpr(statVar);
|
||||
},
|
||||
[&](const Fortran::parser::MsgVariable &errMsgVar) {
|
||||
errMsgExpr = Fortran::semantics::GetExpr(errMsgVar);
|
||||
},
|
||||
},
|
||||
statOrErr.u);
|
||||
Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::parser::StatVariable &statVar) {
|
||||
statExpr = Fortran::semantics::GetExpr(statVar);
|
||||
},
|
||||
[&](const Fortran::parser::MsgVariable &errMsgVar) {
|
||||
errMsgExpr = Fortran::semantics::GetExpr(errMsgVar);
|
||||
},
|
||||
},
|
||||
statOrErr.u);
|
||||
ErrorManager errorManager;
|
||||
errorManager.init(converter, loc, statExpr, errMsgExpr);
|
||||
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
||||
|
||||
@ -302,7 +302,7 @@ public:
|
||||
bool hasMainProgram = false;
|
||||
const Fortran::semantics::Symbol *globalOmpRequiresSymbol = nullptr;
|
||||
for (Fortran::lower::pft::Program::Units &u : pft.getUnits()) {
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](Fortran::lower::pft::FunctionLikeUnit &f) {
|
||||
if (f.isMainProgram())
|
||||
@ -336,7 +336,7 @@ public:
|
||||
|
||||
// Primary translation pass.
|
||||
for (Fortran::lower::pft::Program::Units &u : pft.getUnits()) {
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](Fortran::lower::pft::FunctionLikeUnit &f) { lowerFunc(f); },
|
||||
[&](Fortran::lower::pft::ModuleLikeUnit &m) { lowerMod(m); },
|
||||
@ -2062,7 +2062,7 @@ private:
|
||||
handleLocalitySpecs(info);
|
||||
|
||||
for (const auto *dir : dirs) {
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::parser::CompilerDirective::VectorAlways
|
||||
&d) { addLoopAnnotationAttr(info); },
|
||||
@ -2433,7 +2433,7 @@ private:
|
||||
}
|
||||
|
||||
void genFIR(const Fortran::parser::ForallAssignmentStmt &stmt) {
|
||||
std::visit([&](const auto &x) { genFIR(x); }, stmt.u);
|
||||
Fortran::common::visit([&](const auto &x) { genFIR(x); }, stmt.u);
|
||||
}
|
||||
|
||||
void genFIR(const Fortran::parser::EndForallStmt &) {
|
||||
@ -2494,7 +2494,7 @@ private:
|
||||
forall.t));
|
||||
for (const Fortran::parser::ForallBodyConstruct &s :
|
||||
std::get<std::list<Fortran::parser::ForallBodyConstruct>>(forall.t)) {
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::parser::WhereConstruct &b) { genFIR(b); },
|
||||
[&](const Fortran::common::Indirection<
|
||||
@ -2617,7 +2617,7 @@ private:
|
||||
void genFIR(const Fortran::parser::CompilerDirective &dir) {
|
||||
Fortran::lower::pft::Evaluation &eval = getEval();
|
||||
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::parser::CompilerDirective::VectorAlways &) {
|
||||
attachDirectiveToLoop(dir, &eval);
|
||||
@ -3198,7 +3198,7 @@ private:
|
||||
const auto &rank = std::get<Fortran::parser::SelectRankCaseStmt::Rank>(
|
||||
rankCaseStmt->t);
|
||||
assert(e->block && "missing SelectRankCaseStmt block");
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::parser::ScalarIntConstantExpr &rankExpr) {
|
||||
blockList.emplace_back(e->block);
|
||||
@ -3229,9 +3229,9 @@ private:
|
||||
"selector should not yet be set");
|
||||
Fortran::lower::StatementContext &stmtCtx =
|
||||
activeConstructStack.back().stmtCtx;
|
||||
const Fortran::lower::SomeExpr *selectorExpr =
|
||||
std::visit([](const auto &x) { return Fortran::semantics::GetExpr(x); },
|
||||
std::get<Fortran::parser::Selector>(selectRankStmt.t).u);
|
||||
const Fortran::lower::SomeExpr *selectorExpr = Fortran::common::visit(
|
||||
[](const auto &x) { return Fortran::semantics::GetExpr(x); },
|
||||
std::get<Fortran::parser::Selector>(selectRankStmt.t).u);
|
||||
assert(selectorExpr && "failed to retrieve selector expr");
|
||||
hlfir::Entity selector = Fortran::lower::convertExprToHLFIR(
|
||||
loc, *this, *selectorExpr, localSymbols, stmtCtx);
|
||||
@ -3663,7 +3663,7 @@ private:
|
||||
Fortran::parser::Label errLabel{};
|
||||
bool hasIostat{};
|
||||
for (const auto &spec : specList) {
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::parser::EndLabel &label) {
|
||||
endLabel = label.v;
|
||||
@ -4373,7 +4373,7 @@ private:
|
||||
void genAssignment(const Fortran::evaluate::Assignment &assign) {
|
||||
mlir::Location loc = toLocation();
|
||||
if (lowerToHighLevelFIR()) {
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::evaluate::Assignment::Intrinsic &) {
|
||||
genDataAssignment(assign, /*userDefinedAssignment=*/nullptr);
|
||||
@ -4401,7 +4401,7 @@ private:
|
||||
explicitIterSpace.genLoopNest();
|
||||
}
|
||||
Fortran::lower::StatementContext stmtCtx;
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
// [1] Plain old assignment.
|
||||
[&](const Fortran::evaluate::Assignment::Intrinsic &) {
|
||||
@ -4670,7 +4670,7 @@ private:
|
||||
}
|
||||
}
|
||||
void genFIR(const Fortran::parser::WhereBodyConstruct &body) {
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::parser::Statement<
|
||||
Fortran::parser::AssignmentStmt> &stmt) {
|
||||
@ -5386,18 +5386,19 @@ private:
|
||||
// The intrinsic module scope, if present, is the first scope.
|
||||
const Fortran::semantics::Scope *intrinsicModuleScope = nullptr;
|
||||
for (Fortran::lower::pft::Program::Units &u : pft.getUnits()) {
|
||||
std::visit(Fortran::common::visitors{
|
||||
[&](Fortran::lower::pft::FunctionLikeUnit &f) {
|
||||
intrinsicModuleScope = &f.getScope().parent();
|
||||
},
|
||||
[&](Fortran::lower::pft::ModuleLikeUnit &m) {
|
||||
intrinsicModuleScope = &m.getScope().parent();
|
||||
},
|
||||
[&](Fortran::lower::pft::BlockDataUnit &b) {},
|
||||
[&](Fortran::lower::pft::CompilerDirectiveUnit &d) {},
|
||||
[&](Fortran::lower::pft::OpenACCDirectiveUnit &d) {},
|
||||
},
|
||||
u);
|
||||
Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](Fortran::lower::pft::FunctionLikeUnit &f) {
|
||||
intrinsicModuleScope = &f.getScope().parent();
|
||||
},
|
||||
[&](Fortran::lower::pft::ModuleLikeUnit &m) {
|
||||
intrinsicModuleScope = &m.getScope().parent();
|
||||
},
|
||||
[&](Fortran::lower::pft::BlockDataUnit &b) {},
|
||||
[&](Fortran::lower::pft::CompilerDirectiveUnit &d) {},
|
||||
[&](Fortran::lower::pft::OpenACCDirectiveUnit &d) {},
|
||||
},
|
||||
u);
|
||||
if (intrinsicModuleScope) {
|
||||
while (!intrinsicModuleScope->IsGlobal())
|
||||
intrinsicModuleScope = &intrinsicModuleScope->parent();
|
||||
@ -5531,7 +5532,7 @@ private:
|
||||
analyzeExplicitSpace</*LHS=*/true>(lhs);
|
||||
analyzeExplicitSpace(rhs);
|
||||
};
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::evaluate::ProcedureRef &procRef) {
|
||||
// Ensure the procRef expressions are the one being visited.
|
||||
@ -5549,7 +5550,8 @@ private:
|
||||
explicitIterSpace.endAssign();
|
||||
}
|
||||
void analyzeExplicitSpace(const Fortran::parser::ForallAssignmentStmt &stmt) {
|
||||
std::visit([&](const auto &s) { analyzeExplicitSpace(s); }, stmt.u);
|
||||
Fortran::common::visit([&](const auto &s) { analyzeExplicitSpace(s); },
|
||||
stmt.u);
|
||||
}
|
||||
void analyzeExplicitSpace(const Fortran::parser::AssignmentStmt &s) {
|
||||
analyzeExplicitSpace(s.typedAssignment->v.operator->());
|
||||
@ -5594,13 +5596,14 @@ private:
|
||||
analyzeExplicitSpace(e);
|
||||
}
|
||||
void analyzeExplicitSpace(const Fortran::parser::WhereBodyConstruct &body) {
|
||||
std::visit(Fortran::common::visitors{
|
||||
[&](const Fortran::common::Indirection<
|
||||
Fortran::parser::WhereConstruct> &wc) {
|
||||
analyzeExplicitSpace(wc.value());
|
||||
},
|
||||
[&](const auto &s) { analyzeExplicitSpace(s.statement); }},
|
||||
body.u);
|
||||
Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::common::Indirection<
|
||||
Fortran::parser::WhereConstruct> &wc) {
|
||||
analyzeExplicitSpace(wc.value());
|
||||
},
|
||||
[&](const auto &s) { analyzeExplicitSpace(s.statement); }},
|
||||
body.u);
|
||||
}
|
||||
void analyzeExplicitSpace(const Fortran::parser::MaskedElsewhereStmt &stmt) {
|
||||
const Fortran::lower::SomeExpr *exp = Fortran::semantics::GetExpr(
|
||||
@ -5651,16 +5654,17 @@ private:
|
||||
.statement);
|
||||
for (const Fortran::parser::ForallBodyConstruct &s :
|
||||
std::get<std::list<Fortran::parser::ForallBodyConstruct>>(forall.t)) {
|
||||
std::visit(Fortran::common::visitors{
|
||||
[&](const Fortran::common::Indirection<
|
||||
Fortran::parser::ForallConstruct> &b) {
|
||||
analyzeExplicitSpace(b.value());
|
||||
},
|
||||
[&](const Fortran::parser::WhereConstruct &w) {
|
||||
analyzeExplicitSpace(w);
|
||||
},
|
||||
[&](const auto &b) { analyzeExplicitSpace(b.statement); }},
|
||||
s.u);
|
||||
Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::common::Indirection<
|
||||
Fortran::parser::ForallConstruct> &b) {
|
||||
analyzeExplicitSpace(b.value());
|
||||
},
|
||||
[&](const Fortran::parser::WhereConstruct &w) {
|
||||
analyzeExplicitSpace(w);
|
||||
},
|
||||
[&](const auto &b) { analyzeExplicitSpace(b.statement); }},
|
||||
s.u);
|
||||
}
|
||||
analyzeExplicitSpacePop();
|
||||
}
|
||||
@ -5715,7 +5719,7 @@ private:
|
||||
std::string getConstantExprManglePrefix(mlir::Location loc,
|
||||
const Fortran::lower::SomeExpr &expr,
|
||||
mlir::Type eleTy) {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &x) -> std::string {
|
||||
using T = std::decay_t<decltype(x)>;
|
||||
if constexpr (Fortran::common::HasMember<
|
||||
@ -5730,7 +5734,7 @@ private:
|
||||
fir::emitFatalError(loc,
|
||||
"non a constant derived type expression");
|
||||
} else {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &someKind) -> std::string {
|
||||
using T = std::decay_t<decltype(someKind)>;
|
||||
using TK = Fortran::evaluate::Type<T::Result::category,
|
||||
|
||||
@ -187,7 +187,7 @@ asImplicitArg(Fortran::evaluate::characteristics::DummyDataObject &&dummy) {
|
||||
|
||||
static Fortran::evaluate::characteristics::DummyArgument
|
||||
asImplicitArg(Fortran::evaluate::characteristics::DummyArgument &&dummy) {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](Fortran::evaluate::characteristics::DummyDataObject &obj) {
|
||||
return Fortran::evaluate::characteristics::DummyArgument(
|
||||
@ -843,7 +843,7 @@ public:
|
||||
for (auto pair : llvm::zip(procedure.dummyArguments, argumentEntities)) {
|
||||
const Fortran::evaluate::characteristics::DummyArgument
|
||||
&argCharacteristics = std::get<0>(pair);
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const auto &dummy) {
|
||||
const auto &entity = getDataObjectEntity(std::get<1>(pair));
|
||||
@ -877,7 +877,7 @@ public:
|
||||
for (auto pair : llvm::zip(procedure.dummyArguments, argumentEntities)) {
|
||||
const Fortran::evaluate::characteristics::DummyArgument
|
||||
&argCharacteristics = std::get<0>(pair);
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::evaluate::characteristics::DummyDataObject
|
||||
&dummy) {
|
||||
|
||||
@ -36,7 +36,7 @@ void Fortran::lower::ComponentPath::clear() {
|
||||
|
||||
bool Fortran::lower::isRankedArrayAccess(const Fortran::evaluate::ArrayRef &x) {
|
||||
for (const Fortran::evaluate::Subscript &sub : x.subscript()) {
|
||||
if (std::visit(
|
||||
if (Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::evaluate::Triplet &) { return true; },
|
||||
[&](const Fortran::evaluate::IndirectSubscriptIntegerExpr &e) {
|
||||
|
||||
@ -438,7 +438,7 @@ public:
|
||||
|
||||
void pushValue(mlir::Location loc, fir::FirOpBuilder &builder,
|
||||
hlfir::Entity value) {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
[&](auto &impl) { return impl.pushValue(loc, builder, value); },
|
||||
implVariant);
|
||||
}
|
||||
@ -446,7 +446,7 @@ public:
|
||||
mlir::Value startImpliedDo(mlir::Location loc, fir::FirOpBuilder &builder,
|
||||
mlir::Value lower, mlir::Value upper,
|
||||
mlir::Value stride) {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
[&](auto &impl) {
|
||||
return impl.startImpliedDo(loc, builder, lower, upper, stride);
|
||||
},
|
||||
@ -455,13 +455,13 @@ public:
|
||||
|
||||
hlfir::Entity finishArrayCtorLowering(mlir::Location loc,
|
||||
fir::FirOpBuilder &builder) {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
[&](auto &impl) { return impl.finishArrayCtorLowering(loc, builder); },
|
||||
implVariant);
|
||||
}
|
||||
|
||||
void startImpliedDoScope(llvm::StringRef doName, mlir::Value indexValue) {
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
[&](auto &impl) {
|
||||
return impl.startImpliedDoScope(doName, indexValue);
|
||||
},
|
||||
@ -469,8 +469,8 @@ public:
|
||||
}
|
||||
|
||||
void endImpliedDoScope() {
|
||||
std::visit([&](auto &impl) { return impl.endImpliedDoScope(); },
|
||||
implVariant);
|
||||
Fortran::common::visit([&](auto &impl) { return impl.endImpliedDoScope(); },
|
||||
implVariant);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -612,16 +612,17 @@ ArrayCtorAnalysis::ArrayCtorAnalysis(
|
||||
arrayValueListStack.pop_back_val();
|
||||
for (const Fortran::evaluate::ArrayConstructorValue<T> &acValue :
|
||||
*currentArrayValueList)
|
||||
std::visit(Fortran::common::visitors{
|
||||
[&](const Fortran::evaluate::ImpliedDo<T> &impledDo) {
|
||||
arrayValueListStack.push_back(&impledDo.values());
|
||||
localNumberOfImpliedDo++;
|
||||
},
|
||||
[&](const Fortran::evaluate::Expr<T> &expr) {
|
||||
localNumberOfExpr++;
|
||||
anyArrayExpr = anyArrayExpr || expr.Rank() > 0;
|
||||
}},
|
||||
acValue.u);
|
||||
Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::evaluate::ImpliedDo<T> &impledDo) {
|
||||
arrayValueListStack.push_back(&impledDo.values());
|
||||
localNumberOfImpliedDo++;
|
||||
},
|
||||
[&](const Fortran::evaluate::Expr<T> &expr) {
|
||||
localNumberOfExpr++;
|
||||
anyArrayExpr = anyArrayExpr || expr.Rank() > 0;
|
||||
}},
|
||||
acValue.u);
|
||||
anyImpliedDo = anyImpliedDo || localNumberOfImpliedDo > 0;
|
||||
|
||||
if (localNumberOfImpliedDo == 0) {
|
||||
@ -765,7 +766,7 @@ static void genAcValue(mlir::Location loc,
|
||||
impliedDoIndexValue);
|
||||
|
||||
for (const auto &acValue : impledDo.values())
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
[&](const auto &x) {
|
||||
genAcValue(loc, converter, x, symMap, stmtCtx, arrayBuilder);
|
||||
},
|
||||
@ -787,7 +788,7 @@ hlfir::EntityWithAttributes Fortran::lower::ArrayConstructorBuilder<T>::gen(
|
||||
loc, converter, arrayCtorExpr, symMap, stmtCtx);
|
||||
// Run the array lowering strategy through the ac-values.
|
||||
for (const auto &acValue : arrayCtorExpr)
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
[&](const auto &x) {
|
||||
genAcValue(loc, converter, x, symMap, stmtCtx, arrayBuilder);
|
||||
},
|
||||
|
||||
@ -935,7 +935,8 @@ struct CallCleanUp {
|
||||
mlir::Value mustFree;
|
||||
};
|
||||
void genCleanUp(mlir::Location loc, fir::FirOpBuilder &builder) {
|
||||
std::visit([&](auto &c) { c.genCleanUp(loc, builder); }, cleanUp);
|
||||
Fortran::common::visit([&](auto &c) { c.genCleanUp(loc, builder); },
|
||||
cleanUp);
|
||||
}
|
||||
std::variant<CopyIn, ExprAssociate> cleanUp;
|
||||
};
|
||||
|
||||
@ -105,7 +105,7 @@ public:
|
||||
const Fortran::lower::SomeExpr &initExpr,
|
||||
cuf::DataAttributeAttr dataAttr) {
|
||||
DenseGlobalBuilder globalBuilder;
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::evaluate::Expr<Fortran::evaluate::SomeLogical> &
|
||||
x) { globalBuilder.tryConvertingToAttributes(builder, x); },
|
||||
@ -164,7 +164,7 @@ private:
|
||||
template <typename SomeCat>
|
||||
void tryConvertingToAttributes(fir::FirOpBuilder &builder,
|
||||
const Fortran::evaluate::Expr<SomeCat> &expr) {
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
[&](const auto &x) {
|
||||
using TR = Fortran::evaluate::ResultType<decltype(x)>;
|
||||
if (const auto *constant =
|
||||
@ -796,7 +796,7 @@ static fir::ExtendedValue
|
||||
genConstantValue(Fortran::lower::AbstractConverter &converter,
|
||||
mlir::Location loc,
|
||||
const Fortran::lower::SomeExpr &constantExpr) {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &x) -> fir::ExtendedValue {
|
||||
using T = std::decay_t<decltype(x)>;
|
||||
if constexpr (Fortran::common::HasMember<
|
||||
@ -805,7 +805,7 @@ genConstantValue(Fortran::lower::AbstractConverter &converter,
|
||||
Fortran::common::TypeCategory::Derived) {
|
||||
return genConstantValue(converter, loc, x);
|
||||
} else {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &preciseKind) {
|
||||
return genConstantValue(converter, loc, preciseKind);
|
||||
},
|
||||
|
||||
@ -398,8 +398,8 @@ static bool isParenthesizedVariable(const Fortran::evaluate::Expr<T> &expr) {
|
||||
return Fortran::evaluate::IsVariable(parentheses->left());
|
||||
return false;
|
||||
} else {
|
||||
return std::visit([&](const auto &x) { return isParenthesizedVariable(x); },
|
||||
expr.u);
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &x) { return isParenthesizedVariable(x); }, expr.u);
|
||||
}
|
||||
}
|
||||
|
||||
@ -646,7 +646,7 @@ isOptimizableTranspose(Fortran::evaluate::Expr<T> expr,
|
||||
if (!isTransposeOptEnabled(converter))
|
||||
return false;
|
||||
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &e) { return isOptimizableTranspose(e, converter); },
|
||||
expr.u);
|
||||
}
|
||||
@ -696,7 +696,7 @@ public:
|
||||
// - result of NULL() or NULL(MOLD) intrinsic.
|
||||
// NULL() requires some context to be lowered, so it is not handled
|
||||
// here and must be lowered according to the context where it appears.
|
||||
ExtValue exv = std::visit(
|
||||
ExtValue exv = Fortran::common::visit(
|
||||
[&](const auto &x) { return genMutableBoxValueImpl(x); }, expr.u);
|
||||
const fir::MutableBoxValue *mutableBox =
|
||||
exv.getBoxOf<fir::MutableBoxValue>();
|
||||
@ -737,7 +737,7 @@ public:
|
||||
template <typename T>
|
||||
ExtValue
|
||||
genMutableBoxValueImpl(const Fortran::evaluate::Designator<T> &designator) {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::evaluate::SymbolRef &sym) -> ExtValue {
|
||||
return converter.getSymbolExtendedValue(*sym, &symMap);
|
||||
@ -754,8 +754,8 @@ public:
|
||||
|
||||
template <typename T>
|
||||
ExtValue genMutableBoxValueImpl(const Fortran::evaluate::Expr<T> &expr) {
|
||||
return std::visit([&](const auto &x) { return genMutableBoxValueImpl(x); },
|
||||
expr.u);
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &x) { return genMutableBoxValueImpl(x); }, expr.u);
|
||||
}
|
||||
|
||||
mlir::Location getLoc() { return location; }
|
||||
@ -1222,7 +1222,8 @@ public:
|
||||
|
||||
ExtValue
|
||||
genval(const Fortran::evaluate::Relational<Fortran::evaluate::SomeType> &op) {
|
||||
return std::visit([&](const auto &x) { return genval(x); }, op.u);
|
||||
return Fortran::common::visit([&](const auto &x) { return genval(x); },
|
||||
op.u);
|
||||
}
|
||||
|
||||
template <Fortran::common::TypeCategory TC1, int KIND,
|
||||
@ -1341,7 +1342,7 @@ public:
|
||||
/// Reference to a substring.
|
||||
ExtValue gen(const Fortran::evaluate::Substring &s) {
|
||||
// Get base string
|
||||
auto baseString = std::visit(
|
||||
auto baseString = Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::evaluate::DataRef &x) { return gen(x); },
|
||||
[&](const Fortran::evaluate::StaticDataObject::Pointer &p)
|
||||
@ -1400,10 +1401,12 @@ public:
|
||||
}
|
||||
|
||||
ExtValue gen(const Fortran::evaluate::DataRef &dref) {
|
||||
return std::visit([&](const auto &x) { return gen(x); }, dref.u);
|
||||
return Fortran::common::visit([&](const auto &x) { return gen(x); },
|
||||
dref.u);
|
||||
}
|
||||
ExtValue genval(const Fortran::evaluate::DataRef &dref) {
|
||||
return std::visit([&](const auto &x) { return genval(x); }, dref.u);
|
||||
return Fortran::common::visit([&](const auto &x) { return genval(x); },
|
||||
dref.u);
|
||||
}
|
||||
|
||||
// Helper function to turn the Component structure into a list of nested
|
||||
@ -1418,7 +1421,7 @@ public:
|
||||
std::list<const Fortran::evaluate::Component *> &list) {
|
||||
if (!getLastSym(cmpt).test(Fortran::semantics::Symbol::Flag::ParentComp))
|
||||
list.push_front(&cmpt);
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::evaluate::Component &x) {
|
||||
if (Fortran::semantics::IsAllocatableOrPointer(getLastSym(x)))
|
||||
@ -1713,11 +1716,12 @@ public:
|
||||
|
||||
template <typename A>
|
||||
ExtValue gen(const Fortran::evaluate::Designator<A> &des) {
|
||||
return std::visit([&](const auto &x) { return gen(x); }, des.u);
|
||||
return Fortran::common::visit([&](const auto &x) { return gen(x); }, des.u);
|
||||
}
|
||||
template <typename A>
|
||||
ExtValue genval(const Fortran::evaluate::Designator<A> &des) {
|
||||
return std::visit([&](const auto &x) { return genval(x); }, des.u);
|
||||
return Fortran::common::visit([&](const auto &x) { return genval(x); },
|
||||
des.u);
|
||||
}
|
||||
|
||||
mlir::Type genType(const Fortran::evaluate::DynamicType &dt) {
|
||||
@ -2900,8 +2904,8 @@ public:
|
||||
}
|
||||
template <typename T>
|
||||
bool isTransformationalRef(Fortran::evaluate::Expr<T> expr) {
|
||||
return std::visit([&](const auto &e) { return isTransformationalRef(e); },
|
||||
expr.u);
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &e) { return isTransformationalRef(e); }, expr.u);
|
||||
}
|
||||
|
||||
template <typename A>
|
||||
@ -2914,11 +2918,13 @@ public:
|
||||
/// value, so it may be possible to avoid making a temporary.
|
||||
template <typename A>
|
||||
ExtValue asArrayArg(const Fortran::evaluate::Expr<A> &x) {
|
||||
return std::visit([&](const auto &e) { return asArrayArg(e, x); }, x.u);
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &e) { return asArrayArg(e, x); }, x.u);
|
||||
}
|
||||
template <typename A, typename B>
|
||||
ExtValue asArrayArg(const Fortran::evaluate::Expr<A> &x, const B &y) {
|
||||
return std::visit([&](const auto &e) { return asArrayArg(e, y); }, x.u);
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &e) { return asArrayArg(e, y); }, x.u);
|
||||
}
|
||||
template <typename A, typename B>
|
||||
ExtValue asArrayArg(const Fortran::evaluate::Designator<A> &, const B &x) {
|
||||
@ -2956,7 +2962,8 @@ public:
|
||||
if (isScalar(x) ||
|
||||
Fortran::evaluate::UnwrapWholeSymbolOrComponentDataRef(x) ||
|
||||
(isTransformationalRef(x) && !isOptimizableTranspose(x, converter)))
|
||||
return std::visit([&](const auto &e) { return genref(e); }, x.u);
|
||||
return Fortran::common::visit([&](const auto &e) { return genref(e); },
|
||||
x.u);
|
||||
if (useBoxArg)
|
||||
return asArrayArg(x);
|
||||
return asArray(x);
|
||||
@ -2967,7 +2974,8 @@ public:
|
||||
return val;
|
||||
if (isScalar(x) || Fortran::evaluate::UnwrapWholeSymbolDataRef(x) ||
|
||||
inInitializer)
|
||||
return std::visit([&](const auto &e) { return genval(e); }, x.u);
|
||||
return Fortran::common::visit([&](const auto &e) { return genval(e); },
|
||||
x.u);
|
||||
return asArray(x);
|
||||
}
|
||||
|
||||
@ -2976,7 +2984,8 @@ public:
|
||||
Fortran::common::TypeCategory::Logical, KIND>> &exp) {
|
||||
if (mlir::Value val = getIfOverridenExpr(exp))
|
||||
return val;
|
||||
return std::visit([&](const auto &e) { return genval(e); }, exp.u);
|
||||
return Fortran::common::visit([&](const auto &e) { return genval(e); },
|
||||
exp.u);
|
||||
}
|
||||
|
||||
using RefSet =
|
||||
@ -3462,7 +3471,7 @@ public:
|
||||
|
||||
ExtValue lowerBoxedArrayExpr(const Fortran::lower::SomeExpr &exp) {
|
||||
PushSemantics(ConstituentSemantics::BoxValue);
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &e) {
|
||||
auto f = genarr(e);
|
||||
ExtValue exv = f(IterationSpace{});
|
||||
@ -3824,28 +3833,29 @@ private:
|
||||
fir::factory::getExtents(loc, builder, exv);
|
||||
mlir::Value one = builder.createIntegerConstant(loc, idxTy, 1);
|
||||
for (auto ss : llvm::enumerate(x.subscript())) {
|
||||
std::visit(Fortran::common::visitors{
|
||||
[&](const Fortran::evaluate::Triplet &trip) {
|
||||
// For a subscript of triple notation, we compute the
|
||||
// range of this dimension of the iteration space.
|
||||
auto lo = [&]() {
|
||||
if (auto optLo = trip.lower())
|
||||
return fir::getBase(asScalar(*optLo));
|
||||
return getLBound(exv, ss.index(), one);
|
||||
}();
|
||||
auto hi = [&]() {
|
||||
if (auto optHi = trip.upper())
|
||||
return fir::getBase(asScalar(*optHi));
|
||||
return getUBound(exv, ss.index(), one);
|
||||
}();
|
||||
auto step = builder.createConvert(
|
||||
loc, idxTy, fir::getBase(asScalar(trip.stride())));
|
||||
auto extent = builder.genExtentFromTriplet(loc, lo, hi,
|
||||
step, idxTy);
|
||||
destShape.push_back(extent);
|
||||
},
|
||||
[&](auto) {}},
|
||||
ss.value().u);
|
||||
Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::evaluate::Triplet &trip) {
|
||||
// For a subscript of triple notation, we compute the
|
||||
// range of this dimension of the iteration space.
|
||||
auto lo = [&]() {
|
||||
if (auto optLo = trip.lower())
|
||||
return fir::getBase(asScalar(*optLo));
|
||||
return getLBound(exv, ss.index(), one);
|
||||
}();
|
||||
auto hi = [&]() {
|
||||
if (auto optHi = trip.upper())
|
||||
return fir::getBase(asScalar(*optHi));
|
||||
return getUBound(exv, ss.index(), one);
|
||||
}();
|
||||
auto step = builder.createConvert(
|
||||
loc, idxTy, fir::getBase(asScalar(trip.stride())));
|
||||
auto extent =
|
||||
builder.genExtentFromTriplet(loc, lo, hi, step, idxTy);
|
||||
destShape.push_back(extent);
|
||||
},
|
||||
[&](auto) {}},
|
||||
ss.value().u);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -3855,8 +3865,8 @@ private:
|
||||
return genShapeFromDataRef(x.GetComponent());
|
||||
}
|
||||
bool genShapeFromDataRef(const Fortran::evaluate::DataRef &x) {
|
||||
return std::visit([&](const auto &v) { return genShapeFromDataRef(v); },
|
||||
x.u);
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &v) { return genShapeFromDataRef(v); }, x.u);
|
||||
}
|
||||
|
||||
/// When in an explicit space, the ranked component must be evaluated to
|
||||
@ -3890,7 +3900,7 @@ private:
|
||||
TODO(getLoc(),
|
||||
"polymorphic array expression lowering with vector subscript");
|
||||
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &e) { return lowerArrayExpression(genarr(e), resTy); },
|
||||
exp.u);
|
||||
}
|
||||
@ -5012,10 +5022,12 @@ private:
|
||||
LLVM_DEBUG(Fortran::lower::DumpEvaluateExpr::dump(llvm::dbgs(), x));
|
||||
if (isArray(x) || (explicitSpaceIsActive() && isLeftHandSide()) ||
|
||||
isElementalProcWithArrayArgs(x))
|
||||
return std::visit([&](const auto &e) { return genarr(e); }, x.u);
|
||||
return Fortran::common::visit([&](const auto &e) { return genarr(e); },
|
||||
x.u);
|
||||
if (explicitSpaceIsActive()) {
|
||||
assert(!isArray(x) && !isLeftHandSide());
|
||||
auto cc = std::visit([&](const auto &e) { return genarr(e); }, x.u);
|
||||
auto cc =
|
||||
Fortran::common::visit([&](const auto &e) { return genarr(e); }, x.u);
|
||||
auto result = cc(IterationSpace{});
|
||||
return [=](IterSpace) { return result; };
|
||||
}
|
||||
@ -5289,7 +5301,8 @@ private:
|
||||
static Fortran::lower::SomeExpr
|
||||
ignoreEvConvert(const Fortran::evaluate::Expr<Fortran::evaluate::Type<
|
||||
Fortran::common::TypeCategory::Integer, 8>> &x) {
|
||||
return std::visit([&](const auto &v) { return ignoreEvConvert(v); }, x.u);
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &v) { return ignoreEvConvert(v); }, x.u);
|
||||
}
|
||||
template <Fortran::common::TypeCategory FROM>
|
||||
static Fortran::lower::SomeExpr ignoreEvConvert(
|
||||
@ -5310,8 +5323,8 @@ private:
|
||||
template <typename A>
|
||||
static const Fortran::semantics::Symbol *
|
||||
extractSubscriptSymbol(const Fortran::evaluate::Expr<A> &x) {
|
||||
return std::visit([&](const auto &v) { return extractSubscriptSymbol(v); },
|
||||
x.u);
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &v) { return extractSubscriptSymbol(v); }, x.u);
|
||||
}
|
||||
template <typename A>
|
||||
static const Fortran::semantics::Symbol *
|
||||
@ -5420,7 +5433,7 @@ private:
|
||||
std::size_t shapeIndex = 0;
|
||||
for (auto sub : llvm::enumerate(x.subscript())) {
|
||||
const std::size_t subsIndex = sub.index();
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::evaluate::Triplet &t) {
|
||||
mlir::Value lowerBound;
|
||||
@ -6034,8 +6047,8 @@ private:
|
||||
/// Substrings (see 9.4.1)
|
||||
CC genarr(const Fortran::evaluate::Substring &x, ComponentPath &components) {
|
||||
components.substring = &x;
|
||||
return std::visit([&](const auto &v) { return genarr(v, components); },
|
||||
x.parent());
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &v) { return genarr(v, components); }, x.parent());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -6333,7 +6346,7 @@ private:
|
||||
stmtCtx.pushScope();
|
||||
std::optional<mlir::Value> charLen;
|
||||
for (const Fortran::evaluate::ArrayConstructorValue<A> &acv : x.values()) {
|
||||
auto [exv, copyNeeded] = std::visit(
|
||||
auto [exv, copyNeeded] = Fortran::common::visit(
|
||||
[&](const auto &v) {
|
||||
return genArrayCtorInitializer(v, resTy, mem, buffPos, buffSize,
|
||||
stmtCtx);
|
||||
@ -6417,7 +6430,7 @@ private:
|
||||
// Populate the buffer with the elements, growing as necessary.
|
||||
std::optional<mlir::Value> charLen;
|
||||
for (const auto &expr : x) {
|
||||
auto [exv, copyNeeded] = std::visit(
|
||||
auto [exv, copyNeeded] = Fortran::common::visit(
|
||||
[&](const auto &e) {
|
||||
return genArrayCtorInitializer(e, resTy, mem, buffPos, buffSize,
|
||||
stmtCtx);
|
||||
@ -6582,22 +6595,24 @@ private:
|
||||
}
|
||||
CC genarr(
|
||||
const Fortran::evaluate::Relational<Fortran::evaluate::SomeType> &r) {
|
||||
return std::visit([&](const auto &x) { return genarr(x); }, r.u);
|
||||
return Fortran::common::visit([&](const auto &x) { return genarr(x); },
|
||||
r.u);
|
||||
}
|
||||
|
||||
template <typename A>
|
||||
CC genarr(const Fortran::evaluate::Designator<A> &des) {
|
||||
ComponentPath components(des.Rank() > 0);
|
||||
return std::visit([&](const auto &x) { return genarr(x, components); },
|
||||
des.u);
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &x) { return genarr(x, components); }, des.u);
|
||||
}
|
||||
|
||||
/// Is the path component rank > 0?
|
||||
static bool ranked(const PathComponent &x) {
|
||||
return std::visit(Fortran::common::visitors{
|
||||
[](const ImplicitSubscripts &) { return false; },
|
||||
[](const auto *v) { return v->Rank() > 0; }},
|
||||
x);
|
||||
return Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[](const ImplicitSubscripts &) { return false; },
|
||||
[](const auto *v) { return v->Rank() > 0; }},
|
||||
x);
|
||||
}
|
||||
|
||||
void extendComponent(Fortran::lower::ComponentPath &component,
|
||||
@ -6653,7 +6668,7 @@ private:
|
||||
: nextPathSemantics());
|
||||
unsigned index = 0;
|
||||
for (const auto &v : llvm::reverse(revPath)) {
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const ImplicitSubscripts &) {
|
||||
prefix = false;
|
||||
@ -6678,7 +6693,7 @@ private:
|
||||
unsigned ssIndex = 0u;
|
||||
llvm::SmallVector<mlir::Value> componentsToAdd;
|
||||
for (const auto &ss : x->subscript()) {
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::evaluate::
|
||||
IndirectSubscriptIntegerExpr &ie) {
|
||||
@ -7099,8 +7114,8 @@ private:
|
||||
}
|
||||
|
||||
CC genarr(const Fortran::evaluate::DataRef &x, ComponentPath &components) {
|
||||
return std::visit([&](const auto &v) { return genarr(v, components); },
|
||||
x.u);
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &v) { return genarr(v, components); }, x.u);
|
||||
}
|
||||
|
||||
bool pathIsEmpty(const ComponentPath &components) {
|
||||
@ -7575,13 +7590,13 @@ void Fortran::lower::createArrayLoads(
|
||||
};
|
||||
if (esp.lhsBases[counter]) {
|
||||
auto &base = *esp.lhsBases[counter];
|
||||
auto load = std::visit(genLoad, base);
|
||||
auto load = Fortran::common::visit(genLoad, base);
|
||||
esp.initialArgs.push_back(load);
|
||||
esp.resetInnerArgs();
|
||||
esp.bindLoad(base, load);
|
||||
}
|
||||
for (const auto &base : esp.rhsBases[counter])
|
||||
esp.bindLoad(base, std::visit(genLoad, base));
|
||||
esp.bindLoad(base, Fortran::common::visit(genLoad, base));
|
||||
}
|
||||
|
||||
void Fortran::lower::createArrayMergeStores(
|
||||
|
||||
@ -75,7 +75,7 @@ public:
|
||||
hlfir::EntityWithAttributes
|
||||
gen(const CharacterDesignators &designatorVariant,
|
||||
bool vectorSubscriptDesignatorToValue = true) {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &x) -> hlfir::EntityWithAttributes {
|
||||
return genLeafPartRef(x, vectorSubscriptDesignatorToValue);
|
||||
},
|
||||
@ -88,7 +88,7 @@ public:
|
||||
hlfir::EntityWithAttributes
|
||||
gen(const RealDesignators &designatorVariant,
|
||||
bool vectorSubscriptDesignatorToValue = true) {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &x) -> hlfir::EntityWithAttributes {
|
||||
return genLeafPartRef(x, vectorSubscriptDesignatorToValue);
|
||||
},
|
||||
@ -101,7 +101,7 @@ public:
|
||||
hlfir::EntityWithAttributes
|
||||
gen(const OtherDesignators &designatorVariant,
|
||||
bool vectorSubscriptDesignatorToValue = true) {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &x) -> hlfir::EntityWithAttributes {
|
||||
return genLeafPartRef(x, vectorSubscriptDesignatorToValue);
|
||||
},
|
||||
@ -169,7 +169,7 @@ public:
|
||||
|
||||
fir::FortranVariableOpInterface
|
||||
gen(const Fortran::evaluate::DataRef &dataRef) {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
Fortran::common::visitors{[&](const auto &x) { return gen(x); }},
|
||||
dataRef.u);
|
||||
}
|
||||
@ -364,7 +364,7 @@ private:
|
||||
fir::FortranVariableOpInterface
|
||||
gen(const Fortran::evaluate::Substring &substring) {
|
||||
PartInfo partInfo;
|
||||
mlir::Type baseStringType = std::visit(
|
||||
mlir::Type baseStringType = Fortran::common::visit(
|
||||
[&](const auto &x) { return visit(x, partInfo); }, substring.parent());
|
||||
assert(partInfo.typeParams.size() == 1 && "expect base string length");
|
||||
// Compute the substring lower and upper bound.
|
||||
@ -436,8 +436,8 @@ private:
|
||||
|
||||
mlir::Type visit(const Fortran::evaluate::DataRef &dataRef,
|
||||
PartInfo &partInfo) {
|
||||
return std::visit([&](const auto &x) { return visit(x, partInfo); },
|
||||
dataRef.u);
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &x) { return visit(x, partInfo); }, dataRef.u);
|
||||
}
|
||||
|
||||
mlir::Type
|
||||
@ -892,7 +892,7 @@ hlfir::EntityWithAttributes HlfirDesignatorBuilder::genDesignatorExpr(
|
||||
bool vectorSubscriptDesignatorToValue) {
|
||||
// Expr<SomeType> plumbing to unwrap Designator<T> and call
|
||||
// gen(Designator<T>.u).
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &x) -> hlfir::EntityWithAttributes {
|
||||
using T = std::decay_t<decltype(x)>;
|
||||
if constexpr (Fortran::common::HasMember<
|
||||
@ -904,7 +904,7 @@ hlfir::EntityWithAttributes HlfirDesignatorBuilder::genDesignatorExpr(
|
||||
.u,
|
||||
vectorSubscriptDesignatorToValue);
|
||||
} else {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &preciseKind) {
|
||||
using TK =
|
||||
typename std::decay_t<decltype(preciseKind)>::Result;
|
||||
@ -1426,7 +1426,8 @@ public:
|
||||
return hlfir::EntityWithAttributes{match->second};
|
||||
}
|
||||
}
|
||||
return std::visit([&](const auto &x) { return gen(x); }, expr.u);
|
||||
return Fortran::common::visit([&](const auto &x) { return gen(x); },
|
||||
expr.u);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -1594,7 +1595,7 @@ private:
|
||||
|
||||
hlfir::EntityWithAttributes
|
||||
gen(const Fortran::evaluate::Relational<Fortran::evaluate::SomeType> &op) {
|
||||
return std::visit([&](const auto &x) { return gen(x); }, op.u);
|
||||
return Fortran::common::visit([&](const auto &x) { return gen(x); }, op.u);
|
||||
}
|
||||
|
||||
hlfir::EntityWithAttributes gen(const Fortran::evaluate::TypeParamInquiry &) {
|
||||
|
||||
@ -212,7 +212,7 @@ struct TypeBuilderImpl {
|
||||
}
|
||||
|
||||
mlir::Type genTypelessExprType(const Fortran::lower::SomeExpr &expr) {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::evaluate::BOZLiteralConstant &) -> mlir::Type {
|
||||
return mlir::NoneType::get(context);
|
||||
|
||||
@ -836,7 +836,7 @@ struct PeelConvert {
|
||||
static Fortran::semantics::MaybeExpr visit_with_category(
|
||||
const Fortran::evaluate::Expr<Fortran::evaluate::Type<Category, Kind>>
|
||||
&expr) {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
[](auto &&s) { return visit_with_category<Category, Kind>(s); },
|
||||
expr.u);
|
||||
}
|
||||
@ -859,12 +859,12 @@ struct PeelConvert {
|
||||
static Fortran::semantics::MaybeExpr
|
||||
visit(const Fortran::evaluate::Expr<Fortran::evaluate::SomeKind<Category>>
|
||||
&expr) {
|
||||
return std::visit([](auto &&s) { return visit_with_category<Category>(s); },
|
||||
expr.u);
|
||||
return Fortran::common::visit(
|
||||
[](auto &&s) { return visit_with_category<Category>(s); }, expr.u);
|
||||
}
|
||||
static Fortran::semantics::MaybeExpr
|
||||
visit(const Fortran::evaluate::Expr<Fortran::evaluate::SomeType> &expr) {
|
||||
return std::visit([](auto &&s) { return visit(s); }, expr.u);
|
||||
return Fortran::common::visit([](auto &&s) { return visit(s); }, expr.u);
|
||||
}
|
||||
template <typename T> //
|
||||
static Fortran::semantics::MaybeExpr visit(const T &) {
|
||||
|
||||
@ -1388,7 +1388,7 @@ static void threadSpecs(Fortran::lower::AbstractConverter &converter,
|
||||
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
||||
for (const auto &spec : specList) {
|
||||
makeNextConditionalOn(builder, loc, checkResult, ok);
|
||||
ok = std::visit(
|
||||
ok = Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::parser::IoControlSpec::Size &x) -> mlir::Value {
|
||||
// Size must be queried after the related READ runtime calls, not
|
||||
@ -1425,7 +1425,7 @@ ConditionSpecInfo lowerErrorSpec(Fortran::lower::AbstractConverter &converter,
|
||||
ConditionSpecInfo csi;
|
||||
const Fortran::lower::SomeExpr *ioMsgExpr = nullptr;
|
||||
for (const auto &spec : specList) {
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::parser::StatVariable &var) {
|
||||
csi.ioStatExpr = Fortran::semantics::GetExpr(var);
|
||||
@ -2397,7 +2397,7 @@ lowerIdExpr(Fortran::lower::AbstractConverter &converter, mlir::Location loc,
|
||||
const std::list<Fortran::parser::InquireSpec> &ispecs,
|
||||
Fortran::lower::StatementContext &stmtCtx) {
|
||||
for (const Fortran::parser::InquireSpec &spec : ispecs)
|
||||
if (mlir::Value v = std::visit(
|
||||
if (mlir::Value v = Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::parser::IdExpr &idExpr) {
|
||||
return fir::getBase(converter.genExprValue(
|
||||
@ -2419,11 +2419,11 @@ static void threadInquire(Fortran::lower::AbstractConverter &converter,
|
||||
mlir::Value idExpr = lowerIdExpr(converter, loc, ispecs, stmtCtx);
|
||||
for (const Fortran::parser::InquireSpec &spec : ispecs) {
|
||||
makeNextConditionalOn(builder, loc, checkResult, ok);
|
||||
ok = std::visit(Fortran::common::visitors{[&](const auto &x) {
|
||||
return genInquireSpec(converter, loc, cookie, idExpr, x,
|
||||
stmtCtx);
|
||||
}},
|
||||
spec.u);
|
||||
ok = Fortran::common::visit(Fortran::common::visitors{[&](const auto &x) {
|
||||
return genInquireSpec(converter, loc, cookie,
|
||||
idExpr, x, stmtCtx);
|
||||
}},
|
||||
spec.u);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -21,14 +21,14 @@
|
||||
|
||||
unsigned Fortran::lower::getHashValue(
|
||||
const Fortran::lower::ExplicitIterSpace::ArrayBases &x) {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
[&](const auto *p) { return HashEvaluateExpr::getHashValue(*p); }, x);
|
||||
}
|
||||
|
||||
bool Fortran::lower::isEqual(
|
||||
const Fortran::lower::ExplicitIterSpace::ArrayBases &x,
|
||||
const Fortran::lower::ExplicitIterSpace::ArrayBases &y) {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
// Fortran::semantics::Symbol * are the exception here. These pointers
|
||||
// have identity; if two Symbol * values are the same (different) then
|
||||
@ -169,7 +169,7 @@ private:
|
||||
}
|
||||
template <typename... A>
|
||||
RT find(const std::variant<A...> &u) {
|
||||
return std::visit([&](const auto &v) { return find(v); }, u);
|
||||
return Fortran::common::visit([&](const auto &v) { return find(v); }, u);
|
||||
}
|
||||
template <typename A>
|
||||
RT find(const std::vector<A> &x) {
|
||||
@ -361,22 +361,23 @@ llvm::raw_ostream &
|
||||
Fortran::lower::operator<<(llvm::raw_ostream &s,
|
||||
const Fortran::lower::ExplicitIterSpace &e) {
|
||||
auto dump = [&](const auto &u) {
|
||||
std::visit(Fortran::common::visitors{
|
||||
[&](const Fortran::semantics::Symbol *y) {
|
||||
s << " " << *y << '\n';
|
||||
},
|
||||
[&](const Fortran::evaluate::ArrayRef *y) {
|
||||
s << " ";
|
||||
if (y->base().IsSymbol())
|
||||
s << y->base().GetFirstSymbol();
|
||||
else
|
||||
s << y->base().GetComponent().GetLastSymbol();
|
||||
s << '\n';
|
||||
},
|
||||
[&](const Fortran::evaluate::Component *y) {
|
||||
s << " " << y->GetLastSymbol() << '\n';
|
||||
}},
|
||||
u);
|
||||
Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::semantics::Symbol *y) {
|
||||
s << " " << *y << '\n';
|
||||
},
|
||||
[&](const Fortran::evaluate::ArrayRef *y) {
|
||||
s << " ";
|
||||
if (y->base().IsSymbol())
|
||||
s << y->base().GetFirstSymbol();
|
||||
else
|
||||
s << y->base().GetComponent().GetLastSymbol();
|
||||
s << '\n';
|
||||
},
|
||||
[&](const Fortran::evaluate::Component *y) {
|
||||
s << " " << y->GetLastSymbol() << '\n';
|
||||
}},
|
||||
u);
|
||||
};
|
||||
s << "LHS bases:\n";
|
||||
for (const std::optional<Fortran::lower::ExplicitIterSpace::ArrayBases> &u :
|
||||
|
||||
@ -110,7 +110,7 @@ std::string Fortran::lower::mangle::mangleName(
|
||||
return fir::NameUniquer::doVariable(modules, procs, blockId, symbolName);
|
||||
};
|
||||
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::semantics::MainProgramDetails &) {
|
||||
return fir::NameUniquer::doProgramEntry().str();
|
||||
|
||||
@ -46,14 +46,15 @@ static mlir::Location
|
||||
genOperandLocation(Fortran::lower::AbstractConverter &converter,
|
||||
const Fortran::parser::AccObject &accObject) {
|
||||
mlir::Location loc = converter.genUnknownLocation();
|
||||
std::visit(Fortran::common::visitors{
|
||||
[&](const Fortran::parser::Designator &designator) {
|
||||
loc = converter.genLocation(designator.source);
|
||||
},
|
||||
[&](const Fortran::parser::Name &name) {
|
||||
loc = converter.genLocation(name.source);
|
||||
}},
|
||||
accObject.u);
|
||||
Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::parser::Designator &designator) {
|
||||
loc = converter.genLocation(designator.source);
|
||||
},
|
||||
[&](const Fortran::parser::Name &name) {
|
||||
loc = converter.genLocation(name.source);
|
||||
}},
|
||||
accObject.u);
|
||||
return loc;
|
||||
}
|
||||
|
||||
@ -297,8 +298,8 @@ genDataOperandOperations(const Fortran::parser::AccObjectList &objectList,
|
||||
std::stringstream asFortran;
|
||||
mlir::Location operandLocation = genOperandLocation(converter, accObject);
|
||||
Fortran::semantics::Symbol &symbol = getSymbolFromAccObject(accObject);
|
||||
Fortran::semantics::MaybeExpr designator =
|
||||
std::visit([&](auto &&s) { return ea.Analyze(s); }, accObject.u);
|
||||
Fortran::semantics::MaybeExpr designator = Fortran::common::visit(
|
||||
[&](auto &&s) { return ea.Analyze(s); }, accObject.u);
|
||||
Fortran::lower::AddrAndBoundsInfo info =
|
||||
Fortran::lower::gatherDataOperandAddrAndBounds<
|
||||
mlir::acc::DataBoundsOp, mlir::acc::DataBoundsType>(
|
||||
@ -335,8 +336,8 @@ static void genDeclareDataOperandOperations(
|
||||
std::stringstream asFortran;
|
||||
mlir::Location operandLocation = genOperandLocation(converter, accObject);
|
||||
Fortran::semantics::Symbol &symbol = getSymbolFromAccObject(accObject);
|
||||
Fortran::semantics::MaybeExpr designator =
|
||||
std::visit([&](auto &&s) { return ea.Analyze(s); }, accObject.u);
|
||||
Fortran::semantics::MaybeExpr designator = Fortran::common::visit(
|
||||
[&](auto &&s) { return ea.Analyze(s); }, accObject.u);
|
||||
Fortran::lower::AddrAndBoundsInfo info =
|
||||
Fortran::lower::gatherDataOperandAddrAndBounds<
|
||||
mlir::acc::DataBoundsOp, mlir::acc::DataBoundsType>(
|
||||
@ -790,8 +791,8 @@ genPrivatizations(const Fortran::parser::AccObjectList &objectList,
|
||||
std::stringstream asFortran;
|
||||
mlir::Location operandLocation = genOperandLocation(converter, accObject);
|
||||
Fortran::semantics::Symbol &symbol = getSymbolFromAccObject(accObject);
|
||||
Fortran::semantics::MaybeExpr designator =
|
||||
std::visit([&](auto &&s) { return ea.Analyze(s); }, accObject.u);
|
||||
Fortran::semantics::MaybeExpr designator = Fortran::common::visit(
|
||||
[&](auto &&s) { return ea.Analyze(s); }, accObject.u);
|
||||
Fortran::lower::AddrAndBoundsInfo info =
|
||||
Fortran::lower::gatherDataOperandAddrAndBounds<
|
||||
mlir::acc::DataBoundsOp, mlir::acc::DataBoundsType>(
|
||||
@ -1364,8 +1365,8 @@ genReductions(const Fortran::parser::AccObjectListWithReduction &objectList,
|
||||
std::stringstream asFortran;
|
||||
mlir::Location operandLocation = genOperandLocation(converter, accObject);
|
||||
Fortran::semantics::Symbol &symbol = getSymbolFromAccObject(accObject);
|
||||
Fortran::semantics::MaybeExpr designator =
|
||||
std::visit([&](auto &&s) { return ea.Analyze(s); }, accObject.u);
|
||||
Fortran::semantics::MaybeExpr designator = Fortran::common::visit(
|
||||
[&](auto &&s) { return ea.Analyze(s); }, accObject.u);
|
||||
Fortran::lower::AddrAndBoundsInfo info =
|
||||
Fortran::lower::gatherDataOperandAddrAndBounds<
|
||||
mlir::acc::DataBoundsOp, mlir::acc::DataBoundsType>(
|
||||
@ -3414,7 +3415,7 @@ static void genGlobalCtors(Fortran::lower::AbstractConverter &converter,
|
||||
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
|
||||
for (const auto &accObject : accObjectList.v) {
|
||||
mlir::Location operandLocation = genOperandLocation(converter, accObject);
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::parser::Designator &designator) {
|
||||
if (const auto *name =
|
||||
@ -3993,7 +3994,7 @@ genACC(Fortran::lower::AbstractConverter &converter,
|
||||
const Fortran::parser::OpenACCAtomicConstruct &atomicConstruct) {
|
||||
|
||||
mlir::Location loc = converter.genLocation(atomicConstruct.source);
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::parser::AccAtomicRead &atomicRead) {
|
||||
Fortran::lower::genOmpAccAtomicRead<Fortran::parser::AccAtomicRead,
|
||||
@ -4061,7 +4062,7 @@ mlir::Value Fortran::lower::genOpenACCConstruct(
|
||||
const Fortran::parser::OpenACCConstruct &accConstruct) {
|
||||
|
||||
mlir::Value exitCond;
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
common::visitors{
|
||||
[&](const Fortran::parser::OpenACCBlockConstruct &blockConstruct) {
|
||||
genACC(converter, semanticsContext, eval, blockConstruct);
|
||||
@ -4101,7 +4102,7 @@ void Fortran::lower::genOpenACCDeclarativeConstruct(
|
||||
const Fortran::parser::OpenACCDeclarativeConstruct &accDeclConstruct,
|
||||
Fortran::lower::AccRoutineInfoMappingList &accRoutineInfos) {
|
||||
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
common::visitors{
|
||||
[&](const Fortran::parser::OpenACCStandaloneDeclarativeConstruct
|
||||
&standaloneDeclarativeConstruct) {
|
||||
|
||||
@ -38,8 +38,8 @@ llvm::omp::Clause getClauseIdForClass(C &&) {
|
||||
} // namespace detail
|
||||
|
||||
static llvm::omp::Clause getClauseId(const Fortran::parser::OmpClause &clause) {
|
||||
return std::visit([](auto &&s) { return detail::getClauseIdForClass(s); },
|
||||
clause.u);
|
||||
return Fortran::common::visit(
|
||||
[](auto &&s) { return detail::getClauseIdForClass(s); }, clause.u);
|
||||
}
|
||||
|
||||
namespace Fortran::lower::omp {
|
||||
@ -83,7 +83,7 @@ struct SymbolAndDesignatorExtractor {
|
||||
|
||||
template <typename T>
|
||||
static SymbolWithDesignator visit(const evaluate::Expr<T> &e) {
|
||||
return std::visit([](auto &&s) { return visit(s); }, e.u);
|
||||
return Fortran::common::visit([](auto &&s) { return visit(s); }, e.u);
|
||||
}
|
||||
|
||||
static void verify(const SymbolWithDesignator &sd) {
|
||||
@ -112,7 +112,7 @@ struct SymbolAndDesignatorExtractor {
|
||||
SymbolWithDesignator getSymbolAndDesignator(const MaybeExpr &expr) {
|
||||
if (!expr)
|
||||
return SymbolWithDesignator{};
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
[](auto &&s) { return SymbolAndDesignatorExtractor::visit(s); }, expr->u);
|
||||
}
|
||||
|
||||
@ -278,7 +278,7 @@ DefinedOperator makeDefinedOperator(const parser::DefinedOperator &inp,
|
||||
// clang-format on
|
||||
);
|
||||
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
common::visitors{
|
||||
[&](const parser::DefinedOpName &s) {
|
||||
return DefinedOperator{
|
||||
@ -294,7 +294,7 @@ DefinedOperator makeDefinedOperator(const parser::DefinedOperator &inp,
|
||||
ProcedureDesignator
|
||||
makeProcedureDesignator(const parser::ProcedureDesignator &inp,
|
||||
semantics::SemanticsContext &semaCtx) {
|
||||
return ProcedureDesignator{std::visit(
|
||||
return ProcedureDesignator{Fortran::common::visit(
|
||||
common::visitors{
|
||||
[&](const parser::Name &t) { return makeObject(t, semaCtx); },
|
||||
[&](const parser::ProcComponentRef &t) {
|
||||
@ -306,7 +306,7 @@ makeProcedureDesignator(const parser::ProcedureDesignator &inp,
|
||||
|
||||
ReductionOperator makeReductionOperator(const parser::OmpReductionOperator &inp,
|
||||
semantics::SemanticsContext &semaCtx) {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
common::visitors{
|
||||
[&](const parser::DefinedOperator &s) {
|
||||
return ReductionOperator{makeDefinedOperator(s, semaCtx)};
|
||||
@ -366,7 +366,7 @@ Allocate make(const parser::OmpClause::Allocate &inp,
|
||||
|
||||
using Tuple = decltype(Allocate::t);
|
||||
|
||||
return Allocate{std::visit(
|
||||
return Allocate{Fortran::common::visit(
|
||||
common::visitors{
|
||||
// simple-modifier
|
||||
[&](const wrapped::AllocateModifier::Allocator &v) -> Tuple {
|
||||
@ -531,7 +531,7 @@ Depend make(const parser::OmpClause::Depend &inp,
|
||||
// clang-format on
|
||||
);
|
||||
|
||||
return Depend{std::visit( //
|
||||
return Depend{Fortran::common::visit( //
|
||||
common::visitors{
|
||||
// Doacross
|
||||
[&](const wrapped::Source &s) -> Variant {
|
||||
@ -793,7 +793,7 @@ Linear make(const parser::OmpClause::Linear &inp,
|
||||
|
||||
using Tuple = decltype(Linear::t);
|
||||
|
||||
return Linear{std::visit(
|
||||
return Linear{Fortran::common::visit(
|
||||
common::visitors{
|
||||
[&](const wrapped::WithModifier &s) -> Tuple {
|
||||
return {
|
||||
@ -949,7 +949,7 @@ Order make(const parser::OmpClause::Order &inp,
|
||||
auto &t1 = std::get<wrapped::Type>(inp.v.t);
|
||||
|
||||
auto convert3 = [&](const parser::OmpOrderModifier &s) {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
[&](parser::OmpOrderModifier::Kind k) { return convert1(k); }, s.u);
|
||||
};
|
||||
return Order{
|
||||
@ -1212,7 +1212,7 @@ UsesAllocators make(const parser::OmpClause::UsesAllocators &inp,
|
||||
|
||||
Clause makeClause(const parser::OmpClause &cls,
|
||||
semantics::SemanticsContext &semaCtx) {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
[&](auto &&s) {
|
||||
return makeClause(getClauseId(cls), clause::make(s, semaCtx),
|
||||
cls.source);
|
||||
|
||||
@ -2199,7 +2199,7 @@ static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
|
||||
semantics::SemanticsContext &semaCtx,
|
||||
lower::pft::Evaluation &eval,
|
||||
const parser::OpenMPDeclarativeConstruct &ompDeclConstruct) {
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
[&](auto &&s) { return genOMP(converter, symTable, semaCtx, eval, s); },
|
||||
ompDeclConstruct.u);
|
||||
}
|
||||
@ -2276,7 +2276,7 @@ static void
|
||||
genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
|
||||
semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
|
||||
const parser::OpenMPStandaloneConstruct &standaloneConstruct) {
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
[&](auto &&s) { return genOMP(converter, symTable, semaCtx, eval, s); },
|
||||
standaloneConstruct.u);
|
||||
}
|
||||
@ -2296,7 +2296,7 @@ static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
|
||||
semantics::SemanticsContext &semaCtx,
|
||||
lower::pft::Evaluation &eval,
|
||||
const parser::OpenMPAtomicConstruct &atomicConstruct) {
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
common::visitors{
|
||||
[&](const parser::OmpAtomicRead &atomicRead) {
|
||||
mlir::Location loc = converter.genLocation(atomicRead.source);
|
||||
@ -2487,7 +2487,7 @@ static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
|
||||
semantics::SemanticsContext &semaCtx,
|
||||
lower::pft::Evaluation &eval,
|
||||
const parser::OpenMPConstruct &ompConstruct) {
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
[&](auto &&s) { return genOMP(converter, symTable, semaCtx, eval, s); },
|
||||
ompConstruct.u);
|
||||
}
|
||||
@ -2649,21 +2649,22 @@ void Fortran::lower::gatherOpenMPDeferredDeclareTargets(
|
||||
const parser::OpenMPDeclarativeConstruct &ompDecl,
|
||||
llvm::SmallVectorImpl<OMPDeferredDeclareTargetInfo>
|
||||
&deferredDeclareTarget) {
|
||||
std::visit(common::visitors{
|
||||
[&](const parser::OpenMPDeclareTargetConstruct &ompReq) {
|
||||
collectDeferredDeclareTargets(converter, semaCtx, eval,
|
||||
ompReq, deferredDeclareTarget);
|
||||
},
|
||||
[&](const auto &) {},
|
||||
},
|
||||
ompDecl.u);
|
||||
Fortran::common::visit(
|
||||
common::visitors{
|
||||
[&](const parser::OpenMPDeclareTargetConstruct &ompReq) {
|
||||
collectDeferredDeclareTargets(converter, semaCtx, eval, ompReq,
|
||||
deferredDeclareTarget);
|
||||
},
|
||||
[&](const auto &) {},
|
||||
},
|
||||
ompDecl.u);
|
||||
}
|
||||
|
||||
bool Fortran::lower::isOpenMPDeviceDeclareTarget(
|
||||
lower::AbstractConverter &converter, semantics::SemanticsContext &semaCtx,
|
||||
lower::pft::Evaluation &eval,
|
||||
const parser::OpenMPDeclarativeConstruct &ompDecl) {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
common::visitors{
|
||||
[&](const parser::OpenMPDeclareTargetConstruct &ompReq) {
|
||||
mlir::omp::DeclareTargetDeviceType targetType =
|
||||
|
||||
@ -325,7 +325,7 @@ void insertChildMapInfoIntoParent(
|
||||
|
||||
semantics::Symbol *getOmpObjectSymbol(const parser::OmpObject &ompObject) {
|
||||
semantics::Symbol *sym = nullptr;
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
common::visitors{
|
||||
[&](const parser::Designator &designator) {
|
||||
if (auto *arrayEle =
|
||||
|
||||
@ -103,7 +103,7 @@ public:
|
||||
stmt.unwrapped, pftParentStack.back(), stmt.position, stmt.label});
|
||||
return false;
|
||||
} else if constexpr (std::is_same_v<T, parser::ActionStmt>) {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
common::visitors{
|
||||
[&](const common::Indirection<parser::CallStmt> &x) {
|
||||
addEvaluation(lower::pft::Evaluation{
|
||||
@ -239,7 +239,7 @@ public:
|
||||
|
||||
// Get rid of production wrapper
|
||||
bool Pre(const parser::Statement<parser::ForallAssignmentStmt> &statement) {
|
||||
addEvaluation(std::visit(
|
||||
addEvaluation(Fortran::common::visit(
|
||||
[&](const auto &x) {
|
||||
return lower::pft::Evaluation{x, pftParentStack.back(),
|
||||
statement.source, statement.label};
|
||||
@ -248,7 +248,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
bool Pre(const parser::WhereBodyConstruct &whereBody) {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
common::visitors{
|
||||
[&](const parser::Statement<parser::AssignmentStmt> &stmt) {
|
||||
// Not caught as other AssignmentStmt because it is not
|
||||
@ -469,7 +469,7 @@ private:
|
||||
makeEvaluationAction(const parser::ActionStmt &statement,
|
||||
parser::CharBlock position,
|
||||
std::optional<parser::Label> label) {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
common::visitors{
|
||||
[&](const auto &x) {
|
||||
return lower::pft::Evaluation{
|
||||
@ -664,7 +664,7 @@ private:
|
||||
};
|
||||
auto analyzeSpecs{[&](const auto &specList) {
|
||||
for (const auto &spec : specList) {
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::parser::Format &format) {
|
||||
analyzeFormatSpec(format);
|
||||
@ -1172,26 +1172,27 @@ public:
|
||||
void dumpPFT(llvm::raw_ostream &outputStream,
|
||||
const lower::pft::Program &pft) {
|
||||
for (auto &unit : pft.getUnits()) {
|
||||
std::visit(common::visitors{
|
||||
[&](const lower::pft::BlockDataUnit &unit) {
|
||||
outputStream << getNodeIndex(unit) << " ";
|
||||
outputStream << "BlockData: ";
|
||||
outputStream << "\nEnd BlockData\n\n";
|
||||
},
|
||||
[&](const lower::pft::FunctionLikeUnit &func) {
|
||||
dumpFunctionLikeUnit(outputStream, func);
|
||||
},
|
||||
[&](const lower::pft::ModuleLikeUnit &unit) {
|
||||
dumpModuleLikeUnit(outputStream, unit);
|
||||
},
|
||||
[&](const lower::pft::CompilerDirectiveUnit &unit) {
|
||||
dumpCompilerDirectiveUnit(outputStream, unit);
|
||||
},
|
||||
[&](const lower::pft::OpenACCDirectiveUnit &unit) {
|
||||
dumpOpenACCDirectiveUnit(outputStream, unit);
|
||||
},
|
||||
},
|
||||
unit);
|
||||
Fortran::common::visit(
|
||||
common::visitors{
|
||||
[&](const lower::pft::BlockDataUnit &unit) {
|
||||
outputStream << getNodeIndex(unit) << " ";
|
||||
outputStream << "BlockData: ";
|
||||
outputStream << "\nEnd BlockData\n\n";
|
||||
},
|
||||
[&](const lower::pft::FunctionLikeUnit &func) {
|
||||
dumpFunctionLikeUnit(outputStream, func);
|
||||
},
|
||||
[&](const lower::pft::ModuleLikeUnit &unit) {
|
||||
dumpModuleLikeUnit(outputStream, unit);
|
||||
},
|
||||
[&](const lower::pft::CompilerDirectiveUnit &unit) {
|
||||
dumpCompilerDirectiveUnit(outputStream, unit);
|
||||
},
|
||||
[&](const lower::pft::OpenACCDirectiveUnit &unit) {
|
||||
dumpOpenACCDirectiveUnit(outputStream, unit);
|
||||
},
|
||||
},
|
||||
unit);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -55,10 +55,11 @@ private:
|
||||
using Designator = Fortran::evaluate::Designator<T>;
|
||||
if constexpr (Fortran::common::HasMember<Designator, ExprVariant>) {
|
||||
const auto &designator = std::get<Designator>(expr.u);
|
||||
return std::visit([&](const auto &x) { return gen(x); }, designator.u);
|
||||
return Fortran::common::visit([&](const auto &x) { return gen(x); },
|
||||
designator.u);
|
||||
} else {
|
||||
return std::visit([&](const auto &x) { return genDesignator(x); },
|
||||
expr.u);
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &x) { return genDesignator(x); }, expr.u);
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,8 +67,8 @@ private:
|
||||
// type of X elements.
|
||||
|
||||
mlir::Type gen(const Fortran::evaluate::DataRef &dataRef) {
|
||||
return std::visit([&](const auto &ref) -> mlir::Type { return gen(ref); },
|
||||
dataRef.u);
|
||||
return Fortran::common::visit(
|
||||
[&](const auto &ref) -> mlir::Type { return gen(ref); }, dataRef.u);
|
||||
}
|
||||
|
||||
mlir::Type gen(const Fortran::evaluate::SymbolRef &symRef) {
|
||||
@ -128,7 +129,7 @@ private:
|
||||
mlir::Type gen(const Fortran::evaluate::ArrayRef &arrayRef) {
|
||||
auto isTripletOrVector =
|
||||
[](const Fortran::evaluate::Subscript &subscript) -> bool {
|
||||
return std::visit(
|
||||
return Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[](const Fortran::evaluate::IndirectSubscriptIntegerExpr &expr) {
|
||||
return expr.value().Rank() != 0;
|
||||
@ -165,7 +166,7 @@ private:
|
||||
mlir::Type idxTy = builder.getIndexType();
|
||||
mlir::Value one = builder.createIntegerConstant(loc, idxTy, 1);
|
||||
for (const auto &subscript : llvm::enumerate(arrayRef.subscript())) {
|
||||
std::visit(
|
||||
Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::evaluate::IndirectSubscriptIntegerExpr &expr) {
|
||||
if (expr.value().Rank() == 0) {
|
||||
@ -327,24 +328,24 @@ Fortran::lower::VectorSubscriptBox::createSlice(fir::FirOpBuilder &builder,
|
||||
mlir::Value one = builder.createIntegerConstant(loc, idxTy, 1);
|
||||
auto undef = builder.create<fir::UndefOp>(loc, idxTy);
|
||||
for (const LoweredSubscript &subscript : loweredSubscripts)
|
||||
std::visit(Fortran::common::visitors{
|
||||
[&](const LoweredTriplet &triplet) {
|
||||
triples.emplace_back(triplet.lb);
|
||||
triples.emplace_back(triplet.ub);
|
||||
triples.emplace_back(triplet.stride);
|
||||
},
|
||||
[&](const LoweredVectorSubscript &vector) {
|
||||
triples.emplace_back(one);
|
||||
triples.emplace_back(vector.size);
|
||||
triples.emplace_back(one);
|
||||
},
|
||||
[&](const mlir::Value &i) {
|
||||
triples.emplace_back(i);
|
||||
triples.emplace_back(undef);
|
||||
triples.emplace_back(undef);
|
||||
},
|
||||
},
|
||||
subscript);
|
||||
Fortran::common::visit(Fortran::common::visitors{
|
||||
[&](const LoweredTriplet &triplet) {
|
||||
triples.emplace_back(triplet.lb);
|
||||
triples.emplace_back(triplet.ub);
|
||||
triples.emplace_back(triplet.stride);
|
||||
},
|
||||
[&](const LoweredVectorSubscript &vector) {
|
||||
triples.emplace_back(one);
|
||||
triples.emplace_back(vector.size);
|
||||
triples.emplace_back(one);
|
||||
},
|
||||
[&](const mlir::Value &i) {
|
||||
triples.emplace_back(i);
|
||||
triples.emplace_back(undef);
|
||||
triples.emplace_back(undef);
|
||||
},
|
||||
},
|
||||
subscript);
|
||||
return builder.create<fir::SliceOp>(loc, triples, componentPath);
|
||||
}
|
||||
|
||||
@ -390,28 +391,28 @@ fir::ExtendedValue Fortran::lower::VectorSubscriptBox::getElementAt(
|
||||
llvm::SmallVector<mlir::Value> indexes;
|
||||
size_t inductionIdx = inductionVariables.size() - 1;
|
||||
for (const LoweredSubscript &subscript : loweredSubscripts)
|
||||
std::visit(Fortran::common::visitors{
|
||||
[&](const LoweredTriplet &triplet) {
|
||||
indexes.emplace_back(inductionVariables[inductionIdx--]);
|
||||
},
|
||||
[&](const LoweredVectorSubscript &vector) {
|
||||
mlir::Value vecIndex = inductionVariables[inductionIdx--];
|
||||
mlir::Value vecBase = fir::getBase(vector.vector);
|
||||
mlir::Type vecEleTy = fir::unwrapSequenceType(
|
||||
fir::unwrapPassByRefType(vecBase.getType()));
|
||||
mlir::Type refTy = builder.getRefType(vecEleTy);
|
||||
auto vecEltRef = builder.create<fir::CoordinateOp>(
|
||||
loc, refTy, vecBase, vecIndex);
|
||||
auto vecElt =
|
||||
builder.create<fir::LoadOp>(loc, vecEleTy, vecEltRef);
|
||||
indexes.emplace_back(
|
||||
builder.createConvert(loc, idxTy, vecElt));
|
||||
},
|
||||
[&](const mlir::Value &i) {
|
||||
indexes.emplace_back(builder.createConvert(loc, idxTy, i));
|
||||
},
|
||||
},
|
||||
subscript);
|
||||
Fortran::common::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const LoweredTriplet &triplet) {
|
||||
indexes.emplace_back(inductionVariables[inductionIdx--]);
|
||||
},
|
||||
[&](const LoweredVectorSubscript &vector) {
|
||||
mlir::Value vecIndex = inductionVariables[inductionIdx--];
|
||||
mlir::Value vecBase = fir::getBase(vector.vector);
|
||||
mlir::Type vecEleTy = fir::unwrapSequenceType(
|
||||
fir::unwrapPassByRefType(vecBase.getType()));
|
||||
mlir::Type refTy = builder.getRefType(vecEleTy);
|
||||
auto vecEltRef = builder.create<fir::CoordinateOp>(
|
||||
loc, refTy, vecBase, vecIndex);
|
||||
auto vecElt =
|
||||
builder.create<fir::LoadOp>(loc, vecEleTy, vecEltRef);
|
||||
indexes.emplace_back(builder.createConvert(loc, idxTy, vecElt));
|
||||
},
|
||||
[&](const mlir::Value &i) {
|
||||
indexes.emplace_back(builder.createConvert(loc, idxTy, i));
|
||||
},
|
||||
},
|
||||
subscript);
|
||||
mlir::Type refTy = builder.getRefType(getElementType());
|
||||
auto elementAddr = builder.create<fir::ArrayCoorOp>(
|
||||
loc, refTy, fir::getBase(loweredBase), shape, slice, indexes,
|
||||
|
||||
@ -1788,7 +1788,7 @@ IntrinsicLibrary::genIntrinsicCall(llvm::StringRef specificName,
|
||||
llvm::StringRef name = genericName(specificName);
|
||||
if (const IntrinsicHandler *handler = findIntrinsicHandler(name)) {
|
||||
bool outline = handler->outline || outlineAllIntrinsics;
|
||||
return {std::visit(
|
||||
return {Fortran::common::visit(
|
||||
[&](auto &generator) -> fir::ExtendedValue {
|
||||
return invokeHandler(generator, *handler, resultType, args,
|
||||
outline, *this);
|
||||
@ -1802,7 +1802,7 @@ IntrinsicLibrary::genIntrinsicCall(llvm::StringRef specificName,
|
||||
if (fir::getTargetTriple(mod).isPPC()) {
|
||||
if (const IntrinsicHandler *ppcHandler = findPPCIntrinsicHandler(name)) {
|
||||
bool outline = ppcHandler->outline || outlineAllIntrinsics;
|
||||
return {std::visit(
|
||||
return {Fortran::common::visit(
|
||||
[&](auto &generator) -> fir::ExtendedValue {
|
||||
return invokeHandler(generator, *ppcHandler, resultType,
|
||||
args, outline, *this);
|
||||
@ -2136,7 +2136,7 @@ mlir::SymbolRefAttr IntrinsicLibrary::getUnrestrictedIntrinsicSymbolRefAttr(
|
||||
bool loadRefArguments = true;
|
||||
mlir::func::FuncOp funcOp;
|
||||
if (const IntrinsicHandler *handler = findIntrinsicHandler(name))
|
||||
funcOp = std::visit(
|
||||
funcOp = Fortran::common::visit(
|
||||
[&](auto generator) {
|
||||
return getWrapper(generator, name, signature, loadRefArguments);
|
||||
},
|
||||
|
||||
@ -403,9 +403,9 @@ void AccStructureChecker::CheckMultipleOccurrenceInDeclare(
|
||||
if (GetContext().directive != llvm::acc::Directive::ACCD_declare)
|
||||
return;
|
||||
for (const auto &object : list.v) {
|
||||
std::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::parser::Designator &designator) {
|
||||
common::visit(
|
||||
common::visitors{
|
||||
[&](const parser::Designator &designator) {
|
||||
if (const auto *name = getDesignatorNameIfDataRef(designator)) {
|
||||
if (declareSymbols.contains(&name->symbol->GetUltimate())) {
|
||||
if (declareSymbols[&name->symbol->GetUltimate()] == clause) {
|
||||
@ -435,7 +435,7 @@ void AccStructureChecker::CheckMultipleOccurrenceInDeclare(
|
||||
declareSymbols.insert({&name->symbol->GetUltimate(), clause});
|
||||
}
|
||||
},
|
||||
[&](const Fortran::parser::Name &name) {
|
||||
[&](const parser::Name &name) {
|
||||
// TODO: check common block
|
||||
}},
|
||||
object.u);
|
||||
@ -674,9 +674,9 @@ void AccStructureChecker::Enter(const parser::AccClause::Reduction &reduction) {
|
||||
const auto &objects{std::get<parser::AccObjectList>(list.t)};
|
||||
|
||||
for (const auto &object : objects.v) {
|
||||
std::visit(
|
||||
Fortran::common::visitors{
|
||||
[&](const Fortran::parser::Designator &designator) {
|
||||
common::visit(
|
||||
common::visitors{
|
||||
[&](const parser::Designator &designator) {
|
||||
if (const auto *name = getDesignatorNameIfDataRef(designator)) {
|
||||
const auto *type{name->symbol->GetType()};
|
||||
if (type->IsNumeric(TypeCategory::Integer) &&
|
||||
|
||||
@ -93,7 +93,7 @@ static void CheckCoindexedStatOrErrmsg(SemanticsContext &context,
|
||||
}
|
||||
}
|
||||
}};
|
||||
std::visit(CoindexedCheck, statOrErrmsg.u);
|
||||
Fortran::common::visit(CoindexedCheck, statOrErrmsg.u);
|
||||
}
|
||||
|
||||
static void CheckSyncStatList(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user