ruby-llvm 21.1.0 → 22.1.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.
data/lib/llvm/support.rb CHANGED
@@ -15,21 +15,24 @@ module LLVM
15
15
  ffi_lib [lib_path]
16
16
 
17
17
  attach_function :initialize_all_target_infos,
18
- :LLVMInitializeAllTargetInfos, [], :void
18
+ :LLVMInitializeAllTargetInfos, [], :void
19
19
  attach_function :initialize_all_targets,
20
- :LLVMInitializeAllTargets, [], :void
20
+ :LLVMInitializeAllTargets, [], :void
21
21
  attach_function :initialize_all_target_mcs,
22
- :LLVMInitializeAllTargetMCs, [], :void
22
+ :LLVMInitializeAllTargetMCs, [], :void
23
23
  attach_function :initialize_all_asm_printers,
24
- :LLVMInitializeAllAsmPrinters, [], :void
24
+ :LLVMInitializeAllAsmPrinters, [], :void
25
25
 
26
26
  attach_function :initialize_native_target,
27
- :LLVMInitializeNativeTarget, [], :void
27
+ :LLVMInitializeNativeTarget, [], :void
28
28
  attach_function :initialize_native_asm_printer,
29
- :LLVMInitializeNativeAsmPrinter, [], :void
29
+ :LLVMInitializeNativeAsmPrinter, [], :void
30
30
 
31
31
  attach_function :get_enum_attribute_name_for_kind, :LLVMGetEnumAttributeNameForKind, [:uint], :string
32
- attach_function :get_attribute_as_string, :LLVMGetAttributeAsString, [:pointer], :string
32
+ attach_function :get_attribute_as_string, :LLVMGetAttributeAsString, [:pointer], LLVM::OwnedString
33
+ attach_function :print_module_to_string_debug, :LLVMPrintModuleToStringDebug, [:pointer], LLVM::OwnedString
34
+ attach_function :print_value_to_string_debug, :LLVMPrintValueToStringDebug, [:pointer], LLVM::OwnedString
35
+ attach_function :print_type_to_string_debug, :LLVMPrintTypeToStringDebug, [:pointer], LLVM::OwnedString
33
36
  end
34
37
  end
35
38
 
data/lib/llvm/target.rb CHANGED
@@ -29,7 +29,8 @@ module LLVM
29
29
  module TargetModule
30
30
  extend FFI::Library
31
31
 
32
- ffi_lib ["LLVM-21", "libLLVM-21.so.1", "libLLVM.so.21", "libLLVM.so.21.1"]
32
+ ffi_lib LLVM::LIB_NAMES
33
+
33
34
  #: (*untyped) -> void
34
35
  def self.safe_attach_function(*args)
35
36
  attach_function(
@@ -57,9 +58,9 @@ module LLVM
57
58
  C.extend(target_module)
58
59
 
59
60
  begin
60
- %W(initialize_target_info_#{target}
61
+ %W[initialize_target_info_#{target}
61
62
  initialize_target_#{target}
62
- initialize_target_#{target}_mc).each do |init|
63
+ initialize_target_#{target}_mc].each do |init|
63
64
  C.send init
64
65
  end
65
66
  rescue FFI::NotFoundError
@@ -122,9 +123,14 @@ module LLVM
122
123
  # @private
123
124
  #: (FFI::Pointer) -> Target
124
125
  def self.from_ptr(ptr)
125
- target = allocate
126
- target.instance_variable_set :@ptr, ptr
127
- target
126
+ new(ptr)
127
+ end
128
+
129
+ # @private
130
+ #: (FFI::Pointer) -> void
131
+ def initialize(ptr)
132
+ raise ArgumentError if ptr.null?
133
+ @ptr = ptr
128
134
  end
129
135
 
130
136
  # Returns the name of the target.
@@ -168,7 +174,7 @@ module LLVM
168
174
  def create_machine(triple, cpu = "", features = "",
169
175
  opt_level = :default, reloc = :default, code_model = :default)
170
176
  TargetMachine.from_ptr(C.create_target_machine(self,
171
- triple, cpu, features, opt_level, reloc, code_model))
177
+ triple, cpu, features, opt_level, reloc, code_model))
172
178
  end
173
179
  end
174
180
 
@@ -176,10 +182,16 @@ module LLVM
176
182
  include PointerIdentity
177
183
 
178
184
  # @private
185
+ #: (FFI::Pointer) -> TargetMachine
179
186
  def self.from_ptr(ptr)
180
- target = allocate
181
- target.instance_variable_set :@ptr, ptr
182
- target
187
+ new(ptr)
188
+ end
189
+
190
+ # @private
191
+ #: (FFI::Pointer) -> void
192
+ def initialize(ptr)
193
+ raise ArgumentError if ptr.null?
194
+ @ptr = ptr #: FFI::Pointer?
183
195
  end
184
196
 
185
197
  # Destroys this instance of TargetMachine.
@@ -224,9 +236,8 @@ module LLVM
224
236
 
225
237
  # @private
226
238
  module C
227
- # ffi_gen autodetects :string, which is too weak to be usable
228
- # with LLVMDisposeMessage
229
- attach_function :copy_string_rep_of_target_data, :LLVMCopyStringRepOfTargetData, [OpaqueTargetData], :pointer
239
+ # ffi_gen autodetects :string, which leaks the caller-owned buffer
240
+ attach_function :copy_string_rep_of_target_data, :LLVMCopyStringRepOfTargetData, [OpaqueTargetData], LLVM::OwnedString
230
241
  end
231
242
 
232
243
  class TargetDataLayout
@@ -238,6 +249,7 @@ module LLVM
238
249
  end
239
250
 
240
251
  # @private
252
+ #: (FFI::Pointer) -> TargetDataLayout
241
253
  def self.from_ptr(ptr)
242
254
  target = allocate
243
255
  target.instance_variable_set :@ptr, ptr
@@ -261,11 +273,7 @@ module LLVM
261
273
  #
262
274
  # @return [String]
263
275
  def to_s
264
- string_ptr = C.copy_string_rep_of_target_data(self)
265
- string = string_ptr.read_string
266
- C.dispose_message(string_ptr)
267
-
268
- string
276
+ C.copy_string_rep_of_target_data(self)
269
277
  end
270
278
 
271
279
  # Returns the byte order of a target, either :big_endian or :little_endian.
@@ -1,11 +1,9 @@
1
1
  # Generated by ffi_gen. Please do not change this file by hand.
2
2
 
3
3
  require 'ffi'
4
+ require 'llvm/core_ffi'
4
5
 
5
6
  module LLVM::C
6
- extend FFI::Library
7
-
8
- ffi_lib ["LLVM-21", "libLLVM-21.so.1", "libLLVM.so.21", "libLLVM.so.21.1"]
9
7
  # (Not documented)
10
8
  #
11
9
  # <em>This entry is only for documentation and no real method. The FFI::Enum can be accessed via #enum_type(:byte_ordering).</em>
@@ -518,7 +516,7 @@ module LLVM::C
518
516
  # @param [OpaqueTargetMachine] t
519
517
  # @return [String]
520
518
  # @scope class
521
- attach_function :get_target_machine_triple, :LLVMGetTargetMachineTriple, [OpaqueTargetMachine], :string
519
+ attach_function :get_target_machine_triple, :LLVMGetTargetMachineTriple, [OpaqueTargetMachine], LLVM::OwnedString
522
520
 
523
521
  # Returns the cpu used creating this target machine. See
524
522
  # llvm::TargetMachine::getCPU. The result needs to be disposed with
@@ -528,7 +526,7 @@ module LLVM::C
528
526
  # @param [OpaqueTargetMachine] t
529
527
  # @return [String]
530
528
  # @scope class
531
- attach_function :get_target_machine_cpu, :LLVMGetTargetMachineCPU, [OpaqueTargetMachine], :string
529
+ attach_function :get_target_machine_cpu, :LLVMGetTargetMachineCPU, [OpaqueTargetMachine], LLVM::OwnedString
532
530
 
533
531
  # Returns the feature string used creating this target machine. See
534
532
  # llvm::TargetMachine::getFeatureString. The result needs to be disposed with
@@ -538,7 +536,7 @@ module LLVM::C
538
536
  # @param [OpaqueTargetMachine] t
539
537
  # @return [String]
540
538
  # @scope class
541
- attach_function :get_target_machine_feature_string, :LLVMGetTargetMachineFeatureString, [OpaqueTargetMachine], :string
539
+ attach_function :get_target_machine_feature_string, :LLVMGetTargetMachineFeatureString, [OpaqueTargetMachine], LLVM::OwnedString
542
540
 
543
541
  # Create a DataLayout based on the targetMachine.
544
542
  #
@@ -589,7 +587,7 @@ module LLVM::C
589
587
  # @method get_default_target_triple()
590
588
  # @return [String]
591
589
  # @scope class
592
- attach_function :get_default_target_triple, :LLVMGetDefaultTargetTriple, [], :string
590
+ attach_function :get_default_target_triple, :LLVMGetDefaultTargetTriple, [], LLVM::OwnedString
593
591
 
594
592
  # Adds the target-specific analysis passes to the pass manager.
595
593
  #
data/lib/llvm/version.rb CHANGED
@@ -2,7 +2,27 @@
2
2
  # typed: strict
3
3
 
4
4
  module LLVM
5
- LLVM_VERSION = "21"
6
- LLVM_REQUIRED_VERSION = "21.1.0"
7
- RUBY_LLVM_VERSION = "21.1.0"
5
+ LLVM_VERSION = "22"
6
+ LLVM_REQUIRED_VERSION = "22.1"
7
+ RUBY_LLVM_VERSION = "22.1.0"
8
+
9
+ # Candidate names for the shared library, tried in order by ffi_lib until one
10
+ # loads. Each entry targets a different platform/packaging scheme, so the
11
+ # ones that miss on any given system are expected, not dead weight:
12
+ #
13
+ # LLVM-22 undecorated; FFI.map_library_name adds the platform
14
+ # form -- libLLVM-22.dylib on macOS, libLLVM-22.so on
15
+ # Linux. The only entry that can match on macOS, since
16
+ # the others are literal .so names. Moved to the front in
17
+ # ec556af (LLVM 19), alongside homebrew CI support.
18
+ # libLLVM.so.22 openSUSE layout. Added in 9246958 (LLVM 10) --
19
+ # "Support libLLVM.so.<version> as used in openSUSE".
20
+ # libLLVM.so.22.1 Debian/Ubuntu layout since LLVM 19, and the real file on
21
+ # current systems; added in ec556af to work around the
22
+ # LLVM 19 packaging change.
23
+ LIB_NAMES = [
24
+ "LLVM-#{LLVM_VERSION}",
25
+ "libLLVM.so.#{LLVM_VERSION}",
26
+ "libLLVM.so.#{LLVM_REQUIRED_VERSION}",
27
+ ].freeze #: Array[String]
8
28
  end
data/lib/llvm.rb CHANGED
@@ -22,7 +22,7 @@ module LLVM
22
22
  #: (untyped) -> bool
23
23
  def ==(other)
24
24
  other.respond_to?(:to_ptr) &&
25
- ptr == other.to_ptr
25
+ ptr == other.to_ptr
26
26
  end
27
27
 
28
28
  # Computes hash.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-llvm
3
3
  version: !ruby/object:Gem::Version
4
- version: 21.1.0
4
+ version: 22.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesse Johnson
@@ -45,7 +45,7 @@ dependencies:
45
45
  - !ruby/object:Gem::Version
46
46
  version: '14'
47
47
  - !ruby/object:Gem::Dependency
48
- name: debug
48
+ name: benchmark
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - ">="
@@ -100,48 +100,6 @@ dependencies:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
102
  version: '1.5'
103
- - !ruby/object:Gem::Dependency
104
- name: rubocop
105
- requirement: !ruby/object:Gem::Requirement
106
- requirements:
107
- - - "~>"
108
- - !ruby/object:Gem::Version
109
- version: '1.31'
110
- type: :development
111
- prerelease: false
112
- version_requirements: !ruby/object:Gem::Requirement
113
- requirements:
114
- - - "~>"
115
- - !ruby/object:Gem::Version
116
- version: '1.31'
117
- - !ruby/object:Gem::Dependency
118
- name: rubocop-minitest
119
- requirement: !ruby/object:Gem::Requirement
120
- requirements:
121
- - - ">="
122
- - !ruby/object:Gem::Version
123
- version: '0'
124
- type: :development
125
- prerelease: false
126
- version_requirements: !ruby/object:Gem::Requirement
127
- requirements:
128
- - - ">="
129
- - !ruby/object:Gem::Version
130
- version: '0'
131
- - !ruby/object:Gem::Dependency
132
- name: rubocop-performance
133
- requirement: !ruby/object:Gem::Requirement
134
- requirements:
135
- - - ">="
136
- - !ruby/object:Gem::Version
137
- version: '0'
138
- type: :development
139
- prerelease: false
140
- version_requirements: !ruby/object:Gem::Requirement
141
- requirements:
142
- - - ">="
143
- - !ruby/object:Gem::Version
144
- version: '0'
145
103
  - !ruby/object:Gem::Dependency
146
104
  name: simplecov
147
105
  requirement: !ruby/object:Gem::Requirement
@@ -170,20 +128,6 @@ dependencies:
170
128
  - - ">="
171
129
  - !ruby/object:Gem::Version
172
130
  version: '0'
173
- - !ruby/object:Gem::Dependency
174
- name: tapioca
175
- requirement: !ruby/object:Gem::Requirement
176
- requirements:
177
- - - "~>"
178
- - !ruby/object:Gem::Version
179
- version: 0.16.11
180
- type: :development
181
- prerelease: false
182
- version_requirements: !ruby/object:Gem::Requirement
183
- requirements:
184
- - - "~>"
185
- - !ruby/object:Gem::Version
186
- version: 0.16.11
187
131
  - !ruby/object:Gem::Dependency
188
132
  name: yard
189
133
  requirement: !ruby/object:Gem::Requirement
@@ -217,7 +161,6 @@ files:
217
161
  - lib/llvm.rb
218
162
  - lib/llvm/analysis.rb
219
163
  - lib/llvm/analysis_ffi.rb
220
- - lib/llvm/config.rb
221
164
  - lib/llvm/core.rb
222
165
  - lib/llvm/core/attribute.rb
223
166
  - lib/llvm/core/bitcode.rb
@@ -235,6 +178,7 @@ files:
235
178
  - lib/llvm/linker.rb
236
179
  - lib/llvm/linker_ffi.rb
237
180
  - lib/llvm/lljit.rb
181
+ - lib/llvm/owned_string.rb
238
182
  - lib/llvm/pass_builder.rb
239
183
  - lib/llvm/support.rb
240
184
  - lib/llvm/target.rb
@@ -246,7 +190,8 @@ files:
246
190
  - lib/llvm/transforms/vectorize.rb
247
191
  - lib/llvm/version.rb
248
192
  homepage: http://github.com/ruby-llvm/ruby-llvm
249
- licenses: []
193
+ licenses:
194
+ - BSD-3-Clause
250
195
  metadata:
251
196
  rubygems_mfa_required: 'true'
252
197
  rdoc_options: []
data/lib/llvm/config.rb DELETED
@@ -1,14 +0,0 @@
1
- # Generated by ruby-llvm. Please do not change this file by hand.
2
- module LLVM
3
- module CONFIG
4
- VERSION = "20.1.7"
5
- COMPONENTS = ["aarch64", "aarch64asmparser", "aarch64codegen", "aarch64desc", "aarch64disassembler", "aarch64info", "aarch64utils", "aggressiveinstcombine", "all", "all-targets", "amdgpu", "amdgpuasmparser", "amdgpucodegen", "amdgpudesc", "amdgpudisassembler", "amdgpuinfo", "amdgputargetmca", "amdgpuutils", "analysis", "arm", "armasmparser", "armcodegen", "armdesc", "armdisassembler", "arminfo", "armutils", "asmparser", "asmprinter", "avr", "avrasmparser", "avrcodegen", "avrdesc", "avrdisassembler", "avrinfo", "binaryformat", "bitreader", "bitstreamreader", "bitwriter", "bpf", "bpfasmparser", "bpfcodegen", "bpfdesc", "bpfdisassembler", "bpfinfo", "cfguard", "cgdata", "codegen", "codegentypes", "core", "coroutines", "coverage", "debuginfobtf", "debuginfocodeview", "debuginfodwarf", "debuginfogsym", "debuginfologicalview", "debuginfomsf", "debuginfopdb", "demangle", "dlltooldriver", "dwarflinker", "dwarflinkerclassic", "dwarflinkerparallel", "dwp", "engine", "executionengine", "extensions", "filecheck", "frontendatomic", "frontenddriver", "frontendhlsl", "frontendoffloading", "frontendopenacc", "frontendopenmp", "fuzzercli", "fuzzmutate", "globalisel", "hexagon", "hexagonasmparser", "hexagoncodegen", "hexagondesc", "hexagondisassembler", "hexagoninfo", "hipstdpar", "instcombine", "instrumentation", "interfacestub", "interpreter", "ipo", "irprinter", "irreader", "jitlink", "lanai", "lanaiasmparser", "lanaicodegen", "lanaidesc", "lanaidisassembler", "lanaiinfo", "libdriver", "lineeditor", "linker", "loongarch", "loongarchasmparser", "loongarchcodegen", "loongarchdesc", "loongarchdisassembler", "loongarchinfo", "lto", "m68k", "m68kasmparser", "m68kcodegen", "m68kdesc", "m68kdisassembler", "m68kinfo", "mc", "mca", "mcdisassembler", "mcjit", "mcparser", "mips", "mipsasmparser", "mipscodegen", "mipsdesc", "mipsdisassembler", "mipsinfo", "mirparser", "msp430", "msp430asmparser", "msp430codegen", "msp430desc", "msp430disassembler", "msp430info", "native", "nativecodegen", "nvptx", "nvptxcodegen", "nvptxdesc", "nvptxinfo", "objcarcopts", "objcopy", "object", "objectyaml", "option", "orcdebugging", "orcjit", "orcshared", "orctargetprocess", "passes", "perfjitevents", "powerpc", "powerpcasmparser", "powerpccodegen", "powerpcdesc", "powerpcdisassembler", "powerpcinfo", "profiledata", "remarks", "riscv", "riscvasmparser", "riscvcodegen", "riscvdesc", "riscvdisassembler", "riscvinfo", "riscvtargetmca", "runtimedyld", "sandboxir", "scalaropts", "selectiondag", "sparc", "sparcasmparser", "sparccodegen", "sparcdesc", "sparcdisassembler", "sparcinfo", "spirv", "spirvanalysis", "spirvcodegen", "spirvdesc", "spirvinfo", "support", "symbolize", "systemz", "systemzasmparser", "systemzcodegen", "systemzdesc", "systemzdisassembler", "systemzinfo", "tablegen", "target", "targetparser", "telemetry", "textapi", "textapibinaryreader", "transformutils", "ve", "veasmparser", "vecodegen", "vectorize", "vedesc", "vedisassembler", "veinfo", "webassembly", "webassemblyasmparser", "webassemblycodegen", "webassemblydesc", "webassemblydisassembler", "webassemblyinfo", "webassemblyutils", "windowsdriver", "windowsmanifest", "x86", "x86asmparser", "x86codegen", "x86desc", "x86disassembler", "x86info", "x86targetmca", "xcore", "xcorecodegen", "xcoredesc", "xcoredisassembler", "xcoreinfo", "xray", "xtensa", "xtensaasmparser", "xtensacodegen", "xtensadesc", "xtensadisassembler", "xtensainfo"]
6
- TARGETS_BUILT = ["AArch64", "AMDGPU", "ARM", "AVR", "BPF", "Hexagon", "Lanai", "LoongArch", "Mips", "MSP430", "NVPTX", "PowerPC", "RISCV", "Sparc", "SPIRV", "SystemZ", "VE", "WebAssembly", "X86", "XCore", "M68k", "Xtensa"]
7
- HOST_TARGET = "x86_64-pc-linux-gnu"
8
- BUILD_MODE = "RelWithDebInfo"
9
- CFLAGS = "-I/usr/lib/llvm-20/include -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS"
10
- CXXFLAGS = "-I/usr/lib/llvm-20/include -std=c++17 -fno-exceptions -funwind-tables -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS"
11
- LDFLAGS = "-L/usr/lib/llvm-20/lib"
12
- LIBS = "-lLLVM-20"
13
- end
14
- end