[pypy-dev] Experiments with PyPy and libgccjit
David Malcolm
dmalcolm at redhat.com
Sat Dec 13 03:13:10 CET 2014
I'm the maintainer of a new feature for the (not-yet-released) GCC 5:
libgccjit: a way to build gcc as a shared library, suitable for
generating code in-process. See:
https://gcc.gnu.org/wiki/JIT
I've been experimenting with embedding it within PyPy - my thought was
that gcc has great breadth of hardware support, so maybe PyPy could use
libgccjit as a fallback backend for targets which don't yet have their
own pypy jit backends.
I'm attaching the work I've got so far, in patch form; I apologize for
the rough work-in-progress nature of the patch. It has:
* a toy example of calling libgccjit from cffi, to build and
run code in process (see
rpython/jit/backend/libgccjit/cffi_bindings.py).
* doing the same from rffi (see
rpython/jit/backend/libgccjit/rffi_bindings.py and
rpython/jit/backend/libgccjit/test/test_rffi_bindings.py)
These seem to work: the translator builds binaries that call
into my library, which builds machine code "on the fly".
Is there a way to do this without going through the
translation step?
* the beginnings of a JIT backend:
I hack up rpython/jit/backend/detect_cpu.py to always use:
rpython/jit/backend/libgccjit/runner.py
and this merely raises an exception, albeit dumping the
operations seen in loops.
My thinking is that I ought to be able to use the rffi bindings of
libgccjit to implement the backend, and somehow turn the operations I'm
seeing into calls into my libgccjit API.
Does this sound useful, and am I on the right track here?
Is there documentation about the meaning of the various kinds of
operations within a to-be-JITted-loop?
Thanks
Dave
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pypy-libgccjit-WIP.patch
Type: text/x-patch
Size: 26961 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20141212/8fec9bc7/attachment-0001.bin>
More information about the pypy-dev
mailing list