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



158
159
160
161
162
# File 'lib/llvm/target.rb', line 158

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.



185
186
187
# File 'lib/llvm/target.rb', line 185

def cpu
  C.get_target_machine_cpu(self)
end

#data_layoutTargetDataLayout

Returns the data layout used for this target machine.

Returns:



197
198
199
# File 'lib/llvm/target.rb', line 197

def data_layout
  TargetDataLayout.from_ptr(C.get_target_machine_data(self))
end

#disposeObject

Destroys this instance of TargetMachine.



165
166
167
168
169
170
# File 'lib/llvm/target.rb', line 165

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



204
205
206
207
208
# File 'lib/llvm/target.rb', line 204

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.



190
191
192
# File 'lib/llvm/target.rb', line 190

def features
  C.get_target_machine_feature_string(self)
end

#targetTarget

Returns the corresponding Target.

Returns:



175
176
177
# File 'lib/llvm/target.rb', line 175

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

#tripleObject

Returns the triple used for creating this target machine.



180
181
182
# File 'lib/llvm/target.rb', line 180

def triple
  C.get_target_machine_triple(self)
end