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.



691
692
693
694
# File 'lib/llvm/core/value.rb', line 691

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.



680
681
682
683
# File 'lib/llvm/core/value.rb', line 680

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

#-(rhs) ⇒ Object



685
686
687
688
# File 'lib/llvm/core/value.rb', line 685

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

#-@Object

Negation. fneg



675
676
677
# File 'lib/llvm/core/value.rb', line 675

def -@
  type.from_f(-to_f)
end

#/(rhs) ⇒ Object

Returns the result of dividing this ConstantReal by rhs.



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

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))



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

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:



726
727
728
# File 'lib/llvm/core/value.rb', line 726

def fcmp(_pred, _rhs)
  raise DeprecationError
end

#rem(rhs) ⇒ Object

Remainder.



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

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



751
752
753
754
755
756
757
# File 'lib/llvm/core/value.rb', line 751

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))



733
734
735
# File 'lib/llvm/core/value.rb', line 733

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))



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

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