Class: RLTK::CG::ConstantVector

Inherits:
Constant show all
Defined in:
lib/rltk/cg/value.rb

Overview

A constant vector value used for SIMD instructions.

Instance Attribute Summary

Attributes included from BindingClass

#ptr

Instance Method Summary collapse

Methods inherited from Constant

#addr_space_cast, #bitcast_to, #get_element_ptr, #get_element_ptr_in_bounds

Methods inherited from User

#operands

Methods inherited from Value

#==, #attributes, #bitcast, #constant?, #dump, #hash, #name, #name=, #null?, #print, #trunc, #trunc_or_bitcast, #type, #undefined?, #zextend, #zextend_or_bitcast

Methods included from BindingClass

#==

Constructor Details

#initialize(size_or_values, &block) {|index| ... } ⇒ ConstantVector

Create a new constant vector value.

Examples:

Using array of values:

ConstantVector.new([Int32.new(0), Int32.new(1)])

Using size:

ConstantVector.new(2) { |i| Int32.new(i) }

Yield Parameters:

  • index (Integer)

    Index of the value in the vector.



490
491
492
493
494
495
496
497
498
499
# File 'lib/rltk/cg/value.rb', line 490

def initialize(size_or_values, &block)
  @ptr =
  if size_or_values.is_a?(FFI::Pointer)
    size_or_values
  else
    vals_ptr = make_ptr_to_elements(size_or_values, &block)

    Bindings.const_vector(vals_ptr, vals_ptr.size / vals_ptr.type_size)
  end
end

Instance Method Details

#extract_element(index) ⇒ ConstantExpr



504
505
506
# File 'lib/rltk/cg/value.rb', line 504

def extract_element(index)
  ConstantExpr.new(Bindings.const_extract_element(@ptr, index))
end

#insert_element(element, index) ⇒ ConstantExpr



512
513
514
# File 'lib/rltk/cg/value.rb', line 512

def insert_element(element, index)
  ConstantExpr.new(Bindings.const_insert_element(@ptr, element, index))
end

#shuffle(other, mask) ⇒ ConstantVector



520
521
522
# File 'lib/rltk/cg/value.rb', line 520

def shuffle(other, mask)
  ConstantVector.new(Bindings.const_shuffle_vector(@ptr, other, mask))
end

#sizeObject Also known as: length



524
525
526
# File 'lib/rltk/cg/value.rb', line 524

def size
  self.type.size
end