164 lines
4.7 KiB
LLVM
164 lines
4.7 KiB
LLVM
; expect: run
|
|
; result: 42
|
|
; phase: 1
|
|
; spec: docs/spec/07a-air-instructions.md §2
|
|
module runtime.siblings
|
|
air 0
|
|
lang 0.1
|
|
features [arrays, effects, ownership]
|
|
|
|
type @Empty = struct {}
|
|
type @Pair = struct { flag: bool, values: array<u16, 3> }
|
|
type @Nest = struct { empty: @Empty, pairs: array<@Pair, 2>, tail: u16 }
|
|
|
|
fn @main() -> u16
|
|
effects []
|
|
entry:
|
|
%n_1 = local.alloc @Nest
|
|
local.zero %n_1
|
|
%n_2 = borrow.ref %n_1
|
|
%pairs_3 = borrow.field @Nest.pairs, %n_2
|
|
%c_4 = const.usize 0
|
|
%e_5 = borrow.index %pairs_3, %c_4
|
|
%v_6 = load %e_5
|
|
borrow.end %e_5
|
|
borrow.end %pairs_3
|
|
borrow.end %n_2
|
|
%flag_7 = struct.get @Pair.flag, %v_6
|
|
%c_8 = const.bool true
|
|
cbr %flag_7, @or_end_10(%c_8), @or_rhs_9()
|
|
or_rhs_9:
|
|
%n_12 = borrow.ref %n_1
|
|
%pairs_13 = borrow.field @Nest.pairs, %n_12
|
|
%c_14 = const.usize 1
|
|
%e_15 = borrow.index %pairs_13, %c_14
|
|
%v_16 = load %e_15
|
|
borrow.end %e_15
|
|
borrow.end %pairs_13
|
|
borrow.end %n_12
|
|
%flag_17 = struct.get @Pair.flag, %v_16
|
|
br @or_end_10(%flag_17)
|
|
or_end_10(%or_11: bool):
|
|
cbr %or_11, @then_18(), @else_19()
|
|
then_18:
|
|
%c_20 = const.u16 1
|
|
ret %c_20
|
|
else_19:
|
|
br @endif_21()
|
|
endif_21:
|
|
%n_22 = borrow.ref %n_1
|
|
%pairs_23 = borrow.field @Nest.pairs, %n_22
|
|
%c_24 = const.usize 0
|
|
%e_25 = borrow.index %pairs_23, %c_24
|
|
%values_26 = borrow.field @Pair.values, %e_25
|
|
%c_27 = const.usize 0
|
|
%e_28 = borrow.index %values_26, %c_27
|
|
%v_29 = load %e_28
|
|
borrow.end %e_28
|
|
borrow.end %values_26
|
|
borrow.end %e_25
|
|
borrow.end %pairs_23
|
|
borrow.end %n_22
|
|
%n_30 = borrow.ref %n_1
|
|
%pairs_31 = borrow.field @Nest.pairs, %n_30
|
|
%c_32 = const.usize 0
|
|
%e_33 = borrow.index %pairs_31, %c_32
|
|
%values_34 = borrow.field @Pair.values, %e_33
|
|
%c_35 = const.usize 1
|
|
%e_36 = borrow.index %values_34, %c_35
|
|
%v_37 = load %e_36
|
|
borrow.end %e_36
|
|
borrow.end %values_34
|
|
borrow.end %e_33
|
|
borrow.end %pairs_31
|
|
borrow.end %n_30
|
|
%t_38 = add.checked.u16 %v_29, %v_37
|
|
%n_39 = borrow.ref %n_1
|
|
%pairs_40 = borrow.field @Nest.pairs, %n_39
|
|
%c_41 = const.usize 0
|
|
%e_42 = borrow.index %pairs_40, %c_41
|
|
%values_43 = borrow.field @Pair.values, %e_42
|
|
%c_44 = const.usize 2
|
|
%e_45 = borrow.index %values_43, %c_44
|
|
%v_46 = load %e_45
|
|
borrow.end %e_45
|
|
borrow.end %values_43
|
|
borrow.end %e_42
|
|
borrow.end %pairs_40
|
|
borrow.end %n_39
|
|
%t_47 = add.checked.u16 %t_38, %v_46
|
|
%n_48 = borrow.ref %n_1
|
|
%pairs_49 = borrow.field @Nest.pairs, %n_48
|
|
%c_50 = const.usize 1
|
|
%e_51 = borrow.index %pairs_49, %c_50
|
|
%values_52 = borrow.field @Pair.values, %e_51
|
|
%c_53 = const.usize 0
|
|
%e_54 = borrow.index %values_52, %c_53
|
|
%v_55 = load %e_54
|
|
borrow.end %e_54
|
|
borrow.end %values_52
|
|
borrow.end %e_51
|
|
borrow.end %pairs_49
|
|
borrow.end %n_48
|
|
%t_56 = add.checked.u16 %t_47, %v_55
|
|
%n_57 = borrow.ref %n_1
|
|
%pairs_58 = borrow.field @Nest.pairs, %n_57
|
|
%c_59 = const.usize 1
|
|
%e_60 = borrow.index %pairs_58, %c_59
|
|
%values_61 = borrow.field @Pair.values, %e_60
|
|
%c_62 = const.usize 1
|
|
%e_63 = borrow.index %values_61, %c_62
|
|
%v_64 = load %e_63
|
|
borrow.end %e_63
|
|
borrow.end %values_61
|
|
borrow.end %e_60
|
|
borrow.end %pairs_58
|
|
borrow.end %n_57
|
|
%t_65 = add.checked.u16 %t_56, %v_64
|
|
%n_66 = borrow.ref %n_1
|
|
%pairs_67 = borrow.field @Nest.pairs, %n_66
|
|
%c_68 = const.usize 1
|
|
%e_69 = borrow.index %pairs_67, %c_68
|
|
%values_70 = borrow.field @Pair.values, %e_69
|
|
%c_71 = const.usize 2
|
|
%e_72 = borrow.index %values_70, %c_71
|
|
%v_73 = load %e_72
|
|
borrow.end %e_72
|
|
borrow.end %values_70
|
|
borrow.end %e_69
|
|
borrow.end %pairs_67
|
|
borrow.end %n_66
|
|
%t_74 = add.checked.u16 %t_65, %v_73
|
|
%n_75 = local.load %n_1
|
|
%tail_76 = struct.get @Nest.tail, %n_75
|
|
%t_77 = add.checked.u16 %t_74, %tail_76
|
|
%c_78 = const.u16 42
|
|
%n_79 = borrow.mut %n_1
|
|
%pairs_80 = borrow.field @Nest.pairs, %n_79
|
|
%c_81 = const.usize 0
|
|
%e_82 = borrow.index %pairs_80, %c_81
|
|
%values_83 = borrow.field @Pair.values, %e_82
|
|
%c_84 = const.usize 1
|
|
%e_85 = borrow.index %values_83, %c_84
|
|
store %e_85, %c_78
|
|
borrow.end %e_85
|
|
borrow.end %values_83
|
|
borrow.end %e_82
|
|
borrow.end %pairs_80
|
|
borrow.end %n_79
|
|
%n_86 = borrow.ref %n_1
|
|
%pairs_87 = borrow.field @Nest.pairs, %n_86
|
|
%c_88 = const.usize 0
|
|
%e_89 = borrow.index %pairs_87, %c_88
|
|
%values_90 = borrow.field @Pair.values, %e_89
|
|
%c_91 = const.usize 1
|
|
%e_92 = borrow.index %values_90, %c_91
|
|
%v_93 = load %e_92
|
|
borrow.end %e_92
|
|
borrow.end %values_90
|
|
borrow.end %e_89
|
|
borrow.end %pairs_87
|
|
borrow.end %n_86
|
|
%t_94 = add.checked.u16 %t_77, %v_93
|
|
ret %t_94
|