Class: LLVM::Phi

Inherits:
Instruction show all
Defined in:
lib/llvm/core/value.rb

Instance Method Summary collapse

Methods inherited from Instruction

#next, #opcode, #parent, #previous

Methods inherited from User

#operands

Methods inherited from Value

#add_attribute, #allocated_type, #constant?, #dump, from_ptr, #name, #name=, #null?, #remove_attribute, to_ptr, #to_s, #type, type, #undefined?

Methods included from PointerIdentity

#==, #eql?, #hash, #to_ptr

Instance Method Details

#add_incoming(incoming) ⇒ Object

Add incoming branches to a phi node by passing an alternating list of resulting values and BasicBlocks. e.g.

phi.add_incoming(val1, block1, val2, block2, ...)


1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
# File 'lib/llvm/core/value.rb', line 1010

def add_incoming(incoming)
  blks = incoming.keys
  vals = incoming.values_at(*blks)
  size = incoming.size

  FFI::MemoryPointer.new(FFI.type_size(:pointer) * size) do |vals_ptr|
    vals_ptr.write_array_of_pointer(vals)
    FFI::MemoryPointer.new(FFI.type_size(:pointer) * size) do |blks_ptr|
      blks_ptr.write_array_of_pointer(blks)
      C.add_incoming(self, vals_ptr, blks_ptr, vals.size)
    end
  end

  nil
end