Compare commits
No commits in common. "master" and "0.12.2" have entirely different histories.
20 changed files with 38 additions and 115 deletions
21
CHANGELOG
21
CHANGELOG
|
|
@ -1,23 +1,4 @@
|
||||||
2014-04-28 0.12.5:
|
2013-02-04 0.12.2:
|
||||||
---------------------
|
|
||||||
* Fixes memory leaks (#92)
|
|
||||||
* Fixes tarball (#99)
|
|
||||||
|
|
||||||
2014-03-20 0.12.4:
|
|
||||||
---------------------
|
|
||||||
* Add dylib_import_library and friends
|
|
||||||
* Fix BasicBlock downcast
|
|
||||||
* Module hashing
|
|
||||||
* Fix test script
|
|
||||||
|
|
||||||
2014-02-18 0.12.3:
|
|
||||||
---------------------
|
|
||||||
* Fix deprecation message for py2.6
|
|
||||||
* Fix llvm_cbuilder for using deprecated_alloca
|
|
||||||
* Merged PR #88 by cantora
|
|
||||||
* Merged PR #94 by cgohlke
|
|
||||||
|
|
||||||
2014-02-04 0.12.2:
|
|
||||||
---------------------
|
---------------------
|
||||||
* enhance wrapper efficiency by moving some capsule code into C++
|
* enhance wrapper efficiency by moving some capsule code into C++
|
||||||
* fix unclosed file handler in avx_support
|
* fix unclosed file handler in avx_support
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
include CHANGELOG LICENSE README.rst setup.py MANIFEST.in versioneer.py
|
include CHANGELOG LICENSE README setup.py MANIFEST.in
|
||||||
recursive-include llvm *
|
recursive-include llvm *
|
||||||
recursive-include llvmpy *
|
|
||||||
recursive-include www *
|
recursive-include www *
|
||||||
recursive-include test *
|
recursive-include test *
|
||||||
recursive-include tools *
|
recursive-include tools *
|
||||||
|
|
|
||||||
|
|
@ -30,14 +30,11 @@ Quickstart
|
||||||
to separate your custom build from the default system package. Please
|
to separate your custom build from the default system package. Please
|
||||||
replace ``LLVM_INSTALL_PATH`` with your own path.
|
replace ``LLVM_INSTALL_PATH`` with your own path.
|
||||||
|
|
||||||
3. Run ``REQUIRES_RTTI=1 make install`` to build and install.
|
3. Run ``REQUIRES_RTTI=1 make`` to build.
|
||||||
|
|
||||||
**Note**: With LLVM 3.2, the default build configuration has C++ RTTI
|
**Note**: With LLVM 3.2, the default build configuration has C++ RTTI
|
||||||
disabled. However, llvmpy requires RTTI.
|
disabled. However, llvmpy requires RTTI.
|
||||||
|
|
||||||
**Note**: Use ``make -j2 install`` to enable concurrent build.
|
|
||||||
Replace ``2`` with the actual number of processor you have.
|
|
||||||
|
|
||||||
4. Get llvm-py and install it::
|
4. Get llvm-py and install it::
|
||||||
|
|
||||||
$ git clone git@github.com:llvmpy/llvmpy.git
|
$ git clone git@github.com:llvmpy/llvmpy.git
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@ if sys.platform == 'darwin':
|
||||||
s = {'64bit': 'x86_64', '32bit': 'x86'}[platform.architecture()[0]]
|
s = {'64bit': 'x86_64', '32bit': 'x86'}[platform.architecture()[0]]
|
||||||
assert target.triple.startswith(s + '-apple-darwin')
|
assert target.triple.startswith(s + '-apple-darwin')
|
||||||
|
|
||||||
assert llvm.test(verbosity=2, run_isolated=False) == 0
|
assert llvm.test(verbosity=2) == 0
|
||||||
#check_intrinsics.main()
|
check_intrinsics.main()
|
||||||
|
|
||||||
print('llvm.__version__: %s' % llvm.__version__)
|
print('llvm.__version__: %s' % llvm.__version__)
|
||||||
#assert llvm.__version__ == '0.12.0'
|
#assert llvm.__version__ == '0.12.0'
|
||||||
|
|
|
||||||
|
|
@ -34,14 +34,14 @@ def _extract_ptrs(objs):
|
||||||
class LLVMException(Exception):
|
class LLVMException(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def test(verbosity=3, run_isolated=True):
|
def test(verbosity=3):
|
||||||
"""test(verbosity=1) -> TextTestResult
|
"""test(verbosity=1) -> TextTestResult
|
||||||
|
|
||||||
Run self-test, and return the number of failures + errors
|
Run self-test, and return the number of failures + errors
|
||||||
"""
|
"""
|
||||||
from llvm.tests import run
|
from llvm.tests import run
|
||||||
|
|
||||||
result = run(verbosity=verbosity, run_isolated=run_isolated)
|
result = run(verbosity=verbosity)
|
||||||
errct = len(result.failures) + len(result.errors)
|
errct = len(result.failures) + len(result.errors)
|
||||||
|
|
||||||
return errct
|
return errct
|
||||||
|
|
|
||||||
|
|
@ -452,12 +452,12 @@ class Module(llvm.Wrapper):
|
||||||
"""
|
"""
|
||||||
return str(self._ptr)
|
return str(self._ptr)
|
||||||
|
|
||||||
def __hash__(self):
|
|
||||||
return id(self._ptr)
|
|
||||||
|
|
||||||
def __eq__(self, rhs):
|
def __eq__(self, rhs):
|
||||||
|
assert isinstance(rhs, Module), type(rhs)
|
||||||
if isinstance(rhs, Module):
|
if isinstance(rhs, Module):
|
||||||
return self._ptr == rhs._ptr
|
return str(self) == str(rhs)
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
def __ne__(self, rhs):
|
def __ne__(self, rhs):
|
||||||
return not (self == rhs)
|
return not (self == rhs)
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ def deprecated(func):
|
||||||
@functools.wraps(func)
|
@functools.wraps(func)
|
||||||
def new_func(*args, **kwargs):
|
def new_func(*args, **kwargs):
|
||||||
warnings.warn_explicit(
|
warnings.warn_explicit(
|
||||||
"Call to deprecated function %s." % (func.__name__,),
|
"Call to deprecated function {}.".format(func.__name__),
|
||||||
category=DeprecationWarning,
|
category=DeprecationWarning,
|
||||||
filename=func.func_code.co_filename,
|
filename=func.func_code.co_filename,
|
||||||
lineno=func.func_code.co_firstlineno + 1
|
lineno=func.func_code.co_firstlineno + 1
|
||||||
|
|
|
||||||
24
llvm/ee.py
24
llvm/ee.py
|
|
@ -238,27 +238,3 @@ def dylib_add_symbol(name, ptr):
|
||||||
|
|
||||||
def dylib_address_of_symbol(name):
|
def dylib_address_of_symbol(name):
|
||||||
return api.llvm.sys.DynamicLibrary.SearchForAddressOfSymbol(name)
|
return api.llvm.sys.DynamicLibrary.SearchForAddressOfSymbol(name)
|
||||||
|
|
||||||
def dylib_import_library(filename):
|
|
||||||
"""Permanently import a dynamic library.
|
|
||||||
|
|
||||||
Returns a DynamicLibrary object
|
|
||||||
|
|
||||||
Raises RuntimeError
|
|
||||||
"""
|
|
||||||
return DynamicLibrary(filename)
|
|
||||||
|
|
||||||
|
|
||||||
class DynamicLibrary(object):
|
|
||||||
def __init__(self, filename):
|
|
||||||
"""
|
|
||||||
Raises RuntimeError
|
|
||||||
"""
|
|
||||||
self._ptr = api.llvm.sys.DynamicLibrary.getPermanentLibrary(
|
|
||||||
filename)
|
|
||||||
|
|
||||||
def get_address_of_symbol(self, symbol):
|
|
||||||
"""
|
|
||||||
Get the address of `symbol` (str) as integer
|
|
||||||
"""
|
|
||||||
return self._ptr.getAddressOfSymbol(symbol)
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ tests = [] # stores unittest.TestCase objects
|
||||||
isolated_tests = [] # stores modue name
|
isolated_tests = [] # stores modue name
|
||||||
|
|
||||||
|
|
||||||
def run(verbosity=1, run_isolated=True):
|
def run(verbosity=1):
|
||||||
print('llvmpy is installed in: ' + os.path.dirname(__file__))
|
print('llvmpy is installed in: ' + os.path.dirname(__file__))
|
||||||
print('llvmpy version: ' + llvm.__version__)
|
print('llvmpy version: ' + llvm.__version__)
|
||||||
print(sys.version)
|
print(sys.version)
|
||||||
|
|
@ -48,7 +48,7 @@ def run(verbosity=1, run_isolated=True):
|
||||||
testresult = runner.run(suite)
|
testresult = runner.run(suite)
|
||||||
print(hp.heap())
|
print(hp.heap())
|
||||||
|
|
||||||
if testresult and run_isolated:
|
if testresult:
|
||||||
# Run isolated tests
|
# Run isolated tests
|
||||||
print("run isolated tests".center(80, '-'))
|
print("run isolated tests".center(80, '-'))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -349,7 +349,7 @@ class CBuilder(object):
|
||||||
elif not isinstance(count, lc.Value):
|
elif not isinstance(count, lc.Value):
|
||||||
count = self.constant(types.int, count).value
|
count = self.constant(types.int, count).value
|
||||||
|
|
||||||
ptr = self.builder.alloca(ty, size=count, name=name)
|
ptr = self.builder.alloca_array(ty, count, name=name)
|
||||||
return CArray(self, ptr)
|
return CArray(self, ptr)
|
||||||
|
|
||||||
def ret(self, val=None):
|
def ret(self, val=None):
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ extern "C" {
|
||||||
|
|
||||||
#if (PY_MAJOR_VERSION >= 3)
|
#if (PY_MAJOR_VERSION >= 3)
|
||||||
|
|
||||||
PyMODINIT_FUNC
|
PyObject *
|
||||||
PyInit_%(module)s(void)
|
PyInit_%(module)s(void)
|
||||||
{
|
{
|
||||||
PyObject *module = create_python_module("%(module)s", meth_%(ns)s);
|
PyObject *module = create_python_module("%(module)s", meth_%(ns)s);
|
||||||
|
|
|
||||||
|
|
@ -186,8 +186,8 @@ PyObject* iterator_to_pylist_deref(iterator begin, iterator end,
|
||||||
{
|
{
|
||||||
PyObject* list = PyList_New(0);
|
PyObject* list = PyList_New(0);
|
||||||
for(; begin != end; ++begin) {
|
for(; begin != end; ++begin) {
|
||||||
auto_pyobject cap = pycapsule_new(&*begin, capsuleName, className);
|
PyObject* cap = pycapsule_new(&*begin, capsuleName, className);
|
||||||
PyList_Append(list, *cap);
|
PyList_Append(list, cap);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
@ -198,8 +198,8 @@ PyObject* iterator_to_pylist(iterator begin, iterator end,
|
||||||
{
|
{
|
||||||
PyObject* list = PyList_New(0);
|
PyObject* list = PyList_New(0);
|
||||||
for(; begin != end; ++begin) {
|
for(; begin != end; ++begin) {
|
||||||
auto_pyobject cap = pycapsule_new(*begin, capsuleName, className);
|
PyObject* cap = pycapsule_new(*begin, capsuleName, className);
|
||||||
PyList_Append(list, *cap);
|
PyList_Append(list, cap);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
@ -575,11 +575,11 @@ PyObject* TargetMachine_addPassesToEmitFile(
|
||||||
bool status = TM->addPassesToEmitFile(PM, fso, FTy, disableVerify);
|
bool status = TM->addPassesToEmitFile(PM, fso, FTy, disableVerify);
|
||||||
if (status) {
|
if (status) {
|
||||||
StringRef sr = rso.str();
|
StringRef sr = rso.str();
|
||||||
auto_pyobject buf = PyString_FromStringAndSize(sr.data(), sr.size());
|
PyObject* buf = PyString_FromStringAndSize(sr.data(), sr.size());
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (-1 == PyFile_WriteObject(*buf, Out, Py_PRINT_RAW)){
|
if (-1 == PyFile_WriteObject(buf, Out, Py_PRINT_RAW)){
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
Py_RETURN_TRUE;
|
Py_RETURN_TRUE;
|
||||||
|
|
@ -861,27 +861,6 @@ PyObject* DynamicLibrary_LoadLibraryPermanently(const char * Filename,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
|
||||||
PyObject* DynamicLibrary_getPermanentLibrary(const char * Filename,
|
|
||||||
PyObject* ErrMsg = 0)
|
|
||||||
{
|
|
||||||
using namespace llvm::sys;
|
|
||||||
std::string errmsg;
|
|
||||||
DynamicLibrary dylib = DynamicLibrary::getPermanentLibrary(Filename, &errmsg);
|
|
||||||
if (!dylib.isValid()) {
|
|
||||||
if (ErrMsg) {
|
|
||||||
auto_pyobject buf = PyBytes_FromString(errmsg.c_str());
|
|
||||||
if (!callwrite(ErrMsg, *buf))
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
PyErr_SetString(PyExc_RuntimeError, errmsg.c_str());
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return pycapsule_new(new DynamicLibrary(dylib),
|
|
||||||
"llvm::sys::DynamicLibrary",
|
|
||||||
"llvm::sys::DynamicLibrary");
|
|
||||||
}
|
|
||||||
|
|
||||||
class PassRegistryEnumerator : public llvm::PassRegistrationListener{
|
class PassRegistryEnumerator : public llvm::PassRegistrationListener{
|
||||||
public:
|
public:
|
||||||
PyObject* List;
|
PyObject* List;
|
||||||
|
|
@ -891,8 +870,7 @@ public:
|
||||||
inline virtual void passEnumerate(const llvm::PassInfo * pass_info){
|
inline virtual void passEnumerate(const llvm::PassInfo * pass_info){
|
||||||
PyObject* passArg = PyString_FromString(pass_info->getPassArgument());
|
PyObject* passArg = PyString_FromString(pass_info->getPassArgument());
|
||||||
PyObject* passName = PyString_FromString(pass_info->getPassName());
|
PyObject* passName = PyString_FromString(pass_info->getPassName());
|
||||||
auto_pyobject pair = Py_BuildValue("(OO)", passArg, passName);
|
PyList_Append(List, Py_BuildValue("(OO)", passArg, passName));
|
||||||
PyList_Append(List, *pair);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,12 @@
|
||||||
from binding import *
|
from binding import *
|
||||||
from .namespace import llvm
|
from .namespace import llvm
|
||||||
from .Value import Function, BasicBlock, Value
|
from .Value import Function, BasicBlock
|
||||||
from .Instruction import Instruction, TerminatorInst
|
from .Instruction import Instruction, TerminatorInst
|
||||||
from .LLVMContext import LLVMContext
|
from .LLVMContext import LLVMContext
|
||||||
from .ADT.StringRef import StringRef
|
from .ADT.StringRef import StringRef
|
||||||
|
|
||||||
@BasicBlock
|
@BasicBlock
|
||||||
class BasicBlock:
|
class BasicBlock:
|
||||||
_downcast_ = Value
|
|
||||||
Create = StaticMethod(ptr(BasicBlock), ref(LLVMContext),
|
Create = StaticMethod(ptr(BasicBlock), ref(LLVMContext),
|
||||||
cast(str, StringRef),
|
cast(str, StringRef),
|
||||||
ptr(Function),
|
ptr(Function),
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,3 @@ class DynamicLibrary:
|
||||||
cast(str, StringRef), # symbolName
|
cast(str, StringRef), # symbolName
|
||||||
cast(int, VoidPtr), # address
|
cast(int, VoidPtr), # address
|
||||||
)
|
)
|
||||||
|
|
||||||
getPermanentLibrary = CustomStaticMethod(
|
|
||||||
'DynamicLibrary_getPermanentLibrary',
|
|
||||||
PyObjectPtr,
|
|
||||||
cast(str, ConstCharPtr), # filename
|
|
||||||
PyObjectPtr, # std::string * errmsg = 0
|
|
||||||
).require_only(1)
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
# Import the llvm-py modules.
|
# Import the llvm-py modules.
|
||||||
from llvm import *
|
from llvm import *
|
||||||
from llvm.core import *
|
from llvm.core import *
|
||||||
from llvm.tests.support import TestCase
|
from llvm.test_llvmpy import TestCase
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import unittest
|
import unittest
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ from llvm.core import *
|
||||||
from llvm.passes import *
|
from llvm.passes import *
|
||||||
from llvm.ee import *
|
from llvm.ee import *
|
||||||
import llvm
|
import llvm
|
||||||
from llvm.tests.support import TestCase
|
from llvm.test_llvmpy import TestCase
|
||||||
from os.path import dirname, join as join_path
|
from os.path import dirname, join as join_path
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
from llvm.tests.support import TestCase
|
from llvm.test_llvmpy import TestCase
|
||||||
from llvm.core import *
|
from llvm.core import *
|
||||||
|
|
||||||
class TestMetaData(TestCase):
|
class TestMetaData(TestCase):
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
from llvm.core import *
|
from llvm.core import *
|
||||||
from llvm.tbaa import *
|
from llvm.tbaa import *
|
||||||
from llvm.tests.support import TestCase
|
from llvm.test_llvmpy import TestCase
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
class TestTBAABuilder(TestCase):
|
class TestTBAABuilder(TestCase):
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import unittest, sys, logging
|
||||||
|
|
||||||
from llvm import *
|
from llvm import *
|
||||||
from llvm.core import *
|
from llvm.core import *
|
||||||
from llvm.tests.support import TestCase
|
from llvm.test_llvmpy import TestCase
|
||||||
|
|
||||||
class TestModule(TestCase):
|
class TestModule(TestCase):
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import unittest
|
||||||
import llvm.ee
|
import llvm.ee
|
||||||
from llvm.core import *
|
from llvm.core import *
|
||||||
from llvm import _dwarf, debuginfo
|
from llvm import _dwarf, debuginfo
|
||||||
from llvm.tests.support import TestCase
|
from llvm.test_llvmpy import TestCase
|
||||||
|
|
||||||
class TestDebugInfo(TestCase):
|
class TestDebugInfo(TestCase):
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue