ruby-llvm 15.0.0 → 15.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/ext/ruby-llvm-support/Rakefile +4 -3
- data/lib/llvm/config.rb +5 -5
- data/lib/llvm/core/builder.rb +8 -8
- data/lib/llvm/core/opaque_pointer_builder.rb +2 -1
- data/lib/llvm/core/type.rb +40 -3
- data/lib/llvm/core/value.rb +2 -2
- data/lib/llvm/core.rb +32 -0
- data/lib/llvm/core_ffi.rb +0 -20
- data/lib/llvm/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79169ec6b39406ef0c395bee5bbc02578340808b2728ba61b5b89c1532e05c94
|
4
|
+
data.tar.gz: 8fe97708a36b561acbd24433f1ddf5d940e6535a776d918eca463fd179a29aea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75303049be604101b44001f68264b0ba0e5902816cf8d001ed5302aa7b71067b1e8d4ac7f24cf3470e53f59aac5547391b31c5f1145dceb28661966e95c56928
|
7
|
+
data.tar.gz: 9bad15b50111baf7dd2804d9bd6e61d8a2d05b892eacbbbc52df0194662f961eba8c7f9b81f5ebf1b5e9ce796e4aaeb4b4b47e858874d474ea39e54d3a6dd042
|
data/README.md
CHANGED
@@ -14,7 +14,7 @@ computationally intensive algorithms on the fly.
|
|
14
14
|
Current version
|
15
15
|
---------------
|
16
16
|
|
17
|
-
This library currently binds to LLVM-
|
17
|
+
This library currently binds to LLVM-15 (specifically llvm-c 15).
|
18
18
|
|
19
19
|
About version numbers
|
20
20
|
---------------------
|
@@ -56,7 +56,7 @@ LLVM_CONFIG = find_llvm_config
|
|
56
56
|
CXX = find_cxx
|
57
57
|
|
58
58
|
def invoke_llvm_config(options)
|
59
|
-
`#{LLVM_CONFIG} #{options}`.tr("\n", " ")
|
59
|
+
`#{LLVM_CONFIG} #{options}`.tr("\n", " ").strip
|
60
60
|
end
|
61
61
|
|
62
62
|
def llvm_lib_name
|
@@ -77,8 +77,9 @@ desc "Build the shared library and config module"
|
|
77
77
|
task :default => [SUPPORT_LIB, CONFIG_MOD]
|
78
78
|
|
79
79
|
file SUPPORT_LIB => %w(support.cpp) do |task|
|
80
|
-
|
81
|
-
|
80
|
+
clang_stdlib = CXX.match?(/^clang++/) ? "-stdlib=libc++" : ""
|
81
|
+
sh "#{CXX} -O3 -shared #{task.prerequisites.join(' ')} -l#{llvm_lib_name} " \
|
82
|
+
"#{invoke_llvm_config('--cxxflags --ldflags')} -fPIC #{clang_stdlib} -o #{SUPPORT_LIB}"
|
82
83
|
end
|
83
84
|
|
84
85
|
LLVM_CONFIG_OPTS = [
|
data/lib/llvm/config.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
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", "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", "engine", "executionengine", "frontendopenmp", "fuzzmutate", "globalisel", "hexagon", "hexagonasmparser", "hexagoncodegen", "hexagondesc", "hexagondisassembler", "hexagoninfo", "instcombine", "instrumentation", "interpreter", "ipo", "irreader", "jitlink", "lanai", "lanaiasmparser", "lanaicodegen", "lanaidesc", "lanaidisassembler", "lanaiinfo", "libdriver", "lineeditor", "linker", "lto", "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", "object", "objectyaml", "option", "
|
5
|
-
TARGETS_BUILT = ["AArch64", "AMDGPU", "ARM", "BPF", "Hexagon", "Lanai", "Mips", "MSP430", "NVPTX", "PowerPC", "RISCV", "Sparc", "SystemZ", "WebAssembly", "X86", "XCore", "
|
6
|
-
HOST_TARGET = "x86_64-pc-linux-gnu
|
7
|
-
BUILD_MODE = "
|
8
|
-
CFLAGS = "-I/usr/lib/llvm-15/include
|
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"]
|
6
|
+
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"
|
9
9
|
end
|
10
10
|
end
|
data/lib/llvm/core/builder.rb
CHANGED
@@ -1070,20 +1070,20 @@ module LLVM
|
|
1070
1070
|
|
1071
1071
|
private
|
1072
1072
|
|
1073
|
-
|
1073
|
+
def must_be_value!(value)
|
1074
1074
|
raise "must be a Value, got #{value.class.name}" unless Value === value
|
1075
1075
|
end
|
1076
1076
|
|
1077
|
-
|
1077
|
+
def must_be_type!(type)
|
1078
1078
|
type2 = LLVM.Type(type)
|
1079
1079
|
raise "must be a Type (LLVMTypeRef), got #{type2.class.name}" unless Type === type2
|
1080
1080
|
end
|
1081
1081
|
|
1082
|
-
|
1082
|
+
def must_infer_type!(value)
|
1083
1083
|
infer_type(value)
|
1084
1084
|
end
|
1085
1085
|
|
1086
|
-
|
1086
|
+
def infer_type(ptr)
|
1087
1087
|
case ptr
|
1088
1088
|
when GlobalVariable
|
1089
1089
|
Type.from_ptr(C.global_get_value_type(ptr))
|
@@ -1094,7 +1094,7 @@ module LLVM
|
|
1094
1094
|
end
|
1095
1095
|
end
|
1096
1096
|
|
1097
|
-
|
1097
|
+
def must_infer_instruction_type!(ptr)
|
1098
1098
|
case ptr.opcode
|
1099
1099
|
when :get_element_ptr
|
1100
1100
|
must_infer_gep!(ptr)
|
@@ -1107,7 +1107,7 @@ module LLVM
|
|
1107
1107
|
end
|
1108
1108
|
end
|
1109
1109
|
|
1110
|
-
|
1110
|
+
def must_infer_gep!(ptr)
|
1111
1111
|
source_type = Type.from_ptr(C.get_gep_source_element_type(ptr))
|
1112
1112
|
case source_type.kind
|
1113
1113
|
when :integer
|
@@ -1121,7 +1121,7 @@ module LLVM
|
|
1121
1121
|
end
|
1122
1122
|
end
|
1123
1123
|
|
1124
|
-
|
1124
|
+
def element_error(vector, idx)
|
1125
1125
|
if !vector.is_a?(LLVM::Value)
|
1126
1126
|
"non-value: #{vector.inspect}"
|
1127
1127
|
elsif vector.type.kind != :vector
|
@@ -1131,7 +1131,7 @@ module LLVM
|
|
1131
1131
|
end
|
1132
1132
|
end
|
1133
1133
|
|
1134
|
-
|
1134
|
+
def value_error(aggregate, idx)
|
1135
1135
|
if !aggregate.is_a?(LLVM::Value)
|
1136
1136
|
"non-value: #{aggregate.inspect}"
|
1137
1137
|
# TODO: fix this
|
data/lib/llvm/core/type.rb
CHANGED
@@ -79,18 +79,47 @@ module LLVM
|
|
79
79
|
[:struct, :array].include?(kind)
|
80
80
|
end
|
81
81
|
|
82
|
+
def opaque_struct?
|
83
|
+
C.is_opaque_struct(self)
|
84
|
+
end
|
85
|
+
|
86
|
+
def packed_struct?
|
87
|
+
C.is_packed_struct(self)
|
88
|
+
end
|
89
|
+
|
90
|
+
def literal_struct?
|
91
|
+
C.is_literal_struct(self)
|
92
|
+
end
|
93
|
+
|
82
94
|
# Creates an array type of Type with the given size.
|
95
|
+
# arrays can be size >= 0, https://llvm.org/docs/LangRef.html#array-type
|
83
96
|
def self.array(ty, sz = 0)
|
97
|
+
sz = sz.to_i
|
98
|
+
raise ArgumentError, "LLVM Array size must be >= 0" if sz.negative?
|
99
|
+
|
84
100
|
from_ptr(C.array_type(LLVM::Type(ty), sz), :array)
|
85
101
|
end
|
86
102
|
|
87
103
|
# Creates the pointer type of Type with the given address space.
|
88
|
-
def self.pointer(ty, address_space = 0)
|
89
|
-
|
104
|
+
def self.pointer(ty = nil, address_space = 0)
|
105
|
+
if ty
|
106
|
+
from_ptr(C.pointer_type(LLVM::Type(ty), address_space), :pointer)
|
107
|
+
else
|
108
|
+
ptr(address_space)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# opaque pointer
|
113
|
+
def self.ptr(address_space = 0)
|
114
|
+
from_ptr(C.pointer_type(void, address_space), :pointer)
|
90
115
|
end
|
91
116
|
|
92
117
|
# Creates a vector type of Type with the given element count.
|
118
|
+
# vectors can be size > 0, https://llvm.org/docs/LangRef.html#vector-type
|
93
119
|
def self.vector(ty, element_count)
|
120
|
+
element_count = element_count.to_i
|
121
|
+
raise ArgumentError, "LLVM Vector size must be > 0" unless element_count.positive?
|
122
|
+
|
94
123
|
from_ptr(C.vector_type(LLVM::Type(ty), element_count), :vector)
|
95
124
|
end
|
96
125
|
|
@@ -117,6 +146,14 @@ module LLVM
|
|
117
146
|
end
|
118
147
|
end
|
119
148
|
|
149
|
+
def self.opaque_struct(name)
|
150
|
+
from_ptr(C.struct_create_named(Context.global, name.to_s), :struct)
|
151
|
+
end
|
152
|
+
|
153
|
+
def self.named(name)
|
154
|
+
from_ptr(C.get_type_by_name2(Context.global, name.to_s), nil)
|
155
|
+
end
|
156
|
+
|
120
157
|
# Creates a void type.
|
121
158
|
def self.void
|
122
159
|
from_ptr(C.void_type, :void)
|
@@ -217,7 +254,7 @@ module LLVM
|
|
217
254
|
end
|
218
255
|
|
219
256
|
# Shortcut to Type.pointer.
|
220
|
-
def Pointer(ty)
|
257
|
+
def Pointer(ty = nil)
|
221
258
|
LLVM::Type.pointer(ty)
|
222
259
|
end
|
223
260
|
|
data/lib/llvm/core/value.rb
CHANGED
@@ -291,7 +291,7 @@ module LLVM
|
|
291
291
|
module Support
|
292
292
|
def allocate_pointers(size_or_values, &block)
|
293
293
|
if size_or_values.is_a?(Integer)
|
294
|
-
raise ArgumentError, 'block not given' unless
|
294
|
+
raise ArgumentError, 'block not given' unless block
|
295
295
|
size = size_or_values
|
296
296
|
values = (0...size).map { |i| yield i }
|
297
297
|
else
|
@@ -832,7 +832,7 @@ module LLVM
|
|
832
832
|
|
833
833
|
def attribute_name(attr_name)
|
834
834
|
attr_name = attr_name.to_s
|
835
|
-
if
|
835
|
+
if /_attribute$/.match?(attr_name)
|
836
836
|
attr_name.chomp('_attribute').tr('_', '')
|
837
837
|
else
|
838
838
|
attr_name
|
data/lib/llvm/core.rb
CHANGED
@@ -102,6 +102,38 @@ module LLVM
|
|
102
102
|
|
103
103
|
# LLVMValueRef LLVMGetAggregateElement(LLVMValueRef C, unsigned Idx);
|
104
104
|
attach_function :get_aggregate_element, :LLVMGetAggregateElement, [:pointer, :int], :pointer
|
105
|
+
|
106
|
+
attach_function :get_type_by_name2, :LLVMGetTypeByName2, [:pointer, :string], :pointer
|
107
|
+
|
108
|
+
# Determine whether a structure is packed.
|
109
|
+
#
|
110
|
+
# @see llvm::StructType::isPacked()
|
111
|
+
#
|
112
|
+
# @method is_packed_struct(struct_ty)
|
113
|
+
# @param [FFI::Pointer(TypeRef)] struct_ty
|
114
|
+
# @return [Bool]
|
115
|
+
# @scope class
|
116
|
+
attach_function :is_packed_struct, :LLVMIsPackedStruct, [:pointer], :bool
|
117
|
+
|
118
|
+
# Determine whether a structure is opaque.
|
119
|
+
#
|
120
|
+
# @see llvm::StructType::isOpaque()
|
121
|
+
#
|
122
|
+
# @method is_opaque_struct(struct_ty)
|
123
|
+
# @param [FFI::Pointer(TypeRef)] struct_ty
|
124
|
+
# @return [Bool]
|
125
|
+
# @scope class
|
126
|
+
attach_function :is_opaque_struct, :LLVMIsOpaqueStruct, [:pointer], :bool
|
127
|
+
|
128
|
+
# Determine whether a structure is literal.
|
129
|
+
#
|
130
|
+
# @see llvm::StructType::isLiteral()
|
131
|
+
#
|
132
|
+
# @method is_literal_struct(struct_ty)
|
133
|
+
# @param [FFI::Pointer(TypeRef)] struct_ty
|
134
|
+
# @return [Bool]
|
135
|
+
# @scope class
|
136
|
+
attach_function :is_literal_struct, :LLVMIsLiteralStruct, [:pointer], :bool
|
105
137
|
end
|
106
138
|
|
107
139
|
# Yields a pointer suitable for storing an LLVM output message.
|
data/lib/llvm/core_ffi.rb
CHANGED
@@ -1651,26 +1651,6 @@ module LLVM::C
|
|
1651
1651
|
# @scope class
|
1652
1652
|
attach_function :struct_get_type_at_index, :LLVMStructGetTypeAtIndex, [:pointer, :uint], :pointer
|
1653
1653
|
|
1654
|
-
# Determine whether a structure is packed.
|
1655
|
-
#
|
1656
|
-
# @see llvm::StructType::isPacked()
|
1657
|
-
#
|
1658
|
-
# @method is_packed_struct(struct_ty)
|
1659
|
-
# @param [FFI::Pointer(TypeRef)] struct_ty
|
1660
|
-
# @return [Integer]
|
1661
|
-
# @scope class
|
1662
|
-
attach_function :is_packed_struct, :LLVMIsPackedStruct, [:pointer], :int
|
1663
|
-
|
1664
|
-
# Determine whether a structure is opaque.
|
1665
|
-
#
|
1666
|
-
# @see llvm::StructType::isOpaque()
|
1667
|
-
#
|
1668
|
-
# @method is_opaque_struct(struct_ty)
|
1669
|
-
# @param [FFI::Pointer(TypeRef)] struct_ty
|
1670
|
-
# @return [Integer]
|
1671
|
-
# @scope class
|
1672
|
-
attach_function :is_opaque_struct, :LLVMIsOpaqueStruct, [:pointer], :int
|
1673
|
-
|
1674
1654
|
# Obtain the type of elements within a sequential type.
|
1675
1655
|
#
|
1676
1656
|
# This works on array, vector, and pointer types.
|
data/lib/llvm/version.rb
CHANGED
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
|
+
version: 15.0.2
|
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:
|
12
|
+
date: 2023-01-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ffi
|