Changeset View
Changeset View
Standalone View
Standalone View
flang/lib/Semantics/resolve-names.cpp
Show First 20 Lines • Show All 1,228 Lines • ▼ Show 20 Lines | struct OmpContext { | ||||
parser::CharBlock directiveSource; | parser::CharBlock directiveSource; | ||||
OmpDirective directive; | OmpDirective directive; | ||||
Scope &scope; | Scope &scope; | ||||
// TODO: default DSA is implicitly determined in different ways | // TODO: default DSA is implicitly determined in different ways | ||||
Symbol::Flag defaultDSA{Symbol::Flag::OmpShared}; | Symbol::Flag defaultDSA{Symbol::Flag::OmpShared}; | ||||
// variables on Data-sharing attribute clauses | // variables on Data-sharing attribute clauses | ||||
std::map<const Symbol *, Symbol::Flag> objectWithDSA; | std::map<const Symbol *, Symbol::Flag> objectWithDSA; | ||||
bool withinConstruct{false}; | bool withinConstruct{false}; | ||||
std::size_t associatedLoopLevel{0}; | int64_t associatedLoopLevel{0}; | ||||
DavidTruby: Should this be std::int64_t? I don't think int64_t is guaranteed to be provided outside the std… | |||||
}; | }; | ||||
// back() is the top of the stack | // back() is the top of the stack | ||||
OmpContext &GetContext() { | OmpContext &GetContext() { | ||||
CHECK(!ompContext_.empty()); | CHECK(!ompContext_.empty()); | ||||
return ompContext_.back(); | return ompContext_.back(); | ||||
} | } | ||||
void PushContext(const parser::CharBlock &source, OmpDirective dir) { | void PushContext(const parser::CharBlock &source, OmpDirective dir) { | ||||
ompContext_.emplace_back(source, dir, context_.FindScope(source)); | ompContext_.emplace_back(source, dir, context_.FindScope(source)); | ||||
Show All 16 Lines | private: | ||||
void AddToContextObjectWithDSA(const Symbol &symbol, Symbol::Flag flag) { | void AddToContextObjectWithDSA(const Symbol &symbol, Symbol::Flag flag) { | ||||
AddToContextObjectWithDSA(symbol, flag, GetContext()); | AddToContextObjectWithDSA(symbol, flag, GetContext()); | ||||
} | } | ||||
bool IsObjectWithDSA(const Symbol &symbol) { | bool IsObjectWithDSA(const Symbol &symbol) { | ||||
auto it{GetContext().objectWithDSA.find(&symbol)}; | auto it{GetContext().objectWithDSA.find(&symbol)}; | ||||
return it != GetContext().objectWithDSA.end(); | return it != GetContext().objectWithDSA.end(); | ||||
} | } | ||||
void SetContextAssociatedLoopLevel(std::size_t level) { | void SetContextAssociatedLoopLevel(int64_t level) { | ||||
GetContext().associatedLoopLevel = level; | GetContext().associatedLoopLevel = level; | ||||
} | } | ||||
std::size_t GetAssociatedLoopLevelFromClauses(const parser::OmpClauseList &); | int64_t GetAssociatedLoopLevelFromClauses(const parser::OmpClauseList &); | ||||
Symbol &MakeAssocSymbol(const SourceName &name, Symbol &prev, Scope &scope) { | Symbol &MakeAssocSymbol(const SourceName &name, Symbol &prev, Scope &scope) { | ||||
const auto pair{scope.try_emplace(name, Attrs{}, HostAssocDetails{prev})}; | const auto pair{scope.try_emplace(name, Attrs{}, HostAssocDetails{prev})}; | ||||
return *pair.first->second; | return *pair.first->second; | ||||
} | } | ||||
Symbol &MakeAssocSymbol(const SourceName &name, Symbol &prev) { | Symbol &MakeAssocSymbol(const SourceName &name, Symbol &prev) { | ||||
return MakeAssocSymbol(name, prev, currScope()); | return MakeAssocSymbol(name, prev, currScope()); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 5,159 Lines • ▼ Show 20 Lines | const parser::DoConstruct *OmpAttributeVisitor::GetDoConstructIf( | ||||
if (auto *y{std::get_if<parser::ExecutableConstruct>(&x.u)}) { | if (auto *y{std::get_if<parser::ExecutableConstruct>(&x.u)}) { | ||||
if (auto *z{std::get_if<Indirection<parser::DoConstruct>>(&y->u)}) { | if (auto *z{std::get_if<Indirection<parser::DoConstruct>>(&y->u)}) { | ||||
return &z->value(); | return &z->value(); | ||||
} | } | ||||
} | } | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
std::size_t OmpAttributeVisitor::GetAssociatedLoopLevelFromClauses( | int64_t OmpAttributeVisitor::GetAssociatedLoopLevelFromClauses( | ||||
const parser::OmpClauseList &x) { | const parser::OmpClauseList &x) { | ||||
std::size_t orderedLevel{0}; | int64_t orderedLevel{0}; | ||||
std::size_t collapseLevel{0}; | int64_t collapseLevel{0}; | ||||
for (const auto &clause : x.v) { | for (const auto &clause : x.v) { | ||||
if (const auto *orderedClause{ | if (const auto *orderedClause{ | ||||
std::get_if<parser::OmpClause::Ordered>(&clause.u)}) { | std::get_if<parser::OmpClause::Ordered>(&clause.u)}) { | ||||
if (const auto v{ | if (const auto v{ | ||||
evaluate::ToInt64(resolver_.EvaluateIntExpr(orderedClause->v))}) { | evaluate::ToInt64(resolver_.EvaluateIntExpr(orderedClause->v))}) { | ||||
orderedLevel = *v; | orderedLevel = *v; | ||||
} | } | ||||
} | } | ||||
Show All 18 Lines | |||||
// - The loop iteration variable(s) in the associated do-loop(s) of a do, | // - The loop iteration variable(s) in the associated do-loop(s) of a do, | ||||
// parallel do, taskloop, or distribute construct is (are) private. | // parallel do, taskloop, or distribute construct is (are) private. | ||||
// - The loop iteration variable in the associated do-loop of a simd construct | // - The loop iteration variable in the associated do-loop of a simd construct | ||||
// with just one associated do-loop is linear with a linear-step that is the | // with just one associated do-loop is linear with a linear-step that is the | ||||
// increment of the associated do-loop. | // increment of the associated do-loop. | ||||
// - The loop iteration variables in the associated do-loops of a simd | // - The loop iteration variables in the associated do-loops of a simd | ||||
// construct with multiple associated do-loops are lastprivate. | // construct with multiple associated do-loops are lastprivate. | ||||
// | // | ||||
// TODO: This assumes that the do-loops association for collapse/ordered | // TODO: revisit after semantics checks are completed for do-loop association of | ||||
// clause has been performed (the number of nested do-loops >= n). | // collapse and ordered | ||||
void OmpAttributeVisitor::PrivatizeAssociatedLoopIndex( | void OmpAttributeVisitor::PrivatizeAssociatedLoopIndex( | ||||
const parser::OpenMPLoopConstruct &x) { | const parser::OpenMPLoopConstruct &x) { | ||||
std::size_t level{GetContext().associatedLoopLevel}; | int64_t level{GetContext().associatedLoopLevel}; | ||||
if (level <= 0) | |||||
Perhaps replace the TODO in the comment with: sscalpone: Perhaps replace the TODO in the comment with:
// TODO: revisit after semantics checks are… | |||||
return; | |||||
Symbol::Flag ivDSA{Symbol::Flag::OmpPrivate}; | Symbol::Flag ivDSA{Symbol::Flag::OmpPrivate}; | ||||
if (simdSet.test(GetContext().directive)) { | if (simdSet.test(GetContext().directive)) { | ||||
if (level == 1) { | if (level == 1) { | ||||
ivDSA = Symbol::Flag::OmpLinear; | ivDSA = Symbol::Flag::OmpLinear; | ||||
} else { | } else { | ||||
ivDSA = Symbol::Flag::OmpLastPrivate; | ivDSA = Symbol::Flag::OmpLastPrivate; | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 366 Lines • Show Last 20 Lines |
Should this be std::int64_t? I don't think int64_t is guaranteed to be provided outside the std:: namespace in C++.