[pypy-svn] r34012 - in pypy/dist/pypy/jit/codegen/llvm: . lib test
ericvrp at codespeak.net
ericvrp at codespeak.net
Wed Nov 1 13:41:40 CET 2006
Author: ericvrp
Date: Wed Nov 1 13:41:39 2006
New Revision: 34012
Added:
pypy/dist/pypy/jit/codegen/llvm/lib/libllvmjit.cpp
- copied, changed from r34006, pypy/dist/pypy/jit/codegen/llvm/lib/llvmjit.cpp
pypy/dist/pypy/jit/codegen/llvm/lib/libllvmjit.h
- copied unchanged from r34000, pypy/dist/pypy/jit/codegen/llvm/lib/llvmjit.h
Removed:
pypy/dist/pypy/jit/codegen/llvm/lib/llvmjit.cpp
pypy/dist/pypy/jit/codegen/llvm/lib/llvmjit.h
Modified:
pypy/dist/pypy/jit/codegen/llvm/llvmjit.py
pypy/dist/pypy/jit/codegen/llvm/setup.py
pypy/dist/pypy/jit/codegen/llvm/test/test_llvmjit.py
Log:
(mwh, ericvrp) translation of the c-api lib works
Modified: pypy/dist/pypy/jit/codegen/llvm/llvmjit.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/llvm/llvmjit.py (original)
+++ pypy/dist/pypy/jit/codegen/llvm/llvmjit.py Wed Nov 1 13:41:39 2006
@@ -6,12 +6,20 @@
This file contains the ctypes specification to use the llvmjit library!
'''
+from pypy.rpython.rctypes import implementation
import ctypes
import os
-path = os.path.join(os.path.dirname(__file__), 'llvmjit_.so')
+path = os.path.join(os.path.dirname(__file__), 'libllvmjit.so')
llvmjit = ctypes.cdll.LoadLibrary(os.path.abspath(path))
+class _FuncPtr(ctypes._CFuncPtr):
+ _flags_ = ctypes._FUNCFLAG_CDECL
+ # aaarghdistutilsunixaaargh (may need something different for standalone builds...)
+ libraries = (os.path.join(os.path.dirname(path), 'llvmjit'),)
+llvmjit._FuncPtr = _FuncPtr
-def testme(n):
- return llvmjit.testme(n)
+#impls
+testme = llvmjit.testme
+testme.restype = ctypes.c_int
+testme.argtypes = [ctypes.c_int]
Modified: pypy/dist/pypy/jit/codegen/llvm/setup.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/llvm/setup.py (original)
+++ pypy/dist/pypy/jit/codegen/llvm/setup.py Wed Nov 1 13:41:39 2006
@@ -2,12 +2,14 @@
from distutils.extension import Extension
from os import popen
+#Create llvm c api library by running "python setup.py build_ext -i" here
+
cxxflags = popen('llvm-config --cxxflags').readline().split()
ldflags = popen('llvm-config --ldflags').readline().split()
libs = popen('llvm-config --libs all').readline().split()
-opts = dict(name='llvmjit_',
- sources=['lib/llvmjit.cpp'],
+opts = dict(name='libllvmjit',
+ sources=['lib/libllvmjit.cpp'],
libraries=[],
include_dirs =["include"] + [f[2:] for f in cxxflags if f.startswith('-I')],
library_dirs =[f[2:] for f in ldflags if f.startswith('-L')],
Modified: pypy/dist/pypy/jit/codegen/llvm/test/test_llvmjit.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/llvm/test/test_llvmjit.py (original)
+++ pypy/dist/pypy/jit/codegen/llvm/test/test_llvmjit.py Wed Nov 1 13:41:39 2006
@@ -1,4 +1,5 @@
import py
+from pypy.translator.c.test.test_genc import compile
try:
from pypy.jit.codegen.llvm import llvmjit
@@ -7,3 +8,10 @@
def test_testme():
assert llvmjit.testme(10) == 20
+
+def test_testme_compile():
+ def f(x):
+ return llvmjit.testme(20+x)
+ fn = compile(f, [int])
+ res = fn(1)
+ assert res == 42
More information about the Pypy-commit
mailing list