[flang-commits] [flang] 67609cd - [NFC] Cosmetic changes to OpenACC.cpp.

Eric Schweitz via flang-commits flang-commits at lists.llvm.org
Fri Apr 22 10:20:46 PDT 2022


Author: Eric Schweitz
Date: 2022-04-22T10:20:33-07:00
New Revision: 67609cdf09b04d2d43aeea638b71744a14c81a72

URL: https://github.com/llvm/llvm-project/commit/67609cdf09b04d2d43aeea638b71744a14c81a72
DIFF: https://github.com/llvm/llvm-project/commit/67609cdf09b04d2d43aeea638b71744a14c81a72.diff

LOG: [NFC] Cosmetic changes to OpenACC.cpp.

Differential Revision: https://reviews.llvm.org/D124272

Added: 
    

Modified: 
    flang/lib/Lower/OpenACC.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp
index 4a1ab2f4f75c3..4562b738d80f8 100644
--- 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<Fortran::parser::DataRef>(&designator.u)};
+  const auto *dataRef = std::get_if<Fortran::parser::DataRef>(&designator.u);
   return dataRef ? std::get_if<Fortran::parser::Name>(&dataRef->u) : nullptr;
 }
 
 static void genObjectList(const Fortran::parser::AccObjectList &objectList,
                           Fortran::lower::AbstractConverter &converter,
-                          SmallVectorImpl<Value> &operands) {
+                          llvm::SmallVectorImpl<mlir::Value> &operands) {
   for (const auto &accObject : objectList.v) {
     std::visit(
         Fortran::common::visitors{
@@ -55,14 +53,13 @@ static void genObjectList(const Fortran::parser::AccObjectList &objectList,
 }
 
 template <typename Clause>
-static void
-genObjectListWithModifier(const Clause *x,
-                          Fortran::lower::AbstractConverter &converter,
-                          Fortran::parser::AccDataModifier::Modifier mod,
-                          SmallVectorImpl<Value> &operandsWithModifier,
-                          SmallVectorImpl<Value> &operands) {
+static void genObjectListWithModifier(
+    const Clause *x, Fortran::lower::AbstractConverter &converter,
+    Fortran::parser::AccDataModifier::Modifier mod,
+    llvm::SmallVectorImpl<mlir::Value> &operandsWithModifier,
+    llvm::SmallVectorImpl<mlir::Value> &operands) {
   const Fortran::parser::AccObjectListWithModifier &listWithModifier = x->v;
-  const Fortran::parser::AccObjectList &accObjectList =
+  const auto &accObjectList =
       std::get<Fortran::parser::AccObjectList>(listWithModifier.t);
   const auto &modifier =
       std::get<std::optional<Fortran::parser::AccDataModifier>>(
@@ -74,16 +71,17 @@ genObjectListWithModifier(const Clause *x,
   }
 }
 
-static void addOperands(SmallVectorImpl<Value> &operands,
-                        SmallVectorImpl<int32_t> &operandSegments,
-                        const SmallVectorImpl<Value> &clauseOperands) {
+static void
+addOperands(llvm::SmallVectorImpl<mlir::Value> &operands,
+            llvm::SmallVectorImpl<int32_t> &operandSegments,
+            const llvm::SmallVectorImpl<mlir::Value> &clauseOperands) {
   operands.append(clauseOperands.begin(), clauseOperands.end());
   operandSegments.push_back(clauseOperands.size());
 }
 
-static void addOperand(SmallVectorImpl<Value> &operands,
-                       SmallVectorImpl<int32_t> &operandSegments,
-                       const Value &clauseOperand) {
+static void addOperand(llvm::SmallVectorImpl<mlir::Value> &operands,
+                       llvm::SmallVectorImpl<int32_t> &operandSegments,
+                       const mlir::Value &clauseOperand) {
   if (clauseOperand) {
     operands.push_back(clauseOperand);
     operandSegments.push_back(1);
@@ -93,9 +91,10 @@ static void addOperand(SmallVectorImpl<Value> &operands,
 }
 
 template <typename Op, typename Terminator>
-static Op createRegionOp(fir::FirOpBuilder &builder, mlir::Location loc,
-                         const SmallVectorImpl<Value> &operands,
-                         const SmallVectorImpl<int32_t> &operandSegments) {
+static Op
+createRegionOp(fir::FirOpBuilder &builder, mlir::Location loc,
+               const llvm::SmallVectorImpl<mlir::Value> &operands,
+               const llvm::SmallVectorImpl<int32_t> &operandSegments) {
   llvm::ArrayRef<mlir::Type> argTy;
   Op op = builder.create<Op>(loc, argTy, operands);
   builder.createBlock(&op.getRegion());
@@ -113,9 +112,10 @@ static Op createRegionOp(fir::FirOpBuilder &builder, mlir::Location loc,
 }
 
 template <typename Op>
-static Op createSimpleOp(fir::FirOpBuilder &builder, mlir::Location loc,
-                         const SmallVectorImpl<Value> &operands,
-                         const SmallVectorImpl<int32_t> &operandSegments) {
+static Op
+createSimpleOp(fir::FirOpBuilder &builder, mlir::Location loc,
+               const llvm::SmallVectorImpl<mlir::Value> &operands,
+               const llvm::SmallVectorImpl<int32_t> &operandSegments) {
   llvm::ArrayRef<mlir::Type> argTy;
   Op op = builder.create<Op>(loc, argTy, operands);
   op->setAttr(Op::getOperandSegmentSizeAttr(),
@@ -139,7 +139,7 @@ static void genAsyncClause(Fortran::lower::AbstractConverter &converter,
 static void genDeviceTypeClause(
     Fortran::lower::AbstractConverter &converter,
     const Fortran::parser::AccClause::DeviceType *deviceTypeClause,
-    SmallVectorImpl<mlir::Value> &operands,
+    llvm::SmallVectorImpl<mlir::Value> &operands,
     Fortran::lower::StatementContext &stmtCtx) {
   const auto &deviceTypeValue = deviceTypeClause->v;
   if (deviceTypeValue) {
@@ -162,7 +162,7 @@ static void genIfClause(Fortran::lower::AbstractConverter &converter,
                         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 genIfClause(Fortran::lower::AbstractConverter &converter,
 
 static void genWaitClause(Fortran::lower::AbstractConverter &converter,
                           const Fortran::parser::AccClause::Wait *waitClause,
-                          SmallVectorImpl<mlir::Value> &operands,
+                          llvm::SmallVectorImpl<mlir::Value> &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<Fortran::parser::ScalarIntExpr> &waitList =
+    const auto &waitList =
         std::get<std::list<Fortran::parser::ScalarIntExpr>>(waitArg.t);
     for (const Fortran::parser::ScalarIntExpr &value : waitList) {
       mlir::Value v = fir::getBase(
@@ -184,7 +184,7 @@ static void genWaitClause(Fortran::lower::AbstractConverter &converter,
       operands.push_back(v);
     }
 
-    const std::optional<Fortran::parser::ScalarIntExpr> &waitDevnumValue =
+    const auto &waitDevnumValue =
         std::get<std::optional<Fortran::parser::ScalarIntExpr>>(waitArg.t);
     if (waitDevnumValue)
       waitDevnum = fir::getBase(converter.genExprValue(
@@ -215,7 +215,8 @@ static void genACC(Fortran::lower::AbstractConverter &converter,
     mlir::Value vectorLength;
     mlir::Value gangNum;
     mlir::Value gangStatic;
-    SmallVector<Value, 2> tileOperands, privateOperands, reductionOperands;
+    llvm::SmallVector<mlir::Value, 2> tileOperands, privateOperands,
+        reductionOperands;
     std::int64_t executionMapping = mlir::acc::OpenACCExecMapping::NONE;
 
     // Lower clauses values mapped to operands.
@@ -293,8 +294,8 @@ static void genACC(Fortran::lower::AbstractConverter &converter,
     }
 
     // Prepare the operand segement size attribute and the operands value range.
-    SmallVector<Value, 8> operands;
-    SmallVector<int32_t, 8> operandSegments;
+    llvm::SmallVector<mlir::Value, 8> operands;
+    llvm::SmallVector<int32_t, 8> operandSegments;
     addOperand(operands, operandSegments, gangNum);
     addOperand(operands, operandSegments, gangStatic);
     addOperand(operands, operandSegments, workerNum);
@@ -343,8 +344,8 @@ genACCParallelOp(Fortran::lower::AbstractConverter &converter,
   mlir::Value vectorLength;
   mlir::Value ifCond;
   mlir::Value selfCond;
-  SmallVector<Value, 2> waitOperands, reductionOperands, copyOperands,
-      copyinOperands, copyinReadonlyOperands, copyoutOperands,
+  llvm::SmallVector<mlir::Value, 2> waitOperands, reductionOperands,
+      copyOperands, copyinOperands, copyinReadonlyOperands, copyoutOperands,
       copyoutZeroOperands, createOperands, createZeroOperands, noCreateOperands,
       presentOperands, devicePtrOperands, attachOperands, privateOperands,
       firstprivateOperands;
@@ -378,10 +379,10 @@ genACCParallelOp(Fortran::lower::AbstractConverter &converter,
       const auto &waitClauseValue = waitClause->v;
       if (waitClauseValue) { // wait has a value.
         const Fortran::parser::AccWaitArgument &waitArg = *waitClauseValue;
-        const std::list<Fortran::parser::ScalarIntExpr> &waitList =
+        const auto &waitList =
             std::get<std::list<Fortran::parser::ScalarIntExpr>>(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 @@ genACCParallelOp(Fortran::lower::AbstractConverter &converter,
           *Fortran::semantics::GetExpr(vectorLengthClause->v), stmtCtx));
     } else if (const auto *ifClause =
                    std::get_if<Fortran::parser::AccClause::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 @@ genACCParallelOp(Fortran::lower::AbstractConverter &converter,
               std::get_if<std::optional<Fortran::parser::ScalarLogicalExpr>>(
                   &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 @@ genACCParallelOp(Fortran::lower::AbstractConverter &converter,
   }
 
   // Prepare the operand segement size attribute and the operands value range.
-  SmallVector<Value, 8> operands;
-  SmallVector<int32_t, 8> operandSegments;
+  llvm::SmallVector<mlir::Value, 8> operands;
+  llvm::SmallVector<int32_t, 8> operandSegments;
   addOperand(operands, operandSegments, async);
   addOperands(operands, operandSegments, waitOperands);
   addOperand(operands, operandSegments, numGangs);
@@ -514,9 +515,10 @@ genACCParallelOp(Fortran::lower::AbstractConverter &converter,
 static void genACCDataOp(Fortran::lower::AbstractConverter &converter,
                          const Fortran::parser::AccClauseList &accClauseList) {
   mlir::Value ifCond;
-  SmallVector<mlir::Value> copyOperands, copyinOperands, copyinReadonlyOperands,
-      copyoutOperands, copyoutZeroOperands, createOperands, createZeroOperands,
-      noCreateOperands, presentOperands, deviceptrOperands, attachOperands;
+  llvm::SmallVector<mlir::Value> 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 @@ static void genACCDataOp(Fortran::lower::AbstractConverter &converter,
   }
 
   // Prepare the operand segement size attribute and the operands value range.
-  SmallVector<mlir::Value> operands;
-  SmallVector<int32_t> operandSegments;
+  llvm::SmallVector<mlir::Value> operands;
+  llvm::SmallVector<int32_t> operandSegments;
   addOperand(operands, operandSegments, ifCond);
   addOperands(operands, operandSegments, copyOperands);
   addOperands(operands, operandSegments, copyinOperands);
@@ -611,8 +613,8 @@ static void
 genACCEnterDataOp(Fortran::lower::AbstractConverter &converter,
                   const Fortran::parser::AccClauseList &accClauseList) {
   mlir::Value ifCond, async, waitDevnum;
-  SmallVector<mlir::Value> copyinOperands, createOperands, createZeroOperands,
-      attachOperands, waitOperands;
+  llvm::SmallVector<mlir::Value> 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 @@ genACCEnterDataOp(Fortran::lower::AbstractConverter &converter,
                    std::get_if<Fortran::parser::AccClause::Copyin>(&clause.u)) {
       const Fortran::parser::AccObjectListWithModifier &listWithModifier =
           copyinClause->v;
-      const Fortran::parser::AccObjectList &accObjectList =
+      const auto &accObjectList =
           std::get<Fortran::parser::AccObjectList>(listWithModifier.t);
       genObjectList(accObjectList, converter, copyinOperands);
     } else if (const auto *createClause =
@@ -661,8 +663,8 @@ genACCEnterDataOp(Fortran::lower::AbstractConverter &converter,
   }
 
   // Prepare the operand segement size attribute and the operands value range.
-  SmallVector<mlir::Value, 16> operands;
-  SmallVector<int32_t, 8> operandSegments;
+  llvm::SmallVector<mlir::Value, 16> operands;
+  llvm::SmallVector<int32_t, 8> operandSegments;
   addOperand(operands, operandSegments, ifCond);
   addOperand(operands, operandSegments, async);
   addOperand(operands, operandSegments, waitDevnum);
@@ -685,8 +687,8 @@ static void
 genACCExitDataOp(Fortran::lower::AbstractConverter &converter,
                  const Fortran::parser::AccClauseList &accClauseList) {
   mlir::Value ifCond, async, waitDevnum;
-  SmallVector<mlir::Value> copyoutOperands, deleteOperands, detachOperands,
-      waitOperands;
+  llvm::SmallVector<mlir::Value> 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 @@ genACCExitDataOp(Fortran::lower::AbstractConverter &converter,
                        &clause.u)) {
       const Fortran::parser::AccObjectListWithModifier &listWithModifier =
           copyoutClause->v;
-      const Fortran::parser::AccObjectList &accObjectList =
+      const auto &accObjectList =
           std::get<Fortran::parser::AccObjectList>(listWithModifier.t);
       genObjectList(accObjectList, converter, copyoutOperands);
     } else if (const auto *deleteClause =
@@ -733,8 +735,8 @@ genACCExitDataOp(Fortran::lower::AbstractConverter &converter,
   }
 
   // Prepare the operand segement size attribute and the operands value range.
-  SmallVector<mlir::Value, 14> operands;
-  SmallVector<int32_t, 7> operandSegments;
+  llvm::SmallVector<mlir::Value, 14> operands;
+  llvm::SmallVector<int32_t, 7> operandSegments;
   addOperand(operands, operandSegments, ifCond);
   addOperand(operands, operandSegments, async);
   addOperand(operands, operandSegments, waitDevnum);
@@ -759,7 +761,7 @@ static void
 genACCInitShutdownOp(Fortran::lower::AbstractConverter &converter,
                      const Fortran::parser::AccClauseList &accClauseList) {
   mlir::Value ifCond, deviceNum;
-  SmallVector<mlir::Value> deviceTypeOperands;
+  llvm::SmallVector<mlir::Value> deviceTypeOperands;
 
   fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
   mlir::Location currentLocation = converter.getCurrentLocation();
@@ -786,8 +788,8 @@ genACCInitShutdownOp(Fortran::lower::AbstractConverter &converter,
   }
 
   // Prepare the operand segement size attribute and the operands value range.
-  SmallVector<mlir::Value, 6> operands;
-  SmallVector<int32_t, 3> operandSegments;
+  llvm::SmallVector<mlir::Value, 6> operands;
+  llvm::SmallVector<int32_t, 3> operandSegments;
   addOperands(operands, operandSegments, deviceTypeOperands);
   addOperand(operands, operandSegments, deviceNum);
   addOperand(operands, operandSegments, ifCond);
@@ -799,7 +801,7 @@ static void
 genACCUpdateOp(Fortran::lower::AbstractConverter &converter,
                const Fortran::parser::AccClauseList &accClauseList) {
   mlir::Value ifCond, async, waitDevnum;
-  SmallVector<mlir::Value> hostOperands, deviceOperands, waitOperands,
+  llvm::SmallVector<mlir::Value> hostOperands, deviceOperands, waitOperands,
       deviceTypeOperands;
 
   // Async and wait clause have optional values but can be present with
@@ -842,8 +844,8 @@ genACCUpdateOp(Fortran::lower::AbstractConverter &converter,
   }
 
   // Prepare the operand segement size attribute and the operands value range.
-  SmallVector<mlir::Value> operands;
-  SmallVector<int32_t> operandSegments;
+  llvm::SmallVector<mlir::Value> operands;
+  llvm::SmallVector<int32_t> operandSegments;
   addOperand(operands, operandSegments, ifCond);
   addOperand(operands, operandSegments, async);
   addOperand(operands, operandSegments, waitDevnum);
@@ -899,7 +901,7 @@ static void genACC(Fortran::lower::AbstractConverter &converter,
       std::get<Fortran::parser::AccClauseList>(waitConstruct.t);
 
   mlir::Value ifCond, waitDevnum, async;
-  SmallVector<mlir::Value> waitOperands;
+  llvm::SmallVector<mlir::Value> 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 @@ static void genACC(Fortran::lower::AbstractConverter &converter,
 
   if (waitArgument) { // wait has a value.
     const Fortran::parser::AccWaitArgument &waitArg = *waitArgument;
-    const std::list<Fortran::parser::ScalarIntExpr> &waitList =
+    const auto &waitList =
         std::get<std::list<Fortran::parser::ScalarIntExpr>>(waitArg.t);
     for (const Fortran::parser::ScalarIntExpr &value : waitList) {
       mlir::Value v = fir::getBase(
@@ -920,7 +922,7 @@ static void genACC(Fortran::lower::AbstractConverter &converter,
       waitOperands.push_back(v);
     }
 
-    const std::optional<Fortran::parser::ScalarIntExpr> &waitDevnumValue =
+    const auto &waitDevnumValue =
         std::get<std::optional<Fortran::parser::ScalarIntExpr>>(waitArg.t);
     if (waitDevnumValue)
       waitDevnum = fir::getBase(converter.genExprValue(
@@ -941,8 +943,8 @@ static void genACC(Fortran::lower::AbstractConverter &converter,
   }
 
   // Prepare the operand segement size attribute and the operands value range.
-  SmallVector<mlir::Value> operands;
-  SmallVector<int32_t> operandSegments;
+  llvm::SmallVector<mlir::Value> operands;
+  llvm::SmallVector<int32_t> operandSegments;
   addOperands(operands, operandSegments, waitOperands);
   addOperand(operands, operandSegments, async);
   addOperand(operands, operandSegments, waitDevnum);


        


More information about the flang-commits mailing list