Class: RLTK::CG::TargetMachine
- Includes:
- BindingClass
- Defined in:
- lib/rltk/cg/target.rb
Overview
This class represents a specific architecture that wil be targeted by LLVM’s compilation process.
Instance Attribute Summary
Attributes included from BindingClass
Class Method Summary collapse
-
.build_feature_string(features) ⇒ String
Convert an array of strings representing features of a target machine into a single string.
-
.host ⇒ TargetMachine
TargetMachine representation of the host machine.
Instance Method Summary collapse
-
#initialize(target, mcpu = '', features = '', reloc_model = :default, code_model = :default) ⇒ TargetMachine
constructor
Create a new object describing a target machine.
Methods included from BindingClass
Constructor Details
#initialize(target, mcpu = '', features = '', reloc_model = :default, code_model = :default) ⇒ TargetMachine
Create a new object describing a target machine.
89 90 91 92 93 94 95 96 97 98 |
# File 'lib/rltk/cg/target.rb', line 89 def initialize(target, mcpu = '', features = '', reloc_model = :default, code_model = :default) # Just to make things easier on developers. reloc_model = :default_rmodel if reloc_model == :default code_model = :default_cmodel if code_model == :default # Convert the features parameter if necessary. features = TargetMachine.build_feature_string(features) if features.is_a?(Array) @ptr = Bindings.create_target_machine(target, target.triple.to_s, mcpu, features, reloc_model, code_model) end |
Class Method Details
.build_feature_string(features) ⇒ String
Convert an array of strings representing features of a target machine into a single string.
67 68 69 70 71 72 |
# File 'lib/rltk/cg/target.rb', line 67 def self.build_feature_string(features) strings_ptr = FFI::MemoryPointer.new(:pointer, features.length) strings_ptr.write_array_of_pointer(features.map { |str| FFI::MemoryPointer.from_string(str) }) Bindings.build_features_string(strings_ptr, features.length) end |
.host ⇒ TargetMachine
Returns TargetMachine representation of the host machine.
75 76 77 |
# File 'lib/rltk/cg/target.rb', line 75 def self.host @host ||= self.new(Target.host) end |