Class: RLTK::CG::Builder

Inherits:
Object
  • Object
show all
Includes:
BindingClass
Defined in:
lib/rltk/cg/builder.rb

Overview

This class is responsible for adding Instructions to BasicBlocks.

Direct Known Subclasses

Contractor

Constant Summary collapse

CLASS_FINALIZER =

The Proc object called by the garbage collector to free resources used by LLVM.

Proc.new { |id| Bindings.dispose_builder(ptr) if ptr = ObjectSpace._id2ref(id).ptr }

Instance Attribute Summary

Attributes included from BindingClass

#ptr

Class Method Summary collapse

Instance Method Summary collapse

Methods included from BindingClass

#==

Constructor Details

#initialize(bb = nil, *block_args, &block) ⇒ Builder

Creates a new Builder object, optionally positioning it at the end of block. If a block is given it will be executed as if it was passed to the #build method.

Parameters:

  • bb (BasicBlock, nil) (defaults to: nil)

    BasicBlock used to position the Builder.

  • block_args (Array<Object>)

    Arguments to be passed to block.

  • block (Proc, nil)

    Block to execute in the context of this Builder.



39
40
41
42
43
44
45
46
47
# File 'lib/rltk/cg/builder.rb', line 39

def initialize(bb = nil, *block_args, &block)
	@ptr = Bindings.create_builder

	# Define a finalizer to free the memory used by LLVM for this
	# builder.
	ObjectSpace.define_finalizer(self, CLASS_FINALIZER)

	if block then self.build(bb, *block_args, &block) elsif bb then position_at_end(bb) end
end

Class Method Details

.globalBuilder

Returns A global Builder object.

Returns:

  • (Builder)

    A global Builder object.



28
29
30
# File 'lib/rltk/cg/builder.rb', line 28

def self.global
	@@global_builder ||= Builder.new
end

Instance Method Details

#add(lhs, rhs, name = '') ⇒ AddInst

Returns The integer sum of the two operands.

Parameters:

  • lhs (Value)

    Integer or vector of integers.

  • rhs (Value)

    Integer or vector of integers.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (AddInst)

    The integer sum of the two operands.



323
324
325
# File 'lib/rltk/cg/builder.rb', line 323

def add(lhs, rhs, name = '')
	AddInst.new(Bindings.build_add(@ptr, lhs, rhs, name))
end

#addr_space_cast(val, type, name = '') ⇒ AddrSpaceCastInst

Cast a value to a given address space.

Parameters:

  • val (Value)

    Value to cast

  • type (Type)

    Target type

  • name (String) (defaults to: '')

    Name of the result in LLVM IR

Returns:



842
843
844
# File 'lib/rltk/cg/builder.rb', line 842

def addr_space_cast(val, type, name = '')
	AddrSpaceCast.new(Bindings.addr_space_cast(@ptr, val, check_cg_type(type), name))
end

#alloca(type, name = '') ⇒ AllocaInst

Stack allocation.

Parameters:

  • type (Type)

    Type or value whose type should be allocad.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (AllocaInst)

    A pointer to the allocad bytes.



701
702
703
# File 'lib/rltk/cg/builder.rb', line 701

def alloca(type, name = '')
	AllocaInst.new(Bindings.build_alloca(@ptr, check_cg_type(type), name))
end

#and(lhs, rhs, name = '') ⇒ AndInst

Returns An integer instruction.

Parameters:

  • lhs (Value)

    Integer or vector of integers.

  • rhs (Value)

    Integer or vector of integers.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (AndInst)

    An integer instruction.



638
639
640
# File 'lib/rltk/cg/builder.rb', line 638

def and(lhs, rhs, name = '')
	AndInst.new(Bindings.build_and(@ptr, lhs, rhs, name))
end

#array_alloca(type, size, name = '') ⇒ ArrayAllocaInst

Stack array allocation.

Parameters:

  • type (Type)

    Type or value whose type should be allocad.

  • size (Value)

    Unsigned integer representing size of the array.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:



712
713
714
# File 'lib/rltk/cg/builder.rb', line 712

def array_alloca(type, size, name = '')
	ArrayAllocaInst.new(Bindings.build_array_alloca(@ptr, check_cg_type(type), size, name))
end

#array_malloc(type, size, name = '') ⇒ ArrayMallocInst

Heap array allocation.

Parameters:

  • type (Type)

    Type or value whose type will be the element type of the malloced array.

  • size (Value)

    Unsigned integer representing size of the array.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:



691
692
693
# File 'lib/rltk/cg/builder.rb', line 691

def array_malloc(type, size, name = '')
	ArrayMallocInst.new(Bindings.build_array_malloc(@ptr, check_cg_type(type), size, name))
end

#ashr(lhs, rhs, name = '') ⇒ ARightShiftInst

Arithmetic (sign extended) shift right.

Parameters:

  • lhs (Value)

    Integer or vector of integers.

  • rhs (Value)

    Integer or vector of integers.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:



618
619
620
# File 'lib/rltk/cg/builder.rb', line 618

def ashr(lhs, rhs, name = '')
	ARightShiftInst.new(Bindings.build_a_shr(@ptr, lhs, rhs, name))
end

#atomic_rmw(op, addr, val, ordering, single_thread) ⇒ AtomicRMWInst

Create an atomic read/modify/write instruction.

Parameters:

  • op (Symbol from _enum_atomic_rmw_bin_op_)

    Operation to perform

  • addr (OpaqueValue)

    Address to modify

  • val (OpaqueValue)

    Value to test

  • ordering (Symbol from _enum_atomic_ordering_)

    Memory ordering constraints

  • single_thread (Boolean)

    Synchronize with single thread or all threads

Returns:

See Also:



827
828
829
# File 'lib/rltk/cg/builder.rb', line 827

def atomic_rmw(op, addr, val, ordering, single_thread)
	AtomicRMWInst.new(Bindings.build_atomic_rmw(@ptr, op, addr, val, ordering, single_thread.to_i))
end

#bitcast(val, type, name = '') ⇒ BitCastInst

Cast a value to the given type without changing any bits.

Parameters:

  • val (Value)

    Value to cast

  • type (Type)

    Target type

  • name (String) (defaults to: '')

    Name of the result in LLVM IR

Returns:



853
854
855
# File 'lib/rltk/cg/builder.rb', line 853

def bitcast(val, type, name = '')
	BitCastInst.new(Bindings.build_bit_cast(@ptr, val, check_cg_type(type), name))
end

#branch(block) ⇒ BranchInst Also known as: br

Unconditional branching.

Parameters:

Returns:



164
165
166
# File 'lib/rltk/cg/builder.rb', line 164

def branch(block)
	BranchInst.new(Bindings.build_br(@ptr, block))
end

#build(bb = nil, *block_args, &block) ⇒ Object

Executes a given block inside the context of this builder. If the bb parameter isn’t nill, the Builder will be positioned at the end of the specified BasicBlock.

Parameters:

  • bb (BasicBlock) (defaults to: nil)

    Optional BasicBlock used to position the Builder.

  • block_args (Array<Object>)

    Arguments to be passed to block.

  • block (Proc)

    Block to execute in the context of this Builder.

Returns:

  • (Object)

    The result of evaluating block in the context of this Builder.



58
59
60
61
# File 'lib/rltk/cg/builder.rb', line 58

def build(bb = nil, *block_args, &block)
	self.position_at_end(bb) if bb
	self.instance_exec(*block_args, &block)
end

#build_inst(inst, *args) ⇒ Instruction Also known as: <<

Build an instruction.

Parameters:

  • inst (Symbol)

    Name of instruction building method.

  • args (Array<Object>)

    Arguments to be passed to building method.

Returns:



69
70
71
# File 'lib/rltk/cg/builder.rb', line 69

def build_inst(inst, *args)
	self.send(inst, *args)
end

#call(fun, *args) ⇒ CallInst

Build an instruction that performs a function call.

Parameters:

  • fun (Function)

    Function to call.

  • args (Array<Value>)

    Arguments to pass to function.

Returns:



175
176
177
178
179
180
181
182
# File 'lib/rltk/cg/builder.rb', line 175

def call(fun, *args)
	name = if args.last.is_a?(String) then args.pop else '' end

	args_ptr = FFI::MemoryPointer.new(:pointer, args.length)
	args_ptr.write_array_of_pointer(args)

	CallInst.new(Bindings.build_call(@ptr, fun, args_ptr, args.length, name))
end

#cond_branch(val, iftrue, iffalse) ⇒ CondBranchInst Also known as: cond

Conditional branching.

Parameters:

  • val (Value)

    Condition value.

  • iffalse (BasicBlock)

    Where to jump if condition is true.

  • iftrue (BasicBlock)

    Where to jump if condition is false.

Returns:



191
192
193
# File 'lib/rltk/cg/builder.rb', line 191

def cond_branch(val, iftrue, iffalse)
	CondBranchInst.new(Bindings.build_cond_br(@ptr, val, iftrue, iffalse))
end

#current_blockBasicBlock Also known as: insertion_block

Returns BasicBlock the Builder is currently positioned on.

Returns:

  • (BasicBlock)

    BasicBlock the Builder is currently positioned on.



116
117
118
# File 'lib/rltk/cg/builder.rb', line 116

def current_block
	BasicBlock.new(Bindings.get_insert_block(@ptr))
end

#exact_sdiv(lhs, rhs, name = '') ⇒ SDivInst

Signed exact integer division.

Parameters:

  • lhs (Value)

    Integer or vector of integers.

  • rhs (Value)

    Integer or vector of integers.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (SDivInst)

    The integer quotient of the two operands.



471
472
473
# File 'lib/rltk/cg/builder.rb', line 471

def exact_sdiv(lhs, rhs, name = '')
	ExactSDivInst.new(Bindings.build_exact_s_div(@ptr, lhs, rhs, name))
end

#extract_element(vector, index, name = '') ⇒ ExtractElementInst

Extract an element from a vector.

Parameters:

  • vector (Value)

    Vector from which to extract a value.

  • index (Value)

    Index of the element to extract, an unsigned integer.

  • name (String) (defaults to: '')

    Value of the result in LLVM IR.

Returns:



203
204
205
# File 'lib/rltk/cg/builder.rb', line 203

def extract_element(vector, index, name = '')
	ExtractElementInst.new(Bindings.build_extract_element(@ptr, vector, index, name))
end

#extract_value(aggregate, index, name = '') ⇒ ExtractValueInst

Extract the value of a member field from an aggregate value.

Parameters:

  • aggregate (Value)

    An aggregate value.

  • index (Value)

    Index of the member to extract.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:



214
215
216
# File 'lib/rltk/cg/builder.rb', line 214

def extract_value(aggregate, index, name = '')
	ExtractValueInst.new(Bindings.build_extract_value(@ptr, aggregate, index, name))
end

#fadd(lhs, rhs, name = '') ⇒ FAddInst

Returns The floating point sum of the two operands.

Parameters:

  • lhs (Value)

    Floating point or vector of floating points.

  • rhs (Value)

    Floating point or vector of floating points.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (FAddInst)

    The floating point sum of the two operands.



332
333
334
# File 'lib/rltk/cg/builder.rb', line 332

def fadd(lhs, rhs, name = '')
	FAddInst.new(Bindings.build_f_add(@ptr, lhs, rhs, name))
end

#fdiv(lhs, rhs, name = '') ⇒ FDivInst

Returns The floating point quotient of the two operands.

Parameters:

  • lhs (Value)

    Floating point or vector of floating points.

  • rhs (Value)

    Floating point or vector of floating points.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (FDivInst)

    The floating point quotient of the two operands.



449
450
451
# File 'lib/rltk/cg/builder.rb', line 449

def fdiv(lhs, rhs, name = '')
	FDivInst.new(Bindings.build_f_div(@ptr, lhs, rhs, name))
end

#floating_point_cast(val, type, name = '') ⇒ FPCastInst Also known as: fp_cast

Returns A value of the target type.

Parameters:

  • val (Value)

    Value to cast.

  • type (Type)

    Target type.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:



862
863
864
# File 'lib/rltk/cg/builder.rb', line 862

def floating_point_cast(val, type, name = '')
	FPCastInst.new(Bindings.build_fp_cast(@ptr, val, check_cg_type(type), name))
end

#floating_point_extend(val, type, name = '') ⇒ FPExtendInst Also known as: fp_ext, fp_extend

Extend a floating point value.

Parameters:

  • val (Value)

    Floating point or vector of floating point.

  • type (Type)

    Floating point or vector of floating point type of greater size than val’s type.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:



874
875
876
# File 'lib/rltk/cg/builder.rb', line 874

def floating_point_extend(val, type, name = '')
	FPExtendInst.new(Bindings.build_fp_ext(@ptr, val, check_cg_type(type), name))
end

#floating_point_to_signed_int(val, type, name = '') ⇒ FPToSIInst Also known as: fp2si

Convert a floating point to a signed integer.

Parameters:

  • val (Value)

    Floating point or vector of floating points to convert.

  • type (Type)

    Integer or vector of integer target type.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:



887
888
889
# File 'lib/rltk/cg/builder.rb', line 887

def floating_point_to_signed_int(val, type, name = '')
	FPToSIInst.new(Bindings.build_fp_to_si(@ptr, val, check_cg_type(type), name))
end

#floating_point_to_unsigned_int(val, type, name = '') ⇒ FPToSIInst Also known as: fp2ui

Convert a floating point to an unsigned integer.

Parameters:

  • val (Value)

    Floating point or vector of floating points to convert.

  • type (Type)

    Integer or vector of integer target type.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:



899
900
901
# File 'lib/rltk/cg/builder.rb', line 899

def floating_point_to_unsigned_int(val, type, name = '')
	FPToUIInst.new(Bindings.build_fp_to_ui(@ptr, val, check_cg_type(type), name))
end

#floating_point_truncate(val, type, name = '') ⇒ LLVM::Instruction Also known as: fp_trunc, fp_truncate

Truncate a floating point value.

Parameters:

  • val (Value)

    Floating point or vector of floating point.

  • type (Type)

    Floating point or vector of floating point type of lesser size than val’s type.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (LLVM::Instruction)

    The truncated value



911
912
913
# File 'lib/rltk/cg/builder.rb', line 911

def floating_point_truncate(val, type, name = '')
	FPTruncInst.new(Bindings.build_fp_trunc(@ptr, val, check_cg_type(type), name))
end

#fmul(lhs, rhs, name = '') ⇒ FMulInst

Returns The floating point product of the two operands.

Parameters:

  • lhs (Value)

    Floating point or vector of floating points.

  • rhs (Value)

    Floating point or vector of floating points.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (FMulInst)

    The floating point product of the two operands.



416
417
418
# File 'lib/rltk/cg/builder.rb', line 416

def fmul(lhs, rhs, name = '')
	FMulInst.new(Bindings.build_f_mul(@ptr, lhs, rhs, name))
end

#fneg(val, name = '') ⇒ NegInst

Floating point negation. Implemented as a shortcut to the equivalent sub instruction.

Parameters:

  • val (Value)

    Floating point or vector of floating points.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (NegInst)

    The negated operand.



539
540
541
# File 'lib/rltk/cg/builder.rb', line 539

def fneg(val, name = '')
	FNegInst.new(Bindings.build_f_neg(@ptr, val, name))
end

#fp_comparison(pred, lhs, rhs, name = '') ⇒ FCmpInst Also known as: fcmp

Builds an fcmp instruction. Compares lhs to rhs as reals using the given symbol predicate.

Parameters:

  • pred (Symbol)

    A real predicate.

  • lhs (Value)

    Left hand side of the comparison, of floating point type.

  • rhs (Value)

    Right hand side of the comparison, of the same type as lhs.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (FCmpInst)

    A Boolean represented as an Int1.

See Also:



1091
1092
1093
# File 'lib/rltk/cg/builder.rb', line 1091

def fp_comparison(pred, lhs, rhs, name = '')
	FCmpInst.new(Bindings.build_f_cmp(@ptr, pred, lhs, rhs, name))
end

#free(ptr) ⇒ FreeInst

Returns The result of the free instruction.

Parameters:

  • ptr (LLVM::Value)

    The pointer to be freed.

Returns:

  • (FreeInst)

    The result of the free instruction.



719
720
721
# File 'lib/rltk/cg/builder.rb', line 719

def free(ptr)
	FreeInst.new(Bindings.build_free(@ptr, ptr))
end

#frem(lhs, rhs, name = '') ⇒ FRemInst

Returns The floating point remainder.

Parameters:

  • lhs (Value)

    Floating point or vector of floating points.

  • rhs (Value)

    Floating point or vector of floating points.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (FRemInst)

    The floating point remainder.



493
494
495
# File 'lib/rltk/cg/builder.rb', line 493

def frem(lhs, rhs, name = '')
	FRemInst.new(Bindings.build_f_rem(@ptr, lhs, rhs, name))
end

#fsub(lhs, rhs, name = '') ⇒ FSubInst

Returns The floating point difference of the two operands.

Parameters:

  • lhs (Value)

    Floating point or vector of floating points.

  • rhs (Value)

    Floating point or vector of floating points.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (FSubInst)

    The floating point difference of the two operands.



374
375
376
# File 'lib/rltk/cg/builder.rb', line 374

def fsub(lhs, rhs, name = '')
	FSubInst.new(Bindings.build_f_sub(@ptr, lhs, rhs, name))
end

#get_element_ptr(ptr, indices, name = '') ⇒ GetElementPtrInst Also known as: gep

Obtain a pointer to the element at the given indices.

Parameters:

  • ptr (Value)

    Pointer to an aggregate value

  • indices (Array<Value>)

    Ruby array of Value representing indices into the aggregate.

  • name (String) (defaults to: '')

    The name of the result in LLVM IR.

Returns:



751
752
753
754
755
756
757
758
# File 'lib/rltk/cg/builder.rb', line 751

def get_element_ptr(ptr, indices, name = '')
	check_array_type(indices, Value, 'indices')

	indices_ptr = FFI::MemoryPointer.new(:pointer, indices.length)
	indices_ptr.write_array_of_pointer(indices)

	GetElementPtrInst.new(Bindings.build_gep(@ptr, ptr, indices_ptr, indices.length, name))
end

#get_element_ptr_in_bounds(ptr, indices, name = '') ⇒ InBoundsGEPInst Also known as: inbounds_gep

Builds a in-bounds getelementptr instruction. If the indices are outside the allocated pointer the value is undefined.

Parameters:

  • ptr (Value)

    Pointer to an aggregate value

  • indices (Array<Value>)

    Ruby array of Value representing indices into the aggregate.

  • name (String) (defaults to: '')

    The name of the result in LLVM IR.

Returns:



770
771
772
773
774
775
776
777
# File 'lib/rltk/cg/builder.rb', line 770

def get_element_ptr_in_bounds(ptr, indices, name = '')
	check_array_type(indices, Value, 'indices')

	indices_ptr = FFI::MemoryPointer.new(:pointer, indices.length)
	indices_ptr.write_array_of_pointer(indices)

	InBoundsGEPInst.new(Bindings.build_in_bounds_gep(@ptr, ptr, indices_ptr, indices.length, name))
end

#gloabl_string_pointer(string, name = '') ⇒ GlobalStringPtrInst

Creates a pointer to a global string initialized to a given value.

Parameters:

  • string (String)

    String used by the initializer

  • name (String) (defaults to: '')

    Name of the result in LLVM IR

Returns:



808
809
810
# File 'lib/rltk/cg/builder.rb', line 808

def gloabl_string_pointer(string, name = '')
	GlobalStringPtrInst.new(Bindings.build_global_string_ptr(@ptr, string, name))
end

#global_string(string, name = '') ⇒ GlobalStringInst

Creates a global string initialized to a given value.

Parameters:

  • string (String)

    String used by the initialize.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:



798
799
800
# File 'lib/rltk/cg/builder.rb', line 798

def global_string(string, name = '')
	GlobalStringInst.new(Bindings.build_global_string(@ptr, string, name))
end

#insert_element(vector, element, index, name = '') ⇒ InsertElementInst

Insert an element into a vector.

Parameters:

  • vector (Value)

    Vector into which to insert the element.

  • element (Value)

    Element to be inserted into the vector.

  • index (Value)

    Index at which to insert the element.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:



226
227
228
# File 'lib/rltk/cg/builder.rb', line 226

def insert_element(vector, element, index, name = '')
	InsertElementInst.new(Bindings.build_insert_element(@ptr, vector, element, index, name))
end

#insert_value(aggregate, val, index, name = '') ⇒ InsertValueInst

Insert a value into an aggregate value’s member field.

Parameters:

  • aggregate (Value)

    An aggregate value.

  • val (Value)

    Value to insert into aggregate.

  • index (Value)

    Index at which to insert the value.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:



238
239
240
# File 'lib/rltk/cg/builder.rb', line 238

def insert_value(aggregate, val, index, name = '')
	InsertValueInst.new(Bindings.build_insert_value(@ptr, aggregate, val, index, name))
end

#int_comparison(pred, lhs, rhs, name = '') ⇒ IntCmpInst Also known as: icmp

Builds an icmp instruction. Compares lhs to rhs using the given symbol predicate.

Parameters:

  • pred (Symbol)

    An integer predicate.

  • lhs (Value)

    Left hand side of the comparison, of integer or pointer type.

  • rhs (Value)

    Right hand side of the comparison, of the same type as lhs.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

See Also:



1074
1075
1076
# File 'lib/rltk/cg/builder.rb', line 1074

def int_comparison(pred, lhs, rhs, name = '')
	IntCmpInst.new(Bindings.build_i_cmp(@ptr, pred, lhs, rhs, name))
end

#int_to_ptr(val, type, name = '') ⇒ IntToPtrInst Also known as: int2ptr

Cast an int to a pointer.

Parameters:

  • val (Value)

    An integer value.

  • type (Type)

    A pointer type.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (IntToPtrInst)

    A pointer of the given type and the address held in val.



924
925
926
# File 'lib/rltk/cg/builder.rb', line 924

def int_to_ptr(val, type, name = '')
	IntToPtrInst.new(Bindings.build_int_to_ptr(@ptr, val, check_cg_type(type), name))
end

#integer_cast(val, type, name = '') ⇒ IntCastInst Also known as: int_cast

Parameters:

  • val (Value)

    An integer value.

  • type (Type)

    Integer or vector of integer target type.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:



934
935
936
# File 'lib/rltk/cg/builder.rb', line 934

def integer_cast(val, type, name = '')
	IntCastInst.new(Bindings.build_int_cast(@ptr, val, check_cg_type(type), name))
end

#invoke(fun, args, normal, exception, name = '') ⇒ InvokeInst

Invoke a function which may potentially unwind.

Parameters:

  • fun (Function)

    Function to invoke.

  • args (Array<Value>)

    Arguments passed to fun.

  • normal (BasicBlock)

    Where to jump if fun does not unwind.

  • exception (BasicBlock)

    Where to jump if fun unwinds.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (InvokeInst)

    The value returned by fun, unless an unwind instruction occurs.



251
252
253
# File 'lib/rltk/cg/builder.rb', line 251

def invoke(fun, args, normal, exception, name = '')
	InvokeInst.new(Bindings.build_invoke(@ptr, fun, args, args.length, normal, exception, name))
end

#is_not_null(val, name = '') ⇒ LLVM::Instruction

Check if a value is not null.

Parameters:

  • val (Value)

    Value to check.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (LLVM::Instruction)

    A Boolean represented as an Int1.



1113
1114
1115
# File 'lib/rltk/cg/builder.rb', line 1113

def is_not_null(val, name = '')
	IsNotNullInst.new(Builder.build_is_not_null(@ptr, val, name))
end

#is_null(val, name = '') ⇒ LLVM::Instruction

Check if a value is null.

Parameters:

  • val (Value)

    Value to check.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (LLVM::Instruction)

    A Boolean represented as an Int1.



1123
1124
1125
# File 'lib/rltk/cg/builder.rb', line 1123

def is_null(val, name = '')
	IsNullInst.new(Bindings.build_is_null(@ptr, val, name))
end

#load(ptr, name = '') ⇒ LoadInst

Load the value of a given pointer.

Parameters:

  • ptr (Value)

    Pointer to be loaded.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (LoadInst)

    The result of the load operation. Represents a value of the pointer’s type.



729
730
731
# File 'lib/rltk/cg/builder.rb', line 729

def load(ptr, name = '')
	LoadInst.new(Bindings.build_load(@ptr, ptr, name))
end

#lshr(lhs, rhs, name = '') ⇒ ARightShiftInst

Logical (zero fill) shift right.

Parameters:

  • lhs (Value)

    Integer or vector of integers.

  • rhs (Value)

    Integer or vector of integers.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:



629
630
631
# File 'lib/rltk/cg/builder.rb', line 629

def lshr(lhs, rhs, name = '')
	LRightShiftInst.new(Bindings.build_l_shr(@ptr, lhs, rhs, name))
end

#malloc(type, name = '') ⇒ MallocInst

Heap allocation.

Parameters:

  • type (Type)

    Type or value whose type should be malloced.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (MallocInst)

    A pointer to the malloced bytes.



680
681
682
# File 'lib/rltk/cg/builder.rb', line 680

def malloc(type, name = '')
	MallocInst.new(Bindings.build_malloc(@ptr, check_type(type), name))
end

#mul(lhs, rhs, name = '') ⇒ MulInst

Returns The integer product of the two operands.

Parameters:

  • lhs (Value)

    Integer or vector of integers.

  • rhs (Value)

    Integer or vector of integers.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (MulInst)

    The integer product of the two operands.



407
408
409
# File 'lib/rltk/cg/builder.rb', line 407

def mul(lhs, rhs, name = '')
	MulInst.new(Bindings.build_mul(@ptr, lhs, rhs, name))
end

#neg(val, name = '') ⇒ NegInst

Integer negation. Implemented as a shortcut to the equivalent sub instruction.

Parameters:

  • val (Value)

    Integer or vector of integers.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (NegInst)

    The negated operand.



528
529
530
# File 'lib/rltk/cg/builder.rb', line 528

def neg(val, name = '')
	NegInst.new(Bindings.build_neg(@ptr, val, name))
end

#not(val, name = '') ⇒ NotInst

Boolean negation.

Parameters:

  • val (Value)

    Integer or vector of integers.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (NotInst)

    An integer instruction.



666
667
668
# File 'lib/rltk/cg/builder.rb', line 666

def not(val, name = '')
	NotInst.new(Bindings.build_not(@ptr, val, name))
end

#nsw_add(lhs, rhs, name = '') ⇒ NSWAddInst

No signed wrap addition.

Parameters:

  • lhs (Value)

    Integer or vector of integers.

  • rhs (Value)

    Integer or vector of integers.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (NSWAddInst)

    The integer sum of the two operands.



343
344
345
# File 'lib/rltk/cg/builder.rb', line 343

def nsw_add(lhs, rhs, name = '')
	NSWAddInst.new(Bindings.build_nsw_add(@ptr, lhs, rhs, name))
end

#nsw_mul(lhs, rhs, name = '') ⇒ MulInst

No signed wrap multiplication.

Parameters:

  • lhs (Value)

    Integer or vector of integers.

  • rhs (Value)

    Integer or vector of integers.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (MulInst)

    The integer product of the two operands.



427
428
429
# File 'lib/rltk/cg/builder.rb', line 427

def nsw_mul(lhs, rhs, name = '')
	NSWMulInst.new(Bindings.build_nsw_mul(@ptr, lhs, rhs, name))
end

#nsw_neg(val, name = '') ⇒ NegInst

No signed wrap integer negation. Implemented as a shortcut to the equivalent sub instruction.

Parameters:

  • val (Value)

    Integer or vector of integers.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (NegInst)

    The negated operand.



550
551
552
# File 'lib/rltk/cg/builder.rb', line 550

def nsw_neg(val, name = '')
	NSWNegInst.new(Bindings.build_nsw_neg(@ptr, val, name))
end

#nsw_sub(lhs, rhs, name = '') ⇒ SubInst

No signed wrap subtraction.

Parameters:

  • lhs (Value)

    Integer or vector of integers.

  • rhs (Value)

    Integer or vector of integers.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (SubInst)

    The integer difference of the two operands.



385
386
387
# File 'lib/rltk/cg/builder.rb', line 385

def nsw_sub(lhs, rhs, name = '')
	NSWSubInst.new(Bindings.build_nsw_sub(@ptr, lhs, rhs, name))
end

#nuw_add(lhs, rhs, name = '') ⇒ NSWAddInst

No unsigned wrap addition.

Parameters:

  • lhs (Value)

    Integer or vector of integers.

  • rhs (Value)

    Integer or vector of integers.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (NSWAddInst)

    The integer sum of the two operands.



354
355
356
# File 'lib/rltk/cg/builder.rb', line 354

def nuw_add(lhs, rhs, name = '')
	NUWAddInst.new(Bindings.build_nuw_add(@ptr, lhs, rhs, name))
end

#nuw_mul(lhs, rhs, name = '') ⇒ MulInst

No unsigned wrap multiplication.

Parameters:

  • lhs (Value)

    Integer or vector of integers.

  • rhs (Value)

    Integer or vector of integers.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (MulInst)

    The integer product of the two operands.



438
439
440
# File 'lib/rltk/cg/builder.rb', line 438

def nuw_mul(lhs, rhs, name = '')
	NUWMulInst.new(Bindings.build_nuw_mul(@ptr, lhs, rhs, name))
end

#nuw_neg(val, name = '') ⇒ NegInst

No unsigned wrap integer negation. Implemented as a shortcut to the equivalent sub instruction.

Parameters:

  • val (Value)

    Integer or vector of integers.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (NegInst)

    The negated operand.



561
562
563
# File 'lib/rltk/cg/builder.rb', line 561

def nuw_neg(val, name = '')
	NUWNegInst.new(Bindings.build_nuw_neg(@ptr, val, name))
end

#nuw_sub(lhs, rhs, name = '') ⇒ SubInst

No unsigned wrap subtraction.

Parameters:

  • lhs (Value)

    Integer or vector of integers.

  • rhs (Value)

    Integer or vector of integers.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (SubInst)

    The integer difference of the two operands.



396
397
398
# File 'lib/rltk/cg/builder.rb', line 396

def nuw_sub(lhs, rhs, name = '')
	NUWSubInst.new(Bindings.build_nuw_sub(@ptr, lhs, rhs, name))
end

#or(lhs, rhs, name = '') ⇒ OrInst

Returns An integer instruction.

Parameters:

  • lhs (Value)

    Integer or vector of integers.

  • rhs (Value)

    Integer or vector of integers.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (OrInst)

    An integer instruction.



647
648
649
# File 'lib/rltk/cg/builder.rb', line 647

def or(lhs, rhs, name = '')
	OrInst.new(Bindings.build_or(@ptr, lhs, rhs, name))
end

#phi(type, incoming, name = '') ⇒ PhiInst

Build a Phi node of the given type with the given incoming branches.

Parameters:

  • type (Type)

    Specifies the result type.

  • incoming (Hash{BasicBlock => Value})

    A hash mapping basic blocks to a corresponding value. If the phi node is jumped to from a given basic block, the phi instruction takes on its corresponding value.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:



265
266
267
268
269
# File 'lib/rltk/cg/builder.rb', line 265

def phi(type, incoming, name = '')
	PhiInst.new(Bindings.build_phi(@ptr, check_cg_type(type), name)).tap do |phi|
		phi.incoming.add(incoming)
	end
end

#position(bb, instruction) ⇒ Builder

Position the Builder after the given instruction.

Parameters:

Returns:



80
81
82
83
# File 'lib/rltk/cg/builder.rb', line 80

def position(bb, instruction)
	Bindings.position_builder(@ptr, bb, instruction) if check_type(bb, BasicBlock, 'bb')
	self
end

#position_at_end(bb) ⇒ Bulder Also known as: pae, target

Position the Builder at the end of the given BasicBlock.

Parameters:

Returns:

  • (Bulder)

    self



90
91
92
93
# File 'lib/rltk/cg/builder.rb', line 90

def position_at_end(bb)
	Bindings.position_builder_at_end(@ptr, bb) if check_type(bb, BasicBlock, 'bb')
	self
end

#position_before(instruction) ⇒ Builder

Position the Builder before the given Instruction.

Parameters:

Returns:



102
103
104
105
# File 'lib/rltk/cg/builder.rb', line 102

def position_before(instruction)
	Bindings.position_builder_before(@ptr, instruction)
	self
end

#ptr_cast(val, type, name = '') ⇒ PtrCastInst

Parameters:

  • val (Value)

    A pointer value.

  • type (Type)

    A pointer target type.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:



944
945
946
# File 'lib/rltk/cg/builder.rb', line 944

def ptr_cast(val, type, name = '')
	PtrCastInst.new(Bindings.build_pointer_cast(@ptr, val, check_cg_type(type), name))
end

#ptr_diff(lhs, rhs, name = '') ⇒ PtrDiffInst

Calculate the difference between two pointers.

Parameters:

  • lhs (Value)

    A pointer.

  • rhs (Value)

    A pointer.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (PtrDiffInst)

    The integer difference between the two pointers.



1103
1104
1105
# File 'lib/rltk/cg/builder.rb', line 1103

def ptr_diff(lhs, rhs, name = '')
	PtrDiffInst.new(Bindings.build_ptr_diff(lhs, rhs, name))
end

#ptr_to_int(val, type, name = '') ⇒ PtrToIntInst Also known as: ptr2int

Cast a pointer to an int. Useful for pointer arithmetic.

Parameters:

  • val (Value)

    A pointer value.

  • type (Type)

    An integer type.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (PtrToIntInst)

    An integer of the given type representing the pointer’s address.



955
956
957
# File 'lib/rltk/cg/builder.rb', line 955

def ptr_to_int(val, type, name = '')
	PtrToIntInst.new(Bindings.build_ptr_to_int(@ptr, val, check_cg_type(type), name))
end

#ret(val) ⇒ ReturnInst

Parameters:

  • val (Value)

    The Value to return.

Returns:



136
137
138
# File 'lib/rltk/cg/builder.rb', line 136

def ret(val)
	ReturnInst.new(Bindings.build_ret(@ptr, val))
end

#ret_aggregate(*vals) ⇒ RetAggregateInst

Returns:

  • (RetAggregateInst)


146
147
148
149
150
151
152
153
# File 'lib/rltk/cg/builder.rb', line 146

def ret_aggregate(*vals)
	vals = vals.first if vals.length == 1 and vals.first.instance_of?(::Array)

	vals_ptr = FFI::MemoryPointer.new(:pointer, vals.length)
	vals_ptr.write_array_of_pointer(vals)

	ReturnAggregateInst.new(Bindings.build_aggregate_ret(@ptr, vals_ptr, vals.length))
end

#ret_voidRetVoidInst

Returns:

  • (RetVoidInst)


141
142
143
# File 'lib/rltk/cg/builder.rb', line 141

def ret_void
	ReturnVoidInst.new(Bindings.build_ret_void(@ptr))
end

#sdiv(lhs, rhs, name = '') ⇒ SDivInst

Signed integer division.

Parameters:

  • lhs (Value)

    Integer or vector of integers.

  • rhs (Value)

    Integer or vector of integers.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (SDivInst)

    The integer quotient of the two operands.



460
461
462
# File 'lib/rltk/cg/builder.rb', line 460

def sdiv(lhs, rhs, name = '')
	SDivInst.new(Bindings.build_s_div(@ptr, lhs, rhs, name))
end

#select(if_val, then_val, else_val, name = '') ⇒ SelectInst

Return a value based on a condition. This differs from cond in that its operands are values rather than basic blocks. As a consequence, both arguments must be evaluated.

Parameters:

  • if_val (Value)

    An Int1 or a vector of Int1.

  • then_val (Value)

    Value or vector of the same arity as if_val.

  • else_val (Value)

    Value or vector of values of the same arity as if_val, and of the same type as then_val.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (SelectInst)

    An instruction representing either then_val or else_val.



282
283
284
# File 'lib/rltk/cg/builder.rb', line 282

def select(if_val, then_val, else_val, name = '')
	SelectInst.new(Bindings.build_select(@ptr, if_val, then_val, else_val, name))
end

#shift(dir, lhs, rhs, mode = :arithmetic, name = '') ⇒ LeftShiftInst, ...

A wrapper method around the #shift_left and #shift_right methods.

Parameters:

  • dir (:left, :right)

    The direction to shift.

  • lhs (Value)

    Integer or vector of integers.

  • rhs (Value)

    Integer or vector of integers.

  • mode (:arithmetic, :logical) (defaults to: :arithmetic)

    Shift mode for right shifts.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:



579
580
581
582
583
584
# File 'lib/rltk/cg/builder.rb', line 579

def shift(dir, lhs, rhs, mode = :arithmetic, name = '')
	case dir
	when :left	then shift_left(lhs, rhs, name)
	when :right	then shift_right(lhs, rhs, mode, name)
	end
end

#shift_left(lhs, rhs, name = '') ⇒ LeftShiftInst Also known as: shl

Returns An integer instruction.

Parameters:

  • lhs (Value)

    Integer or vector of integers

  • rhs (Value)

    Integer or vector of integers

  • name (String) (defaults to: '')

    Name of the result in LLVM IR

Returns:



591
592
593
# File 'lib/rltk/cg/builder.rb', line 591

def shift_left(lhs, rhs, name = '')
	LeftShiftInst.new(Bindings.build_shl(@ptr, lhs, rhs, name))
end

#shift_right(lhs, rhs, mode = :arithmetic, name = '') ⇒ LeftShiftInst

A wrapper function around #ashr and #lshr.

Parameters:

  • lhs (Value)

    Integer or vector of integers

  • rhs (Value)

    Integer or vector of integers

  • mode (:arithmetic, :logical) (defaults to: :arithmetic)

    The filling mode.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR

Returns:



604
605
606
607
608
609
# File 'lib/rltk/cg/builder.rb', line 604

def shift_right(lhs, rhs, mode = :arithmetic, name = '')
	case mode
	when :arithmetic	then ashr(lhs, rhs, name)
	when :logical		then lshr(lhs, rhs, name)
	end
end

#shuffle_vector(vec1, vec2, mask, name = '') ⇒ ShuffleVectorInst

Shuffle two vectors according to a given mask.

Parameters:

  • vec1 (Value)

    Vector

  • vec2 (Value)

    Vector of the same type and arity as vec1.

  • mask (Value)

    Vector of Int1 of the same arity as vec1 and vec2.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:



294
295
296
# File 'lib/rltk/cg/builder.rb', line 294

def shuffle_vector(vec1, vec2, mask, name = '')
	ShuffleVectorInst.new(Bindings.build_shuffle_vector(@ptr, vec1, vec2, mask, name))
end

#sign_extend(val, type, name = '') ⇒ SignExtendInst Also known as: sext

Sign extension by copying the sign bit (highest order bit) of the value until it reaches the bit size of the given type.

Parameters:

  • val (Value)

    Integer or vector of integers to be extended.

  • type (Type)

    Integer or vector of integer type of greater size than the size of val.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:



968
969
970
# File 'lib/rltk/cg/builder.rb', line 968

def sign_extend(val, type, name = '')
	SignExtendInst.new(Bindings.build_s_ext(@ptr, val, check_cg_type(type), name))
end

#sign_extend_or_bitcast(val, type, name = '') ⇒ SignExtendOrBitcastInst Also known as: sext_or_bitcast

Sign extension or bitcast.

Parameters:

  • val (Value)

    Integer or vector of integers to be extended.

  • type (Type)

    Integer or vector of integer type of greater size than the size of val.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (SignExtendOrBitcastInst)

    The extended or cast value.



980
981
982
# File 'lib/rltk/cg/builder.rb', line 980

def sign_extend_or_bitcast(val, type, name = '')
	SignExtendOrBitCastInst.new(Bindings.build_s_ext_or_bit_cast(@ptr, val, check_cg_type(type), name))
end

#signed_int_to_floating_point(val, type, name = '') ⇒ SIToFPInst Also known as: si2fp

Convert a signed integer to a floating point.

Parameters:

  • val (Value)

    Signed integer or vector of signed integer to convert.

  • type (Type)

    Floating point or vector of floating point target type.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:



992
993
994
# File 'lib/rltk/cg/builder.rb', line 992

def signed_int_to_floating_point(val, type, name = '')
	SIToFPInst.new(Bindings.build_si_to_fp(@ptr, val, check_cg_type(type), name))
end

#srem(lhs, rhs, name = '') ⇒ SRemInst

Signed remainder.

Parameters:

  • lhs (Value)

    Integer or vector of integers.

  • rhs (Value)

    Integer or vector of integers.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:



504
505
506
# File 'lib/rltk/cg/builder.rb', line 504

def srem(lhs, rhs, name = '')
	SRemInst.new(Bindings.build_s_rem(@ptr, lhs, rhs, name))
end

#store(val, ptr) ⇒ StoreInst

Store a value at a given pointer.

Parameters:

  • val (Value)

    The value to be stored.

  • ptr (Value)

    Pointer to the same type as val.

Returns:

  • (StoreInst)

    The result of the store operation.



739
740
741
# File 'lib/rltk/cg/builder.rb', line 739

def store(val, ptr)
	StoreInst.new(Bindings.build_store(@ptr, val, ptr))
end

#struct_get_element_ptr(ptr, index, name = '') ⇒ StructGEPInst Also known as: struct_getp

Builds a struct getelementptr instruction.

Parameters:

  • ptr (Value)

    Pointer to a structure.

  • index (Value)

    Unsigned integer representing the index of a structure member.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:



787
788
789
# File 'lib/rltk/cg/builder.rb', line 787

def struct_get_element_ptr(ptr, index, name = '')
	StructGEPInst.new(Bindings.build_struct_gep(@ptr, ptr, index, name))
end

#sub(lhs, rhs, name = '') ⇒ SubInst

Returns The integer difference of the two operands.

Parameters:

  • lhs (Value)

    Integer or vector of integers.

  • rhs (Value)

    Integer or vector of integers.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (SubInst)

    The integer difference of the two operands.



365
366
367
# File 'lib/rltk/cg/builder.rb', line 365

def sub(lhs, rhs, name = '')
	SubInst.new(Bindings.build_sub(@ptr, lhs, rhs, name))
end

#switch(val, default, cases) ⇒ SwitchInst

Select a value based on an incoming value.

Parameters:

  • val (Value)

    Value to switch on.

  • default (BasicBlock)

    Default case.

  • cases (Hash{Value => BasicBlock})

    Hash mapping values to basic blocks. When a value is matched, control will jump to the corresponding basic block.

Returns:



306
307
308
309
310
# File 'lib/rltk/cg/builder.rb', line 306

def switch(val, default, cases)
	SwitchInst.new(Bindings.build_switch(@ptr, val, default, cases.size)).tap do |inst|
		cases.each { |val, block| inst.add_case(val, block) }
	end
end

#truncate(val, type, name = '') ⇒ TruncateInst Also known as: trunc

Truncates its operand to the given type. The size of the value type must be greater than the size of the target type.

Parameters:

  • val (Value)

    Integer or vector of integers to be truncated.

  • type (Type)

    Integer or vector of integers of equal size to val.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:



1005
1006
1007
# File 'lib/rltk/cg/builder.rb', line 1005

def truncate(val, type, name = '')
	TruncateInst.new(Bindings.build_trunc(@ptr, val, check_cg_type(type), name))
end

#truncate_or_bitcast(val, type, name = '') ⇒ TruncateInst

Truncates or bitcast.

Parameters:

  • val (Value)

    Integer or vector of integers to be truncated.

  • type (Type)

    Integer or vector of integers of equal size to val.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:



1017
1018
1019
# File 'lib/rltk/cg/builder.rb', line 1017

def truncate_or_bitcast(val, type, name = '')
	TruncateOrBitCastInst.new(Bindings.build_trunc_or_bit_cast(@ptr, val, check_cg_type(type), name))
end

#udiv(lhs, rhs, name = '') ⇒ SDivInst

Unsigned integer division.

Parameters:

  • lhs (Value)

    Integer or vector of integers.

  • rhs (Value)

    Integer or vector of integers.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (SDivInst)

    The integer quotient of the two operands.



482
483
484
# File 'lib/rltk/cg/builder.rb', line 482

def udiv(lhs, rhs, name = '')
	UDivInst.new(Bindings.build_u_div(@ptr, lhs, rhs, name))
end

#unreachableUnreachableInst

Generates an instruction with no defined semantics. Can be used to provide hints to the optimizer.

Returns:



125
126
127
# File 'lib/rltk/cg/builder.rb', line 125

def unreachable
	UnreachableInst.new(Bindings.build_unreachable(@ptr))
end

#unsigned_int_to_floating_point(val, type, name = '') ⇒ SIToFPInst Also known as: ui2fp

Convert an unsigned integer to a floating point.

Parameters:

  • val (Value)

    Signed integer or vector of signed integer to convert.

  • type (Type)

    Floating point or vector of floating point target type.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:



1028
1029
1030
# File 'lib/rltk/cg/builder.rb', line 1028

def unsigned_int_to_floating_point(val, type, name = '')
	UIToFPInst.new(Bindings.build_ui_to_fp(@ptr, val, check_cg_type(type), name))
end

#urem(lhs, rhs, name = '') ⇒ SRemInst

Unsigned remainder.

Parameters:

  • lhs (Value)

    Integer or vector of integers.

  • rhs (Value)

    Integer or vector of integers.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:



515
516
517
# File 'lib/rltk/cg/builder.rb', line 515

def urem(lhs, rhs, name = '')
	URemInst.new(Bindings.build_u_rem(@ptr, lhs, rhs, name))
end

#xor(lhs, rhs, name = '') ⇒ XOrInst

Returns An integer instruction.

Parameters:

  • lhs (Value)

    Integer or vector of integers.

  • rhs (Value)

    Integer or vector of integers.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:

  • (XOrInst)

    An integer instruction.



656
657
658
# File 'lib/rltk/cg/builder.rb', line 656

def xor(lhs, rhs, name = '')
	XOrInst.new(Bindings.build_xor(@ptr, lhs, rhs, name))
end

#zero_extend(val, type, name = '') ⇒ ZeroExtendInst Also known as: zext

Zero extends its operand to the given type. The size of the value type must be greater than the size of the target type.

Parameters:

  • val (Value)

    Integer or vector of integers to be extended.

  • type (Type)

    Integer or vector of integer type of greater size than val.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:



1041
1042
1043
# File 'lib/rltk/cg/builder.rb', line 1041

def zero_extend(val, type, name = '')
	ZeroExtendInst.new(Bindings.build_z_ext(@ptr, val, check_cg_type(type), name))
end

#zero_extend_or_bitcast(val, type, name = '') ⇒ ZeroExtendInst Also known as: zext_or_bitcast

Zero extend or bitcast.

Parameters:

  • val (Value)

    Integer or vector of integers to be extended.

  • type (Type)

    Integer or vector of integer type of greater size than val.

  • name (String) (defaults to: '')

    Name of the result in LLVM IR.

Returns:



1053
1054
1055
# File 'lib/rltk/cg/builder.rb', line 1053

def zero_extend_or_bitcast(val, type, name = '')
	ZeroExtendOrBitCastInst.new(Bindings.build_z_ext_or_bit_cast(@ptr, val, check_cg_type(type), name))
end