class BOAST::Load

@!parse module Functors; functorize Load; end

Attributes

options[R]
return_type[R]
source[R]

Public Class Methods

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

Public Instance Methods

pr() click to toggle source
# File lib/BOAST/Language/Operators.rb, line 614
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 610
def to_s
  return to_var.to_s
end
to_var() click to toggle source
# File lib/BOAST/Language/Operators.rb, line 554
def to_var
  if lang == C or lang == CL then
    if @source.kind_of?(Array) then
      return Set(@source, @return_type).to_var
    elsif @source.instance_of? Variable or @source.respond_to?(:to_var) then
      src_var = source.to_var
      if src_var.type == @return_type.type then
        return src_var
      elsif src_var.type.vector_length == 1 then
        a2 = "#{src_var}"
        if a2[0] != "*" then
          a2 = "&" + a2
        else
          a2 = a2[1..-1]
        end
        return @return_type.copy("vload#{@return_type.type.vector_length}(0, #{a2})", DISCARD_OPTIONS) if lang == CL
        return @return_type.copy("_m_from_int64( *((int64_t * ) #{a2} ) )", DISCARD_OPTIONS) if get_architecture == X86 and @return_type.type.total_size*8 == 64
        sym = ""
        mask = nil
        mask = Mask(@mask, :length => @return_type.type.vector_length) if @mask
        if mask and not mask.full? then
          return Set(0, @return_type) if @zero and mask.empty?
          return @return_type if mask.empty?
          sym << "MASK"
          sym << "Z" if @zero
          sym << "_"
        end
        if src_var.alignment and @return_type.type.total_size and ( src_var.alignment % @return_type.type.total_size ) == 0 then
          sym << "LOADA"
        else
          sym << "LOAD"
        end
        instruction = intrinsics( sym.to_sym, @return_type.type)
        if mask and not mask.full? then
          return @return_type.copy("#{instruction}( (#{mask.value.type.decl})#{mask}, #{a2} )", DISCARD_OPTIONS) if @zero
          return @return_type.copy("#{instruction}( #{@return_type}, (#{mask.value.type.decl})#{mask}, #{a2} )", DISCARD_OPTIONS)
        end
        return @return_type.copy("#{instruction}( #{a2} )", DISCARD_OPTIONS)
      else
        return @return_type.copy("#{Operator.convert(src_var, @return_type.type)}", DISCARD_OPTIONS)
      end
    end
  elsif lang == FORTRAN then
    if @source.kind_of?(Array) then
      return Set(@source, @return_type).to_var
    elsif @source.instance_of? Variable or @source.respond_to?(:to_var) then
      if @source.to_var.type == @return_type.type then
        return @source.to_var
      elsif @source.kind_of?(Index) and @return_type.type.vector_length > 1 then
        return @return_type.copy("#{Slice::new(@source.source, [@source.indexes[0], @source.indexes[0] + @return_type.type.vector_length - 1], *@source.indexes[1..-1])}", DISCARD_OPTIONS)
      end
    end
  end
  return @return_type.copy("#{@source}", DISCARD_OPTIONS)
end
type() click to toggle source
# File lib/BOAST/Language/Operators.rb, line 550
def type
  return @return_type.type
end