Class: RLTK::CG::Builder

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

Overview

This class is responsible for adding Instructions to BasicBlocks.

Instance Attribute Summary

Attributes included from BindingClass

#ptr

Class Method Summary collapse

Instance Method Summary collapse

Methods included from BindingClass

#==

Constructor Details

#initialize(block = nil) ⇒ Builder

Creates a new Builder object, optionally positioning it at the end of block.

Parameters:

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

    BasicBlock used to position the Builder.



33
34
35
36
37
# File 'lib/rltk/cg/builder.rb', line 33

def initialize(block = nil)
	@ptr = Bindings.create_builder
	
	position_at_end(block) if block
end

Class Method Details

.globalBuilder

Returns A global Builder object.

Returns:

  • (Builder)

    A global Builder object.



25
26
27
# File 'lib/rltk/cg/builder.rb', line 25

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.



321
322
323
# File 'lib/rltk/cg/builder.rb', line 321

def add(lhs, rhs, name = '')
	AddInst.new(Bindings.build_add(@ptr, lhs, rhs, 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.



699
700
701
# File 'lib/rltk/cg/builder.rb', line 699

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.



636
637
638
# File 'lib/rltk/cg/builder.rb', line 636

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:



710
711
712
# File 'lib/rltk/cg/builder.rb', line 710

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:



689
690
691
# File 'lib/rltk/cg/builder.rb', line 689

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:



616
617
618
# File 'lib/rltk/cg/builder.rb', line 616

def ashr(lhs, rhs, name = '')
	ARightShiftInst.new(Bindings.build_a_shr(@ptr, lhs, rhs, name))
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:



821
822
823
# File 'lib/rltk/cg/builder.rb', line 821

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:



162
163
164
# File 'lib/rltk/cg/builder.rb', line 162

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.to_sym, *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:



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

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:



189
190
191
# File 'lib/rltk/cg/builder.rb', line 189

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.



114
115
116
# File 'lib/rltk/cg/builder.rb', line 114

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

#disposevoid

This method returns an undefined value.

Frees the resources used by LLVM for this Builder.



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

def dispose
	if @ptr
		Bindings.dispose_builder(@ptr)
		@ptr = nil
	end
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.



469
470
471
# File 'lib/rltk/cg/builder.rb', line 469

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:



201
202
203
# File 'lib/rltk/cg/builder.rb', line 201

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:



212
213
214
# File 'lib/rltk/cg/builder.rb', line 212

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.



330
331
332
# File 'lib/rltk/cg/builder.rb', line 330

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.



447
448
449
# File 'lib/rltk/cg/builder.rb', line 447

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:



830
831
832
# File 'lib/rltk/cg/builder.rb', line 830

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:



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

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:



855
856
857
# File 'lib/rltk/cg/builder.rb', line 855

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:



867
868
869
# File 'lib/rltk/cg/builder.rb', line 867

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



879
880
881
# File 'lib/rltk/cg/builder.rb', line 879

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.



414
415
416
# File 'lib/rltk/cg/builder.rb', line 414

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.



537
538
539
# File 'lib/rltk/cg/builder.rb', line 537

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:



1059
1060
1061
# File 'lib/rltk/cg/builder.rb', line 1059

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.



717
718
719
# File 'lib/rltk/cg/builder.rb', line 717

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.



491
492
493
# File 'lib/rltk/cg/builder.rb', line 491

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.



372
373
374
# File 'lib/rltk/cg/builder.rb', line 372

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:



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

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:



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

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:



806
807
808
# File 'lib/rltk/cg/builder.rb', line 806

def gloabl_string_pointer(string, name = '')
	GlobalStringPtrInst(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:



796
797
798
# File 'lib/rltk/cg/builder.rb', line 796

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:



224
225
226
# File 'lib/rltk/cg/builder.rb', line 224

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:



236
237
238
# File 'lib/rltk/cg/builder.rb', line 236

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:



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

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.



892
893
894
# File 'lib/rltk/cg/builder.rb', line 892

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:



902
903
904
# File 'lib/rltk/cg/builder.rb', line 902

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.



249
250
251
# File 'lib/rltk/cg/builder.rb', line 249

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.



1081
1082
1083
# File 'lib/rltk/cg/builder.rb', line 1081

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.



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

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.



727
728
729
# File 'lib/rltk/cg/builder.rb', line 727

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:



627
628
629
# File 'lib/rltk/cg/builder.rb', line 627

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.



678
679
680
# File 'lib/rltk/cg/builder.rb', line 678

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.



405
406
407
# File 'lib/rltk/cg/builder.rb', line 405

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.



526
527
528
# File 'lib/rltk/cg/builder.rb', line 526

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.



664
665
666
# File 'lib/rltk/cg/builder.rb', line 664

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.



341
342
343
# File 'lib/rltk/cg/builder.rb', line 341

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.



425
426
427
# File 'lib/rltk/cg/builder.rb', line 425

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.



548
549
550
# File 'lib/rltk/cg/builder.rb', line 548

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.



383
384
385
# File 'lib/rltk/cg/builder.rb', line 383

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.



352
353
354
# File 'lib/rltk/cg/builder.rb', line 352

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.



436
437
438
# File 'lib/rltk/cg/builder.rb', line 436

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.



559
560
561
# File 'lib/rltk/cg/builder.rb', line 559

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.



394
395
396
# File 'lib/rltk/cg/builder.rb', line 394

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.



645
646
647
# File 'lib/rltk/cg/builder.rb', line 645

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:



263
264
265
266
267
# File 'lib/rltk/cg/builder.rb', line 263

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

#position(block, 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(block, instruction)
	Bindings.position_builder(@ptr, block, instruction)
	self
end

#position_at_end(block) ⇒ Bulder

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(block)
	Bindings.position_builder_at_end(@ptr, block)
	self
end

#position_before(instruction) ⇒ Builder

Position the Builder before the given Instruction.

Parameters:

Returns:



100
101
102
103
# File 'lib/rltk/cg/builder.rb', line 100

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:



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

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.



1071
1072
1073
# File 'lib/rltk/cg/builder.rb', line 1071

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.



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

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:



134
135
136
# File 'lib/rltk/cg/builder.rb', line 134

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

#ret_aggregate(*vals) ⇒ RetAggregateInst

Returns:

  • (RetAggregateInst)


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

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)


139
140
141
# File 'lib/rltk/cg/builder.rb', line 139

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.



458
459
460
# File 'lib/rltk/cg/builder.rb', line 458

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.



280
281
282
# File 'lib/rltk/cg/builder.rb', line 280

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:



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

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:



589
590
591
# File 'lib/rltk/cg/builder.rb', line 589

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:



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

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:



292
293
294
# File 'lib/rltk/cg/builder.rb', line 292

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:



936
937
938
# File 'lib/rltk/cg/builder.rb', line 936

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.



948
949
950
# File 'lib/rltk/cg/builder.rb', line 948

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:



960
961
962
# File 'lib/rltk/cg/builder.rb', line 960

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:



502
503
504
# File 'lib/rltk/cg/builder.rb', line 502

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.



737
738
739
# File 'lib/rltk/cg/builder.rb', line 737

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:



785
786
787
# File 'lib/rltk/cg/builder.rb', line 785

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.



363
364
365
# File 'lib/rltk/cg/builder.rb', line 363

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:



304
305
306
307
308
# File 'lib/rltk/cg/builder.rb', line 304

def switch(val, default, cases)
	returning SwitchInst.new(Bindings.build_switch(@ptr, val, default, cases.size)) 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:



973
974
975
# File 'lib/rltk/cg/builder.rb', line 973

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:



985
986
987
# File 'lib/rltk/cg/builder.rb', line 985

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.



480
481
482
# File 'lib/rltk/cg/builder.rb', line 480

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:



123
124
125
# File 'lib/rltk/cg/builder.rb', line 123

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:



996
997
998
# File 'lib/rltk/cg/builder.rb', line 996

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:



513
514
515
# File 'lib/rltk/cg/builder.rb', line 513

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.



654
655
656
# File 'lib/rltk/cg/builder.rb', line 654

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:



1009
1010
1011
# File 'lib/rltk/cg/builder.rb', line 1009

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:



1021
1022
1023
# File 'lib/rltk/cg/builder.rb', line 1021

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