class BOAST::MaskStore

@!parse module Functors; functorize MaskStore; end

Attributes

dest[R]
mask[R]
source[R]
store_type[R]

Public Class Methods

new(dest, source, mask, store_type = nil) click to toggle source
# File lib/BOAST/Language/Operators.rb, line 771
def initialize(dest, source, mask, store_type = nil)
  @dest = dest
  @source = source
  @mask = mask
  @store_type = store_type
  @store_type = source.to_var unless @store_type
end

Public Instance Methods

pr() click to toggle source
# File lib/BOAST/Language/Operators.rb, line 805
def pr
  ss = to_s
  if ss then
    s=""
    s << indent
    s << ss
    s << ";" if [C, CL, CUDA].include?( lang )
    output.puts s
  end
  return self
end
to_s() click to toggle source
# File lib/BOAST/Language/Operators.rb, line 786
def to_s
  raise OperatorError,  "Cannot store unknown type!" unless @store_type
  type = @store_type.type
  raise LanguageError,  "Unsupported language!" unless lang == C
  raise OperatorError,  "Mask size is wrong: #{@mask.length} for #{type.vector_length}!" if @mask.length != type.vector_length
  return Store( @dest, @source, :store_type => @store_type ).to_s unless @mask.include?(0)
  return nil if @mask.uniq.size == 1 and @mask.uniq.first == 0
  instruction = intrinsics(:MASKSTORE, type)
  s = ""
  dst = "#{@dest}"
  if dst[0] != "*" then
    dst = "&" + dst
  else
    dst = dst[1..-1]
  end
  p_type = type.copy(:vector_length => 1)
  return s << "#{instruction}( (#{p_type.decl} * ) #{dst}, #{get_mask}, #{Operator.convert(@source, type)} )"
end

Private Instance Methods

get_mask() click to toggle source
# File lib/BOAST/Language/Operators.rb, line 779
def get_mask
  type = @store_type.type
  return Set(@mask.collect { |m| ( m and m != 0 )  ? -1 : 0 }, Int("mask", :size => type.size, :vector_length => type.vector_length ) )
end