1 //===- CRunnerUtils.cpp - Utils for MLIR execution ------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file implements basic functions to manipulate structured MLIR types at 10 // runtime. Entities in this file are meant to be retargetable, including on 11 // targets without a C++ runtime, and must be kept C compatible. 12 // 13 //===----------------------------------------------------------------------===// 14 15 #include "mlir/ExecutionEngine/CRunnerUtils.h" 16 17 #include <cinttypes> 18 #include <cstdio> 19 20 #ifdef MLIR_CRUNNERUTILS_DEFINE_FUNCTIONS 21 22 // Small runtime support "lib" for vector.print lowering. 23 // By providing elementary printing methods only, this 24 // library can remain fully unaware of low-level implementation 25 // details of our vectors. Also useful for direct LLVM IR output. 26 extern "C" void print_i32(int32_t i) { fprintf(stdout, "%" PRId32, i); } 27 extern "C" void print_i64(int64_t l) { fprintf(stdout, "%" PRId64, l); } 28 extern "C" void print_f32(float f) { fprintf(stdout, "%g", f); } 29 extern "C" void print_f64(double d) { fprintf(stdout, "%lg", d); } 30 extern "C" void print_open() { fputs("( ", stdout); } 31 extern "C" void print_close() { fputs(" )", stdout); } 32 extern "C" void print_comma() { fputs(", ", stdout); } 33 extern "C" void print_newline() { fputc('\n', stdout); } 34 35 #endif 36