xref: /freebsd-src/contrib/llvm-project/llvm/include/llvm-c/BitReader.h (revision 753f127f3ace09432b2baeffd71a308760641a62)
10b57cec5SDimitry Andric /*===-- llvm-c/BitReader.h - BitReader 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 libLLVMBitReader.a, which          *|
110b57cec5SDimitry Andric |* implements input 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_BITREADER_H
200b57cec5SDimitry Andric #define LLVM_C_BITREADER_H
210b57cec5SDimitry Andric 
22480093f4SDimitry Andric #include "llvm-c/ExternC.h"
230b57cec5SDimitry Andric #include "llvm-c/Types.h"
240b57cec5SDimitry Andric 
25480093f4SDimitry Andric LLVM_C_EXTERN_C_BEGIN
260b57cec5SDimitry Andric 
270b57cec5SDimitry Andric /**
280b57cec5SDimitry Andric  * @defgroup LLVMCBitReader Bit Reader
290b57cec5SDimitry Andric  * @ingroup LLVMC
300b57cec5SDimitry Andric  *
310b57cec5SDimitry Andric  * @{
320b57cec5SDimitry Andric  */
330b57cec5SDimitry Andric 
340b57cec5SDimitry Andric /* Builds a module from the bitcode in the specified memory buffer, returning a
350b57cec5SDimitry Andric    reference to the module via the OutModule parameter. Returns 0 on success.
360b57cec5SDimitry Andric    Optionally returns a human-readable error message via OutMessage.
370b57cec5SDimitry Andric 
380b57cec5SDimitry Andric    This is deprecated. Use LLVMParseBitcode2. */
390b57cec5SDimitry Andric LLVMBool LLVMParseBitcode(LLVMMemoryBufferRef MemBuf, LLVMModuleRef *OutModule,
400b57cec5SDimitry Andric                           char **OutMessage);
410b57cec5SDimitry Andric 
420b57cec5SDimitry Andric /* Builds a module from the bitcode in the specified memory buffer, returning a
430b57cec5SDimitry Andric    reference to the module via the OutModule parameter. Returns 0 on success. */
440b57cec5SDimitry Andric LLVMBool LLVMParseBitcode2(LLVMMemoryBufferRef MemBuf,
450b57cec5SDimitry Andric                            LLVMModuleRef *OutModule);
460b57cec5SDimitry Andric 
470b57cec5SDimitry Andric /* This is deprecated. Use LLVMParseBitcodeInContext2. */
480b57cec5SDimitry Andric LLVMBool LLVMParseBitcodeInContext(LLVMContextRef ContextRef,
490b57cec5SDimitry Andric                                    LLVMMemoryBufferRef MemBuf,
500b57cec5SDimitry Andric                                    LLVMModuleRef *OutModule, char **OutMessage);
510b57cec5SDimitry Andric 
520b57cec5SDimitry Andric LLVMBool LLVMParseBitcodeInContext2(LLVMContextRef ContextRef,
530b57cec5SDimitry Andric                                     LLVMMemoryBufferRef MemBuf,
540b57cec5SDimitry Andric                                     LLVMModuleRef *OutModule);
550b57cec5SDimitry Andric 
560b57cec5SDimitry Andric /** Reads a module from the specified path, returning via the OutMP parameter
570b57cec5SDimitry Andric     a module provider which performs lazy deserialization. Returns 0 on success.
580b57cec5SDimitry Andric     Optionally returns a human-readable error message via OutMessage.
590b57cec5SDimitry Andric     This is deprecated. Use LLVMGetBitcodeModuleInContext2. */
600b57cec5SDimitry Andric LLVMBool LLVMGetBitcodeModuleInContext(LLVMContextRef ContextRef,
610b57cec5SDimitry Andric                                        LLVMMemoryBufferRef MemBuf,
620b57cec5SDimitry Andric                                        LLVMModuleRef *OutM, char **OutMessage);
630b57cec5SDimitry Andric 
64*753f127fSDimitry Andric /** Reads a module from the given memory buffer, returning via the OutMP
65*753f127fSDimitry Andric  * parameter a module provider which performs lazy deserialization.
66*753f127fSDimitry Andric  *
67*753f127fSDimitry Andric  * Returns 0 on success.
68*753f127fSDimitry Andric  *
69*753f127fSDimitry Andric  * Takes ownership of \p MemBuf if (and only if) the module was read
70*753f127fSDimitry Andric  * successfully. */
710b57cec5SDimitry Andric LLVMBool LLVMGetBitcodeModuleInContext2(LLVMContextRef ContextRef,
720b57cec5SDimitry Andric                                         LLVMMemoryBufferRef MemBuf,
730b57cec5SDimitry Andric                                         LLVMModuleRef *OutM);
740b57cec5SDimitry Andric 
750b57cec5SDimitry Andric /* This is deprecated. Use LLVMGetBitcodeModule2. */
760b57cec5SDimitry Andric LLVMBool LLVMGetBitcodeModule(LLVMMemoryBufferRef MemBuf, LLVMModuleRef *OutM,
770b57cec5SDimitry Andric                               char **OutMessage);
780b57cec5SDimitry Andric 
790b57cec5SDimitry Andric LLVMBool LLVMGetBitcodeModule2(LLVMMemoryBufferRef MemBuf, LLVMModuleRef *OutM);
800b57cec5SDimitry Andric 
810b57cec5SDimitry Andric /**
820b57cec5SDimitry Andric  * @}
830b57cec5SDimitry Andric  */
840b57cec5SDimitry Andric 
85480093f4SDimitry Andric LLVM_C_EXTERN_C_END
860b57cec5SDimitry Andric 
870b57cec5SDimitry Andric #endif
88