Module: LLVM
- Defined in:
- lib/llvm/config.rb,
lib/llvm.rb,
lib/llvm/core.rb,
lib/llvm/lljit.rb,
lib/llvm/linker.rb,
lib/llvm/target.rb,
lib/llvm/support.rb,
lib/llvm/version.rb,
lib/llvm/analysis.rb,
lib/llvm/core/type.rb,
lib/llvm/core/value.rb,
lib/llvm/core/module.rb,
lib/llvm/core_ffi_v2.rb,
lib/llvm/core/bitcode.rb,
lib/llvm/core/builder.rb,
lib/llvm/core/context.rb,
lib/llvm/pass_builder.rb,
lib/llvm/core/attribute.rb,
lib/llvm/transforms/ipo.rb,
lib/llvm/execution_engine.rb,
lib/llvm/transforms/utils.rb,
lib/llvm/core/pass_manager.rb,
lib/llvm/transforms/scalar.rb,
lib/llvm/transforms/vectorize.rb,
lib/llvm/transforms/pass_manager_builder.rb
Overview
Generated by ruby-llvm. Please do not change this file by hand.
Defined Under Namespace
Modules: C, CONFIG, PointerIdentity, Support Classes: Argument, Attribute, BasicBlock, Builder, CallInst, Constant, ConstantArray, ConstantExpr, ConstantInt, ConstantReal, ConstantStruct, ConstantVector, Context, DeprecationError, ExecutionEngine, Function, FunctionPassManager, FunctionType, GenericValue, GlobalAlias, GlobalValue, GlobalVariable, IndirectBr, Instruction, IntType, InvokeInst, LLJit, MCJITCompiler, MemoryBuffer, Module, PassBuilder, PassManager, PassManagerBuilder, Phi, Poison, RealType, StructType, SwitchInst, Target, TargetDataLayout, TargetMachine, Type, User, Value
Constant Summary collapse
- LLVM_VERSION =
"19"
- LLVM_REQUIRED_VERSION =
"19.1.3"
- RUBY_LLVM_VERSION =
"19.1.3"
- Float =
for compatibility
float.freeze
- Double =
double.freeze
- Int =
const_get(:"Int#{bits}")
- TRUE =
Boolean values
::LLVM::Int1.from_i(-1)
- FALSE =
::LLVM::Int1.from_i(0)
- JITCompiler =
MCJITCompiler
Class Method Summary collapse
-
.Array(ty, sz = 0) ⇒ Object
Shortcut to Type.array.
-
.const_missing(const) ⇒ Object
creates LLVM::Int1, LLVM::Int64, etc.
- .double(value = nil) ⇒ Object
-
.Double(value) ⇒ Object
for compatibility Create a double LLVM::ContantReal from a Ruby Float (value).
- .float(value = nil) ⇒ Object
-
.Float(value) ⇒ Object
for compatibility Create a float LLVM::ContantReal from a Ruby Float (value).
-
.Function(argtypes, rettype, options = {}) ⇒ Object
Shortcut to Type.function.
- .i(width, value = nil) ⇒ Object
-
.init_jit(*args) ⇒ Object
A shorthand for Target.init_native.
-
.init_x86 ⇒ Object
deprecated
Deprecated.
Use LLVM.init_jit or LLVM::Target.init(‘X86’).
-
.Int(val) ⇒ Object
Creates a LLVM Int (subclass of ConstantInt) at the NATIVE_INT_SIZE from a integer (val).
- .load_library(libname) ⇒ Object
- .make_generic_value(ty, val) ⇒ Object
-
.Pointer(ty = nil) ⇒ Object
Shortcut to Type.pointer.
- .ptr ⇒ Object
-
.Struct(*elt_types) ⇒ Object
Shortcut to Type.struct.
-
.Type(ty) ⇒ Object
Creates a Type from the given object.
-
.Vector(ty, sz) ⇒ Object
Shortcut to Type.vector.
- .void ⇒ Object
-
.Void ⇒ Object
Shortcut to Type.void.
-
.with_error_output {|FFI::MemoryPointer| ... } ⇒ nil
Same as #with_message_output, but raises a RuntimeError with the resulting message.
-
.with_message_output {|FFI::MemoryPointer| ... } ⇒ String?
Yields a pointer suitable for storing an LLVM output message.
Class Method Details
.Array(ty, sz = 0) ⇒ Object
Shortcut to Type.array.
372 373 374 |
# File 'lib/llvm/core/type.rb', line 372 def Array(ty, sz = 0) LLVM::Type.array(ty, sz) end |
.const_missing(const) ⇒ Object
creates LLVM::Int1, LLVM::Int64, etc
653 654 655 656 657 658 659 660 661 662 663 |
# File 'lib/llvm/core/value.rb', line 653 def self.const_missing(const) case const.to_s when /Int(\d+)/ width = Regexp.last_match(1).to_i name = "Int#{width}" value = LLVM::Type.integer(width).freeze const_set(name, value) else super end end |
.double(value = nil) ⇒ Object
415 416 417 418 |
# File 'lib/llvm/core/type.rb', line 415 def double(value = nil) type = LLVM::Type.double value ? type.from_f(value) : type end |
.Double(value) ⇒ Object
for compatibility Create a double LLVM::ContantReal from a Ruby Float (value).
437 438 439 |
# File 'lib/llvm/core/type.rb', line 437 def Double(value) double(value) end |
.float(value = nil) ⇒ Object
420 421 422 423 |
# File 'lib/llvm/core/type.rb', line 420 def float(value = nil) type = LLVM::Type.float value ? type.from_f(value) : type end |
.Float(value) ⇒ Object
for compatibility Create a float LLVM::ContantReal from a Ruby Float (value).
431 432 433 |
# File 'lib/llvm/core/type.rb', line 431 def Float(value) float(value) end |
.Function(argtypes, rettype, options = {}) ⇒ Object
Shortcut to Type.function.
387 388 389 |
# File 'lib/llvm/core/type.rb', line 387 def Function(argtypes, rettype, = {}) LLVM::Type.function(argtypes, rettype, ) end |
.i(width, value = nil) ⇒ Object
410 411 412 413 |
# File 'lib/llvm/core/type.rb', line 410 def i(width, value = nil) type = LLVM::Type.i(width) value ? type.from_i(value) : type end |
.init_jit(*args) ⇒ Object
A shorthand for LLVM::Target.init_native
9 10 11 |
# File 'lib/llvm/target.rb', line 9 def self.init_jit(*args) LLVM::Target.init_native(*args) end |
.init_x86 ⇒ Object
Use LLVM.init_jit or LLVM::Target.init(‘X86’).
14 15 16 17 |
# File 'lib/llvm/target.rb', line 14 def self.init_x86 warn "LLVM.init_x86 is deprecated. Use LLVM.init_jit or LLVM::Target.init('X86')." LLVM::Target.init('X86') end |
.Int(val) ⇒ Object
Creates a LLVM Int (subclass of ConstantInt) at the NATIVE_INT_SIZE from a integer (val).
670 671 672 673 674 675 676 677 678 679 |
# File 'lib/llvm/core/value.rb', line 670 def self.Int(val) case val when LLVM::ConstantInt then val when Integer then Int.from_i(val) when Value return val if val.type.kind == :integer raise "value not of integer type: #{val.type.kind}" else raise "can't make an LLVM::ConstantInt from #{val.class.name}" end end |
.load_library(libname) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/llvm/support.rb', line 35 def self.load_library(libname) if C.load_library_permanently(libname) != 0 raise "LLVM::Support.load_library failed" end nil end |
.make_generic_value(ty, val) ⇒ Object
314 315 316 317 318 319 320 321 322 323 |
# File 'lib/llvm/execution_engine.rb', line 314 def make_generic_value(ty, val) case ty.kind when :double then GenericValue.from_d(val) when :float then GenericValue.from_f(val) when :pointer then GenericValue.from_value_ptr(val) when :integer then GenericValue.from_i(val, :type => ty) else raise "Unsupported type #{ty.kind}." end end |
.Pointer(ty = nil) ⇒ Object
Shortcut to Type.pointer.
377 378 379 |
# File 'lib/llvm/core/type.rb', line 377 def Pointer(ty = nil) LLVM::Type.pointer(ty) end |
.Struct(*elt_types) ⇒ Object
Shortcut to Type.struct.
392 393 394 395 396 397 398 399 |
# File 'lib/llvm/core/type.rb', line 392 def Struct(*elt_types) name = if elt_types.last.is_a? String elt_types.pop else nil end LLVM::Type.struct(elt_types, false, name) end |
.Type(ty) ⇒ Object
Creates a Type from the given object.
362 363 364 365 366 367 368 369 |
# File 'lib/llvm/core/type.rb', line 362 def Type(ty) case ty when LLVM::Type ty else ty.type end end |
.Vector(ty, sz) ⇒ Object
Shortcut to Type.vector.
382 383 384 |
# File 'lib/llvm/core/type.rb', line 382 def Vector(ty, sz) LLVM::Type.vector(ty, sz) end |
.Void ⇒ Object
Shortcut to Type.void.
402 403 404 |
# File 'lib/llvm/core/type.rb', line 402 def Void LLVM::Type.void end |
.with_error_output {|FFI::MemoryPointer| ... } ⇒ nil
Same as #with_message_output, but raises a RuntimeError with the resulting message.
39 40 41 42 43 |
# File 'lib/llvm/core.rb', line 39 def self.with_error_output(&block) error = (&block) raise error unless error.nil? end |
.with_message_output {|FFI::MemoryPointer| ... } ⇒ String?
Yields a pointer suitable for storing an LLVM output message. If the message pointer is non-NULL (an error has happened), converts the result to a string and returns it. Otherwise, returns nil
.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/llvm/core.rb', line 15 def self. = nil FFI::MemoryPointer.new(FFI.type_size(:pointer)) do |str| result = yield str msg_ptr = str.read_pointer if result != 0 raise "Error is signalled, but msg_ptr is null" if msg_ptr.null? = msg_ptr.read_string C. msg_ptr end end end |