llvmlite 0.46.0b1__cp311-cp311-macosx_11_0_universal2.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 +11 -0
- llvmlite/_version.py +11 -0
- llvmlite/binding/__init__.py +18 -0
- llvmlite/binding/analysis.py +69 -0
- llvmlite/binding/common.py +34 -0
- llvmlite/binding/config.py +143 -0
- llvmlite/binding/context.py +31 -0
- llvmlite/binding/dylib.py +45 -0
- llvmlite/binding/executionengine.py +330 -0
- llvmlite/binding/ffi.py +395 -0
- llvmlite/binding/initfini.py +85 -0
- llvmlite/binding/libllvmlite.dylib +0 -0
- llvmlite/binding/linker.py +20 -0
- llvmlite/binding/module.py +349 -0
- llvmlite/binding/newpassmanagers.py +1049 -0
- llvmlite/binding/object_file.py +82 -0
- llvmlite/binding/options.py +17 -0
- llvmlite/binding/orcjit.py +342 -0
- llvmlite/binding/targets.py +462 -0
- llvmlite/binding/typeref.py +267 -0
- llvmlite/binding/value.py +632 -0
- llvmlite/ir/__init__.py +11 -0
- llvmlite/ir/_utils.py +80 -0
- llvmlite/ir/builder.py +1120 -0
- llvmlite/ir/context.py +20 -0
- llvmlite/ir/instructions.py +920 -0
- llvmlite/ir/module.py +256 -0
- llvmlite/ir/transforms.py +64 -0
- llvmlite/ir/types.py +730 -0
- llvmlite/ir/values.py +1217 -0
- llvmlite/tests/__init__.py +57 -0
- llvmlite/tests/__main__.py +3 -0
- llvmlite/tests/customize.py +407 -0
- llvmlite/tests/refprune_proto.py +330 -0
- llvmlite/tests/test_binding.py +3155 -0
- llvmlite/tests/test_ir.py +3095 -0
- llvmlite/tests/test_refprune.py +574 -0
- llvmlite/tests/test_valuerepr.py +60 -0
- llvmlite/utils.py +29 -0
- llvmlite-0.46.0b1.dist-info/LICENSE +24 -0
- llvmlite-0.46.0b1.dist-info/LICENSE.thirdparty +225 -0
- llvmlite-0.46.0b1.dist-info/METADATA +137 -0
- llvmlite-0.46.0b1.dist-info/RECORD +45 -0
- llvmlite-0.46.0b1.dist-info/WHEEL +5 -0
- llvmlite-0.46.0b1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,1049 @@
|
|
|
1
|
+
from ctypes import c_bool, c_int, c_size_t, POINTER, Structure, byref, c_char_p
|
|
2
|
+
from collections import namedtuple
|
|
3
|
+
from enum import IntFlag
|
|
4
|
+
from llvmlite.binding import ffi
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def create_new_module_pass_manager():
|
|
8
|
+
return ModulePassManager()
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def create_new_function_pass_manager():
|
|
12
|
+
return FunctionPassManager()
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def create_pass_builder(tm, pto):
|
|
16
|
+
return PassBuilder(tm, pto)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def create_pipeline_tuning_options(speed_level=2, size_level=0):
|
|
20
|
+
return PipelineTuningOptions(speed_level, size_level)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
_prunestats = namedtuple('PruneStats',
|
|
24
|
+
('basicblock diamond fanout fanout_raise'))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class PruneStats(_prunestats):
|
|
28
|
+
""" Holds statistics from reference count pruning.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
def __add__(self, other):
|
|
32
|
+
if not isinstance(other, PruneStats):
|
|
33
|
+
msg = 'PruneStats can only be added to another PruneStats, got {}.'
|
|
34
|
+
raise TypeError(msg.format(type(other)))
|
|
35
|
+
return PruneStats(self.basicblock + other.basicblock,
|
|
36
|
+
self.diamond + other.diamond,
|
|
37
|
+
self.fanout + other.fanout,
|
|
38
|
+
self.fanout_raise + other.fanout_raise)
|
|
39
|
+
|
|
40
|
+
def __sub__(self, other):
|
|
41
|
+
if not isinstance(other, PruneStats):
|
|
42
|
+
msg = ('PruneStats can only be subtracted from another PruneStats, '
|
|
43
|
+
'got {}.')
|
|
44
|
+
raise TypeError(msg.format(type(other)))
|
|
45
|
+
return PruneStats(self.basicblock - other.basicblock,
|
|
46
|
+
self.diamond - other.diamond,
|
|
47
|
+
self.fanout - other.fanout,
|
|
48
|
+
self.fanout_raise - other.fanout_raise)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class _c_PruneStats(Structure):
|
|
52
|
+
_fields_ = [
|
|
53
|
+
('basicblock', c_size_t),
|
|
54
|
+
('diamond', c_size_t),
|
|
55
|
+
('fanout', c_size_t),
|
|
56
|
+
('fanout_raise', c_size_t)]
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def dump_refprune_stats(printout=False):
|
|
60
|
+
""" Returns a namedtuple containing the current values for the refop pruning
|
|
61
|
+
statistics. If kwarg `printout` is True the stats are printed to stderr,
|
|
62
|
+
default is False.
|
|
63
|
+
"""
|
|
64
|
+
|
|
65
|
+
stats = _c_PruneStats(0, 0, 0, 0)
|
|
66
|
+
do_print = c_bool(printout)
|
|
67
|
+
|
|
68
|
+
ffi.lib.LLVMPY_DumpRefPruneStats(byref(stats), do_print)
|
|
69
|
+
return PruneStats(stats.basicblock, stats.diamond, stats.fanout,
|
|
70
|
+
stats.fanout_raise)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
# TODO: Rename and add tests for these
|
|
74
|
+
# Although new pass manager has its own timing APIs, we still need to support
|
|
75
|
+
# the legacy ones as LLVM backend still used the LegacyPassManager. These APIs
|
|
76
|
+
# will be used to time the backend passes such as instruction selection,
|
|
77
|
+
# regalloc, etc
|
|
78
|
+
def set_time_passes(enable):
|
|
79
|
+
"""Enable or disable the pass timers.
|
|
80
|
+
|
|
81
|
+
Parameters
|
|
82
|
+
----------
|
|
83
|
+
enable : bool
|
|
84
|
+
Set to True to enable the pass timers.
|
|
85
|
+
Set to False to disable the pass timers.
|
|
86
|
+
"""
|
|
87
|
+
ffi.lib.LLVMPY_SetTimePasses(c_bool(enable))
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def report_and_reset_timings():
|
|
91
|
+
"""Returns the pass timings report and resets the LLVM internal timers.
|
|
92
|
+
|
|
93
|
+
Pass timers are enabled by ``set_time_passes()``. If the timers are not
|
|
94
|
+
enabled, this function will return an empty string.
|
|
95
|
+
|
|
96
|
+
Returns
|
|
97
|
+
-------
|
|
98
|
+
res : str
|
|
99
|
+
LLVM generated timing report.
|
|
100
|
+
"""
|
|
101
|
+
with ffi.OutputString() as buf:
|
|
102
|
+
ffi.lib.LLVMPY_ReportAndResetTimings(buf)
|
|
103
|
+
return str(buf)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class RefPruneSubpasses(IntFlag):
|
|
107
|
+
PER_BB = 0b0001 # noqa: E221
|
|
108
|
+
DIAMOND = 0b0010 # noqa: E221
|
|
109
|
+
FANOUT = 0b0100 # noqa: E221
|
|
110
|
+
FANOUT_RAISE = 0b1000
|
|
111
|
+
ALL = PER_BB | DIAMOND | FANOUT | FANOUT_RAISE
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
class NewPassManager():
|
|
115
|
+
|
|
116
|
+
def __init__(self):
|
|
117
|
+
if type(self) is NewPassManager:
|
|
118
|
+
raise TypeError("Cannot instantiate NewPassManager directly")
|
|
119
|
+
|
|
120
|
+
def run(self,IR, pb):
|
|
121
|
+
if isinstance(self, ModulePassManager):
|
|
122
|
+
ffi.lib.LLVMPY_RunNewModulePassManager(self, IR, pb)
|
|
123
|
+
else:
|
|
124
|
+
ffi.lib.LLVMPY_RunNewFunctionPassManager(self, IR, pb)
|
|
125
|
+
|
|
126
|
+
def add_aa_eval_pass(self):
|
|
127
|
+
if isinstance(self, ModulePassManager):
|
|
128
|
+
ffi.lib.LLVMPY_module_AddAAEvaluator(self)
|
|
129
|
+
else:
|
|
130
|
+
ffi.lib.LLVMPY_function_AddAAEvaluator(self)
|
|
131
|
+
|
|
132
|
+
def add_simplify_cfg_pass(self):
|
|
133
|
+
if isinstance(self, ModulePassManager):
|
|
134
|
+
ffi.lib.LLVMPY_module_AddSimplifyCFGPass(self)
|
|
135
|
+
else:
|
|
136
|
+
ffi.lib.LLVMPY_function_AddSimplifyCFGPass(self)
|
|
137
|
+
|
|
138
|
+
def add_loop_unroll_pass(self):
|
|
139
|
+
if isinstance(self, ModulePassManager):
|
|
140
|
+
ffi.lib.LLVMPY_module_AddLoopUnrollPass(self)
|
|
141
|
+
else:
|
|
142
|
+
ffi.lib.LLVMPY_function_AddLoopUnrollPass(self)
|
|
143
|
+
|
|
144
|
+
def add_instruction_combine_pass(self):
|
|
145
|
+
if isinstance(self, ModulePassManager):
|
|
146
|
+
ffi.lib.LLVMPY_module_AddInstCombinePass(self)
|
|
147
|
+
else:
|
|
148
|
+
ffi.lib.LLVMPY_function_AddInstCombinePass(self)
|
|
149
|
+
|
|
150
|
+
def add_jump_threading_pass(self, threshold=-1):
|
|
151
|
+
if isinstance(self, ModulePassManager):
|
|
152
|
+
ffi.lib.LLVMPY_AddJumpThreadingPass_module(self, threshold)
|
|
153
|
+
else:
|
|
154
|
+
ffi.lib.LLVMPY_AddJumpThreadingPass_function(self, threshold)
|
|
155
|
+
|
|
156
|
+
def add_cfg_printer_pass(self):
|
|
157
|
+
if isinstance(self, ModulePassManager):
|
|
158
|
+
ffi.lib.LLVMPY_module_AddCFGPrinterPass(self)
|
|
159
|
+
else:
|
|
160
|
+
ffi.lib.LLVMPY_function_AddCFGPrinterPass(self)
|
|
161
|
+
|
|
162
|
+
def add_cfg_only_printer_pass(self):
|
|
163
|
+
if isinstance(self, ModulePassManager):
|
|
164
|
+
ffi.lib.LLVMPY_module_AddCFGOnlyPrinterPass(self)
|
|
165
|
+
else:
|
|
166
|
+
ffi.lib.LLVMPY_function_AddCFGOnlyPrinterPass(self)
|
|
167
|
+
|
|
168
|
+
def add_dom_printer_pass(self):
|
|
169
|
+
if isinstance(self, ModulePassManager):
|
|
170
|
+
ffi.lib.LLVMPY_module_AddDomPrinter(self)
|
|
171
|
+
else:
|
|
172
|
+
ffi.lib.LLVMPY_function_AddDomPrinter(self)
|
|
173
|
+
|
|
174
|
+
def add_dom_only_printer_pass(self):
|
|
175
|
+
if isinstance(self, ModulePassManager):
|
|
176
|
+
ffi.lib.LLVMPY_module_AddDomOnlyPrinter(self)
|
|
177
|
+
else:
|
|
178
|
+
ffi.lib.LLVMPY_function_AddDomOnlyPrinter(self)
|
|
179
|
+
|
|
180
|
+
def add_post_dom_printer_pass(self):
|
|
181
|
+
if isinstance(self, ModulePassManager):
|
|
182
|
+
ffi.lib.LLVMPY_module_AddPostDomPrinter(self)
|
|
183
|
+
else:
|
|
184
|
+
ffi.lib.LLVMPY_function_AddPostDomPrinter(self)
|
|
185
|
+
|
|
186
|
+
def add_post_dom_only_printer_pass(self):
|
|
187
|
+
if isinstance(self, ModulePassManager):
|
|
188
|
+
ffi.lib.LLVMPY_module_AddPostDomOnlyPrinter(self)
|
|
189
|
+
else:
|
|
190
|
+
ffi.lib.LLVMPY_function_AddPostDomOnlyPrinter(self)
|
|
191
|
+
|
|
192
|
+
def add_dom_viewer_pass(self):
|
|
193
|
+
if isinstance(self, ModulePassManager):
|
|
194
|
+
ffi.lib.LLVMPY_module_AddDomViewer(self)
|
|
195
|
+
else:
|
|
196
|
+
ffi.lib.LLVMPY_function_AddDomViewer(self)
|
|
197
|
+
|
|
198
|
+
def add_dom_only_viewer_pass(self):
|
|
199
|
+
if isinstance(self, ModulePassManager):
|
|
200
|
+
ffi.lib.LLVMPY_module_AddDomOnlyViewer(self)
|
|
201
|
+
else:
|
|
202
|
+
ffi.lib.LLVMPY_function_AddDomOnlyViewer(self)
|
|
203
|
+
|
|
204
|
+
def add_post_dom_viewer_pass(self):
|
|
205
|
+
if isinstance(self, ModulePassManager):
|
|
206
|
+
ffi.lib.LLVMPY_module_AddPostDomViewer(self)
|
|
207
|
+
else:
|
|
208
|
+
ffi.lib.LLVMPY_function_AddPostDomViewer(self)
|
|
209
|
+
|
|
210
|
+
def add_post_dom_only_viewer_pass(self):
|
|
211
|
+
if isinstance(self, ModulePassManager):
|
|
212
|
+
ffi.lib.LLVMPY_module_AddPostDomOnlyViewer(self)
|
|
213
|
+
else:
|
|
214
|
+
ffi.lib.LLVMPY_function_AddPostDomOnlyViewer(self)
|
|
215
|
+
|
|
216
|
+
def add_lint_pass(self):
|
|
217
|
+
if isinstance(self, ModulePassManager):
|
|
218
|
+
ffi.lib.LLVMPY_module_AddLintPass(self)
|
|
219
|
+
else:
|
|
220
|
+
ffi.lib.LLVMPY_function_AddLintPass(self)
|
|
221
|
+
|
|
222
|
+
def add_aggressive_dce_pass(self):
|
|
223
|
+
if isinstance(self, ModulePassManager):
|
|
224
|
+
ffi.lib.LLVMPY_module_AddADCEPass(self)
|
|
225
|
+
else:
|
|
226
|
+
ffi.lib.LLVMPY_function_AddADCEPass(self)
|
|
227
|
+
|
|
228
|
+
def add_break_critical_edges_pass(self):
|
|
229
|
+
if isinstance(self, ModulePassManager):
|
|
230
|
+
ffi.lib.LLVMPY_module_AddBreakCriticalEdgesPass(self)
|
|
231
|
+
else:
|
|
232
|
+
ffi.lib.LLVMPY_function_AddBreakCriticalEdgesPass(self)
|
|
233
|
+
|
|
234
|
+
def add_dead_store_elimination_pass(self):
|
|
235
|
+
if isinstance(self, ModulePassManager):
|
|
236
|
+
ffi.lib.LLVMPY_module_AddDSEPass(self)
|
|
237
|
+
else:
|
|
238
|
+
ffi.lib.LLVMPY_function_AddDSEPass(self)
|
|
239
|
+
|
|
240
|
+
def add_dead_code_elimination_pass(self):
|
|
241
|
+
if isinstance(self, ModulePassManager):
|
|
242
|
+
ffi.lib.LLVMPY_module_AddDCEPass(self)
|
|
243
|
+
else:
|
|
244
|
+
ffi.lib.LLVMPY_function_AddDCEPass(self)
|
|
245
|
+
|
|
246
|
+
def add_aggressive_instcombine_pass(self):
|
|
247
|
+
if isinstance(self, ModulePassManager):
|
|
248
|
+
ffi.lib.LLVMPY_module_AddAggressiveInstCombinePass(self)
|
|
249
|
+
else:
|
|
250
|
+
ffi.lib.LLVMPY_function_AddAggressiveInstCombinePass(self)
|
|
251
|
+
|
|
252
|
+
def add_lcssa_pass(self):
|
|
253
|
+
if isinstance(self, ModulePassManager):
|
|
254
|
+
ffi.lib.LLVMPY_module_AddLCSSAPass(self)
|
|
255
|
+
else:
|
|
256
|
+
ffi.lib.LLVMPY_function_AddLCSSAPass(self)
|
|
257
|
+
|
|
258
|
+
def add_new_gvn_pass(self):
|
|
259
|
+
if isinstance(self, ModulePassManager):
|
|
260
|
+
ffi.lib.LLVMPY_module_AddNewGVNPass(self)
|
|
261
|
+
else:
|
|
262
|
+
ffi.lib.LLVMPY_function_AddNewGVNPass(self)
|
|
263
|
+
|
|
264
|
+
def add_loop_simplify_pass(self):
|
|
265
|
+
if isinstance(self, ModulePassManager):
|
|
266
|
+
ffi.lib.LLVMPY_module_AddLoopSimplifyPass(self)
|
|
267
|
+
else:
|
|
268
|
+
ffi.lib.LLVMPY_function_AddLoopSimplifyPass(self)
|
|
269
|
+
|
|
270
|
+
def add_loop_unroll_and_jam_pass(self):
|
|
271
|
+
if isinstance(self, ModulePassManager):
|
|
272
|
+
ffi.lib.LLVMPY_module_AddLoopUnrollAndJamPass(self)
|
|
273
|
+
else:
|
|
274
|
+
ffi.lib.LLVMPY_function_AddLoopUnrollAndJamPass(self)
|
|
275
|
+
|
|
276
|
+
def add_sccp_pass(self):
|
|
277
|
+
if isinstance(self, ModulePassManager):
|
|
278
|
+
ffi.lib.LLVMPY_module_AddSCCPPass(self)
|
|
279
|
+
else:
|
|
280
|
+
ffi.lib.LLVMPY_function_AddSCCPPass(self)
|
|
281
|
+
|
|
282
|
+
def add_lower_atomic_pass(self):
|
|
283
|
+
if isinstance(self, ModulePassManager):
|
|
284
|
+
ffi.lib.LLVMPY_module_AddLowerAtomicPass(self)
|
|
285
|
+
else:
|
|
286
|
+
ffi.lib.LLVMPY_function_AddLowerAtomicPass(self)
|
|
287
|
+
|
|
288
|
+
def add_lower_invoke_pass(self):
|
|
289
|
+
if isinstance(self, ModulePassManager):
|
|
290
|
+
ffi.lib.LLVMPY_module_AddLowerInvokePass(self)
|
|
291
|
+
else:
|
|
292
|
+
ffi.lib.LLVMPY_function_AddLowerInvokePass(self)
|
|
293
|
+
|
|
294
|
+
def add_lower_switch_pass(self):
|
|
295
|
+
if isinstance(self, ModulePassManager):
|
|
296
|
+
ffi.lib.LLVMPY_module_AddLowerSwitchPass(self)
|
|
297
|
+
else:
|
|
298
|
+
ffi.lib.LLVMPY_function_AddLowerSwitchPass(self)
|
|
299
|
+
|
|
300
|
+
def add_mem_copy_opt_pass(self):
|
|
301
|
+
if isinstance(self, ModulePassManager):
|
|
302
|
+
ffi.lib.LLVMPY_module_AddMemCpyOptPass(self)
|
|
303
|
+
else:
|
|
304
|
+
ffi.lib.LLVMPY_function_AddMemCpyOptPass(self)
|
|
305
|
+
|
|
306
|
+
def add_unify_function_exit_nodes_pass(self):
|
|
307
|
+
if isinstance(self, ModulePassManager):
|
|
308
|
+
ffi.lib.LLVMPY_module_AddUnifyFunctionExitNodesPass(self)
|
|
309
|
+
else:
|
|
310
|
+
ffi.lib.LLVMPY_function_AddUnifyFunctionExitNodesPass(self)
|
|
311
|
+
|
|
312
|
+
def add_reassociate_pass(self):
|
|
313
|
+
if isinstance(self, ModulePassManager):
|
|
314
|
+
ffi.lib.LLVMPY_module_AddReassociatePass(self)
|
|
315
|
+
else:
|
|
316
|
+
ffi.lib.LLVMPY_function_AddReassociatePass(self)
|
|
317
|
+
|
|
318
|
+
def add_register_to_memory_pass(self):
|
|
319
|
+
if isinstance(self, ModulePassManager):
|
|
320
|
+
ffi.lib.LLVMPY_module_AddRegToMemPass(self)
|
|
321
|
+
else:
|
|
322
|
+
ffi.lib.LLVMPY_function_AddRegToMemPass(self)
|
|
323
|
+
|
|
324
|
+
def add_sroa_pass(self):
|
|
325
|
+
if isinstance(self, ModulePassManager):
|
|
326
|
+
ffi.lib.LLVMPY_module_AddSROAPass(self)
|
|
327
|
+
else:
|
|
328
|
+
ffi.lib.LLVMPY_function_AddSROAPass(self)
|
|
329
|
+
|
|
330
|
+
def add_sinking_pass(self):
|
|
331
|
+
if isinstance(self, ModulePassManager):
|
|
332
|
+
ffi.lib.LLVMPY_module_AddSinkingPass(self)
|
|
333
|
+
else:
|
|
334
|
+
ffi.lib.LLVMPY_function_AddSinkingPass(self)
|
|
335
|
+
|
|
336
|
+
def add_tail_call_elimination_pass(self):
|
|
337
|
+
if isinstance(self, ModulePassManager):
|
|
338
|
+
ffi.lib.LLVMPY_module_AddTailCallElimPass(self)
|
|
339
|
+
else:
|
|
340
|
+
ffi.lib.LLVMPY_function_AddTailCallElimPass(self)
|
|
341
|
+
|
|
342
|
+
def add_instruction_namer_pass(self):
|
|
343
|
+
if isinstance(self, ModulePassManager):
|
|
344
|
+
ffi.lib.LLVMPY_module_AddInstructionNamerPass(self)
|
|
345
|
+
else:
|
|
346
|
+
ffi.lib.LLVMPY_function_AddInstructionNamerPass(self)
|
|
347
|
+
|
|
348
|
+
def add_loop_deletion_pass(self):
|
|
349
|
+
if isinstance(self, ModulePassManager):
|
|
350
|
+
ffi.lib.LLVMPY_module_AddLoopDeletionPass(self)
|
|
351
|
+
else:
|
|
352
|
+
ffi.lib.LLVMPY_function_AddLoopDeletionPass(self)
|
|
353
|
+
|
|
354
|
+
def add_loop_strength_reduce_pass(self):
|
|
355
|
+
if isinstance(self, ModulePassManager):
|
|
356
|
+
ffi.lib.LLVMPY_module_AddLoopStrengthReducePass(self)
|
|
357
|
+
else:
|
|
358
|
+
ffi.lib.LLVMPY_function_AddLoopStrengthReducePass(self)
|
|
359
|
+
|
|
360
|
+
def add_loop_rotate_pass(self):
|
|
361
|
+
if isinstance(self, ModulePassManager):
|
|
362
|
+
ffi.lib.LLVMPY_module_AddLoopRotatePass(self)
|
|
363
|
+
else:
|
|
364
|
+
ffi.lib.LLVMPY_function_AddLoopRotatePass(self)
|
|
365
|
+
|
|
366
|
+
def _dispose(self):
|
|
367
|
+
if isinstance(self, ModulePassManager):
|
|
368
|
+
ffi.lib.LLVMPY_DisposeNewModulePassManger(self)
|
|
369
|
+
else:
|
|
370
|
+
ffi.lib.LLVMPY_DisposeNewFunctionPassManger(self)
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
class ModulePassManager(ffi.ObjectRef, NewPassManager):
|
|
374
|
+
|
|
375
|
+
def __init__(self, ptr=None):
|
|
376
|
+
if ptr is None:
|
|
377
|
+
ptr = ffi.lib.LLVMPY_CreateNewModulePassManager()
|
|
378
|
+
super().__init__(ptr)
|
|
379
|
+
|
|
380
|
+
def add_verifier(self):
|
|
381
|
+
ffi.lib.LLVMPY_module_AddVerifierPass(self)
|
|
382
|
+
|
|
383
|
+
def add_constant_merge_pass(self):
|
|
384
|
+
ffi.lib.LLVMPY_module_AddConstantMergePass(self)
|
|
385
|
+
|
|
386
|
+
def add_dead_arg_elimination_pass(self):
|
|
387
|
+
ffi.lib.LLVMPY_module_AddDeadArgumentEliminationPass(self)
|
|
388
|
+
|
|
389
|
+
def add_dot_call_graph_printer_pass(self):
|
|
390
|
+
ffi.lib.LLVMPY_module_AddCallGraphDOTPrinterPass(self)
|
|
391
|
+
|
|
392
|
+
# TODO: There are a lot more printer passes in llvm that can be exposed
|
|
393
|
+
# FIXME: Find a way to write the output to a buffer instead of stdout
|
|
394
|
+
def add_module_debug_info_pass(self):
|
|
395
|
+
ffi.lib.LLVMPY_module_AddModuleDebugInfoPrinterPass(self)
|
|
396
|
+
|
|
397
|
+
def add_always_inliner_pass(self):
|
|
398
|
+
ffi.lib.LLVMPY_module_AddAlwaysInlinerPass(self)
|
|
399
|
+
|
|
400
|
+
def add_rpo_function_attrs_pass(self):
|
|
401
|
+
ffi.lib.LLVMPY_module_AddReversePostOrderFunctionAttrsPass(self)
|
|
402
|
+
|
|
403
|
+
def add_global_dead_code_eliminate_pass(self):
|
|
404
|
+
ffi.lib.LLVMPY_module_AddGlobalDCEPass(self)
|
|
405
|
+
|
|
406
|
+
def add_global_opt_pass(self):
|
|
407
|
+
ffi.lib.LLVMPY_module_AddGlobalOptPass(self)
|
|
408
|
+
|
|
409
|
+
def add_ipsccp_pass(self):
|
|
410
|
+
ffi.lib.LLVMPY_module_AddIPSCCPPass(self)
|
|
411
|
+
|
|
412
|
+
def add_internalize_pass(self):
|
|
413
|
+
ffi.lib.LLVMPY_module_AddInternalizePass(self)
|
|
414
|
+
|
|
415
|
+
def add_loop_extract_pass(self):
|
|
416
|
+
ffi.lib.LLVMPY_module_AddLoopExtractorPass(self)
|
|
417
|
+
|
|
418
|
+
def add_merge_functions_pass(self):
|
|
419
|
+
ffi.lib.LLVMPY_module_AddMergeFunctionsPass(self)
|
|
420
|
+
|
|
421
|
+
def add_partial_inliner_pass(self):
|
|
422
|
+
ffi.lib.LLVMPY_module_AddPartialInlinerPass(self)
|
|
423
|
+
|
|
424
|
+
def add_strip_symbols_pass(self):
|
|
425
|
+
ffi.lib.LLVMPY_module_AddStripSymbolsPass(self)
|
|
426
|
+
|
|
427
|
+
def add_strip_dead_debug_info_pass(self):
|
|
428
|
+
ffi.lib.LLVMPY_module_AddStripDeadDebugInfoPass(self)
|
|
429
|
+
|
|
430
|
+
def add_strip_dead_prototype_pass(self):
|
|
431
|
+
ffi.lib.LLVMPY_module_AddStripDeadPrototypesPass(self)
|
|
432
|
+
|
|
433
|
+
def add_strip_debug_declare_pass(self):
|
|
434
|
+
ffi.lib.LLVMPY_module_AddStripDebugDeclarePass(self)
|
|
435
|
+
|
|
436
|
+
def add_strip_non_debug_symbols_pass(self):
|
|
437
|
+
ffi.lib.LLVMPY_module_AddStripNonDebugSymbolsPass(self)
|
|
438
|
+
|
|
439
|
+
def add_argument_promotion_pass(self):
|
|
440
|
+
ffi.lib.LLVMPY_module_AddArgumentPromotionPass(self)
|
|
441
|
+
|
|
442
|
+
def add_post_order_function_attributes_pass(self):
|
|
443
|
+
ffi.lib.LLVMPY_module_AddPostOrderFunctionAttrsPass(self)
|
|
444
|
+
|
|
445
|
+
# Non-standard LLVM passes
|
|
446
|
+
def add_refprune_pass(self, subpasses_flags=RefPruneSubpasses.ALL,
|
|
447
|
+
subgraph_limit=1000):
|
|
448
|
+
"""Add Numba specific Reference count pruning pass.
|
|
449
|
+
|
|
450
|
+
Parameters
|
|
451
|
+
----------
|
|
452
|
+
subpasses_flags : RefPruneSubpasses
|
|
453
|
+
A bitmask to control the subpasses to be enabled.
|
|
454
|
+
subgraph_limit : int
|
|
455
|
+
Limit the fanout pruners to working on a subgraph no bigger than
|
|
456
|
+
this number of basic-blocks to avoid spending too much time in very
|
|
457
|
+
large graphs. Default is 1000. Subject to change in future
|
|
458
|
+
versions.
|
|
459
|
+
"""
|
|
460
|
+
iflags = RefPruneSubpasses(subpasses_flags)
|
|
461
|
+
ffi.lib.LLVMPY_AddRefPrunePass_module(self, iflags, subgraph_limit)
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
class FunctionPassManager(ffi.ObjectRef, NewPassManager):
|
|
465
|
+
|
|
466
|
+
def __init__(self, ptr=None):
|
|
467
|
+
if ptr is None:
|
|
468
|
+
ptr = ffi.lib.LLVMPY_CreateNewFunctionPassManager()
|
|
469
|
+
super().__init__(ptr)
|
|
470
|
+
|
|
471
|
+
# Non-standard LLVM passes
|
|
472
|
+
def add_refprune_pass(self, subpasses_flags=RefPruneSubpasses.ALL,
|
|
473
|
+
subgraph_limit=1000):
|
|
474
|
+
"""Add Numba specific Reference count pruning pass.
|
|
475
|
+
|
|
476
|
+
Parameters
|
|
477
|
+
----------
|
|
478
|
+
subpasses_flags : RefPruneSubpasses
|
|
479
|
+
A bitmask to control the subpasses to be enabled.
|
|
480
|
+
subgraph_limit : int
|
|
481
|
+
Limit the fanout pruners to working on a subgraph no bigger than
|
|
482
|
+
this number of basic-blocks to avoid spending too much time in very
|
|
483
|
+
large graphs. Default is 1000. Subject to change in future
|
|
484
|
+
versions.
|
|
485
|
+
"""
|
|
486
|
+
iflags = RefPruneSubpasses(subpasses_flags)
|
|
487
|
+
ffi.lib.LLVMPY_AddRefPrunePass_function(self, iflags, subgraph_limit)
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
class PipelineTuningOptions(ffi.ObjectRef):
|
|
491
|
+
|
|
492
|
+
def __init__(self, speed_level=2, size_level=0):
|
|
493
|
+
self._speed_level = None
|
|
494
|
+
self._size_level = None
|
|
495
|
+
self.speed_level = speed_level
|
|
496
|
+
self.size_level = size_level
|
|
497
|
+
super().__init__(ffi.lib.LLVMPY_CreatePipelineTuningOptions())
|
|
498
|
+
|
|
499
|
+
@property
|
|
500
|
+
def speed_level(self):
|
|
501
|
+
return self._speed_level
|
|
502
|
+
|
|
503
|
+
@speed_level.setter
|
|
504
|
+
def speed_level(self, value):
|
|
505
|
+
if not 0 <= value <= 3:
|
|
506
|
+
raise ValueError(
|
|
507
|
+
"Optimization level for speed should be 0, 1, 2, or 3")
|
|
508
|
+
self._speed_level = value
|
|
509
|
+
|
|
510
|
+
@property
|
|
511
|
+
def size_level(self):
|
|
512
|
+
return self._size_level
|
|
513
|
+
|
|
514
|
+
@size_level.setter
|
|
515
|
+
def size_level(self, value):
|
|
516
|
+
if not 0 <= value <= 2:
|
|
517
|
+
raise ValueError("Optimization level for size should be 0, 1, or 2")
|
|
518
|
+
if value != 0 and self.speed_level != 2:
|
|
519
|
+
raise ValueError(
|
|
520
|
+
"Optimization for size should be encoded with speed level == 2")
|
|
521
|
+
self._size_level = value
|
|
522
|
+
|
|
523
|
+
@property
|
|
524
|
+
def loop_interleaving(self):
|
|
525
|
+
return ffi.lib.LLVMPY_PTOGetLoopInterleaving(self)
|
|
526
|
+
|
|
527
|
+
@loop_interleaving.setter
|
|
528
|
+
def loop_interleaving(self, value):
|
|
529
|
+
ffi.lib.LLVMPY_PTOSetLoopInterleaving(self, value)
|
|
530
|
+
|
|
531
|
+
@property
|
|
532
|
+
def loop_vectorization(self):
|
|
533
|
+
return ffi.lib.LLVMPY_PTOGetLoopVectorization(self)
|
|
534
|
+
|
|
535
|
+
@loop_vectorization.setter
|
|
536
|
+
def loop_vectorization(self, value):
|
|
537
|
+
ffi.lib.LLVMPY_PTOSetLoopVectorization(self, value)
|
|
538
|
+
|
|
539
|
+
@property
|
|
540
|
+
def slp_vectorization(self):
|
|
541
|
+
return ffi.lib.LLVMPY_PTOGetSLPVectorization(self)
|
|
542
|
+
|
|
543
|
+
@slp_vectorization.setter
|
|
544
|
+
def slp_vectorization(self, value):
|
|
545
|
+
ffi.lib.LLVMPY_PTOSetSLPVectorization(self, value)
|
|
546
|
+
|
|
547
|
+
@property
|
|
548
|
+
def loop_unrolling(self):
|
|
549
|
+
return ffi.lib.LLVMPY_PTOGetLoopUnrolling(self)
|
|
550
|
+
|
|
551
|
+
@loop_unrolling.setter
|
|
552
|
+
def loop_unrolling(self, value):
|
|
553
|
+
ffi.lib.LLVMPY_PTOSetLoopUnrolling(self, value)
|
|
554
|
+
|
|
555
|
+
@property
|
|
556
|
+
def inlining_threshold(self):
|
|
557
|
+
return ffi.lib.LLVMPY_PTOGetInlinerThreshold(self)
|
|
558
|
+
|
|
559
|
+
@inlining_threshold.setter
|
|
560
|
+
def inlining_threshold(self, value):
|
|
561
|
+
ffi.lib.LLVMPY_PTOSetInlinerThreshold(self, value)
|
|
562
|
+
|
|
563
|
+
def _dispose(self):
|
|
564
|
+
ffi.lib.LLVMPY_DisposePipelineTuningOptions(self)
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
class TimePassesHandler(ffi.ObjectRef):
|
|
568
|
+
def __init__(self):
|
|
569
|
+
super().__init__(ffi.lib.LLVMPY_CreateTimePassesHandler())
|
|
570
|
+
|
|
571
|
+
def _dispose(self):
|
|
572
|
+
ffi.lib.LLVMPY_DisposeTimePassesHandler(self)
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
class PassBuilder(ffi.ObjectRef):
|
|
576
|
+
|
|
577
|
+
def __init__(self, tm, pto):
|
|
578
|
+
super().__init__(ffi.lib.LLVMPY_CreatePassBuilder(tm, pto))
|
|
579
|
+
self._pto = pto
|
|
580
|
+
self._tm = tm
|
|
581
|
+
self._time_passes_handler = None
|
|
582
|
+
|
|
583
|
+
def getModulePassManager(self):
|
|
584
|
+
return ModulePassManager(
|
|
585
|
+
ffi.lib.LLVMPY_buildPerModuleDefaultPipeline(
|
|
586
|
+
self, self._pto.speed_level, self._pto.size_level)
|
|
587
|
+
)
|
|
588
|
+
|
|
589
|
+
def getFunctionPassManager(self):
|
|
590
|
+
return FunctionPassManager(
|
|
591
|
+
ffi.lib.LLVMPY_buildFunctionSimplificationPipeline(
|
|
592
|
+
self, self._pto.speed_level, self._pto.size_level)
|
|
593
|
+
)
|
|
594
|
+
|
|
595
|
+
def start_pass_timing(self):
|
|
596
|
+
"""Enable the pass timers.
|
|
597
|
+
|
|
598
|
+
Raises
|
|
599
|
+
------
|
|
600
|
+
RuntimeError
|
|
601
|
+
If pass timing is already enabled.
|
|
602
|
+
"""
|
|
603
|
+
if self._time_passes_handler:
|
|
604
|
+
raise RuntimeError("Pass timing can only be done once")
|
|
605
|
+
self._time_passes_handler = TimePassesHandler()
|
|
606
|
+
ffi.lib.LLVMPY_EnableTimePasses(self, self._time_passes_handler)
|
|
607
|
+
|
|
608
|
+
def finish_pass_timing(self):
|
|
609
|
+
"""Returns the pass timings report and disables the LLVM internal
|
|
610
|
+
timers. Pass timers are enabled by ``start_pass_timing()``. If the
|
|
611
|
+
timers are not enabled, this function will return an empty string.
|
|
612
|
+
|
|
613
|
+
Returns
|
|
614
|
+
-------
|
|
615
|
+
res : str
|
|
616
|
+
LLVM generated timing report.
|
|
617
|
+
"""
|
|
618
|
+
|
|
619
|
+
if not self._time_passes_handler:
|
|
620
|
+
raise RuntimeError("Pass timing is not enabled")
|
|
621
|
+
|
|
622
|
+
with ffi.OutputString() as buf:
|
|
623
|
+
ffi.lib.LLVMPY_ReportAndDisableTimePasses(
|
|
624
|
+
self._time_passes_handler, buf)
|
|
625
|
+
return str(buf)
|
|
626
|
+
|
|
627
|
+
def _dispose(self):
|
|
628
|
+
ffi.lib.LLVMPY_DisposePassBuilder(self)
|
|
629
|
+
|
|
630
|
+
|
|
631
|
+
# ============================================================================
|
|
632
|
+
# FFI
|
|
633
|
+
|
|
634
|
+
ffi.lib.LLVMPY_DumpRefPruneStats.argtypes = [POINTER(_c_PruneStats), c_bool]
|
|
635
|
+
|
|
636
|
+
ffi.lib.LLVMPY_SetTimePasses.argtypes = [c_bool]
|
|
637
|
+
|
|
638
|
+
ffi.lib.LLVMPY_ReportAndResetTimings.argtypes = [POINTER(c_char_p)]
|
|
639
|
+
|
|
640
|
+
# ModulePassManager
|
|
641
|
+
|
|
642
|
+
ffi.lib.LLVMPY_CreateNewModulePassManager.restype = ffi.LLVMModulePassManagerRef
|
|
643
|
+
|
|
644
|
+
ffi.lib.LLVMPY_RunNewModulePassManager.argtypes = [
|
|
645
|
+
ffi.LLVMModulePassManagerRef, ffi.LLVMModuleRef,
|
|
646
|
+
ffi.LLVMPassBuilderRef,]
|
|
647
|
+
|
|
648
|
+
ffi.lib.LLVMPY_module_AddVerifierPass.argtypes = [ffi.LLVMModulePassManagerRef,]
|
|
649
|
+
ffi.lib.LLVMPY_module_AddAAEvaluator.argtypes = [ffi.LLVMModulePassManagerRef,]
|
|
650
|
+
ffi.lib.LLVMPY_module_AddSimplifyCFGPass.argtypes = [
|
|
651
|
+
ffi.LLVMModulePassManagerRef,]
|
|
652
|
+
|
|
653
|
+
ffi.lib.LLVMPY_module_AddLoopUnrollPass.argtypes = [
|
|
654
|
+
ffi.LLVMModulePassManagerRef,]
|
|
655
|
+
|
|
656
|
+
ffi.lib.LLVMPY_module_AddLoopRotatePass.argtypes = [
|
|
657
|
+
ffi.LLVMModulePassManagerRef,]
|
|
658
|
+
|
|
659
|
+
ffi.lib.LLVMPY_module_AddInstCombinePass.argtypes = [
|
|
660
|
+
ffi.LLVMModulePassManagerRef,]
|
|
661
|
+
|
|
662
|
+
ffi.lib.LLVMPY_AddJumpThreadingPass_module.argtypes = [
|
|
663
|
+
ffi.LLVMModulePassManagerRef,]
|
|
664
|
+
|
|
665
|
+
ffi.lib.LLVMPY_module_AddCFGPrinterPass.argtypes = [
|
|
666
|
+
ffi.LLVMModulePassManagerRef,]
|
|
667
|
+
|
|
668
|
+
ffi.lib.LLVMPY_module_AddCFGOnlyPrinterPass.argtypes = [
|
|
669
|
+
ffi.LLVMModulePassManagerRef,]
|
|
670
|
+
|
|
671
|
+
ffi.lib.LLVMPY_module_AddDomPrinter.argtypes = [
|
|
672
|
+
ffi.LLVMModulePassManagerRef,]
|
|
673
|
+
|
|
674
|
+
ffi.lib.LLVMPY_module_AddDomOnlyPrinter.argtypes = [
|
|
675
|
+
ffi.LLVMModulePassManagerRef,]
|
|
676
|
+
|
|
677
|
+
ffi.lib.LLVMPY_module_AddPostDomPrinter.argtypes = [
|
|
678
|
+
ffi.LLVMModulePassManagerRef,]
|
|
679
|
+
|
|
680
|
+
ffi.lib.LLVMPY_module_AddPostDomOnlyPrinter.argtypes = [
|
|
681
|
+
ffi.LLVMModulePassManagerRef,]
|
|
682
|
+
|
|
683
|
+
ffi.lib.LLVMPY_module_AddDomViewer.argtypes = [
|
|
684
|
+
ffi.LLVMModulePassManagerRef,]
|
|
685
|
+
|
|
686
|
+
ffi.lib.LLVMPY_module_AddDomOnlyViewer.argtypes = [
|
|
687
|
+
ffi.LLVMModulePassManagerRef,]
|
|
688
|
+
|
|
689
|
+
ffi.lib.LLVMPY_module_AddPostDomViewer.argtypes = [
|
|
690
|
+
ffi.LLVMModulePassManagerRef,]
|
|
691
|
+
|
|
692
|
+
ffi.lib.LLVMPY_module_AddPostDomOnlyViewer.argtypes = [
|
|
693
|
+
ffi.LLVMModulePassManagerRef,]
|
|
694
|
+
|
|
695
|
+
ffi.lib.LLVMPY_module_AddLintPass.argtypes = [
|
|
696
|
+
ffi.LLVMModulePassManagerRef,]
|
|
697
|
+
|
|
698
|
+
ffi.lib.LLVMPY_module_AddADCEPass.argtypes = [
|
|
699
|
+
ffi.LLVMModulePassManagerRef,]
|
|
700
|
+
|
|
701
|
+
ffi.lib.LLVMPY_module_AddBreakCriticalEdgesPass.argtypes = [
|
|
702
|
+
ffi.LLVMModulePassManagerRef,]
|
|
703
|
+
|
|
704
|
+
ffi.lib.LLVMPY_module_AddDSEPass.argtypes = [
|
|
705
|
+
ffi.LLVMModulePassManagerRef,]
|
|
706
|
+
|
|
707
|
+
ffi.lib.LLVMPY_module_AddDCEPass.argtypes = [
|
|
708
|
+
ffi.LLVMModulePassManagerRef,]
|
|
709
|
+
|
|
710
|
+
ffi.lib.LLVMPY_module_AddAggressiveInstCombinePass.argtypes = [
|
|
711
|
+
ffi.LLVMModulePassManagerRef,]
|
|
712
|
+
|
|
713
|
+
ffi.lib.LLVMPY_module_AddLCSSAPass.argtypes = [
|
|
714
|
+
ffi.LLVMModulePassManagerRef,]
|
|
715
|
+
|
|
716
|
+
ffi.lib.LLVMPY_module_AddNewGVNPass.argtypes = [
|
|
717
|
+
ffi.LLVMModulePassManagerRef,]
|
|
718
|
+
|
|
719
|
+
ffi.lib.LLVMPY_module_AddLoopSimplifyPass.argtypes = [
|
|
720
|
+
ffi.LLVMModulePassManagerRef,]
|
|
721
|
+
|
|
722
|
+
ffi.lib.LLVMPY_module_AddLoopUnrollAndJamPass.argtypes = [
|
|
723
|
+
ffi.LLVMModulePassManagerRef,]
|
|
724
|
+
|
|
725
|
+
ffi.lib.LLVMPY_module_AddSCCPPass.argtypes = [
|
|
726
|
+
ffi.LLVMModulePassManagerRef,]
|
|
727
|
+
|
|
728
|
+
ffi.lib.LLVMPY_module_AddLowerAtomicPass.argtypes = [
|
|
729
|
+
ffi.LLVMModulePassManagerRef,]
|
|
730
|
+
|
|
731
|
+
ffi.lib.LLVMPY_module_AddLowerInvokePass.argtypes = [
|
|
732
|
+
ffi.LLVMModulePassManagerRef,]
|
|
733
|
+
|
|
734
|
+
ffi.lib.LLVMPY_module_AddLowerSwitchPass.argtypes = [
|
|
735
|
+
ffi.LLVMModulePassManagerRef,]
|
|
736
|
+
|
|
737
|
+
ffi.lib.LLVMPY_module_AddMemCpyOptPass.argtypes = [
|
|
738
|
+
ffi.LLVMModulePassManagerRef,]
|
|
739
|
+
|
|
740
|
+
ffi.lib.LLVMPY_module_AddUnifyFunctionExitNodesPass.argtypes = [
|
|
741
|
+
ffi.LLVMModulePassManagerRef,]
|
|
742
|
+
|
|
743
|
+
ffi.lib.LLVMPY_module_AddReassociatePass.argtypes = [
|
|
744
|
+
ffi.LLVMModulePassManagerRef,]
|
|
745
|
+
|
|
746
|
+
ffi.lib.LLVMPY_module_AddRegToMemPass.argtypes = [
|
|
747
|
+
ffi.LLVMModulePassManagerRef,]
|
|
748
|
+
|
|
749
|
+
ffi.lib.LLVMPY_module_AddSROAPass.argtypes = [
|
|
750
|
+
ffi.LLVMModulePassManagerRef,]
|
|
751
|
+
|
|
752
|
+
ffi.lib.LLVMPY_module_AddSinkingPass.argtypes = [
|
|
753
|
+
ffi.LLVMModulePassManagerRef,]
|
|
754
|
+
|
|
755
|
+
ffi.lib.LLVMPY_module_AddTailCallElimPass.argtypes = [
|
|
756
|
+
ffi.LLVMModulePassManagerRef,]
|
|
757
|
+
|
|
758
|
+
ffi.lib.LLVMPY_module_AddInstructionNamerPass.argtypes = [
|
|
759
|
+
ffi.LLVMModulePassManagerRef,]
|
|
760
|
+
|
|
761
|
+
ffi.lib.LLVMPY_module_AddLoopDeletionPass.argtypes = [
|
|
762
|
+
ffi.LLVMModulePassManagerRef,]
|
|
763
|
+
|
|
764
|
+
ffi.lib.LLVMPY_module_AddLoopStrengthReducePass.argtypes = [
|
|
765
|
+
ffi.LLVMModulePassManagerRef,]
|
|
766
|
+
|
|
767
|
+
ffi.lib.LLVMPY_module_AddConstantMergePass.argtypes = [
|
|
768
|
+
ffi.LLVMModulePassManagerRef, ]
|
|
769
|
+
|
|
770
|
+
ffi.lib.LLVMPY_module_AddDeadArgumentEliminationPass.argtypes = [
|
|
771
|
+
ffi.LLVMModulePassManagerRef, ]
|
|
772
|
+
|
|
773
|
+
ffi.lib.LLVMPY_module_AddCallGraphDOTPrinterPass.argtypes = [
|
|
774
|
+
ffi.LLVMModulePassManagerRef, ]
|
|
775
|
+
|
|
776
|
+
ffi.lib.LLVMPY_module_AddModuleDebugInfoPrinterPass.argtypes = [
|
|
777
|
+
ffi.LLVMModulePassManagerRef, ]
|
|
778
|
+
|
|
779
|
+
ffi.lib.LLVMPY_module_AddAlwaysInlinerPass.argtypes = [
|
|
780
|
+
ffi.LLVMModulePassManagerRef, ]
|
|
781
|
+
|
|
782
|
+
ffi.lib.LLVMPY_module_AddReversePostOrderFunctionAttrsPass.argtypes = [
|
|
783
|
+
ffi.LLVMModulePassManagerRef, ]
|
|
784
|
+
|
|
785
|
+
ffi.lib.LLVMPY_module_AddGlobalDCEPass.argtypes = [
|
|
786
|
+
ffi.LLVMModulePassManagerRef, ]
|
|
787
|
+
|
|
788
|
+
ffi.lib.LLVMPY_module_AddGlobalOptPass.argtypes = [
|
|
789
|
+
ffi.LLVMModulePassManagerRef, ]
|
|
790
|
+
|
|
791
|
+
ffi.lib.LLVMPY_module_AddIPSCCPPass.argtypes = [
|
|
792
|
+
ffi.LLVMModulePassManagerRef, ]
|
|
793
|
+
|
|
794
|
+
ffi.lib.LLVMPY_module_AddInternalizePass.argtypes = [
|
|
795
|
+
ffi.LLVMModulePassManagerRef, ]
|
|
796
|
+
|
|
797
|
+
ffi.lib.LLVMPY_module_AddLoopExtractorPass.argtypes = [
|
|
798
|
+
ffi.LLVMModulePassManagerRef, ]
|
|
799
|
+
|
|
800
|
+
ffi.lib.LLVMPY_module_AddMergeFunctionsPass.argtypes = [
|
|
801
|
+
ffi.LLVMModulePassManagerRef, ]
|
|
802
|
+
|
|
803
|
+
ffi.lib.LLVMPY_module_AddPartialInlinerPass.argtypes = [
|
|
804
|
+
ffi.LLVMModulePassManagerRef, ]
|
|
805
|
+
|
|
806
|
+
ffi.lib.LLVMPY_module_AddStripSymbolsPass.argtypes = [
|
|
807
|
+
ffi.LLVMModulePassManagerRef, ]
|
|
808
|
+
|
|
809
|
+
ffi.lib.LLVMPY_module_AddStripDeadDebugInfoPass.argtypes = [
|
|
810
|
+
ffi.LLVMModulePassManagerRef, ]
|
|
811
|
+
|
|
812
|
+
ffi.lib.LLVMPY_module_AddStripDeadPrototypesPass.argtypes = [
|
|
813
|
+
ffi.LLVMModulePassManagerRef, ]
|
|
814
|
+
|
|
815
|
+
ffi.lib.LLVMPY_module_AddStripDebugDeclarePass.argtypes = [
|
|
816
|
+
ffi.LLVMModulePassManagerRef, ]
|
|
817
|
+
|
|
818
|
+
ffi.lib.LLVMPY_module_AddStripNonDebugSymbolsPass.argtypes = [
|
|
819
|
+
ffi.LLVMModulePassManagerRef, ]
|
|
820
|
+
|
|
821
|
+
ffi.lib.LLVMPY_module_AddArgumentPromotionPass.argtypes = [
|
|
822
|
+
ffi.LLVMModulePassManagerRef, ]
|
|
823
|
+
|
|
824
|
+
ffi.lib.LLVMPY_module_AddPostOrderFunctionAttrsPass.argtypes = [
|
|
825
|
+
ffi.LLVMModulePassManagerRef, ]
|
|
826
|
+
|
|
827
|
+
ffi.lib.LLVMPY_DisposeNewModulePassManger.argtypes = [
|
|
828
|
+
ffi.LLVMModulePassManagerRef,]
|
|
829
|
+
|
|
830
|
+
ffi.lib.LLVMPY_AddRefPrunePass_module.argtypes = [
|
|
831
|
+
ffi.LLVMModulePassManagerRef, c_int, c_size_t,
|
|
832
|
+
]
|
|
833
|
+
|
|
834
|
+
# FunctionPassManager
|
|
835
|
+
|
|
836
|
+
ffi.lib.LLVMPY_CreateNewFunctionPassManager.restype = \
|
|
837
|
+
ffi.LLVMFunctionPassManagerRef
|
|
838
|
+
|
|
839
|
+
ffi.lib.LLVMPY_RunNewFunctionPassManager.argtypes = [
|
|
840
|
+
ffi.LLVMFunctionPassManagerRef, ffi.LLVMValueRef,
|
|
841
|
+
ffi.LLVMPassBuilderRef,]
|
|
842
|
+
|
|
843
|
+
ffi.lib.LLVMPY_function_AddAAEvaluator.argtypes = [
|
|
844
|
+
ffi.LLVMFunctionPassManagerRef,]
|
|
845
|
+
|
|
846
|
+
ffi.lib.LLVMPY_function_AddSimplifyCFGPass.argtypes = [
|
|
847
|
+
ffi.LLVMFunctionPassManagerRef,]
|
|
848
|
+
|
|
849
|
+
ffi.lib.LLVMPY_function_AddLoopUnrollPass.argtypes = [
|
|
850
|
+
ffi.LLVMFunctionPassManagerRef,]
|
|
851
|
+
|
|
852
|
+
ffi.lib.LLVMPY_function_AddInstCombinePass.argtypes = [
|
|
853
|
+
ffi.LLVMFunctionPassManagerRef,]
|
|
854
|
+
|
|
855
|
+
ffi.lib.LLVMPY_AddJumpThreadingPass_function.argtypes = [
|
|
856
|
+
ffi.LLVMFunctionPassManagerRef, c_int,]
|
|
857
|
+
|
|
858
|
+
ffi.lib.LLVMPY_function_AddCFGPrinterPass.argtypes = [
|
|
859
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
860
|
+
|
|
861
|
+
ffi.lib.LLVMPY_function_AddCFGOnlyPrinterPass.argtypes = [
|
|
862
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
863
|
+
|
|
864
|
+
ffi.lib.LLVMPY_function_AddDomPrinter.argtypes = [
|
|
865
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
866
|
+
|
|
867
|
+
ffi.lib.LLVMPY_function_AddDomOnlyPrinter.argtypes = [
|
|
868
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
869
|
+
|
|
870
|
+
ffi.lib.LLVMPY_function_AddPostDomPrinter.argtypes = [
|
|
871
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
872
|
+
|
|
873
|
+
ffi.lib.LLVMPY_function_AddPostDomOnlyPrinter.argtypes = [
|
|
874
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
875
|
+
|
|
876
|
+
ffi.lib.LLVMPY_function_AddDomViewer.argtypes = [
|
|
877
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
878
|
+
|
|
879
|
+
ffi.lib.LLVMPY_function_AddDomOnlyViewer.argtypes = [
|
|
880
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
881
|
+
|
|
882
|
+
ffi.lib.LLVMPY_function_AddPostDomViewer.argtypes = [
|
|
883
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
884
|
+
|
|
885
|
+
ffi.lib.LLVMPY_function_AddPostDomOnlyViewer.argtypes = [
|
|
886
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
887
|
+
|
|
888
|
+
ffi.lib.LLVMPY_function_AddLintPass.argtypes = [
|
|
889
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
890
|
+
|
|
891
|
+
ffi.lib.LLVMPY_function_AddADCEPass.argtypes = [
|
|
892
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
893
|
+
|
|
894
|
+
ffi.lib.LLVMPY_function_AddBreakCriticalEdgesPass.argtypes = [
|
|
895
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
896
|
+
|
|
897
|
+
ffi.lib.LLVMPY_function_AddDSEPass.argtypes = [
|
|
898
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
899
|
+
|
|
900
|
+
ffi.lib.LLVMPY_function_AddDCEPass.argtypes = [
|
|
901
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
902
|
+
|
|
903
|
+
ffi.lib.LLVMPY_function_AddAggressiveInstCombinePass.argtypes = [
|
|
904
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
905
|
+
|
|
906
|
+
ffi.lib.LLVMPY_function_AddLCSSAPass.argtypes = [
|
|
907
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
908
|
+
|
|
909
|
+
ffi.lib.LLVMPY_function_AddNewGVNPass.argtypes = [
|
|
910
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
911
|
+
|
|
912
|
+
ffi.lib.LLVMPY_function_AddLoopSimplifyPass.argtypes = [
|
|
913
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
914
|
+
|
|
915
|
+
ffi.lib.LLVMPY_function_AddLoopUnrollAndJamPass.argtypes = [
|
|
916
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
917
|
+
|
|
918
|
+
ffi.lib.LLVMPY_function_AddSCCPPass.argtypes = [
|
|
919
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
920
|
+
|
|
921
|
+
ffi.lib.LLVMPY_function_AddLowerAtomicPass.argtypes = [
|
|
922
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
923
|
+
|
|
924
|
+
ffi.lib.LLVMPY_function_AddLowerInvokePass.argtypes = [
|
|
925
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
926
|
+
|
|
927
|
+
ffi.lib.LLVMPY_function_AddLowerSwitchPass.argtypes = [
|
|
928
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
929
|
+
|
|
930
|
+
ffi.lib.LLVMPY_function_AddMemCpyOptPass.argtypes = [
|
|
931
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
932
|
+
|
|
933
|
+
ffi.lib.LLVMPY_function_AddUnifyFunctionExitNodesPass.argtypes = [
|
|
934
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
935
|
+
|
|
936
|
+
ffi.lib.LLVMPY_function_AddReassociatePass.argtypes = [
|
|
937
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
938
|
+
|
|
939
|
+
ffi.lib.LLVMPY_function_AddRegToMemPass.argtypes = [
|
|
940
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
941
|
+
|
|
942
|
+
ffi.lib.LLVMPY_function_AddSROAPass.argtypes = [
|
|
943
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
944
|
+
|
|
945
|
+
ffi.lib.LLVMPY_function_AddSinkingPass.argtypes = [
|
|
946
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
947
|
+
|
|
948
|
+
ffi.lib.LLVMPY_function_AddTailCallElimPass.argtypes = [
|
|
949
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
950
|
+
|
|
951
|
+
ffi.lib.LLVMPY_function_AddInstructionNamerPass.argtypes = [
|
|
952
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
953
|
+
|
|
954
|
+
ffi.lib.LLVMPY_function_AddLoopRotatePass.argtypes = [
|
|
955
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
956
|
+
|
|
957
|
+
ffi.lib.LLVMPY_function_AddLoopDeletionPass.argtypes = [
|
|
958
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
959
|
+
|
|
960
|
+
ffi.lib.LLVMPY_function_AddLoopStrengthReducePass.argtypes = [
|
|
961
|
+
ffi.LLVMFunctionPassManagerRef, ]
|
|
962
|
+
|
|
963
|
+
ffi.lib.LLVMPY_DisposeNewFunctionPassManger.argtypes = [
|
|
964
|
+
ffi.LLVMFunctionPassManagerRef,]
|
|
965
|
+
|
|
966
|
+
ffi.lib.LLVMPY_AddRefPrunePass_function.argtypes = [
|
|
967
|
+
ffi.LLVMFunctionPassManagerRef, c_int, c_size_t,
|
|
968
|
+
]
|
|
969
|
+
|
|
970
|
+
# PipelineTuningOptions
|
|
971
|
+
|
|
972
|
+
ffi.lib.LLVMPY_CreatePipelineTuningOptions.restype = \
|
|
973
|
+
ffi.LLVMPipelineTuningOptionsRef
|
|
974
|
+
|
|
975
|
+
ffi.lib.LLVMPY_PTOGetLoopInterleaving.restype = c_bool
|
|
976
|
+
ffi.lib.LLVMPY_PTOGetLoopInterleaving.argtypes = [
|
|
977
|
+
ffi.LLVMPipelineTuningOptionsRef,]
|
|
978
|
+
|
|
979
|
+
ffi.lib.LLVMPY_PTOSetLoopInterleaving.argtypes = [
|
|
980
|
+
ffi.LLVMPipelineTuningOptionsRef, c_bool]
|
|
981
|
+
|
|
982
|
+
ffi.lib.LLVMPY_PTOGetLoopVectorization.restype = c_bool
|
|
983
|
+
ffi.lib.LLVMPY_PTOGetLoopVectorization.argtypes = [
|
|
984
|
+
ffi.LLVMPipelineTuningOptionsRef,]
|
|
985
|
+
|
|
986
|
+
ffi.lib.LLVMPY_PTOSetLoopVectorization.argtypes = [
|
|
987
|
+
ffi.LLVMPipelineTuningOptionsRef, c_bool]
|
|
988
|
+
|
|
989
|
+
ffi.lib.LLVMPY_PTOGetSLPVectorization.restype = c_bool
|
|
990
|
+
ffi.lib.LLVMPY_PTOGetSLPVectorization.argtypes = [
|
|
991
|
+
ffi.LLVMPipelineTuningOptionsRef,]
|
|
992
|
+
|
|
993
|
+
ffi.lib.LLVMPY_PTOSetSLPVectorization.argtypes = [
|
|
994
|
+
ffi.LLVMPipelineTuningOptionsRef, c_bool]
|
|
995
|
+
|
|
996
|
+
ffi.lib.LLVMPY_PTOGetLoopUnrolling.restype = c_bool
|
|
997
|
+
ffi.lib.LLVMPY_PTOGetLoopUnrolling.argtypes = [
|
|
998
|
+
ffi.LLVMPipelineTuningOptionsRef,]
|
|
999
|
+
|
|
1000
|
+
ffi.lib.LLVMPY_PTOSetLoopUnrolling.argtypes = [
|
|
1001
|
+
ffi.LLVMPipelineTuningOptionsRef, c_bool]
|
|
1002
|
+
|
|
1003
|
+
ffi.lib.LLVMPY_PTOGetInlinerThreshold.restype = c_int
|
|
1004
|
+
|
|
1005
|
+
ffi.lib.LLVMPY_PTOSetInlinerThreshold.argtypes = [
|
|
1006
|
+
ffi.LLVMPipelineTuningOptionsRef, c_int]
|
|
1007
|
+
|
|
1008
|
+
ffi.lib.LLVMPY_DisposePipelineTuningOptions.argtypes = \
|
|
1009
|
+
[ffi.LLVMPipelineTuningOptionsRef,]
|
|
1010
|
+
|
|
1011
|
+
# PassBuilder
|
|
1012
|
+
|
|
1013
|
+
ffi.lib.LLVMPY_CreatePassBuilder.restype = ffi.LLVMPassBuilderRef
|
|
1014
|
+
ffi.lib.LLVMPY_CreatePassBuilder.argtypes = [
|
|
1015
|
+
ffi.LLVMTargetMachineRef,
|
|
1016
|
+
ffi.LLVMPipelineTuningOptionsRef,
|
|
1017
|
+
]
|
|
1018
|
+
|
|
1019
|
+
ffi.lib.LLVMPY_DisposePassBuilder.argtypes = [ffi.LLVMPassBuilderRef,]
|
|
1020
|
+
|
|
1021
|
+
ffi.lib.LLVMPY_CreateTimePassesHandler.restype = \
|
|
1022
|
+
ffi.LLVMTimePassesHandlerRef
|
|
1023
|
+
|
|
1024
|
+
ffi.lib.LLVMPY_DisposeTimePassesHandler.argtypes = [
|
|
1025
|
+
ffi.LLVMTimePassesHandlerRef,]
|
|
1026
|
+
|
|
1027
|
+
ffi.lib.LLVMPY_EnableTimePasses.argtypes = [
|
|
1028
|
+
ffi.LLVMPassBuilderRef,
|
|
1029
|
+
ffi.LLVMTimePassesHandlerRef,
|
|
1030
|
+
]
|
|
1031
|
+
|
|
1032
|
+
ffi.lib.LLVMPY_ReportAndDisableTimePasses.argtypes = [
|
|
1033
|
+
ffi.LLVMTimePassesHandlerRef,
|
|
1034
|
+
POINTER(c_char_p),
|
|
1035
|
+
]
|
|
1036
|
+
|
|
1037
|
+
# Pipeline builders
|
|
1038
|
+
|
|
1039
|
+
ffi.lib.LLVMPY_buildPerModuleDefaultPipeline.restype = \
|
|
1040
|
+
ffi.LLVMModulePassManagerRef
|
|
1041
|
+
|
|
1042
|
+
ffi.lib.LLVMPY_buildPerModuleDefaultPipeline.argtypes = [
|
|
1043
|
+
ffi.LLVMPassBuilderRef, c_int, c_int]
|
|
1044
|
+
|
|
1045
|
+
ffi.lib.LLVMPY_buildFunctionSimplificationPipeline.restype = \
|
|
1046
|
+
ffi.LLVMFunctionPassManagerRef
|
|
1047
|
+
|
|
1048
|
+
ffi.lib.LLVMPY_buildFunctionSimplificationPipeline.argtypes = [
|
|
1049
|
+
ffi.LLVMPassBuilderRef, c_int, c_int]
|