[mlir][openacc][NFC] move index in processDataOperands
authorValentin Clement <clementval@gmail.com>
Wed, 9 Jun 2021 14:28:07 +0000 (10:28 -0400)
committerclementval <clementval@gmail.com>
Wed, 9 Jun 2021 14:28:30 +0000 (10:28 -0400)
Move the index variable used to track variables inside of the specific
processDataOperands functions.

Reviewed By: kiranchandramohan

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

mlir/lib/Target/LLVMIR/Dialect/OpenACC/OpenACCToLLVMIRTranslation.cpp

index cbdf64f..4fbd051 100644 (file)
@@ -187,15 +187,15 @@ processOperands(llvm::IRBuilderBase &builder,
 }
 
 /// Process data operands from acc::EnterDataOp
-static LogicalResult
-processDataOperands(llvm::IRBuilderBase &builder,
-                    LLVM::ModuleTranslation &moduleTranslation,
-                    acc::EnterDataOp op, SmallVector<uint64_t> &flags,
-                    SmallVector<llvm::Constant *> &names, unsigned &index,
-                    llvm::AllocaInst *argsBase, llvm::AllocaInst *args,
-                    llvm::AllocaInst *argSizes) {
+static LogicalResult processDataOperands(
+    llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation,
+    acc::EnterDataOp op, SmallVector<uint64_t> &flags,
+    SmallVector<llvm::Constant *> &names, llvm::AllocaInst *argsBase,
+    llvm::AllocaInst *args, llvm::AllocaInst *argSizes) {
   // TODO add `create_zero` and `attach` operands
 
+  unsigned index = 0;
+
   // Create operands are handled as `alloc` call.
   if (failed(processOperands(builder, moduleTranslation, op,
                              op.createOperands(), op.getNumDataOperands(),
@@ -214,15 +214,15 @@ processDataOperands(llvm::IRBuilderBase &builder,
 }
 
 /// Process data operands from acc::ExitDataOp
-static LogicalResult
-processDataOperands(llvm::IRBuilderBase &builder,
-                    LLVM::ModuleTranslation &moduleTranslation,
-                    acc::ExitDataOp op, SmallVector<uint64_t> &flags,
-                    SmallVector<llvm::Constant *> &names, unsigned &index,
-                    llvm::AllocaInst *argsBase, llvm::AllocaInst *args,
-                    llvm::AllocaInst *argSizes) {
+static LogicalResult processDataOperands(
+    llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation,
+    acc::ExitDataOp op, SmallVector<uint64_t> &flags,
+    SmallVector<llvm::Constant *> &names, llvm::AllocaInst *argsBase,
+    llvm::AllocaInst *args, llvm::AllocaInst *argSizes) {
   // TODO add `detach` operands
 
+  unsigned index = 0;
+
   // Delete operands are handled as `delete` call.
   if (failed(processOperands(builder, moduleTranslation, op,
                              op.deleteOperands(), op.getNumDataOperands(),
@@ -241,13 +241,12 @@ processDataOperands(llvm::IRBuilderBase &builder,
 }
 
 /// Process data operands from acc::UpdateOp
-static LogicalResult
-processDataOperands(llvm::IRBuilderBase &builder,
-                    LLVM::ModuleTranslation &moduleTranslation,
-                    acc::UpdateOp op, SmallVector<uint64_t> &flags,
-                    SmallVector<llvm::Constant *> &names, unsigned &index,
-                    llvm::AllocaInst *argsBase, llvm::AllocaInst *args,
-                    llvm::AllocaInst *argSizes) {
+static LogicalResult processDataOperands(
+    llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation,
+    acc::UpdateOp op, SmallVector<uint64_t> &flags,
+    SmallVector<llvm::Constant *> &names, llvm::AllocaInst *argsBase,
+    llvm::AllocaInst *args, llvm::AllocaInst *argSizes) {
+  unsigned index = 0;
 
   // Host operands are handled as `from` call.
   if (failed(processOperands(builder, moduleTranslation, op, op.hostOperands(),
@@ -305,10 +304,9 @@ convertStandaloneDataOp(OpTy &op, llvm::IRBuilderBase &builder,
 
   SmallVector<uint64_t> flags;
   SmallVector<llvm::Constant *> names;
-  unsigned index = 0;
 
   if (failed(processDataOperands(builder, moduleTranslation, op, flags, names,
-                                 index, argsBase, args, argSizes)))
+                                 argsBase, args, argSizes)))
     return failure();
 
   llvm::GlobalVariable *maptypes =