Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ca192850ee | ||
|
|
7a77be01cc |
143 changed files with 2194 additions and 8627 deletions
37
CHANGELOG
37
CHANGELOG
|
|
@ -1,40 +1,3 @@
|
||||||
2014-04-28 0.12.5:
|
|
||||||
---------------------
|
|
||||||
* 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++
|
|
||||||
* fix unclosed file handler in avx_support
|
|
||||||
* multiple-dimension insert_value, extract_value
|
|
||||||
* various minor fixes
|
|
||||||
|
|
||||||
2013-11-11 0.12.1:
|
|
||||||
---------------------
|
|
||||||
* various bug fixes
|
|
||||||
|
|
||||||
2013-08-28 0.12.0:
|
|
||||||
---------------------
|
|
||||||
* update to LLVM 3.3 and maintain compatibility with LLVM 3.2
|
|
||||||
* add LLRT for minimal support for 64-bit divmod on 32-bit platform
|
|
||||||
* start to adopt MCJIT (not quite usable on win32)
|
|
||||||
* various bug fixes
|
|
||||||
|
|
||||||
2013-03-05 0.11.1:
|
2013-03-05 0.11.1:
|
||||||
--------------------
|
--------------------
|
||||||
* fix test when cc is not available
|
* fix test when cc is not available
|
||||||
|
|
|
||||||
|
|
@ -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,13 +30,10 @@ 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::
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
set LLVMPY_DYNLINK=0
|
|
||||||
set INCLUDE=%LIBRARY_INC%
|
|
||||||
set LIBPATH=%LIBRARY_LIB%
|
|
||||||
set LIB=%LIBRARY_LIB%
|
|
||||||
%PYTHON% setup.py install
|
|
||||||
if errorlevel 1 exit 1
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
if [[ (`uname` == Linux) && (`uname -m` != armv6l) ]]
|
|
||||||
then
|
|
||||||
export CC=gcc
|
|
||||||
#gcc44
|
|
||||||
export CXX=g++
|
|
||||||
#g++44
|
|
||||||
fi
|
|
||||||
|
|
||||||
export LLVMPY_DYNLINK=$DISTRO_BUILD
|
|
||||||
|
|
||||||
$PYTHON setup.py install
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
package:
|
|
||||||
name: llvmpy
|
|
||||||
version: 99.9.9
|
|
||||||
|
|
||||||
source:
|
|
||||||
git_url: git@github.com:llvmpy/llvmpy.git
|
|
||||||
# git_tag: 0.12.0
|
|
||||||
|
|
||||||
requirements:
|
|
||||||
build:
|
|
||||||
- llvm
|
|
||||||
- python
|
|
||||||
#- chrpath [linux]
|
|
||||||
run:
|
|
||||||
- llvm [unix]
|
|
||||||
- python
|
|
||||||
|
|
||||||
test:
|
|
||||||
imports:
|
|
||||||
- llvm
|
|
||||||
- llvmpy
|
|
||||||
- llvmpy._api
|
|
||||||
- llvmpy._capsule
|
|
||||||
- llpython
|
|
||||||
- llvm_array
|
|
||||||
- llvm_cbuilder
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
import sys
|
|
||||||
import platform
|
|
||||||
import llvm
|
|
||||||
|
|
||||||
from llvm.core import Module
|
|
||||||
from llvm.ee import EngineBuilder
|
|
||||||
from llvm.utils import check_intrinsics
|
|
||||||
|
|
||||||
m = Module.new('fjoidajfa')
|
|
||||||
eb = EngineBuilder.new(m)
|
|
||||||
target = eb.select_target()
|
|
||||||
|
|
||||||
print('target.triple=%r' % target.triple)
|
|
||||||
if sys.platform == 'darwin':
|
|
||||||
s = {'64bit': 'x86_64', '32bit': 'x86'}[platform.architecture()[0]]
|
|
||||||
assert target.triple.startswith(s + '-apple-darwin')
|
|
||||||
|
|
||||||
assert llvm.test(verbosity=2, run_isolated=False) == 0
|
|
||||||
#check_intrinsics.main()
|
|
||||||
|
|
||||||
print('llvm.__version__: %s' % llvm.__version__)
|
|
||||||
#assert llvm.__version__ == '0.12.0'
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
You can adapt this file completely to your liking, but it should at least
|
You can adapt this file completely to your liking, but it should at least
|
||||||
contain the root `toctree` directive.
|
contain the root `toctree` directive.
|
||||||
|
|
||||||
llvmpy
|
Documentation for llvmpy
|
||||||
======
|
========================
|
||||||
|
|
||||||
Contents:
|
Contents:
|
||||||
|
|
||||||
|
|
@ -22,7 +22,7 @@ Contents:
|
||||||
|
|
||||||
|
|
||||||
Indices and tables
|
Indices and tables
|
||||||
------------------
|
==================
|
||||||
|
|
||||||
* :ref:`genindex`
|
* :ref:`genindex`
|
||||||
* :ref:`modindex`
|
* :ref:`modindex`
|
||||||
|
|
|
||||||
|
|
@ -1,152 +0,0 @@
|
||||||
'''
|
|
||||||
This example shows:
|
|
||||||
1) how to use vector instructions
|
|
||||||
2) how to take advantage of LLVM loop vectorization to transform scalar
|
|
||||||
operations to vector operations
|
|
||||||
'''
|
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
import llvm.core as lc
|
|
||||||
import llvm.ee as le
|
|
||||||
import llvm.passes as lp
|
|
||||||
from ctypes import CFUNCTYPE, POINTER, c_int, c_float
|
|
||||||
|
|
||||||
def build_manual_vector():
|
|
||||||
mod = lc.Module.new('manual.vector')
|
|
||||||
intty = lc.Type.int(32)
|
|
||||||
vecty = lc.Type.vector(lc.Type.float(), 4)
|
|
||||||
aryty = lc.Type.pointer(lc.Type.float())
|
|
||||||
fnty = lc.Type.function(lc.Type.void(), [aryty, aryty, aryty, intty])
|
|
||||||
fn = mod.add_function(fnty, name='vector_add')
|
|
||||||
bbentry = fn.append_basic_block('entry')
|
|
||||||
bbloopcond = fn.append_basic_block('loop.cond')
|
|
||||||
bbloopbody = fn.append_basic_block('loop.body')
|
|
||||||
bbexit = fn.append_basic_block('exit')
|
|
||||||
builder = lc.Builder.new(bbentry)
|
|
||||||
|
|
||||||
# populate function body
|
|
||||||
in1, in2, out, size = fn.args
|
|
||||||
ZERO = lc.Constant.null(intty)
|
|
||||||
loopi_ptr = builder.alloca(intty)
|
|
||||||
builder.store(ZERO, loopi_ptr)
|
|
||||||
|
|
||||||
builder.branch(bbloopcond)
|
|
||||||
builder.position_at_end(bbloopcond)
|
|
||||||
|
|
||||||
loopi = builder.load(loopi_ptr)
|
|
||||||
loopcond = builder.icmp(lc.ICMP_ULT, loopi, size)
|
|
||||||
|
|
||||||
builder.cbranch(loopcond, bbloopbody, bbexit)
|
|
||||||
builder.position_at_end(bbloopbody)
|
|
||||||
|
|
||||||
vecaryty = lc.Type.pointer(vecty)
|
|
||||||
in1asvec = builder.bitcast(builder.gep(in1, [loopi]), vecaryty)
|
|
||||||
in2asvec = builder.bitcast(builder.gep(in2, [loopi]), vecaryty)
|
|
||||||
outasvec = builder.bitcast(builder.gep(out, [loopi]), vecaryty)
|
|
||||||
|
|
||||||
vec1 = builder.load(in1asvec)
|
|
||||||
vec2 = builder.load(in2asvec)
|
|
||||||
|
|
||||||
vecout = builder.fadd(vec1, vec2)
|
|
||||||
|
|
||||||
builder.store(vecout, outasvec)
|
|
||||||
|
|
||||||
next = builder.add(loopi, lc.Constant.int(intty, 4))
|
|
||||||
builder.store(next, loopi_ptr)
|
|
||||||
|
|
||||||
builder.branch(bbloopcond)
|
|
||||||
builder.position_at_end(bbexit)
|
|
||||||
|
|
||||||
builder.ret_void()
|
|
||||||
|
|
||||||
return mod, fn
|
|
||||||
|
|
||||||
|
|
||||||
def build_auto_vector():
|
|
||||||
mod = lc.Module.new('auto.vector')
|
|
||||||
# Loop vectorize is sensitive to the size of the index size(!?)
|
|
||||||
intty = lc.Type.int(tuple.__itemsize__ * 8)
|
|
||||||
aryty = lc.Type.pointer(lc.Type.float())
|
|
||||||
fnty = lc.Type.function(lc.Type.void(), [aryty, aryty, aryty, intty])
|
|
||||||
fn = mod.add_function(fnty, name='vector_add')
|
|
||||||
bbentry = fn.append_basic_block('entry')
|
|
||||||
bbloopcond = fn.append_basic_block('loop.cond')
|
|
||||||
bbloopbody = fn.append_basic_block('loop.body')
|
|
||||||
bbexit = fn.append_basic_block('exit')
|
|
||||||
builder = lc.Builder.new(bbentry)
|
|
||||||
|
|
||||||
# populate function body
|
|
||||||
in1, in2, out, size = fn.args
|
|
||||||
in1.add_attribute(lc.ATTR_NO_ALIAS)
|
|
||||||
in2.add_attribute(lc.ATTR_NO_ALIAS)
|
|
||||||
out.add_attribute(lc.ATTR_NO_ALIAS)
|
|
||||||
ZERO = lc.Constant.null(intty)
|
|
||||||
loopi_ptr = builder.alloca(intty)
|
|
||||||
builder.store(ZERO, loopi_ptr)
|
|
||||||
|
|
||||||
builder.branch(bbloopcond)
|
|
||||||
builder.position_at_end(bbloopcond)
|
|
||||||
|
|
||||||
loopi = builder.load(loopi_ptr)
|
|
||||||
loopcond = builder.icmp(lc.ICMP_ULT, loopi, size)
|
|
||||||
|
|
||||||
builder.cbranch(loopcond, bbloopbody, bbexit)
|
|
||||||
builder.position_at_end(bbloopbody)
|
|
||||||
|
|
||||||
in1elem = builder.load(builder.gep(in1, [loopi]))
|
|
||||||
in2elem = builder.load(builder.gep(in2, [loopi]))
|
|
||||||
|
|
||||||
outelem = builder.fadd(in1elem, in2elem)
|
|
||||||
|
|
||||||
builder.store(outelem, builder.gep(out, [loopi]))
|
|
||||||
|
|
||||||
next = builder.add(loopi, lc.Constant.int(intty, 1))
|
|
||||||
builder.store(next, loopi_ptr)
|
|
||||||
|
|
||||||
builder.branch(bbloopcond)
|
|
||||||
builder.position_at_end(bbexit)
|
|
||||||
|
|
||||||
builder.ret_void()
|
|
||||||
|
|
||||||
return mod, fn
|
|
||||||
|
|
||||||
def example(title, module_builder, opt):
|
|
||||||
print(title.center(80, '='))
|
|
||||||
mod, fn = module_builder()
|
|
||||||
|
|
||||||
eb = le.EngineBuilder.new(mod).opt(3)
|
|
||||||
if opt:
|
|
||||||
print('opt')
|
|
||||||
tm = eb.select_target()
|
|
||||||
pms = lp.build_pass_managers(mod=mod, tm=tm, opt=3, loop_vectorize=True,
|
|
||||||
fpm=False)
|
|
||||||
pms.pm.run(mod)
|
|
||||||
|
|
||||||
print(mod)
|
|
||||||
print(mod.to_native_assembly())
|
|
||||||
|
|
||||||
engine = eb.create()
|
|
||||||
ptr = engine.get_pointer_to_function(fn)
|
|
||||||
|
|
||||||
callable = CFUNCTYPE(None, POINTER(c_float), POINTER(c_float),
|
|
||||||
POINTER(c_float), c_int)(ptr)
|
|
||||||
|
|
||||||
N = 20
|
|
||||||
in1 = (c_float * N)(*range(N))
|
|
||||||
in2 = (c_float * N)(*range(N))
|
|
||||||
out = (c_float * N)()
|
|
||||||
|
|
||||||
print('in1: ', list(in1))
|
|
||||||
print('in1: ', list(in2))
|
|
||||||
|
|
||||||
callable(in1, in2, out, N)
|
|
||||||
|
|
||||||
print('out', list(out))
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
example('manual vector function', build_manual_vector, False)
|
|
||||||
example('auto vector function', build_auto_vector, True)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#! /usr/bin/env python
|
||||||
# ______________________________________________________________________
|
# ______________________________________________________________________
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
import opcode
|
import opcode
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#! /usr/bin/env python
|
||||||
# ______________________________________________________________________
|
# ______________________________________________________________________
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
import dis
|
import dis
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#! /usr/bin/env python
|
||||||
# ______________________________________________________________________
|
# ______________________________________________________________________
|
||||||
'''Defines a bytecode based LLVM translator for llpython code.
|
'''Defines a bytecode based LLVM translator for llpython code.
|
||||||
'''
|
'''
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#! /usr/bin/env python
|
||||||
# ______________________________________________________________________
|
# ______________________________________________________________________
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
import itertools
|
import itertools
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#! /usr/bin/env python
|
||||||
# ______________________________________________________________________
|
# ______________________________________________________________________
|
||||||
|
|
||||||
import ctypes
|
import ctypes
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#! /usr/bin/env python
|
||||||
# ______________________________________________________________________
|
# ______________________________________________________________________
|
||||||
|
|
||||||
import pprint
|
import pprint
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#! /usr/bin/env python
|
||||||
# ______________________________________________________________________
|
# ______________________________________________________________________
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
from . import opcode_util
|
from . import opcode_util
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#! /usr/bin/env python
|
||||||
# ______________________________________________________________________
|
# ______________________________________________________________________
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
import sys
|
import sys
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#! /usr/bin/env python
|
||||||
# ______________________________________________________________________
|
# ______________________________________________________________________
|
||||||
|
|
||||||
import dis
|
import dis
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#! /usr/bin/env python
|
||||||
# ______________________________________________________________________
|
# ______________________________________________________________________
|
||||||
|
|
||||||
from .bytecode_visitor import BytecodeFlowVisitor, BenignBytecodeVisitorMixin
|
from .bytecode_visitor import BytecodeFlowVisitor, BenignBytecodeVisitorMixin
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#! /usr/bin/env python
|
||||||
# ______________________________________________________________________
|
# ______________________________________________________________________
|
||||||
|
|
||||||
import ctypes
|
import ctypes
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue