Class: LLVM::ConstantReal
- Defined in:
- lib/llvm/core/value.rb
Instance Method Summary collapse
-
#*(rhs) ⇒ Object
Returns the result of multiplying this ConstantReal by rhs.
-
#+(rhs) ⇒ Object
Returns the result of adding this ConstantReal to rhs.
- #-(rhs) ⇒ Object
-
#-@ ⇒ Object
Negation.
-
#/(rhs) ⇒ Object
Returns the result of dividing this ConstantReal by rhs.
-
#ext(type) ⇒ Object
(also: #sext)
Constant FPExt this is a signed extension was: self.class.from_ptr(C.const_fp_ext(self, type)).
-
#fcmp(_pred, _rhs) ⇒ Object
Floating point comparison using the predicate specified via the first parameter.
-
#rem(rhs) ⇒ Object
Remainder.
-
#to_f ⇒ Object
get double from value.
-
#to_i(type) ⇒ Object
constant FPToSI LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType); was: self.class.from_ptr(C.const_fp_to_si(self, type)).
-
#trunc(type) ⇒ Object
was: self.class.from_ptr(C.const_fp_trunc(self, type)).
Methods inherited from Constant
#bitcast_to, #gep, null, null_ptr, poison, #ptr_to_int, undef
Methods inherited from User
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
Instance Method Details
#*(rhs) ⇒ Object
Returns the result of multiplying this ConstantReal by rhs.
706 707 708 709 |
# File 'lib/llvm/core/value.rb', line 706 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.
695 696 697 698 |
# File 'lib/llvm/core/value.rb', line 695 def +(rhs) type = LLVM::RealType.fits([self.type, rhs.type]) type.from_f(to_f + rhs.to_f) end |
#-(rhs) ⇒ Object
700 701 702 703 |
# File 'lib/llvm/core/value.rb', line 700 def -(rhs) type = LLVM::RealType.fits([self.type, rhs.type]) type.from_f(to_f - rhs.to_f) end |
#-@ ⇒ Object
Negation. fneg
690 691 692 |
# File 'lib/llvm/core/value.rb', line 690 def -@ type.from_f(-to_f) end |
#/(rhs) ⇒ Object
Returns the result of dividing this ConstantReal by rhs.
712 713 714 715 |
# File 'lib/llvm/core/value.rb', line 712 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))
755 756 757 |
# File 'lib/llvm/core/value.rb', line 755 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
741 742 743 |
# File 'lib/llvm/core/value.rb', line 741 def fcmp(_pred, _rhs) raise DeprecationError end |
#rem(rhs) ⇒ Object
Remainder.
718 719 720 721 |
# File 'lib/llvm/core/value.rb', line 718 def rem(rhs) type = LLVM::RealType.fits([self.type, rhs.type]) type.from_f(to_f.divmod(rhs.to_f).last) end |
#to_f ⇒ Object
get double from value
766 767 768 769 770 771 772 |
# File 'lib/llvm/core/value.rb', line 766 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))
748 749 750 |
# File 'lib/llvm/core/value.rb', line 748 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))
761 762 763 |
# File 'lib/llvm/core/value.rb', line 761 def trunc(type) type.from_f(to_f) end |