class BOAST::FMS

@!parse module Functors; functorize FMS; end

Attributes

operand1[R]
operand2[R]
operand3[R]
return_type[R]

Public Class Methods

new(a,b,c) click to toggle source
# File lib/BOAST/Language/Operators.rb, line 902
def initialize(a,b,c)
  @operand1 = a
  @operand2 = b
  @operand3 = c
  @return_type = @operand3.to_var
end

Public Instance Methods

pr() click to toggle source
# File lib/BOAST/Language/Operators.rb, line 949
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 945
def to_s
  return to_var.to_s
end
to_var() click to toggle source
# File lib/BOAST/Language/Operators.rb, line 919
def to_var
  instruction = nil
  begin
    instruction = intrinsics(:FNMADD,@return_type.type)
  rescue
  end
  return (@operand3 - @operand1 * @operand2).to_var unless lang != FORTRAN and @return_type and ( instruction or ( [CL, CUDA].include?(lang) ) )
  op1 = convert_operand(@operand1.to_var)
  op2 = convert_operand(@operand2.to_var)
  op3 = convert_operand(@operand3.to_var)
  if [CL, CUDA].include?(lang)
    op1 = convert_operand((-@operand1).to_var)
    ret_name = "fma( #{op1}, #{op2}, #{op3} )"
  else
    case architecture
    when X86
      ret_name = "#{instruction}( #{op1}, #{op2}, #{op3} )"
    when ARM
      ret_name = "#{instruction}( #{op3}, #{op1}, #{op2} )"
    else
      return (@operand3 - @operand1 * @operand2).to_var
    end
  end
  return @return_type.copy( ret_name, DISCARD_OPTIONS)
end
type() click to toggle source
# File lib/BOAST/Language/Operators.rb, line 915
def type
  return @return_type.type
end

Private Instance Methods

convert_operand(op) click to toggle source
# File lib/BOAST/Language/Operators.rb, line 909
def convert_operand(op)
  return  "#{Operator.convert(op, @return_type.type)}"
end