xref: /freebsd-src/contrib/llvm-project/llvm/include/llvm-c/BitWriter.h (revision 5b27928474e6a4103d65b347544705c40c9618fd)
10b57cec5SDimitry Andric /*===-- llvm-c/BitWriter.h - BitWriter Library C Interface ------*- C++ -*-===*\
20b57cec5SDimitry Andric |*                                                                            *|
30b57cec5SDimitry Andric |* Part of the LLVM Project, under the Apache License v2.0 with LLVM          *|
40b57cec5SDimitry Andric |* Exceptions.                                                                *|
50b57cec5SDimitry Andric |* See https://llvm.org/LICENSE.txt for license information.                  *|
60b57cec5SDimitry Andric |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception                    *|
70b57cec5SDimitry Andric |*                                                                            *|
80b57cec5SDimitry Andric |*===----------------------------------------------------------------------===*|
90b57cec5SDimitry Andric |*                                                                            *|
100b57cec5SDimitry Andric |* This header declares the C interface to libLLVMBitWriter.a, which          *|
110b57cec5SDimitry Andric |* implements output of the LLVM bitcode format.                              *|
120b57cec5SDimitry Andric |*                                                                            *|
130b57cec5SDimitry Andric |* Many exotic languages can interoperate with C code but have a harder time  *|
140b57cec5SDimitry Andric |* with C++ due to name mangling. So in addition to C, this interface enables *|
150b57cec5SDimitry Andric |* tools written in such languages.                                           *|
160b57cec5SDimitry Andric |*                                                                            *|
170b57cec5SDimitry Andric \*===----------------------------------------------------------------------===*/
180b57cec5SDimitry Andric 
190b57cec5SDimitry Andric #ifndef LLVM_C_BITWRITER_H
200b57cec5SDimitry Andric #define LLVM_C_BITWRITER_H
210b57cec5SDimitry Andric 
22*480093f4SDimitry Andric #include "llvm-c/ExternC.h"
230b57cec5SDimitry Andric #include "llvm-c/Types.h"
240b57cec5SDimitry Andric 
25*480093f4SDimitry Andric LLVM_C_EXTERN_C_BEGIN
260b57cec5SDimitry Andric 
270b57cec5SDimitry Andric /**
280b57cec5SDimitry Andric  * @defgroup LLVMCBitWriter Bit Writer
290b57cec5SDimitry Andric  * @ingroup LLVMC
300b57cec5SDimitry Andric  *
310b57cec5SDimitry Andric  * @{
320b57cec5SDimitry Andric  */
330b57cec5SDimitry Andric 
340b57cec5SDimitry Andric /*===-- Operations on modules ---------------------------------------------===*/
350b57cec5SDimitry Andric 
360b57cec5SDimitry Andric /** Writes a module to the specified path. Returns 0 on success. */
370b57cec5SDimitry Andric int LLVMWriteBitcodeToFile(LLVMModuleRef M, const char *Path);
380b57cec5SDimitry Andric 
390b57cec5SDimitry Andric /** Writes a module to an open file descriptor. Returns 0 on success. */
400b57cec5SDimitry Andric int LLVMWriteBitcodeToFD(LLVMModuleRef M, int FD, int ShouldClose,
410b57cec5SDimitry Andric                          int Unbuffered);
420b57cec5SDimitry Andric 
430b57cec5SDimitry Andric /** Deprecated for LLVMWriteBitcodeToFD. Writes a module to an open file
440b57cec5SDimitry Andric     descriptor. Returns 0 on success. Closes the Handle. */
450b57cec5SDimitry Andric int LLVMWriteBitcodeToFileHandle(LLVMModuleRef M, int Handle);
460b57cec5SDimitry Andric 
470b57cec5SDimitry Andric /** Writes a module to a new memory buffer and returns it. */
480b57cec5SDimitry Andric LLVMMemoryBufferRef LLVMWriteBitcodeToMemoryBuffer(LLVMModuleRef M);
490b57cec5SDimitry Andric 
500b57cec5SDimitry Andric /**
510b57cec5SDimitry Andric  * @}
520b57cec5SDimitry Andric  */
530b57cec5SDimitry Andric 
54*480093f4SDimitry Andric LLVM_C_EXTERN_C_END
550b57cec5SDimitry Andric 
560b57cec5SDimitry Andric #endif
57