ruby-llvm 3.3.0 → 10.0.0
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.
- checksums.yaml +5 -5
- data/README.md +19 -4
- data/ext/ruby-llvm-support/Rakefile +20 -8
- data/ext/ruby-llvm-support/support.cpp +1 -30
- data/lib/llvm.rb +0 -6
- data/lib/llvm/analysis_ffi.rb +30 -28
- data/lib/llvm/config.rb +4 -4
- data/lib/llvm/core.rb +45 -2
- data/lib/llvm/core/bitcode.rb +10 -10
- data/lib/llvm/core/bitcode_ffi.rb +92 -70
- data/lib/llvm/core/builder.rb +2 -3
- data/lib/llvm/core/context.rb +1 -1
- data/lib/llvm/core/module.rb +7 -21
- data/lib/llvm/core/pass_manager.rb +4 -2
- data/lib/llvm/core/type.rb +3 -3
- data/lib/llvm/core/value.rb +155 -28
- data/lib/llvm/core_ffi.rb +4041 -3564
- data/lib/llvm/execution_engine.rb +176 -8
- data/lib/llvm/execution_engine_ffi.rb +271 -222
- data/lib/llvm/linker.rb +2 -19
- data/lib/llvm/linker_ffi.rb +24 -25
- data/lib/llvm/support.rb +6 -16
- data/lib/llvm/target.rb +12 -18
- data/lib/llvm/target_ffi.rb +386 -330
- data/lib/llvm/transforms/builder.rb +8 -3
- data/lib/llvm/transforms/builder_ffi.rb +57 -58
- data/lib/llvm/transforms/ipo.rb +1 -1
- data/lib/llvm/transforms/ipo_ffi.rb +60 -61
- data/lib/llvm/transforms/scalar_ffi.rb +216 -128
- data/lib/llvm/transforms/vectorize_ffi.rb +15 -16
- data/lib/llvm/version.rb +3 -2
- data/test/basic_block_test.rb +0 -1
- data/test/bitcode_test.rb +1 -2
- data/test/call_test.rb +1 -1
- data/test/double_test.rb +8 -7
- data/test/equality_test.rb +2 -4
- data/test/function_test.rb +27 -0
- data/test/generic_value_test.rb +1 -1
- data/test/instruction_test.rb +0 -2
- data/test/ipo_test.rb +1 -1
- data/test/linker_test.rb +0 -9
- data/test/mcjit_test.rb +94 -0
- data/test/module_test.rb +33 -10
- data/test/pass_manager_builder_test.rb +23 -3
- data/test/target_test.rb +7 -24
- data/test/test_helper.rb +4 -1
- metadata +113 -93
|
@@ -5,12 +5,19 @@ require 'llvm/analysis'
|
|
|
5
5
|
require 'llvm/execution_engine_ffi'
|
|
6
6
|
|
|
7
7
|
module LLVM
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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 =
|
|
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
|
|
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
|
|
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,369 +4,418 @@ require 'ffi'
|
|
|
4
4
|
|
|
5
5
|
module LLVM::C
|
|
6
6
|
extend FFI::Library
|
|
7
|
-
ffi_lib
|
|
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
|
-
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
# @
|
|
19
|
-
#
|
|
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
|
|
44
|
+
layout :dummy, :char
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# (Not documented)
|
|
48
|
+
#
|
|
48
49
|
# = Fields:
|
|
49
50
|
# :opt_level ::
|
|
50
|
-
# (Integer)
|
|
51
|
+
# (Integer)
|
|
51
52
|
# :code_model ::
|
|
52
|
-
# (unknown)
|
|
53
|
+
# (unknown)
|
|
53
54
|
# :no_frame_pointer_elim ::
|
|
54
|
-
# (Integer)
|
|
55
|
+
# (Integer)
|
|
55
56
|
# :enable_fast_i_sel ::
|
|
56
|
-
# (Integer)
|
|
57
|
+
# (Integer)
|
|
58
|
+
# :mcjmm ::
|
|
59
|
+
# (OpaqueMCJITMemoryManager)
|
|
57
60
|
class MCJITCompilerOptions < FFI::Struct
|
|
58
61
|
layout :opt_level, :uint,
|
|
59
62
|
:code_model, :char,
|
|
60
63
|
:no_frame_pointer_elim, :int,
|
|
61
|
-
:enable_fast_i_sel, :int
|
|
64
|
+
:enable_fast_i_sel, :int,
|
|
65
|
+
:mcjmm, OpaqueMCJITMemoryManager
|
|
62
66
|
end
|
|
63
|
-
|
|
67
|
+
|
|
64
68
|
# ===-- Operations on generic values --------------------------------------===
|
|
65
|
-
#
|
|
69
|
+
#
|
|
66
70
|
# @method create_generic_value_of_int(ty, n, is_signed)
|
|
67
|
-
# @param [FFI::Pointer(TypeRef)] ty
|
|
68
|
-
# @param [Integer] n
|
|
69
|
-
# @param [Integer] is_signed
|
|
70
|
-
# @return [OpaqueGenericValue]
|
|
71
|
+
# @param [FFI::Pointer(TypeRef)] ty
|
|
72
|
+
# @param [Integer] n
|
|
73
|
+
# @param [Integer] is_signed
|
|
74
|
+
# @return [OpaqueGenericValue]
|
|
71
75
|
# @scope class
|
|
72
76
|
attach_function :create_generic_value_of_int, :LLVMCreateGenericValueOfInt, [:pointer, :ulong_long, :int], OpaqueGenericValue
|
|
73
|
-
|
|
77
|
+
|
|
74
78
|
# (Not documented)
|
|
75
|
-
#
|
|
79
|
+
#
|
|
76
80
|
# @method create_generic_value_of_pointer(p)
|
|
77
|
-
# @param [FFI::Pointer(*Void)] p
|
|
78
|
-
# @return [OpaqueGenericValue]
|
|
81
|
+
# @param [FFI::Pointer(*Void)] p
|
|
82
|
+
# @return [OpaqueGenericValue]
|
|
79
83
|
# @scope class
|
|
80
84
|
attach_function :create_generic_value_of_pointer, :LLVMCreateGenericValueOfPointer, [:pointer], OpaqueGenericValue
|
|
81
|
-
|
|
85
|
+
|
|
82
86
|
# (Not documented)
|
|
83
|
-
#
|
|
87
|
+
#
|
|
84
88
|
# @method create_generic_value_of_float(ty, n)
|
|
85
|
-
# @param [FFI::Pointer(TypeRef)] ty
|
|
86
|
-
# @param [Float] n
|
|
87
|
-
# @return [OpaqueGenericValue]
|
|
89
|
+
# @param [FFI::Pointer(TypeRef)] ty
|
|
90
|
+
# @param [Float] n
|
|
91
|
+
# @return [OpaqueGenericValue]
|
|
88
92
|
# @scope class
|
|
89
93
|
attach_function :create_generic_value_of_float, :LLVMCreateGenericValueOfFloat, [:pointer, :double], OpaqueGenericValue
|
|
90
|
-
|
|
94
|
+
|
|
91
95
|
# (Not documented)
|
|
92
|
-
#
|
|
96
|
+
#
|
|
93
97
|
# @method generic_value_int_width(gen_val_ref)
|
|
94
|
-
# @param [OpaqueGenericValue] gen_val_ref
|
|
95
|
-
# @return [Integer]
|
|
98
|
+
# @param [OpaqueGenericValue] gen_val_ref
|
|
99
|
+
# @return [Integer]
|
|
96
100
|
# @scope class
|
|
97
101
|
attach_function :generic_value_int_width, :LLVMGenericValueIntWidth, [OpaqueGenericValue], :uint
|
|
98
|
-
|
|
102
|
+
|
|
99
103
|
# (Not documented)
|
|
100
|
-
#
|
|
104
|
+
#
|
|
101
105
|
# @method generic_value_to_int(gen_val, is_signed)
|
|
102
|
-
# @param [OpaqueGenericValue] gen_val
|
|
103
|
-
# @param [Integer] is_signed
|
|
104
|
-
# @return [Integer]
|
|
106
|
+
# @param [OpaqueGenericValue] gen_val
|
|
107
|
+
# @param [Integer] is_signed
|
|
108
|
+
# @return [Integer]
|
|
105
109
|
# @scope class
|
|
106
110
|
attach_function :generic_value_to_int, :LLVMGenericValueToInt, [OpaqueGenericValue, :int], :ulong_long
|
|
107
|
-
|
|
111
|
+
|
|
108
112
|
# (Not documented)
|
|
109
|
-
#
|
|
113
|
+
#
|
|
110
114
|
# @method generic_value_to_pointer(gen_val)
|
|
111
|
-
# @param [OpaqueGenericValue] gen_val
|
|
112
|
-
# @return [FFI::Pointer(*Void)]
|
|
115
|
+
# @param [OpaqueGenericValue] gen_val
|
|
116
|
+
# @return [FFI::Pointer(*Void)]
|
|
113
117
|
# @scope class
|
|
114
118
|
attach_function :generic_value_to_pointer, :LLVMGenericValueToPointer, [OpaqueGenericValue], :pointer
|
|
115
|
-
|
|
119
|
+
|
|
116
120
|
# (Not documented)
|
|
117
|
-
#
|
|
121
|
+
#
|
|
118
122
|
# @method generic_value_to_float(ty_ref, gen_val)
|
|
119
|
-
# @param [FFI::Pointer(TypeRef)] ty_ref
|
|
120
|
-
# @param [OpaqueGenericValue] gen_val
|
|
121
|
-
# @return [Float]
|
|
123
|
+
# @param [FFI::Pointer(TypeRef)] ty_ref
|
|
124
|
+
# @param [OpaqueGenericValue] gen_val
|
|
125
|
+
# @return [Float]
|
|
122
126
|
# @scope class
|
|
123
127
|
attach_function :generic_value_to_float, :LLVMGenericValueToFloat, [:pointer, OpaqueGenericValue], :double
|
|
124
|
-
|
|
128
|
+
|
|
125
129
|
# (Not documented)
|
|
126
|
-
#
|
|
130
|
+
#
|
|
127
131
|
# @method dispose_generic_value(gen_val)
|
|
128
|
-
# @param [OpaqueGenericValue] gen_val
|
|
129
|
-
# @return [nil]
|
|
132
|
+
# @param [OpaqueGenericValue] gen_val
|
|
133
|
+
# @return [nil]
|
|
130
134
|
# @scope class
|
|
131
135
|
attach_function :dispose_generic_value, :LLVMDisposeGenericValue, [OpaqueGenericValue], :void
|
|
132
|
-
|
|
136
|
+
|
|
133
137
|
# ===-- Operations on execution engines -----------------------------------===
|
|
134
|
-
#
|
|
138
|
+
#
|
|
135
139
|
# @method create_execution_engine_for_module(out_ee, m, out_error)
|
|
136
|
-
# @param [FFI::Pointer(*ExecutionEngineRef)] out_ee
|
|
137
|
-
# @param [FFI::Pointer(ModuleRef)] m
|
|
138
|
-
# @param [FFI::Pointer(**CharS)] out_error
|
|
139
|
-
# @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]
|
|
140
144
|
# @scope class
|
|
141
145
|
attach_function :create_execution_engine_for_module, :LLVMCreateExecutionEngineForModule, [:pointer, :pointer, :pointer], :int
|
|
142
|
-
|
|
146
|
+
|
|
143
147
|
# (Not documented)
|
|
144
|
-
#
|
|
148
|
+
#
|
|
145
149
|
# @method create_interpreter_for_module(out_interp, m, out_error)
|
|
146
|
-
# @param [FFI::Pointer(*ExecutionEngineRef)] out_interp
|
|
147
|
-
# @param [FFI::Pointer(ModuleRef)] m
|
|
148
|
-
# @param [FFI::Pointer(**CharS)] out_error
|
|
149
|
-
# @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]
|
|
150
154
|
# @scope class
|
|
151
155
|
attach_function :create_interpreter_for_module, :LLVMCreateInterpreterForModule, [:pointer, :pointer, :pointer], :int
|
|
152
|
-
|
|
156
|
+
|
|
153
157
|
# (Not documented)
|
|
154
|
-
#
|
|
158
|
+
#
|
|
155
159
|
# @method create_jit_compiler_for_module(out_jit, m, opt_level, out_error)
|
|
156
|
-
# @param [FFI::Pointer(*ExecutionEngineRef)] out_jit
|
|
157
|
-
# @param [FFI::Pointer(ModuleRef)] m
|
|
158
|
-
# @param [Integer] opt_level
|
|
159
|
-
# @param [FFI::Pointer(**CharS)] out_error
|
|
160
|
-
# @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]
|
|
161
165
|
# @scope class
|
|
162
166
|
attach_function :create_jit_compiler_for_module, :LLVMCreateJITCompilerForModule, [:pointer, :pointer, :uint, :pointer], :int
|
|
163
|
-
|
|
167
|
+
|
|
164
168
|
# (Not documented)
|
|
165
|
-
#
|
|
169
|
+
#
|
|
166
170
|
# @method initialize_mcjit_compiler_options(options, size_of_options)
|
|
167
|
-
# @param [MCJITCompilerOptions] options
|
|
168
|
-
# @param [Integer] size_of_options
|
|
169
|
-
# @return [nil]
|
|
171
|
+
# @param [MCJITCompilerOptions] options
|
|
172
|
+
# @param [Integer] size_of_options
|
|
173
|
+
# @return [nil]
|
|
170
174
|
# @scope class
|
|
171
175
|
attach_function :initialize_mcjit_compiler_options, :LLVMInitializeMCJITCompilerOptions, [MCJITCompilerOptions, :ulong], :void
|
|
172
|
-
|
|
176
|
+
|
|
173
177
|
# Create an MCJIT execution engine for a module, with the given options. It is
|
|
174
178
|
# the responsibility of the caller to ensure that all fields in Options up to
|
|
175
179
|
# the given SizeOfOptions are initialized. It is correct to pass a smaller
|
|
176
180
|
# value of SizeOfOptions that omits some fields. The canonical way of using
|
|
177
181
|
# this is:
|
|
178
|
-
#
|
|
182
|
+
#
|
|
179
183
|
# LLVMMCJITCompilerOptions options;
|
|
180
184
|
# LLVMInitializeMCJITCompilerOptions(&options, sizeof(options));
|
|
181
185
|
# ... fill in those options you care about
|
|
182
186
|
# LLVMCreateMCJITCompilerForModule(&jit, mod, &options, sizeof(options),
|
|
183
187
|
# &error);
|
|
184
|
-
#
|
|
188
|
+
#
|
|
185
189
|
# Note that this is also correct, though possibly suboptimal:
|
|
186
|
-
#
|
|
190
|
+
#
|
|
187
191
|
# LLVMCreateMCJITCompilerForModule(&jit, mod, 0, 0, &error);
|
|
188
|
-
#
|
|
192
|
+
#
|
|
189
193
|
# @method create_mcjit_compiler_for_module(out_jit, m, options, size_of_options, out_error)
|
|
190
|
-
# @param [FFI::Pointer(*ExecutionEngineRef)] out_jit
|
|
191
|
-
# @param [FFI::Pointer(ModuleRef)] m
|
|
192
|
-
# @param [MCJITCompilerOptions] options
|
|
193
|
-
# @param [Integer] size_of_options
|
|
194
|
-
# @param [FFI::Pointer(**CharS)] out_error
|
|
195
|
-
# @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]
|
|
196
200
|
# @scope class
|
|
197
201
|
attach_function :create_mcjit_compiler_for_module, :LLVMCreateMCJITCompilerForModule, [:pointer, :pointer, MCJITCompilerOptions, :ulong, :pointer], :int
|
|
198
|
-
|
|
199
|
-
#
|
|
200
|
-
#
|
|
201
|
-
# @method create_execution_engine(out_ee, mp, out_error)
|
|
202
|
-
# @param [FFI::Pointer(*ExecutionEngineRef)] out_ee
|
|
203
|
-
# @param [FFI::Pointer(ModuleProviderRef)] mp
|
|
204
|
-
# @param [FFI::Pointer(**CharS)] out_error
|
|
205
|
-
# @return [Integer]
|
|
206
|
-
# @scope class
|
|
207
|
-
attach_function :create_execution_engine, :LLVMCreateExecutionEngine, [:pointer, :pointer, :pointer], :int
|
|
208
|
-
|
|
209
|
-
# Deprecated: Use LLVMCreateInterpreterForModule instead.
|
|
210
|
-
#
|
|
211
|
-
# @method create_interpreter(out_interp, mp, out_error)
|
|
212
|
-
# @param [FFI::Pointer(*ExecutionEngineRef)] out_interp
|
|
213
|
-
# @param [FFI::Pointer(ModuleProviderRef)] mp
|
|
214
|
-
# @param [FFI::Pointer(**CharS)] out_error
|
|
215
|
-
# @return [Integer]
|
|
216
|
-
# @scope class
|
|
217
|
-
attach_function :create_interpreter, :LLVMCreateInterpreter, [:pointer, :pointer, :pointer], :int
|
|
218
|
-
|
|
219
|
-
# Deprecated: Use LLVMCreateJITCompilerForModule instead.
|
|
220
|
-
#
|
|
221
|
-
# @method create_jit_compiler(out_jit, mp, opt_level, out_error)
|
|
222
|
-
# @param [FFI::Pointer(*ExecutionEngineRef)] out_jit
|
|
223
|
-
# @param [FFI::Pointer(ModuleProviderRef)] mp
|
|
224
|
-
# @param [Integer] opt_level
|
|
225
|
-
# @param [FFI::Pointer(**CharS)] out_error
|
|
226
|
-
# @return [Integer]
|
|
227
|
-
# @scope class
|
|
228
|
-
attach_function :create_jit_compiler, :LLVMCreateJITCompiler, [:pointer, :pointer, :uint, :pointer], :int
|
|
229
|
-
|
|
230
|
-
# (Not documented)
|
|
231
|
-
#
|
|
202
|
+
|
|
203
|
+
# (Not documented)
|
|
204
|
+
#
|
|
232
205
|
# @method dispose_execution_engine(ee)
|
|
233
|
-
# @param [OpaqueExecutionEngine] ee
|
|
234
|
-
# @return [nil]
|
|
206
|
+
# @param [OpaqueExecutionEngine] ee
|
|
207
|
+
# @return [nil]
|
|
235
208
|
# @scope class
|
|
236
209
|
attach_function :dispose_execution_engine, :LLVMDisposeExecutionEngine, [OpaqueExecutionEngine], :void
|
|
237
|
-
|
|
210
|
+
|
|
238
211
|
# (Not documented)
|
|
239
|
-
#
|
|
212
|
+
#
|
|
240
213
|
# @method run_static_constructors(ee)
|
|
241
|
-
# @param [OpaqueExecutionEngine] ee
|
|
242
|
-
# @return [nil]
|
|
214
|
+
# @param [OpaqueExecutionEngine] ee
|
|
215
|
+
# @return [nil]
|
|
243
216
|
# @scope class
|
|
244
217
|
attach_function :run_static_constructors, :LLVMRunStaticConstructors, [OpaqueExecutionEngine], :void
|
|
245
|
-
|
|
218
|
+
|
|
246
219
|
# (Not documented)
|
|
247
|
-
#
|
|
220
|
+
#
|
|
248
221
|
# @method run_static_destructors(ee)
|
|
249
|
-
# @param [OpaqueExecutionEngine] ee
|
|
250
|
-
# @return [nil]
|
|
222
|
+
# @param [OpaqueExecutionEngine] ee
|
|
223
|
+
# @return [nil]
|
|
251
224
|
# @scope class
|
|
252
225
|
attach_function :run_static_destructors, :LLVMRunStaticDestructors, [OpaqueExecutionEngine], :void
|
|
253
|
-
|
|
226
|
+
|
|
254
227
|
# (Not documented)
|
|
255
|
-
#
|
|
228
|
+
#
|
|
256
229
|
# @method run_function_as_main(ee, f, arg_c, arg_v, env_p)
|
|
257
|
-
# @param [OpaqueExecutionEngine] ee
|
|
258
|
-
# @param [FFI::Pointer(ValueRef)] f
|
|
259
|
-
# @param [Integer] arg_c
|
|
260
|
-
# @param [FFI::Pointer(**CharS)] arg_v
|
|
261
|
-
# @param [FFI::Pointer(**CharS)] env_p
|
|
262
|
-
# @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]
|
|
263
236
|
# @scope class
|
|
264
237
|
attach_function :run_function_as_main, :LLVMRunFunctionAsMain, [OpaqueExecutionEngine, :pointer, :uint, :pointer, :pointer], :int
|
|
265
|
-
|
|
238
|
+
|
|
266
239
|
# (Not documented)
|
|
267
|
-
#
|
|
240
|
+
#
|
|
268
241
|
# @method run_function(ee, f, num_args, args)
|
|
269
|
-
# @param [OpaqueExecutionEngine] ee
|
|
270
|
-
# @param [FFI::Pointer(ValueRef)] f
|
|
271
|
-
# @param [Integer] num_args
|
|
272
|
-
# @param [FFI::Pointer(*GenericValueRef)] args
|
|
273
|
-
# @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]
|
|
274
247
|
# @scope class
|
|
275
248
|
attach_function :run_function, :LLVMRunFunction, [OpaqueExecutionEngine, :pointer, :uint, :pointer], OpaqueGenericValue
|
|
276
|
-
|
|
249
|
+
|
|
277
250
|
# (Not documented)
|
|
278
|
-
#
|
|
251
|
+
#
|
|
279
252
|
# @method free_machine_code_for_function(ee, f)
|
|
280
|
-
# @param [OpaqueExecutionEngine] ee
|
|
281
|
-
# @param [FFI::Pointer(ValueRef)] f
|
|
282
|
-
# @return [nil]
|
|
253
|
+
# @param [OpaqueExecutionEngine] ee
|
|
254
|
+
# @param [FFI::Pointer(ValueRef)] f
|
|
255
|
+
# @return [nil]
|
|
283
256
|
# @scope class
|
|
284
257
|
attach_function :free_machine_code_for_function, :LLVMFreeMachineCodeForFunction, [OpaqueExecutionEngine, :pointer], :void
|
|
285
|
-
|
|
258
|
+
|
|
286
259
|
# (Not documented)
|
|
287
|
-
#
|
|
260
|
+
#
|
|
288
261
|
# @method add_module(ee, m)
|
|
289
|
-
# @param [OpaqueExecutionEngine] ee
|
|
290
|
-
# @param [FFI::Pointer(ModuleRef)] m
|
|
291
|
-
# @return [nil]
|
|
262
|
+
# @param [OpaqueExecutionEngine] ee
|
|
263
|
+
# @param [FFI::Pointer(ModuleRef)] m
|
|
264
|
+
# @return [nil]
|
|
292
265
|
# @scope class
|
|
293
266
|
attach_function :add_module, :LLVMAddModule, [OpaqueExecutionEngine, :pointer], :void
|
|
294
|
-
|
|
295
|
-
#
|
|
296
|
-
#
|
|
297
|
-
# @method add_module_provider(ee, mp)
|
|
298
|
-
# @param [OpaqueExecutionEngine] ee
|
|
299
|
-
# @param [FFI::Pointer(ModuleProviderRef)] mp
|
|
300
|
-
# @return [nil]
|
|
301
|
-
# @scope class
|
|
302
|
-
attach_function :add_module_provider, :LLVMAddModuleProvider, [OpaqueExecutionEngine, :pointer], :void
|
|
303
|
-
|
|
304
|
-
# (Not documented)
|
|
305
|
-
#
|
|
267
|
+
|
|
268
|
+
# (Not documented)
|
|
269
|
+
#
|
|
306
270
|
# @method remove_module(ee, m, out_mod, out_error)
|
|
307
|
-
# @param [OpaqueExecutionEngine] ee
|
|
308
|
-
# @param [FFI::Pointer(ModuleRef)] m
|
|
309
|
-
# @param [FFI::Pointer(*ModuleRef)] out_mod
|
|
310
|
-
# @param [FFI::Pointer(**CharS)] out_error
|
|
311
|
-
# @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]
|
|
312
276
|
# @scope class
|
|
313
277
|
attach_function :remove_module, :LLVMRemoveModule, [OpaqueExecutionEngine, :pointer, :pointer, :pointer], :int
|
|
314
|
-
|
|
315
|
-
#
|
|
316
|
-
#
|
|
317
|
-
# @method remove_module_provider(ee, mp, out_mod, out_error)
|
|
318
|
-
# @param [OpaqueExecutionEngine] ee
|
|
319
|
-
# @param [FFI::Pointer(ModuleProviderRef)] mp
|
|
320
|
-
# @param [FFI::Pointer(*ModuleRef)] out_mod
|
|
321
|
-
# @param [FFI::Pointer(**CharS)] out_error
|
|
322
|
-
# @return [Integer]
|
|
323
|
-
# @scope class
|
|
324
|
-
attach_function :remove_module_provider, :LLVMRemoveModuleProvider, [OpaqueExecutionEngine, :pointer, :pointer, :pointer], :int
|
|
325
|
-
|
|
326
|
-
# (Not documented)
|
|
327
|
-
#
|
|
278
|
+
|
|
279
|
+
# (Not documented)
|
|
280
|
+
#
|
|
328
281
|
# @method find_function(ee, name, out_fn)
|
|
329
|
-
# @param [OpaqueExecutionEngine] ee
|
|
330
|
-
# @param [String] name
|
|
331
|
-
# @param [FFI::Pointer(*ValueRef)] out_fn
|
|
332
|
-
# @return [Integer]
|
|
282
|
+
# @param [OpaqueExecutionEngine] ee
|
|
283
|
+
# @param [String] name
|
|
284
|
+
# @param [FFI::Pointer(*ValueRef)] out_fn
|
|
285
|
+
# @return [Integer]
|
|
333
286
|
# @scope class
|
|
334
287
|
attach_function :find_function, :LLVMFindFunction, [OpaqueExecutionEngine, :string, :pointer], :int
|
|
335
|
-
|
|
288
|
+
|
|
336
289
|
# (Not documented)
|
|
337
|
-
#
|
|
290
|
+
#
|
|
338
291
|
# @method recompile_and_relink_function(ee, fn)
|
|
339
|
-
# @param [OpaqueExecutionEngine] ee
|
|
340
|
-
# @param [FFI::Pointer(ValueRef)] fn
|
|
341
|
-
# @return [FFI::Pointer(*Void)]
|
|
292
|
+
# @param [OpaqueExecutionEngine] ee
|
|
293
|
+
# @param [FFI::Pointer(ValueRef)] fn
|
|
294
|
+
# @return [FFI::Pointer(*Void)]
|
|
342
295
|
# @scope class
|
|
343
296
|
attach_function :recompile_and_relink_function, :LLVMRecompileAndRelinkFunction, [OpaqueExecutionEngine, :pointer], :pointer
|
|
344
|
-
|
|
297
|
+
|
|
345
298
|
# (Not documented)
|
|
346
|
-
#
|
|
299
|
+
#
|
|
347
300
|
# @method get_execution_engine_target_data(ee)
|
|
348
|
-
# @param [OpaqueExecutionEngine] ee
|
|
349
|
-
# @return [FFI::Pointer(TargetDataRef)]
|
|
301
|
+
# @param [OpaqueExecutionEngine] ee
|
|
302
|
+
# @return [FFI::Pointer(TargetDataRef)]
|
|
350
303
|
# @scope class
|
|
351
304
|
attach_function :get_execution_engine_target_data, :LLVMGetExecutionEngineTargetData, [OpaqueExecutionEngine], :pointer
|
|
352
|
-
|
|
305
|
+
|
|
353
306
|
# (Not documented)
|
|
354
|
-
#
|
|
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
|
+
#
|
|
355
316
|
# @method add_global_mapping(ee, global, addr)
|
|
356
|
-
# @param [OpaqueExecutionEngine] ee
|
|
357
|
-
# @param [FFI::Pointer(ValueRef)] global
|
|
358
|
-
# @param [FFI::Pointer(*Void)] addr
|
|
359
|
-
# @return [nil]
|
|
317
|
+
# @param [OpaqueExecutionEngine] ee
|
|
318
|
+
# @param [FFI::Pointer(ValueRef)] global
|
|
319
|
+
# @param [FFI::Pointer(*Void)] addr
|
|
320
|
+
# @return [nil]
|
|
360
321
|
# @scope class
|
|
361
322
|
attach_function :add_global_mapping, :LLVMAddGlobalMapping, [OpaqueExecutionEngine, :pointer, :pointer], :void
|
|
362
|
-
|
|
323
|
+
|
|
363
324
|
# (Not documented)
|
|
364
|
-
#
|
|
325
|
+
#
|
|
365
326
|
# @method get_pointer_to_global(ee, global)
|
|
366
|
-
# @param [OpaqueExecutionEngine] ee
|
|
367
|
-
# @param [FFI::Pointer(ValueRef)] global
|
|
368
|
-
# @return [FFI::Pointer(*Void)]
|
|
327
|
+
# @param [OpaqueExecutionEngine] ee
|
|
328
|
+
# @param [FFI::Pointer(ValueRef)] global
|
|
329
|
+
# @return [FFI::Pointer(*Void)]
|
|
369
330
|
# @scope class
|
|
370
331
|
attach_function :get_pointer_to_global, :LLVMGetPointerToGlobal, [OpaqueExecutionEngine, :pointer], :pointer
|
|
371
|
-
|
|
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
|
+
|
|
351
|
+
# ===-- Operations on memory managers -------------------------------------===
|
|
352
|
+
#
|
|
353
|
+
# <em>This entry is only for documentation and no real method.</em>
|
|
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
|
+
#
|
|
368
|
+
# <em>This entry is only for documentation and no real method.</em>
|
|
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
|
+
#
|
|
384
|
+
# <em>This entry is only for documentation and no real method.</em>
|
|
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
|
+
|
|
394
|
+
# Create a simple custom MCJIT memory manager. This memory manager can
|
|
395
|
+
# intercept allocations in a module-oblivious way. This will return NULL
|
|
396
|
+
# if any of the passed functions are NULL.
|
|
397
|
+
#
|
|
398
|
+
# @param Opaque An opaque client object to pass back to the callbacks.
|
|
399
|
+
# @param AllocateCodeSection Allocate a block of memory for executable code.
|
|
400
|
+
# @param AllocateDataSection Allocate a block of memory for data.
|
|
401
|
+
# @param FinalizeMemory Set page permissions and flush cache. Return 0 on
|
|
402
|
+
# success, 1 on error.
|
|
403
|
+
#
|
|
404
|
+
# @method create_simple_mcjit_memory_manager(opaque, allocate_code_section, allocate_data_section, finalize_memory, destroy)
|
|
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]
|
|
411
|
+
# @scope class
|
|
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
|
|
413
|
+
|
|
414
|
+
# (Not documented)
|
|
415
|
+
#
|
|
416
|
+
# @method dispose_mcjit_memory_manager(mm)
|
|
417
|
+
# @param [OpaqueMCJITMemoryManager] mm
|
|
418
|
+
# @return [nil]
|
|
419
|
+
# @scope class
|
|
420
|
+
attach_function :dispose_mcjit_memory_manager, :LLVMDisposeMCJITMemoryManager, [OpaqueMCJITMemoryManager], :void
|
|
372
421
|
end
|