Class: LLVM::ConstantReal

Inherits:
Constant show all
Defined in:
lib/llvm/core/value.rb

Instance Method Summary collapse

Methods inherited from Constant

#bitcast_to, #gep, null, null_ptr, poison, #ptr_to_int, undef

Methods inherited from User

#operands

Methods inherited from Value

#add_attribute, #allocated_type, #allocated_type?, #constant?, #dump, from_ptr, from_ptr_kind, #gep_source_element_type, #gep_source_element_type?, #global_parent, #kind, #name, #name=, #null?, #poison?, #remove_attribute, to_ptr, #to_s, type, #type, #undef?

Methods included from PointerIdentity

#==, #eql?, #hash, #to_ptr

Instance Method Details

#*(rhs) ⇒ Object

Returns the result of multiplying this ConstantReal by rhs.



704
705
706
707
# File 'lib/llvm/core/value.rb', line 704

def *(rhs)
  type = LLVM::RealType.fits([self.type, rhs.type])
  type.from_f(to_f * rhs.to_f)
end

#+(rhs) ⇒ Object

Returns the result of adding this ConstantReal to rhs.



693
694
695
696
# File 'lib/llvm/core/value.rb', line 693

def +(rhs)
  type = LLVM::RealType.fits([self.type, rhs.type])
  type.from_f(to_f + rhs.to_f)
end

#-(rhs) ⇒ Object



698
699
700
701
# File 'lib/llvm/core/value.rb', line 698

def -(rhs)
  type = LLVM::RealType.fits([self.type, rhs.type])
  type.from_f(to_f - rhs.to_f)
end

#-@Object

Negation. fneg



688
689
690
# File 'lib/llvm/core/value.rb', line 688

def -@
  type.from_f(-to_f)
end

#/(rhs) ⇒ Object

Returns the result of dividing this ConstantReal by rhs.



710
711
712
713
# File 'lib/llvm/core/value.rb', line 710

def /(rhs)
  type = LLVM::RealType.fits([self.type, rhs.type])
  type.from_f(to_f / rhs.to_f) # rubocop:disable Style/FloatDivision
end

#ext(type) ⇒ Object Also known as: sext

Constant FPExt this is a signed extension was: self.class.from_ptr(C.const_fp_ext(self, type))



753
754
755
# File 'lib/llvm/core/value.rb', line 753

def ext(type)
  type.from_f(to_f)
end

#fcmp(_pred, _rhs) ⇒ Object

Floating point comparison using the predicate specified via the first parameter. Predicate can be any of:

:ord  - ordered
:uno  - unordered: isnan(X) | isnan(Y)
:oeq  - ordered and equal to
:oeq  - unordered and equal to
:one  - ordered and not equal to
:one  - unordered and not equal to
:ogt  - ordered and greater than
:uge  - unordered and greater than or equal to
:olt  - ordered and less than
:ule  - unordered and less than or equal to
:oge  - ordered and greater than or equal to
:sge  - unordered and greater than or equal to
:ole  - ordered and less than or equal to
:sle  - unordered and less than or equal to
:true - always true
:false- always false

Raises:



739
740
741
# File 'lib/llvm/core/value.rb', line 739

def fcmp(_pred, _rhs)
  raise DeprecationError
end

#rem(rhs) ⇒ Object

Remainder.



716
717
718
719
# File 'lib/llvm/core/value.rb', line 716

def rem(rhs)
  type = LLVM::RealType.fits([self.type, rhs.type])
  type.from_f(to_f.divmod(rhs.to_f).last)
end

#to_fObject

get double from value



764
765
766
767
768
769
770
# File 'lib/llvm/core/value.rb', line 764

def to_f
  double = nil
  FFI::MemoryPointer.new(:bool, 1) do |loses_info|
    double = C.const_real_get_double(self, loses_info)
  end
  double
end

#to_i(type) ⇒ Object

constant FPToSI LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType); was: self.class.from_ptr(C.const_fp_to_si(self, type))



746
747
748
# File 'lib/llvm/core/value.rb', line 746

def to_i(type)
  type.from_i(to_f.to_i)
end

#trunc(type) ⇒ Object

was: self.class.from_ptr(C.const_fp_trunc(self, type))



759
760
761
# File 'lib/llvm/core/value.rb', line 759

def trunc(type)
  type.from_f(to_f)
end