Class: LLVM::ConstantInt

Inherits:
Constant show all
Defined in:
lib/llvm/core/value.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Constant

#bitcast_to, #gep, null, null_ptr, #ptr_to_int, undef

Methods inherited from User

#operands

Methods inherited from Value

#add_attribute, #allocated_type, #constant?, #dump, from_ptr, from_ptr_kind, #kind, #name, #name=, #null?, #remove_attribute, to_ptr, #to_s, type, #type, #undefined?

Methods included from PointerIdentity

#==, #eql?, #hash, #to_ptr

Class Method Details

.all_onesObject



357
358
359
# File 'lib/llvm/core/value.rb', line 357

def self.all_ones
  from_ptr(C.const_all_ones(type))
end

.from_i(n, signed = true) ⇒ Object

Creates a ConstantInt from an integer.



362
363
364
# File 'lib/llvm/core/value.rb', line 362

def self.from_i(n, signed = true)
  from_ptr(C.const_int(type, n, signed ? 1 : 0))
end

.parse(str, radix = 10) ⇒ Object



366
367
368
# File 'lib/llvm/core/value.rb', line 366

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.



466
467
468
# File 'lib/llvm/core/value.rb', line 466

def &(rhs)
  self.class.from_ptr(C.const_and(self, rhs))
end

#*(rhs) ⇒ Object Also known as: mul

Multiplication.



422
423
424
# File 'lib/llvm/core/value.rb', line 422

def *(rhs)
  self.class.from_ptr(C.const_mul(self, rhs))
end

#+(rhs) ⇒ Object Also known as: add

Addition.



388
389
390
# File 'lib/llvm/core/value.rb', line 388

def +(rhs)
  self.class.from_ptr(C.const_add(self, rhs))
end

#-(rhs) ⇒ Object Also known as: sub

Subtraction.



405
406
407
# File 'lib/llvm/core/value.rb', line 405

def -(rhs)
  self.class.from_ptr(C.const_sub(self, rhs))
end

#-@Object Also known as: neg

Negation.



371
372
373
# File 'lib/llvm/core/value.rb', line 371

def -@
  self.class.from_ptr(C.const_neg(self))
end

#/(rhs) ⇒ Object

Signed division.



444
445
446
# File 'lib/llvm/core/value.rb', line 444

def /(rhs)
  raise "constant sdiv removed in LLVM 15"
end

#<<(bits) ⇒ Object Also known as: shl

Shift left.



487
488
489
# File 'lib/llvm/core/value.rb', line 487

def <<(bits)
  self.class.from_ptr(C.const_shl(self, bits))
end

#>>(bits) ⇒ Object Also known as: shr

Shift right.



494
495
496
# File 'lib/llvm/core/value.rb', line 494

def >>(bits)
  self.class.from_ptr(C.const_l_shr(self, bits))
end

#^(rhs) ⇒ Object Also known as: xor

Integer XOR.



480
481
482
# File 'lib/llvm/core/value.rb', line 480

def ^(rhs)
  self.class.from_ptr(C.const_xor(self, rhs))
end

#ashr(bits) ⇒ Object

Arithmatic shift right.



501
502
503
# File 'lib/llvm/core/value.rb', line 501

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


517
518
519
# File 'lib/llvm/core/value.rb', line 517

def icmp(pred, rhs)
  self.class.from_ptr(C.const_i_cmp(pred, self, rhs))
end

#int_to_ptr(type) ⇒ Object

Conversion to pointer.



522
523
524
# File 'lib/llvm/core/value.rb', line 522

def int_to_ptr(type)
  ConstantExpr.from_ptr(C.const_int_to_ptr(self, type))
end

#nsw_add(rhs) ⇒ Object

“No signed wrap” addition.



395
396
397
# File 'lib/llvm/core/value.rb', line 395

def nsw_add(rhs)
  self.class.from_ptr(C.const_nsw_add(self, rhs))
end

#nsw_mul(rhs) ⇒ Object

“No signed wrap” multiplication.



429
430
431
# File 'lib/llvm/core/value.rb', line 429

def nsw_mul(rhs)
  self.class.from_ptr(C.const_nsw_mul(self, rhs))
end

#nsw_negObject

“No signed wrap” negation.



378
379
380
# File 'lib/llvm/core/value.rb', line 378

def nsw_neg
  self.class.from_ptr(C.const_nsw_neg(self))
end

#nsw_sub(rhs) ⇒ Object

“No signed wrap” subtraction.



412
413
414
# File 'lib/llvm/core/value.rb', line 412

def nsw_sub(rhs)
  self.class.from_ptr(C.const_nsw_sub(self, rhs))
end

#nuw_add(rhs) ⇒ Object

“No unsigned wrap” addition.



400
401
402
# File 'lib/llvm/core/value.rb', line 400

def nuw_add(rhs)
  self.class.from_ptr(C.const_nuw_add(self, rhs))
end

#nuw_mul(rhs) ⇒ Object

“No unsigned wrap” multiplication.



434
435
436
# File 'lib/llvm/core/value.rb', line 434

def nuw_mul(rhs)
  self.class.from_ptr(C.const_nuw_mul(self, rhs))
end

#nuw_negObject

“No unsigned wrap” negation.



383
384
385
# File 'lib/llvm/core/value.rb', line 383

def nuw_neg
  self.class.from_ptr(C.const_nuw_neg(self))
end

#nuw_sub(rhs) ⇒ Object

“No unsigned wrap” subtraction.



417
418
419
# File 'lib/llvm/core/value.rb', line 417

def nuw_sub(rhs)
  self.class.from_ptr(C.const_nuw_sub(self, rhs))
end

#rem(rhs) ⇒ Object

Signed remainder.



454
455
456
# File 'lib/llvm/core/value.rb', line 454

def rem(rhs)
  raise "constant srem removed in LLVM 15"
end

#sext(type) ⇒ Object Also known as: ext

constant sext



532
533
534
# File 'lib/llvm/core/value.rb', line 532

def sext(type)
  self.class.from_ptr(C.const_s_ext(self, type))
end

#to_f(type) ⇒ Object

LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType);



543
544
545
# File 'lib/llvm/core/value.rb', line 543

def to_f(type)
  self.class.from_ptr(C.const_si_to_fp(self, type))
end

#trunc(type) ⇒ Object

constant trunc



538
539
540
# File 'lib/llvm/core/value.rb', line 538

def trunc(type)
  self.class.from_ptr(C.const_trunc(self, type))
end

#udiv(rhs) ⇒ Object

Unsigned division.



439
440
441
# File 'lib/llvm/core/value.rb', line 439

def udiv(rhs)
  raise "constant udiv removed in LLVM 15"
end

#urem(rhs) ⇒ Object

Unsigned remainder.



449
450
451
# File 'lib/llvm/core/value.rb', line 449

def urem(rhs)
  raise "constant urem removed in LLVM 15"
end

#zext(type) ⇒ Object

constant zext



527
528
529
# File 'lib/llvm/core/value.rb', line 527

def zext(type)
  self.class.from_ptr(C.const_z_ext(self, type))
end

#|(rhs) ⇒ Object Also known as: or

Integer OR.



473
474
475
# File 'lib/llvm/core/value.rb', line 473

def |(rhs)
  self.class.from_ptr(C.const_or(self, rhs))
end

#~@Object

Boolean negation.



459
460
461
# File 'lib/llvm/core/value.rb', line 459

def ~@
  self.class.from_ptr(C.const_not(self))
end