Add Module bitcode writer/parser
This commit is contained in:
parent
961c5e99e1
commit
168510222f
7 changed files with 138 additions and 14 deletions
30
newbinding/src/Bitcode/ReaderWriter.py
Normal file
30
newbinding/src/Bitcode/ReaderWriter.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
from binding import *
|
||||
from ..namespace import llvm
|
||||
from ..ADT.StringRef import StringRef
|
||||
from ..Module import Module
|
||||
from ..LLVMContext import LLVMContext
|
||||
|
||||
llvm.includes.add('llvm/Bitcode/ReaderWriter.h')
|
||||
|
||||
ParseBitCodeFile = llvm.CustomFunction('ParseBitCodeFile',
|
||||
'llvm_ParseBitCodeFile',
|
||||
PyObjectPtr, # returns Module*
|
||||
cast(str, StringRef),
|
||||
ref(LLVMContext),
|
||||
PyObjectPtr, # file-like object
|
||||
).require_only(2)
|
||||
|
||||
WriteBitcodeToFile = llvm.CustomFunction('WriteBitcodeToFile',
|
||||
'llvm_WriteBitcodeToFile',
|
||||
PyObjectPtr, # return None
|
||||
ptr(Module),
|
||||
PyObjectPtr, # file-like object
|
||||
)
|
||||
|
||||
getBitcodeTargetTriple = llvm.CustomFunction('getBitcodeTargetTriple',
|
||||
'llvm_getBitcodeTargetTriple',
|
||||
PyObjectPtr, # return str
|
||||
cast(str, StringRef),
|
||||
ref(LLVMContext),
|
||||
PyObjectPtr, # file-like object
|
||||
).require_only(2)
|
||||
10
newbinding/src/Bitcode/__init__.py
Normal file
10
newbinding/src/Bitcode/__init__.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import os.path, importlib
|
||||
|
||||
def _init():
|
||||
for fname in os.listdir(os.path.dirname(__file__)):
|
||||
if ((fname.endswith('.py') or fname.endswith('.pyc')) and
|
||||
not fname.startswith('__init__')):
|
||||
modname = os.path.basename(fname).rsplit('.', 1)[0]
|
||||
importlib.import_module('.' + modname, __name__)
|
||||
|
||||
_init()
|
||||
Loading…
Add table
Add a link
Reference in a new issue