Class: Kumi::IR::Loop::Validator

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

Overview

Enforces the LoopIR execution contract: only execution-shaped ops, balanced loops, and registers defined before use. No vector-semantics ops (map/broadcast/shift/reduce) may survive lowering.

Constant Summary collapse

ALLOWED_OPS =
%i[
  constant
  load_input
  load_field
  kernel_call
  select
  make_object
  ref
  loop_start
  loop_end
  array_init
  array_push
  array_len
  index_read
  shift_read
  shift_in_bounds
  acc_init
  acc_step
  acc_load
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(loop_module) ⇒ Validator

Returns a new instance of Validator.



36
37
38
# File 'lib/kumi/ir/loop/validator.rb', line 36

def initialize(loop_module)
  @loop_module = loop_module
end

Class Method Details

.validate!(loop_module) ⇒ Object



31
32
33
34
# File 'lib/kumi/ir/loop/validator.rb', line 31

def self.validate!(loop_module)
  new(loop_module).validate!
  loop_module
end

Instance Method Details

#validate!Object



40
41
42
# File 'lib/kumi/ir/loop/validator.rb', line 40

def validate!
  loop_module.each_function { |fn| validate_function(fn) }
end