ruby-llvm 3.4.0 → 11.0.1

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