ruby-llvm 3.5.0 → 13.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +21 -4
- data/ext/ruby-llvm-support/Rakefile +17 -6
- data/lib/llvm/analysis.rb +2 -0
- data/lib/llvm/analysis_ffi.rb +27 -28
- data/lib/llvm/config.rb +4 -4
- data/lib/llvm/core/bitcode.rb +12 -10
- data/lib/llvm/core/bitcode_ffi.rb +89 -65
- data/lib/llvm/core/builder.rb +4 -3
- data/lib/llvm/core/context.rb +3 -1
- data/lib/llvm/core/module.rb +2 -0
- data/lib/llvm/core/pass_manager.rb +6 -2
- data/lib/llvm/core/type.rb +9 -2
- data/lib/llvm/core/value.rb +154 -24
- data/lib/llvm/core.rb +47 -2
- data/lib/llvm/core_ffi.rb +3863 -3730
- data/lib/llvm/execution_engine.rb +39 -35
- data/lib/llvm/execution_engine_ffi.rb +238 -276
- data/lib/llvm/linker.rb +3 -14
- data/lib/llvm/linker_ffi.rb +22 -26
- data/lib/llvm/support.rb +2 -0
- data/lib/llvm/target.rb +11 -15
- data/lib/llvm/target_ffi.rb +301 -293
- data/lib/llvm/transforms/builder.rb +3 -1
- data/lib/llvm/transforms/builder_ffi.rb +57 -58
- data/lib/llvm/transforms/ipo.rb +3 -1
- data/lib/llvm/transforms/ipo_ffi.rb +59 -60
- data/lib/llvm/transforms/scalar.rb +12 -0
- data/lib/llvm/transforms/scalar_ffi.rb +199 -143
- data/lib/llvm/transforms/vectorize.rb +2 -0
- data/lib/llvm/transforms/vectorize_ffi.rb +15 -16
- data/lib/llvm/version.rb +5 -2
- data/lib/llvm.rb +2 -0
- data/test/array_test.rb +2 -0
- data/test/basic_block_test.rb +2 -1
- data/test/binary_operations_test.rb +2 -0
- data/test/bitcode_test.rb +3 -2
- data/test/branch_test.rb +2 -0
- data/test/call_test.rb +3 -1
- data/test/comparisons_test.rb +2 -0
- data/test/conversions_test.rb +2 -0
- data/test/double_test.rb +10 -7
- data/test/equality_test.rb +4 -4
- data/test/function_test.rb +29 -0
- data/test/generic_value_test.rb +3 -1
- data/test/instruction_test.rb +2 -2
- data/test/integer_test.rb +28 -0
- data/test/ipo_test.rb +3 -1
- data/test/linker_test.rb +2 -9
- data/test/mcjit_test.rb +11 -3
- data/test/memory_access_test.rb +2 -0
- data/test/module_test.rb +18 -1
- data/test/parameter_collection_test.rb +2 -0
- data/test/pass_manager_builder_test.rb +22 -2
- data/test/phi_test.rb +2 -0
- data/test/select_test.rb +2 -0
- data/test/struct_test.rb +2 -0
- data/test/target_test.rb +16 -20
- data/test/test_helper.rb +6 -1
- data/test/type_test.rb +47 -0
- data/test/vector_test.rb +2 -0
- metadata +105 -40
@@ -4,285 +4,341 @@ require 'ffi'
|
|
4
4
|
|
5
5
|
module LLVM::C
|
6
6
|
extend FFI::Library
|
7
|
-
ffi_lib ["libLLVM-
|
8
|
-
|
7
|
+
ffi_lib ["libLLVM-13.so.1", "libLLVM.so.13", "LLVM-13"]
|
8
|
+
|
9
9
|
def self.attach_function(name, *_)
|
10
10
|
begin; super; rescue FFI::NotFoundError => e
|
11
11
|
(class << self; self; end).class_eval { define_method(name) { |*_| raise e } }
|
12
12
|
end
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
# See llvm::createAggressiveDCEPass function.
|
16
|
-
#
|
16
|
+
#
|
17
17
|
# @method add_aggressive_dce_pass(pm)
|
18
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
19
|
-
# @return [nil]
|
18
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
19
|
+
# @return [nil]
|
20
20
|
# @scope class
|
21
21
|
attach_function :add_aggressive_dce_pass, :LLVMAddAggressiveDCEPass, [:pointer], :void
|
22
|
-
|
22
|
+
|
23
|
+
# See llvm::createBitTrackingDCEPass function.
|
24
|
+
#
|
25
|
+
# @method add_bit_tracking_dce_pass(pm)
|
26
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
27
|
+
# @return [nil]
|
28
|
+
# @scope class
|
29
|
+
attach_function :add_bit_tracking_dce_pass, :LLVMAddBitTrackingDCEPass, [:pointer], :void
|
30
|
+
|
31
|
+
# See llvm::createAlignmentFromAssumptionsPass function.
|
32
|
+
#
|
33
|
+
# @method add_alignment_from_assumptions_pass(pm)
|
34
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
35
|
+
# @return [nil]
|
36
|
+
# @scope class
|
37
|
+
attach_function :add_alignment_from_assumptions_pass, :LLVMAddAlignmentFromAssumptionsPass, [:pointer], :void
|
38
|
+
|
23
39
|
# See llvm::createCFGSimplificationPass function.
|
24
|
-
#
|
40
|
+
#
|
25
41
|
# @method add_cfg_simplification_pass(pm)
|
26
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
27
|
-
# @return [nil]
|
42
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
43
|
+
# @return [nil]
|
28
44
|
# @scope class
|
29
45
|
attach_function :add_cfg_simplification_pass, :LLVMAddCFGSimplificationPass, [:pointer], :void
|
30
|
-
|
46
|
+
|
47
|
+
# See llvm::createLateCFGSimplificationPass function.
|
48
|
+
#
|
49
|
+
# @method add_late_cfg_simplification_pass(pm)
|
50
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
51
|
+
# @return [nil]
|
52
|
+
# @scope class
|
53
|
+
attach_function :add_late_cfg_simplification_pass, :LLVMAddLateCFGSimplificationPass, [:pointer], :void
|
54
|
+
|
31
55
|
# See llvm::createDeadStoreEliminationPass function.
|
32
|
-
#
|
56
|
+
#
|
33
57
|
# @method add_dead_store_elimination_pass(pm)
|
34
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
35
|
-
# @return [nil]
|
58
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
59
|
+
# @return [nil]
|
36
60
|
# @scope class
|
37
61
|
attach_function :add_dead_store_elimination_pass, :LLVMAddDeadStoreEliminationPass, [:pointer], :void
|
38
|
-
|
62
|
+
|
39
63
|
# See llvm::createScalarizerPass function.
|
40
|
-
#
|
64
|
+
#
|
41
65
|
# @method add_scalarizer_pass(pm)
|
42
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
43
|
-
# @return [nil]
|
66
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
67
|
+
# @return [nil]
|
44
68
|
# @scope class
|
45
69
|
attach_function :add_scalarizer_pass, :LLVMAddScalarizerPass, [:pointer], :void
|
46
|
-
|
70
|
+
|
47
71
|
# See llvm::createMergedLoadStoreMotionPass function.
|
48
|
-
#
|
72
|
+
#
|
49
73
|
# @method add_merged_load_store_motion_pass(pm)
|
50
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
51
|
-
# @return [nil]
|
74
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
75
|
+
# @return [nil]
|
52
76
|
# @scope class
|
53
77
|
attach_function :add_merged_load_store_motion_pass, :LLVMAddMergedLoadStoreMotionPass, [:pointer], :void
|
54
|
-
|
78
|
+
|
55
79
|
# See llvm::createGVNPass function.
|
56
|
-
#
|
80
|
+
#
|
57
81
|
# @method add_gvn_pass(pm)
|
58
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
59
|
-
# @return [nil]
|
82
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
83
|
+
# @return [nil]
|
60
84
|
# @scope class
|
61
85
|
attach_function :add_gvn_pass, :LLVMAddGVNPass, [:pointer], :void
|
62
|
-
|
86
|
+
|
87
|
+
# See llvm::createGVNPass function.
|
88
|
+
#
|
89
|
+
# @method add_new_gvn_pass(pm)
|
90
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
91
|
+
# @return [nil]
|
92
|
+
# @scope class
|
93
|
+
attach_function :add_new_gvn_pass, :LLVMAddNewGVNPass, [:pointer], :void
|
94
|
+
|
63
95
|
# See llvm::createIndVarSimplifyPass function.
|
64
|
-
#
|
96
|
+
#
|
65
97
|
# @method add_ind_var_simplify_pass(pm)
|
66
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
67
|
-
# @return [nil]
|
98
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
99
|
+
# @return [nil]
|
68
100
|
# @scope class
|
69
101
|
attach_function :add_ind_var_simplify_pass, :LLVMAddIndVarSimplifyPass, [:pointer], :void
|
70
|
-
|
102
|
+
|
71
103
|
# See llvm::createInstructionCombiningPass function.
|
72
|
-
#
|
104
|
+
#
|
73
105
|
# @method add_instruction_combining_pass(pm)
|
74
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
75
|
-
# @return [nil]
|
106
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
107
|
+
# @return [nil]
|
76
108
|
# @scope class
|
77
109
|
attach_function :add_instruction_combining_pass, :LLVMAddInstructionCombiningPass, [:pointer], :void
|
78
|
-
|
110
|
+
|
79
111
|
# See llvm::createJumpThreadingPass function.
|
80
|
-
#
|
112
|
+
#
|
81
113
|
# @method add_jump_threading_pass(pm)
|
82
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
83
|
-
# @return [nil]
|
114
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
115
|
+
# @return [nil]
|
84
116
|
# @scope class
|
85
117
|
attach_function :add_jump_threading_pass, :LLVMAddJumpThreadingPass, [:pointer], :void
|
86
|
-
|
118
|
+
|
87
119
|
# See llvm::createLICMPass function.
|
88
|
-
#
|
120
|
+
#
|
89
121
|
# @method add_licm_pass(pm)
|
90
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
91
|
-
# @return [nil]
|
122
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
123
|
+
# @return [nil]
|
92
124
|
# @scope class
|
93
125
|
attach_function :add_licm_pass, :LLVMAddLICMPass, [:pointer], :void
|
94
|
-
|
126
|
+
|
95
127
|
# See llvm::createLoopDeletionPass function.
|
96
|
-
#
|
128
|
+
#
|
97
129
|
# @method add_loop_deletion_pass(pm)
|
98
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
99
|
-
# @return [nil]
|
130
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
131
|
+
# @return [nil]
|
100
132
|
# @scope class
|
101
133
|
attach_function :add_loop_deletion_pass, :LLVMAddLoopDeletionPass, [:pointer], :void
|
102
|
-
|
134
|
+
|
103
135
|
# See llvm::createLoopIdiomPass function
|
104
|
-
#
|
136
|
+
#
|
105
137
|
# @method add_loop_idiom_pass(pm)
|
106
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
107
|
-
# @return [nil]
|
138
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
139
|
+
# @return [nil]
|
108
140
|
# @scope class
|
109
141
|
attach_function :add_loop_idiom_pass, :LLVMAddLoopIdiomPass, [:pointer], :void
|
110
|
-
|
142
|
+
|
111
143
|
# See llvm::createLoopRotatePass function.
|
112
|
-
#
|
144
|
+
#
|
113
145
|
# @method add_loop_rotate_pass(pm)
|
114
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
115
|
-
# @return [nil]
|
146
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
147
|
+
# @return [nil]
|
116
148
|
# @scope class
|
117
149
|
attach_function :add_loop_rotate_pass, :LLVMAddLoopRotatePass, [:pointer], :void
|
118
|
-
|
150
|
+
|
119
151
|
# See llvm::createLoopRerollPass function.
|
120
|
-
#
|
152
|
+
#
|
121
153
|
# @method add_loop_reroll_pass(pm)
|
122
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
123
|
-
# @return [nil]
|
154
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
155
|
+
# @return [nil]
|
124
156
|
# @scope class
|
125
157
|
attach_function :add_loop_reroll_pass, :LLVMAddLoopRerollPass, [:pointer], :void
|
126
|
-
|
158
|
+
|
127
159
|
# See llvm::createLoopUnrollPass function.
|
128
|
-
#
|
160
|
+
#
|
129
161
|
# @method add_loop_unroll_pass(pm)
|
130
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
131
|
-
# @return [nil]
|
162
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
163
|
+
# @return [nil]
|
132
164
|
# @scope class
|
133
165
|
attach_function :add_loop_unroll_pass, :LLVMAddLoopUnrollPass, [:pointer], :void
|
134
|
-
|
166
|
+
|
135
167
|
# See llvm::createLoopUnswitchPass function.
|
136
|
-
#
|
168
|
+
#
|
137
169
|
# @method add_loop_unswitch_pass(pm)
|
138
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
139
|
-
# @return [nil]
|
170
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
171
|
+
# @return [nil]
|
140
172
|
# @scope class
|
141
173
|
attach_function :add_loop_unswitch_pass, :LLVMAddLoopUnswitchPass, [:pointer], :void
|
142
|
-
|
174
|
+
|
143
175
|
# See llvm::createMemCpyOptPass function.
|
144
|
-
#
|
176
|
+
#
|
145
177
|
# @method add_mem_cpy_opt_pass(pm)
|
146
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
147
|
-
# @return [nil]
|
178
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
179
|
+
# @return [nil]
|
148
180
|
# @scope class
|
149
181
|
attach_function :add_mem_cpy_opt_pass, :LLVMAddMemCpyOptPass, [:pointer], :void
|
150
|
-
|
182
|
+
|
151
183
|
# See llvm::createPartiallyInlineLibCallsPass function.
|
152
|
-
#
|
184
|
+
#
|
153
185
|
# @method add_partially_inline_lib_calls_pass(pm)
|
154
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
155
|
-
# @return [nil]
|
186
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
187
|
+
# @return [nil]
|
156
188
|
# @scope class
|
157
189
|
attach_function :add_partially_inline_lib_calls_pass, :LLVMAddPartiallyInlineLibCallsPass, [:pointer], :void
|
158
|
-
|
190
|
+
|
191
|
+
# See llvm::createLowerSwitchPass function.
|
192
|
+
#
|
193
|
+
# @method add_lower_switch_pass(pm)
|
194
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
195
|
+
# @return [nil]
|
196
|
+
# @scope class
|
197
|
+
attach_function :add_lower_switch_pass, :LLVMAddLowerSwitchPass, [:pointer], :void
|
198
|
+
|
159
199
|
# See llvm::createPromoteMemoryToRegisterPass function.
|
160
|
-
#
|
200
|
+
#
|
161
201
|
# @method add_promote_memory_to_register_pass(pm)
|
162
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
163
|
-
# @return [nil]
|
202
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
203
|
+
# @return [nil]
|
164
204
|
# @scope class
|
165
205
|
attach_function :add_promote_memory_to_register_pass, :LLVMAddPromoteMemoryToRegisterPass, [:pointer], :void
|
166
|
-
|
206
|
+
|
167
207
|
# See llvm::createReassociatePass function.
|
168
|
-
#
|
208
|
+
#
|
169
209
|
# @method add_reassociate_pass(pm)
|
170
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
171
|
-
# @return [nil]
|
210
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
211
|
+
# @return [nil]
|
172
212
|
# @scope class
|
173
213
|
attach_function :add_reassociate_pass, :LLVMAddReassociatePass, [:pointer], :void
|
174
|
-
|
214
|
+
|
175
215
|
# See llvm::createSCCPPass function.
|
176
|
-
#
|
216
|
+
#
|
177
217
|
# @method add_sccp_pass(pm)
|
178
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
179
|
-
# @return [nil]
|
218
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
219
|
+
# @return [nil]
|
180
220
|
# @scope class
|
181
221
|
attach_function :add_sccp_pass, :LLVMAddSCCPPass, [:pointer], :void
|
182
|
-
|
183
|
-
# See llvm::
|
184
|
-
#
|
222
|
+
|
223
|
+
# See llvm::createSROAPass function.
|
224
|
+
#
|
185
225
|
# @method add_scalar_repl_aggregates_pass(pm)
|
186
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
187
|
-
# @return [nil]
|
226
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
227
|
+
# @return [nil]
|
188
228
|
# @scope class
|
189
229
|
attach_function :add_scalar_repl_aggregates_pass, :LLVMAddScalarReplAggregatesPass, [:pointer], :void
|
190
|
-
|
191
|
-
# See llvm::
|
192
|
-
#
|
230
|
+
|
231
|
+
# See llvm::createSROAPass function.
|
232
|
+
#
|
193
233
|
# @method add_scalar_repl_aggregates_pass_ssa(pm)
|
194
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
195
|
-
# @return [nil]
|
234
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
235
|
+
# @return [nil]
|
196
236
|
# @scope class
|
197
237
|
attach_function :add_scalar_repl_aggregates_pass_ssa, :LLVMAddScalarReplAggregatesPassSSA, [:pointer], :void
|
198
|
-
|
199
|
-
# See llvm::
|
200
|
-
#
|
238
|
+
|
239
|
+
# See llvm::createSROAPass function.
|
240
|
+
#
|
201
241
|
# @method add_scalar_repl_aggregates_pass_with_threshold(pm, threshold)
|
202
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
203
|
-
# @param [Integer] threshold
|
204
|
-
# @return [nil]
|
242
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
243
|
+
# @param [Integer] threshold
|
244
|
+
# @return [nil]
|
205
245
|
# @scope class
|
206
246
|
attach_function :add_scalar_repl_aggregates_pass_with_threshold, :LLVMAddScalarReplAggregatesPassWithThreshold, [:pointer, :int], :void
|
207
|
-
|
247
|
+
|
208
248
|
# See llvm::createSimplifyLibCallsPass function.
|
209
|
-
#
|
249
|
+
#
|
210
250
|
# @method add_simplify_lib_calls_pass(pm)
|
211
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
212
|
-
# @return [nil]
|
251
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
252
|
+
# @return [nil]
|
213
253
|
# @scope class
|
214
254
|
attach_function :add_simplify_lib_calls_pass, :LLVMAddSimplifyLibCallsPass, [:pointer], :void
|
215
|
-
|
255
|
+
|
216
256
|
# See llvm::createTailCallEliminationPass function.
|
217
|
-
#
|
257
|
+
#
|
218
258
|
# @method add_tail_call_elimination_pass(pm)
|
219
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
220
|
-
# @return [nil]
|
259
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
260
|
+
# @return [nil]
|
221
261
|
# @scope class
|
222
262
|
attach_function :add_tail_call_elimination_pass, :LLVMAddTailCallEliminationPass, [:pointer], :void
|
223
|
-
|
263
|
+
|
224
264
|
# See llvm::createConstantPropagationPass function.
|
225
|
-
#
|
265
|
+
#
|
226
266
|
# @method add_constant_propagation_pass(pm)
|
227
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
228
|
-
# @return [nil]
|
267
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
268
|
+
# @return [nil]
|
229
269
|
# @scope class
|
230
270
|
attach_function :add_constant_propagation_pass, :LLVMAddConstantPropagationPass, [:pointer], :void
|
231
|
-
|
271
|
+
|
232
272
|
# See llvm::demotePromoteMemoryToRegisterPass function.
|
233
|
-
#
|
273
|
+
#
|
234
274
|
# @method add_demote_memory_to_register_pass(pm)
|
235
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
236
|
-
# @return [nil]
|
275
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
276
|
+
# @return [nil]
|
237
277
|
# @scope class
|
238
278
|
attach_function :add_demote_memory_to_register_pass, :LLVMAddDemoteMemoryToRegisterPass, [:pointer], :void
|
239
|
-
|
279
|
+
|
240
280
|
# See llvm::createVerifierPass function.
|
241
|
-
#
|
281
|
+
#
|
242
282
|
# @method add_verifier_pass(pm)
|
243
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
244
|
-
# @return [nil]
|
283
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
284
|
+
# @return [nil]
|
245
285
|
# @scope class
|
246
286
|
attach_function :add_verifier_pass, :LLVMAddVerifierPass, [:pointer], :void
|
247
|
-
|
287
|
+
|
248
288
|
# See llvm::createCorrelatedValuePropagationPass function
|
249
|
-
#
|
289
|
+
#
|
250
290
|
# @method add_correlated_value_propagation_pass(pm)
|
251
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
252
|
-
# @return [nil]
|
291
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
292
|
+
# @return [nil]
|
253
293
|
# @scope class
|
254
294
|
attach_function :add_correlated_value_propagation_pass, :LLVMAddCorrelatedValuePropagationPass, [:pointer], :void
|
255
|
-
|
295
|
+
|
256
296
|
# See llvm::createEarlyCSEPass function
|
257
|
-
#
|
297
|
+
#
|
258
298
|
# @method add_early_cse_pass(pm)
|
259
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
260
|
-
# @return [nil]
|
299
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
300
|
+
# @return [nil]
|
261
301
|
# @scope class
|
262
302
|
attach_function :add_early_cse_pass, :LLVMAddEarlyCSEPass, [:pointer], :void
|
263
|
-
|
303
|
+
|
304
|
+
# See llvm::createEarlyCSEPass function
|
305
|
+
#
|
306
|
+
# @method add_early_cse_mem_ssa_pass(pm)
|
307
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
308
|
+
# @return [nil]
|
309
|
+
# @scope class
|
310
|
+
attach_function :add_early_cse_mem_ssa_pass, :LLVMAddEarlyCSEMemSSAPass, [:pointer], :void
|
311
|
+
|
264
312
|
# See llvm::createLowerExpectIntrinsicPass function
|
265
|
-
#
|
313
|
+
#
|
266
314
|
# @method add_lower_expect_intrinsic_pass(pm)
|
267
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
268
|
-
# @return [nil]
|
315
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
316
|
+
# @return [nil]
|
269
317
|
# @scope class
|
270
318
|
attach_function :add_lower_expect_intrinsic_pass, :LLVMAddLowerExpectIntrinsicPass, [:pointer], :void
|
271
|
-
|
319
|
+
|
272
320
|
# See llvm::createTypeBasedAliasAnalysisPass function
|
273
|
-
#
|
321
|
+
#
|
274
322
|
# @method add_type_based_alias_analysis_pass(pm)
|
275
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
276
|
-
# @return [nil]
|
323
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
324
|
+
# @return [nil]
|
277
325
|
# @scope class
|
278
326
|
attach_function :add_type_based_alias_analysis_pass, :LLVMAddTypeBasedAliasAnalysisPass, [:pointer], :void
|
279
|
-
|
327
|
+
|
328
|
+
# See llvm::createScopedNoAliasAAPass function
|
329
|
+
#
|
330
|
+
# @method add_scoped_no_alias_aa_pass(pm)
|
331
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
332
|
+
# @return [nil]
|
333
|
+
# @scope class
|
334
|
+
attach_function :add_scoped_no_alias_aa_pass, :LLVMAddScopedNoAliasAAPass, [:pointer], :void
|
335
|
+
|
280
336
|
# See llvm::createBasicAliasAnalysisPass function
|
281
|
-
#
|
337
|
+
#
|
282
338
|
# @method add_basic_alias_analysis_pass(pm)
|
283
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
284
|
-
# @return [nil]
|
339
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
340
|
+
# @return [nil]
|
285
341
|
# @scope class
|
286
342
|
attach_function :add_basic_alias_analysis_pass, :LLVMAddBasicAliasAnalysisPass, [:pointer], :void
|
287
|
-
|
343
|
+
|
288
344
|
end
|
@@ -4,36 +4,35 @@ require 'ffi'
|
|
4
4
|
|
5
5
|
module LLVM::C
|
6
6
|
extend FFI::Library
|
7
|
-
ffi_lib ["libLLVM-
|
8
|
-
|
7
|
+
ffi_lib ["libLLVM-13.so.1", "libLLVM.so.13", "LLVM-13"]
|
8
|
+
|
9
9
|
def self.attach_function(name, *_)
|
10
10
|
begin; super; rescue FFI::NotFoundError => e
|
11
11
|
(class << self; self; end).class_eval { define_method(name) { |*_| raise e } }
|
12
12
|
end
|
13
13
|
end
|
14
|
-
|
15
|
-
#
|
16
|
-
#
|
14
|
+
|
15
|
+
# DEPRECATED - Use LLVMAddSLPVectorizePass
|
16
|
+
#
|
17
17
|
# @method add_bb_vectorize_pass(pm)
|
18
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
19
|
-
# @return [nil]
|
18
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
19
|
+
# @return [nil]
|
20
20
|
# @scope class
|
21
21
|
attach_function :add_bb_vectorize_pass, :LLVMAddBBVectorizePass, [:pointer], :void
|
22
|
-
|
22
|
+
|
23
23
|
# See llvm::createLoopVectorizePass function.
|
24
|
-
#
|
24
|
+
#
|
25
25
|
# @method add_loop_vectorize_pass(pm)
|
26
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
27
|
-
# @return [nil]
|
26
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
27
|
+
# @return [nil]
|
28
28
|
# @scope class
|
29
29
|
attach_function :add_loop_vectorize_pass, :LLVMAddLoopVectorizePass, [:pointer], :void
|
30
|
-
|
30
|
+
|
31
31
|
# See llvm::createSLPVectorizerPass function.
|
32
|
-
#
|
32
|
+
#
|
33
33
|
# @method add_slp_vectorize_pass(pm)
|
34
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
35
|
-
# @return [nil]
|
34
|
+
# @param [FFI::Pointer(PassManagerRef)] pm
|
35
|
+
# @return [nil]
|
36
36
|
# @scope class
|
37
37
|
attach_function :add_slp_vectorize_pass, :LLVMAddSLPVectorizePass, [:pointer], :void
|
38
|
-
|
39
38
|
end
|
data/lib/llvm/version.rb
CHANGED
data/lib/llvm.rb
CHANGED
data/test/array_test.rb
CHANGED
data/test/basic_block_test.rb
CHANGED
data/test/bitcode_test.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "test_helper"
|
2
4
|
require "tempfile"
|
3
5
|
|
@@ -8,8 +10,7 @@ class BitcodeTestCase < Minitest::Test
|
|
8
10
|
|
9
11
|
def test_bitcode
|
10
12
|
test_module = define_module("test_module") do |mod|
|
11
|
-
define_function(mod, "test_function", [], LLVM::Int) do
|
12
|
-
|builder, function, *arguments|
|
13
|
+
define_function(mod, "test_function", [], LLVM::Int) do |builder, function, *arguments|
|
13
14
|
entry = function.basic_blocks.append
|
14
15
|
builder.position_at_end(entry)
|
15
16
|
builder.ret(LLVM::Int(1))
|
data/test/branch_test.rb
CHANGED
data/test/call_test.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "test_helper"
|
2
4
|
|
3
5
|
class CallTestCase < Minitest::Test
|
@@ -60,7 +62,7 @@ class CallTestCase < Minitest::Test
|
|
60
62
|
builder.ret(builder.call(external, arguments.first))
|
61
63
|
end
|
62
64
|
end
|
63
|
-
assert_equal
|
65
|
+
assert_equal(-10.abs, run_function_on_module(test_module, "test_function", -10).to_i)
|
64
66
|
end
|
65
67
|
|
66
68
|
def test_external_string
|
data/test/comparisons_test.rb
CHANGED
data/test/conversions_test.rb
CHANGED
data/test/double_test.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "test_helper"
|
2
4
|
|
3
5
|
class DoubleTestCase < Minitest::Test
|
@@ -6,7 +8,7 @@ class DoubleTestCase < Minitest::Test
|
|
6
8
|
end
|
7
9
|
|
8
10
|
def test_double
|
9
|
-
mod
|
11
|
+
mod = LLVM::Module.new("Double Test")
|
10
12
|
mod.functions.add(:sin, [LLVM::Double], LLVM::Double)
|
11
13
|
|
12
14
|
builder = LLVM::Builder.new
|
@@ -20,14 +22,15 @@ class DoubleTestCase < Minitest::Test
|
|
20
22
|
builder.ret(builder.fadd(p0, LLVM::Double(1.0)))
|
21
23
|
end
|
22
24
|
|
23
|
-
engine = LLVM::
|
25
|
+
engine = LLVM::MCJITCompiler.new(mod)
|
24
26
|
|
25
|
-
arg
|
27
|
+
arg = 5.0
|
26
28
|
result = engine.run_function(mod.functions["test"], arg)
|
27
|
-
assert_equal arg+1, result.to_f(LLVM::Double)
|
29
|
+
assert_equal arg + 1, result.to_f(LLVM::Double)
|
28
30
|
|
29
|
-
|
30
|
-
|
31
|
-
|
31
|
+
# TODO: fix this
|
32
|
+
# assert_in_delta(Math.sin(1.0),
|
33
|
+
# engine.run_function(mod.functions["sin"], 1.0).to_f(LLVM::Double),
|
34
|
+
# 1e-10)
|
32
35
|
end
|
33
36
|
end
|