ruby-llvm 15.0.4 → 16.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a9606baaed260920d087cafdc03a4524875a11378d9e15792128ec7df9946c7b
4
- data.tar.gz: 0fba76718a8f7dfd2ee63993eb9ceecb94d0feb75d286997a3dc651ac966ecf7
3
+ metadata.gz: eab8e45c12865b1daf5e471e0e01d59a80580a910fffb0b698c53602ce49fd66
4
+ data.tar.gz: e2b3bbf235ab6a378cb322e69e255b17e3f29f38af990e2c2c315b603cd8f534
5
5
  SHA512:
6
- metadata.gz: 1c095bf095482f67ca94efc4e36c7d04fb5f82f65b9a483c79239e9bcb91fa4da0f6ed76b77259140a9d17e3a268d77fb05899b59a7469d5d664d808ff8be53a
7
- data.tar.gz: 88b3dae5b535fdf9d7a6cd0225e3b809b7f54c2d072668516e53a18298953a9d4daa68669e7b01ddb0ddb03a044975828741eecf47b3683f66bfa229e44d3ead
6
+ metadata.gz: 6aefeb6655934955bfaa5073541d028488c053094c7e47ea6ef4562833f3c84cd52e100641a921671213d1f8d792cc8b1b839312caf0acf12a449a310cd13292
7
+ data.tar.gz: d8d01c13ec575e0ba7f5f9b2bdd11cb66c10bdfb6e0eb39187f151c81fa810dddfae34763d2e2bdc5cf30bacd71dc9034f1f4dab5c2c8bcfff5072710edc652b
@@ -76,18 +76,22 @@ CLEAN.include(SUPPORT_LIB, CONFIG_MOD)
76
76
  desc "Build the shared library and config module"
77
77
  task :default => [SUPPORT_LIB, CONFIG_MOD]
78
78
 
79
+ # -I/usr/lib/llvm-14/include/c++/v1/ is needed for CI
79
80
  file SUPPORT_LIB => %w(support.cpp) do |task|
80
81
  clang_stdlib = CXX.match?(/^clang++/) ? "-stdlib=libc++" : ""
81
82
  sh "#{CXX} -O3 -shared #{task.prerequisites.join(' ')} -l#{llvm_lib_name} " \
82
- "#{invoke_llvm_config('--cxxflags --ldflags')} -fPIC #{clang_stdlib} -o #{SUPPORT_LIB}"
83
+ "#{invoke_llvm_config('--cxxflags --ldflags')} -I/usr/lib/llvm-14/include/c++/v1/ -fPIC #{clang_stdlib} -o #{SUPPORT_LIB}"
83
84
  end
84
85
 
85
86
  LLVM_CONFIG_OPTS = [
87
+ ['VERSION', :string, '--version'],
86
88
  ['COMPONENTS', :array, '--components'],
87
89
  ['TARGETS_BUILT', :array, '--targets-built'],
88
90
  ['HOST_TARGET', :string, '--host-target'],
89
91
  ['BUILD_MODE', :string, '--build-mode'],
90
92
  ['CFLAGS', :string, '--cflags'],
93
+ ['CXXFLAGS', :string, '--cxxflags'],
94
+ ['LDFLAGS', :string, '--ldflags'],
91
95
  ].freeze
92
96
 
93
97
  file CONFIG_MOD do
@@ -3,6 +3,7 @@
3
3
  */
4
4
 
5
5
  #include <llvm/Support/TargetSelect.h>
6
+ #include <llvm/IR/Attributes.h>
6
7
 
7
8
  extern "C" {
8
9
  void LLVMInitializeAllTargetInfos() {
@@ -28,5 +29,11 @@ extern "C" {
28
29
  void LLVMInitializeNativeAsmPrinter() {
29
30
  llvm::InitializeNativeTargetAsmPrinter();
30
31
  }
32
+
33
+ const char* LLVMGetEnumAttributeNameForKind(const unsigned KindID) {
34
+ const auto AttrKind = (llvm::Attribute::AttrKind) KindID;
35
+ const auto S = llvm::Attribute::getNameFromAttrKind(AttrKind);
36
+ return S.data();
37
+ }
31
38
  }
32
39
 
@@ -4,7 +4,7 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib ["libLLVM-15.so.1", "libLLVM.so.15", "LLVM-15"]
7
+ ffi_lib ["libLLVM-16.so.1", "libLLVM.so.16", "LLVM-16"]
8
8
 
9
9
  def self.attach_function(name, *_)
10
10
  begin; super; rescue FFI::NotFoundError => e
data/lib/llvm/config.rb CHANGED
@@ -1,10 +1,13 @@
1
1
  # Generated by ruby-llvm. Please do not change this file by hand.
2
2
  module LLVM
3
3
  module CONFIG
4
- 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", "codegen", "core", "coroutines", "coverage", "debuginfocodeview", "debuginfodwarf", "debuginfogsym", "debuginfomsf", "debuginfopdb", "demangle", "dlltooldriver", "dwarflinker", "dwp", "engine", "executionengine", "extensions", "filecheck", "frontendopenacc", "frontendopenmp", "fuzzercli", "fuzzmutate", "globalisel", "hexagon", "hexagonasmparser", "hexagoncodegen", "hexagondesc", "hexagondisassembler", "hexagoninfo", "instcombine", "instrumentation", "interfacestub", "interpreter", "ipo", "irreader", "jitlink", "lanai", "lanaiasmparser", "lanaicodegen", "lanaidesc", "lanaidisassembler", "lanaiinfo", "libdriver", "lineeditor", "linker", "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", "orcjit", "orcshared", "orctargetprocess", "passes", "perfjitevents", "powerpc", "powerpcasmparser", "powerpccodegen", "powerpcdesc", "powerpcdisassembler", "powerpcinfo", "profiledata", "remarks", "riscv", "riscvasmparser", "riscvcodegen", "riscvdesc", "riscvdisassembler", "riscvinfo", "runtimedyld", "scalaropts", "selectiondag", "sparc", "sparcasmparser", "sparccodegen", "sparcdesc", "sparcdisassembler", "sparcinfo", "support", "symbolize", "systemz", "systemzasmparser", "systemzcodegen", "systemzdesc", "systemzdisassembler", "systemzinfo", "tablegen", "target", "textapi", "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"]
5
- TARGETS_BUILT = ["AArch64", "AMDGPU", "ARM", "AVR", "BPF", "Hexagon", "Lanai", "Mips", "MSP430", "NVPTX", "PowerPC", "RISCV", "Sparc", "SystemZ", "VE", "WebAssembly", "X86", "XCore", "M68k"]
4
+ VERSION = "16.0.5"
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", "codegen", "core", "coroutines", "coverage", "debuginfocodeview", "debuginfodwarf", "debuginfogsym", "debuginfologicalview", "debuginfomsf", "debuginfopdb", "demangle", "dlltooldriver", "dwarflinker", "dwarflinkerparallel", "dwp", "engine", "executionengine", "extensions", "filecheck", "frontendhlsl", "frontendopenacc", "frontendopenmp", "fuzzercli", "fuzzmutate", "globalisel", "hexagon", "hexagonasmparser", "hexagoncodegen", "hexagondesc", "hexagondisassembler", "hexagoninfo", "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", "orcjit", "orcshared", "orctargetprocess", "passes", "perfjitevents", "powerpc", "powerpcasmparser", "powerpccodegen", "powerpcdesc", "powerpcdisassembler", "powerpcinfo", "profiledata", "remarks", "riscv", "riscvasmparser", "riscvcodegen", "riscvdesc", "riscvdisassembler", "riscvinfo", "riscvtargetmca", "runtimedyld", "scalaropts", "selectiondag", "sparc", "sparcasmparser", "sparccodegen", "sparcdesc", "sparcdisassembler", "sparcinfo", "support", "symbolize", "systemz", "systemzasmparser", "systemzcodegen", "systemzdesc", "systemzdisassembler", "systemzinfo", "tablegen", "target", "targetparser", "textapi", "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"]
6
+ TARGETS_BUILT = ["AArch64", "AMDGPU", "ARM", "AVR", "BPF", "Hexagon", "Lanai", "LoongArch", "Mips", "MSP430", "NVPTX", "PowerPC", "RISCV", "Sparc", "SystemZ", "VE", "WebAssembly", "X86", "XCore", "M68k"]
6
7
  HOST_TARGET = "x86_64-pc-linux-gnu"
7
- BUILD_MODE = "Release"
8
- CFLAGS = "-I/usr/lib/llvm-15/include -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS"
8
+ BUILD_MODE = "RelWithDebInfo"
9
+ CFLAGS = "-I/usr/lib/llvm-16/include -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS"
10
+ CXXFLAGS = "-I/usr/lib/llvm-16/include -std=c++17 -fno-exceptions -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS"
11
+ LDFLAGS = "-L/usr/lib/llvm-16/lib"
9
12
  end
10
13
  end
@@ -0,0 +1,158 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LLVM
4
+ class Attribute
5
+
6
+ include PointerIdentity
7
+
8
+ class << self
9
+
10
+ def new(from)
11
+ case from
12
+ when String, Symbol
13
+ enum(from)
14
+ else
15
+ raise "Not implemented to create Attribute from #{from.class}"
16
+ end
17
+ end
18
+
19
+ # create a memory attribute from a hash where the keys are:
20
+ # argmem, inaccessiblemem, memory
21
+ # and the valid values are:
22
+ # read, write, readwrite
23
+ def memory(opts = {})
24
+ opts = opts.transform_keys(&:to_sym)
25
+ val = bit_value(opts[:argmem]) | (bit_value(opts[:inaccessiblemem]) << 2) | (bit_value(opts[:memory]) << 4)
26
+ enum(:memory, val)
27
+ end
28
+
29
+ # create enum attribute with optional value and context
30
+ def enum(kind, value = 0, context = Context.global)
31
+ attr_id = attribute_id(kind)
32
+ ptr = C.create_enum_attribute(context, attr_id, value)
33
+ from_ptr(ptr)
34
+ end
35
+
36
+ # create string attribute with key and value
37
+ def string(key, value, context = Context.global)
38
+ key = key.to_s
39
+ value = value.to_s
40
+ ptr = C.create_string_attribute(context, key, key.size, value, value.size)
41
+ from_ptr(ptr)
42
+ end
43
+
44
+ def last_enum
45
+ C.get_last_enum_attribute_kind
46
+ end
47
+
48
+ private
49
+
50
+ def from_ptr(ptr)
51
+ return if ptr.null?
52
+ val = allocate
53
+ val.instance_variable_set(:@ptr, ptr)
54
+ val
55
+ end
56
+
57
+ def attribute_name(attr_name)
58
+ attr_name = attr_name.to_s
59
+ if /_attribute$/.match?(attr_name)
60
+ attr_name.chomp('_attribute').tr('_', '')
61
+ else
62
+ attr_name
63
+ end
64
+ end
65
+
66
+ def attribute_id(attr_name)
67
+ attr_mem = FFI::MemoryPointer.from_string(attribute_name(attr_name))
68
+ attr_kind_id = C.get_enum_attribute_kind_for_name(attr_mem, attr_mem.size - 1)
69
+
70
+ raise "No attribute named: #{attr_name}" if attr_kind_id.zero?
71
+ attr_kind_id
72
+ end
73
+
74
+ # returns correct 2 bits of memory value:
75
+ # 0 = none
76
+ # 1 = read
77
+ # 2 = write
78
+ # 3 = readwrite
79
+ def bit_value(maybe_value)
80
+ case maybe_value.to_s
81
+ when 'read'
82
+ 1
83
+ when 'write'
84
+ 2
85
+ when 'readwrite'
86
+ 3
87
+ else
88
+ 0
89
+ end
90
+ end
91
+
92
+ end
93
+
94
+ def kind
95
+ return enum_kind if enum?
96
+ return string_kind if string?
97
+ raise
98
+ end
99
+
100
+ def value
101
+ return C.get_enum_attribute_value(self) if enum?
102
+ return string_value if string?
103
+ raise
104
+ end
105
+
106
+ def enum?
107
+ C.is_enum_attribute(self)
108
+ end
109
+
110
+ def string?
111
+ C.is_string_attribute(self)
112
+ end
113
+
114
+ def type?
115
+ C.is_type_attribute(self)
116
+ end
117
+
118
+ def inspect
119
+ return "\"#{kind}\" = \"#{value}\"" if string?
120
+ return "#{kind}(#{value})" if enum?
121
+ super
122
+ end
123
+
124
+ def to_s
125
+ return kind if enum?
126
+ super
127
+ end
128
+
129
+ def kind_id
130
+ enum_kind_id
131
+ end
132
+
133
+ private
134
+
135
+ def enum_kind_id
136
+ C.get_enum_attribute_kind(self)
137
+ end
138
+
139
+ def enum_kind
140
+ Support::C.get_enum_attribute_name_for_kind(enum_kind_id)
141
+ end
142
+
143
+ # wraps get_string_attribute_kind
144
+ def string_kind
145
+ FFI::MemoryPointer.new(:uint64) do |size_ptr|
146
+ return C.get_string_attribute_kind(self, size_ptr)
147
+ end
148
+ end
149
+
150
+ # wraps get_string_attribute_value
151
+ def string_value
152
+ FFI::MemoryPointer.new(:uint) do |size_ptr|
153
+ return C.get_string_attribute_value(self, size_ptr)
154
+ end
155
+ end
156
+
157
+ end
158
+ end
@@ -4,7 +4,7 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib ["libLLVM-15.so.1", "libLLVM.so.15", "LLVM-15"]
7
+ ffi_lib ["libLLVM-16.so.1", "libLLVM.so.16", "LLVM-16"]
8
8
 
9
9
  def self.attach_function(name, *_)
10
10
  begin; super; rescue FFI::NotFoundError => e
@@ -595,7 +595,7 @@ module LLVM
595
595
 
596
596
  # Negation.
597
597
  def -@
598
- self.class.from_ptr(C.const_f_neg(self))
598
+ raise "constant fneg removed in LLVM 16"
599
599
  end
600
600
 
601
601
  # Returns the result of adding this ConstantReal to rhs.
@@ -856,9 +856,16 @@ module LLVM
856
856
  end
857
857
 
858
858
  def add(attr)
859
- attr_kind_id = attribute_id(attr)
860
- ctx = Context.global
861
- attr_ref = C.create_enum_attribute(ctx, attr_kind_id, 0)
859
+ attr_ref = case attr
860
+ when Attribute
861
+ attr
862
+ when Symbol
863
+ attr_kind_id = attribute_id(attr)
864
+ ctx = Context.global
865
+ C.create_enum_attribute(ctx, attr_kind_id, 0)
866
+ else
867
+ raise "Adding unknown attribute type"
868
+ end
862
869
  C.add_attribute_at_index(@fun, @index, attr_ref)
863
870
  end
864
871
 
@@ -879,7 +886,7 @@ module LLVM
879
886
  attr_refs = p.read_array_of_type(:pointer, :read_pointer, n)
880
887
  end
881
888
 
882
- attr_refs.map { |e| C.get_enum_attribute_kind(e) }
889
+ attr_refs.map { |e| Attribute.send(:from_ptr, e) }
883
890
  end
884
891
 
885
892
  private
data/lib/llvm/core.rb CHANGED
@@ -24,10 +24,17 @@ module LLVM
24
24
  # (LLVMContextRef C, unsigned KindID, uint64_t Val);
25
25
  attach_function :create_enum_attribute, :LLVMCreateEnumAttribute, [:pointer, :uint, :uint64], :pointer
26
26
 
27
+ # LLVMAttributeRef LLVMCreateStringAttribute(LLVMContextRef C,
28
+ # const char *K, unsigned KLength,
29
+ # const char *V, unsigned VLength);
30
+ attach_function :create_string_attribute, :LLVMCreateStringAttribute, [:pointer, :string, :uint, :string, :uint], :pointer
31
+
27
32
  # unsigned LLVMGetEnumAttributeKindForName
28
33
  # (const char *Name, size_t SLen);
29
34
  attach_function :get_enum_attribute_kind_for_name, :LLVMGetEnumAttributeKindForName, [:pointer, :size_t], :uint
30
35
 
36
+ attach_function :get_last_enum_attribute_kind, :LLVMGetLastEnumAttributeKind, [], :uint
37
+
31
38
  # unsigned LLVMGetAttributeCountAtIndex
32
39
  # (LLVMValueRef F, LLVMAttributeIndex Idx);
33
40
  attach_function :get_attribute_count_at_index, :LLVMGetAttributeCountAtIndex, [:pointer, :llvmattributeindex], :uint
@@ -42,15 +49,19 @@ module LLVM
42
49
 
43
50
  # uint64_t LLVMGetEnumAttributeValue
44
51
  # (LLVMAttributeRef A);
45
- attach_function :get_enum_attribute_value, :LLVMGetEnumAttributeKind, [:pointer], :uint64
52
+ attach_function :get_enum_attribute_value, :LLVMGetEnumAttributeValue, [:pointer], :uint64
46
53
 
47
54
  # const char *LLVMGetStringAttributeKind
48
55
  # (LLVMAttributeRef A, unsigned *Length);
49
- attach_function :get_string_attribute_kind, :LLVMGetStringAttributeKind, [:pointer, :pointer], :pointer
56
+ attach_function :get_string_attribute_kind, :LLVMGetStringAttributeKind, [:pointer, :pointer], :string
50
57
 
51
58
  # const char *LLVMGetStringAttributeValue
52
59
  # (LLVMAttributeRef A, unsigned *Length);
53
- attach_function :get_string_attribute_value, :LLVMGetStringAttributeValue, [:pointer, :pointer], :pointer
60
+ attach_function :get_string_attribute_value, :LLVMGetStringAttributeValue, [:pointer, :pointer], :string
61
+
62
+ attach_function :is_enum_attribute, :LLVMIsEnumAttribute, [:pointer], :bool
63
+ attach_function :is_string_attribute, :LLVMIsStringAttribute, [:pointer], :bool
64
+ attach_function :is_type_attribute, :LLVMIsTypeAttribute, [:pointer], :bool
54
65
 
55
66
  # LLVMValueRef LLVMBuildLoad2(LLVMBuilderRef, LLVMTypeRef Ty, LLVMValueRef PointerVal, const char *Name);
56
67
  attach_function :build_load2, :LLVMBuildLoad2, [:pointer, :pointer, :pointer, :string], :pointer
@@ -229,4 +240,5 @@ module LLVM
229
240
  require 'llvm/core/builder'
230
241
  require 'llvm/core/pass_manager'
231
242
  require 'llvm/core/bitcode'
243
+ require 'llvm/core/attribute'
232
244
  end
data/lib/llvm/core_ffi.rb CHANGED
@@ -4,7 +4,7 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib ["libLLVM-15.so.1", "libLLVM.so.15", "LLVM-15"]
7
+ ffi_lib ["libLLVM-16.so.1", "libLLVM.so.16", "LLVM-16"]
8
8
 
9
9
  def self.attach_function(name, *_)
10
10
  begin; super; rescue FFI::NotFoundError => e
@@ -4,7 +4,7 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib ["libLLVM-15.so.1", "libLLVM.so.15", "LLVM-15"]
7
+ ffi_lib ["libLLVM-16.so.1", "libLLVM.so.16", "LLVM-16"]
8
8
 
9
9
  def self.attach_function(name, *_)
10
10
  begin; super; rescue FFI::NotFoundError => e
@@ -4,7 +4,7 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib ["libLLVM-15.so.1", "libLLVM.so.15", "LLVM-15"]
7
+ ffi_lib ["libLLVM-16.so.1", "libLLVM.so.16", "LLVM-16"]
8
8
 
9
9
  def self.attach_function(name, *_)
10
10
  begin; super; rescue FFI::NotFoundError => e
data/lib/llvm/support.rb CHANGED
@@ -27,6 +27,8 @@ module LLVM
27
27
  :LLVMInitializeNativeTarget, [], :void
28
28
  attach_function :initialize_native_asm_printer,
29
29
  :LLVMInitializeNativeAsmPrinter, [], :void
30
+
31
+ attach_function :get_enum_attribute_name_for_kind, :LLVMGetEnumAttributeNameForKind, [:uint], :string
30
32
  end
31
33
  end
32
34
 
data/lib/llvm/target.rb CHANGED
@@ -22,8 +22,21 @@ module LLVM
22
22
  #
23
23
  # @param [String] target Target name in LLVM format, e.g. "X86", "ARM" or "PowerPC".
24
24
  # @param [true, false] asm_printer Initialize corresponding AsmPrinter.
25
+
26
+ module TargetModule
27
+ extend FFI::Library
28
+ ffi_lib ["libLLVM-16.so.1", "libLLVM.so.16", "LLVM-16"]
29
+
30
+ def self.safe_attach_function(*args)
31
+ attach_function(*args)
32
+ rescue FFI::NotFoundError => e
33
+ warn(e)
34
+ end
35
+ end
36
+
25
37
  def self.init(target, asm_printer = false)
26
- C.module_eval do
38
+ target_module = TargetModule.dup
39
+ target_module.module_eval do
27
40
  attach_function :"initialize_target_info_#{target}",
28
41
  :"LLVMInitialize#{target}TargetInfo", [], :void
29
42
  attach_function :"initialize_target_#{target}",
@@ -33,12 +46,14 @@ module LLVM
33
46
 
34
47
  attach_function :"initialize_#{target}_asm_printer",
35
48
  :"LLVMInitialize#{target}AsmPrinter", [], :void
36
- attach_function :"initialize_#{target}_asm_parser",
49
+ safe_attach_function :"initialize_#{target}_asm_parser",
37
50
  :"LLVMInitialize#{target}AsmParser", [], :void
38
- attach_function :"initialize_#{target}_disassembler",
51
+ safe_attach_function :"initialize_#{target}_disassembler",
39
52
  :"LLVMInitialize#{target}Disassembler", [], :void
40
53
  end
41
54
 
55
+ C.extend(target_module)
56
+
42
57
  begin
43
58
  %W(initialize_target_info_#{target}
44
59
  initialize_target_#{target}
@@ -4,7 +4,7 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib ["libLLVM-15.so.1", "libLLVM.so.15", "LLVM-15"]
7
+ ffi_lib ["libLLVM-16.so.1", "libLLVM.so.16", "LLVM-16"]
8
8
 
9
9
  def self.attach_function(name, *_)
10
10
  begin; super; rescue FFI::NotFoundError => e
@@ -4,7 +4,7 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib ["libLLVM-15.so.1", "libLLVM.so.15", "LLVM-15"]
7
+ ffi_lib ["libLLVM-16.so.1", "libLLVM.so.16", "LLVM-16"]
8
8
 
9
9
  def self.attach_function(name, *_)
10
10
  begin; super; rescue FFI::NotFoundError => e
@@ -84,7 +84,7 @@ module LLVM
84
84
  # /** See llvm::createPruneEHPass function. */
85
85
  # void LLVMAddPruneEHPass(LLVMPassManagerRef PM);
86
86
  def prune_eh!
87
- C.add_prune_eh_pass(self)
87
+ warn('prune_eh! / LLVMAddPruneEHPass was removed in LLVM 16')
88
88
  end
89
89
 
90
90
  # @LLVMpass ipsccp
@@ -4,7 +4,7 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib ["libLLVM-15.so.1", "libLLVM.so.15", "LLVM-15"]
7
+ ffi_lib ["libLLVM-16.so.1", "libLLVM.so.16", "LLVM-16"]
8
8
 
9
9
  def self.attach_function(name, *_)
10
10
  begin; super; rescue FFI::NotFoundError => e
@@ -4,7 +4,7 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib ["libLLVM-15.so.1", "libLLVM.so.15", "LLVM-15"]
7
+ ffi_lib ["libLLVM-16.so.1", "libLLVM.so.16", "LLVM-16"]
8
8
 
9
9
  def self.attach_function(name, *_)
10
10
  begin; super; rescue FFI::NotFoundError => e
@@ -4,7 +4,7 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib ["libLLVM-15.so.1", "libLLVM.so.15", "LLVM-15"]
7
+ ffi_lib ["libLLVM-16.so.1", "libLLVM.so.16", "LLVM-16"]
8
8
 
9
9
  def self.attach_function(name, *_)
10
10
  begin; super; rescue FFI::NotFoundError => e
data/lib/llvm/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LLVM
4
- LLVM_VERSION = "15"
5
- LLVM_REQUIRED_VERSION = "15.0"
6
- RUBY_LLVM_VERSION = "15.0.4"
4
+ LLVM_VERSION = "16"
5
+ LLVM_REQUIRED_VERSION = "16.0"
6
+ RUBY_LLVM_VERSION = "16.0.0"
7
7
  end
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: 15.0.4
4
+ version: 16.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesse Johnson
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-05-15 00:00:00.000000000 Z
12
+ date: 2023-06-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi
@@ -192,6 +192,7 @@ files:
192
192
  - lib/llvm/analysis_ffi.rb
193
193
  - lib/llvm/config.rb
194
194
  - lib/llvm/core.rb
195
+ - lib/llvm/core/attribute.rb
195
196
  - lib/llvm/core/bitcode.rb
196
197
  - lib/llvm/core/bitcode_ffi.rb
197
198
  - lib/llvm/core/builder.rb