Class: LLVM::ConstantInt
- Extended by:
- Gem::Deprecate
- Defined in:
- lib/llvm/core/value.rb
Instance Attribute Summary
Attributes included from PointerIdentity
Instance Method Summary collapse
-
#&(rhs) ⇒ Object
(also: #and)
Integer AND.
-
#*(rhs) ⇒ Object
(also: #mul)
Multiplication.
-
#+(rhs) ⇒ Object
(also: #add)
Addition.
-
#-(rhs) ⇒ Object
(also: #sub)
Subtraction.
-
#-@ ⇒ Object
(also: #neg)
Negation.
-
#/(rhs) ⇒ Object
Signed division.
-
#<<(bits) ⇒ Object
(also: #shl)
Shift left.
-
#^(rhs) ⇒ Object
(also: #xor)
Integer XOR.
-
#ashr(bits) ⇒ Object
Arithmatic shift right.
-
#icmp(_pred, _rhs) ⇒ Object
Integer comparison using the predicate specified via the first parameter.
-
#lshr(bits) ⇒ Object
(also: #shr, #>>)
Shift right.
-
#nsw_add(rhs) ⇒ Object
“No signed wrap” addition.
-
#nsw_mul(rhs) ⇒ Object
“No signed wrap” multiplication.
-
#nsw_neg ⇒ Object
“No signed wrap” negation.
-
#nsw_sub(rhs) ⇒ Object
“No signed wrap” subtraction.
-
#nuw_add(rhs) ⇒ Object
“No unsigned wrap” addition.
-
#nuw_mul(rhs) ⇒ Object
“No unsigned wrap” multiplication.
- #nuw_neg ⇒ Object deprecated Deprecated.
-
#nuw_sub(rhs) ⇒ Object
“No unsigned wrap” subtraction.
-
#rem(rhs) ⇒ Object
Signed remainder.
-
#sext(type) ⇒ Object
(also: #ext)
constant sext was: self.class.from_ptr(C.const_s_ext(self, type)).
-
#to_f(type) ⇒ Object
LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType); was: self.class.from_ptr(C.const_si_to_fp(self, type)).
-
#to_i(signed = true) ⇒ Object
const_int_get_sext_value const_int_get_zext_value only return long long, 64-bits beyond 64-bits parse the string value into a ruby integer TODO: overflow behavior is not the same on these arms, signed is ignored above 64-bits.
- #to_si ⇒ Object
- #to_ui ⇒ Object
-
#trunc(type) ⇒ Object
constant trunc was: self.class.from_ptr(C.const_trunc(self, type)).
-
#udiv(rhs) ⇒ Object
Unsigned division.
-
#urem(rhs) ⇒ Object
Unsigned remainder.
-
#zext(type) ⇒ Object
constant zext was: self.class.from_ptr(C.const_z_ext(self, type)).
-
#|(rhs) ⇒ Object
(also: #or)
Integer OR.
-
#~ ⇒ Object
(also: #not)
Boolean negation.
Methods inherited from Constant
#bitcast_to, #gep, #int_to_ptr, 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 Also known as: and
Integer AND. was: self.class.from_ptr(C.const_and(self, rhs))
570 571 572 573 |
# File 'lib/llvm/core/value.rb', line 570 def &(rhs) width = [type.width, rhs.type.width].max LLVM::Type.integer(width).from_i(to_i & rhs.to_i) end |
#*(rhs) ⇒ Object Also known as: mul
Multiplication. : (ConstantInt) -> ConstantInt
511 512 513 514 515 516 |
# File 'lib/llvm/core/value.rb', line 511 def *(rhs) width = [type.width, rhs.type.width].max product = to_i * rhs.to_i modulo = product % (2**width) LLVM::Type.integer(width).from_i(modulo, false) end |
#+(rhs) ⇒ Object Also known as: add
Addition. : (ConstantInt) -> ConstantInt
471 472 473 |
# File 'lib/llvm/core/value.rb', line 471 def +(rhs) self.class.from_ptr(C.const_add(self, rhs)) end |
#-(rhs) ⇒ Object Also known as: sub
Subtraction. : (ConstantInt) -> ConstantInt
491 492 493 |
# File 'lib/llvm/core/value.rb', line 491 def -(rhs) self.class.from_ptr(C.const_sub(self, rhs)) end |
#-@ ⇒ Object Also known as: neg
Negation. : -> ConstantInt
447 448 449 |
# File 'lib/llvm/core/value.rb', line 447 def -@ self.class.from_ptr(C.const_neg(self)) end |
#/(rhs) ⇒ Object
Signed division. : (ConstantInt) -> ConstantInt
541 542 543 544 |
# File 'lib/llvm/core/value.rb', line 541 def /(rhs) width = [type.width, rhs.type.width].max LLVM::Type.integer(width).from_i(to_si / rhs.to_si, true) end |
#<<(bits) ⇒ Object Also known as: shl
Shift left.
593 594 595 596 |
# File 'lib/llvm/core/value.rb', line 593 def <<(bits) width = [type.width, bits.type.width].max LLVM::Type.integer(width).from_i(to_i << bits.to_i) end |
#^(rhs) ⇒ Object Also known as: xor
Integer XOR.
586 587 588 |
# File 'lib/llvm/core/value.rb', line 586 def ^(rhs) self.class.from_ptr(C.const_xor(self, rhs)) end |
#ashr(bits) ⇒ Object
Arithmatic shift right.
610 611 612 613 |
# File 'lib/llvm/core/value.rb', line 610 def ashr(bits) width = [type.width, bits.type.width].max LLVM::Type.integer(width).from_i(to_i >> bits.to_i) end |
#icmp(_pred, _rhs) ⇒ Object
Integer comparison using the predicate specified via the first parameter. Predicate can be any of:
:eq - equal to
:ne - not equal to
:ugt - unsigned greater than
:uge - unsigned greater than or equal to
:ult - unsigned less than
:ule - unsigned less than or equal to
:sgt - signed greater than
:sge - signed greater than or equal to
:slt - signed less than
:sle - signed less than or equal to
627 628 629 |
# File 'lib/llvm/core/value.rb', line 627 def icmp(_pred, _rhs) raise DeprecationError end |
#lshr(bits) ⇒ Object Also known as: shr, >>
Shift right.
601 602 603 604 |
# File 'lib/llvm/core/value.rb', line 601 def lshr(bits) width = [type.width, bits.type.width].max LLVM::Type.integer(width).from_i(to_ui >> bits.to_i) end |
#nsw_add(rhs) ⇒ Object
“No signed wrap” addition. : (ConstantInt) -> ConstantInt
479 480 481 |
# File 'lib/llvm/core/value.rb', line 479 def nsw_add(rhs) self.class.from_ptr(C.const_nsw_add(self, rhs)) end |
#nsw_mul(rhs) ⇒ Object
“No signed wrap” multiplication. : (ConstantInt) -> ConstantInt
522 523 524 |
# File 'lib/llvm/core/value.rb', line 522 def nsw_mul(rhs) mul(rhs) end |
#nsw_neg ⇒ Object
“No signed wrap” negation. : -> ConstantInt
455 456 457 |
# File 'lib/llvm/core/value.rb', line 455 def nsw_neg self.class.from_ptr(C.const_nsw_neg(self)) end |
#nsw_sub(rhs) ⇒ Object
“No signed wrap” subtraction. : (ConstantInt) -> ConstantInt
499 500 501 |
# File 'lib/llvm/core/value.rb', line 499 def nsw_sub(rhs) self.class.from_ptr(C.const_nsw_sub(self, rhs)) end |
#nuw_add(rhs) ⇒ Object
“No unsigned wrap” addition. : (ConstantInt) -> ConstantInt
485 486 487 |
# File 'lib/llvm/core/value.rb', line 485 def nuw_add(rhs) self.class.from_ptr(C.const_nuw_add(self, rhs)) end |
#nuw_mul(rhs) ⇒ Object
“No unsigned wrap” multiplication. : (ConstantInt) -> ConstantInt
528 529 530 |
# File 'lib/llvm/core/value.rb', line 528 def nuw_mul(rhs) mul(rhs) end |
#nuw_neg ⇒ Object
“No unsigned wrap” negation. : -> ConstantInt
462 463 464 465 466 |
# File 'lib/llvm/core/value.rb', line 462 def nuw_neg # :nocov: self.class.from_ptr(C.const_nuw_neg(self)) # :nocov: end |
#nuw_sub(rhs) ⇒ Object
“No unsigned wrap” subtraction. : (ConstantInt) -> ConstantInt
505 506 507 |
# File 'lib/llvm/core/value.rb', line 505 def nuw_sub(rhs) self.class.from_ptr(C.const_nuw_sub(self, rhs)) end |
#rem(rhs) ⇒ Object
Signed remainder. : (ConstantInt) -> ConstantInt
555 556 557 558 |
# File 'lib/llvm/core/value.rb', line 555 def rem(rhs) width = [type.width, rhs.type.width].max LLVM::Type.integer(width).from_i(to_si % rhs.to_si, true) end |
#sext(type) ⇒ Object Also known as: ext
constant sext was: self.class.from_ptr(C.const_s_ext(self, type))
647 648 649 |
# File 'lib/llvm/core/value.rb', line 647 def sext(type) type.from_i(to_si) end |
#to_f(type) ⇒ Object
LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType); was: self.class.from_ptr(C.const_si_to_fp(self, type))
660 661 662 |
# File 'lib/llvm/core/value.rb', line 660 def to_f(type) type.from_f(to_i.to_f) end |
#to_i(signed = true) ⇒ Object
const_int_get_sext_value const_int_get_zext_value only return long long, 64-bits beyond 64-bits parse the string value into a ruby integer TODO: overflow behavior is not the same on these arms, signed is ignored above 64-bits
675 676 677 678 679 680 681 |
# File 'lib/llvm/core/value.rb', line 675 def to_i(signed = true) if type.width <= 64 to_i_i64(signed) else to_s.split.last.to_i end end |
#to_si ⇒ Object
635 636 637 |
# File 'lib/llvm/core/value.rb', line 635 def to_si to_i(true) end |
#to_ui ⇒ Object
631 632 633 |
# File 'lib/llvm/core/value.rb', line 631 def to_ui to_i(false) end |
#trunc(type) ⇒ Object
constant trunc was: self.class.from_ptr(C.const_trunc(self, type))
654 655 656 |
# File 'lib/llvm/core/value.rb', line 654 def trunc(type) type.from_i(to_i) end |
#udiv(rhs) ⇒ Object
Unsigned division. : (ConstantInt) -> ConstantInt
534 535 536 537 |
# File 'lib/llvm/core/value.rb', line 534 def udiv(rhs) width = [type.width, rhs.type.width].max LLVM::Type.integer(width).from_i(to_ui / rhs.to_ui, false) end |
#urem(rhs) ⇒ Object
Unsigned remainder. : (ConstantInt) -> ConstantInt
548 549 550 551 |
# File 'lib/llvm/core/value.rb', line 548 def urem(rhs) width = [type.width, rhs.type.width].max LLVM::Type.integer(width).from_i(to_ui % rhs.to_ui, false) end |
#zext(type) ⇒ Object
constant zext was: self.class.from_ptr(C.const_z_ext(self, type))
641 642 643 |
# File 'lib/llvm/core/value.rb', line 641 def zext(type) type.from_i(to_ui) end |