Class: BOAST::Set

Inherits:
Operator show all
Defined in:
lib/BOAST/Operators.rb

Class Method Summary collapse

Methods inherited from Operator

convert, get_vector_name, inspect

Methods included from PrivateStateAccessor

private_boolean_state_accessor, private_state_accessor

Class Method Details

.basic_usage(arg1, arg2) ⇒ Object



207
208
209
# File 'lib/BOAST/Operators.rb', line 207

def Set.basic_usage(arg1, arg2)
  return "(#{arg1} = #{arg2})"
end

.to_s(arg1, arg2, return_type) ⇒ Object



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/BOAST/Operators.rb', line 170

def Set.to_s(arg1, arg2, return_type)
  if lang == C then
    if arg1.class == Variable and arg1.type.vector_length > 1 then
      if arg1.type == arg2.type then
        return basic_usage(arg1, arg2)
      elsif arg1.type.vector_length == arg2.type.vector_length then
        return "(#{arg1} = #{convert(arg2, arg1.type)})"
      elsif arg2.type.vector_length == 1 then
        size = arg1.type.total_size*8
        case get_architecture
        when ARM
          intr_name = "vmov"
          intr_name += "q" if size == 128
          intr_name += "_n_#{get_vector_name(arg1.type)}"
        when X86
          return "(#{arg1} = _m_from_int64( #{a2} ))" if arg1.type.class == Int and arg1.type.size == 8 and size == 64
          intr_name = "_mm"
          if size > 128 then
            intr_name += "#{size}"
          end
          intr_name += "_set1_#{get_vector_name(arg1.type).gsub("u","")}"
          intr_name += "x" if arg1.type.class == Int and arg1.type.size == 8
        else
          raise "Unsupported architecture!"
        end
        return "(#{arg1} = #{intr_name}( #{arg2} ))"
      else
        raise "Unknown convertion between vector of different length!"
      end
    else
      return basic_usage(arg1, arg2)
    end
  else
    return basic_usage(arg1, arg2)
  end
end