Class: Kumi::IR::Loop::Lower

Inherits:
Object
  • Object
show all
Defined in:
lib/kumi/ir/loop/lower.rb

Overview

Lowers VecIR into execution-shaped LoopIR.

Input contract (VecIR after VecValidatePass):

  • one entry block per function, SSA registers

  • every instruction stamped with axes and dtype

  • load_input/load_field chains follow the DF access contract

  • reduce over_axes are an innermost suffix of the argument axes

Output contract (enforced by Loop::Validator):

  • explicit loop_start/loop_end nests over axis carrier arrays

  • reductions as acc_init/acc_step/acc_load

  • axis_index as loop index registers

  • axis_shift as shift_read with explicit policy

  • vector values that escape their defining loop are materialized via array_init/array_push and read back with index_read

Defined Under Namespace

Classes: DefSite, FunctionLowering, Instance, LoopNode, PendingAcc

Instance Method Summary collapse

Constructor Details

#initialize(vec_module:, context: {}) ⇒ Lower

Returns a new instance of Lower.



22
23
24
25
# File 'lib/kumi/ir/loop/lower.rb', line 22

def initialize(vec_module:, context: {})
  @vec_module = vec_module
  @context = context
end

Instance Method Details

#callObject



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/kumi/ir/loop/lower.rb', line 27

def call
  plans = @context[:input_plans] || {}
  registry = @context[:registry]

  loop_module = Loop::Module.new(name: @vec_module.name)
  @vec_module.each_function do |vec_function|
    lowering = FunctionLowering.new(vec_function, plans: plans, registry: registry)
    loop_module.add_function(lowering.call)
  end
  loop_module
end