Class: LLVM::Builder
- Inherits:
-
Object
- Object
- LLVM::Builder
- Defined in:
- lib/llvm/core/builder.rb
Instance Method Summary collapse
-
#add(lhs, rhs, name = "") ⇒ LLVM::Instruction
Integer addition.
-
#aggregate_ret(*vals) ⇒ LLVM::Instruction
Builds a ret instruction returning multiple values.
-
#alloca(ty, name = "") ⇒ LLVM::Instruction
Stack allocation.
-
#and(lhs, rhs, name = "") ⇒ LLVM::Instruction
An integer instruction.
-
#array_alloca(ty, sz, name = "") ⇒ LLVM::Instruction
Array stack allocation.
-
#array_malloc(ty, sz, name = "") ⇒ LLVM::Instruction
A pointer to the malloced array.
-
#ashr(lhs, rhs, name = "") ⇒ LLVM::Instruction
Arithmatic shift right.
-
#bit_cast(val, ty, name = "") ⇒ LLVM::Instruction
Cast a value to the given type without changing any bits.
-
#br(block) ⇒ LLVM::Instruction
Unconditional branching (i.e. goto).
-
#call(fun, *args) ⇒ Object
Builds a call Instruction.
-
#cond(cond, iftrue, iffalse) ⇒ LLVM::Instruction
Conditional branching (i.e. if).
- #dispose ⇒ Object
-
#exact_sdiv(lhs, rhs, name = "") ⇒ LLVM::Instruction
Signed exact division.
-
#extract_element(vector, idx, name = "") ⇒ LLVM::Instruction
Extract an element from a vector.
-
#extract_value(aggregate, idx, name = "") ⇒ LLVM::Instruction
Extract the value of a member field from an aggregate value.
-
#fadd(lhs, rhs, name = "") ⇒ LLVM::Instruction
The floating point sum of the two operands.
-
#fcmp(pred, lhs, rhs, name = "") ⇒ LLVM::Instruction
Builds an fcmp Instruction.
-
#fdiv(lhs, rhs, name = "") ⇒ LLVM::Instruction
The floating point quotient of the two operands.
-
#fmul(lhs, rhs, name = "") ⇒ LLVM::Instruction
Floating point multiplication.
-
#fp2si(val, ty, name = "") ⇒ LLVM::Instruction
Convert a floating point to a signed integer.
-
#fp2ui(val, ty, name = "") ⇒ LLVM::Instruction
Convert a floating point to an unsigned integer.
- #fp_cast(val, ty, name = "") ⇒ LLVM::Instruction
-
#fp_ext(val, ty, name = "") ⇒ LLVM::Instruction
Extend a floating point value.
-
#fp_trunc(val, ty, name = "") ⇒ LLVM::Instruction
Truncate a floating point value.
-
#free(ptr) ⇒ LLVM::Instruction
The result of the free instruction.
-
#frem(lhs, rhs, name = "") ⇒ LLVM::Instruction
The floating point remainder.
-
#fsub(lhs, rhs, name = "") ⇒ LLVM::Instruction
The floating point difference of the two operands.
-
#gep(ptr, indices, name = "") ⇒ LLVM::Instruction
Obtain a pointer to the element at the given indices.
-
#global_string(string, name = "") ⇒ LLVM::Instruction
Creates a global string initialized to a given value.
-
#global_string_pointer(string, name = "") ⇒ LLVM::Instruction
Creates a pointer to a global string initialized to a given value.
-
#ibr(addr, num_dests) ⇒ LLVM::Instruction
Indirect branching (i.e. computed goto).
-
#icmp(pred, lhs, rhs, name = "") ⇒ LLVM::Instruction
Builds an icmp Instruction.
-
#inbounds_gep(ptr, indices, name = "") ⇒ LLVM::Instruction
Builds a inbounds getelementptr instruction.
-
#initialize ⇒ Builder
constructor
Important: Call #dispose to free backend memory after use.
-
#insert_block ⇒ LLVM::BasicBlock
The BasicBlock at which the Builder is currently positioned.
-
#insert_element(vector, elem, idx, name = "") ⇒ LLVM::Instruction
Insert an element into a vector.
-
#insert_value(aggregate, elem, idx, name = "") ⇒ LLVM::Instruction
Insert a value into an aggregate value’s member field.
-
#int2ptr(val, ty, name = "") ⇒ LLVM::Instruction
Cast an int to a pointer.
- #int_cast(val, ty, name = "") ⇒ LLVM::Instruction
-
#invoke(fun, args, normal, exception, name = "") ⇒ LLVM::Instruction
Invoke a function which may potentially unwind.
-
#is_not_null(val, name = "") ⇒ LLVM::Instruction
Check if a value is not null.
-
#is_null(val, name = "") ⇒ LLVM::Instruction
Check if a value is null.
-
#load(ptr, name = "") ⇒ LLVM::Instruction
Load the value of a given pointer.
-
#lshr(lhs, rhs, name = "") ⇒ LLVM::Instruction
Shifts right with zero fill.
-
#malloc(ty, name = "") ⇒ LLVM::Instruction
A pointer to the malloced bytes.
-
#mul(lhs, rhs, name = "") ⇒ LLVM::Instruction
Integer multiplication.
-
#neg(arg, name = "") ⇒ LLVM::Instruction
Integer negation.
-
#not(arg, name = "") ⇒ LLVM::Instruction
Boolean negation.
-
#nsw_add(lhs, rhs, name = "") ⇒ LLVM::Instruction
“No signed wrap” integer addition.
-
#nsw_mul(lhs, rhs, name = "") ⇒ LLVM::Instruction
“No signed wrap” integer multiplication.
-
#nsw_neg(arg, name = "") ⇒ LLVM::Instruction
“No signed wrap” integer negation.
-
#nsw_sub(lhs, rhs, name = "") ⇒ LLVM::Instruction
No signed wrap integer subtraction.
-
#nuw_add(lhs, rhs, name = "") ⇒ LLVM::Instruction
“No unsigned wrap” integer addition.
-
#nuw_mul(lhs, rhs, name = "") ⇒ LLVM::Instruction
“No unsigned wrap” integer multiplication.
-
#nuw_neg(arg, name = "") ⇒ LLVM::Instruction
“No unsigned wrap” integer negation.
-
#nuw_sub(lhs, rhs, name = "") ⇒ LLVM::Instruction
No unsigned wrap integer subtraction.
-
#or(lhs, rhs, name = "") ⇒ LLVM::Instruction
An integer instruction.
-
#phi(ty, incoming, name = "") ⇒ LLVM::Instruction
Build a Phi node of the given type with the given incoming branches.
- #pointer_cast(val, ty, name = "") ⇒ LLVM::Instruction
-
#position(block, instruction) ⇒ LLVM::Builder
Position the builder at the given Instruction within the given BasicBlock.
-
#position_at_end(block) ⇒ LLVM::Builder
Positions the builder at the end of the given BasicBlock.
-
#position_before(instruction) ⇒ LLVM::Builder
Positions the builder before the given Instruction.
-
#ptr2int(val, ty, name = "") ⇒ LLVM::Instruction
Cast a pointer to an int.
-
#ptr_diff(lhs, rhs, name = "") ⇒ LLVM::Instruction
Calculate the difference between two pointers.
- #ret(val) ⇒ LLVM::Instruction
- #ret_void ⇒ LLVM::Instruction
-
#sdiv(lhs, rhs, name = "") ⇒ LLVM::Instruction
Signed division.
-
#select(_if, _then, _else, name = "") ⇒ LLVM::Instruction
Return a value based on a condition.
-
#sext(val, ty, name = "") ⇒ LLVM::Instruction
Sign extension by copying the sign bit (highest order bit) of the value until it reaches the bit size of the given type.
- #sext_or_bit_cast(val, ty, name = "") ⇒ LLVM::Instruction
-
#shl(lhs, rhs, name = "") ⇒ LLVM::Instruction
An integer instruction.
-
#shuffle_vector(vec1, vec2, mask, name = "") ⇒ LLVM::Instruction
Shuffle two vectors according to a given mask.
-
#si2fp(val, ty, name = "") ⇒ LLVM::Instruction
Convert a signed integer to a floating point.
-
#srem(lhs, rhs, name = "") ⇒ LLVM::Instruction
Signed remainder.
-
#store(val, ptr) ⇒ LLVM::Instruction
Store a value at a given pointer.
-
#struct_gep(pointer, idx, name = "") ⇒ LLVM::Instruction
Builds a struct getelementptr Instruction.
-
#sub(lhs, rhs, name = "") ⇒ LLVM::Instruction
Integer subtraction.
- #switch(val, default, cases) ⇒ LLVM::Instruction
- #to_ptr ⇒ Object
-
#trunc(val, ty, name = "") ⇒ LLVM::Instruction
Truncates its operand to the given type.
- #trunc_or_bit_cast(val, ty, name = "") ⇒ LLVM::Instruction
-
#udiv(lhs, rhs, name = "") ⇒ LLVM::Instruction
Unsigned integer division.
-
#ui2fp(val, ty, name = "") ⇒ LLVM::Instruction
Convert an unsigned integer to a floating point.
-
#unreachable ⇒ LLVM::Instruction
Generates an instruction with no defined semantics.
-
#unwind ⇒ Object
Builds an unwind Instruction.
-
#urem(lhs, rhs, name = "") ⇒ LLVM::Instruction
Unsigned remainder.
-
#xor(lhs, rhs, name = "") ⇒ LLVM::Instruction
An integer instruction.
-
#zext(val, ty, name = "") ⇒ LLVM::Instruction
Zero extends its operand to the given type.
- #zext_or_bit_cast(val, ty, name = "") ⇒ LLVM::Instruction
Constructor Details
#initialize ⇒ Builder
Important: Call #dispose to free backend memory after use.
6 7 8 |
# File 'lib/llvm/core/builder.rb', line 6 def initialize @ptr = C.create_builder() end |
Instance Method Details
#add(lhs, rhs, name = "") ⇒ LLVM::Instruction
Integer addition.
168 169 170 |
# File 'lib/llvm/core/builder.rb', line 168 def add(lhs, rhs, name = "") Instruction.from_ptr(C.build_add(self, lhs, rhs, name)) end |
#aggregate_ret(*vals) ⇒ LLVM::Instruction
Builds a ret instruction returning multiple values.
76 77 78 79 80 81 |
# File 'lib/llvm/core/builder.rb', line 76 def aggregate_ret(*vals) FFI::MemoryPointer.new(FFI.type_size(:pointer) * vals.size) do |vals_ptr| vals_ptr.write_array_of_pointer(vals) Instruction.from_ptr(C.build_aggregate_ret(self, vals_ptr, vals.size)) end end |
#alloca(ty, name = "") ⇒ LLVM::Instruction
Stack allocation.
466 467 468 |
# File 'lib/llvm/core/builder.rb', line 466 def alloca(ty, name = "") Instruction.from_ptr(C.build_alloca(self, LLVM::Type(ty), name)) end |
#and(lhs, rhs, name = "") ⇒ LLVM::Instruction
Returns An integer instruction.
385 386 387 |
# File 'lib/llvm/core/builder.rb', line 385 def and(lhs, rhs, name = "") Instruction.from_ptr(C.build_and(self, lhs, rhs, name)) end |
#array_alloca(ty, sz, name = "") ⇒ LLVM::Instruction
Array stack allocation
477 478 479 |
# File 'lib/llvm/core/builder.rb', line 477 def array_alloca(ty, sz, name = "") Instruction.from_ptr(C.build_array_alloca(self, LLVM::Type(ty), sz, name)) end |
#array_malloc(ty, sz, name = "") ⇒ LLVM::Instruction
Returns A pointer to the malloced array.
456 457 458 |
# File 'lib/llvm/core/builder.rb', line 456 def array_malloc(ty, sz, name = "") Instruction.from_ptr(C.build_array_malloc(self, LLVM::Type(ty), sz, name)) end |
#ashr(lhs, rhs, name = "") ⇒ LLVM::Instruction
Arithmatic shift right.
376 377 378 |
# File 'lib/llvm/core/builder.rb', line 376 def ashr(lhs, rhs, name = "") Instruction.from_ptr(C.build_a_shr(self, lhs, rhs, name)) end |
#bit_cast(val, ty, name = "") ⇒ LLVM::Instruction
Cast a value to the given type without changing any bits
703 704 705 |
# File 'lib/llvm/core/builder.rb', line 703 def bit_cast(val, ty, name = "") Instruction.from_ptr(C.build_bit_cast(self, val, LLVM::Type(ty), name)) end |
#br(block) ⇒ LLVM::Instruction
Unconditional branching (i.e. goto)
87 88 89 90 91 |
# File 'lib/llvm/core/builder.rb', line 87 def br(block) raise "Block must not be nil" if block.nil? Instruction.from_ptr( C.build_br(self, block)) end |
#call(fun, *args) ⇒ Object
Builds a call Instruction. Calls the given Function with the given args (Instructions).
837 838 839 840 841 842 843 844 845 846 847 848 |
# File 'lib/llvm/core/builder.rb', line 837 def call(fun, *args) raise "No fun" if fun.nil? if args.last.kind_of? String name = args.pop else name = "" end args_ptr = FFI::MemoryPointer.new(FFI.type_size(:pointer) * args.size) args_ptr.write_array_of_pointer(args) CallInst.from_ptr(C.build_call(self, fun, args_ptr, args.size, name)) end |
#cond(cond, iftrue, iffalse) ⇒ LLVM::Instruction
Conditional branching (i.e. if)
109 110 111 112 |
# File 'lib/llvm/core/builder.rb', line 109 def cond(cond, iftrue, iffalse) Instruction.from_ptr( C.build_cond_br(self, cond, iftrue, iffalse)) end |
#dispose ⇒ Object
10 11 12 13 14 |
# File 'lib/llvm/core/builder.rb', line 10 def dispose return if @ptr.nil? C.dispose_builder(@ptr) @ptr = nil end |
#exact_sdiv(lhs, rhs, name = "") ⇒ LLVM::Instruction
Signed exact division
308 309 310 |
# File 'lib/llvm/core/builder.rb', line 308 def exact_sdiv(lhs, rhs, name = "") Instruction.from_ptr(C.build_exact_s_div(self, lhs, rhs, name)) end |
#extract_element(vector, idx, name = "") ⇒ LLVM::Instruction
Extract an element from a vector
872 873 874 |
# File 'lib/llvm/core/builder.rb', line 872 def extract_element(vector, idx, name = "") Instruction.from_ptr(C.build_extract_element(self, vector, idx, name)) end |
#extract_value(aggregate, idx, name = "") ⇒ LLVM::Instruction
Extract the value of a member field from an aggregate value
905 906 907 |
# File 'lib/llvm/core/builder.rb', line 905 def extract_value(aggregate, idx, name = "") Instruction.from_ptr(C.build_extract_value(self, aggregate, idx, name)) end |
#fadd(lhs, rhs, name = "") ⇒ LLVM::Instruction
Returns The floating point sum of the two operands.
197 198 199 |
# File 'lib/llvm/core/builder.rb', line 197 def fadd(lhs, rhs, name = "") Instruction.from_ptr(C.build_f_add(self, lhs, rhs, name)) end |
#fcmp(pred, lhs, rhs, name = "") ⇒ LLVM::Instruction
Builds an fcmp Instruction. Compares lhs to rhs (Instructions) as Reals using the given symbol predicate (pred):
:ord - ordered
:uno - unordered: isnan(X) | isnan(Y)
:oeq - ordered and equal to
:oeq - unordered and equal to
:one - ordered and not equal to
:one - unordered and not equal to
:ogt - ordered and greater than
:uge - unordered and greater than or equal to
:olt - ordered and less than
:ule - unordered and less than or equal to
:oge - ordered and greater than or equal to
:sge - unordered and greater than or equal to
:ole - ordered and less than or equal to
:sle - unordered and less than or equal to
:true - always true and folded
:false - always false and folded
811 812 813 |
# File 'lib/llvm/core/builder.rb', line 811 def fcmp(pred, lhs, rhs, name = "") Instruction.from_ptr(C.build_f_cmp(self, pred, lhs, rhs, name)) end |
#fdiv(lhs, rhs, name = "") ⇒ LLVM::Instruction
Returns The floating point quotient of the two operands.
318 319 320 |
# File 'lib/llvm/core/builder.rb', line 318 def fdiv(lhs, rhs, name = "") Instruction.from_ptr(C.build_f_div(self, lhs, rhs, name)) end |
#fmul(lhs, rhs, name = "") ⇒ LLVM::Instruction
Floating point multiplication
278 279 280 |
# File 'lib/llvm/core/builder.rb', line 278 def fmul(lhs, rhs, name = "") Instruction.from_ptr(C.build_f_mul(self, lhs, rhs, name)) end |
#fp2si(val, ty, name = "") ⇒ LLVM::Instruction
Convert a floating point to a signed integer
625 626 627 |
# File 'lib/llvm/core/builder.rb', line 625 def fp2si(val, ty, name = "") Instruction.from_ptr(C.build_fp_to_si(self, val, LLVM::Type(ty), name)) end |
#fp2ui(val, ty, name = "") ⇒ LLVM::Instruction
Convert a floating point to an unsigned integer
614 615 616 |
# File 'lib/llvm/core/builder.rb', line 614 def fp2ui(val, ty, name = "") Instruction.from_ptr(C.build_fp_to_ui(self, val, LLVM::Type(ty), name)) end |
#fp_cast(val, ty, name = "") ⇒ LLVM::Instruction
757 758 759 |
# File 'lib/llvm/core/builder.rb', line 757 def fp_cast(val, ty, name = "") Instruction.from_ptr(C.build_fp_cast(self, val, LLVM::Type(ty), name)) end |
#fp_ext(val, ty, name = "") ⇒ LLVM::Instruction
Extend a floating point value
671 672 673 |
# File 'lib/llvm/core/builder.rb', line 671 def fp_ext(val, ty, name = "") Instruction.from_ptr(C.build_fp_ext(self, val, LLVM::Type(ty), name)) end |
#fp_trunc(val, ty, name = "") ⇒ LLVM::Instruction
Truncate a floating point value
660 661 662 |
# File 'lib/llvm/core/builder.rb', line 660 def fp_trunc(val, ty, name = "") Instruction.from_ptr(C.build_fp_trunc(self, val, LLVM::Type(ty), name)) end |
#free(ptr) ⇒ LLVM::Instruction
Returns The result of the free instruction.
483 484 485 |
# File 'lib/llvm/core/builder.rb', line 483 def free(ptr) Instruction.from_ptr(C.build_free(self, ptr)) end |
#frem(lhs, rhs, name = "") ⇒ LLVM::Instruction
Returns The floating point remainder.
347 348 349 |
# File 'lib/llvm/core/builder.rb', line 347 def frem(lhs, rhs, name = "") Instruction.from_ptr(C.build_f_rem(self, lhs, rhs, name)) end |
#fsub(lhs, rhs, name = "") ⇒ LLVM::Instruction
Returns The floating point difference of the two operands.
237 238 239 |
# File 'lib/llvm/core/builder.rb', line 237 def fsub(lhs, rhs, name = "") Instruction.from_ptr(C.build_f_sub(self, lhs, rhs, name)) end |
#gep(ptr, indices, name = "") ⇒ LLVM::Instruction
Obtain a pointer to the element at the given indices
515 516 517 518 519 520 521 522 |
# File 'lib/llvm/core/builder.rb', line 515 def gep(ptr, indices, name = "") indices = Array(indices) FFI::MemoryPointer.new(FFI.type_size(:pointer) * indices.size) do |indices_ptr| indices_ptr.write_array_of_pointer(indices) return Instruction.from_ptr( C.build_gep(self, ptr, indices_ptr, indices.size, name)) end end |
#global_string(string, name = "") ⇒ LLVM::Instruction
Creates a global string initialized to a given value.
559 560 561 |
# File 'lib/llvm/core/builder.rb', line 559 def global_string(string, name = "") Instruction.from_ptr(C.build_global_string(self, string, name)) end |
#global_string_pointer(string, name = "") ⇒ LLVM::Instruction
Creates a pointer to a global string initialized to a given value.
567 568 569 |
# File 'lib/llvm/core/builder.rb', line 567 def global_string_pointer(string, name = "") Instruction.from_ptr(C.build_global_string_ptr(self, string, name)) end |
#ibr(addr, num_dests) ⇒ LLVM::Instruction
Indirect branching (i.e. computed goto)
98 99 100 101 |
# File 'lib/llvm/core/builder.rb', line 98 def ibr(addr, num_dests) IndirectBr.from_ptr( C.build_indirect_br(self, addr, num_dests)) end |
#icmp(pred, lhs, rhs, name = "") ⇒ LLVM::Instruction
Builds an icmp Instruction. Compares lhs to rhs (Instructions) using the given symbol predicate (pred):
:eq - equal to
:ne - not equal to
:ugt - unsigned greater than
:uge - unsigned greater than or equal to
:ult - unsigned less than
:ule - unsigned less than or equal to
:sgt - signed greater than
:sge - signed greater than or equal to
:slt - signed less than
:sle - signed less than or equal to
781 782 783 |
# File 'lib/llvm/core/builder.rb', line 781 def icmp(pred, lhs, rhs, name = "") Instruction.from_ptr(C.build_i_cmp(self, pred, lhs, rhs, name)) end |
#inbounds_gep(ptr, indices, name = "") ⇒ LLVM::Instruction
Builds a inbounds getelementptr instruction. If the indices are outside the allocated pointer the value is undefined.
533 534 535 536 537 538 539 540 |
# File 'lib/llvm/core/builder.rb', line 533 def inbounds_gep(ptr, indices, name = "") indices = Array(indices) FFI::MemoryPointer.new(FFI.type_size(:pointer) * indices.size) do |indices_ptr| indices_ptr.write_array_of_pointer(indices) return Instruction.from_ptr( C.build_in_bounds_gep(self, ptr, indices_ptr, indices.size, name)) end end |
#insert_block ⇒ LLVM::BasicBlock
The BasicBlock at which the Builder is currently positioned.
55 56 57 |
# File 'lib/llvm/core/builder.rb', line 55 def insert_block BasicBlock.from_ptr(C.get_insert_block(self)) end |
#insert_element(vector, elem, idx, name = "") ⇒ LLVM::Instruction
Insert an element into a vector
883 884 885 |
# File 'lib/llvm/core/builder.rb', line 883 def insert_element(vector, elem, idx, name = "") Instruction.from_ptr(C.build_insert_element(self, vector, elem, idx, name)) end |
#insert_value(aggregate, elem, idx, name = "") ⇒ LLVM::Instruction
Insert a value into an aggregate value’s member field
916 917 918 |
# File 'lib/llvm/core/builder.rb', line 916 def insert_value(aggregate, elem, idx, name = "") Instruction.from_ptr(C.build_insert_value(self, aggregate, elem, idx, name)) end |
#int2ptr(val, ty, name = "") ⇒ LLVM::Instruction
Cast an int to a pointer
693 694 695 |
# File 'lib/llvm/core/builder.rb', line 693 def int2ptr(val, ty, name = "") Instruction.from_ptr(C.build_int_to_ptr(self, val, LLVM::Type(ty), name)) end |
#int_cast(val, ty, name = "") ⇒ LLVM::Instruction
749 750 751 |
# File 'lib/llvm/core/builder.rb', line 749 def int_cast(val, ty, name = "") Instruction.from_ptr(C.build_int_cast(self, val, LLVM::Type(ty), name)) end |
#invoke(fun, args, normal, exception, name = "") ⇒ LLVM::Instruction
Invoke a function which may potentially unwind
138 139 140 141 142 143 144 145 146 |
# File 'lib/llvm/core/builder.rb', line 138 def invoke(fun, args, normal, exception, name = "") s = args.size FFI::MemoryPointer.new(FFI.type_size(:pointer) * s) do |args_ptr| args_ptr.write_array_of_pointer(args) return Instruction.from_ptr( C.build_invoke(self, fun, args_ptr, s, normal, exception, name)) end end |
#is_not_null(val, name = "") ⇒ LLVM::Instruction
Check if a value is not null
932 933 934 |
# File 'lib/llvm/core/builder.rb', line 932 def is_not_null(val, name = "") Instruction.from_ptr(C.build_is_not_null(self, val, name)) end |
#is_null(val, name = "") ⇒ LLVM::Instruction
Check if a value is null
924 925 926 |
# File 'lib/llvm/core/builder.rb', line 924 def is_null(val, name = "") Instruction.from_ptr(C.build_is_null(self, val, name)) end |
#load(ptr, name = "") ⇒ LLVM::Instruction
Load the value of a given pointer
493 494 495 |
# File 'lib/llvm/core/builder.rb', line 493 def load(ptr, name = "") Instruction.from_ptr(C.build_load(self, ptr, name)) end |
#lshr(lhs, rhs, name = "") ⇒ LLVM::Instruction
Shifts right with zero fill.
366 367 368 |
# File 'lib/llvm/core/builder.rb', line 366 def lshr(lhs, rhs, name = "") Instruction.from_ptr(C.build_l_shr(self, lhs, rhs, name)) end |
#malloc(ty, name = "") ⇒ LLVM::Instruction
Returns A pointer to the malloced bytes.
447 448 449 |
# File 'lib/llvm/core/builder.rb', line 447 def malloc(ty, name = "") Instruction.from_ptr(C.build_malloc(self, LLVM::Type(ty), name)) end |
#mul(lhs, rhs, name = "") ⇒ LLVM::Instruction
Integer multiplication.
247 248 249 |
# File 'lib/llvm/core/builder.rb', line 247 def mul(lhs, rhs, name = "") Instruction.from_ptr(C.build_mul(self, lhs, rhs, name)) end |
#neg(arg, name = "") ⇒ LLVM::Instruction
Integer negation. Implemented as a shortcut to the equivalent sub
instruction.
413 414 415 |
# File 'lib/llvm/core/builder.rb', line 413 def neg(arg, name = "") Instruction.from_ptr(C.build_neg(self, arg, name)) end |
#not(arg, name = "") ⇒ LLVM::Instruction
Boolean negation.
439 440 441 |
# File 'lib/llvm/core/builder.rb', line 439 def not(arg, name = "") Instruction.from_ptr(C.build_not(self, arg, name)) end |
#nsw_add(lhs, rhs, name = "") ⇒ LLVM::Instruction
“No signed wrap” integer addition.
178 179 180 |
# File 'lib/llvm/core/builder.rb', line 178 def nsw_add(lhs, rhs, name = "") Instruction.from_ptr(C.build_nsw_add(self, lhs, rhs, name)) end |
#nsw_mul(lhs, rhs, name = "") ⇒ LLVM::Instruction
“No signed wrap” integer multiplication.
257 258 259 |
# File 'lib/llvm/core/builder.rb', line 257 def nsw_mul(lhs, rhs, name = "") Instruction.from_ptr(C.build_nsw_mul(self, lhs, rhs, name)) end |
#nsw_neg(arg, name = "") ⇒ LLVM::Instruction
“No signed wrap” integer negation.
422 423 424 |
# File 'lib/llvm/core/builder.rb', line 422 def nsw_neg(arg, name = "") Instruction.from_ptr(C.build_nsw_neg(self, arg, name)) end |
#nsw_sub(lhs, rhs, name = "") ⇒ LLVM::Instruction
No signed wrap integer subtraction.
217 218 219 |
# File 'lib/llvm/core/builder.rb', line 217 def nsw_sub(lhs, rhs, name = "") Instruction.from_ptr(C.build_nsw_sub(self, lhs, rhs, name)) end |
#nuw_add(lhs, rhs, name = "") ⇒ LLVM::Instruction
“No unsigned wrap” integer addition.
188 189 190 |
# File 'lib/llvm/core/builder.rb', line 188 def nuw_add(lhs, rhs, name = "") Instruction.from_ptr(C.build_nuw_add(self, lhs, rhs, name)) end |
#nuw_mul(lhs, rhs, name = "") ⇒ LLVM::Instruction
“No unsigned wrap” integer multiplication.
267 268 269 |
# File 'lib/llvm/core/builder.rb', line 267 def nuw_mul(lhs, rhs, name = "") Instruction.from_ptr(C.build_nuw_mul(self, lhs, rhs, name)) end |
#nuw_neg(arg, name = "") ⇒ LLVM::Instruction
“No unsigned wrap” integer negation.
431 432 433 |
# File 'lib/llvm/core/builder.rb', line 431 def nuw_neg(arg, name = "") Instruction.from_ptr(C.build_nuw_neg(self, arg, name)) end |
#nuw_sub(lhs, rhs, name = "") ⇒ LLVM::Instruction
No unsigned wrap integer subtraction.
227 228 229 |
# File 'lib/llvm/core/builder.rb', line 227 def nuw_sub(lhs, rhs, name = "") Instruction.from_ptr(C.build_nuw_sub(self, lhs, rhs, name)) end |
#or(lhs, rhs, name = "") ⇒ LLVM::Instruction
Returns An integer instruction.
394 395 396 |
# File 'lib/llvm/core/builder.rb', line 394 def or(lhs, rhs, name = "") Instruction.from_ptr(C.build_or(self, lhs, rhs, name)) end |
#phi(ty, incoming, name = "") ⇒ LLVM::Instruction
Build a Phi node of the given type with the given incoming branches
824 825 826 827 828 |
# File 'lib/llvm/core/builder.rb', line 824 def phi(ty, incoming, name = "") phi = Phi.from_ptr(C.build_phi(self, LLVM::Type(ty), name)) phi.add_incoming(incoming) phi end |
#pointer_cast(val, ty, name = "") ⇒ LLVM::Instruction
741 742 743 |
# File 'lib/llvm/core/builder.rb', line 741 def pointer_cast(val, ty, name = "") Instruction.from_ptr(C.build_pointer_cast(self, val, LLVM::Type(ty), name)) end |
#position(block, instruction) ⇒ LLVM::Builder
Position the builder at the given Instruction within the given BasicBlock.
26 27 28 29 30 |
# File 'lib/llvm/core/builder.rb', line 26 def position(block, instruction) raise "Block must not be nil" if block.nil? C.position_builder(self, block, instruction) self end |
#position_at_end(block) ⇒ LLVM::Builder
Positions the builder at the end of the given BasicBlock.
46 47 48 49 50 |
# File 'lib/llvm/core/builder.rb', line 46 def position_at_end(block) raise "Block must not be nil" if block.nil? C.position_builder_at_end(self, block) self end |
#position_before(instruction) ⇒ LLVM::Builder
Positions the builder before the given Instruction.
36 37 38 39 40 |
# File 'lib/llvm/core/builder.rb', line 36 def position_before(instruction) raise "Instruction must not be nil" if instruction.nil? C.position_builder_before(self, instruction) self end |
#ptr2int(val, ty, name = "") ⇒ LLVM::Instruction
Cast a pointer to an int. Useful for pointer arithmetic.
682 683 684 |
# File 'lib/llvm/core/builder.rb', line 682 def ptr2int(val, ty, name = "") Instruction.from_ptr(C.build_ptr_to_int(self, val, LLVM::Type(ty), name)) end |
#ptr_diff(lhs, rhs, name = "") ⇒ LLVM::Instruction
Calculate the difference between two pointers
942 943 944 |
# File 'lib/llvm/core/builder.rb', line 942 def ptr_diff(lhs, rhs, name = "") Instruction.from_ptr(C.build_ptr_diff(lhs, rhs, name)) end |
#ret(val) ⇒ LLVM::Instruction
68 69 70 |
# File 'lib/llvm/core/builder.rb', line 68 def ret(val) Instruction.from_ptr(C.build_ret(self, val)) end |
#ret_void ⇒ LLVM::Instruction
61 62 63 |
# File 'lib/llvm/core/builder.rb', line 61 def ret_void Instruction.from_ptr(C.build_ret_void(self)) end |
#sdiv(lhs, rhs, name = "") ⇒ LLVM::Instruction
Signed division
298 299 300 |
# File 'lib/llvm/core/builder.rb', line 298 def sdiv(lhs, rhs, name = "") Instruction.from_ptr(C.build_s_div(self, lhs, rhs, name)) end |
#select(_if, _then, _else, name = "") ⇒ LLVM::Instruction
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.
861 862 863 |
# File 'lib/llvm/core/builder.rb', line 861 def select(_if, _then, _else, name = "") Instruction.from_ptr(C.build_select(self, _if, _then, _else, name)) end |
#sext(val, ty, name = "") ⇒ LLVM::Instruction
Sign extension by copying the sign bit (highest order bit) of the value until it reaches the bit size of the given type.
603 604 605 |
# File 'lib/llvm/core/builder.rb', line 603 def sext(val, ty, name = "") Instruction.from_ptr(C.build_s_ext(self, val, LLVM::Type(ty), name)) end |
#sext_or_bit_cast(val, ty, name = "") ⇒ LLVM::Instruction
723 724 725 |
# File 'lib/llvm/core/builder.rb', line 723 def sext_or_bit_cast(val, ty, name = "") Instruction.from_ptr(C.build_s_ext_or_bit_cast(self, val, LLVM::Type(ty), name)) end |
#shl(lhs, rhs, name = "") ⇒ LLVM::Instruction
Returns An integer instruction.
356 357 358 |
# File 'lib/llvm/core/builder.rb', line 356 def shl(lhs, rhs, name = "") Instruction.from_ptr(C.build_shl(self, lhs, rhs, name)) end |
#shuffle_vector(vec1, vec2, mask, name = "") ⇒ LLVM::Instruction
Shuffle two vectors according to a given mask
895 896 897 |
# File 'lib/llvm/core/builder.rb', line 895 def shuffle_vector(vec1, vec2, mask, name = "") Instruction.from_ptr(C.build_shuffle_vector(self, vec1, vec2, mask, name)) end |
#si2fp(val, ty, name = "") ⇒ LLVM::Instruction
Convert a signed integer to a floating point
649 650 651 |
# File 'lib/llvm/core/builder.rb', line 649 def si2fp(val, ty, name = "") Instruction.from_ptr(C.build_si_to_fp(self, val, LLVM::Type(ty), name)) end |
#srem(lhs, rhs, name = "") ⇒ LLVM::Instruction
Signed remainder
338 339 340 |
# File 'lib/llvm/core/builder.rb', line 338 def srem(lhs, rhs, name = "") Instruction.from_ptr(C.build_s_rem(self, lhs, rhs, name)) end |
#store(val, ptr) ⇒ LLVM::Instruction
Store a value at a given pointer
502 503 504 505 |
# File 'lib/llvm/core/builder.rb', line 502 def store(val, ptr) raise "val must be a Value, got #{val.class.name}" unless Value === val Instruction.from_ptr(C.build_store(self, val, ptr)) end |
#struct_gep(pointer, idx, name = "") ⇒ LLVM::Instruction
Builds a struct getelementptr Instruction.
551 552 553 |
# File 'lib/llvm/core/builder.rb', line 551 def struct_gep(pointer, idx, name = "") Instruction.from_ptr(C.build_struct_gep(self, pointer, idx, name)) end |
#sub(lhs, rhs, name = "") ⇒ LLVM::Instruction
Integer subtraction.
207 208 209 |
# File 'lib/llvm/core/builder.rb', line 207 def sub(lhs, rhs, name = "") Instruction.from_ptr(C.build_sub(self, lhs, rhs, name)) end |
#switch(val, default, cases) ⇒ LLVM::Instruction
121 122 123 124 125 126 127 |
# File 'lib/llvm/core/builder.rb', line 121 def switch(val, default, cases) inst = SwitchInst.from_ptr(C.build_switch(self, val, default, cases.size)) cases.each do |(c, block)| inst.add_case(c, block) end inst end |
#to_ptr ⇒ Object
17 18 19 |
# File 'lib/llvm/core/builder.rb', line 17 def to_ptr @ptr end |
#trunc(val, ty, name = "") ⇒ LLVM::Instruction
Truncates its operand to the given type. The size of the value type must be greater than the size of the target type.
579 580 581 |
# File 'lib/llvm/core/builder.rb', line 579 def trunc(val, ty, name = "") Instruction.from_ptr(C.build_trunc(self, val, LLVM::Type(ty), name)) end |
#trunc_or_bit_cast(val, ty, name = "") ⇒ LLVM::Instruction
733 734 735 |
# File 'lib/llvm/core/builder.rb', line 733 def trunc_or_bit_cast(val, ty, name = "") Instruction.from_ptr(C.build_trunc_or_bit_cast(self, val, LLVM::Type(ty), name)) end |
#udiv(lhs, rhs, name = "") ⇒ LLVM::Instruction
Unsigned integer division
288 289 290 |
# File 'lib/llvm/core/builder.rb', line 288 def udiv(lhs, rhs, name = "") Instruction.from_ptr(C.build_u_div(self, lhs, rhs, name)) end |
#ui2fp(val, ty, name = "") ⇒ LLVM::Instruction
Convert an unsigned integer to a floating point
637 638 639 |
# File 'lib/llvm/core/builder.rb', line 637 def ui2fp(val, ty, name = "") Instruction.from_ptr(C.build_ui_to_fp(self, val, LLVM::Type(ty), name)) end |
#unreachable ⇒ LLVM::Instruction
Generates an instruction with no defined semantics. Can be used to provide hints to the optimizer.
158 159 160 |
# File 'lib/llvm/core/builder.rb', line 158 def unreachable Instruction.from_ptr(C.build_unreachable(self)) end |
#unwind ⇒ Object
Builds an unwind Instruction.
150 151 152 |
# File 'lib/llvm/core/builder.rb', line 150 def unwind Instruction.from_ptr(C.build_unwind(self)) end |
#urem(lhs, rhs, name = "") ⇒ LLVM::Instruction
Unsigned remainder
328 329 330 |
# File 'lib/llvm/core/builder.rb', line 328 def urem(lhs, rhs, name = "") Instruction.from_ptr(C.build_u_rem(self, lhs, rhs, name)) end |
#xor(lhs, rhs, name = "") ⇒ LLVM::Instruction
Returns An integer instruction.
403 404 405 |
# File 'lib/llvm/core/builder.rb', line 403 def xor(lhs, rhs, name = "") Instruction.from_ptr(C.build_xor(self, lhs, rhs, name)) end |
#zext(val, ty, name = "") ⇒ LLVM::Instruction
Zero extends its operand to the given type. The size of the value type must be greater than the size of the target type.
591 592 593 |
# File 'lib/llvm/core/builder.rb', line 591 def zext(val, ty, name = "") Instruction.from_ptr(C.build_z_ext(self, val, LLVM::Type(ty), name)) end |
#zext_or_bit_cast(val, ty, name = "") ⇒ LLVM::Instruction
713 714 715 |
# File 'lib/llvm/core/builder.rb', line 713 def zext_or_bit_cast(val, ty, name = "") Instruction.from_ptr(C.build_z_ext_or_bit_cast(self, val, LLVM::Type(ty), name)) end |