Class: BOAST::Load
- 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
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#return_type ⇒ Object
readonly
Returns the value of attribute return_type.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
-
#initialize(source, return_type, options = {}) ⇒ Load
constructor
A new instance of Load.
- #pr ⇒ Object
- #to_s ⇒ Object
- #to_var ⇒ Object
- #type ⇒ Object
Methods included from Functor
Methods included from PrivateStateAccessor
#address_size, #address_size=, #annotate, #annotate=, #annotate?, #annotate_indepth_list, #annotate_indepth_list=, #annotate_level, #annotate_level=, #annotate_list, #annotate_list=, #architecture, #architecture=, #array_start, #array_start=, #chain_code, #chain_code=, #chain_code?, #debug, #debug=, #debug?, #debug_kernel_source, #debug_kernel_source=, #debug_kernel_source?, #debug_source, #debug_source=, #debug_source?, #decl_module, #decl_module=, #decl_module?, #default_align, #default_align=, #default_int_signed, #default_int_signed=, #default_int_signed?, #default_int_size, #default_int_size=, #default_real_size, #default_real_size=, #default_type, #default_type=, #disable_openmp, #disable_openmp=, #disable_openmp?, #executable, #executable=, #executable?, #ffi, #ffi=, #ffi?, #fortran_line_length, #fortran_line_length=, #get_address_size, #get_annotate, #get_annotate_indepth_list, #get_annotate_level, #get_annotate_list, #get_architecture, #get_array_start, #get_chain_code, #get_debug, #get_debug_kernel_source, #get_debug_source, #get_decl_module, #get_default_align, #get_default_int_signed, #get_default_int_size, #get_default_real_size, #get_default_type, #get_disable_openmp, #get_executable, #get_ffi, #get_fortran_line_length, #get_indent_increment, #get_indent_level, #get_keep_temp, #get_lang, #get_model, #get_optimizer_log, #get_optimizer_log_file, #get_output, #get_replace_constants, #get_synchro, #get_use_vla, #get_verbose, #indent_increment, #indent_increment=, #indent_level, #indent_level=, #keep_temp, #keep_temp=, #keep_temp?, #lang, #lang=, #model, #model=, #optimizer_log, #optimizer_log=, #optimizer_log?, #optimizer_log_file, #optimizer_log_file=, #output, #output=, #replace_constants, #replace_constants=, #replace_constants?, #set_address_size, #set_annotate, #set_annotate_indepth_list, #set_annotate_level, #set_annotate_list, #set_architecture, #set_array_start, #set_chain_code, #set_debug, #set_debug_kernel_source, #set_debug_source, #set_decl_module, #set_default_align, #set_default_int_signed, #set_default_int_size, #set_default_real_size, #set_default_type, #set_disable_openmp, #set_executable, #set_ffi, #set_fortran_line_length, #set_indent_increment, #set_indent_level, #set_keep_temp, #set_lang, #set_model, #set_optimizer_log, #set_optimizer_log_file, #set_output, #set_replace_constants, #set_synchro, #set_use_vla, #set_verbose, #synchro, #synchro=, #use_vla, #use_vla=, #use_vla?, #verbose, #verbose=, #verbose?
Methods included from Inspectable
Methods included from Arithmetic
#!, #!=, #*, #**, #+, #+@, #-, #-@, #/, #<, #<=, #==, #===, #>, #>=, #and, #cast, #coerce, #components, #dereference, #or, #reference
Methods included from Intrinsics
check_coverage, generate_conversions, get_conversion_path, get_vector_decl, get_vector_decl_ARM, get_vector_decl_X86, get_vector_name, intrinsics, intrinsics_by_vector_name, type_name_ARM, type_name_X86, vector_type_name
Methods inherited from Operator
Constructor Details
#initialize(source, return_type, options = {}) ⇒ Load
Returns a new instance of Load.
542 543 544 545 546 547 548 |
# File 'lib/BOAST/Language/Operators.rb', line 542 def initialize(source, return_type, = {}) @source = source @return_type = return_type.to_var @options = @mask = [:mask] @zero = [:zero] end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
540 541 542 |
# File 'lib/BOAST/Language/Operators.rb', line 540 def @options end |
#return_type ⇒ Object (readonly)
Returns the value of attribute return_type.
539 540 541 |
# File 'lib/BOAST/Language/Operators.rb', line 539 def return_type @return_type end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
538 539 540 |
# File 'lib/BOAST/Language/Operators.rb', line 538 def source @source end |
Instance Method Details
#pr ⇒ Object
614 615 616 617 618 619 620 621 |
# 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 ⇒ Object
610 611 612 |
# File 'lib/BOAST/Language/Operators.rb', line 610 def to_s return to_var.to_s end |
#to_var ⇒ Object
554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 |
# 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 ⇒ Object
550 551 552 |
# File 'lib/BOAST/Language/Operators.rb', line 550 def type return @return_type.type end |