ruby-llvm 2.7.0 → 2.9.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,28 +1,31 @@
1
1
  = LLVM
2
2
 
3
3
  Author:: Jeremy Voorhis
4
- Contributors:: Evan Phoenix
5
- Copyright:: Copyright (c) 2010 Jeremy Voorhis
4
+ Contributors:: Evan Phoenix, Takanori Ishikawa, Ronaldo M. Ferraz
5
+ Copyright:: Copyright (c) 2010-2011 Jeremy Voorhis
6
6
  License:: BSD 3-clause (see LICENSE)
7
7
 
8
- This package contains Ruby bindings to the LLVM api, enabling users to make use
9
- of LLVM's optimization passes and JIT compilation for implementing compiled
10
- DSLs, callback functions, or fast Ruby method implementations.
8
+ This package contains Ruby bindings to the LLVM api, enabling users to
9
+ make use of LLVM's optimization passes and JIT compilation for
10
+ implementing compiled DSLs, callback functions, or fast Ruby method
11
+ implementations.
11
12
 
12
- ruby-llvm has been tested on the following Ruby interpreters:
13
13
 
14
- * MRI 1.8.7
15
- * MRI 1.9.1
14
+
15
+ ruby-llvm has been tested on Mac OS X 10.6 using the following Ruby interpreters:
16
+
17
+ * MRI 1.8.7-p174
18
+ * MRI 1.9.2-p180
16
19
  * JRuby 1.4.0
17
20
 
18
- If using MRI, then at least ffi >= 0.5.4 is required.
21
+ If using MRI, ffi >= 1.0.7 is recommended.
19
22
 
20
23
  == Requirements
21
- * LLVM 2.7, compiled with --shared-library
24
+ * LLVM 2.9, including libLLVM-2.9 (compile LLVM with --enable-shared)
22
25
 
23
26
  == About version numbers
24
27
 
25
- The first two digits of ruby-llvm's version number refer to the required major
26
- and minor version of LLVM. The third digit refers to the ruby-llvm release
27
- itself. Because LLVM's api changes often, this coupling between LLVM and
28
- ruby-llvm versions is necessary.
28
+ The first two digits of ruby-llvm's version number refer to the required
29
+ major and minor version of LLVM. The third digit refers to the ruby-llvm
30
+ release itself. Because LLVM's api changes often, this coupling between
31
+ LLVM and ruby-llvm versions is useful.
data/lib/llvm.rb CHANGED
@@ -1,10 +1,12 @@
1
+ require 'rubygems'
1
2
  require 'ffi'
2
3
 
3
4
  module LLVM
4
5
  module C
5
6
  extend ::FFI::Library
7
+
6
8
  # load required libraries
7
- ffi_lib 'LLVM-2.7'
9
+ ffi_lib ['LLVM-2.9', 'libLLVM-2.9']
8
10
  end
9
11
 
10
12
  NATIVE_INT_SIZE = case FFI::Platform::ARCH
data/lib/llvm/analysis.rb CHANGED
@@ -35,12 +35,8 @@ module LLVM
35
35
  end
36
36
 
37
37
  class Function
38
- def verify(action = :abort)
39
- str = FFI::MemoryPointer.new(FFI.type_size(:pointer))
40
- case status = C.LLVMVerifyFunction(self, action, str)
41
- when 1 then str.read_string
42
- else nil
43
- end
38
+ def verify(action = :abort_process)
39
+ C.LLVMVerifyFunction(self, action) != 0
44
40
  end
45
41
  end
46
42
  end
data/lib/llvm/core.rb CHANGED
@@ -24,7 +24,76 @@ module LLVM
24
24
  :no_implicit_float, 1 << 23,
25
25
  :naked, 1 << 24
26
26
  ]
27
-
27
+
28
+ enum :opcode, [
29
+ # Terminator Instructions
30
+ :ret, 1,
31
+ :br, 2,
32
+ :switch, 3,
33
+ :indirectbr, 4,
34
+ :invoke, 5,
35
+ :unwind, 6,
36
+ :unreachable, 7,
37
+
38
+ # Standard Binary Operators
39
+ :add, 8,
40
+ :fadd, 9,
41
+ :sub, 10,
42
+ :fsub, 11,
43
+ :mul, 12,
44
+ :fmul, 13,
45
+ :udiv, 14,
46
+ :sdiv, 15,
47
+ :fdiv, 16,
48
+ :urem, 17,
49
+ :srem, 18,
50
+ :frem, 19,
51
+
52
+ # Logical Operators
53
+ :shl, 20,
54
+ :lshr, 21,
55
+ :ashr, 22,
56
+ :and, 23,
57
+ :or, 24,
58
+ :xor, 25,
59
+
60
+ # Memory Operators
61
+ :alloca, 26,
62
+ :load, 27,
63
+ :store, 28,
64
+ :getelementptr, 29,
65
+
66
+ # Cast Operators
67
+ :trunc, 30,
68
+ :zext, 31,
69
+ :sext, 32,
70
+ :fptoui, 33,
71
+ :fptosi, 34,
72
+ :uitofp, 35,
73
+ :sitofp, 36,
74
+ :fptrunc, 37,
75
+ :fpext, 38,
76
+ :ptrtoint, 39,
77
+ :inttoptr, 40,
78
+ :bitcast, 41,
79
+
80
+ # Other Operators
81
+ :icmp, 42,
82
+ :fcmp, 43,
83
+ :phi, 44,
84
+ :call, 45,
85
+ :select, 46,
86
+
87
+ # UserOp1
88
+ # UserOp2
89
+ :vaarg, 49,
90
+ :extractelement, 50,
91
+ :insertelement, 51,
92
+ :shufflevector, 52,
93
+ :extractvalue, 53,
94
+ :insertvalue, 54,
95
+ ]
96
+
28
97
  enum :type_kind, [
29
98
  :void,
30
99
  :float,
@@ -206,6 +275,11 @@ module LLVM
206
275
  attach_function :LLVMSetValueName, [:pointer, :string], :void
207
276
  attach_function :LLVMDumpValue, [:pointer], :void
208
277
 
278
+ # Operations on Users
279
+ attach_function :LLVMGetOperand, [:pointer, :int], :pointer
280
+ attach_function :LLVMSetOperand, [:pointer, :int, :pointer], :void
281
+ attach_function :LLVMGetNumOperands, [:pointer], :int
282
+
209
283
  # Constants of any type
210
284
  attach_function :LLVMConstNull, [:pointer], :pointer
211
285
  attach_function :LLVMConstAllOnes, [:pointer], :pointer
@@ -233,6 +307,7 @@ module LLVM
233
307
  attach_function :LLVMConstVector, [:pointer, :uint], :pointer
234
308
 
235
309
  # Constant expressions
310
+ attach_function :LLVMGetConstOpcode, [:pointer], :opcode
236
311
  attach_function :LLVMAlignOf, [:pointer], :pointer
237
312
  attach_function :LLVMSizeOf, [:pointer], :pointer
238
313
  attach_function :LLVMConstNeg, [:pointer], :pointer
@@ -309,10 +384,10 @@ module LLVM
309
384
  attach_function :LLVMDeleteGlobal, [:pointer], :void
310
385
  attach_function :LLVMGetInitializer, [:pointer], :pointer
311
386
  attach_function :LLVMSetInitializer, [:pointer, :pointer], :void
312
- attach_function :LLVMIsThreadLocal, [:pointer], :int
387
+ attach_function :LLVMIsThreadLocal, [:pointer], :bool
313
388
  attach_function :LLVMSetThreadLocal, [:pointer, :int], :void
314
- attach_function :LLVMIsGlobalConstant, [:pointer], :int
315
- attach_function :LLVMSetGlobalConstant, [:pointer, :int], :void
389
+ attach_function :LLVMIsGlobalConstant, [:pointer], :bool
390
+ attach_function :LLVMSetGlobalConstant, [:pointer, :bool], :void
316
391
 
317
392
  # Aliases
318
393
  attach_function :LLVMAddAlias, [:pointer, :pointer, :pointer, :string], :pointer
@@ -443,7 +518,7 @@ module LLVM
443
518
  attach_function :LLVMBuildMalloc, [:pointer, :pointer, :string], :pointer
444
519
  attach_function :LLVMBuildArrayMalloc, [:pointer, :pointer, :pointer, :string], :string
445
520
  attach_function :LLVMBuildAlloca, [:pointer, :pointer, :string], :pointer
446
- attach_function :LLVMBuildArrayAlloca, [:pointer, :pointer, :string], :pointer
521
+ attach_function :LLVMBuildArrayAlloca, [:pointer, :pointer, :pointer, :string], :pointer
447
522
  attach_function :LLVMBuildFree, [:pointer, :pointer], :pointer
448
523
  attach_function :LLVMBuildLoad, [:pointer, :pointer, :string], :pointer
449
524
  attach_function :LLVMBuildStore, [:pointer, :pointer, :pointer], :pointer
@@ -459,7 +534,7 @@ module LLVM
459
534
  attach_function :LLVMBuildSExt, [:pointer, :pointer, :pointer, :string], :pointer
460
535
  attach_function :LLVMBuildFPToUI, [:pointer, :pointer, :pointer, :string], :pointer
461
536
  attach_function :LLVMBuildFPToSI, [:pointer, :pointer, :pointer, :string], :pointer
462
- attach_function :LLVMBuildUIToFP, [:pointer, :pointer, :string], :pointer
537
+ attach_function :LLVMBuildUIToFP, [:pointer, :pointer, :pointer, :string], :pointer
463
538
  attach_function :LLVMBuildSIToFP, [:pointer, :pointer, :pointer, :string], :pointer
464
539
  attach_function :LLVMBuildFPTrunc, [:pointer, :pointer, :pointer, :string], :pointer
465
540
  attach_function :LLVMBuildFPExt, [:pointer, :pointer, :pointer, :string], :pointer
@@ -504,6 +579,7 @@ module LLVM
504
579
  # Pass managers
505
580
  attach_function :LLVMCreatePassManager, [], :pointer
506
581
  attach_function :LLVMCreateFunctionPassManager, [:pointer], :pointer
582
+ attach_function :LLVMCreateFunctionPassManagerForModule, [:pointer], :pointer
507
583
  attach_function :LLVMRunPassManager, [:pointer, :pointer], :int
508
584
  attach_function :LLVMInitializeFunctionPassManager, [:pointer], :int
509
585
  attach_function :LLVMRunFunctionPassManager, [:pointer, :pointer], :int
@@ -1,314 +1,325 @@
1
1
  module LLVM
2
2
  class Builder
3
- class << self
4
- private :new
5
- end
6
-
3
+ private_class_method :new
4
+
7
5
  def initialize(ptr) # :nodoc:
8
6
  @ptr = ptr
9
7
  end
10
-
8
+
11
9
  def to_ptr # :nodoc:
12
10
  @ptr
13
11
  end
14
-
12
+
15
13
  def self.create
16
14
  new(C.LLVMCreateBuilder())
17
15
  end
18
-
16
+
17
+ def position(block, instruction)
18
+ raise "block must not be nil" if block.nil?
19
+ C.LLVMPositionBuilder(self, block, instruction)
20
+ self
21
+ end
22
+
23
+ def position_before(instruction)
24
+ raise "instruction must not be nil" if instruction.nil?
25
+ C.LLVMPositionBuilderBefore(self, instruction)
26
+ self
27
+ end
28
+
19
29
  def position_at_end(block)
30
+ raise "block must not be nil" if block.nil?
20
31
  C.LLVMPositionBuilderAtEnd(self, block)
21
32
  self
22
33
  end
23
-
34
+
24
35
  def get_insert_block
25
36
  BasicBlock.from_ptr(C.LLVMGetInsertBlock(self))
26
37
  end
27
-
38
+
28
39
  # Terminators
29
-
40
+
30
41
  def ret_void
31
42
  Instruction.from_ptr(C.LLVMBuildRetVoid(self))
32
43
  end
33
-
44
+
34
45
  def ret(val)
35
46
  Instruction.from_ptr(C.LLVMBuildRet(self, val))
36
47
  end
37
-
48
+
38
49
  def aggregate_ret(*vals)
39
50
  FFI::MemoryPointer.new(FFI.type_size(:pointer) * vals.size) do |vals_ptr|
40
51
  vals_ptr.write_array_of_pointer(vals)
41
52
  Instruction.from_ptr(C.LLVMBuildAggregateRet(self, vals_ptr, vals.size))
42
53
  end
43
54
  end
44
-
55
+
45
56
  def br(block)
46
57
  Instruction.from_ptr(
47
58
  C.LLVMBuildBr(self, block))
48
59
  end
49
-
60
+
50
61
  def cond(cond, iftrue, iffalse)
51
62
  Instruction.from_ptr(
52
63
  C.LLVMBuildCondBr(self, cond, iftrue, iffalse))
53
64
  end
54
-
65
+
55
66
  def switch(val, block, ncases)
56
67
  SwitchInst.from_ptr(C.LLVMBuildSwitch(self, val, block, ncases))
57
68
  end
58
-
69
+
59
70
  def invoke(fun, args, _then, _catch, name = "")
60
71
  Instruction.from_ptr(
61
72
  C.LLVMBuildInvoke(self,
62
73
  fun, args, args.size, _then, _catch, name))
63
74
  end
64
-
75
+
65
76
  def unwind
66
77
  Instruction.from_ptr(C.LLVMBuildUnwind(self))
67
78
  end
68
-
79
+
69
80
  def unreachable
70
81
  Instruction.from_ptr(C.LLVMBuildUnreachable(self))
71
82
  end
72
-
83
+
73
84
  # Arithmetic
74
-
85
+
75
86
  def add(lhs, rhs, name = "")
76
87
  Instruction.from_ptr(C.LLVMBuildAdd(self, lhs, rhs, name))
77
88
  end
78
-
89
+
79
90
  def nsw_add(lhs, rhs, name = "")
80
91
  Instruction.from_ptr(C.LLVMBuildNSWAdd(self, lhs, rhs, name))
81
92
  end
82
-
93
+
83
94
  def fadd(lhs, rhs, name = "")
84
95
  Instruction.from_ptr(C.LLVMBuildFAdd(self, lhs, rhs, name))
85
96
  end
86
-
97
+
87
98
  def sub(lhs, rhs, name = "")
88
99
  Instruction.from_ptr(C.LLVMBuildSub(self, lhs, rhs, name))
89
100
  end
90
-
101
+
91
102
  def fsub(lhs, rhs, name = "")
92
103
  Instruction.from_ptr(C.LLVMBuildFSub(self, lhs, rhs, name))
93
104
  end
94
-
105
+
95
106
  def mul(lhs, rhs, name = "")
96
107
  Instruction.from_ptr(C.LLVMBuildMul(self, lhs, rhs, name))
97
108
  end
98
-
109
+
99
110
  def fmul(lhs, rhs, name = "")
100
111
  Instruction.from_ptr(C.LLVMBuildFMul(self, lhs, rhs, name))
101
112
  end
102
-
113
+
103
114
  def udiv(lhs, rhs, name = "")
104
115
  Instruction.from_ptr(C.LLVMBuildUDiv(self, lhs, rhs, name))
105
116
  end
106
-
117
+
107
118
  def sdiv(lhs, rhs, name = "")
108
119
  Instruction.from_ptr(C.LLVMBuildSDiv(self, lhs, rhs, name))
109
120
  end
110
-
121
+
111
122
  def exact_sdiv(lhs, rhs, name = "")
112
123
  Instruction.from_ptr(C.LLVMBuildExactSDiv(self, lhs, rhs, name))
113
124
  end
114
-
125
+
115
126
  def fdiv(lhs, rhs, name = "")
116
127
  Instruction.from_ptr(C.LLVMBuildFDiv(self, lhs, rhs, name))
117
128
  end
118
-
129
+
119
130
  def urem(lhs, rhs, name = "")
120
131
  Instruction.from_ptr(C.LLVMBuildURem(self, lhs, rhs, name))
121
132
  end
122
-
133
+
123
134
  def srem(lhs, rhs, name = "")
124
135
  Instruction.from_ptr(C.LLVMBuildSRem(self, lhs, rhs, name))
125
136
  end
126
-
137
+
127
138
  def frem(lhs, rhs, name = "")
128
139
  Instruction.from_ptr(C.LLVMBuildFRem(self, lhs, rhs, name))
129
140
  end
130
-
141
+
131
142
  def shl(lhs, rhs, name = "")
132
143
  Instruction.from_ptr(C.LLVMBuildShl(self, lhs, rhs, name))
133
144
  end
134
-
145
+
135
146
  def lshr(lhs, rhs, name = "")
136
147
  Instruction.from_ptr(C.LLVMBuildLShr(self, lhs, rhs, name))
137
148
  end
138
-
149
+
139
150
  def ashr(lhs, rhs, name = "")
140
151
  Instruction.from_ptr(C.LLVMBuildAShr(self, lhs, rhs, name))
141
152
  end
142
-
153
+
143
154
  def and(lhs, rhs, name = "")
144
155
  Instruction.from_ptr(C.LLVMBuildAnd(self, lhs, rhs, name))
145
156
  end
146
-
157
+
147
158
  def or(lhs, rhs, name = "")
148
159
  Instruction.from_ptr(C.LLVMBuildOr(self, lhs, rhs, name))
149
160
  end
150
-
161
+
151
162
  def xor(lhs, rhs, name = "")
152
163
  Instruction.from_ptr(C.LLVMBuildXor(self, lhs, rhs, name))
153
164
  end
154
-
165
+
155
166
  def neg(arg, name = "")
156
167
  Instruction.from_ptr(C.LLVMBuildNeg(self, arg, name))
157
168
  end
158
-
169
+
159
170
  def not(arg, name = "")
160
171
  Instruction.from_ptr(C.LLVMBuildNot(self, arg, name))
161
172
  end
162
-
173
+
163
174
  # Memory
164
-
175
+
165
176
  def malloc(ty, name = "")
166
177
  Instruction.from_ptr(C.LLVMBuildMalloc(self, LLVM::Type(ty), name))
167
178
  end
168
-
179
+
169
180
  def array_malloc(ty, val, name = "")
170
181
  Instruction.from_ptr(C.LLVMBuildArrayMalloc(self, LLVM::Type(ty), val, name))
171
182
  end
172
-
183
+
173
184
  def alloca(ty, name = "")
174
185
  Instruction.from_ptr(C.LLVMBuildAlloca(self, LLVM::Type(ty), name))
175
186
  end
176
-
187
+
177
188
  def array_alloca(ty, val, name = "")
178
189
  Instruction.from_ptr(C.LLVMBuildArrayAlloca(self, LLVM::Type(ty), val, name))
179
190
  end
180
-
191
+
181
192
  def free(pointer)
182
193
  Instruction.from_ptr(C.LLVMBuildFree(self, pointer))
183
194
  end
184
-
195
+
185
196
  def load(pointer, name = "")
186
197
  Instruction.from_ptr(C.LLVMBuildLoad(self, pointer, name))
187
198
  end
188
-
199
+
189
200
  def store(val, pointer)
190
201
  Instruction.from_ptr(C.LLVMBuildStore(self, val, pointer))
191
202
  end
192
-
203
+
193
204
  def gep(pointer, indices, name = "")
194
205
  indices = Array(indices)
195
206
  FFI::MemoryPointer.new(FFI.type_size(:pointer) * indices.size) do |indices_ptr|
196
207
  indices_ptr.write_array_of_pointer(indices)
197
208
  return Instruction.from_ptr(
198
- C.LLVMBuildInBoundsGEP(self, pointer, indices_ptr, indices.size, name))
209
+ C.LLVMBuildGEP(self, pointer, indices_ptr, indices.size, name))
199
210
  end
200
211
  end
201
-
212
+
202
213
  def inbounds_gep(pointer, indices, name = "")
203
214
  indices = Array(indices)
204
215
  FFI::MemoryPointer.new(FFI.type_size(:pointer) * indices.size) do |indices_ptr|
205
216
  indices_ptr.write_array_of_pointer(indices)
206
217
  return Instruction.from_ptr(
207
- C.LLVMBuildGEP(self, pointer, indices_ptr, indices.size, name))
218
+ C.LLVMBuildInBoundsGEP(self, pointer, indices_ptr, indices.size, name))
208
219
  end
209
220
  end
210
-
221
+
211
222
  def struct_gep(pointer, idx, name = "")
212
223
  Instruction.from_ptr(C.LLVMBuildStructGEP(self, pointer, idx, name))
213
224
  end
214
-
225
+
215
226
  def global_string(string, name = "")
216
227
  Instruction.from_ptr(C.LLVMBuildGlobalString(self, string, name))
217
228
  end
218
-
229
+
219
230
  def global_string_pointer(string, name = "")
220
- Instruction.from_ptr(C.LLVMBuildGlobalStringPointer(self, string, name))
231
+ Instruction.from_ptr(C.LLVMBuildGlobalStringPtr(self, string, name))
221
232
  end
222
-
233
+
223
234
  # Casts
224
-
235
+
225
236
  def trunc(val, ty, name = "")
226
237
  Instruction.from_ptr(C.LLVMBuildTrunc(self, val, LLVM::Type(ty), name))
227
238
  end
228
-
239
+
229
240
  def zext(val, ty, name = "")
230
241
  Instruction.from_ptr(C.LLVMBuildZExt(self, val, LLVM::Type(ty), name))
231
242
  end
232
-
243
+
233
244
  def sext(val, ty, name = "")
234
245
  Instruction.from_ptr(C.LLVMBuildSExt(self, val, LLVM::Type(ty), name))
235
246
  end
236
-
247
+
237
248
  def fp2ui(val, ty, name = "")
238
249
  Instruction.from_ptr(C.LLVMBuildFPToUI(self, val, LLVM::Type(ty), name))
239
250
  end
240
-
251
+
241
252
  def fp2si(val, ty, name = "")
242
253
  Instruction.from_ptr(C.LLVMBuildFPToSI(self, val, LLVM::Type(ty), name))
243
254
  end
244
-
255
+
245
256
  def ui2fp(val, ty, name = "")
246
257
  Instruction.from_ptr(C.LLVMBuildUIToFP(self, val, LLVM::Type(ty), name))
247
258
  end
248
-
259
+
249
260
  def si2fp(val, ty, name = "")
250
261
  Instruction.from_ptr(C.LLVMBuildSIToFP(self, val, LLVM::Type(ty), name))
251
262
  end
252
-
263
+
253
264
  def fp_trunc(val, ty, name = "")
254
265
  Instruction.from_ptr(C.LLVMBuildFPTrunc(self, val, LLVM::Type(ty), name))
255
266
  end
256
-
267
+
257
268
  def fp_ext(val, ty, name = "")
258
269
  Instruction.from_ptr(C.LLVMBuildFPExt(self, val, LLVM::Type(ty), name))
259
270
  end
260
-
271
+
261
272
  def ptr2int(val, ty, name = "")
262
273
  Instruction.from_ptr(C.LLVMBuildPtrToInt(self, val, LLVM::Type(ty), name))
263
274
  end
264
-
275
+
265
276
  def int2ptr(val, ty, name = "")
266
277
  Instruction.from_ptr(C.LLVMBuildIntToPtr(self, val, LLVM::Type(ty), name))
267
278
  end
268
-
279
+
269
280
  def bit_cast(val, ty, name = "")
270
281
  Instruction.from_ptr(C.LLVMBuildBitCast(self, val, LLVM::Type(ty), name))
271
282
  end
272
-
283
+
273
284
  def zext_or_bit_cast(val, ty, name = "")
274
285
  Instruction.from_ptr(C.LLVMBuildZExtOrBitCast(self, val, LLVM::Type(ty), name))
275
286
  end
276
-
287
+
277
288
  def sext_or_bit_cast(val, ty, name = "")
278
289
  Instruction.from_ptr(C.LLVMBuildSExtOrBitCast(self, val, LLVM::Type(ty), name))
279
290
  end
280
-
291
+
281
292
  def trunc_or_bit_cast(val, ty, name = "")
282
293
  Instruction.from_ptr(C.LLVMBuildTruncOrBitCast(self, val, LLVM::Type(ty), name))
283
294
  end
284
-
295
+
285
296
  def pointer_cast(val, ty, name = "")
286
297
  Instruction.from_ptr(C.LLVMBuildPointerCast(self, val, LLVM::Type(ty), name))
287
298
  end
288
-
299
+
289
300
  def int_cast(val, ty, name = "")
290
301
  Instruction.from_ptr(C.LLVMBuildIntCast(self, val, LLVM::Type(ty), name))
291
302
  end
292
-
303
+
293
304
  def fp_cast(val, ty, name = "")
294
305
  Instruction.from_ptr(C.LLVMBuildFPCast(self, val, LLVM::Type(ty), name))
295
306
  end
296
-
307
+
297
308
  # Comparisons
298
-
309
+
299
310
  def icmp(pred, lhs, rhs, name = "")
300
311
  Instruction.from_ptr(C.LLVMBuildICmp(self, pred, lhs, rhs, name))
301
312
  end
302
-
313
+
303
314
  def fcmp(pred, lhs, rhs, name = "")
304
315
  Instruction.from_ptr(C.LLVMBuildFCmp(self, pred, lhs, rhs, name))
305
316
  end
306
-
317
+
307
318
  # Misc
308
-
319
+
309
320
  def phi(ty, *incoming)
310
321
  if incoming.last.kind_of? String
311
- name = incomimg.pop
322
+ name = incoming.pop
312
323
  else
313
324
  name = ""
314
325
  end
@@ -317,8 +328,9 @@ module LLVM
317
328
  phi.add_incoming(*incoming) unless incoming.empty?
318
329
  phi
319
330
  end
320
-
331
+
321
332
  def call(fun, *args)
333
+ raise "No fun" if fun.nil?
322
334
  if args.last.kind_of? String
323
335
  name = args.pop
324
336
  else
@@ -329,47 +341,47 @@ module LLVM
329
341
  args_ptr.write_array_of_pointer(args)
330
342
  CallInst.from_ptr(C.LLVMBuildCall(self, fun, args_ptr, args.size, name))
331
343
  end
332
-
344
+
333
345
  def select(_if, _then, _else, name = "")
334
346
  Instruction.from_ptr(C.LLVMBuildSelect(self, _if, _then, _else, name))
335
347
  end
336
-
348
+
337
349
  def va_arg(list, ty, name = "")
338
350
  Instruction.from_ptr(C.LLVMBuildVAArg(self, list, LLVM::Type(ty), name))
339
351
  end
340
-
352
+
341
353
  def extract_element(vector, index, name = "")
342
354
  Instruction.from_ptr(C.LLVMBuildExtractElement(self, vector, index, name))
343
355
  end
344
-
356
+
345
357
  def insert_element(vector, elem, index, name = "")
346
358
  Instruction.from_ptr(C.LLVMBuildInsertElement(self, vector, elem, index, name))
347
359
  end
348
-
360
+
349
361
  def shuffle_vector(vec1, vec2, mask, name = "")
350
362
  Instruction.from_ptr(C.LLVMBuildShuffleVector(self, vec1, vec2, mask, name))
351
363
  end
352
-
364
+
353
365
  def extract_value(aggregate, index, name = "")
354
366
  Instruction.from_ptr(C.LLVMBuildExtractValue(self, aggregate, index, name))
355
367
  end
356
-
368
+
357
369
  def insert_value(aggregate, elem, index, name = "")
358
370
  Instruction.from_ptr(C.LLVMBuildInsertValue(self, aggregate, elem, index, name))
359
371
  end
360
-
372
+
361
373
  def is_null(val, name = "")
362
374
  Instruction.from_ptr(C.LLVMBuildIsNull(self, val, name))
363
375
  end
364
-
376
+
365
377
  def is_not_null(val, name = "")
366
378
  Instruction.from_ptr(C.LLVMBuildIsNotNull(self, val, name))
367
379
  end
368
-
380
+
369
381
  def ptr_diff(lhs, rhs, name = "")
370
382
  Instruction.from_ptr(C.LLVMBuildPtrDiff(lhs, rhs, name))
371
383
  end
372
-
384
+
373
385
  def dispose
374
386
  C.LLVMDisposeBuilder(@ptr)
375
387
  end