[InstCombine] Signed saturation patterns
[llvm-core.git] / bindings / go / llvm / bitwriter.go
blob83780fc69713e47c887432e6a43cd8f2eb94827b
1 //===- bitwriter.go - Bindings for bitwriter ------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines bindings for the bitwriter component.
11 //===----------------------------------------------------------------------===//
13 package llvm
16 #include "llvm-c/BitWriter.h"
17 #include <stdlib.h>
19 import "C"
20 import "os"
21 import "errors"
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))
27 if fail != 0 {
28 return writeBitcodeToFileErr
30 return nil
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