class RLTK::CG::Target

Class binding for the LLVM Triple class.

Public Class Methods

first() click to toggle source

@return [Target] First target in the target list

# File lib/rltk/cg/target.rb, line 29
def self.first
        @first ||= self.new(Bindings.get_first_target)
end
host() click to toggle source

@return [Target] Target object for the host architecture.

# File lib/rltk/cg/target.rb, line 34
def self.host
        @host ||= self.new(Triple.host)
end
new(overloaded) click to toggle source

Create an object representing a particular code generation target. You can create a target either from a string or a Triple.

@param [Triple, String] overloaded Object describing the target.

# File lib/rltk/cg/target.rb, line 51
def initialize(overloaded)
        @ptr, @triple =
        case overloaded
        when String
                [Bindings.get_target_from_name(overloaded), Triple.new(overloaded)]

        when RLTK::CG::Triple
                ptr    = FFI::MemoryPointer.new(:pointer)
                error  = FFI::MemoryPointer.new(:pointer)
                status = Bindings.get_target_from_triple(overloaded.to_s, ptr, error)

                if status.zero?
                        [ptr, overloaded]

                else
                        errorp  = error.read_pointer
                        message = errorp.null? ? 'Unknown' : errorp.read_string

                        error.autorelease = false

                        Bindings.dispose_message(error)

                        raise "Error creating target: #{message}"
                end

        when RLTK::CG::Bindings::Triple
                [overloaded, nil]
        end
end
next_target(target) click to toggle source

@return [Target] Next target in the target list

# File lib/rltk/cg/target.rb, line 39
def self.next_target(target)
        self.new(Bindings.get_next_target(target))
end

Public Instance Methods

asm_backend?() click to toggle source

@return [Boolean] Whether or not the target has an ASM backend

# File lib/rltk/cg/target.rb, line 82
def asm_backend?
        Bindings.target_has_asm_backend(@ptr).to_bool
end
describe() click to toggle source

@return [String] Description of the target

# File lib/rltk/cg/target.rb, line 97
def describe
        Bindings.get_target_description(@ptr)
end
jit?() click to toggle source

@return [Boolean] Whether or not the target has a JIT

# File lib/rltk/cg/target.rb, line 87
def jit?
        Bindings.target_has_jit(@ptr).to_bool
end
target_machine?() click to toggle source

@return [Boolean] Whether or not the target has a TargetMachine

# File lib/rltk/cg/target.rb, line 92
def target_machine?
        Bindings.target_has_target_machine(@ptr).to_bool
end
triple() click to toggle source

@return [Triple] Triple object for this target

# File lib/rltk/cg/target.rb, line 102
def triple
        @triple ||= Triple.new(Bindings.get_target_name(@ptr))
end