ruby-llvm 3.5.0 → 10.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +19 -4
  3. data/ext/ruby-llvm-support/Rakefile +15 -6
  4. data/lib/llvm/analysis_ffi.rb +27 -28
  5. data/lib/llvm/config.rb +4 -4
  6. data/lib/llvm/core.rb +45 -2
  7. data/lib/llvm/core/bitcode.rb +10 -10
  8. data/lib/llvm/core/bitcode_ffi.rb +89 -65
  9. data/lib/llvm/core/builder.rb +2 -3
  10. data/lib/llvm/core/context.rb +1 -1
  11. data/lib/llvm/core/pass_manager.rb +4 -2
  12. data/lib/llvm/core/type.rb +2 -2
  13. data/lib/llvm/core/value.rb +138 -24
  14. data/lib/llvm/core_ffi.rb +3863 -3730
  15. data/lib/llvm/execution_engine.rb +37 -35
  16. data/lib/llvm/execution_engine_ffi.rb +238 -276
  17. data/lib/llvm/linker.rb +1 -14
  18. data/lib/llvm/linker_ffi.rb +22 -26
  19. data/lib/llvm/target.rb +9 -15
  20. data/lib/llvm/target_ffi.rb +301 -293
  21. data/lib/llvm/transforms/builder.rb +1 -1
  22. data/lib/llvm/transforms/builder_ffi.rb +57 -58
  23. data/lib/llvm/transforms/ipo.rb +1 -1
  24. data/lib/llvm/transforms/ipo_ffi.rb +59 -60
  25. data/lib/llvm/transforms/scalar_ffi.rb +199 -143
  26. data/lib/llvm/transforms/vectorize_ffi.rb +15 -16
  27. data/lib/llvm/version.rb +3 -2
  28. data/test/basic_block_test.rb +0 -1
  29. data/test/bitcode_test.rb +1 -2
  30. data/test/call_test.rb +1 -1
  31. data/test/double_test.rb +8 -7
  32. data/test/equality_test.rb +2 -4
  33. data/test/function_test.rb +27 -0
  34. data/test/generic_value_test.rb +1 -1
  35. data/test/instruction_test.rb +0 -2
  36. data/test/ipo_test.rb +1 -1
  37. data/test/linker_test.rb +0 -9
  38. data/test/mcjit_test.rb +3 -3
  39. data/test/module_test.rb +16 -1
  40. data/test/pass_manager_builder_test.rb +1 -2
  41. data/test/target_test.rb +3 -20
  42. data/test/test_helper.rb +4 -1
  43. metadata +55 -37
@@ -25,8 +25,8 @@ module LLVM
25
25
  @ptr = ptr.read_pointer
26
26
  else
27
27
  C.dispose_message(error)
28
- error.autorelease=false
29
- raise RuntimeError, "Error creating JIT compiler: #{message}"
28
+ error.autorelease = false
29
+ raise "Error creating JIT compiler: #{message}"
30
30
  end
31
31
  end
32
32
  end
@@ -63,7 +63,7 @@ module LLVM
63
63
  def run_function(fun, *args)
64
64
  FFI::MemoryPointer.new(FFI.type_size(:pointer) * args.size) do |args_ptr|
65
65
  new_values = []
66
- args_ptr.write_array_of_pointer fun.params.zip(args).map { |p, a|
66
+ args_ptr.write_array_of_pointer(fun.params.zip(args).map do |p, a|
67
67
  if a.kind_of?(GenericValue)
68
68
  a
69
69
  else
@@ -71,7 +71,7 @@ module LLVM
71
71
  new_values << value
72
72
  value
73
73
  end
74
- }
74
+ end)
75
75
  result = LLVM::GenericValue.from_ptr(
76
76
  C.run_function(self, fun, args.size, args_ptr))
77
77
  new_values.each(&:dispose)
@@ -84,6 +84,10 @@ module LLVM
84
84
  C.get_pointer_to_global(self, global)
85
85
  end
86
86
 
87
+ def function_address(name)
88
+ C.get_function_address(self, name)
89
+ end
90
+
87
91
  # Returns a ModuleCollection of all the Modules in the engine.
88
92
  # @return [ModuleCollection]
89
93
  def modules
@@ -123,7 +127,7 @@ module LLVM
123
127
  message = errorp.read_string unless errorp.null?
124
128
 
125
129
  C.dispose_message(error)
126
- error.autorelease=false
130
+ error.autorelease = false
127
131
 
128
132
  raise "Error removing module: #{message}"
129
133
  end
@@ -166,35 +170,6 @@ module LLVM
166
170
  end
167
171
  end
168
172
 
169
- class JITCompiler < ExecutionEngine
170
- # Create a JIT execution engine.
171
- #
172
- # @note You should call `LLVM.init_jit` before creating an execution engine.
173
- #
174
- # @param [LLVM::Module] mod module
175
- # @param [Hash{Symbol => Object}] options options
176
- # @option options [Integer] :opt_level (3) Optimization level
177
- # @return [ExecutionEngine] Execution engine
178
- def initialize(mod, options = {})
179
- # Prior to ruby-llvm 3.4.0, signature is initialize(mod, opt_level = 3)
180
- if options.kind_of?(Integer)
181
- options = { :opt_level => options }
182
- end
183
-
184
- options = {
185
- :opt_level => 3,
186
- }.merge(options)
187
-
188
- super
189
- end
190
-
191
- protected
192
-
193
- def create_execution_engine_for_module(out_ee, mod, out_error, options)
194
- C.create_jit_compiler_for_module(out_ee, mod, options[:opt_level], out_error)
195
- end
196
- end
197
-
198
173
  class MCJITCompiler < ExecutionEngine
199
174
  # Create a MCJIT execution engine.
200
175
  #
@@ -211,7 +186,7 @@ module LLVM
211
186
  def initialize(mod, options = {})
212
187
  options = {
213
188
  :opt_level => 2, # LLVMCodeGenLevelDefault
214
- :code_model => 0, # LLVMCodeModelDefault
189
+ :code_model => 0,
215
190
  :no_frame_pointer_elim => false,
216
191
  :enable_fast_i_sel => false,
217
192
  # TODO
@@ -221,6 +196,31 @@ module LLVM
221
196
  super
222
197
  end
223
198
 
199
+ def convert_type(type)
200
+ case type.kind
201
+ when :integer
202
+ if type.width <= 8
203
+ :int8
204
+ else
205
+ "int#{type.width}".to_sym
206
+ end
207
+ else
208
+ type.kind
209
+ end
210
+ end
211
+
212
+ def run_function(fun, *args)
213
+ args2 = fun.params.map {|e| convert_type(e.type)}
214
+ ptr = FFI::Pointer.new(function_address(fun.name))
215
+ raise "Couldn't find function" if ptr.null?
216
+
217
+ return_type = convert_type(fun.function_type.return_type)
218
+ f = FFI::Function.new(return_type, args2, ptr)
219
+ ret1 = f.call(*args)
220
+ ret2 = LLVM.make_generic_value(fun.function_type.return_type, ret1)
221
+ ret2
222
+ end
223
+
224
224
  protected
225
225
 
226
226
  def create_execution_engine_for_module(out_ee, mod, out_error, options)
@@ -237,6 +237,8 @@ module LLVM
237
237
  end
238
238
  end
239
239
 
240
+ JITCompiler = MCJITCompiler
241
+
240
242
  class GenericValue
241
243
  # @private
242
244
  def to_ptr
@@ -4,66 +4,59 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib ["libLLVM-3.5.so.1", "LLVM-3.5"]
8
-
7
+ ffi_lib ["libLLVM-10.so.1", "LLVM-10"]
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
  # @defgroup LLVMCExecutionEngine Execution Engine
16
16
  # @ingroup LLVMC
17
- #
17
+ #
18
18
  # @{
19
- #
20
- # @method link_in_jit()
21
- # @return [nil]
22
- # @scope class
23
- attach_function :link_in_jit, :LLVMLinkInJIT, [], :void
24
-
25
- # (Not documented)
26
- #
19
+ #
27
20
  # @method link_in_mcjit()
28
- # @return [nil]
21
+ # @return [nil]
29
22
  # @scope class
30
23
  attach_function :link_in_mcjit, :LLVMLinkInMCJIT, [], :void
31
-
24
+
32
25
  # (Not documented)
33
- #
26
+ #
34
27
  # @method link_in_interpreter()
35
- # @return [nil]
28
+ # @return [nil]
36
29
  # @scope class
37
30
  attach_function :link_in_interpreter, :LLVMLinkInInterpreter, [], :void
38
-
31
+
39
32
  # (Not documented)
40
33
  class OpaqueGenericValue < FFI::Struct
41
34
  layout :dummy, :char
42
35
  end
43
-
36
+
44
37
  # (Not documented)
45
38
  class OpaqueExecutionEngine < FFI::Struct
46
39
  layout :dummy, :char
47
40
  end
48
-
41
+
49
42
  # (Not documented)
50
43
  class OpaqueMCJITMemoryManager < FFI::Struct
51
44
  layout :dummy, :char
52
45
  end
53
-
46
+
54
47
  # (Not documented)
55
- #
48
+ #
56
49
  # = Fields:
57
50
  # :opt_level ::
58
- # (Integer)
51
+ # (Integer)
59
52
  # :code_model ::
60
- # (unknown)
53
+ # (unknown)
61
54
  # :no_frame_pointer_elim ::
62
- # (Integer)
55
+ # (Integer)
63
56
  # :enable_fast_i_sel ::
64
- # (Integer)
57
+ # (Integer)
65
58
  # :mcjmm ::
66
- # (OpaqueMCJITMemoryManager)
59
+ # (OpaqueMCJITMemoryManager)
67
60
  class MCJITCompilerOptions < FFI::Struct
68
61
  layout :opt_level, :uint,
69
62
  :code_model, :char,
@@ -71,389 +64,358 @@ module LLVM::C
71
64
  :enable_fast_i_sel, :int,
72
65
  :mcjmm, OpaqueMCJITMemoryManager
73
66
  end
74
-
67
+
75
68
  # ===-- Operations on generic values --------------------------------------===
76
- #
69
+ #
77
70
  # @method create_generic_value_of_int(ty, n, is_signed)
78
- # @param [FFI::Pointer(TypeRef)] ty
79
- # @param [Integer] n
80
- # @param [Integer] is_signed
81
- # @return [OpaqueGenericValue]
71
+ # @param [FFI::Pointer(TypeRef)] ty
72
+ # @param [Integer] n
73
+ # @param [Integer] is_signed
74
+ # @return [OpaqueGenericValue]
82
75
  # @scope class
83
76
  attach_function :create_generic_value_of_int, :LLVMCreateGenericValueOfInt, [:pointer, :ulong_long, :int], OpaqueGenericValue
84
-
77
+
85
78
  # (Not documented)
86
- #
79
+ #
87
80
  # @method create_generic_value_of_pointer(p)
88
- # @param [FFI::Pointer(*Void)] p
89
- # @return [OpaqueGenericValue]
81
+ # @param [FFI::Pointer(*Void)] p
82
+ # @return [OpaqueGenericValue]
90
83
  # @scope class
91
84
  attach_function :create_generic_value_of_pointer, :LLVMCreateGenericValueOfPointer, [:pointer], OpaqueGenericValue
92
-
85
+
93
86
  # (Not documented)
94
- #
87
+ #
95
88
  # @method create_generic_value_of_float(ty, n)
96
- # @param [FFI::Pointer(TypeRef)] ty
97
- # @param [Float] n
98
- # @return [OpaqueGenericValue]
89
+ # @param [FFI::Pointer(TypeRef)] ty
90
+ # @param [Float] n
91
+ # @return [OpaqueGenericValue]
99
92
  # @scope class
100
93
  attach_function :create_generic_value_of_float, :LLVMCreateGenericValueOfFloat, [:pointer, :double], OpaqueGenericValue
101
-
94
+
102
95
  # (Not documented)
103
- #
96
+ #
104
97
  # @method generic_value_int_width(gen_val_ref)
105
- # @param [OpaqueGenericValue] gen_val_ref
106
- # @return [Integer]
98
+ # @param [OpaqueGenericValue] gen_val_ref
99
+ # @return [Integer]
107
100
  # @scope class
108
101
  attach_function :generic_value_int_width, :LLVMGenericValueIntWidth, [OpaqueGenericValue], :uint
109
-
102
+
110
103
  # (Not documented)
111
- #
104
+ #
112
105
  # @method generic_value_to_int(gen_val, is_signed)
113
- # @param [OpaqueGenericValue] gen_val
114
- # @param [Integer] is_signed
115
- # @return [Integer]
106
+ # @param [OpaqueGenericValue] gen_val
107
+ # @param [Integer] is_signed
108
+ # @return [Integer]
116
109
  # @scope class
117
110
  attach_function :generic_value_to_int, :LLVMGenericValueToInt, [OpaqueGenericValue, :int], :ulong_long
118
-
111
+
119
112
  # (Not documented)
120
- #
113
+ #
121
114
  # @method generic_value_to_pointer(gen_val)
122
- # @param [OpaqueGenericValue] gen_val
123
- # @return [FFI::Pointer(*Void)]
115
+ # @param [OpaqueGenericValue] gen_val
116
+ # @return [FFI::Pointer(*Void)]
124
117
  # @scope class
125
118
  attach_function :generic_value_to_pointer, :LLVMGenericValueToPointer, [OpaqueGenericValue], :pointer
126
-
119
+
127
120
  # (Not documented)
128
- #
121
+ #
129
122
  # @method generic_value_to_float(ty_ref, gen_val)
130
- # @param [FFI::Pointer(TypeRef)] ty_ref
131
- # @param [OpaqueGenericValue] gen_val
132
- # @return [Float]
123
+ # @param [FFI::Pointer(TypeRef)] ty_ref
124
+ # @param [OpaqueGenericValue] gen_val
125
+ # @return [Float]
133
126
  # @scope class
134
127
  attach_function :generic_value_to_float, :LLVMGenericValueToFloat, [:pointer, OpaqueGenericValue], :double
135
-
128
+
136
129
  # (Not documented)
137
- #
130
+ #
138
131
  # @method dispose_generic_value(gen_val)
139
- # @param [OpaqueGenericValue] gen_val
140
- # @return [nil]
132
+ # @param [OpaqueGenericValue] gen_val
133
+ # @return [nil]
141
134
  # @scope class
142
135
  attach_function :dispose_generic_value, :LLVMDisposeGenericValue, [OpaqueGenericValue], :void
143
-
136
+
144
137
  # ===-- Operations on execution engines -----------------------------------===
145
- #
138
+ #
146
139
  # @method create_execution_engine_for_module(out_ee, m, out_error)
147
- # @param [FFI::Pointer(*ExecutionEngineRef)] out_ee
148
- # @param [FFI::Pointer(ModuleRef)] m
149
- # @param [FFI::Pointer(**CharS)] out_error
150
- # @return [Integer]
140
+ # @param [FFI::Pointer(*ExecutionEngineRef)] out_ee
141
+ # @param [FFI::Pointer(ModuleRef)] m
142
+ # @param [FFI::Pointer(**CharS)] out_error
143
+ # @return [Integer]
151
144
  # @scope class
152
145
  attach_function :create_execution_engine_for_module, :LLVMCreateExecutionEngineForModule, [:pointer, :pointer, :pointer], :int
153
-
146
+
154
147
  # (Not documented)
155
- #
148
+ #
156
149
  # @method create_interpreter_for_module(out_interp, m, out_error)
157
- # @param [FFI::Pointer(*ExecutionEngineRef)] out_interp
158
- # @param [FFI::Pointer(ModuleRef)] m
159
- # @param [FFI::Pointer(**CharS)] out_error
160
- # @return [Integer]
150
+ # @param [FFI::Pointer(*ExecutionEngineRef)] out_interp
151
+ # @param [FFI::Pointer(ModuleRef)] m
152
+ # @param [FFI::Pointer(**CharS)] out_error
153
+ # @return [Integer]
161
154
  # @scope class
162
155
  attach_function :create_interpreter_for_module, :LLVMCreateInterpreterForModule, [:pointer, :pointer, :pointer], :int
163
-
156
+
164
157
  # (Not documented)
165
- #
158
+ #
166
159
  # @method create_jit_compiler_for_module(out_jit, m, opt_level, out_error)
167
- # @param [FFI::Pointer(*ExecutionEngineRef)] out_jit
168
- # @param [FFI::Pointer(ModuleRef)] m
169
- # @param [Integer] opt_level
170
- # @param [FFI::Pointer(**CharS)] out_error
171
- # @return [Integer]
160
+ # @param [FFI::Pointer(*ExecutionEngineRef)] out_jit
161
+ # @param [FFI::Pointer(ModuleRef)] m
162
+ # @param [Integer] opt_level
163
+ # @param [FFI::Pointer(**CharS)] out_error
164
+ # @return [Integer]
172
165
  # @scope class
173
166
  attach_function :create_jit_compiler_for_module, :LLVMCreateJITCompilerForModule, [:pointer, :pointer, :uint, :pointer], :int
174
-
167
+
175
168
  # (Not documented)
176
- #
169
+ #
177
170
  # @method initialize_mcjit_compiler_options(options, size_of_options)
178
- # @param [MCJITCompilerOptions] options
179
- # @param [Integer] size_of_options
180
- # @return [nil]
171
+ # @param [MCJITCompilerOptions] options
172
+ # @param [Integer] size_of_options
173
+ # @return [nil]
181
174
  # @scope class
182
175
  attach_function :initialize_mcjit_compiler_options, :LLVMInitializeMCJITCompilerOptions, [MCJITCompilerOptions, :ulong], :void
183
-
176
+
184
177
  # Create an MCJIT execution engine for a module, with the given options. It is
185
178
  # the responsibility of the caller to ensure that all fields in Options up to
186
179
  # the given SizeOfOptions are initialized. It is correct to pass a smaller
187
180
  # value of SizeOfOptions that omits some fields. The canonical way of using
188
181
  # this is:
189
- #
182
+ #
190
183
  # LLVMMCJITCompilerOptions options;
191
184
  # LLVMInitializeMCJITCompilerOptions(&options, sizeof(options));
192
185
  # ... fill in those options you care about
193
186
  # LLVMCreateMCJITCompilerForModule(&jit, mod, &options, sizeof(options),
194
187
  # &error);
195
- #
188
+ #
196
189
  # Note that this is also correct, though possibly suboptimal:
197
- #
190
+ #
198
191
  # LLVMCreateMCJITCompilerForModule(&jit, mod, 0, 0, &error);
199
- #
192
+ #
200
193
  # @method create_mcjit_compiler_for_module(out_jit, m, options, size_of_options, out_error)
201
- # @param [FFI::Pointer(*ExecutionEngineRef)] out_jit
202
- # @param [FFI::Pointer(ModuleRef)] m
203
- # @param [MCJITCompilerOptions] options
204
- # @param [Integer] size_of_options
205
- # @param [FFI::Pointer(**CharS)] out_error
206
- # @return [Integer]
194
+ # @param [FFI::Pointer(*ExecutionEngineRef)] out_jit
195
+ # @param [FFI::Pointer(ModuleRef)] m
196
+ # @param [MCJITCompilerOptions] options
197
+ # @param [Integer] size_of_options
198
+ # @param [FFI::Pointer(**CharS)] out_error
199
+ # @return [Integer]
207
200
  # @scope class
208
201
  attach_function :create_mcjit_compiler_for_module, :LLVMCreateMCJITCompilerForModule, [:pointer, :pointer, MCJITCompilerOptions, :ulong, :pointer], :int
209
-
210
- # Deprecated: Use LLVMCreateExecutionEngineForModule instead.
211
- #
212
- # @method create_execution_engine(out_ee, mp, out_error)
213
- # @param [FFI::Pointer(*ExecutionEngineRef)] out_ee
214
- # @param [FFI::Pointer(ModuleProviderRef)] mp
215
- # @param [FFI::Pointer(**CharS)] out_error
216
- # @return [Integer]
217
- # @scope class
218
- attach_function :create_execution_engine, :LLVMCreateExecutionEngine, [:pointer, :pointer, :pointer], :int
219
-
220
- # Deprecated: Use LLVMCreateInterpreterForModule instead.
221
- #
222
- # @method create_interpreter(out_interp, mp, out_error)
223
- # @param [FFI::Pointer(*ExecutionEngineRef)] out_interp
224
- # @param [FFI::Pointer(ModuleProviderRef)] mp
225
- # @param [FFI::Pointer(**CharS)] out_error
226
- # @return [Integer]
227
- # @scope class
228
- attach_function :create_interpreter, :LLVMCreateInterpreter, [:pointer, :pointer, :pointer], :int
229
-
230
- # Deprecated: Use LLVMCreateJITCompilerForModule instead.
231
- #
232
- # @method create_jit_compiler(out_jit, mp, opt_level, out_error)
233
- # @param [FFI::Pointer(*ExecutionEngineRef)] out_jit
234
- # @param [FFI::Pointer(ModuleProviderRef)] mp
235
- # @param [Integer] opt_level
236
- # @param [FFI::Pointer(**CharS)] out_error
237
- # @return [Integer]
238
- # @scope class
239
- attach_function :create_jit_compiler, :LLVMCreateJITCompiler, [:pointer, :pointer, :uint, :pointer], :int
240
-
241
- # (Not documented)
242
- #
202
+
203
+ # (Not documented)
204
+ #
243
205
  # @method dispose_execution_engine(ee)
244
- # @param [OpaqueExecutionEngine] ee
245
- # @return [nil]
206
+ # @param [OpaqueExecutionEngine] ee
207
+ # @return [nil]
246
208
  # @scope class
247
209
  attach_function :dispose_execution_engine, :LLVMDisposeExecutionEngine, [OpaqueExecutionEngine], :void
248
-
210
+
249
211
  # (Not documented)
250
- #
212
+ #
251
213
  # @method run_static_constructors(ee)
252
- # @param [OpaqueExecutionEngine] ee
253
- # @return [nil]
214
+ # @param [OpaqueExecutionEngine] ee
215
+ # @return [nil]
254
216
  # @scope class
255
217
  attach_function :run_static_constructors, :LLVMRunStaticConstructors, [OpaqueExecutionEngine], :void
256
-
218
+
257
219
  # (Not documented)
258
- #
220
+ #
259
221
  # @method run_static_destructors(ee)
260
- # @param [OpaqueExecutionEngine] ee
261
- # @return [nil]
222
+ # @param [OpaqueExecutionEngine] ee
223
+ # @return [nil]
262
224
  # @scope class
263
225
  attach_function :run_static_destructors, :LLVMRunStaticDestructors, [OpaqueExecutionEngine], :void
264
-
226
+
265
227
  # (Not documented)
266
- #
228
+ #
267
229
  # @method run_function_as_main(ee, f, arg_c, arg_v, env_p)
268
- # @param [OpaqueExecutionEngine] ee
269
- # @param [FFI::Pointer(ValueRef)] f
270
- # @param [Integer] arg_c
271
- # @param [FFI::Pointer(**CharS)] arg_v
272
- # @param [FFI::Pointer(**CharS)] env_p
273
- # @return [Integer]
230
+ # @param [OpaqueExecutionEngine] ee
231
+ # @param [FFI::Pointer(ValueRef)] f
232
+ # @param [Integer] arg_c
233
+ # @param [FFI::Pointer(**CharS)] arg_v
234
+ # @param [FFI::Pointer(**CharS)] env_p
235
+ # @return [Integer]
274
236
  # @scope class
275
237
  attach_function :run_function_as_main, :LLVMRunFunctionAsMain, [OpaqueExecutionEngine, :pointer, :uint, :pointer, :pointer], :int
276
-
238
+
277
239
  # (Not documented)
278
- #
240
+ #
279
241
  # @method run_function(ee, f, num_args, args)
280
- # @param [OpaqueExecutionEngine] ee
281
- # @param [FFI::Pointer(ValueRef)] f
282
- # @param [Integer] num_args
283
- # @param [FFI::Pointer(*GenericValueRef)] args
284
- # @return [OpaqueGenericValue]
242
+ # @param [OpaqueExecutionEngine] ee
243
+ # @param [FFI::Pointer(ValueRef)] f
244
+ # @param [Integer] num_args
245
+ # @param [FFI::Pointer(*GenericValueRef)] args
246
+ # @return [OpaqueGenericValue]
285
247
  # @scope class
286
248
  attach_function :run_function, :LLVMRunFunction, [OpaqueExecutionEngine, :pointer, :uint, :pointer], OpaqueGenericValue
287
-
249
+
288
250
  # (Not documented)
289
- #
251
+ #
290
252
  # @method free_machine_code_for_function(ee, f)
291
- # @param [OpaqueExecutionEngine] ee
292
- # @param [FFI::Pointer(ValueRef)] f
293
- # @return [nil]
253
+ # @param [OpaqueExecutionEngine] ee
254
+ # @param [FFI::Pointer(ValueRef)] f
255
+ # @return [nil]
294
256
  # @scope class
295
257
  attach_function :free_machine_code_for_function, :LLVMFreeMachineCodeForFunction, [OpaqueExecutionEngine, :pointer], :void
296
-
258
+
297
259
  # (Not documented)
298
- #
260
+ #
299
261
  # @method add_module(ee, m)
300
- # @param [OpaqueExecutionEngine] ee
301
- # @param [FFI::Pointer(ModuleRef)] m
302
- # @return [nil]
262
+ # @param [OpaqueExecutionEngine] ee
263
+ # @param [FFI::Pointer(ModuleRef)] m
264
+ # @return [nil]
303
265
  # @scope class
304
266
  attach_function :add_module, :LLVMAddModule, [OpaqueExecutionEngine, :pointer], :void
305
-
306
- # Deprecated: Use LLVMAddModule instead.
307
- #
308
- # @method add_module_provider(ee, mp)
309
- # @param [OpaqueExecutionEngine] ee
310
- # @param [FFI::Pointer(ModuleProviderRef)] mp
311
- # @return [nil]
312
- # @scope class
313
- attach_function :add_module_provider, :LLVMAddModuleProvider, [OpaqueExecutionEngine, :pointer], :void
314
-
315
- # (Not documented)
316
- #
267
+
268
+ # (Not documented)
269
+ #
317
270
  # @method remove_module(ee, m, out_mod, out_error)
318
- # @param [OpaqueExecutionEngine] ee
319
- # @param [FFI::Pointer(ModuleRef)] m
320
- # @param [FFI::Pointer(*ModuleRef)] out_mod
321
- # @param [FFI::Pointer(**CharS)] out_error
322
- # @return [Integer]
271
+ # @param [OpaqueExecutionEngine] ee
272
+ # @param [FFI::Pointer(ModuleRef)] m
273
+ # @param [FFI::Pointer(*ModuleRef)] out_mod
274
+ # @param [FFI::Pointer(**CharS)] out_error
275
+ # @return [Integer]
323
276
  # @scope class
324
277
  attach_function :remove_module, :LLVMRemoveModule, [OpaqueExecutionEngine, :pointer, :pointer, :pointer], :int
325
-
326
- # Deprecated: Use LLVMRemoveModule instead.
327
- #
328
- # @method remove_module_provider(ee, mp, out_mod, out_error)
329
- # @param [OpaqueExecutionEngine] ee
330
- # @param [FFI::Pointer(ModuleProviderRef)] mp
331
- # @param [FFI::Pointer(*ModuleRef)] out_mod
332
- # @param [FFI::Pointer(**CharS)] out_error
333
- # @return [Integer]
334
- # @scope class
335
- attach_function :remove_module_provider, :LLVMRemoveModuleProvider, [OpaqueExecutionEngine, :pointer, :pointer, :pointer], :int
336
-
337
- # (Not documented)
338
- #
278
+
279
+ # (Not documented)
280
+ #
339
281
  # @method find_function(ee, name, out_fn)
340
- # @param [OpaqueExecutionEngine] ee
341
- # @param [String] name
342
- # @param [FFI::Pointer(*ValueRef)] out_fn
343
- # @return [Integer]
282
+ # @param [OpaqueExecutionEngine] ee
283
+ # @param [String] name
284
+ # @param [FFI::Pointer(*ValueRef)] out_fn
285
+ # @return [Integer]
344
286
  # @scope class
345
287
  attach_function :find_function, :LLVMFindFunction, [OpaqueExecutionEngine, :string, :pointer], :int
346
-
288
+
347
289
  # (Not documented)
348
- #
290
+ #
349
291
  # @method recompile_and_relink_function(ee, fn)
350
- # @param [OpaqueExecutionEngine] ee
351
- # @param [FFI::Pointer(ValueRef)] fn
352
- # @return [FFI::Pointer(*Void)]
292
+ # @param [OpaqueExecutionEngine] ee
293
+ # @param [FFI::Pointer(ValueRef)] fn
294
+ # @return [FFI::Pointer(*Void)]
353
295
  # @scope class
354
296
  attach_function :recompile_and_relink_function, :LLVMRecompileAndRelinkFunction, [OpaqueExecutionEngine, :pointer], :pointer
355
-
297
+
356
298
  # (Not documented)
357
- #
299
+ #
358
300
  # @method get_execution_engine_target_data(ee)
359
- # @param [OpaqueExecutionEngine] ee
360
- # @return [FFI::Pointer(TargetDataRef)]
301
+ # @param [OpaqueExecutionEngine] ee
302
+ # @return [FFI::Pointer(TargetDataRef)]
361
303
  # @scope class
362
304
  attach_function :get_execution_engine_target_data, :LLVMGetExecutionEngineTargetData, [OpaqueExecutionEngine], :pointer
363
-
305
+
364
306
  # (Not documented)
365
- #
307
+ #
366
308
  # @method get_execution_engine_target_machine(ee)
367
- # @param [OpaqueExecutionEngine] ee
368
- # @return [FFI::Pointer(TargetMachineRef)]
309
+ # @param [OpaqueExecutionEngine] ee
310
+ # @return [FFI::Pointer(TargetMachineRef)]
369
311
  # @scope class
370
312
  attach_function :get_execution_engine_target_machine, :LLVMGetExecutionEngineTargetMachine, [OpaqueExecutionEngine], :pointer
371
-
313
+
372
314
  # (Not documented)
373
- #
315
+ #
374
316
  # @method add_global_mapping(ee, global, addr)
375
- # @param [OpaqueExecutionEngine] ee
376
- # @param [FFI::Pointer(ValueRef)] global
377
- # @param [FFI::Pointer(*Void)] addr
378
- # @return [nil]
317
+ # @param [OpaqueExecutionEngine] ee
318
+ # @param [FFI::Pointer(ValueRef)] global
319
+ # @param [FFI::Pointer(*Void)] addr
320
+ # @return [nil]
379
321
  # @scope class
380
322
  attach_function :add_global_mapping, :LLVMAddGlobalMapping, [OpaqueExecutionEngine, :pointer, :pointer], :void
381
-
323
+
382
324
  # (Not documented)
383
- #
325
+ #
384
326
  # @method get_pointer_to_global(ee, global)
385
- # @param [OpaqueExecutionEngine] ee
386
- # @param [FFI::Pointer(ValueRef)] global
387
- # @return [FFI::Pointer(*Void)]
327
+ # @param [OpaqueExecutionEngine] ee
328
+ # @param [FFI::Pointer(ValueRef)] global
329
+ # @return [FFI::Pointer(*Void)]
388
330
  # @scope class
389
331
  attach_function :get_pointer_to_global, :LLVMGetPointerToGlobal, [OpaqueExecutionEngine, :pointer], :pointer
390
-
332
+
333
+ # (Not documented)
334
+ #
335
+ # @method get_global_value_address(ee, name)
336
+ # @param [OpaqueExecutionEngine] ee
337
+ # @param [String] name
338
+ # @return [Integer]
339
+ # @scope class
340
+ attach_function :get_global_value_address, :LLVMGetGlobalValueAddress, [OpaqueExecutionEngine, :string], :ulong
341
+
342
+ # (Not documented)
343
+ #
344
+ # @method get_function_address(ee, name)
345
+ # @param [OpaqueExecutionEngine] ee
346
+ # @param [String] name
347
+ # @return [Integer]
348
+ # @scope class
349
+ attach_function :get_function_address, :LLVMGetFunctionAddress, [OpaqueExecutionEngine, :string], :ulong
350
+
391
351
  # ===-- Operations on memory managers -------------------------------------===
392
- #
352
+ #
393
353
  # <em>This entry is only for documentation and no real method.</em>
394
- #
395
- # @method _callback_memory_manager_allocate_code_section_callback_(opaque, size, alignment, section_id, section_name)
396
- # @param [FFI::Pointer(*Void)] opaque
397
- # @param [Integer] size
398
- # @param [Integer] alignment
399
- # @param [Integer] section_id
400
- # @param [String] section_name
401
- # @return [Integer]
402
- # @scope class
403
- callback :memory_manager_allocate_code_section_callback, [:pointer, :ulong, :uint, :uint, :string], :uchar
404
-
405
- # (Not documented)
406
- #
354
+ #
355
+ # @method _callback_memory_manager_allocate_code_section_callback_(uint8_t, opaque, size, alignment, section_id, section_name)
356
+ # @param [Integer] uint8_t
357
+ # @param [FFI::Pointer(*Void)] opaque
358
+ # @param [Integer] size
359
+ # @param [Integer] alignment
360
+ # @param [Integer] section_id
361
+ # @param [String] section_name
362
+ # @return [Integer]
363
+ # @scope class
364
+ callback :memory_manager_allocate_code_section_callback, [:uchar, :pointer, :ulong, :uint, :uint, :string], :uchar
365
+
366
+ # (Not documented)
367
+ #
407
368
  # <em>This entry is only for documentation and no real method.</em>
408
- #
409
- # @method _callback_memory_manager_allocate_data_section_callback_(opaque, size, alignment, section_id, section_name, is_read_only)
410
- # @param [FFI::Pointer(*Void)] opaque
411
- # @param [Integer] size
412
- # @param [Integer] alignment
413
- # @param [Integer] section_id
414
- # @param [String] section_name
415
- # @param [Integer] is_read_only
416
- # @return [Integer]
417
- # @scope class
418
- callback :memory_manager_allocate_data_section_callback, [:pointer, :ulong, :uint, :uint, :string, :int], :uchar
419
-
420
- # (Not documented)
421
- #
369
+ #
370
+ # @method _callback_memory_manager_allocate_data_section_callback_(uint8_t, opaque, size, alignment, section_id, section_name, is_read_only)
371
+ # @param [Integer] uint8_t
372
+ # @param [FFI::Pointer(*Void)] opaque
373
+ # @param [Integer] size
374
+ # @param [Integer] alignment
375
+ # @param [Integer] section_id
376
+ # @param [String] section_name
377
+ # @param [Integer] is_read_only
378
+ # @return [Integer]
379
+ # @scope class
380
+ callback :memory_manager_allocate_data_section_callback, [:uchar, :pointer, :ulong, :uint, :uint, :string, :int], :uchar
381
+
382
+ # (Not documented)
383
+ #
422
384
  # <em>This entry is only for documentation and no real method.</em>
423
- #
424
- # @method _callback_memory_manager_finalize_memory_callback_(opaque, err_msg)
425
- # @param [FFI::Pointer(*Void)] opaque
426
- # @param [FFI::Pointer(**CharS)] err_msg
427
- # @return [Integer]
428
- # @scope class
429
- callback :memory_manager_finalize_memory_callback, [:pointer, :pointer], :int
430
-
385
+ #
386
+ # @method _callback_memory_manager_finalize_memory_callback_(bool, opaque, err_msg)
387
+ # @param [Integer] bool
388
+ # @param [FFI::Pointer(*Void)] opaque
389
+ # @param [FFI::Pointer(**CharS)] err_msg
390
+ # @return [Integer]
391
+ # @scope class
392
+ callback :memory_manager_finalize_memory_callback, [:int, :pointer, :pointer], :int
393
+
431
394
  # Create a simple custom MCJIT memory manager. This memory manager can
432
395
  # intercept allocations in a module-oblivious way. This will return NULL
433
396
  # if any of the passed functions are NULL.
434
- #
397
+ #
435
398
  # @param Opaque An opaque client object to pass back to the callbacks.
436
399
  # @param AllocateCodeSection Allocate a block of memory for executable code.
437
400
  # @param AllocateDataSection Allocate a block of memory for data.
438
401
  # @param FinalizeMemory Set page permissions and flush cache. Return 0 on
439
402
  # success, 1 on error.
440
- #
403
+ #
441
404
  # @method create_simple_mcjit_memory_manager(opaque, allocate_code_section, allocate_data_section, finalize_memory, destroy)
442
- # @param [FFI::Pointer(*Void)] opaque
443
- # @param [Proc(_callback_memory_manager_allocate_code_section_callback_)] allocate_code_section
444
- # @param [Proc(_callback_memory_manager_allocate_data_section_callback_)] allocate_data_section
445
- # @param [Proc(_callback_memory_manager_finalize_memory_callback_)] finalize_memory
446
- # @param [FFI::Pointer(MemoryManagerDestroyCallback)] destroy
447
- # @return [OpaqueMCJITMemoryManager]
405
+ # @param [FFI::Pointer(*Void)] opaque
406
+ # @param [Proc(_callback_memory_manager_allocate_code_section_callback_)] allocate_code_section
407
+ # @param [Proc(_callback_memory_manager_allocate_data_section_callback_)] allocate_data_section
408
+ # @param [Proc(_callback_memory_manager_finalize_memory_callback_)] finalize_memory
409
+ # @param [FFI::Pointer(MemoryManagerDestroyCallback)] destroy
410
+ # @return [OpaqueMCJITMemoryManager]
448
411
  # @scope class
449
412
  attach_function :create_simple_mcjit_memory_manager, :LLVMCreateSimpleMCJITMemoryManager, [:pointer, :memory_manager_allocate_code_section_callback, :memory_manager_allocate_data_section_callback, :memory_manager_finalize_memory_callback, :pointer], OpaqueMCJITMemoryManager
450
-
413
+
451
414
  # (Not documented)
452
- #
415
+ #
453
416
  # @method dispose_mcjit_memory_manager(mm)
454
- # @param [OpaqueMCJITMemoryManager] mm
455
- # @return [nil]
417
+ # @param [OpaqueMCJITMemoryManager] mm
418
+ # @return [nil]
456
419
  # @scope class
457
420
  attach_function :dispose_mcjit_memory_manager, :LLVMDisposeMCJITMemoryManager, [OpaqueMCJITMemoryManager], :void
458
-
459
421
  end