3232#include " flang/Semantics/expression.h"
3333#include " flang/Semantics/scope.h"
3434#include " flang/Semantics/tools.h"
35+ #include " mlir/Dialect/ControlFlow/IR/ControlFlowOps.h"
36+ #include " mlir/IR/MLIRContext.h"
37+ #include " mlir/Support/LLVM.h"
3538#include " llvm/ADT/STLExtras.h"
3639#include " llvm/Frontend/OpenACC/ACC.h.inc"
3740#include " llvm/Support/CommandLine.h"
3841#include " llvm/Support/Debug.h"
3942#include " llvm/Support/ErrorHandling.h"
40- #include " mlir/Dialect/ControlFlow/IR/ControlFlowOps.h"
41- #include " mlir/IR/MLIRContext.h"
42- #include " mlir/Support/LLVM.h"
4343
4444#define DEBUG_TYPE " flang-lower-openacc"
4545
@@ -4141,7 +4141,9 @@ static void attachRoutineInfo(mlir::func::FuncOp func,
41414141 mlir::acc::RoutineInfoAttr::get (func.getContext (), routines));
41424142}
41434143
4144- static mlir::ArrayAttr getArrayAttrOrNull (fir::FirOpBuilder &builder, llvm::SmallVector<mlir::Attribute> &attributes) {
4144+ static mlir::ArrayAttr
4145+ getArrayAttrOrNull (fir::FirOpBuilder &builder,
4146+ llvm::SmallVector<mlir::Attribute> &attributes) {
41454147 if (attributes.empty ()) {
41464148 return nullptr ;
41474149 } else {
@@ -4181,25 +4183,24 @@ void createOpenACCRoutineConstruct(
41814183 mlir::OpBuilder modBuilder (mod.getBodyRegion ());
41824184 fir::FirOpBuilder &builder = converter.getFirOpBuilder ();
41834185 modBuilder.create <mlir::acc::RoutineOp>(
4184- loc, routineOpStr, funcName,
4185- getArrayAttrOrNull (builder, bindNames),
4186+ loc, routineOpStr, funcName, getArrayAttrOrNull (builder, bindNames),
41864187 getArrayAttrOrNull (builder, bindNameDeviceTypes),
41874188 getArrayAttrOrNull (builder, workerDeviceTypes),
41884189 getArrayAttrOrNull (builder, vectorDeviceTypes),
4189- getArrayAttrOrNull (builder, seqDeviceTypes),
4190- hasNohost, /* implicit=*/ false ,
4191- getArrayAttrOrNull (builder, gangDeviceTypes),
4190+ getArrayAttrOrNull (builder, seqDeviceTypes), hasNohost,
4191+ /* implicit=*/ false , getArrayAttrOrNull (builder, gangDeviceTypes),
41924192 getArrayAttrOrNull (builder, gangDimValues),
41934193 getArrayAttrOrNull (builder, gangDimDeviceTypes));
41944194
41954195 auto symbolRefAttr = builder.getSymbolRefAttr (routineOpStr);
41964196 if (funcOp) {
4197-
4197+
41984198 attachRoutineInfo (funcOp, symbolRefAttr);
41994199 } else {
42004200 // FuncOp is not lowered yet. Keep the information so the routine info
42014201 // can be attached later to the funcOp.
4202- converter.getAccDelayedRoutines ().push_back (std::make_pair (funcName, symbolRefAttr));
4202+ converter.getAccDelayedRoutines ().push_back (
4203+ std::make_pair (funcName, symbolRefAttr));
42034204 }
42044205}
42054206
@@ -4218,7 +4219,7 @@ static void interpretRoutineDeviceInfo(
42184219 auto getDeviceTypeAttr = [&]() -> mlir::Attribute {
42194220 auto context = builder.getContext ();
42204221 auto value = getDeviceType (dinfo.dType ());
4221- return mlir::acc::DeviceTypeAttr::get (context, value );
4222+ return mlir::acc::DeviceTypeAttr::get (context, value);
42224223 };
42234224 if (dinfo.isSeq ()) {
42244225 seqDeviceTypes.push_back (getDeviceTypeAttr ());
@@ -4244,14 +4245,15 @@ static void interpretRoutineDeviceInfo(
42444245 const auto &bindName = dinfo.bindNameOpt ().value ();
42454246 mlir::Attribute bindNameAttr;
42464247 if (const auto &bindStr{std::get_if<std::string>(&bindName)}) {
4247- bindNameAttr = builder.getStringAttr (*bindStr);
4248- } else if (const auto &bindSym{std::get_if<Fortran::semantics::SymbolRef>(&bindName)}) {
4249- bindNameAttr = builder.getStringAttr (converter.mangleName (*bindSym));
4250- } else {
4251- llvm_unreachable (" Unsupported bind name type" );
4252- }
4253- bindNames.push_back (bindNameAttr);
4254- bindNameDeviceTypes.push_back (getDeviceTypeAttr ());
4248+ bindNameAttr = builder.getStringAttr (*bindStr);
4249+ } else if (const auto &bindSym{
4250+ std::get_if<Fortran::semantics::SymbolRef>(&bindName)}) {
4251+ bindNameAttr = builder.getStringAttr (converter.mangleName (*bindSym));
4252+ } else {
4253+ llvm_unreachable (" Unsupported bind name type" );
4254+ }
4255+ bindNames.push_back (bindNameAttr);
4256+ bindNameDeviceTypes.push_back (getDeviceTypeAttr ());
42554257 }
42564258}
42574259
@@ -4277,18 +4279,18 @@ void Fortran::lower::genOpenACCRoutineConstruct(
42774279 }
42784280 // Note: Device Independent Attributes are set to the
42794281 // none device type in `info`.
4280- interpretRoutineDeviceInfo (converter, info, seqDeviceTypes, vectorDeviceTypes,
4281- workerDeviceTypes, bindNameDeviceTypes ,
4282- bindNames, gangDeviceTypes, gangDimValues ,
4283- gangDimDeviceTypes);
4282+ interpretRoutineDeviceInfo (converter, info, seqDeviceTypes,
4283+ vectorDeviceTypes, workerDeviceTypes ,
4284+ bindNameDeviceTypes, bindNames, gangDeviceTypes ,
4285+ gangDimValues, gangDimDeviceTypes);
42844286
42854287 // Device Dependent Attributes
42864288 for (const Fortran::semantics::OpenACCRoutineDeviceTypeInfo &dinfo :
42874289 info.deviceTypeInfos ()) {
42884290 interpretRoutineDeviceInfo (
4289- converter, dinfo, seqDeviceTypes, vectorDeviceTypes, workerDeviceTypes,
4290- bindNameDeviceTypes, bindNames, gangDeviceTypes, gangDimValues ,
4291- gangDimDeviceTypes);
4291+ converter, dinfo, seqDeviceTypes, vectorDeviceTypes,
4292+ workerDeviceTypes, bindNameDeviceTypes, bindNames, gangDeviceTypes,
4293+ gangDimValues, gangDimDeviceTypes);
42924294 }
42934295 }
42944296 createOpenACCRoutineConstruct (
0 commit comments