class BOAST::Store

@!parse module Functors; functorize Store; end

Attributes

dest[R]
options[R]
source[R]
store_type[R]

Public Class Methods

new(dest, source, options = {}) click to toggle source
# File lib/BOAST/Language/Operators.rb, line 702
def initialize(dest, source, options = {})
  @dest = dest
  @source = source
  @store_type = options[:store_type]
  @store_type = source.to_var unless @store_type
  @mask = options[:mask]
end

Public Instance Methods

pr() click to toggle source
# File lib/BOAST/Language/Operators.rb, line 747
def pr
  s=""
  s << indent
  s << to_s
  s << ";" if [C, CL, CUDA].include?( lang )
  output.puts s
  return self
end
to_s() click to toggle source
# File lib/BOAST/Language/Operators.rb, line 710
def to_s
  if @store_type.type == @dest.type then
    return "#{@dest} = #{@source}"
  end
  if lang == C or lang == CL then
    dst = "#{@dest}"
    if dst[0] != "*" then
      dst = "&" + dst
    else
      dst = dst[1..-1]
    end
    type = @store_type.type
    return "vstore#{type.vector_length}( #{@source}, 0, #{dst} )" if lang == CL
    return "*((int64_t * ) #{dst}) = _m_to_int64( #{@source} )" if get_architecture == X86 and type.total_size*8 == 64
    sym = ""
    mask = nil
    mask = Mask(@mask, :length => @store_type.type.vector_length) if @mask
    return "" if mask and mask.empty?
    sym << "MASK_" if mask and not mask.full?
    if @dest.alignment and type.total_size and ( @dest.alignment % type.total_size ) == 0 then
      sym << "STOREA"
    else
      sym << "STORE"
    end
    instruction = intrinsics(sym.to_sym, type)
    p_type = type.copy(:vector_length => 1)
    p_type = type if get_architecture == X86 and type.kind_of?(Int)
    return "#{instruction}( (#{p_type.decl} * ) #{dst}, (#{mask.value.type.decl})#{mask}, #{@source} )" if mask and not mask.full?
    return "#{instruction}( (#{p_type.decl} * ) #{dst}, #{@source} )"
  elsif lang == FORTRAN
    if @store_type.type.vector_length > 1 and @dest.kind_of?(Index) then
      return "#{Slice::new(@dest.source, [@dest.indexes[0], @dest.indexes[0] + @store_type.type.vector_length - 1], *@dest.indexes[1..-1])} = #{@source}"
    end
  end
  return "#{@dest} = #{@source}"
end