1 //===- bitwriter.go - Bindings for bitwriter ------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines bindings for the bitwriter component.
12 //===----------------------------------------------------------------------===//
17 #include "llvm-c/BitWriter.h"
24 var writeBitcodeToFileErr = errors.New("Failed to write bitcode to file")
26 func WriteBitcodeToFile(m Module, file *os.File) error {
27 fail := C.LLVMWriteBitcodeToFD(m.C, C.int(file.Fd()), C.int(0), C.int(0))
29 return writeBitcodeToFileErr
34 func WriteBitcodeToMemoryBuffer(m Module) MemoryBuffer {
35 mb := C.LLVMWriteBitcodeToMemoryBuffer(m.C)
36 return MemoryBuffer{mb}
39 // TODO(nsf): Figure out way how to make it work with io.Writer