1//===- ExportSMTLIB.cpp - C Interface to ExportSMTLIB ---------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM
4// Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9//
10// Implements a C Interface for export SMTLIB.
11//
12//===----------------------------------------------------------------------===//
13
14#include "mlir-c/Target/ExportSMTLIB.h"
15#include "mlir/CAPI/IR.h"
16#include "mlir/CAPI/Support.h"
17#include "mlir/CAPI/Utils.h"
18#include "mlir/Target/SMTLIB/ExportSMTLIB.h"
19
20using namespace mlir;
21
22MlirLogicalResult mlirTranslateOperationToSMTLIB(
23 MlirOperation module, MlirStringCallback callback, void *userData,
24 bool inlineSingleUseValues, bool indentLetBody, bool emitReset) {
25 mlir::detail::CallbackOstream stream(callback, userData);
26 smt::SMTEmissionOptions options;
27 options.inlineSingleUseValues = inlineSingleUseValues;
28 options.indentLetBody = indentLetBody;
29 options.emitReset = emitReset;
30 return wrap(res: smt::exportSMTLIB(module: unwrap(c: module), os&: stream, options));
31}
32
33MlirLogicalResult
34mlirTranslateModuleToSMTLIB(MlirModule module, MlirStringCallback callback,
35 void *userData, bool inlineSingleUseValues,
36 bool indentLetBody, bool emitReset) {
37 return mlirTranslateOperationToSMTLIB(
38 module: mlirModuleGetOperation(module), callback, userData, inlineSingleUseValues,
39 indentLetBody, emitReset);
40}
41