llvmlite 0.43.0__cp312-cp312-win_amd64.whl → 0.44.0rc1__cp312-cp312-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 +2986 -2729
- llvmlite/tests/test_refprune.py +730 -557
- llvmlite/tests/test_valuerepr.py +60 -60
- llvmlite/utils.py +29 -29
- {llvmlite-0.43.0.dist-info → llvmlite-0.44.0rc1.dist-info}/LICENSE +24 -24
- {llvmlite-0.43.0.dist-info → llvmlite-0.44.0rc1.dist-info}/LICENSE.thirdparty +225 -225
- {llvmlite-0.43.0.dist-info → llvmlite-0.44.0rc1.dist-info}/METADATA +7 -6
- llvmlite-0.44.0rc1.dist-info/RECORD +46 -0
- {llvmlite-0.43.0.dist-info → llvmlite-0.44.0rc1.dist-info}/WHEEL +1 -1
- llvmlite-0.43.0.dist-info/RECORD +0 -45
- {llvmlite-0.43.0.dist-info → llvmlite-0.44.0rc1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
from ctypes import c_bool, c_int, c_size_t
|
|
2
|
+
from enum import IntFlag
|
|
3
|
+
from llvmlite.binding import ffi
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def create_new_module_pass_manager():
|
|
7
|
+
return ModulePassManager()
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def create_new_function_pass_manager():
|
|
11
|
+
return FunctionPassManager()
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def create_pass_builder(tm, pto):
|
|
15
|
+
return PassBuilder(tm, pto)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def create_pipeline_tuning_options(speed_level=2, size_level=0):
|
|
19
|
+
return PipelineTuningOptions(speed_level, size_level)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class RefPruneSubpasses(IntFlag):
|
|
23
|
+
PER_BB = 0b0001 # noqa: E221
|
|
24
|
+
DIAMOND = 0b0010 # noqa: E221
|
|
25
|
+
FANOUT = 0b0100 # noqa: E221
|
|
26
|
+
FANOUT_RAISE = 0b1000
|
|
27
|
+
ALL = PER_BB | DIAMOND | FANOUT | FANOUT_RAISE
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class ModulePassManager(ffi.ObjectRef):
|
|
31
|
+
|
|
32
|
+
def __init__(self, ptr=None):
|
|
33
|
+
if ptr is None:
|
|
34
|
+
ptr = ffi.lib.LLVMPY_CreateNewModulePassManager()
|
|
35
|
+
super().__init__(ptr)
|
|
36
|
+
|
|
37
|
+
def run(self, module, pb):
|
|
38
|
+
ffi.lib.LLVMPY_RunNewModulePassManager(self, module, pb)
|
|
39
|
+
|
|
40
|
+
def add_verifier(self):
|
|
41
|
+
ffi.lib.LLVMPY_AddVerifierPass(self)
|
|
42
|
+
|
|
43
|
+
def add_aa_eval_pass(self):
|
|
44
|
+
ffi.lib.LLVMPY_AddAAEvalPass_module(self)
|
|
45
|
+
|
|
46
|
+
def add_simplify_cfg_pass(self):
|
|
47
|
+
ffi.lib.LLVMPY_AddSimplifyCFGPass_module(self)
|
|
48
|
+
|
|
49
|
+
def add_loop_unroll_pass(self):
|
|
50
|
+
ffi.lib.LLVMPY_AddLoopUnrollPass_module(self)
|
|
51
|
+
|
|
52
|
+
def add_loop_rotate_pass(self):
|
|
53
|
+
ffi.lib.LLVMPY_AddLoopRotatePass_module(self)
|
|
54
|
+
|
|
55
|
+
def add_instruction_combine_pass(self):
|
|
56
|
+
ffi.lib.LLVMPY_AddInstructionCombinePass_module(self)
|
|
57
|
+
|
|
58
|
+
def add_jump_threading_pass(self, threshold=-1):
|
|
59
|
+
ffi.lib.LLVMPY_AddJumpThreadingPass_module(self, threshold)
|
|
60
|
+
|
|
61
|
+
def _dispose(self):
|
|
62
|
+
ffi.lib.LLVMPY_DisposeNewModulePassManger(self)
|
|
63
|
+
|
|
64
|
+
# Non-standard LLVM passes
|
|
65
|
+
def add_refprune_pass(self, subpasses_flags=RefPruneSubpasses.ALL,
|
|
66
|
+
subgraph_limit=1000):
|
|
67
|
+
"""Add Numba specific Reference count pruning pass.
|
|
68
|
+
|
|
69
|
+
Parameters
|
|
70
|
+
----------
|
|
71
|
+
subpasses_flags : RefPruneSubpasses
|
|
72
|
+
A bitmask to control the subpasses to be enabled.
|
|
73
|
+
subgraph_limit : int
|
|
74
|
+
Limit the fanout pruners to working on a subgraph no bigger than
|
|
75
|
+
this number of basic-blocks to avoid spending too much time in very
|
|
76
|
+
large graphs. Default is 1000. Subject to change in future
|
|
77
|
+
versions.
|
|
78
|
+
"""
|
|
79
|
+
iflags = RefPruneSubpasses(subpasses_flags)
|
|
80
|
+
ffi.lib.LLVMPY_AddRefPrunePass_module(self, iflags, subgraph_limit)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class FunctionPassManager(ffi.ObjectRef):
|
|
84
|
+
|
|
85
|
+
def __init__(self, ptr=None):
|
|
86
|
+
if ptr is None:
|
|
87
|
+
ptr = ffi.lib.LLVMPY_CreateNewFunctionPassManager()
|
|
88
|
+
super().__init__(ptr)
|
|
89
|
+
|
|
90
|
+
def run(self, fun, pb):
|
|
91
|
+
ffi.lib.LLVMPY_RunNewFunctionPassManager(self, fun, pb)
|
|
92
|
+
|
|
93
|
+
def add_aa_eval_pass(self):
|
|
94
|
+
ffi.lib.LLVMPY_AddAAEvalPass_function(self)
|
|
95
|
+
|
|
96
|
+
def add_simplify_cfg_pass(self):
|
|
97
|
+
ffi.lib.LLVMPY_AddSimplifyCFGPass_function(self)
|
|
98
|
+
|
|
99
|
+
def add_loop_unroll_pass(self):
|
|
100
|
+
ffi.lib.LLVMPY_AddLoopUnrollPass_function(self)
|
|
101
|
+
|
|
102
|
+
def add_loop_rotate_pass(self):
|
|
103
|
+
ffi.lib.LLVMPY_AddLoopRotatePass_function(self)
|
|
104
|
+
|
|
105
|
+
def add_instruction_combine_pass(self):
|
|
106
|
+
ffi.lib.LLVMPY_AddInstructionCombinePass_function(self)
|
|
107
|
+
|
|
108
|
+
def add_jump_threading_pass(self, threshold=-1):
|
|
109
|
+
ffi.lib.LLVMPY_AddJumpThreadingPass_function(self, threshold)
|
|
110
|
+
|
|
111
|
+
def _dispose(self):
|
|
112
|
+
ffi.lib.LLVMPY_DisposeNewFunctionPassManger(self)
|
|
113
|
+
|
|
114
|
+
# Non-standard LLVM passes
|
|
115
|
+
def add_refprune_pass(self, subpasses_flags=RefPruneSubpasses.ALL,
|
|
116
|
+
subgraph_limit=1000):
|
|
117
|
+
"""Add Numba specific Reference count pruning pass.
|
|
118
|
+
|
|
119
|
+
Parameters
|
|
120
|
+
----------
|
|
121
|
+
subpasses_flags : RefPruneSubpasses
|
|
122
|
+
A bitmask to control the subpasses to be enabled.
|
|
123
|
+
subgraph_limit : int
|
|
124
|
+
Limit the fanout pruners to working on a subgraph no bigger than
|
|
125
|
+
this number of basic-blocks to avoid spending too much time in very
|
|
126
|
+
large graphs. Default is 1000. Subject to change in future
|
|
127
|
+
versions.
|
|
128
|
+
"""
|
|
129
|
+
iflags = RefPruneSubpasses(subpasses_flags)
|
|
130
|
+
ffi.lib.LLVMPY_AddRefPrunePass_function(self, iflags, subgraph_limit)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
class PipelineTuningOptions(ffi.ObjectRef):
|
|
134
|
+
|
|
135
|
+
def __init__(self, speed_level=2, size_level=0):
|
|
136
|
+
self._speed_level = None
|
|
137
|
+
self._size_level = None
|
|
138
|
+
self.speed_level = speed_level
|
|
139
|
+
self.size_level = size_level
|
|
140
|
+
super().__init__(ffi.lib.LLVMPY_CreatePipelineTuningOptions())
|
|
141
|
+
|
|
142
|
+
@property
|
|
143
|
+
def speed_level(self):
|
|
144
|
+
return self._speed_level
|
|
145
|
+
|
|
146
|
+
@speed_level.setter
|
|
147
|
+
def speed_level(self, value):
|
|
148
|
+
if not 0 <= value <= 3:
|
|
149
|
+
raise ValueError(
|
|
150
|
+
"Optimization level for speed should be 0, 1, 2, or 3")
|
|
151
|
+
self._speed_level = value
|
|
152
|
+
|
|
153
|
+
@property
|
|
154
|
+
def size_level(self):
|
|
155
|
+
return self._size_level
|
|
156
|
+
|
|
157
|
+
@size_level.setter
|
|
158
|
+
def size_level(self, value):
|
|
159
|
+
if not 0 <= value <= 2:
|
|
160
|
+
raise ValueError("Optimization level for size should be 0, 1, or 2")
|
|
161
|
+
if value != 0 and self.speed_level != 2:
|
|
162
|
+
raise ValueError(
|
|
163
|
+
"Optimization for size should be encoded with speed level == 2")
|
|
164
|
+
self._size_level = value
|
|
165
|
+
|
|
166
|
+
@property
|
|
167
|
+
def loop_interleaving(self):
|
|
168
|
+
return ffi.lib.LLVMPY_PTOGetLoopInterleaving(self)
|
|
169
|
+
|
|
170
|
+
@loop_interleaving.setter
|
|
171
|
+
def loop_interleaving(self, value):
|
|
172
|
+
ffi.lib.LLVMPY_PTOSetLoopInterleaving(self, value)
|
|
173
|
+
|
|
174
|
+
@property
|
|
175
|
+
def loop_vectorization(self):
|
|
176
|
+
return ffi.lib.LLVMPY_PTOGetLoopVectorization(self)
|
|
177
|
+
|
|
178
|
+
@loop_vectorization.setter
|
|
179
|
+
def loop_vectorization(self, value):
|
|
180
|
+
ffi.lib.LLVMPY_PTOSetLoopVectorization(self, value)
|
|
181
|
+
|
|
182
|
+
@property
|
|
183
|
+
def slp_vectorization(self):
|
|
184
|
+
return ffi.lib.LLVMPY_PTOGetSLPVectorization(self)
|
|
185
|
+
|
|
186
|
+
@slp_vectorization.setter
|
|
187
|
+
def slp_vectorization(self, value):
|
|
188
|
+
ffi.lib.LLVMPY_PTOSetSLPVectorization(self, value)
|
|
189
|
+
|
|
190
|
+
@property
|
|
191
|
+
def loop_unrolling(self):
|
|
192
|
+
return ffi.lib.LLVMPY_PTOGetLoopUnrolling(self)
|
|
193
|
+
|
|
194
|
+
@loop_unrolling.setter
|
|
195
|
+
def loop_unrolling(self, value):
|
|
196
|
+
ffi.lib.LLVMPY_PTOSetLoopUnrolling(self, value)
|
|
197
|
+
|
|
198
|
+
# // FIXME: Available from llvm16
|
|
199
|
+
# @property
|
|
200
|
+
# def inlining_threshold(self):
|
|
201
|
+
# return ffi.lib.LLVMPY_PTOGetInlinerThreshold(self)
|
|
202
|
+
|
|
203
|
+
# @inlining_threshold.setter
|
|
204
|
+
# def inlining_threshold(self, value):
|
|
205
|
+
# ffi.lib.LLVMPY_PTOSetInlinerThreshold(self, value)
|
|
206
|
+
|
|
207
|
+
def _dispose(self):
|
|
208
|
+
ffi.lib.LLVMPY_DisposePipelineTuningOptions(self)
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
class PassBuilder(ffi.ObjectRef):
|
|
212
|
+
|
|
213
|
+
def __init__(self, tm, pto):
|
|
214
|
+
super().__init__(ffi.lib.LLVMPY_CreatePassBuilder(tm, pto))
|
|
215
|
+
self._pto = pto
|
|
216
|
+
self._tm = tm
|
|
217
|
+
|
|
218
|
+
def getModulePassManager(self):
|
|
219
|
+
return ModulePassManager(
|
|
220
|
+
ffi.lib.LLVMPY_buildPerModuleDefaultPipeline(
|
|
221
|
+
self, self._pto.speed_level, self._pto.size_level)
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
def getFunctionPassManager(self):
|
|
225
|
+
return FunctionPassManager(
|
|
226
|
+
ffi.lib.LLVMPY_buildFunctionSimplificationPipeline(
|
|
227
|
+
self, self._pto.speed_level, self._pto.size_level)
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
def _dispose(self):
|
|
231
|
+
ffi.lib.LLVMPY_DisposePassBuilder(self)
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
# ============================================================================
|
|
235
|
+
# FFI
|
|
236
|
+
|
|
237
|
+
# ModulePassManager
|
|
238
|
+
|
|
239
|
+
ffi.lib.LLVMPY_CreateNewModulePassManager.restype = ffi.LLVMModulePassManagerRef
|
|
240
|
+
|
|
241
|
+
ffi.lib.LLVMPY_RunNewModulePassManager.argtypes = [
|
|
242
|
+
ffi.LLVMModulePassManagerRef, ffi.LLVMModuleRef,
|
|
243
|
+
ffi.LLVMPassBuilderRef,]
|
|
244
|
+
|
|
245
|
+
ffi.lib.LLVMPY_AddVerifierPass.argtypes = [ffi.LLVMModulePassManagerRef,]
|
|
246
|
+
ffi.lib.LLVMPY_AddAAEvalPass_module.argtypes = [ffi.LLVMModulePassManagerRef,]
|
|
247
|
+
ffi.lib.LLVMPY_AddSimplifyCFGPass_module.argtypes = [
|
|
248
|
+
ffi.LLVMModulePassManagerRef,]
|
|
249
|
+
|
|
250
|
+
ffi.lib.LLVMPY_AddLoopUnrollPass_module.argtypes = [
|
|
251
|
+
ffi.LLVMModulePassManagerRef,]
|
|
252
|
+
|
|
253
|
+
ffi.lib.LLVMPY_AddLoopRotatePass_module.argtypes = [
|
|
254
|
+
ffi.LLVMModulePassManagerRef,]
|
|
255
|
+
|
|
256
|
+
ffi.lib.LLVMPY_AddInstructionCombinePass_module.argtypes = [
|
|
257
|
+
ffi.LLVMModulePassManagerRef,]
|
|
258
|
+
|
|
259
|
+
ffi.lib.LLVMPY_AddJumpThreadingPass_module.argtypes = [
|
|
260
|
+
ffi.LLVMModulePassManagerRef,]
|
|
261
|
+
|
|
262
|
+
ffi.lib.LLVMPY_DisposeNewModulePassManger.argtypes = [
|
|
263
|
+
ffi.LLVMModulePassManagerRef,]
|
|
264
|
+
|
|
265
|
+
ffi.lib.LLVMPY_AddRefPrunePass_module.argtypes = [
|
|
266
|
+
ffi.LLVMModulePassManagerRef, c_int, c_size_t,
|
|
267
|
+
]
|
|
268
|
+
|
|
269
|
+
# FunctionPassManager
|
|
270
|
+
|
|
271
|
+
ffi.lib.LLVMPY_CreateNewFunctionPassManager.restype = \
|
|
272
|
+
ffi.LLVMFunctionPassManagerRef
|
|
273
|
+
|
|
274
|
+
ffi.lib.LLVMPY_RunNewFunctionPassManager.argtypes = [
|
|
275
|
+
ffi.LLVMFunctionPassManagerRef, ffi.LLVMValueRef,
|
|
276
|
+
ffi.LLVMPassBuilderRef,]
|
|
277
|
+
|
|
278
|
+
ffi.lib.LLVMPY_AddAAEvalPass_function.argtypes = [
|
|
279
|
+
ffi.LLVMFunctionPassManagerRef,]
|
|
280
|
+
|
|
281
|
+
ffi.lib.LLVMPY_AddSimplifyCFGPass_function.argtypes = [
|
|
282
|
+
ffi.LLVMFunctionPassManagerRef,]
|
|
283
|
+
|
|
284
|
+
ffi.lib.LLVMPY_AddLoopUnrollPass_function.argtypes = [
|
|
285
|
+
ffi.LLVMFunctionPassManagerRef,]
|
|
286
|
+
|
|
287
|
+
ffi.lib.LLVMPY_AddLoopRotatePass_function.argtypes = [
|
|
288
|
+
ffi.LLVMFunctionPassManagerRef,]
|
|
289
|
+
|
|
290
|
+
ffi.lib.LLVMPY_AddInstructionCombinePass_function.argtypes = [
|
|
291
|
+
ffi.LLVMFunctionPassManagerRef,]
|
|
292
|
+
|
|
293
|
+
ffi.lib.LLVMPY_AddJumpThreadingPass_function.argtypes = [
|
|
294
|
+
ffi.LLVMFunctionPassManagerRef, c_int,]
|
|
295
|
+
|
|
296
|
+
ffi.lib.LLVMPY_DisposeNewFunctionPassManger.argtypes = [
|
|
297
|
+
ffi.LLVMFunctionPassManagerRef,]
|
|
298
|
+
|
|
299
|
+
ffi.lib.LLVMPY_AddRefPrunePass_function.argtypes = [
|
|
300
|
+
ffi.LLVMFunctionPassManagerRef, c_int, c_size_t,
|
|
301
|
+
]
|
|
302
|
+
|
|
303
|
+
# PipelineTuningOptions
|
|
304
|
+
|
|
305
|
+
ffi.lib.LLVMPY_CreatePipelineTuningOptions.restype = \
|
|
306
|
+
ffi.LLVMPipelineTuningOptionsRef
|
|
307
|
+
|
|
308
|
+
ffi.lib.LLVMPY_PTOGetLoopInterleaving.restype = c_bool
|
|
309
|
+
ffi.lib.LLVMPY_PTOGetLoopInterleaving.argtypes = [
|
|
310
|
+
ffi.LLVMPipelineTuningOptionsRef,]
|
|
311
|
+
|
|
312
|
+
ffi.lib.LLVMPY_PTOSetLoopInterleaving.argtypes = [
|
|
313
|
+
ffi.LLVMPipelineTuningOptionsRef, c_bool]
|
|
314
|
+
|
|
315
|
+
ffi.lib.LLVMPY_PTOGetLoopVectorization.restype = c_bool
|
|
316
|
+
ffi.lib.LLVMPY_PTOGetLoopVectorization.argtypes = [
|
|
317
|
+
ffi.LLVMPipelineTuningOptionsRef,]
|
|
318
|
+
|
|
319
|
+
ffi.lib.LLVMPY_PTOSetLoopVectorization.argtypes = [
|
|
320
|
+
ffi.LLVMPipelineTuningOptionsRef, c_bool]
|
|
321
|
+
|
|
322
|
+
ffi.lib.LLVMPY_PTOGetSLPVectorization.restype = c_bool
|
|
323
|
+
ffi.lib.LLVMPY_PTOGetSLPVectorization.argtypes = [
|
|
324
|
+
ffi.LLVMPipelineTuningOptionsRef,]
|
|
325
|
+
|
|
326
|
+
ffi.lib.LLVMPY_PTOSetSLPVectorization.argtypes = [
|
|
327
|
+
ffi.LLVMPipelineTuningOptionsRef, c_bool]
|
|
328
|
+
|
|
329
|
+
ffi.lib.LLVMPY_PTOGetLoopUnrolling.restype = c_bool
|
|
330
|
+
ffi.lib.LLVMPY_PTOGetLoopUnrolling.argtypes = [
|
|
331
|
+
ffi.LLVMPipelineTuningOptionsRef,]
|
|
332
|
+
|
|
333
|
+
ffi.lib.LLVMPY_PTOSetLoopUnrolling.argtypes = [
|
|
334
|
+
ffi.LLVMPipelineTuningOptionsRef, c_bool]
|
|
335
|
+
|
|
336
|
+
ffi.lib.LLVMPY_DisposePipelineTuningOptions.argtypes = \
|
|
337
|
+
[ffi.LLVMPipelineTuningOptionsRef,]
|
|
338
|
+
|
|
339
|
+
# PassBuilder
|
|
340
|
+
|
|
341
|
+
ffi.lib.LLVMPY_CreatePassBuilder.restype = ffi.LLVMPassBuilderRef
|
|
342
|
+
ffi.lib.LLVMPY_CreatePassBuilder.argtypes = [ffi.LLVMTargetMachineRef,
|
|
343
|
+
ffi.LLVMPipelineTuningOptionsRef,]
|
|
344
|
+
|
|
345
|
+
ffi.lib.LLVMPY_DisposePassBuilder.argtypes = [ffi.LLVMPassBuilderRef,]
|
|
346
|
+
|
|
347
|
+
# Pipeline builders
|
|
348
|
+
|
|
349
|
+
ffi.lib.LLVMPY_buildPerModuleDefaultPipeline.restype = \
|
|
350
|
+
ffi.LLVMModulePassManagerRef
|
|
351
|
+
ffi.lib.LLVMPY_buildPerModuleDefaultPipeline.argtypes = [
|
|
352
|
+
ffi.LLVMPassBuilderRef, c_int, c_int]
|
|
353
|
+
|
|
354
|
+
ffi.lib.LLVMPY_buildFunctionSimplificationPipeline.restype = \
|
|
355
|
+
ffi.LLVMFunctionPassManagerRef
|
|
356
|
+
ffi.lib.LLVMPY_buildFunctionSimplificationPipeline.argtypes = [
|
|
357
|
+
ffi.LLVMPassBuilderRef, c_int, c_int]
|
llvmlite/binding/object_file.py
CHANGED
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
from llvmlite.binding import ffi
|
|
2
|
-
from ctypes import (c_bool, c_char_p, c_char, c_size_t, string_at, c_uint64,
|
|
3
|
-
POINTER)
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class SectionIteratorRef(ffi.ObjectRef):
|
|
7
|
-
def name(self):
|
|
8
|
-
return ffi.lib.LLVMPY_GetSectionName(self)
|
|
9
|
-
|
|
10
|
-
def is_text(self):
|
|
11
|
-
return ffi.lib.LLVMPY_IsSectionText(self)
|
|
12
|
-
|
|
13
|
-
def size(self):
|
|
14
|
-
return ffi.lib.LLVMPY_GetSectionSize(self)
|
|
15
|
-
|
|
16
|
-
def address(self):
|
|
17
|
-
return ffi.lib.LLVMPY_GetSectionAddress(self)
|
|
18
|
-
|
|
19
|
-
def data(self):
|
|
20
|
-
return string_at(ffi.lib.LLVMPY_GetSectionContents(self), self.size())
|
|
21
|
-
|
|
22
|
-
def is_end(self, object_file):
|
|
23
|
-
return ffi.lib.LLVMPY_IsSectionIteratorAtEnd(object_file, self)
|
|
24
|
-
|
|
25
|
-
def next(self):
|
|
26
|
-
ffi.lib.LLVMPY_MoveToNextSection(self)
|
|
27
|
-
|
|
28
|
-
def _dispose(self):
|
|
29
|
-
ffi.lib.LLVMPY_DisposeSectionIterator(self)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
class ObjectFileRef(ffi.ObjectRef):
|
|
33
|
-
@classmethod
|
|
34
|
-
def from_data(cls, data):
|
|
35
|
-
return cls(ffi.lib.LLVMPY_CreateObjectFile(data, len(data)))
|
|
36
|
-
|
|
37
|
-
@classmethod
|
|
38
|
-
def from_path(cls, path):
|
|
39
|
-
with open(path, 'rb') as f:
|
|
40
|
-
data = f.read()
|
|
41
|
-
return cls(ffi.lib.LLVMPY_CreateObjectFile(data, len(data)))
|
|
42
|
-
|
|
43
|
-
def sections(self):
|
|
44
|
-
it = SectionIteratorRef(ffi.lib.LLVMPY_GetSections(self))
|
|
45
|
-
while not it.is_end(self):
|
|
46
|
-
yield it
|
|
47
|
-
it.next()
|
|
48
|
-
|
|
49
|
-
def _dispose(self):
|
|
50
|
-
ffi.lib.LLVMPY_DisposeObjectFile(self)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
ffi.lib.LLVMPY_CreateObjectFile.argtypes = [c_char_p, c_size_t]
|
|
54
|
-
ffi.lib.LLVMPY_CreateObjectFile.restype = ffi.LLVMObjectFileRef
|
|
55
|
-
|
|
56
|
-
ffi.lib.LLVMPY_DisposeObjectFile.argtypes = [ffi.LLVMObjectFileRef]
|
|
57
|
-
|
|
58
|
-
ffi.lib.LLVMPY_GetSections.argtypes = [ffi.LLVMObjectFileRef]
|
|
59
|
-
ffi.lib.LLVMPY_GetSections.restype = ffi.LLVMSectionIteratorRef
|
|
60
|
-
|
|
61
|
-
ffi.lib.LLVMPY_DisposeSectionIterator.argtypes = [ffi.LLVMSectionIteratorRef]
|
|
62
|
-
|
|
63
|
-
ffi.lib.LLVMPY_MoveToNextSection.argtypes = [ffi.LLVMSectionIteratorRef]
|
|
64
|
-
|
|
65
|
-
ffi.lib.LLVMPY_IsSectionIteratorAtEnd.argtypes = [
|
|
66
|
-
ffi.LLVMObjectFileRef, ffi.LLVMSectionIteratorRef]
|
|
67
|
-
ffi.lib.LLVMPY_IsSectionIteratorAtEnd.restype = c_bool
|
|
68
|
-
|
|
69
|
-
ffi.lib.LLVMPY_GetSectionName.argtypes = [ffi.LLVMSectionIteratorRef]
|
|
70
|
-
ffi.lib.LLVMPY_GetSectionName.restype = c_char_p
|
|
71
|
-
|
|
72
|
-
ffi.lib.LLVMPY_GetSectionSize.argtypes = [ffi.LLVMSectionIteratorRef]
|
|
73
|
-
ffi.lib.LLVMPY_GetSectionSize.restype = c_uint64
|
|
74
|
-
|
|
75
|
-
ffi.lib.LLVMPY_GetSectionAddress.argtypes = [ffi.LLVMSectionIteratorRef]
|
|
76
|
-
ffi.lib.LLVMPY_GetSectionAddress.restype = c_uint64
|
|
77
|
-
|
|
78
|
-
ffi.lib.LLVMPY_GetSectionContents.argtypes = [ffi.LLVMSectionIteratorRef]
|
|
79
|
-
ffi.lib.LLVMPY_GetSectionContents.restype = POINTER(c_char)
|
|
80
|
-
|
|
81
|
-
ffi.lib.LLVMPY_IsSectionText.argtypes = [ffi.LLVMSectionIteratorRef]
|
|
82
|
-
ffi.lib.LLVMPY_IsSectionText.restype = c_bool
|
|
1
|
+
from llvmlite.binding import ffi
|
|
2
|
+
from ctypes import (c_bool, c_char_p, c_char, c_size_t, string_at, c_uint64,
|
|
3
|
+
POINTER)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class SectionIteratorRef(ffi.ObjectRef):
|
|
7
|
+
def name(self):
|
|
8
|
+
return ffi.lib.LLVMPY_GetSectionName(self)
|
|
9
|
+
|
|
10
|
+
def is_text(self):
|
|
11
|
+
return ffi.lib.LLVMPY_IsSectionText(self)
|
|
12
|
+
|
|
13
|
+
def size(self):
|
|
14
|
+
return ffi.lib.LLVMPY_GetSectionSize(self)
|
|
15
|
+
|
|
16
|
+
def address(self):
|
|
17
|
+
return ffi.lib.LLVMPY_GetSectionAddress(self)
|
|
18
|
+
|
|
19
|
+
def data(self):
|
|
20
|
+
return string_at(ffi.lib.LLVMPY_GetSectionContents(self), self.size())
|
|
21
|
+
|
|
22
|
+
def is_end(self, object_file):
|
|
23
|
+
return ffi.lib.LLVMPY_IsSectionIteratorAtEnd(object_file, self)
|
|
24
|
+
|
|
25
|
+
def next(self):
|
|
26
|
+
ffi.lib.LLVMPY_MoveToNextSection(self)
|
|
27
|
+
|
|
28
|
+
def _dispose(self):
|
|
29
|
+
ffi.lib.LLVMPY_DisposeSectionIterator(self)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class ObjectFileRef(ffi.ObjectRef):
|
|
33
|
+
@classmethod
|
|
34
|
+
def from_data(cls, data):
|
|
35
|
+
return cls(ffi.lib.LLVMPY_CreateObjectFile(data, len(data)))
|
|
36
|
+
|
|
37
|
+
@classmethod
|
|
38
|
+
def from_path(cls, path):
|
|
39
|
+
with open(path, 'rb') as f:
|
|
40
|
+
data = f.read()
|
|
41
|
+
return cls(ffi.lib.LLVMPY_CreateObjectFile(data, len(data)))
|
|
42
|
+
|
|
43
|
+
def sections(self):
|
|
44
|
+
it = SectionIteratorRef(ffi.lib.LLVMPY_GetSections(self))
|
|
45
|
+
while not it.is_end(self):
|
|
46
|
+
yield it
|
|
47
|
+
it.next()
|
|
48
|
+
|
|
49
|
+
def _dispose(self):
|
|
50
|
+
ffi.lib.LLVMPY_DisposeObjectFile(self)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
ffi.lib.LLVMPY_CreateObjectFile.argtypes = [c_char_p, c_size_t]
|
|
54
|
+
ffi.lib.LLVMPY_CreateObjectFile.restype = ffi.LLVMObjectFileRef
|
|
55
|
+
|
|
56
|
+
ffi.lib.LLVMPY_DisposeObjectFile.argtypes = [ffi.LLVMObjectFileRef]
|
|
57
|
+
|
|
58
|
+
ffi.lib.LLVMPY_GetSections.argtypes = [ffi.LLVMObjectFileRef]
|
|
59
|
+
ffi.lib.LLVMPY_GetSections.restype = ffi.LLVMSectionIteratorRef
|
|
60
|
+
|
|
61
|
+
ffi.lib.LLVMPY_DisposeSectionIterator.argtypes = [ffi.LLVMSectionIteratorRef]
|
|
62
|
+
|
|
63
|
+
ffi.lib.LLVMPY_MoveToNextSection.argtypes = [ffi.LLVMSectionIteratorRef]
|
|
64
|
+
|
|
65
|
+
ffi.lib.LLVMPY_IsSectionIteratorAtEnd.argtypes = [
|
|
66
|
+
ffi.LLVMObjectFileRef, ffi.LLVMSectionIteratorRef]
|
|
67
|
+
ffi.lib.LLVMPY_IsSectionIteratorAtEnd.restype = c_bool
|
|
68
|
+
|
|
69
|
+
ffi.lib.LLVMPY_GetSectionName.argtypes = [ffi.LLVMSectionIteratorRef]
|
|
70
|
+
ffi.lib.LLVMPY_GetSectionName.restype = c_char_p
|
|
71
|
+
|
|
72
|
+
ffi.lib.LLVMPY_GetSectionSize.argtypes = [ffi.LLVMSectionIteratorRef]
|
|
73
|
+
ffi.lib.LLVMPY_GetSectionSize.restype = c_uint64
|
|
74
|
+
|
|
75
|
+
ffi.lib.LLVMPY_GetSectionAddress.argtypes = [ffi.LLVMSectionIteratorRef]
|
|
76
|
+
ffi.lib.LLVMPY_GetSectionAddress.restype = c_uint64
|
|
77
|
+
|
|
78
|
+
ffi.lib.LLVMPY_GetSectionContents.argtypes = [ffi.LLVMSectionIteratorRef]
|
|
79
|
+
ffi.lib.LLVMPY_GetSectionContents.restype = POINTER(c_char)
|
|
80
|
+
|
|
81
|
+
ffi.lib.LLVMPY_IsSectionText.argtypes = [ffi.LLVMSectionIteratorRef]
|
|
82
|
+
ffi.lib.LLVMPY_IsSectionText.restype = c_bool
|
llvmlite/binding/options.py
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
from llvmlite.binding import ffi
|
|
2
|
-
from llvmlite.binding.common import _encode_string
|
|
3
|
-
from ctypes import c_char_p
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def set_option(name, option):
|
|
7
|
-
"""
|
|
8
|
-
Set the given LLVM "command-line" option.
|
|
9
|
-
|
|
10
|
-
For example set_option("test", "-debug-pass=Structure") would display
|
|
11
|
-
all optimization passes when generating code.
|
|
12
|
-
"""
|
|
13
|
-
ffi.lib.LLVMPY_SetCommandLine(_encode_string(name),
|
|
14
|
-
_encode_string(option))
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
ffi.lib.LLVMPY_SetCommandLine.argtypes = [c_char_p, c_char_p]
|
|
1
|
+
from llvmlite.binding import ffi
|
|
2
|
+
from llvmlite.binding.common import _encode_string
|
|
3
|
+
from ctypes import c_char_p
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def set_option(name, option):
|
|
7
|
+
"""
|
|
8
|
+
Set the given LLVM "command-line" option.
|
|
9
|
+
|
|
10
|
+
For example set_option("test", "-debug-pass=Structure") would display
|
|
11
|
+
all optimization passes when generating code.
|
|
12
|
+
"""
|
|
13
|
+
ffi.lib.LLVMPY_SetCommandLine(_encode_string(name),
|
|
14
|
+
_encode_string(option))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
ffi.lib.LLVMPY_SetCommandLine.argtypes = [c_char_p, c_char_p]
|