rltk 3.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +21 -22
  3. data/lib/rltk/ast.rb +185 -118
  4. data/lib/rltk/cfg.rb +157 -103
  5. data/lib/rltk/cg/basic_block.rb +19 -19
  6. data/lib/rltk/cg/bindings.rb +16 -16
  7. data/lib/rltk/cg/builder.rb +129 -129
  8. data/lib/rltk/cg/context.rb +7 -7
  9. data/lib/rltk/cg/contractor.rb +7 -7
  10. data/lib/rltk/cg/execution_engine.rb +30 -30
  11. data/lib/rltk/cg/function.rb +37 -37
  12. data/lib/rltk/cg/generated_bindings.rb +3932 -3932
  13. data/lib/rltk/cg/generic_value.rb +17 -17
  14. data/lib/rltk/cg/instruction.rb +116 -116
  15. data/lib/rltk/cg/llvm.rb +22 -22
  16. data/lib/rltk/cg/memory_buffer.rb +7 -7
  17. data/lib/rltk/cg/module.rb +73 -73
  18. data/lib/rltk/cg/pass_manager.rb +35 -35
  19. data/lib/rltk/cg/target.rb +41 -41
  20. data/lib/rltk/cg/triple.rb +7 -7
  21. data/lib/rltk/cg/type.rb +75 -75
  22. data/lib/rltk/cg/value.rb +161 -161
  23. data/lib/rltk/lexer.rb +57 -57
  24. data/lib/rltk/lexers/calculator.rb +7 -7
  25. data/lib/rltk/lexers/ebnf.rb +5 -5
  26. data/lib/rltk/parser.rb +338 -295
  27. data/lib/rltk/parsers/infix_calc.rb +7 -7
  28. data/lib/rltk/parsers/postfix_calc.rb +3 -3
  29. data/lib/rltk/parsers/prefix_calc.rb +3 -3
  30. data/lib/rltk/token.rb +13 -13
  31. data/lib/rltk/version.rb +6 -6
  32. data/test/cg/tc_basic_block.rb +17 -17
  33. data/test/cg/tc_control_flow.rb +41 -41
  34. data/test/cg/tc_function.rb +4 -4
  35. data/test/cg/tc_generic_value.rb +3 -3
  36. data/test/cg/tc_instruction.rb +53 -53
  37. data/test/cg/tc_math.rb +12 -12
  38. data/test/cg/tc_module.rb +14 -14
  39. data/test/cg/tc_transforms.rb +11 -11
  40. data/test/cg/tc_type.rb +12 -12
  41. data/test/cg/tc_value.rb +35 -35
  42. data/test/cg/ts_cg.rb +5 -5
  43. data/test/tc_ast.rb +137 -60
  44. data/test/tc_cfg.rb +34 -34
  45. data/test/tc_lexer.rb +42 -42
  46. data/test/tc_parser.rb +250 -173
  47. data/test/tc_token.rb +2 -2
  48. data/test/ts_rltk.rb +8 -8
  49. metadata +84 -85
  50. data/lib/rltk/cg/old_generated_bindings.rb +0 -6152
@@ -23,7 +23,7 @@ module RLTK::CG
23
23
  # BasicBlock.new or using the {Function::BasicBlockCollection#append}
24
24
  # method.
25
25
  class BasicBlock < Value
26
-
26
+
27
27
  # Create a new BasicBlock object. The way the block is created is
28
28
  # determined by the *overloaded* parameter. If it is a Function
29
29
  # object then the new block is appended to the end of the function.
@@ -41,19 +41,19 @@ module RLTK::CG
41
41
  # @param [Proc] block Block to be invoked by {#build}.
42
42
  def initialize(overloaded, name = '', builder = nil, context = nil, *block_args, &block)
43
43
  check_type(context, Context, 'context') if context
44
-
44
+
45
45
  @ptr =
46
46
  case overloaded
47
47
  when FFI::Pointer
48
48
  overloaded
49
-
49
+
50
50
  when Function
51
51
  if context
52
52
  Bindings.append_basic_block_in_context(context, overloaded, name)
53
53
  else
54
54
  Bindings.append_basic_block(overloaded, name)
55
55
  end
56
-
56
+
57
57
  when BasicBlock
58
58
  if context
59
59
  Bindings.insert_basic_block_in_context(context, overloaded, name)
@@ -61,10 +61,10 @@ module RLTK::CG
61
61
  Bindings.insert_basic_block(overloaded, name)
62
62
  end
63
63
  end
64
-
64
+
65
65
  self.build(builder, *block_args, &block) if block
66
66
  end
67
-
67
+
68
68
  # Used to add instructions to a BasicBlock. The block given to this
69
69
  # method is executed inside the context of a {Builder} object, either
70
70
  # the one passed in the *builder* parameter or one created for this
@@ -85,7 +85,7 @@ module RLTK::CG
85
85
  def build(builder = nil, *block_args, &block)
86
86
  if builder then builder else Builder.new end.build(self, *block_args, &block)
87
87
  end
88
-
88
+
89
89
  # Creates a new BasicBlock inserted immediately before this block.
90
90
  #
91
91
  # @param [String] name Name of this BasicBlock.
@@ -95,36 +95,36 @@ module RLTK::CG
95
95
  def insert_before(name = '', context = nil)
96
96
  BasicBlock.new(self, name, context)
97
97
  end
98
-
98
+
99
99
  # @return [InstructionCollect] Collection of all instructions inside this BasicBlock.
100
100
  def instructions
101
101
  @instructions ||= InstructionCollection.new(self)
102
102
  end
103
-
103
+
104
104
  # @return [BasicBlock, nil] BasicBlock that occures immediately after this block or nil.
105
105
  def next
106
106
  if (ptr = Bindings.get_next_basic_block(@ptr)).null? then nil else BasicBlock.new(ptr) end
107
107
  end
108
-
108
+
109
109
  # @return [Function] Function object that this BasicBlock belongs to.
110
110
  def parent
111
111
  if (ptr = Bindings.get_basic_block_parent(@ptr)).null? then nil else Function.new(ptr) end
112
112
  end
113
-
113
+
114
114
  # @return [BasicBlock, nil] BasicBlock that occures immediately before this block or nil.
115
115
  def previous
116
116
  if (ptr = Bindings.get_previous_basic_block(@ptr)).null? then nil else BasicBlock.new(ptr) end
117
117
  end
118
-
118
+
119
119
  # This class is used to access all of the {Instruction Instructions} that have been added to a {BasicBlock}.
120
120
  class InstructionCollection
121
121
  include Enumerable
122
-
122
+
123
123
  # @param [BasicBlock] bb BasicBlock this collection belongs to.
124
124
  def initialize(bb)
125
125
  @bb = bb
126
126
  end
127
-
127
+
128
128
  # Iterate over each {Instruction} in this collection.
129
129
  #
130
130
  # @yieldparam inst [Instruction]
@@ -132,22 +132,22 @@ module RLTK::CG
132
132
  # @return [Enumerator] An Enumerator is returned if no block is given.
133
133
  def each
134
134
  return to_enum(:each) unless block_given?
135
-
135
+
136
136
  inst = self.first
137
-
137
+
138
138
  while inst
139
139
  yield inst
140
140
  inst = inst.next
141
141
  end
142
-
142
+
143
143
  self
144
144
  end
145
-
145
+
146
146
  # @return [Instruction] First instruction in this collection.
147
147
  def first
148
148
  if (ptr = Bindings.get_first_instruction(@bb)).null? then nil else Instruction.from_ptr(ptr) end
149
149
  end
150
-
150
+
151
151
  # @return [Instruction] Last instruction in this collection.
152
152
  def last
153
153
  if (ptr = Bindings.get_last_instruction(@bb)).null? then nil else Instruction.from_ptr(ptr) end
@@ -27,7 +27,7 @@ require 'rltk/cg'
27
27
  #######################
28
28
 
29
29
  module RLTK::CG
30
-
30
+
31
31
  # This module provides access to stored FFI::Pointer objects and allows a
32
32
  # class to be passed directly into FFI methods. It also provides a
33
33
  # pointer comparison method.
@@ -35,7 +35,7 @@ module RLTK::CG
35
35
  # @return [FFI::Pointer]
36
36
  attr_accessor :ptr
37
37
  alias :to_ptr :ptr
38
-
38
+
39
39
  # Compares one BindingClass object to another.
40
40
  #
41
41
  # @param [BindingClass] other Another BindingClass object to compare to.
@@ -45,23 +45,23 @@ module RLTK::CG
45
45
  self.class == other.class and @ptr == other.ptr
46
46
  end
47
47
  end
48
-
48
+
49
49
  # This module contains FFI bindings to LLVM.
50
50
  module Bindings
51
51
  extend FFI::Library
52
52
  ffi_lib("LLVM-#{RLTK::LLVM_TARGET_VERSION}")
53
-
53
+
54
54
  # Exception that is thrown when the LLVM target version does not
55
55
  # match the version of LLVM present on the system.
56
56
  class LibraryMismatch < Exception; end
57
-
57
+
58
58
  # Require the generated bindings files while handling errors.
59
59
  require 'rltk/cg/generated_bindings'
60
-
60
+
61
61
  #############
62
62
  # Constants #
63
63
  #############
64
-
64
+
65
65
  # List of architectures supported by LLVM.
66
66
  ARCHS = [
67
67
  :Alpha,
@@ -80,14 +80,14 @@ module RLTK::CG
80
80
  :X86,
81
81
  :XCore
82
82
  ]
83
-
83
+
84
84
  # List of assembly parsers.
85
85
  ASM_PARSERS = [
86
86
  :ARM,
87
87
  :MBLaze,
88
88
  :X86
89
89
  ]
90
-
90
+
91
91
  # List of assembly printers.
92
92
  ASM_PRINTERS = [
93
93
  :Alpha,
@@ -104,11 +104,11 @@ module RLTK::CG
104
104
  :X86,
105
105
  :XCore
106
106
  ]
107
-
107
+
108
108
  ###########
109
109
  # Methods #
110
110
  ###########
111
-
111
+
112
112
  # Converts a CamelCase string into an underscored string.
113
113
  #
114
114
  # @param [#to_s] name CamelCase string.
@@ -120,7 +120,7 @@ module RLTK::CG
120
120
  gsub(/([a-z\d])([A-Z])/,'\1_\2').
121
121
  downcase.to_sym
122
122
  end
123
-
123
+
124
124
  # A wrapper class for FFI::Library.attach_function
125
125
  #
126
126
  # @param [Symbol] func Function name.
@@ -129,21 +129,21 @@ module RLTK::CG
129
129
  def self.add_binding(func, args, returns)
130
130
  attach_function(get_bname(func.to_s[4..-1]), func, args, returns)
131
131
  end
132
-
132
+
133
133
  ####################
134
134
  # Missing Bindings #
135
135
  ####################
136
-
136
+
137
137
  ARCHS.each do |arch|
138
138
  add_binding("LLVMInitialize#{arch}Target", [], :void)
139
139
  add_binding("LLVMInitialize#{arch}TargetInfo", [], :void)
140
140
  add_binding("LLVMInitialize#{arch}TargetMC", [], :void)
141
141
  end
142
-
142
+
143
143
  ASM_PARSERS.each do |asm|
144
144
  add_binding("LLVMInitialize#{asm}AsmParser", [], :void)
145
145
  end
146
-
146
+
147
147
  ASM_PRINTERS.each do |asm|
148
148
  add_binding("LLVMInitialize#{asm}AsmPrinter", [], :void)
149
149
  end
@@ -16,36 +16,36 @@ require 'rltk/cg/instruction'
16
16
  #######################
17
17
 
18
18
  module RLTK::CG
19
-
19
+
20
20
  # This class is responsible for adding {Instruction Instructions} to {BasicBlock BasicBlocks}.
21
21
  class Builder
22
22
  include BindingClass
23
-
23
+
24
24
  # The Proc object called by the garbage collector to free resources used by LLVM.
25
25
  CLASS_FINALIZER = Proc.new { |id| Bindings.dispose_builder(ptr) if ptr = ObjectSpace._id2ref(id).ptr }
26
-
26
+
27
27
  # @return [Builder] A global Builder object.
28
28
  def self.global
29
29
  @@global_builder ||= Builder.new
30
30
  end
31
-
31
+
32
32
  # Creates a new Builder object, optionally positioning it at the end
33
33
  # of *block*. If a block is given it will be executed as if it was
34
34
  # passed to the #build method.
35
35
  #
36
36
  # @param [BasicBlock, nil] bb BasicBlock used to position the Builder.
37
37
  # @param [Array<Object>] block_args Arguments to be passed to *block*.
38
- # @param [Proc, nil] block Block to execute in the context of this Builder.
38
+ # @param [Proc, nil] block Block to execute in the context of this Builder.
39
39
  def initialize(bb = nil, *block_args, &block)
40
40
  @ptr = Bindings.create_builder
41
-
41
+
42
42
  # Define a finalizer to free the memory used by LLVM for this
43
43
  # builder.
44
44
  ObjectSpace.define_finalizer(self, CLASS_FINALIZER)
45
-
45
+
46
46
  if block then self.build(bb, *block_args, &block) elsif bb then position_at_end(bb) end
47
47
  end
48
-
48
+
49
49
  # Executes a given block inside the context of this builder. If the
50
50
  # *bb* parameter isn't nill, the Builder will be positioned at the
51
51
  # end of the specified BasicBlock.
@@ -59,7 +59,7 @@ module RLTK::CG
59
59
  self.position_at_end(bb) if bb
60
60
  self.instance_exec(*block_args, &block)
61
61
  end
62
-
62
+
63
63
  # Build an instruction.
64
64
  #
65
65
  # @param [Symbol] inst Name of instruction building method.
@@ -70,7 +70,7 @@ module RLTK::CG
70
70
  self.send(inst, *args)
71
71
  end
72
72
  alias :'<<' :build_inst
73
-
73
+
74
74
  # Position the Builder after the given instruction.
75
75
  #
76
76
  # @param [BasicBlock] bb
@@ -81,7 +81,7 @@ module RLTK::CG
81
81
  Bindings.position_builder(@ptr, bb, instruction) if check_type(bb, BasicBlock, 'bb')
82
82
  self
83
83
  end
84
-
84
+
85
85
  # Position the Builder at the end of the given BasicBlock.
86
86
  #
87
87
  # @param [BasicBlock] bb
@@ -93,7 +93,7 @@ module RLTK::CG
93
93
  end
94
94
  alias :pae :position_at_end
95
95
  alias :target :position_at_end
96
-
96
+
97
97
  # Position the Builder before the given Instruction.
98
98
  #
99
99
  # @param [Instruction] instruction
@@ -103,21 +103,21 @@ module RLTK::CG
103
103
  Bindings.position_builder_before(@ptr, instruction)
104
104
  self
105
105
  end
106
-
106
+
107
107
  ################################
108
108
  # Instruction Building Methods #
109
109
  ################################
110
-
110
+
111
111
  #################
112
112
  # Miscellaneous #
113
113
  #################
114
-
114
+
115
115
  # @return [BasicBlock] BasicBlock the Builder is currently positioned on.
116
116
  def current_block
117
117
  BasicBlock.new(Bindings.get_insert_block(@ptr))
118
118
  end
119
119
  alias :insertion_block :current_block
120
-
120
+
121
121
  # Generates an instruction with no defined semantics. Can be used to
122
122
  # provide hints to the optimizer.
123
123
  #
@@ -125,37 +125,37 @@ module RLTK::CG
125
125
  def unreachable
126
126
  UnreachableInst.new(Bindings.build_unreachable(@ptr))
127
127
  end
128
-
128
+
129
129
  ###########
130
130
  # Returns #
131
131
  ###########
132
-
132
+
133
133
  # @param [Value] val The Value to return.
134
134
  #
135
135
  # @return [ReturnInst]
136
136
  def ret(val)
137
137
  ReturnInst.new(Bindings.build_ret(@ptr, val))
138
138
  end
139
-
139
+
140
140
  # @return [RetVoidInst]
141
141
  def ret_void
142
142
  ReturnVoidInst.new(Bindings.build_ret_void(@ptr))
143
143
  end
144
-
144
+
145
145
  # @return [RetAggregateInst]
146
146
  def ret_aggregate(*vals)
147
147
  vals = vals.first if vals.length == 1 and vals.first.instance_of?(::Array)
148
-
148
+
149
149
  vals_ptr = FFI::MemoryPointer.new(:pointer, vals.length)
150
150
  vals_ptr.write_array_of_pointer(vals)
151
-
151
+
152
152
  ReturnAggregateInst.new(Bindings.build_aggregate_ret(@ptr, vals_ptr, vals.length))
153
153
  end
154
-
154
+
155
155
  ################
156
156
  # Control Flow #
157
157
  ################
158
-
158
+
159
159
  # Unconditional branching.
160
160
  #
161
161
  # @param [BasicBlock] block Where to jump.
@@ -165,7 +165,7 @@ module RLTK::CG
165
165
  BranchInst.new(Bindings.build_br(@ptr, block))
166
166
  end
167
167
  alias :br :branch
168
-
168
+
169
169
  # Build an instruction that performs a function call.
170
170
  #
171
171
  # @param [Function] fun Function to call.
@@ -174,13 +174,13 @@ module RLTK::CG
174
174
  # @return [CallInst]
175
175
  def call(fun, *args)
176
176
  name = if args.last.is_a?(String) then args.pop else '' end
177
-
177
+
178
178
  args_ptr = FFI::MemoryPointer.new(:pointer, args.length)
179
179
  args_ptr.write_array_of_pointer(args)
180
-
180
+
181
181
  CallInst.new(Bindings.build_call(@ptr, fun, args_ptr, args.length, name))
182
182
  end
183
-
183
+
184
184
  # Conditional branching.
185
185
  #
186
186
  # @param [Value] val Condition value.
@@ -192,7 +192,7 @@ module RLTK::CG
192
192
  CondBranchInst.new(Bindings.build_cond_br(@ptr, val, iftrue, iffalse))
193
193
  end
194
194
  alias :cond :cond_branch
195
-
195
+
196
196
  # Extract an element from a vector.
197
197
  #
198
198
  # @param [Value] vector Vector from which to extract a value.
@@ -203,7 +203,7 @@ module RLTK::CG
203
203
  def extract_element(vector, index, name = '')
204
204
  ExtractElementInst.new(Bindings.build_extract_element(@ptr, vector, index, name))
205
205
  end
206
-
206
+
207
207
  # Extract the value of a member field from an aggregate value.
208
208
  #
209
209
  # @param [Value] aggregate An aggregate value.
@@ -214,7 +214,7 @@ module RLTK::CG
214
214
  def extract_value(aggregate, index, name = '')
215
215
  ExtractValueInst.new(Bindings.build_extract_value(@ptr, aggregate, index, name))
216
216
  end
217
-
217
+
218
218
  # Insert an element into a vector.
219
219
  #
220
220
  # @param [Value] vector Vector into which to insert the element.
@@ -226,7 +226,7 @@ module RLTK::CG
226
226
  def insert_element(vector, element, index, name = '')
227
227
  InsertElementInst.new(Bindings.build_insert_element(@ptr, vector, element, index, name))
228
228
  end
229
-
229
+
230
230
  # Insert a value into an aggregate value's member field.
231
231
  #
232
232
  # @param [Value] aggregate An aggregate value.
@@ -238,7 +238,7 @@ module RLTK::CG
238
238
  def insert_value(aggregate, val, index, name = '')
239
239
  InsertValueInst.new(Bindings.build_insert_value(@ptr, aggregate, val, index, name))
240
240
  end
241
-
241
+
242
242
  # Invoke a function which may potentially unwind.
243
243
  #
244
244
  # @param [Function] fun Function to invoke.
@@ -251,7 +251,7 @@ module RLTK::CG
251
251
  def invoke(fun, args, normal, exception, name = '')
252
252
  InvokeInst.new(Bindings.build_invoke(@ptr, fun, args, args.length, normal, exception, name))
253
253
  end
254
-
254
+
255
255
  # Build a Phi node of the given type with the given incoming
256
256
  # branches.
257
257
  #
@@ -267,7 +267,7 @@ module RLTK::CG
267
267
  phi.incoming.add(incoming)
268
268
  end
269
269
  end
270
-
270
+
271
271
  # Return a value based on a condition. This differs from *cond* in
272
272
  # that its operands are values rather than basic blocks. As a
273
273
  # consequence, both arguments must be evaluated.
@@ -282,7 +282,7 @@ module RLTK::CG
282
282
  def select(if_val, then_val, else_val, name = '')
283
283
  SelectInst.new(Bindings.build_select(@ptr, if_val, then_val, else_val, name))
284
284
  end
285
-
285
+
286
286
  # Shuffle two vectors according to a given mask.
287
287
  #
288
288
  # @param [Value] vec1 Vector
@@ -294,7 +294,7 @@ module RLTK::CG
294
294
  def shuffle_vector(vec1, vec2, mask, name = '')
295
295
  ShuffleVectorInst.new(Bindings.build_shuffle_vector(@ptr, vec1, vec2, mask, name))
296
296
  end
297
-
297
+
298
298
  # Select a value based on an incoming value.
299
299
  # @param [Value] val Value to switch on.
300
300
  # @param [BasicBlock] default Default case.
@@ -308,13 +308,13 @@ module RLTK::CG
308
308
  cases.each { |val, block| inst.add_case(val, block) }
309
309
  end
310
310
  end
311
-
311
+
312
312
  ########
313
313
  # Math #
314
314
  ########
315
-
315
+
316
316
  # Addition
317
-
317
+
318
318
  # @param [Value] lhs Integer or vector of integers.
319
319
  # @param [Value] rhs Integer or vector of integers.
320
320
  # @param [String] name Name of the result in LLVM IR.
@@ -323,7 +323,7 @@ module RLTK::CG
323
323
  def add(lhs, rhs, name = '')
324
324
  AddInst.new(Bindings.build_add(@ptr, lhs, rhs, name))
325
325
  end
326
-
326
+
327
327
  # @param [Value] lhs Floating point or vector of floating points.
328
328
  # @param [Value] rhs Floating point or vector of floating points.
329
329
  # @param [String] name Name of the result in LLVM IR.
@@ -332,7 +332,7 @@ module RLTK::CG
332
332
  def fadd(lhs, rhs, name = '')
333
333
  FAddInst.new(Bindings.build_f_add(@ptr, lhs, rhs, name))
334
334
  end
335
-
335
+
336
336
  # No signed wrap addition.
337
337
  #
338
338
  # @param [Value] lhs Integer or vector of integers.
@@ -343,7 +343,7 @@ module RLTK::CG
343
343
  def nsw_add(lhs, rhs, name = '')
344
344
  NSWAddInst.new(Bindings.build_nsw_add(@ptr, lhs, rhs, name))
345
345
  end
346
-
346
+
347
347
  # No unsigned wrap addition.
348
348
  #
349
349
  # @param [Value] lhs Integer or vector of integers.
@@ -354,9 +354,9 @@ module RLTK::CG
354
354
  def nuw_add(lhs, rhs, name = '')
355
355
  NUWAddInst.new(Bindings.build_nuw_add(@ptr, lhs, rhs, name))
356
356
  end
357
-
357
+
358
358
  # Subtraction
359
-
359
+
360
360
  # @param [Value] lhs Integer or vector of integers.
361
361
  # @param [Value] rhs Integer or vector of integers.
362
362
  # @param [String] name Name of the result in LLVM IR.
@@ -365,7 +365,7 @@ module RLTK::CG
365
365
  def sub(lhs, rhs, name = '')
366
366
  SubInst.new(Bindings.build_sub(@ptr, lhs, rhs, name))
367
367
  end
368
-
368
+
369
369
  # @param [Value] lhs Floating point or vector of floating points.
370
370
  # @param [Value] rhs Floating point or vector of floating points.
371
371
  # @param [String] name Name of the result in LLVM IR.
@@ -374,7 +374,7 @@ module RLTK::CG
374
374
  def fsub(lhs, rhs, name = '')
375
375
  FSubInst.new(Bindings.build_f_sub(@ptr, lhs, rhs, name))
376
376
  end
377
-
377
+
378
378
  # No signed wrap subtraction.
379
379
  #
380
380
  # @param [Value] lhs Integer or vector of integers.
@@ -385,7 +385,7 @@ module RLTK::CG
385
385
  def nsw_sub(lhs, rhs, name = '')
386
386
  NSWSubInst.new(Bindings.build_nsw_sub(@ptr, lhs, rhs, name))
387
387
  end
388
-
388
+
389
389
  # No unsigned wrap subtraction.
390
390
  #
391
391
  # @param [Value] lhs Integer or vector of integers.
@@ -396,9 +396,9 @@ module RLTK::CG
396
396
  def nuw_sub(lhs, rhs, name = '')
397
397
  NUWSubInst.new(Bindings.build_nuw_sub(@ptr, lhs, rhs, name))
398
398
  end
399
-
399
+
400
400
  # Multiplication
401
-
401
+
402
402
  # @param [Value] lhs Integer or vector of integers.
403
403
  # @param [Value] rhs Integer or vector of integers.
404
404
  # @param [String] name Name of the result in LLVM IR.
@@ -407,7 +407,7 @@ module RLTK::CG
407
407
  def mul(lhs, rhs, name = '')
408
408
  MulInst.new(Bindings.build_mul(@ptr, lhs, rhs, name))
409
409
  end
410
-
410
+
411
411
  # @param [Value] lhs Floating point or vector of floating points.
412
412
  # @param [Value] rhs Floating point or vector of floating points.
413
413
  # @param [String] name Name of the result in LLVM IR.
@@ -416,7 +416,7 @@ module RLTK::CG
416
416
  def fmul(lhs, rhs, name = '')
417
417
  FMulInst.new(Bindings.build_f_mul(@ptr, lhs, rhs, name))
418
418
  end
419
-
419
+
420
420
  # No signed wrap multiplication.
421
421
  #
422
422
  # @param [Value] lhs Integer or vector of integers.
@@ -427,7 +427,7 @@ module RLTK::CG
427
427
  def nsw_mul(lhs, rhs, name = '')
428
428
  NSWMulInst.new(Bindings.build_nsw_mul(@ptr, lhs, rhs, name))
429
429
  end
430
-
430
+
431
431
  # No unsigned wrap multiplication.
432
432
  #
433
433
  # @param [Value] lhs Integer or vector of integers.
@@ -438,9 +438,9 @@ module RLTK::CG
438
438
  def nuw_mul(lhs, rhs, name = '')
439
439
  NUWMulInst.new(Bindings.build_nuw_mul(@ptr, lhs, rhs, name))
440
440
  end
441
-
441
+
442
442
  # Division
443
-
443
+
444
444
  # @param [Value] lhs Floating point or vector of floating points.
445
445
  # @param [Value] rhs Floating point or vector of floating points.
446
446
  # @param [String] name Name of the result in LLVM IR.
@@ -449,7 +449,7 @@ module RLTK::CG
449
449
  def fdiv(lhs, rhs, name = '')
450
450
  FDivInst.new(Bindings.build_f_div(@ptr, lhs, rhs, name))
451
451
  end
452
-
452
+
453
453
  # Signed integer division.
454
454
  #
455
455
  # @param [Value] lhs Integer or vector of integers.
@@ -460,7 +460,7 @@ module RLTK::CG
460
460
  def sdiv(lhs, rhs, name = '')
461
461
  SDivInst.new(Bindings.build_s_div(@ptr, lhs, rhs, name))
462
462
  end
463
-
463
+
464
464
  # Signed exact integer division.
465
465
  #
466
466
  # @param [Value] lhs Integer or vector of integers.
@@ -471,7 +471,7 @@ module RLTK::CG
471
471
  def exact_sdiv(lhs, rhs, name = '')
472
472
  ExactSDivInst.new(Bindings.build_exact_s_div(@ptr, lhs, rhs, name))
473
473
  end
474
-
474
+
475
475
  # Unsigned integer division.
476
476
  #
477
477
  # @param [Value] lhs Integer or vector of integers.
@@ -482,9 +482,9 @@ module RLTK::CG
482
482
  def udiv(lhs, rhs, name = '')
483
483
  UDivInst.new(Bindings.build_u_div(@ptr, lhs, rhs, name))
484
484
  end
485
-
485
+
486
486
  # Remainder
487
-
487
+
488
488
  # @param [Value] lhs Floating point or vector of floating points.
489
489
  # @param [Value] rhs Floating point or vector of floating points.
490
490
  # @param [String] name Name of the result in LLVM IR.
@@ -493,7 +493,7 @@ module RLTK::CG
493
493
  def frem(lhs, rhs, name = '')
494
494
  FRemInst.new(Bindings.build_f_rem(@ptr, lhs, rhs, name))
495
495
  end
496
-
496
+
497
497
  # Signed remainder.
498
498
  #
499
499
  # @param [Value] lhs Integer or vector of integers.
@@ -504,7 +504,7 @@ module RLTK::CG
504
504
  def srem(lhs, rhs, name = '')
505
505
  SRemInst.new(Bindings.build_s_rem(@ptr, lhs, rhs, name))
506
506
  end
507
-
507
+
508
508
  # Unsigned remainder.
509
509
  #
510
510
  # @param [Value] lhs Integer or vector of integers.
@@ -515,9 +515,9 @@ module RLTK::CG
515
515
  def urem(lhs, rhs, name = '')
516
516
  URemInst.new(Bindings.build_u_rem(@ptr, lhs, rhs, name))
517
517
  end
518
-
518
+
519
519
  # Negation
520
-
520
+
521
521
  # Integer negation. Implemented as a shortcut to the equivalent sub
522
522
  # instruction.
523
523
  #
@@ -528,7 +528,7 @@ module RLTK::CG
528
528
  def neg(val, name = '')
529
529
  NegInst.new(Bindings.build_neg(@ptr, val, name))
530
530
  end
531
-
531
+
532
532
  # Floating point negation. Implemented as a shortcut to the
533
533
  # equivalent sub instruction.
534
534
  #
@@ -539,7 +539,7 @@ module RLTK::CG
539
539
  def fneg(val, name = '')
540
540
  FNegInst.new(Bindings.build_f_neg(@ptr, val, name))
541
541
  end
542
-
542
+
543
543
  # No signed wrap integer negation. Implemented as a shortcut to the
544
544
  # equivalent sub instruction.
545
545
  #
@@ -550,7 +550,7 @@ module RLTK::CG
550
550
  def nsw_neg(val, name = '')
551
551
  NSWNegInst.new(Bindings.build_nsw_neg(@ptr, val, name))
552
552
  end
553
-
553
+
554
554
  # No unsigned wrap integer negation. Implemented as a shortcut to the
555
555
  # equivalent sub instruction.
556
556
  #
@@ -561,11 +561,11 @@ module RLTK::CG
561
561
  def nuw_neg(val, name = '')
562
562
  NUWNegInst.new(Bindings.build_nuw_neg(@ptr, val, name))
563
563
  end
564
-
564
+
565
565
  ######################
566
566
  # Bitwise Operations #
567
567
  ######################
568
-
568
+
569
569
  # A wrapper method around the {#shift_left} and {#shift_right}
570
570
  # methods.
571
571
  #
@@ -582,7 +582,7 @@ module RLTK::CG
582
582
  when :right then shift_right(lhs, rhs, mode, name)
583
583
  end
584
584
  end
585
-
585
+
586
586
  # @param [Value] lhs Integer or vector of integers
587
587
  # @param [Value] rhs Integer or vector of integers
588
588
  # @param [String] name Name of the result in LLVM IR
@@ -592,7 +592,7 @@ module RLTK::CG
592
592
  LeftShiftInst.new(Bindings.build_shl(@ptr, lhs, rhs, name))
593
593
  end
594
594
  alias :shl :shift_left
595
-
595
+
596
596
  # A wrapper function around {#ashr} and {#lshr}.
597
597
  #
598
598
  # @param [Value] lhs Integer or vector of integers
@@ -605,9 +605,9 @@ module RLTK::CG
605
605
  case mode
606
606
  when :arithmetic then ashr(lhs, rhs, name)
607
607
  when :logical then lshr(lhs, rhs, name)
608
- end
608
+ end
609
609
  end
610
-
610
+
611
611
  # Arithmetic (sign extended) shift right.
612
612
  #
613
613
  # @param [Value] lhs Integer or vector of integers.
@@ -618,7 +618,7 @@ module RLTK::CG
618
618
  def ashr(lhs, rhs, name = '')
619
619
  ARightShiftInst.new(Bindings.build_a_shr(@ptr, lhs, rhs, name))
620
620
  end
621
-
621
+
622
622
  # Logical (zero fill) shift right.
623
623
  #
624
624
  # @param [Value] lhs Integer or vector of integers.
@@ -629,7 +629,7 @@ module RLTK::CG
629
629
  def lshr(lhs, rhs, name = '')
630
630
  LRightShiftInst.new(Bindings.build_l_shr(@ptr, lhs, rhs, name))
631
631
  end
632
-
632
+
633
633
  # @param [Value] lhs Integer or vector of integers.
634
634
  # @param [Value] rhs Integer or vector of integers.
635
635
  # @param [String] name Name of the result in LLVM IR.
@@ -638,7 +638,7 @@ module RLTK::CG
638
638
  def and(lhs, rhs, name = '')
639
639
  AndInst.new(Bindings.build_and(@ptr, lhs, rhs, name))
640
640
  end
641
-
641
+
642
642
  # @param [Value] lhs Integer or vector of integers.
643
643
  # @param [Value] rhs Integer or vector of integers.
644
644
  # @param [String] name Name of the result in LLVM IR.
@@ -647,7 +647,7 @@ module RLTK::CG
647
647
  def or(lhs, rhs, name = '')
648
648
  OrInst.new(Bindings.build_or(@ptr, lhs, rhs, name))
649
649
  end
650
-
650
+
651
651
  # @param [Value] lhs Integer or vector of integers.
652
652
  # @param [Value] rhs Integer or vector of integers.
653
653
  # @param [String] name Name of the result in LLVM IR.
@@ -656,7 +656,7 @@ module RLTK::CG
656
656
  def xor(lhs, rhs, name = '')
657
657
  XOrInst.new(Bindings.build_xor(@ptr, lhs, rhs, name))
658
658
  end
659
-
659
+
660
660
  # Boolean negation.
661
661
  #
662
662
  # @param [Value] val Integer or vector of integers.
@@ -666,11 +666,11 @@ module RLTK::CG
666
666
  def not(val, name = '')
667
667
  NotInst.new(Bindings.build_not(@ptr, val, name))
668
668
  end
669
-
669
+
670
670
  #####################
671
671
  # Memory Management #
672
672
  #####################
673
-
673
+
674
674
  # Heap allocation.
675
675
  #
676
676
  # @param [Type] type Type or value whose type should be malloced.
@@ -680,7 +680,7 @@ module RLTK::CG
680
680
  def malloc(type, name = '')
681
681
  MallocInst.new(Bindings.build_malloc(@ptr, check_type(type), name))
682
682
  end
683
-
683
+
684
684
  # Heap array allocation.
685
685
  #
686
686
  # @param [Type] type Type or value whose type will be the element type of the malloced array.
@@ -691,7 +691,7 @@ module RLTK::CG
691
691
  def array_malloc(type, size, name = '')
692
692
  ArrayMallocInst.new(Bindings.build_array_malloc(@ptr, check_cg_type(type), size, name))
693
693
  end
694
-
694
+
695
695
  # Stack allocation.
696
696
  #
697
697
  # @param [Type] type Type or value whose type should be allocad.
@@ -701,7 +701,7 @@ module RLTK::CG
701
701
  def alloca(type, name = '')
702
702
  AllocaInst.new(Bindings.build_alloca(@ptr, check_cg_type(type), name))
703
703
  end
704
-
704
+
705
705
  # Stack array allocation.
706
706
  #
707
707
  # @param [Type] type Type or value whose type should be allocad.
@@ -712,14 +712,14 @@ module RLTK::CG
712
712
  def array_alloca(type, size, name = '')
713
713
  ArrayAllocaInst.new(Bindings.build_array_alloca(@ptr, check_cg_type(type), size, name))
714
714
  end
715
-
715
+
716
716
  # @param [LLVM::Value] ptr The pointer to be freed.
717
717
  #
718
718
  # @return [FreeInst] The result of the free instruction.
719
719
  def free(ptr)
720
720
  FreeInst.new(Bindings.build_free(@ptr, ptr))
721
721
  end
722
-
722
+
723
723
  # Load the value of a given pointer.
724
724
  #
725
725
  # @param [Value] ptr Pointer to be loaded.
@@ -729,7 +729,7 @@ module RLTK::CG
729
729
  def load(ptr, name = '')
730
730
  LoadInst.new(Bindings.build_load(@ptr, ptr, name))
731
731
  end
732
-
732
+
733
733
  # Store a value at a given pointer.
734
734
  #
735
735
  # @param [Value] val The value to be stored.
@@ -739,7 +739,7 @@ module RLTK::CG
739
739
  def store(val, ptr)
740
740
  StoreInst.new(Bindings.build_store(@ptr, val, ptr))
741
741
  end
742
-
742
+
743
743
  # Obtain a pointer to the element at the given indices.
744
744
  #
745
745
  # @param [Value] ptr Pointer to an aggregate value
@@ -750,14 +750,14 @@ module RLTK::CG
750
750
  # @return [GetElementPtrInst] The resulting pointer.
751
751
  def get_element_ptr(ptr, indices, name = '')
752
752
  check_array_type(indices, Value, 'indices')
753
-
753
+
754
754
  indices_ptr = FFI::MemoryPointer.new(:pointer, indices.length)
755
755
  indices_ptr.write_array_of_pointer(indices)
756
-
756
+
757
757
  GetElementPtrInst.new(Bindings.build_gep(@ptr, ptr, indices_ptr, indices.length, name))
758
758
  end
759
759
  alias :gep :get_element_ptr
760
-
760
+
761
761
  # Builds a in-bounds getelementptr instruction. If the indices are
762
762
  # outside the allocated pointer the value is undefined.
763
763
  #
@@ -769,14 +769,14 @@ module RLTK::CG
769
769
  # @return [InBoundsGEPInst] The resulting pointer.
770
770
  def get_element_ptr_in_bounds(ptr, indices, name = '')
771
771
  check_array_type(indices, Value, 'indices')
772
-
772
+
773
773
  indices_ptr = FFI::MemoryPointer.new(:pointer, indices.length)
774
774
  indices_ptr.write_array_of_pointer(indices)
775
-
775
+
776
776
  InBoundsGEPInst.new(Bindings.build_in_bounds_gep(@ptr, ptr, indices_ptr, indices.length, name))
777
777
  end
778
778
  alias :inbounds_gep :get_element_ptr_in_bounds
779
-
779
+
780
780
  # Builds a struct getelementptr instruction.
781
781
  #
782
782
  # @param [Value] ptr Pointer to a structure.
@@ -788,7 +788,7 @@ module RLTK::CG
788
788
  StructGEPInst.new(Bindings.build_struct_gep(@ptr, ptr, index, name))
789
789
  end
790
790
  alias :struct_getp :struct_get_element_ptr
791
-
791
+
792
792
  # Creates a global string initialized to a given value.
793
793
  #
794
794
  # @param [String] string String used by the initialize.
@@ -798,7 +798,7 @@ module RLTK::CG
798
798
  def global_string(string, name = '')
799
799
  GlobalStringInst.new(Bindings.build_global_string(@ptr, string, name))
800
800
  end
801
-
801
+
802
802
  # Creates a pointer to a global string initialized to a given value.
803
803
  #
804
804
  # @param [String] string String used by the initializer
@@ -808,11 +808,11 @@ module RLTK::CG
808
808
  def gloabl_string_pointer(string, name = '')
809
809
  GlobalStringPtrInst.new(Bindings.build_global_string_ptr(@ptr, string, name))
810
810
  end
811
-
811
+
812
812
  #######################
813
813
  # Atomic Instructions #
814
814
  #######################
815
-
815
+
816
816
  # Create an atomic read/modify/write instruction.
817
817
  #
818
818
  # @see http://llvm.org/docs/LangRef.html#atomic-memory-ordering-constraints
@@ -827,11 +827,11 @@ module RLTK::CG
827
827
  def atomic_rmw(op, addr, val, ordering, single_thread)
828
828
  AtomicRMWInst.new(Bindings.build_atomic_rmw(@ptr, op, addr, val, ordering, single_thread.to_i))
829
829
  end
830
-
830
+
831
831
  ###############################
832
832
  # Type and Value Manipulation #
833
833
  ###############################
834
-
834
+
835
835
  # Cast a value to a given address space.
836
836
  #
837
837
  # @param [Value] val Value to cast
@@ -842,7 +842,7 @@ module RLTK::CG
842
842
  def addr_space_cast(val, type, name = '')
843
843
  AddrSpaceCast.new(Bindings.addr_space_cast(@ptr, val, check_cg_type(type), name))
844
844
  end
845
-
845
+
846
846
  # Cast a value to the given type without changing any bits.
847
847
  #
848
848
  # @param [Value] val Value to cast
@@ -853,7 +853,7 @@ module RLTK::CG
853
853
  def bitcast(val, type, name = '')
854
854
  BitCastInst.new(Bindings.build_bit_cast(@ptr, val, check_cg_type(type), name))
855
855
  end
856
-
856
+
857
857
  # @param [Value] val Value to cast.
858
858
  # @param [Type] type Target type.
859
859
  # @param [String] name Name of the result in LLVM IR.
@@ -863,7 +863,7 @@ module RLTK::CG
863
863
  FPCastInst.new(Bindings.build_fp_cast(@ptr, val, check_cg_type(type), name))
864
864
  end
865
865
  alias :fp_cast :floating_point_cast
866
-
866
+
867
867
  # Extend a floating point value.
868
868
  #
869
869
  # @param [Value] val Floating point or vector of floating point.
@@ -876,7 +876,7 @@ module RLTK::CG
876
876
  end
877
877
  alias :fp_ext :floating_point_extend
878
878
  alias :fp_extend :floating_point_extend
879
-
879
+
880
880
  # Convert a floating point to a signed integer.
881
881
  #
882
882
  # @param [Value] val Floating point or vector of floating points to convert.
@@ -888,7 +888,7 @@ module RLTK::CG
888
888
  FPToSIInst.new(Bindings.build_fp_to_si(@ptr, val, check_cg_type(type), name))
889
889
  end
890
890
  alias :fp2si :floating_point_to_signed_int
891
-
891
+
892
892
  # Convert a floating point to an unsigned integer.
893
893
  #
894
894
  # @param [Value] val Floating point or vector of floating points to convert.
@@ -900,7 +900,7 @@ module RLTK::CG
900
900
  FPToUIInst.new(Bindings.build_fp_to_ui(@ptr, val, check_cg_type(type), name))
901
901
  end
902
902
  alias :fp2ui :floating_point_to_unsigned_int
903
-
903
+
904
904
  # Truncate a floating point value.
905
905
  #
906
906
  # @param [Value] val Floating point or vector of floating point.
@@ -913,7 +913,7 @@ module RLTK::CG
913
913
  end
914
914
  alias :fp_trunc :floating_point_truncate
915
915
  alias :fp_truncate :floating_point_truncate
916
-
916
+
917
917
  # Cast an int to a pointer.
918
918
  #
919
919
  # @param [Value] val An integer value.
@@ -925,7 +925,7 @@ module RLTK::CG
925
925
  IntToPtrInst.new(Bindings.build_int_to_ptr(@ptr, val, check_cg_type(type), name))
926
926
  end
927
927
  alias :int2ptr :int_to_ptr
928
-
928
+
929
929
  # @param [Value] val An integer value.
930
930
  # @param [Type] type Integer or vector of integer target type.
931
931
  # @param [String] name Name of the result in LLVM IR.
@@ -935,7 +935,7 @@ module RLTK::CG
935
935
  IntCastInst.new(Bindings.build_int_cast(@ptr, val, check_cg_type(type), name))
936
936
  end
937
937
  alias :int_cast :integer_cast
938
-
938
+
939
939
  # @param [Value] val A pointer value.
940
940
  # @param [Type] type A pointer target type.
941
941
  # @param [String] name Name of the result in LLVM IR.
@@ -944,7 +944,7 @@ module RLTK::CG
944
944
  def ptr_cast(val, type, name = '')
945
945
  PtrCastInst.new(Bindings.build_pointer_cast(@ptr, val, check_cg_type(type), name))
946
946
  end
947
-
947
+
948
948
  # Cast a pointer to an int. Useful for pointer arithmetic.
949
949
  #
950
950
  # @param [Value] val A pointer value.
@@ -956,32 +956,32 @@ module RLTK::CG
956
956
  PtrToIntInst.new(Bindings.build_ptr_to_int(@ptr, val, check_cg_type(type), name))
957
957
  end
958
958
  alias :ptr2int :ptr_to_int
959
-
959
+
960
960
  # Sign extension by copying the sign bit (highest order bit) of the
961
961
  # value until it reaches the bit size of the given type.
962
962
  #
963
963
  # @param [Value] val Integer or vector of integers to be extended.
964
964
  # @param [Type] type Integer or vector of integer type of greater size than the size of val.
965
965
  # @param [String] name Name of the result in LLVM IR.
966
- #
966
+ #
967
967
  # @return [SignExtendInst] The extended value.
968
968
  def sign_extend(val, type, name = '')
969
969
  SignExtendInst.new(Bindings.build_s_ext(@ptr, val, check_cg_type(type), name))
970
970
  end
971
971
  alias :sext :sign_extend
972
-
972
+
973
973
  # Sign extension or bitcast.
974
974
  #
975
975
  # @param [Value] val Integer or vector of integers to be extended.
976
976
  # @param [Type] type Integer or vector of integer type of greater size than the size of val.
977
977
  # @param [String] name Name of the result in LLVM IR.
978
- #
978
+ #
979
979
  # @return [SignExtendOrBitcastInst] The extended or cast value.
980
980
  def sign_extend_or_bitcast(val, type, name = '')
981
981
  SignExtendOrBitCastInst.new(Bindings.build_s_ext_or_bit_cast(@ptr, val, check_cg_type(type), name))
982
982
  end
983
983
  alias :sext_or_bitcast :sign_extend_or_bitcast
984
-
984
+
985
985
  # Convert a signed integer to a floating point.
986
986
  #
987
987
  # @param [Value] val Signed integer or vector of signed integer to convert.
@@ -993,31 +993,31 @@ module RLTK::CG
993
993
  SIToFPInst.new(Bindings.build_si_to_fp(@ptr, val, check_cg_type(type), name))
994
994
  end
995
995
  alias :si2fp :signed_int_to_floating_point
996
-
996
+
997
997
  # Truncates its operand to the given type. The size of the value type
998
998
  # must be greater than the size of the target type.
999
999
  #
1000
1000
  # @param [Value] val Integer or vector of integers to be truncated.
1001
1001
  # @param [Type] type Integer or vector of integers of equal size to val.
1002
1002
  # @param [String] name Name of the result in LLVM IR.
1003
- #
1003
+ #
1004
1004
  # @return [TruncateInst] The truncated value.
1005
1005
  def truncate(val, type, name = '')
1006
1006
  TruncateInst.new(Bindings.build_trunc(@ptr, val, check_cg_type(type), name))
1007
1007
  end
1008
1008
  alias :trunc :truncate
1009
-
1009
+
1010
1010
  # Truncates or bitcast.
1011
1011
  #
1012
1012
  # @param [Value] val Integer or vector of integers to be truncated.
1013
1013
  # @param [Type] type Integer or vector of integers of equal size to val.
1014
1014
  # @param [String] name Name of the result in LLVM IR.
1015
- #
1015
+ #
1016
1016
  # @return [TruncateInst] The truncated or cast value.
1017
1017
  def truncate_or_bitcast(val, type, name = '')
1018
1018
  TruncateOrBitCastInst.new(Bindings.build_trunc_or_bit_cast(@ptr, val, check_cg_type(type), name))
1019
1019
  end
1020
-
1020
+
1021
1021
  # Convert an unsigned integer to a floating point.
1022
1022
  #
1023
1023
  # @param [Value] val Signed integer or vector of signed integer to convert.
@@ -1029,36 +1029,36 @@ module RLTK::CG
1029
1029
  UIToFPInst.new(Bindings.build_ui_to_fp(@ptr, val, check_cg_type(type), name))
1030
1030
  end
1031
1031
  alias :ui2fp :unsigned_int_to_floating_point
1032
-
1032
+
1033
1033
  # Zero extends its operand to the given type. The size of the value
1034
1034
  # type must be greater than the size of the target type.
1035
1035
  #
1036
1036
  # @param [Value] val Integer or vector of integers to be extended.
1037
1037
  # @param [Type] type Integer or vector of integer type of greater size than val.
1038
1038
  # @param [String] name Name of the result in LLVM IR.
1039
- #
1039
+ #
1040
1040
  # @return [ZeroExtendInst] The extended value.
1041
1041
  def zero_extend(val, type, name = '')
1042
1042
  ZeroExtendInst.new(Bindings.build_z_ext(@ptr, val, check_cg_type(type), name))
1043
1043
  end
1044
1044
  alias :zext :zero_extend
1045
-
1045
+
1046
1046
  # Zero extend or bitcast.
1047
1047
  #
1048
1048
  # @param [Value] val Integer or vector of integers to be extended.
1049
1049
  # @param [Type] type Integer or vector of integer type of greater size than val.
1050
1050
  # @param [String] name Name of the result in LLVM IR.
1051
- #
1051
+ #
1052
1052
  # @return [ZeroExtendInst] The extended or cast value.
1053
1053
  def zero_extend_or_bitcast(val, type, name = '')
1054
1054
  ZeroExtendOrBitCastInst.new(Bindings.build_z_ext_or_bit_cast(@ptr, val, check_cg_type(type), name))
1055
1055
  end
1056
1056
  alias :zext_or_bitcast :zero_extend_or_bitcast
1057
-
1057
+
1058
1058
  ###########################
1059
1059
  # Comparison Instructions #
1060
1060
  ###########################
1061
-
1061
+
1062
1062
  # Builds an icmp instruction. Compares lhs to rhs using the given
1063
1063
  # symbol predicate.
1064
1064
  #
@@ -1075,7 +1075,7 @@ module RLTK::CG
1075
1075
  IntCmpInst.new(Bindings.build_i_cmp(@ptr, pred, lhs, rhs, name))
1076
1076
  end
1077
1077
  alias :icmp :int_comparison
1078
-
1078
+
1079
1079
  # Builds an fcmp instruction. Compares lhs to rhs as reals using the
1080
1080
  # given symbol predicate.
1081
1081
  #
@@ -1092,7 +1092,7 @@ module RLTK::CG
1092
1092
  FCmpInst.new(Bindings.build_f_cmp(@ptr, pred, lhs, rhs, name))
1093
1093
  end
1094
1094
  alias :fcmp :fp_comparison
1095
-
1095
+
1096
1096
  # Calculate the difference between two pointers.
1097
1097
  #
1098
1098
  # @param [Value] lhs A pointer.
@@ -1103,7 +1103,7 @@ module RLTK::CG
1103
1103
  def ptr_diff(lhs, rhs, name = '')
1104
1104
  PtrDiffInst.new(Bindings.build_ptr_diff(lhs, rhs, name))
1105
1105
  end
1106
-
1106
+
1107
1107
  # Check if a value is not null.
1108
1108
  #
1109
1109
  # @param [Value] val Value to check.
@@ -1113,7 +1113,7 @@ module RLTK::CG
1113
1113
  def is_not_null(val, name = '')
1114
1114
  IsNotNullInst.new(Builder.build_is_not_null(@ptr, val, name))
1115
1115
  end
1116
-
1116
+
1117
1117
  # Check if a value is null.
1118
1118
  #
1119
1119
  # @param [Value] val Value to check.