Class: LLVM::ConstantInt
- Extended by:
- Gem::Deprecate
- Defined in:
- lib/llvm/core/value.rb
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.
-
#int_to_ptr(type = LLVM.Pointer) ⇒ Object
Conversion to pointer.
-
#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
Boolean negation.
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 Also known as: and
Integer AND. was: self.class.from_ptr(C.const_and(self, rhs))
535 536 537 538 |
# File 'lib/llvm/core/value.rb', line 535 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.
486 487 488 |
# File 'lib/llvm/core/value.rb', line 486 def *(rhs) self.class.from_ptr(C.const_mul(self, rhs)) end |
#+(rhs) ⇒ Object Also known as: add
Addition.
452 453 454 |
# File 'lib/llvm/core/value.rb', line 452 def +(rhs) self.class.from_ptr(C.const_add(self, rhs)) end |
#-(rhs) ⇒ Object Also known as: sub
Subtraction.
469 470 471 |
# File 'lib/llvm/core/value.rb', line 469 def -(rhs) self.class.from_ptr(C.const_sub(self, rhs)) end |
#-@ ⇒ Object Also known as: neg
Negation.
431 432 433 |
# File 'lib/llvm/core/value.rb', line 431 def -@ self.class.from_ptr(C.const_neg(self)) end |
#/(rhs) ⇒ Object
Signed division.
509 510 511 512 |
# File 'lib/llvm/core/value.rb', line 509 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.
558 559 560 561 |
# File 'lib/llvm/core/value.rb', line 558 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.
551 552 553 |
# File 'lib/llvm/core/value.rb', line 551 def ^(rhs) self.class.from_ptr(C.const_xor(self, rhs)) end |
#ashr(bits) ⇒ Object
Arithmatic shift right.
575 576 577 578 |
# File 'lib/llvm/core/value.rb', line 575 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
592 593 594 |
# File 'lib/llvm/core/value.rb', line 592 def icmp(_pred, _rhs) raise DeprecationError end |
#int_to_ptr(type = LLVM.Pointer) ⇒ Object
Conversion to pointer.
597 598 599 |
# File 'lib/llvm/core/value.rb', line 597 def int_to_ptr(type = LLVM.Pointer) ConstantExpr.from_ptr(C.const_int_to_ptr(self, type)) end |
#lshr(bits) ⇒ Object Also known as: shr, >>
Shift right.
566 567 568 569 |
# File 'lib/llvm/core/value.rb', line 566 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.
459 460 461 |
# File 'lib/llvm/core/value.rb', line 459 def nsw_add(rhs) self.class.from_ptr(C.const_nsw_add(self, rhs)) end |
#nsw_mul(rhs) ⇒ Object
“No signed wrap” multiplication.
493 494 495 |
# File 'lib/llvm/core/value.rb', line 493 def nsw_mul(rhs) self.class.from_ptr(C.const_nsw_mul(self, rhs)) end |
#nsw_neg ⇒ Object
“No signed wrap” negation.
438 439 440 |
# File 'lib/llvm/core/value.rb', line 438 def nsw_neg self.class.from_ptr(C.const_nsw_neg(self)) end |
#nsw_sub(rhs) ⇒ Object
“No signed wrap” subtraction.
476 477 478 |
# File 'lib/llvm/core/value.rb', line 476 def nsw_sub(rhs) self.class.from_ptr(C.const_nsw_sub(self, rhs)) end |
#nuw_add(rhs) ⇒ Object
“No unsigned wrap” addition.
464 465 466 |
# File 'lib/llvm/core/value.rb', line 464 def nuw_add(rhs) self.class.from_ptr(C.const_nuw_add(self, rhs)) end |
#nuw_mul(rhs) ⇒ Object
“No unsigned wrap” multiplication.
498 499 500 |
# File 'lib/llvm/core/value.rb', line 498 def nuw_mul(rhs) self.class.from_ptr(C.const_nuw_mul(self, rhs)) end |
#nuw_neg ⇒ Object
“No unsigned wrap” negation.
444 445 446 447 448 |
# File 'lib/llvm/core/value.rb', line 444 def nuw_neg # :nocov: self.class.from_ptr(C.const_nuw_neg(self)) # :nocov: end |
#nuw_sub(rhs) ⇒ Object
“No unsigned wrap” subtraction.
481 482 483 |
# File 'lib/llvm/core/value.rb', line 481 def nuw_sub(rhs) self.class.from_ptr(C.const_nuw_sub(self, rhs)) end |
#rem(rhs) ⇒ Object
Signed remainder.
521 522 523 524 |
# File 'lib/llvm/core/value.rb', line 521 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))
617 618 619 |
# File 'lib/llvm/core/value.rb', line 617 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))
630 631 632 |
# File 'lib/llvm/core/value.rb', line 630 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
645 646 647 648 649 650 651 |
# File 'lib/llvm/core/value.rb', line 645 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
605 606 607 |
# File 'lib/llvm/core/value.rb', line 605 def to_si to_i(true) end |
#to_ui ⇒ Object
601 602 603 |
# File 'lib/llvm/core/value.rb', line 601 def to_ui to_i(false) end |
#trunc(type) ⇒ Object
constant trunc was: self.class.from_ptr(C.const_trunc(self, type))
624 625 626 |
# File 'lib/llvm/core/value.rb', line 624 def trunc(type) type.from_i(to_i) end |
#udiv(rhs) ⇒ Object
Unsigned division.
503 504 505 506 |
# File 'lib/llvm/core/value.rb', line 503 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.
515 516 517 518 |
# File 'lib/llvm/core/value.rb', line 515 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))
611 612 613 |
# File 'lib/llvm/core/value.rb', line 611 def zext(type) type.from_i(to_ui) end |