Class: BOAST::Store

Inherits:
Operator show all
Extended by:
Functor
Includes:
Arithmetic, Inspectable, Intrinsics, PrivateStateAccessor
Defined in:
lib/BOAST/Language/Operators.rb

Constant Summary

Constants included from Intrinsics

Intrinsics::CONVERSIONS, Intrinsics::INTRINSICS

Constants inherited from Operator

Operator::DISCARD_OPTIONS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Functor

extended

Methods included from PrivateStateAccessor

private_boolean_state_accessor, private_state_accessor

Methods included from Inspectable

#inspect

Methods included from Arithmetic

#!, #!=, #*, #+, #-, #-@, #/, #<, #<=, #==, #===, #>, #>=, #address, #and, #components, #dereference, #or

Methods included from Intrinsics

get_conversion_path, get_vector_decl, get_vector_decl_ARM, get_vector_decl_X86, get_vector_name, intrinsics, intrinsics_by_vector_name, supported, type_name_ARM, type_name_X86, vector_type_name

Methods inherited from Operator

convert, inspect

Constructor Details

#initialize(dest, source, mask, store_type = nil) ⇒ Store

Returns a new instance of Store.



370
371
372
373
374
375
# File 'lib/BOAST/Language/Operators.rb', line 370

def initialize(dest, source, mask, store_type = nil)
  @dest = dest
  @source = source
  @store_type = store_type
  @store_type = source unless @store_type
end

Instance Attribute Details

#destObject (readonly)

Returns the value of attribute dest.



366
367
368
# File 'lib/BOAST/Language/Operators.rb', line 366

def dest
  @dest
end

#sourceObject (readonly)

Returns the value of attribute source.



367
368
369
# File 'lib/BOAST/Language/Operators.rb', line 367

def source
  @source
end

#store_typeObject (readonly)

Returns the value of attribute store_type.



368
369
370
# File 'lib/BOAST/Language/Operators.rb', line 368

def store_type
  @store_type
end

Instance Method Details

#prObject



402
403
404
405
406
407
408
409
# File 'lib/BOAST/Language/Operators.rb', line 402

def pr
  s=""
  s += indent
  s += to_s
  s += ";" if [C, CL, CUDA].include?( lang )
  output.puts s
  return self
end

#to_sObject



377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
# File 'lib/BOAST/Language/Operators.rb', line 377

def to_s
  if lang == C or lang == CL then
    dst = "#{@dest}"
    if dst[0] != "*" then
      dst = "&" + dst
    else
      dst = dst[1..-1]
    end

    return "vstore#{@source.type.vector_length}(#{@source}, 0, #{dst})" if lang == CL
    return "*((int64_t * ) #{dst}) = _m_to_int64( #{@source} )" if get_architecture == X86 and @source.type.total_size*8 == 64

    if @dest.align == @source.type.total_size then
      instruction = intrinsics(:STOREA, @source.type)
    else
      instruction = intrinsics(:STORE, @source.type)
    end
    raise "Unavailable operator store for #{get_vector_name(@source.type)}!" unless instruction
    p_type = @source.type.copy(:vector_length => 1)
    p_type = @source.type if get_architecture == X86 and @source.type.kind_of?(Int)
    return "#{instruction}( (#{p_type.decl} * ) #{dst}, #{@source} )"
  end
  return Affectation.basic_usage(@dest, @source)
end