//===----------------------------------------------------------------------===//
// 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);
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);
}
// 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",
// 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); }
// 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