Added Module.to_native_object() and Module.to_native_assembly().

Added test for these new functions.
This commit is contained in:
Siu Kwan Lam 2012-08-09 15:41:55 -07:00
commit bed4f24cbd
5 changed files with 175 additions and 3 deletions

View file

@ -516,6 +516,16 @@ class Module(llvm.Ownable, llvm.Cacheable):
id = property(_get_id, _set_id)
def to_native_object(self):
'''returns byte string of the module as native object code
'''
return _core.LLVMGetNativeCodeFromModule(self.ptr, 0)
def to_native_assembly(self):
'''returns byte string of the module as native assembly code
'''
return _core.LLVMGetNativeCodeFromModule(self.ptr, 1)
#===----------------------------------------------------------------------===
# Types
#===----------------------------------------------------------------------===
@ -2126,3 +2136,12 @@ def inline_function(call):
check_is_value(call)
return _core.LLVMInlineFunction(call.ptr)
#===----------------------------------------------------------------------===
# Initialization
#===----------------------------------------------------------------------===
if _core.LLVMInitializeNativeTarget():
raise llvm.LLVMException("No native target!?")