Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/seed/ng/a64/tests/fusion.om # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / seed / ng / a64 / tests / fusion.om` 199 lines ยท 3579 bytes Raw Blame History 1 note Build with seed/ng/src/ir.om. Generates the deterministic fusion fixture consumed by rgate. 2 note Every comparison and integer type, both branch directions, select operands, and all TBZ bit numbers. 3 global fu_f uint 256 4 global fu_t uint 256 5 global fu_x ulong 256 6 global fu_n uint 1 7 global fu_buf uint 1 8 fn fu_k b uint t uint x ulong to uint 9 ret ir_res ir_op b 1 t x 0 10 end 11 fn fu_bin b uint op uint t uint x uint y uint to uint 12 o = ir_op b op t 0 2 13 ir_set o 0 x 14 ir_set o 1 y 15 ret ir_res o 16 end 17 fn fu_ret b uint tok uint v uint to void 18 o = ir_op b 63 0 0 2 19 ir_set o 0 tok 20 ir_set o 1 v 21 end 22 fn fu_addf f uint t uint to void 23 n = get fu_n 0 24 put fu_f n f 25 put fu_t n t 26 put fu_x n 1 27 put fu_n 0 add n 1 28 end 29 fn fu_cmp t uint op uint sel bool to void 30 f = ir_fnew 0 0 5 31 a = ir_fpar f t 32 b = ir_fpar f t 33 x = ir_blk f 34 u = fu_k x 5 17 35 v = fu_k x 5 23 36 if not sel 37 if or eq op 30 eq op 31 38 b = fu_k x t 0 39 end 40 end 41 c = fu_bin x op 1 a b 42 if sel 43 o = ir_op x 2 5 0 3 44 ir_set o 0 c 45 ir_set o 1 u 46 ir_set o 2 v 47 fu_ret x ir_ftok f ir_res o 48 else 49 bt = ir_blk f 50 bf = ir_blk f 51 o = ir_op x 61 0 0 4 52 ir_set o 0 ir_ftok f 53 ir_set o 1 c 54 ir_set o 2 bt 55 ir_set o 3 bf 56 fu_ret bt ir_btok bt u 57 fu_ret bf ir_btok bf v 58 end 59 fu_addf f t 60 end 61 fn fu_pad b uint to void 62 j = ulong 0 63 while lt j 9000 bound 9000 64 unused = fu_k b 5 j 65 j = add j 1 66 end 67 end 68 fn fu_setbit bit ulong to void 69 k = sub get fu_n 0 1 70 put fu_x k shl ulong 1 bit 71 end 72 fn fu_bit bit ulong op uint to void 73 f = ir_fnew 0 0 5 74 a = ir_fpar f 5 75 b = ir_fpar f 5 76 x = ir_blk f 77 z = fu_k x 5 0 78 m = fu_k x 5 shl ulong 1 bit 79 v = fu_bin x 16 5 a m 80 c = fu_bin x op 1 v z 81 bf = ir_blk f 82 bt = ir_blk f 83 o = ir_op x 61 0 0 4 84 ir_set o 0 ir_ftok f 85 ir_set o 1 c 86 ir_set o 2 bt 87 ir_set o 3 bf 88 fu_ret bt ir_btok bt fu_k bt 5 17 89 if and eq bit 63 eq op 31 90 fu_pad bf 91 end 92 fu_ret bf ir_btok bf fu_k bf 5 23 93 fu_addf f 5 94 fu_setbit bit 95 end 96 fn fu_call b uint tok uint k uint a ulong to uint 97 t = get fu_t k 98 f = get fu_f k 99 v = fu_k b t a 100 z = fu_k b t 0 101 o = ir_op b 64 5 0 4 102 ir_set o 0 tok 103 ir_set o 1 f 104 ir_set o 2 v 105 ir_set o 3 z 106 ret o 107 end 108 fn fu_save b uint t uint k ulong v uint to uint 109 r = get fu_buf 0 110 i = fu_k b 5 k 111 e = fu_k b 5 1 112 o = ir_op b 79 0 3 4 113 ir_set o 0 t 114 ir_set o 1 r 115 ir_set o 2 i 116 ir_set o 3 e 117 q = ir_op b 36 2 0 1 118 ir_set q 0 v 119 p = ir_op b 43 0 0 4 120 ir_set p 0 ir_otok o 121 ir_set p 1 r 122 ir_set p 2 i 123 ir_set p 3 ir_res q 124 ret ir_otok p 125 end 126 fn fu_write b uint t uint to uint 127 r = get fu_buf 0 128 z = fu_k b 5 0 129 n = fu_k b 5 mul ulong get fu_n 0 2 130 o = ir_op b 80 0 3 4 131 ir_set o 0 t 132 ir_set o 1 r 133 ir_set o 2 z 134 ir_set o 3 n 135 fd = fu_k b 8 1 136 q = ir_op b 110 9 54 5 137 ir_set q 0 ir_otok o 138 ir_set q 1 fd 139 ir_set q 2 r 140 ir_set q 3 z 141 ir_set q 4 n 142 ret ir_otok q 143 end 144 fn fu_storage b uint to void 145 arrty = ir_tarr 2 mul get fu_n 0 2 146 rt = ir_tref arrty 1 0 147 g = ir_glob arrty 0 148 put fu_buf 0 ir_res ir_op b 52 rt ulong g 0 149 end 150 fn fu_main to void 151 f = ir_fnew 2 0 8 152 b = ir_blk f 153 fu_storage b 154 t = ir_ftok f 155 s = fu_k b 5 0 156 k = uint 0 157 while lt k get fu_n 0 bound 256 158 q = fu_call b t k get fu_x k 159 t = ir_otok q 160 s = fu_bin b 10 5 s ir_res q 161 t = fu_save b t mul ulong k 2 ir_res q 162 q = fu_call b t k 0 163 t = ir_otok q 164 s = fu_bin b 10 5 s ir_res q 165 t = fu_save b t add mul ulong k 2 1 ir_res q 166 k = add k 1 167 end 168 s = fu_bin b 16 5 s fu_k b 5 255 169 o = ir_op b 36 8 0 1 170 ir_set o 0 s 171 t = fu_write b t 172 fu_ret b t ir_res o 173 end 174 fn main to int 175 ir_init 176 put fu_n 0 0 177 t = uint 2 178 while lt t 10 bound 8 179 op = uint 30 180 while lt op 36 bound 6 181 fu_cmp t op false 182 fu_cmp t op true 183 op = add op 1 184 end 185 t = add t 1 186 end 187 bit = ulong 0 188 while lt bit 64 bound 64 189 fu_bit bit 30 190 fu_bit bit 31 191 bit = add bit 1 192 end 193 fu_main 194 n = ir_wr 195 if eq ar_out 1 1 0 n 0 196 ret 27 197 end 198 ret 0 199 end