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 printI64(int64_t i) { fprintf(stdout, "%" PRId64, i); } 27 extern "C" void printU64(uint64_t u) { fprintf(stdout, "%" PRIu64, u); } 28 extern "C" void printF32(float f) { fprintf(stdout, "%g", f); } 29 extern "C" void printF64(double d) { fprintf(stdout, "%lg", d); } 30 extern "C" void printOpen() { fputs("( ", stdout); } 31 extern "C" void printClose() { fputs(" )", stdout); } 32 extern "C" void printComma() { fputs(", ", stdout); } 33 extern "C" void printNewline() { fputc('\n', stdout); } 34 35 #endif 36