ruby-llvm 3.2.0.beta.1 → 3.3.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.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +6 -3
  3. data/ext/ruby-llvm-support/Rakefile +80 -24
  4. data/ext/ruby-llvm-support/support.cpp +4 -3
  5. data/lib/llvm.rb +2 -2
  6. data/lib/llvm/analysis_ffi.rb +1 -1
  7. data/lib/llvm/config.rb +10 -0
  8. data/lib/llvm/core.rb +7 -5
  9. data/lib/llvm/core/bitcode_ffi.rb +1 -1
  10. data/lib/llvm/core/builder.rb +88 -6
  11. data/lib/llvm/core/module.rb +1 -0
  12. data/lib/llvm/core/type.rb +4 -4
  13. data/lib/llvm/core/value.rb +111 -25
  14. data/lib/llvm/core_ffi.rb +248 -1
  15. data/lib/llvm/execution_engine_ffi.rb +61 -1
  16. data/lib/llvm/linker.rb +0 -2
  17. data/lib/llvm/linker_ffi.rb +1 -1
  18. data/lib/llvm/support.rb +1 -1
  19. data/lib/llvm/target.rb +1 -1
  20. data/lib/llvm/target_ffi.rb +30 -25
  21. data/lib/llvm/transforms/builder.rb +102 -0
  22. data/lib/llvm/transforms/builder_ffi.rb +118 -0
  23. data/lib/llvm/transforms/ipo.rb +64 -4
  24. data/lib/llvm/transforms/ipo_ffi.rb +1 -1
  25. data/lib/llvm/transforms/scalar.rb +60 -20
  26. data/lib/llvm/transforms/scalar_ffi.rb +1 -1
  27. data/lib/llvm/transforms/vectorize.rb +5 -0
  28. data/lib/llvm/transforms/vectorize_ffi.rb +9 -1
  29. data/lib/llvm/version.rb +2 -21
  30. data/test/array_test.rb +1 -1
  31. data/test/basic_block_test.rb +1 -1
  32. data/test/binary_operations_test.rb +1 -1
  33. data/test/bitcode_test.rb +1 -1
  34. data/test/branch_test.rb +1 -1
  35. data/test/call_test.rb +1 -1
  36. data/test/comparisons_test.rb +1 -1
  37. data/test/conversions_test.rb +1 -1
  38. data/test/double_test.rb +1 -1
  39. data/test/equality_test.rb +4 -4
  40. data/test/function_test.rb +73 -0
  41. data/test/generic_value_test.rb +1 -1
  42. data/test/instruction_test.rb +1 -1
  43. data/test/ipo_test.rb +1 -1
  44. data/test/linker_test.rb +2 -2
  45. data/test/memory_access_test.rb +1 -1
  46. data/test/module_test.rb +6 -6
  47. data/test/parameter_collection_test.rb +1 -1
  48. data/test/pass_manager_builder_test.rb +33 -0
  49. data/test/phi_test.rb +1 -1
  50. data/test/select_test.rb +1 -1
  51. data/test/struct_test.rb +9 -1
  52. data/test/target_test.rb +19 -13
  53. data/test/test_helper.rb +2 -2
  54. data/test/type_test.rb +1 -1
  55. data/test/vector_test.rb +2 -2
  56. metadata +117 -85
  57. data/test/basic_test.rb +0 -11
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6cddca1edd8ba250d7003d333aeba9c4fffffc9a
4
+ data.tar.gz: 480c115d38ecc429338f474e7bfcbdba846406e0
5
+ SHA512:
6
+ metadata.gz: f9bd7e960dc2b5cc1654254e14afb0dfa10d447a330dc0950035517a6f31adaa488fa1cd4aad1b6d87dc286d420ff477e2bdc0801994f03929240346c4534da8
7
+ data.tar.gz: 7851c1b08cd9df28d8d518bfe97f6f1b8b2629ee68f3eac1feea6799d24549d9db92adc2d05bfd2a2611ed98a7f758bd0b9c2313564bc2bbb63153e187a4db34
data/README.md CHANGED
@@ -4,12 +4,12 @@ Ruby-LLVM
4
4
  Ruby-LLVM is a Ruby language binding to the LLVM compiler infrastructure
5
5
  library. LLVM allows users to create just-in-time (JIT) compilers, ahead-of-time
6
6
  (AOT) compilers for multiple architectures, code analyzers and more. LLVM
7
- bindings can also be used to speed up Ruby code by compiling Ruby methods on the
8
- fly.
7
+ bindings can also be used to speed up Ruby code by compiling and loading
8
+ computationally intensive algorithms on the fly.
9
9
 
10
10
  Requirements
11
11
  ------------
12
- * LLVM 3.2, including libLLVM-3.2 (compile LLVM with --enable-shared).
12
+ * LLVM 3.3, including libLLVM-3.3 (compile LLVM with --enable-shared).
13
13
  * In order to ensure the usability of JIT features (i.e. create_jit_compiler), compile LLVM with --enable-jit as well.
14
14
 
15
15
  About version numbers
@@ -47,3 +47,6 @@ Ruby-LLVM is possible because of its contributors:
47
47
  * Juan Wajnerman
48
48
  * Steven Farlie
49
49
  * Peter Zotov
50
+ * Austin Seipp
51
+ * Torsten Rüger
52
+ * Nathaniel Barnes
@@ -1,42 +1,98 @@
1
- require 'rake/clean'
2
1
  require 'rubygems'
2
+ require 'rake/clean'
3
3
  require 'ffi'
4
4
 
5
- # Change this when updating for a newer LLVM.
6
- LLVM_VERSION = '3.2'
5
+ require File.expand_path('../../lib/llvm/version', File.dirname(__FILE__))
6
+ include LLVM
7
+
8
+ def check_for(what, variants, env_var)
9
+ variants = [ ENV[env_var], *variants ] if ENV.include?(env_var)
7
10
 
8
- def check_llvm_config(name)
9
- actual_version = `#{name} --version`
10
- actual_version.strip == LLVM_VERSION
11
- rescue Errno::ENOENT
12
- false
11
+ $stdout.print("checking for #{what}... ")
12
+ $stdout.flush
13
+
14
+ result = variants.find do |variant|
15
+ if yield(variant)
16
+ $stdout.puts(variant)
17
+ true
18
+ end
19
+ end
20
+
21
+ if result
22
+ result
23
+ else
24
+ raise RuntimeError, "Cannot find #{what}: tried #{variants}"
25
+ end
13
26
  end
14
27
 
15
- def invoke_llvm_config(options)
16
- variants = %W(llvm-config-#{LLVM_VERSION} llvm-config)
28
+ def find_llvm_config
29
+ check_for('llvm-config',
30
+ %W(llvm-config-#{LLVM_VERSION} llvm-config),
31
+ 'LLVM_CONFIG') do |llvm_config|
17
32
 
18
- variants.each do |name|
19
- if check_llvm_config(name)
20
- return `#{name} #{options}`.gsub("\n", " ")
33
+ begin
34
+ actual_version = `#{llvm_config} --version`.strip
35
+
36
+ actual_version == LLVM_VERSION
37
+ rescue Errno::ENOENT
38
+ false
21
39
  end
22
40
  end
41
+ end
42
+
43
+ def find_cxx
44
+ check_for('C++ compiler', %W(clang++ g++), 'CXX') do |cxx|
45
+ system(cxx, "--version", out: :close, err: :close)
46
+ $?.success?
47
+ end
48
+ end
23
49
 
24
- raise RuntimeError, "No valid llvm-config found. Tried: #{variants}"
50
+ LLVM_CONFIG = find_llvm_config
51
+ CXX = find_cxx
52
+
53
+ def invoke_llvm_config(options)
54
+ `#{LLVM_CONFIG} #{options}`.gsub("\n", " ")
25
55
  end
26
56
 
27
- LLVM_CONFIG = invoke_llvm_config('--cxxflags --ldflags')
57
+ SUPPORT_LIB = FFI.map_library_name("RubyLLVMSupport-#{LLVM_VERSION}")
58
+ CONFIG_MOD = File.expand_path('../../lib/llvm/config.rb', File.dirname(__FILE__))
28
59
 
29
- CXX = "g++"
30
- SRC = "support.cpp"
31
- OUTPUT = FFI.map_library_name("RubyLLVMSupport-#{LLVM_VERSION}")
60
+ CLEAN.include(SUPPORT_LIB, CONFIG_MOD)
32
61
 
33
- CLEAN.include(OUTPUT)
62
+ desc "Build the shared library and config module"
63
+ task :default => [SUPPORT_LIB, CONFIG_MOD]
34
64
 
35
- task :default => [:build]
65
+ file SUPPORT_LIB => %w(support.cpp) do |task|
66
+ sh "#{CXX} -shared -lLLVM-#{LLVM_VERSION} #{task.prerequisites.join(' ')} " \
67
+ "#{invoke_llvm_config('--cxxflags --ldflags')} -o #{SUPPORT_LIB}"
68
+ end
36
69
 
37
- desc "Build the shared library"
38
- task :build => [OUTPUT]
70
+ LLVM_CONFIG_OPTS = [
71
+ ['COMPONENTS', :array, '--components'],
72
+ ['TARGETS_BUILT', :array, '--targets-built'],
73
+ ['HOST_TARGET', :string, '--host-target'],
74
+ ['BUILD_MODE', :string, '--build-mode'],
75
+ ['CFLAGS', :string, '--cflags'],
76
+ ]
39
77
 
40
- file OUTPUT => [SRC] do
41
- sh "#{CXX} -shared -lLLVM-#{LLVM_VERSION} #{SRC} #{LLVM_CONFIG} -o #{OUTPUT}"
78
+ file CONFIG_MOD do
79
+ open(CONFIG_MOD, 'w') do |f|
80
+ f.puts '# Generated by ruby-llvm. Please do not change this file by hand.'
81
+ f.puts 'module LLVM'
82
+ f.puts ' module CONFIG'
83
+
84
+ LLVM_CONFIG_OPTS.each do |(const, fmt, flag)|
85
+ case fmt
86
+ when :string
87
+ value = invoke_llvm_config(flag)
88
+ when :array
89
+ value = invoke_llvm_config(flag).split
90
+ end
91
+
92
+ f.puts " #{const} = #{value.inspect}"
93
+ end
94
+
95
+ f.puts ' end'
96
+ f.puts 'end'
97
+ end
42
98
  end
@@ -3,8 +3,9 @@
3
3
  */
4
4
 
5
5
  #include <llvm-c/Core.h>
6
- #include <llvm/Type.h>
7
- #include <llvm/GlobalValue.h>
6
+ #include <llvm/IR/Type.h>
7
+ #include <llvm/IR/Module.h>
8
+ #include <llvm/IR/GlobalValue.h>
8
9
  #include <llvm/Support/DynamicLibrary.h>
9
10
  #include <llvm/Support/TargetSelect.h>
10
11
  #include <llvm/Support/raw_ostream.h>
@@ -28,7 +29,7 @@ extern "C" {
28
29
  unwrap<Type>(type)->dump();
29
30
  }
30
31
 
31
- int LLVMPrintModuleToFD(LLVMModuleRef module, int fd, LLVMBool shouldClose, LLVMBool unbuffered) {
32
+ void LLVMPrintModuleToFD(LLVMModuleRef module, int fd, LLVMBool shouldClose, LLVMBool unbuffered) {
32
33
  raw_fd_ostream os(fd, shouldClose, unbuffered);
33
34
  unwrap(module)->print(os, 0);
34
35
  }
@@ -1,13 +1,13 @@
1
- require 'rubygems'
2
1
  require 'ffi'
3
2
 
4
3
  module LLVM
4
+ require 'llvm/version'
5
5
  require 'llvm/support'
6
6
 
7
7
  # @private
8
8
  module C
9
9
  extend ::FFI::Library
10
- ffi_lib ['LLVM-3.2']
10
+ ffi_lib ["LLVM-#{LLVM_VERSION}"]
11
11
  end
12
12
 
13
13
  module PointerIdentity
@@ -4,7 +4,7 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib 'LLVM-3.2'
7
+ ffi_lib 'LLVM-3.3'
8
8
 
9
9
  def self.attach_function(name, *_)
10
10
  begin; super; rescue FFI::NotFoundError => e
@@ -0,0 +1,10 @@
1
+ # Generated by ruby-llvm. Please do not change this file by hand.
2
+ module LLVM
3
+ module CONFIG
4
+ COMPONENTS = ["aarch64", "aarch64asmparser", "aarch64asmprinter", "aarch64codegen", "aarch64desc", "aarch64disassembler", "aarch64info", "aarch64utils", "all", "all-targets", "analysis", "archive", "arm", "armasmparser", "armasmprinter", "armcodegen", "armdesc", "armdisassembler", "arminfo", "asmparser", "asmprinter", "bitreader", "bitwriter", "codegen", "core", "cppbackend", "cppbackendcodegen", "cppbackendinfo", "debuginfo", "engine", "executionengine", "hexagon", "hexagonasmprinter", "hexagoncodegen", "hexagondesc", "hexagoninfo", "instcombine", "instrumentation", "interpreter", "ipa", "ipo", "irreader", "jit", "linker", "mblaze", "mblazeasmparser", "mblazeasmprinter", "mblazecodegen", "mblazedesc", "mblazedisassembler", "mblazeinfo", "mc", "mcdisassembler", "mcjit", "mcparser", "mips", "mipsasmparser", "mipsasmprinter", "mipscodegen", "mipsdesc", "mipsdisassembler", "mipsinfo", "msp430", "msp430asmprinter", "msp430codegen", "msp430desc", "msp430info", "native", "nativecodegen", "nvptx", "nvptxasmprinter", "nvptxcodegen", "nvptxdesc", "nvptxinfo", "objcarcopts", "object", "option", "powerpc", "powerpcasmparser", "powerpcasmprinter", "powerpccodegen", "powerpcdesc", "powerpcinfo", "r600", "r600asmprinter", "r600codegen", "r600desc", "r600info", "runtimedyld", "scalaropts", "selectiondag", "sparc", "sparccodegen", "sparcdesc", "sparcinfo", "support", "systemz", "systemzasmparser", "systemzasmprinter", "systemzcodegen", "systemzdesc", "systemzinfo", "tablegen", "target", "transformutils", "vectorize", "x86", "x86asmparser", "x86asmprinter", "x86codegen", "x86desc", "x86disassembler", "x86info", "x86utils", "xcore", "xcoreasmprinter", "xcorecodegen", "xcoredesc", "xcoredisassembler", "xcoreinfo"]
5
+ TARGETS_BUILT = ["R600", "X86", "Sparc", "PowerPC", "AArch64", "ARM", "Mips", "XCore", "MSP430", "CppBackend", "MBlaze", "NVPTX", "Hexagon", "SystemZ"]
6
+ HOST_TARGET = "x86_64-pc-linux-gnu "
7
+ BUILD_MODE = "Release "
8
+ CFLAGS = "-I/usr/lib/llvm-3.3/include -DNDEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -g -O2 -fomit-frame-pointer -fPIC "
9
+ end
10
+ end
@@ -15,20 +15,22 @@ module LLVM
15
15
  # @yield [FFI::MemoryPointer]
16
16
  # @return [String, nil]
17
17
  def self.with_message_output
18
- result = nil
18
+ message = nil
19
19
 
20
20
  FFI::MemoryPointer.new(FFI.type_size(:pointer)) do |str|
21
- yield str
21
+ result = yield str
22
22
 
23
23
  msg_ptr = str.read_pointer
24
24
 
25
- unless msg_ptr.null?
26
- result = msg_ptr.read_string
25
+ if result != 0
26
+ raise RuntimeError, "Error is signalled, but msg_ptr is null" if msg_ptr.null?
27
+
28
+ message = msg_ptr.read_string
27
29
  C.dispose_message msg_ptr
28
30
  end
29
31
  end
30
32
 
31
- result
33
+ message
32
34
  end
33
35
 
34
36
  # Same as #with_message_output, but raises a RuntimeError with the
@@ -4,7 +4,7 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib 'LLVM-3.2'
7
+ ffi_lib 'LLVM-3.3'
8
8
 
9
9
  def self.attach_function(name, *_)
10
10
  begin; super; rescue FFI::NotFoundError => e
@@ -79,7 +79,7 @@ module LLVM
79
79
  end
80
80
 
81
81
  # Unconditional branching (i.e. goto)
82
- # @param [LLVM::BasicBlock] block Where to jump
82
+ # @param [LLVM::BasicBlock] block Where to jump
83
83
  # @return [LLVM::Instruction]
84
84
  # @LLVMinst br
85
85
  def br(block)
@@ -88,10 +88,20 @@ module LLVM
88
88
  C.build_br(self, block))
89
89
  end
90
90
 
91
+ # Indirect branching (i.e. computed goto)
92
+ # @param [LLVM::BasicBlock] addr Where to jump
93
+ # @param [Integer] num_dests Number of possible destinations to be added
94
+ # @return [LLVM::Instruction]
95
+ # @LLVMinst indirectbr
96
+ def ibr(addr, num_dests)
97
+ IndirectBr.from_ptr(
98
+ C.build_indirect_br(self, addr, num_dests))
99
+ end
100
+
91
101
  # Conditional branching (i.e. if)
92
- # @param [LLVM::Value] cond The condition
93
- # @param [LLVM::BasicBlock] iftrue Where to jump if condition is true
94
- # @param [LLVM::BasicBlock] iffalse Where to jump if condition is false
102
+ # @param [LLVM::Value] cond The condition
103
+ # @param [LLVM::BasicBlock] iftrue Where to jump if condition is true
104
+ # @param [LLVM::BasicBlock] iffalse Where to jump if condition is false
95
105
  # @return [LLVM::Instruction]
96
106
  # @LLVMinst br
97
107
  def cond(cond, iftrue, iffalse)
@@ -136,7 +146,7 @@ module LLVM
136
146
  # Builds an unwind Instruction.
137
147
  # @LLVMinst unwind
138
148
  def unwind
139
- Instruction.from_ptr(C.LLVMBuildUnwind(self))
149
+ Instruction.from_ptr(C.build_unwind(self))
140
150
  end
141
151
 
142
152
  # Generates an instruction with no defined semantics. Can be used to
@@ -147,6 +157,7 @@ module LLVM
147
157
  Instruction.from_ptr(C.build_unreachable(self))
148
158
  end
149
159
 
160
+ # Integer addition.
150
161
  # @param [LLVM::Value] lhs Integer or vector of integers
151
162
  # @param [LLVM::Value] rhs Integer or vector of integers
152
163
  # @param [String] name Name of the result in LLVM IR
@@ -156,7 +167,7 @@ module LLVM
156
167
  Instruction.from_ptr(C.build_add(self, lhs, rhs, name))
157
168
  end
158
169
 
159
- # No signed wrap addition.
170
+ # "No signed wrap" integer addition.
160
171
  # @param [LLVM::Value] lhs Integer or vector of integers
161
172
  # @param [LLVM::Value] rhs Integer or vector of integers
162
173
  # @param [String] name Name of the result in LLVM IR
@@ -166,6 +177,16 @@ module LLVM
166
177
  Instruction.from_ptr(C.build_nsw_add(self, lhs, rhs, name))
167
178
  end
168
179
 
180
+ # "No unsigned wrap" integer addition.
181
+ # @param [LLVM::Value] lhs Integer or vector of integers
182
+ # @param [LLVM::Value] rhs Integer or vector of integers
183
+ # @param [String] name Name of the result in LLVM IR
184
+ # @return [LLVM::Instruction] The integer sum of the two operands
185
+ # @LLVMinst add
186
+ def nuw_add(lhs, rhs, name = "")
187
+ Instruction.from_ptr(C.build_nuw_add(self, lhs, rhs, name))
188
+ end
189
+
169
190
  # @param [LLVM::Value] lhs Floating point or vector of floating points
170
191
  # @param [LLVM::Value] rhs Floating point or vector of floating points
171
192
  # @param [String] name Name of the result in LLVM IR
@@ -175,6 +196,7 @@ module LLVM
175
196
  Instruction.from_ptr(C.build_f_add(self, lhs, rhs, name))
176
197
  end
177
198
 
199
+ # Integer subtraction.
178
200
  # @param [LLVM::Value] lhs Integer or vector of integers
179
201
  # @param [LLVM::Value] rhs Integer or vector of integers
180
202
  # @param [String] name Name of the result in LLVM IR
@@ -184,6 +206,26 @@ module LLVM
184
206
  Instruction.from_ptr(C.build_sub(self, lhs, rhs, name))
185
207
  end
186
208
 
209
+ # No signed wrap integer subtraction.
210
+ # @param [LLVM::Value] lhs Integer or vector of integers
211
+ # @param [LLVM::Value] rhs Integer or vector of integers
212
+ # @param [String] name Name of the result in LLVM IR
213
+ # @return [LLVM::Instruction] The integer difference of the two operands
214
+ # @LLVMinst sub
215
+ def nsw_sub(lhs, rhs, name = "")
216
+ Instruction.from_ptr(C.build_nsw_sub(self, lhs, rhs, name))
217
+ end
218
+
219
+ # No unsigned wrap integer subtraction.
220
+ # @param [LLVM::Value] lhs Integer or vector of integers
221
+ # @param [LLVM::Value] rhs Integer or vector of integers
222
+ # @param [String] name Name of the result in LLVM IR
223
+ # @return [LLVM::Instruction] The integer difference of the two operands
224
+ # @LLVMinst sub
225
+ def nuw_sub(lhs, rhs, name = "")
226
+ Instruction.from_ptr(C.build_nuw_sub(self, lhs, rhs, name))
227
+ end
228
+
187
229
  # @param [LLVM::Value] lhs Floating point or vector of floating points
188
230
  # @param [LLVM::Value] rhs Floating point or vector of floating points
189
231
  # @param [String] name Name of the result in LLVM IR
@@ -194,6 +236,7 @@ module LLVM
194
236
  Instruction.from_ptr(C.build_f_sub(self, lhs, rhs, name))
195
237
  end
196
238
 
239
+ # Integer multiplication.
197
240
  # @param [LLVM::Value] lhs Integer or vector of integers
198
241
  # @param [LLVM::Value] rhs Integer or vector of integers
199
242
  # @param [String] name Name of the result in LLVM IR
@@ -203,6 +246,27 @@ module LLVM
203
246
  Instruction.from_ptr(C.build_mul(self, lhs, rhs, name))
204
247
  end
205
248
 
249
+ # "No signed wrap" integer multiplication.
250
+ # @param [LLVM::Value] lhs Integer or vector of integers
251
+ # @param [LLVM::Value] rhs Integer or vector of integers
252
+ # @param [String] name Name of the result in LLVM IR
253
+ # @return [LLVM::Instruction] The integer product of the two operands
254
+ # @LLVMinst mul
255
+ def nsw_mul(lhs, rhs, name = "")
256
+ Instruction.from_ptr(C.build_nsw_mul(self, lhs, rhs, name))
257
+ end
258
+
259
+ # "No unsigned wrap" integer multiplication.
260
+ # @param [LLVM::Value] lhs Integer or vector of integers
261
+ # @param [LLVM::Value] rhs Integer or vector of integers
262
+ # @param [String] name Name of the result in LLVM IR
263
+ # @return [LLVM::Instruction] The integer product of the two operands
264
+ # @LLVMinst mul
265
+ def nuw_mul(lhs, rhs, name = "")
266
+ Instruction.from_ptr(C.build_nuw_mul(self, lhs, rhs, name))
267
+ end
268
+
269
+ # Floating point multiplication
206
270
  # @param [LLVM::Value] lhs Floating point or vector of floating points
207
271
  # @param [LLVM::Value] rhs Floating point or vector of floating points
208
272
  # @param [String] name Name of the result in LLVM IR
@@ -348,6 +412,24 @@ module LLVM
348
412
  Instruction.from_ptr(C.build_neg(self, arg, name))
349
413
  end
350
414
 
415
+ # "No signed wrap" integer negation.
416
+ # @param [LLVM::Value] arg Integer or vector of integers
417
+ # @param [String] name Name of the result in LLVM IR
418
+ # @return [LLVM::Instruction] The negated operand
419
+ # @LLVMinst sub
420
+ def nsw_neg(arg, name = "")
421
+ Instruction.from_ptr(C.build_nsw_neg(self, arg, name))
422
+ end
423
+
424
+ # "No unsigned wrap" integer negation.
425
+ # @param [LLVM::Value] arg Integer or vector of integers
426
+ # @param [String] name Name of the result in LLVM IR
427
+ # @return [LLVM::Instruction] The negated operand
428
+ # @LLVMinst sub
429
+ def nuw_neg(arg, name = "")
430
+ Instruction.from_ptr(C.build_nuw_neg(self, arg, name))
431
+ end
432
+
351
433
  # Boolean negation.
352
434
  # @param [LLVM::Value] arg Integer or vector of integers
353
435
  # @param [String] name The name of the result in LLVM IR
@@ -17,6 +17,7 @@ module LLVM
17
17
 
18
18
  def dispose
19
19
  return if @ptr.nil?
20
+
20
21
  C.dispose_module(@ptr)
21
22
  @ptr = nil
22
23
  end
@@ -125,14 +125,14 @@ module LLVM
125
125
  size = C.count_param_types(self)
126
126
  result = nil
127
127
  FFI::MemoryPointer.new(FFI.type_size(:pointer) * size) do |types_ptr|
128
- C.LLVMGetParamTypes(self, types_ptr)
129
- result = types_ptr.read_array_of_pointer(size)
128
+ C.get_param_types(self, types_ptr)
129
+ result = types_ptr.read_array_of_pointer(size)
130
130
  end
131
- result.map{ |p| Type.from_ptr(p) }
131
+ result.map{ |p| Type.from_ptr(p, nil) }
132
132
  end
133
133
 
134
134
  def vararg?
135
- C.LLVMIsFunctionVarArg(self)
135
+ C.is_function_var_arg(self) != 0
136
136
  end
137
137
  end
138
138