Module: LLVM
- Defined in:
- lib/llvm/config.rb,
lib/llvm.rb,
lib/llvm/core.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/bitcode.rb,
lib/llvm/core/builder.rb,
lib/llvm/core/context.rb,
lib/llvm/transforms/ipo.rb,
lib/llvm/execution_engine.rb,
lib/llvm/core/pass_manager.rb,
lib/llvm/transforms/scalar.rb,
lib/llvm/transforms/builder.rb,
lib/llvm/transforms/vectorize.rb
Overview
Generated by ruby-llvm. Please do not change this file by hand.
Defined Under Namespace
Modules: C, CONFIG, PointerIdentity, Support Classes: Argument, BasicBlock, Builder, CallInst, Constant, ConstantArray, ConstantExpr, ConstantInt, ConstantReal, ConstantStruct, ConstantVector, Context, Double, ExecutionEngine, Float, Function, FunctionPassManager, FunctionType, GenericValue, GlobalAlias, GlobalValue, GlobalVariable, IndirectBr, Instruction, IntType, MCJITCompiler, MemoryBuffer, Module, PassManager, PassManagerBuilder, Phi, StructType, SwitchInst, Target, TargetDataLayout, TargetMachine, Type, User, Value
Constant Summary collapse
- LLVM_VERSION =
"15"
- LLVM_REQUIRED_VERSION =
"15.0"
- RUBY_LLVM_VERSION =
"15.0.1"
- 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
- .Double(val) ⇒ Object
-
.Float(val) ⇒ Object
Create a LLVM::Float from a Ruby Float (val).
-
.Function(argtypes, rettype, options = {}) ⇒ Object
Shortcut to Type.function.
-
.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) ⇒ Object
Shortcut to Type.pointer.
-
.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
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.
215 216 217 |
# File 'lib/llvm/core/type.rb', line 215 def Array(ty, sz = 0) LLVM::Type.array(ty, sz) end |
.const_missing(const) ⇒ Object
512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 |
# File 'lib/llvm/core/value.rb', line 512 def self.const_missing(const) case const.to_s when /Int(\d+)/ width = Regexp.last_match(1).to_i name = "Int#{width}" eval <<-KLASS class #{name} < ConstantInt def self.type Type.from_ptr(C.int_type(#{width}), :integer) end end KLASS const_get(name) else super end end |
.Double(val) ⇒ Object
626 627 628 |
# File 'lib/llvm/core/value.rb', line 626 def self.Double(val) Double.from_f(val) end |
.Float(val) ⇒ Object
Create a LLVM::Float from a Ruby Float (val).
616 617 618 |
# File 'lib/llvm/core/value.rb', line 616 def self.Float(val) Float.from_f(val) end |
.Function(argtypes, rettype, options = {}) ⇒ Object
Shortcut to Type.function.
230 231 232 |
# File 'lib/llvm/core/type.rb', line 230 def Function(argtypes, rettype, = {}) LLVM::Type.function(argtypes, rettype, ) 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).
535 536 537 538 539 540 541 542 543 544 |
# File 'lib/llvm/core/value.rb', line 535 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
33 34 35 36 37 38 39 |
# File 'lib/llvm/support.rb', line 33 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) ⇒ Object
Shortcut to Type.pointer.
220 221 222 |
# File 'lib/llvm/core/type.rb', line 220 def Pointer(ty) LLVM::Type.pointer(ty) end |
.Struct(*elt_types) ⇒ Object
Shortcut to Type.struct.
235 236 237 238 239 240 241 242 |
# File 'lib/llvm/core/type.rb', line 235 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.
207 208 209 210 211 212 |
# File 'lib/llvm/core/type.rb', line 207 def Type(ty) case ty when LLVM::Type then ty else ty.type end end |
.Vector(ty, sz) ⇒ Object
Shortcut to Type.vector.
225 226 227 |
# File 'lib/llvm/core/type.rb', line 225 def Vector(ty, sz) LLVM::Type.vector(ty, sz) end |
.Void ⇒ Object
Shortcut to Type.void.
245 246 247 |
# File 'lib/llvm/core/type.rb', line 245 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.
137 138 139 140 141 |
# File 'lib/llvm/core.rb', line 137 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
.
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/llvm/core.rb', line 113 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 |