diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp --- a/flang/lib/Lower/OpenACC.cpp +++ b/flang/lib/Lower/OpenACC.cpp @@ -23,20 +23,18 @@ #include "mlir/Dialect/OpenACC/OpenACC.h" #include "llvm/Frontend/OpenACC/ACC.h.inc" -using namespace mlir; - // Special value for * passed in device_type or gang clauses. -static constexpr std::int64_t starCst{-1}; +static constexpr std::int64_t starCst = -1; static const Fortran::parser::Name * getDesignatorNameIfDataRef(const Fortran::parser::Designator &designator) { - const auto *dataRef{std::get_if(&designator.u)}; + const auto *dataRef = std::get_if(&designator.u); return dataRef ? std::get_if(&dataRef->u) : nullptr; } static void genObjectList(const Fortran::parser::AccObjectList &objectList, Fortran::lower::AbstractConverter &converter, - SmallVectorImpl &operands) { + llvm::SmallVectorImpl &operands) { for (const auto &accObject : objectList.v) { std::visit( Fortran::common::visitors{ @@ -55,14 +53,13 @@ } template -static void -genObjectListWithModifier(const Clause *x, - Fortran::lower::AbstractConverter &converter, - Fortran::parser::AccDataModifier::Modifier mod, - SmallVectorImpl &operandsWithModifier, - SmallVectorImpl &operands) { +static void genObjectListWithModifier( + const Clause *x, Fortran::lower::AbstractConverter &converter, + Fortran::parser::AccDataModifier::Modifier mod, + llvm::SmallVectorImpl &operandsWithModifier, + llvm::SmallVectorImpl &operands) { const Fortran::parser::AccObjectListWithModifier &listWithModifier = x->v; - const Fortran::parser::AccObjectList &accObjectList = + const auto &accObjectList = std::get(listWithModifier.t); const auto &modifier = std::get>( @@ -74,16 +71,17 @@ } } -static void addOperands(SmallVectorImpl &operands, - SmallVectorImpl &operandSegments, - const SmallVectorImpl &clauseOperands) { +static void +addOperands(llvm::SmallVectorImpl &operands, + llvm::SmallVectorImpl &operandSegments, + const llvm::SmallVectorImpl &clauseOperands) { operands.append(clauseOperands.begin(), clauseOperands.end()); operandSegments.push_back(clauseOperands.size()); } -static void addOperand(SmallVectorImpl &operands, - SmallVectorImpl &operandSegments, - const Value &clauseOperand) { +static void addOperand(llvm::SmallVectorImpl &operands, + llvm::SmallVectorImpl &operandSegments, + const mlir::Value &clauseOperand) { if (clauseOperand) { operands.push_back(clauseOperand); operandSegments.push_back(1); @@ -93,9 +91,10 @@ } template -static Op createRegionOp(fir::FirOpBuilder &builder, mlir::Location loc, - const SmallVectorImpl &operands, - const SmallVectorImpl &operandSegments) { +static Op +createRegionOp(fir::FirOpBuilder &builder, mlir::Location loc, + const llvm::SmallVectorImpl &operands, + const llvm::SmallVectorImpl &operandSegments) { llvm::ArrayRef argTy; Op op = builder.create(loc, argTy, operands); builder.createBlock(&op.getRegion()); @@ -113,9 +112,10 @@ } template -static Op createSimpleOp(fir::FirOpBuilder &builder, mlir::Location loc, - const SmallVectorImpl &operands, - const SmallVectorImpl &operandSegments) { +static Op +createSimpleOp(fir::FirOpBuilder &builder, mlir::Location loc, + const llvm::SmallVectorImpl &operands, + const llvm::SmallVectorImpl &operandSegments) { llvm::ArrayRef argTy; Op op = builder.create(loc, argTy, operands); op->setAttr(Op::getOperandSegmentSizeAttr(), @@ -139,7 +139,7 @@ static void genDeviceTypeClause( Fortran::lower::AbstractConverter &converter, const Fortran::parser::AccClause::DeviceType *deviceTypeClause, - SmallVectorImpl &operands, + llvm::SmallVectorImpl &operands, Fortran::lower::StatementContext &stmtCtx) { const auto &deviceTypeValue = deviceTypeClause->v; if (deviceTypeValue) { @@ -162,7 +162,7 @@ mlir::Value &ifCond, Fortran::lower::StatementContext &stmtCtx) { fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder(); - Value cond = fir::getBase(converter.genExprValue( + mlir::Value cond = fir::getBase(converter.genExprValue( *Fortran::semantics::GetExpr(ifClause->v), stmtCtx)); ifCond = firOpBuilder.createConvert(converter.getCurrentLocation(), firOpBuilder.getI1Type(), cond); @@ -170,13 +170,13 @@ static void genWaitClause(Fortran::lower::AbstractConverter &converter, const Fortran::parser::AccClause::Wait *waitClause, - SmallVectorImpl &operands, + llvm::SmallVectorImpl &operands, mlir::Value &waitDevnum, bool &addWaitAttr, Fortran::lower::StatementContext &stmtCtx) { const auto &waitClauseValue = waitClause->v; if (waitClauseValue) { // wait has a value. const Fortran::parser::AccWaitArgument &waitArg = *waitClauseValue; - const std::list &waitList = + const auto &waitList = std::get>(waitArg.t); for (const Fortran::parser::ScalarIntExpr &value : waitList) { mlir::Value v = fir::getBase( @@ -184,7 +184,7 @@ operands.push_back(v); } - const std::optional &waitDevnumValue = + const auto &waitDevnumValue = std::get>(waitArg.t); if (waitDevnumValue) waitDevnum = fir::getBase(converter.genExprValue( @@ -215,7 +215,8 @@ mlir::Value vectorLength; mlir::Value gangNum; mlir::Value gangStatic; - SmallVector tileOperands, privateOperands, reductionOperands; + llvm::SmallVector tileOperands, privateOperands, + reductionOperands; std::int64_t executionMapping = mlir::acc::OpenACCExecMapping::NONE; // Lower clauses values mapped to operands. @@ -293,8 +294,8 @@ } // Prepare the operand segement size attribute and the operands value range. - SmallVector operands; - SmallVector operandSegments; + llvm::SmallVector operands; + llvm::SmallVector operandSegments; addOperand(operands, operandSegments, gangNum); addOperand(operands, operandSegments, gangStatic); addOperand(operands, operandSegments, workerNum); @@ -343,8 +344,8 @@ mlir::Value vectorLength; mlir::Value ifCond; mlir::Value selfCond; - SmallVector waitOperands, reductionOperands, copyOperands, - copyinOperands, copyinReadonlyOperands, copyoutOperands, + llvm::SmallVector waitOperands, reductionOperands, + copyOperands, copyinOperands, copyinReadonlyOperands, copyoutOperands, copyoutZeroOperands, createOperands, createZeroOperands, noCreateOperands, presentOperands, devicePtrOperands, attachOperands, privateOperands, firstprivateOperands; @@ -378,10 +379,10 @@ const auto &waitClauseValue = waitClause->v; if (waitClauseValue) { // wait has a value. const Fortran::parser::AccWaitArgument &waitArg = *waitClauseValue; - const std::list &waitList = + const auto &waitList = std::get>(waitArg.t); for (const Fortran::parser::ScalarIntExpr &value : waitList) { - Value v = fir::getBase(converter.genExprValue( + auto v = fir::getBase(converter.genExprValue( *Fortran::semantics::GetExpr(value), stmtCtx)); waitOperands.push_back(v); } @@ -405,7 +406,7 @@ *Fortran::semantics::GetExpr(vectorLengthClause->v), stmtCtx)); } else if (const auto *ifClause = std::get_if(&clause.u)) { - Value cond = fir::getBase(converter.genExprValue( + mlir::Value cond = fir::getBase(converter.genExprValue( *Fortran::semantics::GetExpr(ifClause->v), stmtCtx)); ifCond = firOpBuilder.createConvert(currentLocation, firOpBuilder.getI1Type(), cond); @@ -416,7 +417,7 @@ std::get_if>( &accSelfClause.u)) { if (*optCondition) { - Value cond = fir::getBase(converter.genExprValue( + mlir::Value cond = fir::getBase(converter.genExprValue( *Fortran::semantics::GetExpr(*optCondition), stmtCtx)); selfCond = firOpBuilder.createConvert(currentLocation, firOpBuilder.getI1Type(), cond); @@ -473,8 +474,8 @@ } // Prepare the operand segement size attribute and the operands value range. - SmallVector operands; - SmallVector operandSegments; + llvm::SmallVector operands; + llvm::SmallVector operandSegments; addOperand(operands, operandSegments, async); addOperands(operands, operandSegments, waitOperands); addOperand(operands, operandSegments, numGangs); @@ -514,9 +515,10 @@ static void genACCDataOp(Fortran::lower::AbstractConverter &converter, const Fortran::parser::AccClauseList &accClauseList) { mlir::Value ifCond; - SmallVector copyOperands, copyinOperands, copyinReadonlyOperands, - copyoutOperands, copyoutZeroOperands, createOperands, createZeroOperands, - noCreateOperands, presentOperands, deviceptrOperands, attachOperands; + llvm::SmallVector copyOperands, copyinOperands, + copyinReadonlyOperands, copyoutOperands, copyoutZeroOperands, + createOperands, createZeroOperands, noCreateOperands, presentOperands, + deviceptrOperands, attachOperands; fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder(); mlir::Location currentLocation = converter.getCurrentLocation(); @@ -570,8 +572,8 @@ } // Prepare the operand segement size attribute and the operands value range. - SmallVector operands; - SmallVector operandSegments; + llvm::SmallVector operands; + llvm::SmallVector operandSegments; addOperand(operands, operandSegments, ifCond); addOperands(operands, operandSegments, copyOperands); addOperands(operands, operandSegments, copyinOperands); @@ -611,8 +613,8 @@ genACCEnterDataOp(Fortran::lower::AbstractConverter &converter, const Fortran::parser::AccClauseList &accClauseList) { mlir::Value ifCond, async, waitDevnum; - SmallVector copyinOperands, createOperands, createZeroOperands, - attachOperands, waitOperands; + llvm::SmallVector copyinOperands, createOperands, + createZeroOperands, attachOperands, waitOperands; // Async, wait and self clause have optional values but can be present with // no value as well. When there is no value, the op has an attribute to @@ -642,7 +644,7 @@ std::get_if(&clause.u)) { const Fortran::parser::AccObjectListWithModifier &listWithModifier = copyinClause->v; - const Fortran::parser::AccObjectList &accObjectList = + const auto &accObjectList = std::get(listWithModifier.t); genObjectList(accObjectList, converter, copyinOperands); } else if (const auto *createClause = @@ -661,8 +663,8 @@ } // Prepare the operand segement size attribute and the operands value range. - SmallVector operands; - SmallVector operandSegments; + llvm::SmallVector operands; + llvm::SmallVector operandSegments; addOperand(operands, operandSegments, ifCond); addOperand(operands, operandSegments, async); addOperand(operands, operandSegments, waitDevnum); @@ -685,8 +687,8 @@ genACCExitDataOp(Fortran::lower::AbstractConverter &converter, const Fortran::parser::AccClauseList &accClauseList) { mlir::Value ifCond, async, waitDevnum; - SmallVector copyoutOperands, deleteOperands, detachOperands, - waitOperands; + llvm::SmallVector copyoutOperands, deleteOperands, + detachOperands, waitOperands; // Async and wait clause have optional values but can be present with // no value as well. When there is no value, the op has an attribute to @@ -718,7 +720,7 @@ &clause.u)) { const Fortran::parser::AccObjectListWithModifier &listWithModifier = copyoutClause->v; - const Fortran::parser::AccObjectList &accObjectList = + const auto &accObjectList = std::get(listWithModifier.t); genObjectList(accObjectList, converter, copyoutOperands); } else if (const auto *deleteClause = @@ -733,8 +735,8 @@ } // Prepare the operand segement size attribute and the operands value range. - SmallVector operands; - SmallVector operandSegments; + llvm::SmallVector operands; + llvm::SmallVector operandSegments; addOperand(operands, operandSegments, ifCond); addOperand(operands, operandSegments, async); addOperand(operands, operandSegments, waitDevnum); @@ -759,7 +761,7 @@ genACCInitShutdownOp(Fortran::lower::AbstractConverter &converter, const Fortran::parser::AccClauseList &accClauseList) { mlir::Value ifCond, deviceNum; - SmallVector deviceTypeOperands; + llvm::SmallVector deviceTypeOperands; fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder(); mlir::Location currentLocation = converter.getCurrentLocation(); @@ -786,8 +788,8 @@ } // Prepare the operand segement size attribute and the operands value range. - SmallVector operands; - SmallVector operandSegments; + llvm::SmallVector operands; + llvm::SmallVector operandSegments; addOperands(operands, operandSegments, deviceTypeOperands); addOperand(operands, operandSegments, deviceNum); addOperand(operands, operandSegments, ifCond); @@ -799,7 +801,7 @@ genACCUpdateOp(Fortran::lower::AbstractConverter &converter, const Fortran::parser::AccClauseList &accClauseList) { mlir::Value ifCond, async, waitDevnum; - SmallVector hostOperands, deviceOperands, waitOperands, + llvm::SmallVector hostOperands, deviceOperands, waitOperands, deviceTypeOperands; // Async and wait clause have optional values but can be present with @@ -842,8 +844,8 @@ } // Prepare the operand segement size attribute and the operands value range. - SmallVector operands; - SmallVector operandSegments; + llvm::SmallVector operands; + llvm::SmallVector operandSegments; addOperand(operands, operandSegments, ifCond); addOperand(operands, operandSegments, async); addOperand(operands, operandSegments, waitDevnum); @@ -899,7 +901,7 @@ std::get(waitConstruct.t); mlir::Value ifCond, waitDevnum, async; - SmallVector waitOperands; + llvm::SmallVector waitOperands; // Async clause have optional values but can be present with // no value as well. When there is no value, the op has an attribute to @@ -912,7 +914,7 @@ if (waitArgument) { // wait has a value. const Fortran::parser::AccWaitArgument &waitArg = *waitArgument; - const std::list &waitList = + const auto &waitList = std::get>(waitArg.t); for (const Fortran::parser::ScalarIntExpr &value : waitList) { mlir::Value v = fir::getBase( @@ -920,7 +922,7 @@ waitOperands.push_back(v); } - const std::optional &waitDevnumValue = + const auto &waitDevnumValue = std::get>(waitArg.t); if (waitDevnumValue) waitDevnum = fir::getBase(converter.genExprValue( @@ -941,8 +943,8 @@ } // Prepare the operand segement size attribute and the operands value range. - SmallVector operands; - SmallVector operandSegments; + llvm::SmallVector operands; + llvm::SmallVector operandSegments; addOperands(operands, operandSegments, waitOperands); addOperand(operands, operandSegments, async); addOperand(operands, operandSegments, waitDevnum);