Class: Kumi::IR::Loop::Lower::FunctionLowering
- Inherits:
-
Object
- Object
- Kumi::IR::Loop::Lower::FunctionLowering
- 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
- #call ⇒ Object
-
#initialize(vec_function, plans:, registry:, cross_axes: {}, outer_axes: {}) ⇒ FunctionLowering
constructor
A new instance of FunctionLowering.
Constructor Details
#initialize(vec_function, plans:, registry:, cross_axes: {}, outer_axes: {}) ⇒ FunctionLowering
Returns a new instance of FunctionLowering.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/kumi/ir/loop/lower.rb', line 84 def initialize(vec_function, plans:, registry:, cross_axes: {}, outer_axes: {}) @fn = vec_function @plans = plans @registry = registry @cross_axes = cross_axes || {} @outer_axes = outer_axes || {} @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
#call ⇒ Object
105 106 107 108 109 110 111 112 113 |
# File 'lib/kumi/ir/loop/lower.rb', line 105 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 |