[Mlir-commits] [mlir] 5e82120 - [mlir] Use `interleave` in `printOperands` (NFC)

Jeff Niu llvmlistbot at llvm.org
Thu Sep 29 15:58:46 PDT 2022


Author: Jeff Niu
Date: 2022-09-29T15:58:37-07:00
New Revision: 5e82120e6815bb7aa2af095f056b0c18bfd314d7

URL: https://github.com/llvm/llvm-project/commit/5e82120e6815bb7aa2af095f056b0c18bfd314d7
DIFF: https://github.com/llvm/llvm-project/commit/5e82120e6815bb7aa2af095f056b0c18bfd314d7.diff

LOG: [mlir] Use `interleave` in `printOperands` (NFC)

Instead of reimplementing it.

Reviewed By: rriddle

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

Added: 
    

Modified: 
    mlir/include/mlir/IR/OpImplementation.h

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/IR/OpImplementation.h b/mlir/include/mlir/IR/OpImplementation.h
index fcfd2f57cf91..78843accdf45 100644
--- a/mlir/include/mlir/IR/OpImplementation.h
+++ b/mlir/include/mlir/IR/OpImplementation.h
@@ -356,13 +356,8 @@ class OpAsmPrinter : public AsmPrinter {
   /// Print a comma separated list of operands.
   template <typename IteratorType>
   void printOperands(IteratorType it, IteratorType end) {
-    if (it == end)
-      return;
-    printOperand(*it);
-    for (++it; it != end; ++it) {
-      getStream() << ", ";
-      printOperand(*it);
-    }
+    llvm::interleaveComma(llvm::make_range(it, end), getStream(),
+                          [this](Value value) { printOperand(value); });
   }
 
   /// Print the given successor.


        


More information about the Mlir-commits mailing list