Class: LLVM::ConstantInt
- Defined in:
- lib/llvm/core/value.rb
Class Method Summary collapse
- .all_ones ⇒ Object
-
.fits_width?(int, width, signed) ⇒ Boolean
does int fit in width allow 1 for signed i1 (though really it’s -1 to 0).
-
.from_i(int, signed = true) ⇒ Object
Creates a ConstantInt from an integer.
- .parse(str, radix = 10) ⇒ Object
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.
-
#>>(bits) ⇒ Object
(also: #shr)
Shift right.
-
#^(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) ⇒ Object
Conversion to pointer.
-
#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
“No unsigned wrap” negation.
-
#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
- #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, #ptr_to_int, undef
Methods inherited from User
Methods inherited from Value
#add_attribute, #allocated_type, #constant?, #dump, from_ptr, from_ptr_kind, #global_parent, #kind, #name, #name=, #null?, #remove_attribute, to_ptr, #to_s, type, #type, #undefined?
Methods included from PointerIdentity
Class Method Details
.all_ones ⇒ Object
362 363 364 |
# File 'lib/llvm/core/value.rb', line 362 def self.all_ones from_ptr(C.const_all_ones(type)) end |
.fits_width?(int, width, signed) ⇒ Boolean
does int fit in width allow 1 for signed i1 (though really it’s -1 to 0)
376 377 378 379 380 381 382 |
# File 'lib/llvm/core/value.rb', line 376 def self.fits_width?(int, width, signed) if signed int.bit_length < width || int == 1 else int >= 0 && int.bit_length <= width end end |
.from_i(int, signed = true) ⇒ Object
Creates a ConstantInt from an integer.
367 368 369 370 371 372 |
# File 'lib/llvm/core/value.rb', line 367 def self.from_i(int, signed = true) width = type.width return type.poison if !fits_width?(int, width, signed) from_ptr(C.const_int(type, int, signed ? 1 : 0)) end |
.parse(str, radix = 10) ⇒ Object
384 385 386 |
# File 'lib/llvm/core/value.rb', line 384 def self.parse(str, radix = 10) from_ptr(C.const_int_of_string(type, str, radix)) end |
Instance Method Details
#&(rhs) ⇒ Object Also known as: and
Integer AND. was: self.class.from_ptr(C.const_and(self, rhs))
485 486 487 |
# File 'lib/llvm/core/value.rb', line 485 def &(rhs) self.class.from_i(to_i & rhs.to_i) end |
#*(rhs) ⇒ Object Also known as: mul
Multiplication.
440 441 442 |
# File 'lib/llvm/core/value.rb', line 440 def *(rhs) self.class.from_ptr(C.const_mul(self, rhs)) end |
#+(rhs) ⇒ Object Also known as: add
Addition.
406 407 408 |
# File 'lib/llvm/core/value.rb', line 406 def +(rhs) self.class.from_ptr(C.const_add(self, rhs)) end |
#-(rhs) ⇒ Object Also known as: sub
Subtraction.
423 424 425 |
# File 'lib/llvm/core/value.rb', line 423 def -(rhs) self.class.from_ptr(C.const_sub(self, rhs)) end |
#-@ ⇒ Object Also known as: neg
Negation.
389 390 391 |
# File 'lib/llvm/core/value.rb', line 389 def -@ self.class.from_ptr(C.const_neg(self)) end |
#/(rhs) ⇒ Object
Signed division.
462 463 464 |
# File 'lib/llvm/core/value.rb', line 462 def /(rhs) self.class.from_i(to_si / rhs.to_si, true) end |
#<<(bits) ⇒ Object Also known as: shl
Shift left.
506 507 508 |
# File 'lib/llvm/core/value.rb', line 506 def <<(bits) self.class.from_ptr(C.const_shl(self, bits)) end |
#>>(bits) ⇒ Object Also known as: shr
Shift right.
513 514 515 |
# File 'lib/llvm/core/value.rb', line 513 def >>(bits) self.class.from_ptr(C.const_l_shr(self, bits)) end |
#^(rhs) ⇒ Object Also known as: xor
Integer XOR.
499 500 501 |
# File 'lib/llvm/core/value.rb', line 499 def ^(rhs) self.class.from_ptr(C.const_xor(self, rhs)) end |
#ashr(bits) ⇒ Object
Arithmatic shift right.
520 521 522 |
# File 'lib/llvm/core/value.rb', line 520 def ashr(bits) self.class.from_ptr(C.const_a_shr(self, bits)) 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
536 537 538 |
# File 'lib/llvm/core/value.rb', line 536 def icmp(pred, rhs) self.class.from_ptr(C.const_i_cmp(pred, self, rhs)) end |
#int_to_ptr(type) ⇒ Object
Conversion to pointer.
541 542 543 |
# File 'lib/llvm/core/value.rb', line 541 def int_to_ptr(type) ConstantExpr.from_ptr(C.const_int_to_ptr(self, type)) end |
#nsw_add(rhs) ⇒ Object
“No signed wrap” addition.
413 414 415 |
# File 'lib/llvm/core/value.rb', line 413 def nsw_add(rhs) self.class.from_ptr(C.const_nsw_add(self, rhs)) end |
#nsw_mul(rhs) ⇒ Object
“No signed wrap” multiplication.
447 448 449 |
# File 'lib/llvm/core/value.rb', line 447 def nsw_mul(rhs) self.class.from_ptr(C.const_nsw_mul(self, rhs)) end |
#nsw_neg ⇒ Object
“No signed wrap” negation.
396 397 398 |
# File 'lib/llvm/core/value.rb', line 396 def nsw_neg self.class.from_ptr(C.const_nsw_neg(self)) end |
#nsw_sub(rhs) ⇒ Object
“No signed wrap” subtraction.
430 431 432 |
# File 'lib/llvm/core/value.rb', line 430 def nsw_sub(rhs) self.class.from_ptr(C.const_nsw_sub(self, rhs)) end |
#nuw_add(rhs) ⇒ Object
“No unsigned wrap” addition.
418 419 420 |
# File 'lib/llvm/core/value.rb', line 418 def nuw_add(rhs) self.class.from_ptr(C.const_nuw_add(self, rhs)) end |
#nuw_mul(rhs) ⇒ Object
“No unsigned wrap” multiplication.
452 453 454 |
# File 'lib/llvm/core/value.rb', line 452 def nuw_mul(rhs) self.class.from_ptr(C.const_nuw_mul(self, rhs)) end |
#nuw_neg ⇒ Object
“No unsigned wrap” negation.
401 402 403 |
# File 'lib/llvm/core/value.rb', line 401 def nuw_neg self.class.from_ptr(C.const_nuw_neg(self)) end |
#nuw_sub(rhs) ⇒ Object
“No unsigned wrap” subtraction.
435 436 437 |
# File 'lib/llvm/core/value.rb', line 435 def nuw_sub(rhs) self.class.from_ptr(C.const_nuw_sub(self, rhs)) end |
#rem(rhs) ⇒ Object
Signed remainder.
472 473 474 |
# File 'lib/llvm/core/value.rb', line 472 def rem(rhs) self.class.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))
561 562 563 |
# File 'lib/llvm/core/value.rb', line 561 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))
574 575 576 |
# File 'lib/llvm/core/value.rb', line 574 def to_f(type) type.from_f(to_i.to_f) end |
#to_i(signed = true) ⇒ Object
578 579 580 581 582 583 584 |
# File 'lib/llvm/core/value.rb', line 578 def to_i(signed = true) if signed C.const_int_get_sext_value(self) else C.const_int_get_zext_value(self) end end |
#to_si ⇒ Object
549 550 551 |
# File 'lib/llvm/core/value.rb', line 549 def to_si to_i(true) end |
#to_ui ⇒ Object
545 546 547 |
# File 'lib/llvm/core/value.rb', line 545 def to_ui to_i(false) end |
#trunc(type) ⇒ Object
constant trunc was: self.class.from_ptr(C.const_trunc(self, type))
568 569 570 |
# File 'lib/llvm/core/value.rb', line 568 def trunc(type) type.from_i(to_i) end |
#udiv(rhs) ⇒ Object
Unsigned division.
457 458 459 |
# File 'lib/llvm/core/value.rb', line 457 def udiv(rhs) self.class.from_i(to_ui / rhs.to_ui, false) end |
#urem(rhs) ⇒ Object
Unsigned remainder.
467 468 469 |
# File 'lib/llvm/core/value.rb', line 467 def urem(rhs) self.class.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))
555 556 557 |
# File 'lib/llvm/core/value.rb', line 555 def zext(type) type.from_i(to_ui) end |
#|(rhs) ⇒ Object Also known as: or
Integer OR.
492 493 494 |
# File 'lib/llvm/core/value.rb', line 492 def |(rhs) self.class.from_i(to_i | rhs.to_i) end |