mirror of
https://github.com/intel/llvm.git
synced 2026-01-26 21:53:12 +08:00
Summary: The "i1" (viz. bool) type does not have a proper equivalent on the "C" size. So, to avoid any ABIs issues, we simply use print_i32 on an i32 value of one or zero for true and false. This has the added advantage that one less function needs to be implemented when porting the runtime support library. Reviewers: ftynse, bkramer, nicolasvasilache Reviewed By: ftynse Subscribers: mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, liufengdb, stephenneuendorffer, Joonsoo, grosul1, frgossen, Kayjukh, jurahul, msifontes Tags: #mlir Differential Revision: https://reviews.llvm.org/D82048
36 lines
1.5 KiB
C++
36 lines
1.5 KiB
C++
//===- CRunnerUtils.cpp - Utils for MLIR execution ------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file implements basic functions to manipulate structured MLIR types at
|
|
// runtime. Entities in this file are meant to be retargetable, including on
|
|
// targets without a C++ runtime, and must be kept C compatible.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "mlir/ExecutionEngine/CRunnerUtils.h"
|
|
|
|
#include <cinttypes>
|
|
#include <cstdio>
|
|
|
|
#ifdef MLIR_CRUNNERUTILS_DEFINE_FUNCTIONS
|
|
|
|
// Small runtime support "lib" for vector.print lowering.
|
|
// 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_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); }
|
|
extern "C" void print_f64(double d) { fprintf(stdout, "%lg", d); }
|
|
extern "C" void print_open() { fputs("( ", stdout); }
|
|
extern "C" void print_close() { fputs(" )", stdout); }
|
|
extern "C" void print_comma() { fputs(", ", stdout); }
|
|
extern "C" void print_newline() { fputc('\n', stdout); }
|
|
|
|
#endif
|