Class: LLVM::Builder
- Inherits:
-
Object
- Object
- LLVM::Builder
- Extended by:
- Gem::Deprecate
- Defined in:
- lib/llvm/core/builder.rb
Instance Attribute Summary collapse
-
#ptr ⇒ Object
readonly
: FFI::Pointer?.
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
: (Value, Value, ?String) -> Value.
-
#array_alloca(ty, sz, name = "") ⇒ LLVM::Instruction
Array stack allocation : (Type, Integer, ?String) -> Alloca.
-
#array_malloc(ty, sz, name = "") ⇒ LLVM::Instruction
: (Type, Integer, ?String) -> Value.
-
#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 : (Value, Type, ?String) -> Value.
-
#br(block) ⇒ LLVM::Instruction
Unconditional branching (i.e. goto) : (BasicBlock) -> Value.
-
#call(fun, *args) ⇒ Object
Builds a call Instruction.
-
#call2(type, fun, *args) ⇒ Object
: (Type, untyped, *Value) -> CallInst.
-
#cond(cond, iftrue, iffalse) ⇒ LLVM::Instruction
Conditional branching (i.e. if) : (Value, BasicBlock, BasicBlock) -> Value.
-
#dispose ⇒ Object
: -> void.
-
#exact_sdiv(lhs, rhs, name = "") ⇒ LLVM::Instruction
Signed exact division : (Value, Value, ?String) -> Value.
-
#extract_element(vector, idx, name = "") ⇒ LLVM::Instruction
Extract an element from a vector : (Value, Value, ?String) -> Value.
-
#extract_value(aggregate, idx, name = "") ⇒ LLVM::Instruction
Extract the value of a member field from an aggregate value : (Value, Integer, ?String) -> Value.
-
#fadd(lhs, rhs, name = "") ⇒ LLVM::Instruction
: (Value, Value, ?String) -> Value.
-
#fcmp(pred, lhs, rhs, name = "") ⇒ LLVM::Instruction
Builds an fcmp Instruction.
-
#fdiv(lhs, rhs, name = "") ⇒ LLVM::Instruction
: (Value, Value, ?String) -> Value.
-
#fmul(lhs, rhs, name = "") ⇒ LLVM::Instruction
Floating point multiplication : (Value, Value, ?String) -> Value.
-
#fneg(lhs, name = "") ⇒ LLVM::Instruction
The ‘fneg’ instruction returns the negation of its operand.
-
#fp2si(val, ty, name = "") ⇒ LLVM::Instruction
Convert a floating point to a signed integer : (Value, Type, ?String) -> Value.
-
#fp2ui(val, ty, name = "") ⇒ LLVM::Instruction
Convert a floating point to an unsigned integer : (Value, Type, ?String) -> Value.
-
#fp_cast(val, ty, name = "") ⇒ LLVM::Instruction
: (Value, Type, ?String) -> Value.
-
#fp_ext(val, ty, name = "") ⇒ LLVM::Instruction
Extend a floating point value : (Value, Type, ?String) -> Value.
-
#fp_trunc(val, ty, name = "") ⇒ LLVM::Instruction
Truncate a floating point value : (Value, Type, ?String) -> Value.
-
#free(ptr) ⇒ LLVM::Instruction
: (Value) -> Value.
-
#frem(lhs, rhs, name = "") ⇒ LLVM::Instruction
: (Value, Value, ?String) -> Value.
-
#fsub(lhs, rhs, name = "") ⇒ LLVM::Instruction
: (Value, Value, ?String) -> Value.
-
#gep(ptr, indices, name = "") ⇒ LLVM::Instruction
Obtain a pointer to the element at the given indices may return Instruction or GlobalVariable : (Value, [Value], ?String) -> Value.
-
#gep2(type, ptr, indices, name = '') ⇒ LLVM::Instruction
Obtain a pointer to the element at the given indices may return Instruction or GlobalVariable : (Type?, Value, [Value], ?String) -> Value.
-
#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) : (BasicBlock, Integer) -> Value.
-
#icmp(pred, lhs, rhs, name = "") ⇒ LLVM::Instruction
Builds an icmp Instruction.
-
#inbounds_gep(ptr, indices, name = "") ⇒ LLVM::Instruction
Builds a inbounds getelementptr instruction.
-
#inbounds_gep2(type, ptr, indices, name = "") ⇒ Object
: (Type?, Value, [Value], ?String) -> Value.
-
#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 : (Value, Value, Value, ?String) -> Value.
-
#insert_value(aggregate, elem, idx, name = "") ⇒ LLVM::Instruction
Insert a value into an aggregate value’s member field : (Value, Value, Integer, ?String) -> Value.
-
#int2ptr(val, ty, name = "") ⇒ LLVM::Instruction
Cast an int to a pointer : (Value, Type, ?String) -> Value.
-
#int_cast(val, ty, name = "") ⇒ LLVM::Instruction
: (Value, Type, ?String) -> Value.
-
#int_cast2(val, ty, signed, name = "") ⇒ LLVM::Instruction
: (Value, Type, bool, ?String) -> Value.
-
#invoke(fun, args, normal, exception, name = "") ⇒ LLVM::Instruction
Invoke a function which may potentially unwind : (untyped, [Value], BasicBlock, BasicBlock, ?String) -> InvokeInst.
-
#invoke2(type, fun, args, normal, exception, name = "") ⇒ Object
: (Type?, untyped, [Value], BasicBlock, BasicBlock, ?String) -> InvokeInst.
-
#is_not_null(val, name = "") ⇒ LLVM::Instruction
Check if a value is not null : (Value, ?String) -> Value.
-
#is_null(val, name = "") ⇒ LLVM::Instruction
Check if a value is null rubocop:disable Naming/PredicatePrefix : (Value, ?String) -> Value.
-
#landing_pad(type, personality_function, num_clauses, name = '') ⇒ Object
: (Type, untyped, Integer, ?String) -> Value.
-
#landing_pad_cleanup(type, personality_function, num_clauses, name = '') ⇒ Object
: (Type, untyped, Integer, ?String) -> Value.
-
#load(ptr, name = "") ⇒ LLVM::Instruction
Load the value of a given pointer : (Value, ?String) -> Value.
-
#load2(type, ptr, name = "") ⇒ Object
: (Type?, Value, ?String) -> Value.
-
#lshr(lhs, rhs, name = "") ⇒ LLVM::Instruction
Shifts right with zero fill.
-
#malloc(ty, name = "") ⇒ LLVM::Instruction
: (Type, ?String) -> Value.
-
#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 deprecated Deprecated.
-
#nuw_sub(lhs, rhs, name = "") ⇒ LLVM::Instruction
No unsigned wrap integer subtraction.
-
#or(lhs, rhs, name = "") ⇒ LLVM::Instruction
: (Value, Value, ?String) -> Value.
-
#phi(ty, incoming, name = "") ⇒ LLVM::Instruction
Build a Phi node of the given type with the given incoming branches : (Type, Hash[BasicBlock, Value], ?String) -> Value.
-
#pointer_cast(val, ty, name = "") ⇒ LLVM::Instruction
Cast pointer to other type : (Value, Type, ?String) -> Value.
-
#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 : (Value, Value, ?String) -> Value.
-
#ptr_diff2(type, lhs, rhs, name = "") ⇒ Object
: (Type?, Value, Value, ?String) -> Value.
-
#ret(val = nil) ⇒ LLVM::Instruction
: (?Value?) -> Value.
-
#ret_void ⇒ LLVM::Instruction
: -> Value.
-
#sdiv(lhs, rhs, name = "") ⇒ LLVM::Instruction
Signed division : (Value, Value, ?String) -> Value.
-
#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
: (Value, Type, ?String) -> Value.
-
#shl(lhs, rhs, name = "") ⇒ LLVM::Instruction
: (Value, Value, ?String) -> Value.
-
#shuffle_vector(vec1, vec2, mask, name = "") ⇒ LLVM::Instruction
Shuffle two vectors according to a given mask : (Value, Value, Value, ?String) -> Value.
-
#si2fp(val, ty, name = "") ⇒ LLVM::Instruction
Convert a signed integer to a floating point : (Value, Type, ?String) -> Value.
-
#srem(lhs, rhs, name = "") ⇒ LLVM::Instruction
Signed remainder : (Value, Value, ?String) -> Value.
-
#store(val, ptr) ⇒ LLVM::Instruction
Store a value at a given pointer : (Value, Value) -> Value.
-
#struct_gep(ptr, idx, name = "") ⇒ LLVM::Instruction
Builds a struct getelementptr Instruction.
-
#struct_gep2(type, ptr, idx, name = "") ⇒ Object
: (Type?, Value, Value, ?String) -> Value.
-
#sub(lhs, rhs, name = "") ⇒ LLVM::Instruction
Integer subtraction.
-
#switch(val, default, cases) ⇒ LLVM::Instruction
: (Value, BasicBlock, Hash[Value, BasicBlock]) -> Value.
-
#to_ptr ⇒ Object
: -> FFI::Pointer?.
-
#trunc(val, ty, name = "") ⇒ LLVM::Instruction
Truncates its operand to the given type.
-
#trunc_or_bit_cast(val, ty, name = "") ⇒ LLVM::Instruction
: (Value, Type, ?String) -> Value.
-
#udiv(lhs, rhs, name = "") ⇒ LLVM::Instruction
Unsigned integer division : (Value, Value, ?String) -> Value.
-
#ui2fp(val, ty, name = "") ⇒ LLVM::Instruction
Convert an unsigned integer to a floating point : (Value, Type, ?String) -> Value.
-
#unreachable ⇒ LLVM::Instruction
Generates an instruction with no defined semantics.
-
#unwind ⇒ Object
Builds an unwind Instruction.
-
#urem(lhs, rhs, name = "") ⇒ LLVM::Instruction
Unsigned remainder : (Value, Value, ?String) -> Value.
-
#xor(lhs, rhs, name = "") ⇒ LLVM::Instruction
: (Value, Value, ?String) -> Value.
-
#zext(val, ty, name = "") ⇒ LLVM::Instruction
Zero extends its operand to the given type.
-
#zext_or_bit_cast(val, ty, name = "") ⇒ LLVM::Instruction
: (Value, Type, ?String) -> Value.
Constructor Details
#initialize ⇒ Builder
Important: Call #dispose to free backend memory after use. : -> void
10 11 12 13 |
# File 'lib/llvm/core/builder.rb', line 10 def initialize @ptr = C.create_builder() #: FFI::Pointer? raise RuntimeError if @ptr.null? || ptr.nil? end |
Instance Attribute Details
#ptr ⇒ Object (readonly)
: FFI::Pointer?
16 17 18 |
# File 'lib/llvm/core/builder.rb', line 16 def ptr @ptr end |
Instance Method Details
#add(lhs, rhs, name = "") ⇒ LLVM::Instruction
Integer addition. : (Value, Value, ?String) -> Value
251 252 253 |
# File 'lib/llvm/core/builder.rb', line 251 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. : (*Value) -> Value
102 103 104 105 106 107 |
# File 'lib/llvm/core/builder.rb', line 102 def aggregate_ret(*vals) FFI::MemoryPointer.new(FFI.type_size(:pointer) * vals.size) do |vals_ptr| vals_ptr.write_array_of_pointer(vals) return Instruction.from_ptr(C.build_aggregate_ret(self, vals_ptr, vals.size)) end #: as Value end |
#alloca(ty, name = "") ⇒ LLVM::Instruction
Stack allocation. : (Type, ?String) -> Alloca
601 602 603 |
# File 'lib/llvm/core/builder.rb', line 601 def alloca(ty, name = "") Alloca.from_ptr(C.build_alloca(self, LLVM::Type(ty), name)) #: as Alloca end |
#and(lhs, rhs, name = "") ⇒ LLVM::Instruction
: (Value, Value, ?String) -> Value
501 502 503 |
# File 'lib/llvm/core/builder.rb', line 501 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 : (Type, Integer, ?String) -> Alloca
613 614 615 |
# File 'lib/llvm/core/builder.rb', line 613 def array_alloca(ty, sz, name = "") Alloca.from_ptr(C.build_array_alloca(self, LLVM::Type(ty), sz, name)) #: as Alloca end |
#array_malloc(ty, sz, name = "") ⇒ LLVM::Instruction
: (Type, Integer, ?String) -> Value
582 583 584 585 586 587 588 589 590 591 592 |
# File 'lib/llvm/core/builder.rb', line 582 def array_malloc(ty, sz, name = "") size = case sz when LLVM::Value sz when Integer LLVM.i(32, sz) else raise ArgumentError, "Unknown size parameter for array_malloc: #{sz}" end Instruction.from_ptr(C.build_array_malloc(self, LLVM::Type(ty), size, name)) end |
#ashr(lhs, rhs, name = "") ⇒ LLVM::Instruction
Arithmatic shift right. : (Value, Value, ?String) -> Value
491 492 493 |
# File 'lib/llvm/core/builder.rb', line 491 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 : (Value, Type, ?String) -> Value
912 913 914 |
# File 'lib/llvm/core/builder.rb', line 912 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) : (BasicBlock) -> Value
114 115 116 117 118 |
# File 'lib/llvm/core/builder.rb', line 114 def br(block) raise ArgumentError, "Trying to build LLVM br with non-block: #{block.inspect}" if !block.is_a?(LLVM::BasicBlock) 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).
: (untyped, *Value) -> CallInst
1067 1068 1069 1070 1071 1072 1073 |
# File 'lib/llvm/core/builder.rb', line 1067 def call(fun, *args) call2( nil, fun, *args #: untyped ) end |
#call2(type, fun, *args) ⇒ Object
: (Type, untyped, *Value) -> CallInst
1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 |
# File 'lib/llvm/core/builder.rb', line 1093 def call2(type, fun, *args) type, fun = call2_infer_function_and_type(type, fun) name = if args.last.kind_of? String args.pop else "" end args_ptr = FFI::MemoryPointer.new(FFI.type_size(:pointer) * args.size) args_ptr.write_array_of_pointer(args) ins = C.build_call2(self, type, fun, args_ptr, args.size, name) call_inst = CallInst.from_ptr(ins) #: as CallInst if fun.is_a?(Function) call_inst.call_conv = fun.call_conv end call_inst end |
#cond(cond, iftrue, iffalse) ⇒ LLVM::Instruction
Conditional branching (i.e. if) : (Value, BasicBlock, BasicBlock) -> Value
138 139 140 141 142 143 144 145 146 |
# File 'lib/llvm/core/builder.rb', line 138 def cond(cond, iftrue, iffalse) raise ArgumentError, "Trying to build LLVM cond br with non-block (true branch): #{iftrue.inspect}" if !iftrue.is_a?(LLVM::BasicBlock) raise ArgumentError, "Trying to build LLVM cond br with non-block (false branch): #{iffalse.inspect}" if !iffalse.is_a?(LLVM::BasicBlock) cond2 = cond_condition(cond) Instruction.from_ptr(C.build_cond_br(self, cond2, iftrue, iffalse)) end |
#dispose ⇒ Object
: -> void
19 20 21 22 23 |
# File 'lib/llvm/core/builder.rb', line 19 def dispose return if @ptr.nil? C.dispose_builder(@ptr) @ptr = nil end |
#exact_sdiv(lhs, rhs, name = "") ⇒ LLVM::Instruction
Signed exact division : (Value, Value, ?String) -> Value
405 406 407 |
# File 'lib/llvm/core/builder.rb', line 405 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 : (Value, Value, ?String) -> Value
1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 |
# File 'lib/llvm/core/builder.rb', line 1139 def extract_element(vector, idx, name = "") must_be_value!(vector) must_be_value!(idx) error = element_error(vector, idx) raise ArgumentError, "Error building extract_element with #{error}" if error ins = C.build_extract_element(self, vector, idx, name) Instruction.from_ptr(ins) end |
#extract_value(aggregate, idx, name = "") ⇒ LLVM::Instruction
Extract the value of a member field from an aggregate value : (Value, Integer, ?String) -> Value
1190 1191 1192 1193 1194 1195 1196 1197 1198 |
# File 'lib/llvm/core/builder.rb', line 1190 def extract_value(aggregate, idx, name = "") must_be_value!(aggregate) error = value_error(aggregate, idx) raise ArgumentError, "Error building extract_value with #{error}" if error ins = C.build_extract_value(self, aggregate, idx, name) Instruction.from_ptr(ins) end |
#fadd(lhs, rhs, name = "") ⇒ LLVM::Instruction
: (Value, Value, ?String) -> Value
283 284 285 |
# File 'lib/llvm/core/builder.rb', line 283 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
: (Symbol, Value, Value, ?String) -> Value
1039 1040 1041 |
# File 'lib/llvm/core/builder.rb', line 1039 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
: (Value, Value, ?String) -> Value
416 417 418 |
# File 'lib/llvm/core/builder.rb', line 416 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 : (Value, Value, ?String) -> Value
372 373 374 |
# File 'lib/llvm/core/builder.rb', line 372 def fmul(lhs, rhs, name = "") Instruction.from_ptr(C.build_f_mul(self, lhs, rhs, name)) end |
#fneg(lhs, name = "") ⇒ LLVM::Instruction
The ‘fneg’ instruction returns the negation of its operand. llvm.org/docs/LangRef.html#fneg-instruction : (Value, ?String) -> Value
459 460 461 |
# File 'lib/llvm/core/builder.rb', line 459 def fneg(lhs, name = "") Instruction.from_ptr(C.build_f_neg(self, lhs, name)) end |
#fp2si(val, ty, name = "") ⇒ LLVM::Instruction
Convert a floating point to a signed integer : (Value, Type, ?String) -> Value
827 828 829 |
# File 'lib/llvm/core/builder.rb', line 827 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 : (Value, Type, ?String) -> Value
815 816 817 |
# File 'lib/llvm/core/builder.rb', line 815 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
: (Value, Type, ?String) -> Value
983 984 985 |
# File 'lib/llvm/core/builder.rb', line 983 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 : (Value, Type, ?String) -> Value
877 878 879 |
# File 'lib/llvm/core/builder.rb', line 877 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 : (Value, Type, ?String) -> Value
865 866 867 |
# File 'lib/llvm/core/builder.rb', line 865 def fp_trunc(val, ty, name = "") Instruction.from_ptr(C.build_fp_trunc(self, val, LLVM::Type(ty), name)) end |
#free(ptr) ⇒ LLVM::Instruction
: (Value) -> Value
620 621 622 |
# File 'lib/llvm/core/builder.rb', line 620 def free(ptr) Instruction.from_ptr(C.build_free(self, ptr)) end |
#frem(lhs, rhs, name = "") ⇒ LLVM::Instruction
: (Value, Value, ?String) -> Value
448 449 450 |
# File 'lib/llvm/core/builder.rb', line 448 def frem(lhs, rhs, name = "") Instruction.from_ptr(C.build_f_rem(self, lhs, rhs, name)) end |
#fsub(lhs, rhs, name = "") ⇒ LLVM::Instruction
: (Value, Value, ?String) -> Value
327 328 329 |
# File 'lib/llvm/core/builder.rb', line 327 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 may return Instruction or GlobalVariable : (Value, [Value], ?String) -> Value
667 668 669 |
# File 'lib/llvm/core/builder.rb', line 667 def gep(ptr, indices, name = "") gep2(nil, ptr, indices, name) end |
#gep2(type, ptr, indices, name = '') ⇒ LLVM::Instruction
Obtain a pointer to the element at the given indices may return Instruction or GlobalVariable : (Type?, Value, [Value], ?String) -> Value
682 683 684 685 686 687 688 689 690 691 692 693 694 |
# File 'lib/llvm/core/builder.rb', line 682 def gep2(type, ptr, indices, name = '') must_be_value!(ptr) type ||= must_infer_type!(ptr) must_be_type!(type) indices = Array(indices) FFI::MemoryPointer.new(FFI.type_size(:pointer) * indices.size) do |indices_ptr| indices_ptr.write_array_of_pointer(indices) ins = C.build_gep2(self, type, ptr, indices_ptr, indices.size, name) return Instruction.from_ptr(ins) end #: as Value end |
#global_string(string, name = "") ⇒ LLVM::Instruction
Creates a global string initialized to a given value. : (String, ?String) -> Value
755 756 757 |
# File 'lib/llvm/core/builder.rb', line 755 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. : (String, ?String) -> Value
764 765 766 |
# File 'lib/llvm/core/builder.rb', line 764 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) : (BasicBlock, Integer) -> Value
126 127 128 129 |
# File 'lib/llvm/core/builder.rb', line 126 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
: (Symbol, Value, Value, ?String) -> Value
1008 1009 1010 |
# File 'lib/llvm/core/builder.rb', line 1008 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. : (Value, [Value], ?String) -> Value
706 707 708 |
# File 'lib/llvm/core/builder.rb', line 706 def inbounds_gep(ptr, indices, name = "") inbounds_gep2(nil, ptr, indices, name) end |
#inbounds_gep2(type, ptr, indices, name = "") ⇒ Object
: (Type?, Value, [Value], ?String) -> Value
711 712 713 714 715 716 717 718 719 720 721 722 723 |
# File 'lib/llvm/core/builder.rb', line 711 def inbounds_gep2(type, ptr, indices, name = "") must_be_value!(ptr) type ||= must_infer_type!(ptr) must_be_type!(type) indices = Array(indices) FFI::MemoryPointer.new(FFI.type_size(:pointer) * indices.size) do |indices_ptr| indices_ptr.write_array_of_pointer(indices) ins = C.build_inbounds_gep2(self, type, ptr, indices_ptr, indices.size, name) return Instruction.from_ptr(ins) end #: as Value end |
#insert_block ⇒ LLVM::BasicBlock
The BasicBlock at which the Builder is currently positioned.
: -> BasicBlock
74 75 76 |
# File 'lib/llvm/core/builder.rb', line 74 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 : (Value, Value, Value, ?String) -> Value
1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 |
# File 'lib/llvm/core/builder.rb', line 1158 def insert_element(vector, elem, idx, name = "") must_be_value!(vector) must_be_value!(elem) must_be_value!(idx) error = element_error(vector, idx) raise ArgumentError, "Error building insert_element with #{error}" if error ins = C.build_insert_element(self, vector, elem, idx, name) Instruction.from_ptr(ins) end |
#insert_value(aggregate, elem, idx, name = "") ⇒ LLVM::Instruction
Insert a value into an aggregate value’s member field : (Value, Value, Integer, ?String) -> Value
1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 |
# File 'lib/llvm/core/builder.rb', line 1208 def insert_value(aggregate, elem, idx, name = "") must_be_value!(aggregate) must_be_value!(elem) error = value_error(aggregate, idx) raise ArgumentError, "Error building insert_value with #{error}" if error ins = C.build_insert_value(self, aggregate, elem, idx, name) Instruction.from_ptr(ins) end |
#int2ptr(val, ty, name = "") ⇒ LLVM::Instruction
Cast an int to a pointer : (Value, Type, ?String) -> Value
901 902 903 |
# File 'lib/llvm/core/builder.rb', line 901 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
: (Value, Type, ?String) -> Value
964 965 966 |
# File 'lib/llvm/core/builder.rb', line 964 def int_cast(val, ty, name = "") Instruction.from_ptr(C.build_int_cast(self, val, LLVM::Type(ty), name)) end |
#int_cast2(val, ty, signed, name = "") ⇒ LLVM::Instruction
: (Value, Type, bool, ?String) -> Value
974 975 976 |
# File 'lib/llvm/core/builder.rb', line 974 def int_cast2(val, ty, signed, name = "") Instruction.from_ptr(C.build_int_cast2(self, val, LLVM::Type(ty), signed, name)) end |
#invoke(fun, args, normal, exception, name = "") ⇒ LLVM::Instruction
Invoke a function which may potentially unwind : (untyped, [Value], BasicBlock, BasicBlock, ?String) -> InvokeInst
192 193 194 |
# File 'lib/llvm/core/builder.rb', line 192 def invoke(fun, args, normal, exception, name = "") invoke2(nil, fun, args, normal, exception, name) end |
#invoke2(type, fun, args, normal, exception, name = "") ⇒ Object
: (Type?, untyped, [Value], BasicBlock, BasicBlock, ?String) -> InvokeInst
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/llvm/core/builder.rb', line 197 def invoke2(type, fun, args, normal, exception, name = "") type, fun = call2_infer_function_and_type(type, fun) arg_count = args.size invoke_ins = nil #: InvokeInst? FFI::MemoryPointer.new(FFI.type_size(:pointer) * arg_count) do |args_ptr| args_ptr.write_array_of_pointer(args) ins = C.build_invoke2(self, type, fun, args_ptr, arg_count, normal, exception, name) invoke_ins = InvokeInst.from_ptr(ins) #: as InvokeInst end if fun.is_a?(Function) invoke_ins.call_conv = fun.call_conv end invoke_ins #: as !nil end |
#is_not_null(val, name = "") ⇒ LLVM::Instruction
Check if a value is not null : (Value, ?String) -> Value
1234 1235 1236 |
# File 'lib/llvm/core/builder.rb', line 1234 def is_not_null(val, name = "") # rubocop:disable Naming/PredicatePrefix Instruction.from_ptr(C.build_is_not_null(self, val, name)) end |
#is_null(val, name = "") ⇒ LLVM::Instruction
Check if a value is null rubocop:disable Naming/PredicatePrefix : (Value, ?String) -> Value
1225 1226 1227 |
# File 'lib/llvm/core/builder.rb', line 1225 def is_null(val, name = "") Instruction.from_ptr(C.build_is_null(self, val, name)) end |
#landing_pad(type, personality_function, num_clauses, name = '') ⇒ Object
: (Type, untyped, Integer, ?String) -> Value
217 218 219 |
# File 'lib/llvm/core/builder.rb', line 217 def landing_pad(type, personality_function, num_clauses, name = '') C.build_landing_pad(self, type, personality_function, num_clauses, name) end |
#landing_pad_cleanup(type, personality_function, num_clauses, name = '') ⇒ Object
: (Type, untyped, Integer, ?String) -> Value
222 223 224 225 226 |
# File 'lib/llvm/core/builder.rb', line 222 def landing_pad_cleanup(type, personality_function, num_clauses, name = '') lp = landing_pad(type, personality_function, num_clauses, name) C.set_cleanup(lp, 1) lp end |
#load(ptr, name = "") ⇒ LLVM::Instruction
Load the value of a given pointer : (Value, ?String) -> Value
631 632 633 |
# File 'lib/llvm/core/builder.rb', line 631 def load(ptr, name = "") load2(nil, ptr, name) end |
#load2(type, ptr, name = "") ⇒ Object
: (Type?, Value, ?String) -> Value
636 637 638 639 640 641 642 643 644 |
# File 'lib/llvm/core/builder.rb', line 636 def load2(type, ptr, name = "") must_be_value!(ptr) type ||= infer_type(ptr) must_be_type!(type) load = C.build_load2(self, type, ptr, name) Instruction.from_ptr(load) end |
#lshr(lhs, rhs, name = "") ⇒ LLVM::Instruction
Shifts right with zero fill. : (Value, Value, ?String) -> Value
480 481 482 |
# File 'lib/llvm/core/builder.rb', line 480 def lshr(lhs, rhs, name = "") Instruction.from_ptr(C.build_l_shr(self, lhs, rhs, name)) end |
#malloc(ty, name = "") ⇒ LLVM::Instruction
: (Type, ?String) -> Value
572 573 574 |
# File 'lib/llvm/core/builder.rb', line 572 def malloc(ty, name = "") Instruction.from_ptr(C.build_malloc(self, LLVM::Type(ty), name)) end |
#mul(lhs, rhs, name = "") ⇒ LLVM::Instruction
Integer multiplication. : (Value, Value, ?String) -> Value
338 339 340 |
# File 'lib/llvm/core/builder.rb', line 338 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.
: (Value, ?String) -> Value
532 533 534 |
# File 'lib/llvm/core/builder.rb', line 532 def neg(arg, name = "") Instruction.from_ptr(C.build_neg(self, arg, name)) end |
#not(arg, name = "") ⇒ LLVM::Instruction
Boolean negation. : (Value, ?String) -> Value
563 564 565 |
# File 'lib/llvm/core/builder.rb', line 563 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. : (Value, Value, ?String) -> Value
262 263 264 |
# File 'lib/llvm/core/builder.rb', line 262 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. : (Value, Value, ?String) -> Value
349 350 351 |
# File 'lib/llvm/core/builder.rb', line 349 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. : (Value, ?String) -> Value
542 543 544 |
# File 'lib/llvm/core/builder.rb', line 542 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. : (Value, Value, ?String) -> Value
305 306 307 |
# File 'lib/llvm/core/builder.rb', line 305 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. : (Value, Value, ?String) -> Value
273 274 275 |
# File 'lib/llvm/core/builder.rb', line 273 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. : (Value, Value, ?String) -> Value
360 361 362 |
# File 'lib/llvm/core/builder.rb', line 360 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. : (Value, ?String) -> Value
553 554 555 |
# File 'lib/llvm/core/builder.rb', line 553 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. : (Value, Value, ?String) -> Value
316 317 318 |
# File 'lib/llvm/core/builder.rb', line 316 def nuw_sub(lhs, rhs, name = "") Instruction.from_ptr(C.build_nuw_sub(self, lhs, rhs, name)) end |
#or(lhs, rhs, name = "") ⇒ LLVM::Instruction
: (Value, Value, ?String) -> Value
511 512 513 |
# File 'lib/llvm/core/builder.rb', line 511 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 : (Type, Hash[BasicBlock, Value], ?String) -> Value
1053 1054 1055 1056 1057 |
# File 'lib/llvm/core/builder.rb', line 1053 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
Cast pointer to other type : (Value, Type, ?String) -> Value
955 956 957 |
# File 'lib/llvm/core/builder.rb', line 955 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.
: (BasicBlock, Instruction) -> self
37 38 39 40 41 42 43 44 |
# File 'lib/llvm/core/builder.rb', line 37 def position(block, instruction) raise ArgumentError, "Block must be LLVM::BasicBlock" if !block.is_a?(LLVM::BasicBlock) raise ArgumentError, "Instruction must be LLVM::Instruction" if !instruction.is_a?(LLVM::Instruction) C.position_builder(self, block, instruction) self end |
#position_at_end(block) ⇒ LLVM::Builder
Positions the builder at the end of the given BasicBlock.
: (BasicBlock) -> self
63 64 65 66 67 68 |
# File 'lib/llvm/core/builder.rb', line 63 def position_at_end(block) raise ArgumentError, "Block must be LLVM::BasicBlock" if !block.is_a?(LLVM::BasicBlock) C.position_builder_at_end(self, block) self end |
#position_before(instruction) ⇒ LLVM::Builder
Positions the builder before the given Instruction.
: (Instruction) -> self
51 52 53 54 55 56 |
# File 'lib/llvm/core/builder.rb', line 51 def position_before(instruction) raise ArgumentError, "Instruction must be LLVM::Instruction" if !instruction.is_a?(LLVM::Instruction) C.position_builder_before(self, instruction) self end |
#ptr2int(val, ty, name = "") ⇒ LLVM::Instruction
Cast a pointer to an int. Useful for pointer arithmetic. : (Value, Type, ?String) -> Value
889 890 891 |
# File 'lib/llvm/core/builder.rb', line 889 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 : (Value, Value, ?String) -> Value
1245 1246 1247 |
# File 'lib/llvm/core/builder.rb', line 1245 def ptr_diff(lhs, rhs, name = "") ptr_diff2(nil, lhs, rhs, name) end |
#ptr_diff2(type, lhs, rhs, name = "") ⇒ Object
: (Type?, Value, Value, ?String) -> Value
1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 |
# File 'lib/llvm/core/builder.rb', line 1250 def ptr_diff2(type, lhs, rhs, name = "") must_be_value!(lhs) must_be_value!(rhs) type ||= begin lhs_type = must_infer_type!(lhs) rhs_type = must_infer_type!(lhs) raise ArgumentError, "ptr_diff types must match: [#{lhs_type}] [#{rhs_type}]" if lhs_type != rhs_type lhs_type end must_be_type!(type) Instruction.from_ptr(C.build_ptr_diff2(self, type, lhs, rhs, name)) end |
#ret(val = nil) ⇒ LLVM::Instruction
: (?Value?) -> Value
89 90 91 92 93 94 95 |
# File 'lib/llvm/core/builder.rb', line 89 def ret(val = nil) unless [LLVM::Value, NilClass].any? { |c| val.is_a?(c) } raise ArgumentError, "Trying to build LLVM ret with non-value: #{val.inspect}" end Instruction.from_ptr(C.build_ret(self, val)) end |
#ret_void ⇒ LLVM::Instruction
: -> Value
81 82 83 |
# File 'lib/llvm/core/builder.rb', line 81 def ret_void Instruction.from_ptr(C.build_ret_void(self)) end |
#sdiv(lhs, rhs, name = "") ⇒ LLVM::Instruction
Signed division : (Value, Value, ?String) -> Value
394 395 396 |
# File 'lib/llvm/core/builder.rb', line 394 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. : (Value, Value, Value, ?String) -> Value
1127 1128 1129 |
# File 'lib/llvm/core/builder.rb', line 1127 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. : (Value, Type, ?String) -> Value
803 804 805 |
# File 'lib/llvm/core/builder.rb', line 803 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
: (Value, Type, ?String) -> Value
934 935 936 |
# File 'lib/llvm/core/builder.rb', line 934 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
: (Value, Value, ?String) -> Value
469 470 471 |
# File 'lib/llvm/core/builder.rb', line 469 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 : (Value, Value, Value, ?String) -> Value
1179 1180 1181 |
# File 'lib/llvm/core/builder.rb', line 1179 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 : (Value, Type, ?String) -> Value
853 854 855 |
# File 'lib/llvm/core/builder.rb', line 853 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 : (Value, Value, ?String) -> Value
438 439 440 |
# File 'lib/llvm/core/builder.rb', line 438 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 : (Value, Value) -> Value
652 653 654 655 |
# File 'lib/llvm/core/builder.rb', line 652 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(ptr, idx, name = "") ⇒ LLVM::Instruction
Builds a struct getelementptr Instruction.
: (Value, Value, ?String) -> Value
735 736 737 |
# File 'lib/llvm/core/builder.rb', line 735 def struct_gep(ptr, idx, name = "") struct_gep2(nil, ptr, idx, name) end |
#struct_gep2(type, ptr, idx, name = "") ⇒ Object
: (Type?, Value, Value, ?String) -> Value
740 741 742 743 744 745 746 747 748 |
# File 'lib/llvm/core/builder.rb', line 740 def struct_gep2(type, ptr, idx, name = "") must_be_value!(ptr) type ||= must_infer_type!(ptr) must_be_type!(type) ins = C.build_struct_gep2(self, type, ptr, idx.to_i, name) Instruction.from_ptr(ins) end |
#sub(lhs, rhs, name = "") ⇒ LLVM::Instruction
Integer subtraction. : (Value, Value, ?String) -> Value
294 295 296 |
# File 'lib/llvm/core/builder.rb', line 294 def sub(lhs, rhs, name = "") Instruction.from_ptr(C.build_sub(self, lhs, rhs, name)) end |
#switch(val, default, cases) ⇒ LLVM::Instruction
: (Value, BasicBlock, Hash[Value, BasicBlock]) -> Value
174 175 176 177 178 179 180 |
# File 'lib/llvm/core/builder.rb', line 174 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
: -> FFI::Pointer?
27 28 29 |
# File 'lib/llvm/core/builder.rb', line 27 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. : (Value, Type, ?String) -> Value
777 778 779 |
# File 'lib/llvm/core/builder.rb', line 777 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
: (Value, Type, ?String) -> Value
945 946 947 |
# File 'lib/llvm/core/builder.rb', line 945 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 : (Value, Value, ?String) -> Value
383 384 385 |
# File 'lib/llvm/core/builder.rb', line 383 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 : (Value, Type, ?String) -> Value
840 841 842 |
# File 'lib/llvm/core/builder.rb', line 840 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. : -> Value
240 241 242 |
# File 'lib/llvm/core/builder.rb', line 240 def unreachable Instruction.from_ptr(C.build_unreachable(self)) end |
#unwind ⇒ Object
Builds an unwind Instruction. : -> void
231 232 233 |
# File 'lib/llvm/core/builder.rb', line 231 def unwind raise DeprecationError end |
#urem(lhs, rhs, name = "") ⇒ LLVM::Instruction
Unsigned remainder : (Value, Value, ?String) -> Value
427 428 429 |
# File 'lib/llvm/core/builder.rb', line 427 def urem(lhs, rhs, name = "") Instruction.from_ptr(C.build_u_rem(self, lhs, rhs, name)) end |
#xor(lhs, rhs, name = "") ⇒ LLVM::Instruction
: (Value, Value, ?String) -> Value
521 522 523 |
# File 'lib/llvm/core/builder.rb', line 521 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. : (Value, Type, ?String) -> Value
790 791 792 |
# File 'lib/llvm/core/builder.rb', line 790 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
: (Value, Type, ?String) -> Value
923 924 925 |
# File 'lib/llvm/core/builder.rb', line 923 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 |