Class: LLVM::TargetMachine

Inherits:
Object
  • Object
show all
Includes:
PointerIdentity
Defined in:
lib/llvm/target.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from PointerIdentity

#==, #eql?, #hash, #to_ptr

Class Method Details

.from_ptr(ptr) ⇒ Object



161
162
163
164
165
# File 'lib/llvm/target.rb', line 161

def self.from_ptr(ptr)
  target = allocate
  target.instance_variable_set :@ptr, ptr
  target
end

Instance Method Details

#cpuObject

Returns the CPU used for creating this target machine.



188
189
190
# File 'lib/llvm/target.rb', line 188

def cpu
  C.get_target_machine_cpu(self)
end

#disposeObject

Destroys this instance of TargetMachine.



168
169
170
171
172
173
# File 'lib/llvm/target.rb', line 168

def dispose
  return if @ptr.nil?

  C.dispose_target_machine(self)
  @ptr = nil
end

#emit(mod, filename, codegen = :assembly) ⇒ Object

Emits an asm or object file for the given module.

Parameters:

  • codegen (Symbol) (defaults to: :assembly)

    :assembly, :object



200
201
202
203
204
# File 'lib/llvm/target.rb', line 200

def emit(mod, filename, codegen = :assembly)
  LLVM.with_error_output do |err|
    C.target_machine_emit_to_file(self, mod, filename.to_s, codegen, err)
  end
end

#featuresObject

Returns the feature string used for creating this target machine.



193
194
195
# File 'lib/llvm/target.rb', line 193

def features
  C.get_target_machine_feature_string(self)
end

#targetTarget

Returns the corresponding Target.

Returns:



178
179
180
# File 'lib/llvm/target.rb', line 178

def target
  Target.from_ptr(C.get_target_machine_target(self))
end

#tripleObject

Returns the triple used for creating this target machine.



183
184
185
# File 'lib/llvm/target.rb', line 183

def triple
  C.get_target_machine_triple(self)
end