Class: Kumi::Core::Analyzer::Passes::LIR::InstructionSchedulingPass

Inherits:
PassBase
  • Object
show all
Defined in:
lib/kumi/core/analyzer/passes/lir/instruction_scheduling_pass.rb

Overview

InstructionSchedulingPass


This pass reorders instructions within a block to improve opportunities for other passes, particularly LoopFusionPass. It treats a block of LIR as a graph of atomic items (single instructions or entire loops), builds a dependency graph, and then re-emits the instructions in an optimal order determined by a topological sort.

Defined Under Namespace

Classes: Scheduler

Instance Method Summary collapse

Methods inherited from PassBase

#debug, #debug_enabled?, #initialize

Methods included from ErrorReporting

#inferred_location, #raise_localized_error, #raise_syntax_error, #raise_type_error, #report_enhanced_error, #report_error, #report_semantic_error, #report_syntax_error, #report_type_error

Constructor Details

This class inherits a constructor from Kumi::Core::Analyzer::Passes::PassBase

Instance Method Details

#run(_errors) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/kumi/core/analyzer/passes/lir/instruction_scheduling_pass.rb', line 18

def run(_errors)
  scheduled_module = get_state(:lir_module).transform_values do |decl|
    debug "\n--- Scheduling: Processing declaration: #{decl[:name]} ---"
    { operations: schedule_block(Array(decl[:operations])) }
  end

  state.with(:lir_module, scheduled_module)
end