[PATCH] D79198: [mlir] [VectorOps] Included i1 support for vector.print

Aart Bik via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 30 15:08:00 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG6937251f013f: [mlir] [VectorOps] Included i1 support for vector.print (authored by aartbik).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79198/new/

https://reviews.llvm.org/D79198

Files:
  mlir/include/mlir/ExecutionEngine/CRunnerUtils.h
  mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
  mlir/lib/ExecutionEngine/CRunnerUtils.cpp
  mlir/test/Conversion/VectorToLLVM/vector-to-llvm.mlir


Index: mlir/test/Conversion/VectorToLLVM/vector-to-llvm.mlir
===================================================================
--- mlir/test/Conversion/VectorToLLVM/vector-to-llvm.mlir
+++ mlir/test/Conversion/VectorToLLVM/vector-to-llvm.mlir
@@ -418,6 +418,15 @@
 //       CHECK:   llvm.mlir.constant(0 : index
 //       CHECK:   llvm.insertvalue {{.*}}[2] : !llvm<"{ [8 x [8 x <8 x float>]]*, [8 x [8 x <8 x float>]]*, i64 }">
 
+func @vector_print_scalar_i1(%arg0: i1) {
+  vector.print %arg0 : i1
+  return
+}
+// CHECK-LABEL: llvm.func @vector_print_scalar_i1(
+// CHECK-SAME: %[[A:.*]]: !llvm.i1)
+//       CHECK:    llvm.call @print_i1(%[[A]]) : (!llvm.i1) -> ()
+//       CHECK:    llvm.call @print_newline() : () -> ()
+
 func @vector_print_scalar_i32(%arg0: i32) {
   vector.print %arg0 : i32
   return
Index: mlir/lib/ExecutionEngine/CRunnerUtils.cpp
===================================================================
--- mlir/lib/ExecutionEngine/CRunnerUtils.cpp
+++ mlir/lib/ExecutionEngine/CRunnerUtils.cpp
@@ -23,6 +23,7 @@
 // By providing elementary printing methods only, this
 // library can remain fully unaware of low-level implementation
 // details of our vectors. Also useful for direct LLVM IR output.
+extern "C" void print_i1(bool b) { fputc(b ? '1' : '0', stdout); }
 extern "C" void print_i32(int32_t i) { fprintf(stdout, "%" PRId32, i); }
 extern "C" void print_i64(int64_t l) { fprintf(stdout, "%" PRId64, l); }
 extern "C" void print_f32(float f) { fprintf(stdout, "%g", f); }
Index: mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
===================================================================
--- mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
+++ mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
@@ -925,7 +925,9 @@
     Type eltType = vectorType ? vectorType.getElementType() : printType;
     int64_t rank = vectorType ? vectorType.getRank() : 0;
     Operation *printer;
-    if (eltType.isSignlessInteger(32))
+    if (eltType.isSignlessInteger(1))
+      printer = getPrintI1(op);
+    else if (eltType.isSignlessInteger(32))
       printer = getPrintI32(op);
     else if (eltType.isSignlessInteger(64))
       printer = getPrintI64(op);
@@ -992,6 +994,11 @@
   }
 
   // Helpers for method names.
+  Operation *getPrintI1(Operation *op) const {
+    LLVM::LLVMDialect *dialect = typeConverter.getDialect();
+    return getPrint(op, dialect, "print_i1",
+                    LLVM::LLVMType::getInt1Ty(dialect));
+  }
   Operation *getPrintI32(Operation *op) const {
     LLVM::LLVMDialect *dialect = typeConverter.getDialect();
     return getPrint(op, dialect, "print_i32",
Index: mlir/include/mlir/ExecutionEngine/CRunnerUtils.h
===================================================================
--- mlir/include/mlir/ExecutionEngine/CRunnerUtils.h
+++ mlir/include/mlir/ExecutionEngine/CRunnerUtils.h
@@ -167,6 +167,7 @@
 //===----------------------------------------------------------------------===//
 // Small runtime support "lib" for vector.print lowering during codegen.
 //===----------------------------------------------------------------------===//
+extern "C" MLIR_CRUNNERUTILS_EXPORT void print_i1(bool b);
 extern "C" MLIR_CRUNNERUTILS_EXPORT void print_i32(int32_t i);
 extern "C" MLIR_CRUNNERUTILS_EXPORT void print_i64(int64_t l);
 extern "C" MLIR_CRUNNERUTILS_EXPORT void print_f32(float f);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79198.261371.patch
Type: text/x-patch
Size: 3389 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200430/c19d1c5c/attachment.bin>


More information about the llvm-commits mailing list