Class: RLTK::CG::PassManager
- Includes:
- BindingClass
- Defined in:
- lib/rltk/cg/pass_manager.rb
Overview
A PassManager is responsible for scheduling and running optimization passes on modules.
Direct Known Subclasses
Constant Summary collapse
- CLASS_FINALIZER =
The Proc object called by the garbage collector to free resources used by LLVM.
Proc.new { |id| Bindings.dispose_pass_manager(ptr) if ptr = ObjectSpace._id2ref(id).ptr }
- PASSES =
A list of passes that are available to be added to the pass manager via the #add method.
{ :ADCE => :agressive_dce, :AlwaysInline => :always_inliner, :ArgPromote => :argument_promotion, :BasicAliasAnalysis => :basic_alias_analysis, :CFGSimplify => :cfg_simplification, :ConstMerge => :constant_merge, :ConstProp => :constant_propagation, :CorValProp => :correlated_value_propagation, :DAE => :dead_arg_elimination, :DSE => :dead_store_elimination, :DemoteMemToReg => :demote_memory_to_register, :EarlyCSE => :early_cse, :FunctionAttrs => :function_attrs, :FunctionInline => :function_inlining, :GDCE => :global_dce, :GlobalOpt => :global_optimizer, :GVN => :gvn, :Internalize => :internalize, :IndVarSimplify => :ind_var_simplify, :InstCombine => :instruction_combining, :IPConstProp => :ip_constant_propagation, :IPSCCP => :ipsccp, :JumpThreading => :jump_threading, :LICM => :licm, :LoopDeletion => :loop_deletion, :LoopIdiom => :loop_idiom, :LoopRotate => :loop_rotate, :LoopUnroll => :loop_unroll, :LoopUnswitch => :loop_unswitch, :LEI => :lower_expect_intrinsics, :MemCopyOpt => :mem_cpy_opt, :PromoteMemToReg => :promote_memory_to_register, :PruneEH => :prune_eh, :Reassociate => :reassociate, :SCCP => :sccp, :ScalarRepl => :scalar_repl_aggregates, :SimplifyLibCalls => :simplify_lib_calls, :StripDeadProtos => :strip_dead_prototypes, :StripSymbols => :strip_symbols, :TailCallElim => :tail_call_elimination, :TBAA => :type_based_alias_analysis, :Verifier => :verifier }
Instance Attribute Summary
Attributes included from BindingClass
Instance Method Summary collapse
-
#add(*names) ⇒ PassManager
(also: #<<)
Add a pass or passes to this pass manager.
-
#enabled ⇒ Array<Symbol>
List of passes that have been enabled.
-
#enabled?(name) ⇒ Boolean
Weather the pass has been enabled or not.
-
#initialize(mod) ⇒ PassManager
constructor
Create a new pass manager.
-
#run ⇒ void
Run the enabled passes on the execution engine’s module.
-
#target_data=(data) ⇒ void
Set the target data for this pass manager.
Methods included from BindingClass
Constructor Details
#initialize(mod) ⇒ PassManager
Create a new pass manager. You should never have to do this as Modules should create PassManagers for you whenever they are requested.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/rltk/cg/pass_manager.rb', line 81 def initialize(mod) # LLVM Initialization @ptr = Bindings.create_pass_manager @mod = mod # Set the target data if the module is associated with a execution engine. self.target_data = mod.engine.target_data if mod.engine # RLTK Initialization @enabled = Array.new # Define a finalizer to free the memory used by LLVM for this # pass manager. ObjectSpace.define_finalizer(self, CLASS_FINALIZER) end |
Instance Method Details
#add(*names) ⇒ PassManager Also known as: <<
Add a pass or passes to this pass manager. Passes may either be specified via the keys for the PASSES hash or any string that will be turned into a string (via the Bindings.get_bname method) appearing as a value of the PASSES hash.
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/rltk/cg/pass_manager.rb', line 107 def add(*names) names.each do |name| name = name.to_sym if PASSES.has_key?(name) next if @enabled.include?(name) Bindings.send("add_#{PASSES[name]}_pass", @ptr) @enabled << name elsif PASSES.has_value?(bname = Bindings.get_bname(name)) next if @enabled.include?(PASSES.key(bname)) Bindings.send("add_#{bname}_pass", @ptr) @enabled << PASSES.key(bname) else raise "Unknown pass: #{name}" end end self end |
#enabled ⇒ Array<Symbol>
Returns List of passes that have been enabled.
135 136 137 |
# File 'lib/rltk/cg/pass_manager.rb', line 135 def enabled @enabled.clone end |
#enabled?(name) ⇒ Boolean
Returns Weather the pass has been enabled or not.
140 141 142 |
# File 'lib/rltk/cg/pass_manager.rb', line 140 def enabled?(name) @enabled.include?(name) or @enabled.include?(PASSES.key(Bindings.get_bname(name))) end |
#run ⇒ void
This method returns an undefined value.
Run the enabled passes on the execution engine’s module.
147 148 149 |
# File 'lib/rltk/cg/pass_manager.rb', line 147 def run Bindings.run_pass_manager(@ptr, @mod).to_bool end |
#target_data=(data) ⇒ void
This method returns an undefined value.
Set the target data for this pass manager.
156 157 158 |
# File 'lib/rltk/cg/pass_manager.rb', line 156 def target_data=(data) Bindings.add_target_data(check_type(data, TargetData, 'data'), @ptr) end |