ruby-llvm 3.5.0 → 13.0.1
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 +21 -4
- data/ext/ruby-llvm-support/Rakefile +17 -6
- data/lib/llvm/analysis.rb +2 -0
- data/lib/llvm/analysis_ffi.rb +27 -28
- data/lib/llvm/config.rb +4 -4
- data/lib/llvm/core/bitcode.rb +12 -10
- data/lib/llvm/core/bitcode_ffi.rb +89 -65
- data/lib/llvm/core/builder.rb +4 -3
- data/lib/llvm/core/context.rb +3 -1
- data/lib/llvm/core/module.rb +2 -0
- data/lib/llvm/core/pass_manager.rb +6 -2
- data/lib/llvm/core/type.rb +9 -2
- data/lib/llvm/core/value.rb +154 -24
- data/lib/llvm/core.rb +47 -2
- data/lib/llvm/core_ffi.rb +3863 -3730
- data/lib/llvm/execution_engine.rb +39 -35
- data/lib/llvm/execution_engine_ffi.rb +238 -276
- data/lib/llvm/linker.rb +3 -14
- data/lib/llvm/linker_ffi.rb +22 -26
- data/lib/llvm/support.rb +2 -0
- data/lib/llvm/target.rb +11 -15
- data/lib/llvm/target_ffi.rb +301 -293
- data/lib/llvm/transforms/builder.rb +3 -1
- data/lib/llvm/transforms/builder_ffi.rb +57 -58
- data/lib/llvm/transforms/ipo.rb +3 -1
- data/lib/llvm/transforms/ipo_ffi.rb +59 -60
- data/lib/llvm/transforms/scalar.rb +12 -0
- data/lib/llvm/transforms/scalar_ffi.rb +199 -143
- data/lib/llvm/transforms/vectorize.rb +2 -0
- data/lib/llvm/transforms/vectorize_ffi.rb +15 -16
- data/lib/llvm/version.rb +5 -2
- data/lib/llvm.rb +2 -0
- data/test/array_test.rb +2 -0
- data/test/basic_block_test.rb +2 -1
- data/test/binary_operations_test.rb +2 -0
- data/test/bitcode_test.rb +3 -2
- data/test/branch_test.rb +2 -0
- data/test/call_test.rb +3 -1
- data/test/comparisons_test.rb +2 -0
- data/test/conversions_test.rb +2 -0
- data/test/double_test.rb +10 -7
- data/test/equality_test.rb +4 -4
- data/test/function_test.rb +29 -0
- data/test/generic_value_test.rb +3 -1
- data/test/instruction_test.rb +2 -2
- data/test/integer_test.rb +28 -0
- data/test/ipo_test.rb +3 -1
- data/test/linker_test.rb +2 -9
- data/test/mcjit_test.rb +11 -3
- data/test/memory_access_test.rb +2 -0
- data/test/module_test.rb +18 -1
- data/test/parameter_collection_test.rb +2 -0
- data/test/pass_manager_builder_test.rb +22 -2
- data/test/phi_test.rb +2 -0
- data/test/select_test.rb +2 -0
- data/test/struct_test.rb +2 -0
- data/test/target_test.rb +16 -20
- data/test/test_helper.rb +6 -1
- data/test/type_test.rb +47 -0
- data/test/vector_test.rb +2 -0
- metadata +105 -40
data/lib/llvm/linker.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'llvm'
|
2
4
|
require 'llvm/core'
|
3
5
|
require 'llvm/linker_ffi'
|
@@ -9,21 +11,8 @@ module LLVM
|
|
9
11
|
# @return [nil, String] human-readable error if linking has failed
|
10
12
|
def link_into(other)
|
11
13
|
LLVM.with_message_output do |msg|
|
12
|
-
C.
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
# Link the current module into +other+, and dispose the current module.
|
17
|
-
#
|
18
|
-
# @return [nil, String] human-readable error if linking has failed
|
19
|
-
def link_into_and_destroy(other)
|
20
|
-
result = LLVM.with_message_output do |msg|
|
21
|
-
C.link_modules(other, self, :destroy_source, msg)
|
14
|
+
C.link_modules2(other, self)
|
22
15
|
end
|
23
|
-
|
24
|
-
@ptr = nil
|
25
|
-
|
26
|
-
result
|
27
16
|
end
|
28
17
|
end
|
29
18
|
end
|
data/lib/llvm/linker_ffi.rb
CHANGED
@@ -4,45 +4,41 @@ require 'ffi'
|
|
4
4
|
|
5
5
|
module LLVM::C
|
6
6
|
extend FFI::Library
|
7
|
-
ffi_lib ["libLLVM-
|
8
|
-
|
7
|
+
ffi_lib ["libLLVM-13.so.1", "libLLVM.so.13", "LLVM-13"]
|
8
|
+
|
9
9
|
def self.attach_function(name, *_)
|
10
10
|
begin; super; rescue FFI::NotFoundError => e
|
11
11
|
(class << self; self; end).class_eval { define_method(name) { |*_| raise e } }
|
12
12
|
end
|
13
13
|
end
|
14
|
-
|
15
|
-
#
|
16
|
-
#
|
14
|
+
|
15
|
+
# This enum is provided for backwards-compatibility only. It has no effect.
|
16
|
+
#
|
17
17
|
# <em>This entry is only for documentation and no real method. The FFI::Enum can be accessed via #enum_type(:linker_mode).</em>
|
18
|
-
#
|
18
|
+
#
|
19
19
|
# === Options:
|
20
20
|
# :destroy_source ::
|
21
|
-
#
|
22
|
-
# :
|
23
|
-
#
|
24
|
-
#
|
21
|
+
#
|
22
|
+
# :preserve_source_removed ::
|
23
|
+
# This is the default behavior.
|
24
|
+
#
|
25
25
|
# @method _enum_linker_mode_
|
26
26
|
# @return [Symbol]
|
27
27
|
# @scope class
|
28
28
|
enum :linker_mode, [
|
29
29
|
:destroy_source, 0,
|
30
|
-
:
|
30
|
+
:preserve_source_removed, 1
|
31
31
|
]
|
32
|
-
|
33
|
-
# Links the source module into the destination module
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
# @
|
40
|
-
# @param [FFI::Pointer(ModuleRef)]
|
41
|
-
# @
|
42
|
-
# @param [Symbol from _enum_linker_mode_] mode
|
43
|
-
# @param [FFI::Pointer(**CharS)] out_message
|
44
|
-
# @return [Integer]
|
32
|
+
|
33
|
+
# Links the source module into the destination module. The source module is
|
34
|
+
# destroyed.
|
35
|
+
# The return value is true if an error occurred, false otherwise.
|
36
|
+
# Use the diagnostic handler to get any diagnostic message.
|
37
|
+
#
|
38
|
+
# @method link_modules2(dest, src)
|
39
|
+
# @param [FFI::Pointer(ModuleRef)] dest
|
40
|
+
# @param [FFI::Pointer(ModuleRef)] src
|
41
|
+
# @return [Integer]
|
45
42
|
# @scope class
|
46
|
-
attach_function :
|
47
|
-
|
43
|
+
attach_function :link_modules2, :LLVMLinkModules2, [:pointer, :pointer], :int
|
48
44
|
end
|
data/lib/llvm/support.rb
CHANGED
data/lib/llvm/target.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'llvm'
|
2
4
|
require 'llvm/core'
|
3
5
|
require 'llvm/target_ffi'
|
@@ -20,7 +22,7 @@ module LLVM
|
|
20
22
|
#
|
21
23
|
# @param [String] target Target name in LLVM format, e.g. "X86", "ARM" or "PowerPC".
|
22
24
|
# @param [true, false] asm_printer Initialize corresponding AsmPrinter.
|
23
|
-
def self.init(target, asm_printer=false)
|
25
|
+
def self.init(target, asm_printer = false)
|
24
26
|
C.module_eval do
|
25
27
|
attach_function :"initialize_target_info_#{target}",
|
26
28
|
:"LLVMInitialize#{target}TargetInfo", [], :void
|
@@ -57,7 +59,7 @@ module LLVM
|
|
57
59
|
# Initializes all available targets.
|
58
60
|
#
|
59
61
|
# @param [true, false] asm_printer Initialize corresponding AsmPrinters.
|
60
|
-
def self.init_all(asm_printer=false)
|
62
|
+
def self.init_all(asm_printer = false)
|
61
63
|
Support::C.initialize_all_target_infos
|
62
64
|
Support::C.initialize_all_targets
|
63
65
|
Support::C.initialize_all_target_mcs
|
@@ -68,7 +70,8 @@ module LLVM
|
|
68
70
|
# Initializes native target. Useful for JIT applications.
|
69
71
|
#
|
70
72
|
# @param [true, false] asm_printer Initialize corresponding AsmPrinter.
|
71
|
-
|
73
|
+
# True by default, as this is required for MCJIT to function.
|
74
|
+
def self.init_native(asm_printer = true)
|
72
75
|
Support::C.initialize_native_target
|
73
76
|
|
74
77
|
Support::C.initialize_native_asm_printer if asm_printer
|
@@ -144,8 +147,8 @@ module LLVM
|
|
144
147
|
# @param [Symbol] reloc :default, :static, :pic, :dynamic_no_pic
|
145
148
|
# @param [Symbol] code_model :default, :jit_default, :small, :kernel, :medium, :large
|
146
149
|
# @return [TargetMachine]
|
147
|
-
def create_machine(triple, cpu="", features="",
|
148
|
-
opt_level
|
150
|
+
def create_machine(triple, cpu = "", features = "",
|
151
|
+
opt_level = :default, reloc = :default, code_model = :default)
|
149
152
|
TargetMachine.from_ptr(C.create_target_machine(self,
|
150
153
|
triple, cpu, features, opt_level, reloc, code_model))
|
151
154
|
end
|
@@ -191,17 +194,10 @@ module LLVM
|
|
191
194
|
C.get_target_machine_feature_string(self)
|
192
195
|
end
|
193
196
|
|
194
|
-
# Returns the data layout used for this target machine.
|
195
|
-
#
|
196
|
-
# @return [TargetDataLayout]
|
197
|
-
def data_layout
|
198
|
-
TargetDataLayout.from_ptr(C.get_target_machine_data(self))
|
199
|
-
end
|
200
|
-
|
201
197
|
# Emits an asm or object file for the given module.
|
202
198
|
#
|
203
199
|
# @param [Symbol] codegen :assembly, :object
|
204
|
-
def emit(mod, filename, codegen
|
200
|
+
def emit(mod, filename, codegen = :assembly)
|
205
201
|
LLVM.with_error_output do |err|
|
206
202
|
C.target_machine_emit_to_file(self, mod, filename.to_s, codegen, err)
|
207
203
|
end
|
@@ -262,14 +258,14 @@ module LLVM
|
|
262
258
|
# Returns the pointer size in bytes for a target.
|
263
259
|
#
|
264
260
|
# @param [Integer] addr_space address space number
|
265
|
-
def pointer_size(addr_space=0)
|
261
|
+
def pointer_size(addr_space = 0)
|
266
262
|
C.pointer_size_for_as(self, addr_space)
|
267
263
|
end
|
268
264
|
|
269
265
|
# Returns the integer type that is the same size as a pointer on a target.
|
270
266
|
#
|
271
267
|
# @param [Integer] addr_space address space number
|
272
|
-
def int_ptr_type(addr_space=0)
|
268
|
+
def int_ptr_type(addr_space = 0)
|
273
269
|
Type.from_ptr(C.int_ptr_type_for_as(self, addr_space), :integer)
|
274
270
|
end
|
275
271
|
|