Skip to content

Commit f518d61

Browse files
committed
addressing feedback
1 parent 524841c commit f518d61

File tree

2 files changed

+40
-25
lines changed

2 files changed

+40
-25
lines changed

flang/include/flang/Semantics/symbol.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ class WithBindName {
128128
// Device type specific OpenACC routine information
129129
class OpenACCRoutineDeviceTypeInfo {
130130
public:
131-
OpenACCRoutineDeviceTypeInfo(Fortran::common::OpenACCDeviceType dType)
131+
explicit OpenACCRoutineDeviceTypeInfo(
132+
Fortran::common::OpenACCDeviceType dType)
132133
: deviceType_{dType} {}
133134
bool isSeq() const { return isSeq_; }
134135
void set_isSeq(bool value = true) { isSeq_ = value; }
@@ -161,6 +162,8 @@ class OpenACCRoutineDeviceTypeInfo {
161162
bool isWorker_{false};
162163
bool isGang_{false};
163164
unsigned gangDim_{0};
165+
// bind("name") -> std::string
166+
// bind(sym) -> SymbolRef (requires namemangling in lowering)
164167
std::optional<std::variant<std::string, SymbolRef>> bindName_;
165168
Fortran::common::OpenACCDeviceType deviceType_{
166169
Fortran::common::OpenACCDeviceType::None};

flang/lib/Semantics/resolve-directives.cpp

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,65 +1036,75 @@ void AccAttributeVisitor::AddRoutineInfoToSymbol(
10361036
Fortran::semantics::OpenACCRoutineInfo info;
10371037
std::vector<OpenACCRoutineDeviceTypeInfo *> currentDevices;
10381038
currentDevices.push_back(&info);
1039-
const auto &clauses = std::get<Fortran::parser::AccClauseList>(x.t);
1039+
const auto &clauses{std::get<Fortran::parser::AccClauseList>(x.t)};
10401040
for (const Fortran::parser::AccClause &clause : clauses.v) {
1041-
if (const auto *dTypeClause =
1042-
std::get_if<Fortran::parser::AccClause::DeviceType>(&clause.u)) {
1041+
if (const auto *dTypeClause{
1042+
std::get_if<Fortran::parser::AccClause::DeviceType>(&clause.u)}) {
10431043
currentDevices.clear();
1044-
for (const auto &deviceTypeExpr : dTypeClause->v.v)
1044+
for (const auto &deviceTypeExpr : dTypeClause->v.v) {
10451045
currentDevices.push_back(&info.add_deviceTypeInfo(deviceTypeExpr.v));
1046+
}
10461047
} else if (std::get_if<Fortran::parser::AccClause::Nohost>(&clause.u)) {
10471048
info.set_isNohost();
10481049
} else if (std::get_if<Fortran::parser::AccClause::Seq>(&clause.u)) {
1049-
for (auto &device : currentDevices)
1050+
for (auto &device : currentDevices) {
10501051
device->set_isSeq();
1052+
}
10511053
} else if (std::get_if<Fortran::parser::AccClause::Vector>(&clause.u)) {
1052-
for (auto &device : currentDevices)
1054+
for (auto &device : currentDevices) {
10531055
device->set_isVector();
1056+
}
10541057
} else if (std::get_if<Fortran::parser::AccClause::Worker>(&clause.u)) {
1055-
for (auto &device : currentDevices)
1058+
for (auto &device : currentDevices) {
10561059
device->set_isWorker();
1057-
} else if (const auto *gangClause =
1058-
std::get_if<Fortran::parser::AccClause::Gang>(&clause.u)) {
1059-
for (auto &device : currentDevices)
1060+
}
1061+
} else if (const auto *gangClause{
1062+
std::get_if<Fortran::parser::AccClause::Gang>(
1063+
&clause.u)}) {
1064+
for (auto &device : currentDevices) {
10601065
device->set_isGang();
1066+
}
10611067
if (gangClause->v) {
10621068
const Fortran::parser::AccGangArgList &x = *gangClause->v;
10631069
int numArgs{0};
10641070
for (const Fortran::parser::AccGangArg &gangArg : x.v) {
10651071
CHECK(numArgs <= 1 && "expecting 0 or 1 gang dim args");
1066-
if (const auto *dim =
1067-
std::get_if<Fortran::parser::AccGangArg::Dim>(&gangArg.u)) {
1072+
if (const auto *dim{std::get_if<Fortran::parser::AccGangArg::Dim>(
1073+
&gangArg.u)}) {
10681074
if (const auto v{EvaluateInt64(context_, dim->v)}) {
1069-
for (auto &device : currentDevices)
1075+
for (auto &device : currentDevices) {
10701076
device->set_gangDim(*v);
1077+
}
10711078
}
10721079
}
10731080
numArgs++;
10741081
}
10751082
}
1076-
} else if (const auto *bindClause =
1077-
std::get_if<Fortran::parser::AccClause::Bind>(&clause.u)) {
1078-
if (const auto *name =
1079-
std::get_if<Fortran::parser::Name>(&bindClause->v.u)) {
1080-
if (Symbol *sym = ResolveFctName(*name)) {
1083+
} else if (const auto *bindClause{
1084+
std::get_if<Fortran::parser::AccClause::Bind>(
1085+
&clause.u)}) {
1086+
if (const auto *name{
1087+
std::get_if<Fortran::parser::Name>(&bindClause->v.u)}) {
1088+
if (Symbol * sym{ResolveFctName(*name)}) {
10811089
Symbol &ultimate{sym->GetUltimate()};
1082-
for (auto &device : currentDevices)
1090+
for (auto &device : currentDevices) {
10831091
device->set_bindName(SymbolRef(ultimate));
1092+
}
10841093
} else {
10851094
context_.Say((*name).source,
10861095
"No function or subroutine declared for '%s'"_err_en_US,
10871096
(*name).source);
10881097
}
1089-
} else if (const auto charExpr =
1098+
} else if (const auto charExpr{
10901099
std::get_if<Fortran::parser::ScalarDefaultCharExpr>(
1091-
&bindClause->v.u)) {
1092-
auto *charConst =
1100+
&bindClause->v.u)}) {
1101+
auto *charConst{
10931102
Fortran::parser::Unwrap<Fortran::parser::CharLiteralConstant>(
1094-
*charExpr);
1103+
*charExpr)};
10951104
std::string str{std::get<std::string>(charConst->t)};
1096-
for (auto &device : currentDevices)
1105+
for (auto &device : currentDevices) {
10971106
device->set_bindName(std::string(str));
1107+
}
10981108
}
10991109
}
11001110
}
@@ -3031,3 +3041,5 @@ void OmpAttributeVisitor::IssueNonConformanceWarning(
30313041
warnStrOS.str());
30323042
}
30333043
} // namespace Fortran::semantics
3044+
3045+
} // namespace Fortran::semantics

0 commit comments

Comments
 (0)