Files
aji/tests/conformance/source/layer7/parallel_square.aji.expected
T
dev 179dee3c3a Phase 6A: .aji layer 7 (task scopes, spawn/join, channels)
- scope s { … }: task.scope.begin, task.scope.end at every normal exit
  (scope ends generalized: borrow.end or task.scope.end, innermost first)
- task.spawn(s, f, args): call-like; named linear values moved (E7003);
  lent borrows are bound first (inline borrow E7006); scope operand E7005
- task.join/cancel/cancelled; task<T>, sender<T>, receiver<T>, scope types
- channels: make<T>, dup, send, recv, close_sender, close_receiver; send,
  recv and close_receiver are outcome matches; endpoints by name, borrowed
  for the operation and ended on every edge (written `mut tx`: E7006)
- outcome rebinding: a value coming back under the name of a variable of
  its type becomes the variable's value (pending(r))
- joins carry live variables only (pruned SSA): a linear value consumed
  before a join does not travel to it; ordered after-walk over the
  enclosing statement or tail, sibling arms not counted
- parser: a keyword after `.` is a member name (task.cancelled)
- conformance equivalence ignores schedule.choices (quantum counts AIR
  instructions)
- tests: 10 run tests with AIR equivalence (Phase 3 programs), 12 rejects
  (E4301, E4101 x2, E4002, E2001, E3101, E3002, E7006 x2, E7003, E0006,
  E7005); Quick Reference tasks/channels programs now pass
- spec 15 §4/§6/§7, grammar, quick reference, bundle notes, plan
2026-10-05 17:55:30 +03:00

83 lines
2.0 KiB
Plaintext

module demo.parallelsquare
air 0
lang 0.1
features [arrays, effects, ownership, tasks]
fn @square(%s: slice_mut<u64>) -> void
effects []
entry:
%c_1 = const.usize 0
%len_2 = slice.len %s
br @while_3(%c_1)
while_3(%i_6: usize):
%cmp_8 = lt.usize %i_6, %len_2
cbr %cmp_8, @body_9(), @after_4()
after_4:
ret
step_5(%i_7: usize):
%one_16 = const.usize 1
%i_17 = add.checked.usize %i_7, %one_16
br @while_3(%i_17)
body_9:
%e_10 = borrow.index %s, %i_6
%v_11 = load %e_10
borrow.end %e_10
%e_12 = borrow.index %s, %i_6
%v_13 = load %e_12
borrow.end %e_12
%t_14 = mul.checked.u64 %v_11, %v_13
%e_15 = borrow.index %s, %i_6
store %e_15, %t_14
borrow.end %e_15
br @step_5(%i_6)
fn @main() -> array<u64, 4>
effects [task.spawn]
entry:
%buf_1 = local.alloc array<u64, 4>
local.zero %buf_1
%c_2 = const.u64 1
%buf_3 = borrow.mut %buf_1
%c_4 = const.usize 0
%e_5 = borrow.index %buf_3, %c_4
store %e_5, %c_2
borrow.end %e_5
borrow.end %buf_3
%c_6 = const.u64 2
%buf_7 = borrow.mut %buf_1
%c_8 = const.usize 1
%e_9 = borrow.index %buf_7, %c_8
store %e_9, %c_6
borrow.end %e_9
borrow.end %buf_7
%c_10 = const.u64 3
%buf_11 = borrow.mut %buf_1
%c_12 = const.usize 2
%e_13 = borrow.index %buf_11, %c_12
store %e_13, %c_10
borrow.end %e_13
borrow.end %buf_11
%c_14 = const.u64 4
%buf_15 = borrow.mut %buf_1
%c_16 = const.usize 3
%e_17 = borrow.index %buf_15, %c_16
store %e_17, %c_14
borrow.end %e_17
borrow.end %buf_15
%buf_18 = borrow.mut %buf_1
%s_19 = slice.make %buf_18
%c_20 = const.usize 2
%l_21, %r_22 = slice.split %s_19, %c_20
%sc_23 = task.scope.begin
%t_24 = task.spawn %sc_23, @square(%l_21)
%t_25 = task.spawn %sc_23, @square(%r_22)
task.join %t_24
task.join %t_25
task.scope.end %sc_23
borrow.end %r_22
borrow.end %l_21
borrow.end %s_19
borrow.end %buf_18
%buf_26 = local.load %buf_1
ret %buf_26