[InstCombine] Signed saturation patterns
[llvm-core.git] / bindings / python / llvm / bit_reader.py
blob33b8211076b8024fdefae59dc89ef0028a491fca
2 from .common import LLVMObject
3 from .common import c_object_p
4 from .common import get_library
5 from . import enumerations
6 from .core import MemoryBuffer
7 from .core import Module
8 from .core import OpCode
9 from ctypes import POINTER
10 from ctypes import byref
11 from ctypes import c_char_p
12 from ctypes import cast
13 __all__ = ['parse_bitcode']
14 lib = get_library()
16 def parse_bitcode(mem_buffer):
17 """Input is .core.MemoryBuffer"""
18 module = c_object_p()
19 result = lib.LLVMParseBitcode2(mem_buffer, byref(module))
20 if result:
21 raise RuntimeError('LLVM Error')
22 m = Module(module)
23 m.take_ownership(mem_buffer)
24 return m
26 def register_library(library):
27 library.LLVMParseBitcode2.argtypes = [MemoryBuffer, POINTER(c_object_p)]
28 library.LLVMParseBitcode2.restype = bool
30 register_library(lib)