llvmlite 0.43.0rc1__cp310-cp310-win_amd64.whl → 0.44.0rc2__cp310-cp310-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of llvmlite might be problematic. Click here for more details.
- llvmlite/__init__.py +10 -3
- llvmlite/_version.py +2 -2
- llvmlite/binding/__init__.py +19 -18
- llvmlite/binding/analysis.py +69 -69
- llvmlite/binding/common.py +34 -34
- llvmlite/binding/context.py +39 -29
- llvmlite/binding/dylib.py +45 -45
- llvmlite/binding/executionengine.py +330 -330
- llvmlite/binding/ffi.py +395 -390
- llvmlite/binding/initfini.py +73 -73
- llvmlite/binding/linker.py +20 -20
- llvmlite/binding/llvmlite.dll +0 -0
- llvmlite/binding/module.py +349 -349
- llvmlite/binding/newpassmanagers.py +357 -0
- llvmlite/binding/object_file.py +82 -82
- llvmlite/binding/options.py +17 -17
- llvmlite/binding/orcjit.py +342 -342
- llvmlite/binding/passmanagers.py +946 -939
- llvmlite/binding/targets.py +520 -450
- llvmlite/binding/transforms.py +151 -151
- llvmlite/binding/typeref.py +285 -198
- llvmlite/binding/value.py +632 -618
- llvmlite/ir/__init__.py +11 -11
- llvmlite/ir/_utils.py +80 -80
- llvmlite/ir/builder.py +1120 -1119
- llvmlite/ir/context.py +20 -20
- llvmlite/ir/instructions.py +920 -893
- llvmlite/ir/module.py +246 -246
- llvmlite/ir/transforms.py +64 -64
- llvmlite/ir/types.py +734 -614
- llvmlite/ir/values.py +1217 -1217
- llvmlite/tests/__init__.py +57 -57
- llvmlite/tests/__main__.py +3 -3
- llvmlite/tests/customize.py +407 -407
- llvmlite/tests/refprune_proto.py +329 -329
- llvmlite/tests/test_binding.py +3208 -2585
- llvmlite/tests/test_ir.py +2994 -2729
- llvmlite/tests/test_refprune.py +730 -557
- llvmlite/tests/test_valuerepr.py +60 -60
- llvmlite/utils.py +29 -29
- {llvmlite-0.43.0rc1.dist-info → llvmlite-0.44.0rc2.dist-info}/LICENSE +24 -24
- {llvmlite-0.43.0rc1.dist-info → llvmlite-0.44.0rc2.dist-info}/LICENSE.thirdparty +225 -225
- {llvmlite-0.43.0rc1.dist-info → llvmlite-0.44.0rc2.dist-info}/METADATA +7 -6
- llvmlite-0.44.0rc2.dist-info/RECORD +46 -0
- {llvmlite-0.43.0rc1.dist-info → llvmlite-0.44.0rc2.dist-info}/WHEEL +1 -1
- llvmlite-0.43.0rc1.dist-info/RECORD +0 -45
- {llvmlite-0.43.0rc1.dist-info → llvmlite-0.44.0rc2.dist-info}/top_level.txt +0 -0
llvmlite/__init__.py
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
from ._version import get_versions
|
|
2
|
-
__version__ = get_versions()['version']
|
|
3
|
-
del get_versions
|
|
1
|
+
from ._version import get_versions
|
|
2
|
+
__version__ = get_versions()['version']
|
|
3
|
+
del get_versions
|
|
4
|
+
|
|
5
|
+
# FIXME: Remove me once typed pointers are no longer supported.
|
|
6
|
+
def _opaque_pointers_enabled():
|
|
7
|
+
import os
|
|
8
|
+
return os.environ.get('LLVMLITE_ENABLE_OPAQUE_POINTERS', '0') == '1'
|
|
9
|
+
opaque_pointers_enabled = _opaque_pointers_enabled()
|
|
10
|
+
del _opaque_pointers_enabled
|
llvmlite/_version.py
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
# unpacked source archive. Distribution tarballs contain a pre-generated copy
|
|
5
5
|
# of this file.
|
|
6
6
|
|
|
7
|
-
version_version = '0.
|
|
8
|
-
version_full = '
|
|
7
|
+
version_version = '0.44.0rc2'
|
|
8
|
+
version_full = '8213a18880cfe34a54b684aea555975bfe6f110b'
|
|
9
9
|
def get_versions(default={}, verbose=False):
|
|
10
10
|
return {'version': version_version, 'full': version_full}
|
|
11
11
|
|
llvmlite/binding/__init__.py
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Things that rely on the LLVM library
|
|
3
|
-
"""
|
|
4
|
-
from .dylib import *
|
|
5
|
-
from .executionengine import *
|
|
6
|
-
from .initfini import *
|
|
7
|
-
from .linker import *
|
|
8
|
-
from .module import *
|
|
9
|
-
from .options import *
|
|
10
|
-
from .
|
|
11
|
-
from .
|
|
12
|
-
from .
|
|
13
|
-
from .
|
|
14
|
-
from .
|
|
15
|
-
from .
|
|
16
|
-
from .
|
|
17
|
-
from .
|
|
18
|
-
from .
|
|
1
|
+
"""
|
|
2
|
+
Things that rely on the LLVM library
|
|
3
|
+
"""
|
|
4
|
+
from .dylib import *
|
|
5
|
+
from .executionengine import *
|
|
6
|
+
from .initfini import *
|
|
7
|
+
from .linker import *
|
|
8
|
+
from .module import *
|
|
9
|
+
from .options import *
|
|
10
|
+
from .newpassmanagers import *
|
|
11
|
+
from .passmanagers import *
|
|
12
|
+
from .targets import *
|
|
13
|
+
from .transforms import *
|
|
14
|
+
from .value import *
|
|
15
|
+
from .typeref import *
|
|
16
|
+
from .analysis import *
|
|
17
|
+
from .object_file import *
|
|
18
|
+
from .context import *
|
|
19
|
+
from .orcjit import *
|
llvmlite/binding/analysis.py
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
"""
|
|
2
|
-
A collection of analysis utilities
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
from ctypes import POINTER, c_char_p, c_int
|
|
6
|
-
|
|
7
|
-
from llvmlite.binding import ffi
|
|
8
|
-
from llvmlite.binding.module import parse_assembly
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def get_function_cfg(func, show_inst=True):
|
|
12
|
-
"""Return a string of the control-flow graph of the function in DOT
|
|
13
|
-
format. If the input `func` is not a materialized function, the module
|
|
14
|
-
containing the function is parsed to create an actual LLVM module.
|
|
15
|
-
The `show_inst` flag controls whether the instructions of each block
|
|
16
|
-
are printed.
|
|
17
|
-
"""
|
|
18
|
-
assert func is not None
|
|
19
|
-
from llvmlite import ir
|
|
20
|
-
if isinstance(func, ir.Function):
|
|
21
|
-
mod = parse_assembly(str(func.module))
|
|
22
|
-
func = mod.get_function(func.name)
|
|
23
|
-
|
|
24
|
-
# Assume func is a materialized function
|
|
25
|
-
with ffi.OutputString() as dotstr:
|
|
26
|
-
ffi.lib.LLVMPY_WriteCFG(func, dotstr, show_inst)
|
|
27
|
-
return str(dotstr)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def view_dot_graph(graph, filename=None, view=False):
|
|
31
|
-
"""
|
|
32
|
-
View the given DOT source. If view is True, the image is rendered
|
|
33
|
-
and viewed by the default application in the system. The file path of
|
|
34
|
-
the output is returned. If view is False, a graphviz.Source object is
|
|
35
|
-
returned. If view is False and the environment is in a IPython session,
|
|
36
|
-
an IPython image object is returned and can be displayed inline in the
|
|
37
|
-
notebook.
|
|
38
|
-
|
|
39
|
-
This function requires the graphviz package.
|
|
40
|
-
|
|
41
|
-
Args
|
|
42
|
-
----
|
|
43
|
-
- graph [str]: a DOT source code
|
|
44
|
-
- filename [str]: optional. if given and view is True, this specifies
|
|
45
|
-
the file path for the rendered output to write to.
|
|
46
|
-
- view [bool]: if True, opens the rendered output file.
|
|
47
|
-
|
|
48
|
-
"""
|
|
49
|
-
# Optionally depends on graphviz package
|
|
50
|
-
import graphviz as gv
|
|
51
|
-
|
|
52
|
-
src = gv.Source(graph)
|
|
53
|
-
if view:
|
|
54
|
-
# Returns the output file path
|
|
55
|
-
return src.render(filename, view=view)
|
|
56
|
-
else:
|
|
57
|
-
# Attempts to show the graph in IPython notebook
|
|
58
|
-
try:
|
|
59
|
-
__IPYTHON__
|
|
60
|
-
except NameError:
|
|
61
|
-
return src
|
|
62
|
-
else:
|
|
63
|
-
import IPython.display as display
|
|
64
|
-
format = 'svg'
|
|
65
|
-
return display.SVG(data=src.pipe(format))
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
# Ctypes binding
|
|
69
|
-
ffi.lib.LLVMPY_WriteCFG.argtypes = [ffi.LLVMValueRef, POINTER(c_char_p), c_int]
|
|
1
|
+
"""
|
|
2
|
+
A collection of analysis utilities
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from ctypes import POINTER, c_char_p, c_int
|
|
6
|
+
|
|
7
|
+
from llvmlite.binding import ffi
|
|
8
|
+
from llvmlite.binding.module import parse_assembly
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def get_function_cfg(func, show_inst=True):
|
|
12
|
+
"""Return a string of the control-flow graph of the function in DOT
|
|
13
|
+
format. If the input `func` is not a materialized function, the module
|
|
14
|
+
containing the function is parsed to create an actual LLVM module.
|
|
15
|
+
The `show_inst` flag controls whether the instructions of each block
|
|
16
|
+
are printed.
|
|
17
|
+
"""
|
|
18
|
+
assert func is not None
|
|
19
|
+
from llvmlite import ir
|
|
20
|
+
if isinstance(func, ir.Function):
|
|
21
|
+
mod = parse_assembly(str(func.module))
|
|
22
|
+
func = mod.get_function(func.name)
|
|
23
|
+
|
|
24
|
+
# Assume func is a materialized function
|
|
25
|
+
with ffi.OutputString() as dotstr:
|
|
26
|
+
ffi.lib.LLVMPY_WriteCFG(func, dotstr, show_inst)
|
|
27
|
+
return str(dotstr)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def view_dot_graph(graph, filename=None, view=False):
|
|
31
|
+
"""
|
|
32
|
+
View the given DOT source. If view is True, the image is rendered
|
|
33
|
+
and viewed by the default application in the system. The file path of
|
|
34
|
+
the output is returned. If view is False, a graphviz.Source object is
|
|
35
|
+
returned. If view is False and the environment is in a IPython session,
|
|
36
|
+
an IPython image object is returned and can be displayed inline in the
|
|
37
|
+
notebook.
|
|
38
|
+
|
|
39
|
+
This function requires the graphviz package.
|
|
40
|
+
|
|
41
|
+
Args
|
|
42
|
+
----
|
|
43
|
+
- graph [str]: a DOT source code
|
|
44
|
+
- filename [str]: optional. if given and view is True, this specifies
|
|
45
|
+
the file path for the rendered output to write to.
|
|
46
|
+
- view [bool]: if True, opens the rendered output file.
|
|
47
|
+
|
|
48
|
+
"""
|
|
49
|
+
# Optionally depends on graphviz package
|
|
50
|
+
import graphviz as gv
|
|
51
|
+
|
|
52
|
+
src = gv.Source(graph)
|
|
53
|
+
if view:
|
|
54
|
+
# Returns the output file path
|
|
55
|
+
return src.render(filename, view=view)
|
|
56
|
+
else:
|
|
57
|
+
# Attempts to show the graph in IPython notebook
|
|
58
|
+
try:
|
|
59
|
+
__IPYTHON__
|
|
60
|
+
except NameError:
|
|
61
|
+
return src
|
|
62
|
+
else:
|
|
63
|
+
import IPython.display as display
|
|
64
|
+
format = 'svg'
|
|
65
|
+
return display.SVG(data=src.pipe(format))
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
# Ctypes binding
|
|
69
|
+
ffi.lib.LLVMPY_WriteCFG.argtypes = [ffi.LLVMValueRef, POINTER(c_char_p), c_int]
|
llvmlite/binding/common.py
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import atexit
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def _encode_string(s):
|
|
5
|
-
encoded = s.encode('utf-8')
|
|
6
|
-
return encoded
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def _decode_string(b):
|
|
10
|
-
return b.decode('utf-8')
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
_encode_string.__doc__ = """Encode a string for use by LLVM."""
|
|
14
|
-
_decode_string.__doc__ = """Decode a LLVM character (byte)string."""
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
_shutting_down = [False]
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def _at_shutdown():
|
|
21
|
-
_shutting_down[0] = True
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
atexit.register(_at_shutdown)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def _is_shutting_down(_shutting_down=_shutting_down):
|
|
28
|
-
"""
|
|
29
|
-
Whether the interpreter is currently shutting down.
|
|
30
|
-
For use in finalizers, __del__ methods, and similar; it is advised
|
|
31
|
-
to early bind this function rather than look it up when calling it,
|
|
32
|
-
since at shutdown module globals may be cleared.
|
|
33
|
-
"""
|
|
34
|
-
return _shutting_down[0]
|
|
1
|
+
import atexit
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def _encode_string(s):
|
|
5
|
+
encoded = s.encode('utf-8')
|
|
6
|
+
return encoded
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def _decode_string(b):
|
|
10
|
+
return b.decode('utf-8')
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
_encode_string.__doc__ = """Encode a string for use by LLVM."""
|
|
14
|
+
_decode_string.__doc__ = """Decode a LLVM character (byte)string."""
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
_shutting_down = [False]
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _at_shutdown():
|
|
21
|
+
_shutting_down[0] = True
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
atexit.register(_at_shutdown)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _is_shutting_down(_shutting_down=_shutting_down):
|
|
28
|
+
"""
|
|
29
|
+
Whether the interpreter is currently shutting down.
|
|
30
|
+
For use in finalizers, __del__ methods, and similar; it is advised
|
|
31
|
+
to early bind this function rather than look it up when calling it,
|
|
32
|
+
since at shutdown module globals may be cleared.
|
|
33
|
+
"""
|
|
34
|
+
return _shutting_down[0]
|
llvmlite/binding/context.py
CHANGED
|
@@ -1,29 +1,39 @@
|
|
|
1
|
-
from llvmlite.binding import ffi
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def
|
|
9
|
-
return
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
from llvmlite.binding import ffi
|
|
2
|
+
|
|
3
|
+
# FIXME: Remove me once typed pointers are no longer supported.
|
|
4
|
+
from llvmlite import opaque_pointers_enabled
|
|
5
|
+
from ctypes import c_bool
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def create_context():
|
|
9
|
+
return ContextRef(
|
|
10
|
+
ffi.lib.LLVMPY_ContextCreate(opaque_pointers_enabled))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def get_global_context():
|
|
14
|
+
return GlobalContextRef(
|
|
15
|
+
ffi.lib.LLVMPY_GetGlobalContext(opaque_pointers_enabled))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class ContextRef(ffi.ObjectRef):
|
|
19
|
+
def __init__(self, context_ptr):
|
|
20
|
+
super(ContextRef, self).__init__(context_ptr)
|
|
21
|
+
|
|
22
|
+
def _dispose(self):
|
|
23
|
+
ffi.lib.LLVMPY_ContextDispose(self)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class GlobalContextRef(ContextRef):
|
|
27
|
+
def _dispose(self):
|
|
28
|
+
pass
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# FIXME: Remove argtypes once typed pointers are no longer supported.
|
|
32
|
+
ffi.lib.LLVMPY_GetGlobalContext.argtypes = [c_bool]
|
|
33
|
+
ffi.lib.LLVMPY_GetGlobalContext.restype = ffi.LLVMContextRef
|
|
34
|
+
|
|
35
|
+
# FIXME: Remove argtypes once typed pointers are no longer supported.
|
|
36
|
+
ffi.lib.LLVMPY_ContextCreate.argtypes = [c_bool]
|
|
37
|
+
ffi.lib.LLVMPY_ContextCreate.restype = ffi.LLVMContextRef
|
|
38
|
+
|
|
39
|
+
ffi.lib.LLVMPY_ContextDispose.argtypes = [ffi.LLVMContextRef]
|
llvmlite/binding/dylib.py
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
from ctypes import c_void_p, c_char_p, c_bool, POINTER
|
|
2
|
-
|
|
3
|
-
from llvmlite.binding import ffi
|
|
4
|
-
from llvmlite.binding.common import _encode_string
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def address_of_symbol(name):
|
|
8
|
-
"""
|
|
9
|
-
Get the in-process address of symbol named *name*.
|
|
10
|
-
An integer is returned, or None if the symbol isn't found.
|
|
11
|
-
"""
|
|
12
|
-
return ffi.lib.LLVMPY_SearchAddressOfSymbol(_encode_string(name))
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def add_symbol(name, address):
|
|
16
|
-
"""
|
|
17
|
-
Register the *address* of global symbol *name*. This will make
|
|
18
|
-
it usable (e.g. callable) from LLVM-compiled functions.
|
|
19
|
-
"""
|
|
20
|
-
ffi.lib.LLVMPY_AddSymbol(_encode_string(name), c_void_p(address))
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def load_library_permanently(filename):
|
|
24
|
-
"""
|
|
25
|
-
Load an external library
|
|
26
|
-
"""
|
|
27
|
-
with ffi.OutputString() as outerr:
|
|
28
|
-
if ffi.lib.LLVMPY_LoadLibraryPermanently(
|
|
29
|
-
_encode_string(filename), outerr):
|
|
30
|
-
raise RuntimeError(str(outerr))
|
|
31
|
-
|
|
32
|
-
# ============================================================================
|
|
33
|
-
# FFI
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
ffi.lib.LLVMPY_AddSymbol.argtypes = [
|
|
37
|
-
c_char_p,
|
|
38
|
-
c_void_p,
|
|
39
|
-
]
|
|
40
|
-
|
|
41
|
-
ffi.lib.LLVMPY_SearchAddressOfSymbol.argtypes = [c_char_p]
|
|
42
|
-
ffi.lib.LLVMPY_SearchAddressOfSymbol.restype = c_void_p
|
|
43
|
-
|
|
44
|
-
ffi.lib.LLVMPY_LoadLibraryPermanently.argtypes = [c_char_p, POINTER(c_char_p)]
|
|
45
|
-
ffi.lib.LLVMPY_LoadLibraryPermanently.restype = c_bool
|
|
1
|
+
from ctypes import c_void_p, c_char_p, c_bool, POINTER
|
|
2
|
+
|
|
3
|
+
from llvmlite.binding import ffi
|
|
4
|
+
from llvmlite.binding.common import _encode_string
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def address_of_symbol(name):
|
|
8
|
+
"""
|
|
9
|
+
Get the in-process address of symbol named *name*.
|
|
10
|
+
An integer is returned, or None if the symbol isn't found.
|
|
11
|
+
"""
|
|
12
|
+
return ffi.lib.LLVMPY_SearchAddressOfSymbol(_encode_string(name))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def add_symbol(name, address):
|
|
16
|
+
"""
|
|
17
|
+
Register the *address* of global symbol *name*. This will make
|
|
18
|
+
it usable (e.g. callable) from LLVM-compiled functions.
|
|
19
|
+
"""
|
|
20
|
+
ffi.lib.LLVMPY_AddSymbol(_encode_string(name), c_void_p(address))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def load_library_permanently(filename):
|
|
24
|
+
"""
|
|
25
|
+
Load an external library
|
|
26
|
+
"""
|
|
27
|
+
with ffi.OutputString() as outerr:
|
|
28
|
+
if ffi.lib.LLVMPY_LoadLibraryPermanently(
|
|
29
|
+
_encode_string(filename), outerr):
|
|
30
|
+
raise RuntimeError(str(outerr))
|
|
31
|
+
|
|
32
|
+
# ============================================================================
|
|
33
|
+
# FFI
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
ffi.lib.LLVMPY_AddSymbol.argtypes = [
|
|
37
|
+
c_char_p,
|
|
38
|
+
c_void_p,
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
ffi.lib.LLVMPY_SearchAddressOfSymbol.argtypes = [c_char_p]
|
|
42
|
+
ffi.lib.LLVMPY_SearchAddressOfSymbol.restype = c_void_p
|
|
43
|
+
|
|
44
|
+
ffi.lib.LLVMPY_LoadLibraryPermanently.argtypes = [c_char_p, POINTER(c_char_p)]
|
|
45
|
+
ffi.lib.LLVMPY_LoadLibraryPermanently.restype = c_bool
|