1 //===- bitwriter.go - Bindings for bitwriter ------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // This file defines bindings for the bitwriter component.
11 //===----------------------------------------------------------------------===//
16 #include "llvm-c/BitWriter.h"
23 var writeBitcodeToFileErr
= errors
.New("Failed to write bitcode to file")
25 func WriteBitcodeToFile(m Module
, file
*os
.File
) error
{
26 fail
:= C
.LLVMWriteBitcodeToFD(m
.C
, C
.int(file
.Fd()), C
.int(0), C
.int(0))
28 return writeBitcodeToFileErr
33 func WriteBitcodeToMemoryBuffer(m Module
) MemoryBuffer
{
34 mb
:= C
.LLVMWriteBitcodeToMemoryBuffer(m
.C
)
35 return MemoryBuffer
{mb
}
38 // TODO(nsf): Figure out way how to make it work with io.Writer