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

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

Constant Summary collapse

ZERO_FILLS =
{ "integer" => 0, "float" => 0.0, "boolean" => false, "string" => "" }.freeze

Instance Method Summary collapse

Constructor Details

#initialize(vec_function, plans:, registry:) ⇒ FunctionLowering

Returns a new instance of FunctionLowering.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/kumi/ir/loop/lower.rb', line 65

def initialize(vec_function, plans:, registry:)
  @fn = vec_function
  @plans = plans
  @registry = registry

  @instrs = vec_function.blocks.flat_map(&:instructions)
  @by_reg = @instrs.each_with_object({}) { |i, h| h[i.result] = i if i.result }

  @top = []
  @stack = []
  @memo = Hash.new { |h, k| h[k] = {} }
  @def_sites = {}
  @materialized = {}
  @pending_accs = []
  @axis_table = build_axis_table

  @counter = next_reg_start
end

Instance Method Details

#callObject



84
85
86
87
88
89
90
91
92
# File 'lib/kumi/ir/loop/lower.rb', line 84

def call
  @instrs.each { |instr| lower_instruction(instr) }
  return_reg = emit_return
  close_all

  instructions = flatten(@top)
  block = Base::Block.new(name: :entry, instructions: instructions)
  Loop::Function.new(name: @fn.name, blocks: [block], return_reg: return_reg)
end