CUDApp
CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.
Brought by drakestapleton
CUDApp / om / components / staged.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Native unsolved port of omega_blackwell_codegen_gemm.c at b759afc3. |
| 3 | note spec16 frozen:0K,1laneBytes,2MT,3warps,4rowmap,5mutant0,6..15reserved0. |
| 4 | note Bounded subset:MT1/2/4/8,NJ=MT*LB/warps<=8,rowmap MT<=4. |
| 5 | note K<=16384;KS even or<=3;LB8/16;warps power2<=32;shared<=16384. |
| 6 | note stats:instruction count,virtual GPR count,virtual UGPR count,shared bytes. |
| 7 | note No allocation/encoding here. Caller runs the shared global allocator once. |
| 8 | note Exact C decode masks/shift provenance:decode_byte lines149..157. |
| 9 | note Exact SB3/4 prefetch/control provenance:ldw_pf/consume lines123..129. |
| 10 | note Source formulas are translated verbatim; no numerical output oracle invented. |
| 11 | fn sg_kind idx ulong to ulong |
| 12 | if eq idx 0 |
| 13 | ret 2 |
| 14 | end |
| 15 | ret 3 |
| 16 | end |
| 17 | fn sg_clear ins edit ulong 8192 m edit ulong 2048 stats edit ulong 4 to void |
| 18 | for k ulong 8192 |
| 19 | put ins k 0 |
| 20 | end |
| 21 | for k ulong 2048 |
| 22 | put m k 0 |
| 23 | end |
| 24 | for k ulong 4 |
| 25 | put stats k 0 |
| 26 | end |
| 27 | end |
| 28 | fn sg_valid spec view ulong 16 to bool |
| 29 | if or eq get spec 0 0 gt get spec 0 16384 |
| 30 | ret false |
| 31 | end |
| 32 | if and ne get spec 1 8 ne get spec 1 16 |
| 33 | ret false |
| 34 | end |
| 35 | if and ne get spec 2 1 and ne get spec 2 2 and ne get spec 2 4 ne get spec 2 8 |
| 36 | ret false |
| 37 | end |
| 38 | if or eq get spec 3 0 gt get spec 3 32 |
| 39 | ret false |
| 40 | end |
| 41 | if eq bc_log get spec 3 BCNONE |
| 42 | ret false |
| 43 | end |
| 44 | if ne rem get spec 0 mul get spec 1 32 0 |
| 45 | ret false |
| 46 | end |
| 47 | if ne rem mul get spec 2 get spec 1 get spec 3 0 |
| 48 | ret false |
| 49 | end |
| 50 | if gt div mul get spec 2 get spec 1 get spec 3 8 |
| 51 | ret false |
| 52 | end |
| 53 | if gt mul mul get spec 2 128 get spec 1 16384 |
| 54 | ret false |
| 55 | end |
| 56 | ks = div get spec 0 mul get spec 1 32 |
| 57 | if and ne rem ks 2 0 gt ks 3 |
| 58 | ret false |
| 59 | end |
| 60 | if or gt get spec 4 1 and eq get spec 4 1 gt get spec 2 4 |
| 61 | ret false |
| 62 | end |
| 63 | for k ulong 11 |
| 64 | if ne get spec add k 5 0 |
| 65 | ret false |
| 66 | end |
| 67 | end |
| 68 | ret true |
| 69 | end |
| 70 | note r0pseg1px2py3n4stride5tid6cx7cy8warp9lane10one11tent12wbase13sbase14rc. |
| 71 | note r15row0 16cnt17tpass18passes19wlane20slane21xl22nm1 23ysn24mrow25off4 26sa0 27base28z. |
| 72 | note r29pxm30pym31rg32over33t1 34d35tmp36rgc37lo38pw39ps40pyrg41rowp42rem43pc. |
| 73 | note r44xrp45xs46pwc47psc48cntk49pyr50pya51t52tq53fl54sv. |
| 74 | note r56..63xb64..67yi68xso69ma70u71a72sg73onef74dum. |
| 75 | note r76..83acc84..91dot92..95xq96..97wq98..99sc100..103fr. |
| 76 | note r104pwn105psn106sa107nf108inc109inc2 110..113xv114..117xa. |
| 77 | fn sg_regs m edit ulong 2048 s edit ulong 64 r edit ulong 128 to void |
| 78 | uv = bc_vreg s m 2 true |
| 79 | for k ulong 29 |
| 80 | w = ulong 1 |
| 81 | if or lt k 3 and ge k 11 le k 14 |
| 82 | w = 2 |
| 83 | end |
| 84 | put r k bc_vreg s m w false |
| 85 | end |
| 86 | if eq get s 36 1 |
| 87 | put r 29 bc_vreg s m 2 false |
| 88 | put r 30 bc_vreg s m 2 false |
| 89 | end |
| 90 | end |
| 91 | fn sg_loopregs m edit ulong 2048 s edit ulong 64 r edit ulong 128 to void |
| 92 | for k ulong 24 |
| 93 | idx = add k 31 |
| 94 | w = ulong 1 |
| 95 | if or and ge idx 38 le idx 40 and ge idx 44 le idx 47 |
| 96 | w = 2 |
| 97 | end |
| 98 | if or eq idx 49 eq idx 50 |
| 99 | w = 2 |
| 100 | end |
| 101 | put r idx bc_vreg s m w false |
| 102 | end |
| 103 | if eq get s 36 1 |
| 104 | for j ulong get s 39 |
| 105 | put r add j 56 bc_vreg s m 2 false |
| 106 | end |
| 107 | for j ulong get s 34 |
| 108 | put r add j 64 bc_vreg s m 1 false |
| 109 | end |
| 110 | put r 68 bc_vreg s m 1 false |
| 111 | put r 69 bc_vreg s m 2 false |
| 112 | end |
| 113 | for j ulong 5 |
| 114 | put r add j 70 bc_vreg s m 1 false |
| 115 | end |
| 116 | for j ulong get s 34 |
| 117 | put r add j 76 bc_vreg s m 1 false |
| 118 | put r add j 84 bc_vreg s m 1 false |
| 119 | end |
| 120 | for j ulong 4 |
| 121 | put r add j 92 bc_vreg s m 4 false |
| 122 | end |
| 123 | for j ulong 2 |
| 124 | put r add j 96 bc_vreg s m div get s 33 4 false |
| 125 | put r add j 98 bc_vreg s m 1 false |
| 126 | end |
| 127 | for j ulong 4 |
| 128 | put r add j 100 bc_vreg s m 1 false |
| 129 | end |
| 130 | end |
| 131 | fn sg_load ins edit ulong 8192 s edit ulong 64 op ulong d ulong off ulong kind ulong to void |
| 132 | bc_node s op d BCNONE BCNONE BCNONE |
| 133 | put s 22 off |
| 134 | if eq op 7 |
| 135 | put s 23 1 |
| 136 | end |
| 137 | bc_emit ins s kind |
| 138 | end |
| 139 | fn sg_prologue ins edit ulong 8192 s edit ulong 64 r view ulong 128 to void |
| 140 | sg_load ins s 7 0 856 4 |
| 141 | for k ulong 5 |
| 142 | op = ulong 5 |
| 143 | off = add ulong 896 mul k 8 |
| 144 | if ge k 3 |
| 145 | op = 4 |
| 146 | off = add ulong 920 mul sub k 3 4 |
| 147 | end |
| 148 | sg_load ins s op get r k off 2 |
| 149 | end |
| 150 | if eq get s 36 1 |
| 151 | sg_load ins s 5 get r 29 928 2 |
| 152 | sg_load ins s 5 get r 30 936 2 |
| 153 | end |
| 154 | for k ulong 3 |
| 155 | sr = ulong 33 |
| 156 | if eq k 1 |
| 157 | sr = 37 |
| 158 | end |
| 159 | if eq k 2 |
| 160 | sr = 38 |
| 161 | end |
| 162 | sg_load ins s 3 get r add k 5 sr 2 |
| 163 | end |
| 164 | bc_inst ins s 2 get r 10 BCNONE 1 |
| 165 | bc_shift ins s get r 8 get r 5 0 5 |
| 166 | bc_mask ins s get r 9 get r 5 0 31 |
| 167 | bc_wide ins s get r 11 get r 7 get r 0 32 |
| 168 | for k ulong 3 |
| 169 | put s 8 mul k 8 |
| 170 | bc_mem ins s 56 get r add k 12 get r 11 sg_kind k |
| 171 | end |
| 172 | put s 8 1 |
| 173 | put s 9 0 |
| 174 | bc_imad ins s 8 get r 15 get r 14 BCNONE |
| 175 | put s 9 1 |
| 176 | bc_imad ins s 8 get r 16 get r 14 BCNONE |
| 177 | bc_imm ins s get r 17 get r 10 get r 16 sub get s 34 1 |
| 178 | bc_shift ins s get r 18 get r 17 0 get s 43 |
| 179 | bc_imm ins s get r 28 get r 10 get r 16 4294967295 |
| 180 | bc_shift ins s get r 28 get r 28 0 31 |
| 181 | bc_pred ins s get r 28 get r 10 |
| 182 | put s 46 bc_branch ins s add get s 0 1 true |
| 183 | bc_imm ins s get r 19 get r 9 BCNONE get s 33 |
| 184 | bc_shift ins s get r 20 get r 9 0 get s 42 |
| 185 | bc_imm ins s get r 20 get r 20 BCNONE 4 |
| 186 | bc_imm ins s get r 21 get r 9 BCNONE 16 |
| 187 | bc_imm ins s get r 22 get r 10 get r 3 4294967295 |
| 188 | bc_imm ins s get r 23 get r 3 BCNONE 4 |
| 189 | bc_shift ins s get r 24 get r 5 0 get s 44 |
| 190 | bc_mask ins s get r 25 get r 5 0 sub get s 40 1 |
| 191 | bc_imm ins s get r 25 get r 25 BCNONE 4 |
| 192 | bc_imm ins s get r 26 get r 5 BCNONE 4 |
| 193 | bc_imm ins s get r 27 get r 6 BCNONE get s 35 |
| 194 | end |
| 195 | fn sg_row ins edit ulong 8192 s edit ulong 64 r view ulong 128 to void |
| 196 | put s 47 get s 0 |
| 197 | bc_pred ins s get r 27 get r 3 |
| 198 | put s 48 bc_branch ins s add get s 0 1 true |
| 199 | bc_imm ins s get r 31 get r 27 get r 8 1 |
| 200 | bc_imm ins s get r 33 get r 31 get r 22 4294967295 |
| 201 | bc_shift ins s get r 32 get r 33 0 31 |
| 202 | bc_imm ins s get r 34 get r 22 get r 31 4294967295 |
| 203 | bc_node s 8 get r 35 get r 32 get r 34 BCNONE |
| 204 | bc_emit ins s 0 |
| 205 | bc_imm ins s get r 36 get r 35 get r 31 4294967295 |
| 206 | bc_wide ins s get r 38 get r 36 get r 12 get s 32 |
| 207 | bc_wide ins s get r 38 get r 19 get r 38 1 |
| 208 | bc_shift ins s get r 35 get r 36 0 7 |
| 209 | bc_wide ins s get r 39 get r 35 get r 13 mul div get s 32 128 4 |
| 210 | bc_wide ins s get r 39 get r 20 get r 39 1 |
| 211 | bc_wide ins s get r 40 get r 31 get r 2 4 |
| 212 | bc_imm ins s get r 37 get r 32 get r 9 1 |
| 213 | bc_imm ins s get r 41 get r 15 BCNONE 1 |
| 214 | bc_imm ins s get r 42 get r 16 BCNONE 1 |
| 215 | bc_imm ins s get r 43 get r 18 BCNONE 1 |
| 216 | end |
| 217 | note Prefetch is an existing IR instruction with explicit control, never encoded bytes. |
| 218 | fn sg_pref ins edit ulong 8192 s edit ulong 64 op ulong d ulong a ulong sb ulong to void |
| 219 | bc_node s op d a BCNONE BCNONE |
| 220 | put s 21 0 |
| 221 | ctrl = bc_control 4 sb 1 and get s 1 2 true |
| 222 | put s 22 shl ctrl 32 |
| 223 | put s 1 or get s 1 2 |
| 224 | put s 2 or get s 2 shl ulong 1 sb |
| 225 | if ge get s 0 1024 |
| 226 | put s 3 1 |
| 227 | ret |
| 228 | end |
| 229 | for k ulong 8 |
| 230 | put ins add mul get s 0 8 k get s add k 16 |
| 231 | end |
| 232 | put s 0 add get s 0 1 |
| 233 | end |
| 234 | fn sg_consume s edit ulong 64 sb ulong to void |
| 235 | mask = shl ulong 1 sb |
| 236 | put s 1 or get s 1 and get s 2 mask |
| 237 | put s 2 and get s 2 not mask |
| 238 | end |
| 239 | fn sg_pass ins edit ulong 8192 s edit ulong 64 r view ulong 128 to void |
| 240 | put s 49 get s 0 |
| 241 | bc_imm ins s get r 51 get r 41 get r 24 1 |
| 242 | if eq get s 36 0 |
| 243 | bc_wide ins s get r 44 get r 51 get r 1 mul get s 32 4 |
| 244 | bc_wide ins s get r 44 get r 25 get r 44 1 |
| 245 | bc_wide ins s get r 45 get r 10 get r 44 0 |
| 246 | else |
| 247 | for j ulong get s 39 |
| 248 | put s 8 div mul j get s 41 get s 40 |
| 249 | bc_imm ins s get r 52 get r 10 get r 51 get s 8 |
| 250 | bc_wide ins s get r 69 get r 52 get r 29 4 |
| 251 | put s 8 0 |
| 252 | bc_mem ins s 11 get r add j 56 get r 69 sg_kind j |
| 253 | end |
| 254 | for j ulong get s 39 |
| 255 | put s 8 mul get s 32 4 |
| 256 | bc_wide ins s get r add j 56 get r add j 56 get r 1 get s 8 |
| 257 | bc_wide ins s get r add j 56 get r 25 get r add j 56 1 |
| 258 | put s 8 mul j get s 41 |
| 259 | put s 8 rem get s 8 get s 40 |
| 260 | put s 8 mul get s 8 4 |
| 261 | bc_wide ins s get r add j 56 get r 10 get r add j 56 get s 8 |
| 262 | end |
| 263 | bc_inst ins s 2 get r 68 BCNONE 0 |
| 264 | end |
| 265 | bc_wide ins s get r 46 get r 10 get r 38 0 |
| 266 | bc_wide ins s get r 47 get r 10 get r 39 0 |
| 267 | for j ulong get s 34 |
| 268 | bc_inst ins s 1 get r add j 76 BCNONE 0 |
| 269 | end |
| 270 | sg_pref ins s get s 45 get r 96 get r 46 3 |
| 271 | sg_pref ins s 11 get r 98 get r 47 3 |
| 272 | bc_inst ins s 2 get r 48 BCNONE div get s 37 get s 38 |
| 273 | put s 50 get s 0 |
| 274 | end |
| 275 | fn sg_addresses ins edit ulong 8192 s edit ulong 64 r edit ulong 128 m edit ulong 2048 us ulong to void |
| 276 | put s 51 0 |
| 277 | if or ne add us 1 get s 38 gt get s 37 get s 38 |
| 278 | put s 51 1 |
| 279 | end |
| 280 | if eq get s 51 1 |
| 281 | put r 104 bc_vreg s m 2 false |
| 282 | put r 105 bc_vreg s m 2 false |
| 283 | end |
| 284 | put r 106 bc_vreg s m 1 false |
| 285 | if eq get s 51 1 |
| 286 | if ne add us 1 get s 38 |
| 287 | put s 8 mul add us 1 get s 40 |
| 288 | bc_wide ins s get r 104 get r 10 get r 46 get s 8 |
| 289 | put s 8 div get s 40 128 |
| 290 | put s 8 mul add us 1 get s 8 |
| 291 | put s 8 mul get s 8 4 |
| 292 | bc_wide ins s get r 105 get r 10 get r 47 get s 8 |
| 293 | else |
| 294 | for j ulong 3 |
| 295 | put r add j 107 bc_vreg s m 1 false |
| 296 | end |
| 297 | bc_imm ins s get r 107 get r 10 get r 48 4294967294 |
| 298 | bc_shift ins s get r 107 get r 107 0 31 |
| 299 | bc_imm ins s get r 107 get r 107 get r 10 4294967295 |
| 300 | put s 8 mul get s 38 get s 40 |
| 301 | bc_imm ins s get r 108 get r 107 BCNONE get s 8 |
| 302 | put s 8 div get s 40 128 |
| 303 | put s 8 mul get s 38 get s 8 |
| 304 | put s 8 mul get s 8 4 |
| 305 | bc_imm ins s get r 109 get r 107 BCNONE get s 8 |
| 306 | bc_wide ins s get r 104 get r 108 get r 46 1 |
| 307 | bc_wide ins s get r 105 get r 109 get r 47 1 |
| 308 | end |
| 309 | end |
| 310 | end |
| 311 | fn sg_stage_size s edit ulong 64 to void |
| 312 | put s 53 sub get s 39 get s 52 |
| 313 | if gt get s 53 4 |
| 314 | put s 53 4 |
| 315 | end |
| 316 | end |
| 317 | fn sg_stage_regs s edit ulong 64 r edit ulong 128 m edit ulong 2048 to void |
| 318 | for q ulong get s 53 |
| 319 | put r add q 110 bc_vreg s m 1 false |
| 320 | put r add q 114 bc_vreg s m 2 false |
| 321 | end |
| 322 | end |
| 323 | fn sg_stage_addr ins edit ulong 8192 s edit ulong 64 r view ulong 128 to void |
| 324 | for q ulong get s 53 |
| 325 | put s 57 add get s 52 q |
| 326 | put s 57 mul get s 57 get s 41 |
| 327 | if eq get s 36 1 |
| 328 | put s 59 add get s 52 q |
| 329 | put s 59 add get s 59 56 |
| 330 | put s 59 get r get s 59 |
| 331 | bc_wide ins s get r add q 114 get r 68 get s 59 1 |
| 332 | else |
| 333 | put s 8 div get s 57 get s 40 |
| 334 | put s 8 mul get s 8 get s 32 |
| 335 | put s 59 rem get s 57 get s 40 |
| 336 | put s 8 add get s 8 get s 59 |
| 337 | put s 8 mul get s 8 4 |
| 338 | bc_wide ins s get r add q 114 get r 10 get r 45 get s 8 |
| 339 | end |
| 340 | end |
| 341 | end |
| 342 | fn sg_stage_round ins edit ulong 8192 s edit ulong 64 r view ulong 128 to void |
| 343 | sg_stage_addr ins s r |
| 344 | for q ulong get s 53 |
| 345 | put s 8 0 |
| 346 | bc_mem ins s 11 get r add q 110 get r add q 114 sg_kind q |
| 347 | end |
| 348 | if and eq get s 51 1 eq get s 52 0 |
| 349 | put s 59 sub ulong 1 and get s 58 1 |
| 350 | sg_pref ins s get s 45 get r add get s 59 96 get r 104 add get s 59 3 |
| 351 | sg_pref ins s 11 get r add get s 59 98 get r 105 add get s 59 3 |
| 352 | end |
| 353 | for q ulong get s 53 |
| 354 | put s 8 add get s 52 q |
| 355 | put s 8 mul get s 8 get s 41 |
| 356 | put s 8 mul get s 8 4 |
| 357 | bc_imm ins s get r 106 get r 10 get r 26 get s 8 |
| 358 | bc_node s 50 BCNONE get r 106 get r add q 110 BCNONE |
| 359 | bc_emit ins s 5 |
| 360 | end |
| 361 | end |
| 362 | fn sg_stage ins edit ulong 8192 s edit ulong 64 r edit ulong 128 m edit ulong 2048 us ulong to void |
| 363 | put s 58 us |
| 364 | put s 52 0 |
| 365 | while lt get s 52 get s 39 bound 2 |
| 366 | sg_stage_size s |
| 367 | sg_stage_regs s r m |
| 368 | sg_stage_round ins s r |
| 369 | put s 52 add get s 52 4 |
| 370 | end |
| 371 | bc_node s 48 BCNONE BCNONE BCNONE BCNONE |
| 372 | bc_emit ins s 6 |
| 373 | sg_consume s add and us 1 3 |
| 374 | end |
| 375 | fn sg_decode ins edit ulong 8192 s edit ulong 64 r view ulong 128 wq ulong word ulong byteidx ulong to void |
| 376 | if lt byteidx 3 |
| 377 | put s 8 shl ulong 1 sub ulong 20 mul byteidx 8 |
| 378 | put s 9 word |
| 379 | bc_imad ins s 8 get r 70 wq BCNONE |
| 380 | else |
| 381 | bc_shift ins s get r 70 wq word 4 |
| 382 | end |
| 383 | bc_mask ins s get r 71 get r 70 0 shl ulong 127 20 |
| 384 | bc_mask ins s get r 72 wq word shl ulong 128 mul byteidx 8 |
| 385 | put s 8 1 |
| 386 | if lt byteidx 3 |
| 387 | put s 8 shl ulong 1 sub ulong 24 mul byteidx 8 |
| 388 | end |
| 389 | put s 9 0 |
| 390 | bc_imad ins s 8 get r add byteidx 100 get r 72 get r 71 |
| 391 | end |
| 392 | fn sg_group_lds ins edit ulong 8192 s edit ulong 64 r view ulong 128 q ulong to void |
| 393 | put s 8 add get s 60 q |
| 394 | put s 8 mul get s 8 get s 40 |
| 395 | put s 8 mul get s 8 4 |
| 396 | put s 62 mul get s 61 512 |
| 397 | put s 8 add get s 8 get s 62 |
| 398 | bc_node s 58 get r add q 92 get r 21 BCNONE BCNONE |
| 399 | put s 22 get s 8 |
| 400 | bc_emit ins s sg_kind q |
| 401 | end |
| 402 | fn sg_group_dot ins edit ulong 8192 s edit ulong 64 r view ulong 128 q ulong to void |
| 403 | put s 62 add get s 60 q |
| 404 | put s 62 add get s 62 84 |
| 405 | put s 62 get r get s 62 |
| 406 | for byteidx ulong 4 |
| 407 | put s 9 byteidx |
| 408 | bc_ffma ins s get s 62 get r add byteidx 100 get r add q 92 get s 62 |
| 409 | end |
| 410 | end |
| 411 | fn sg_group ins edit ulong 8192 s edit ulong 64 r view ulong 128 m0 ulong word ulong to void |
| 412 | put s 60 m0 |
| 413 | put s 61 word |
| 414 | nb = sub get s 34 m0 |
| 415 | if gt nb 4 |
| 416 | nb = 4 |
| 417 | end |
| 418 | for q ulong nb |
| 419 | sg_group_lds ins s r q |
| 420 | end |
| 421 | for q ulong nb |
| 422 | sg_group_dot ins s r q |
| 423 | end |
| 424 | end |
| 425 | fn sg_wordcompute ins edit ulong 8192 s edit ulong 64 r view ulong 128 word ulong to void |
| 426 | put s 59 add and get s 58 1 96 |
| 427 | put s 59 get r get s 59 |
| 428 | for byteidx ulong 4 |
| 429 | sg_decode ins s r get s 59 word byteidx |
| 430 | end |
| 431 | for batch ulong div add get s 34 3 4 |
| 432 | sg_group ins s r mul batch 4 word |
| 433 | end |
| 434 | end |
| 435 | fn sg_compute ins edit ulong 8192 s edit ulong 64 r view ulong 128 us ulong to void |
| 436 | for row ulong get s 34 |
| 437 | bc_inst ins s 1 get r add row 84 BCNONE 0 |
| 438 | end |
| 439 | for word ulong div get s 33 4 |
| 440 | sg_wordcompute ins s r word |
| 441 | end |
| 442 | put s 59 add and us 1 98 |
| 443 | put s 59 get r get s 59 |
| 444 | for row ulong get s 34 |
| 445 | put s 60 get r add row 76 |
| 446 | put s 61 get r add row 84 |
| 447 | put s 9 0 |
| 448 | bc_ffma ins s get s 60 get s 61 get s 59 get s 60 |
| 449 | end |
| 450 | bc_node s 48 BCNONE BCNONE BCNONE BCNONE |
| 451 | bc_emit ins s 6 |
| 452 | if eq get s 36 1 |
| 453 | bc_imm ins s get r 68 get r 10 get r 68 mul get s 40 4 |
| 454 | else |
| 455 | bc_wide ins s get r 45 get r 10 get r 45 mul get s 40 4 |
| 456 | end |
| 457 | end |
| 458 | fn sg_kend ins edit ulong 8192 s edit ulong 64 r view ulong 128 to void |
| 459 | bc_wide ins s get r 46 get r 10 get r 46 mul get s 38 get s 40 |
| 460 | put s 8 div get s 40 128 |
| 461 | put s 8 mul get s 38 get s 8 |
| 462 | put s 8 mul get s 8 4 |
| 463 | bc_wide ins s get r 47 get r 10 get r 47 get s 8 |
| 464 | bc_imm ins s get r 48 get r 10 get r 48 4294967295 |
| 465 | bc_pred ins s get r 48 get r 10 |
| 466 | at = bc_branch ins s get s 50 true |
| 467 | sg_consume s 3 |
| 468 | sg_consume s 4 |
| 469 | end |
| 470 | fn sg_store ins edit ulong 8192 s edit ulong 64 r view ulong 128 to void |
| 471 | for row ulong get s 34 |
| 472 | for q ulong 5 |
| 473 | bc_node s 42 get r 51 get r add row 76 BCNONE BCNONE |
| 474 | put s 22 shr ulong 16 q |
| 475 | bc_emit ins s 2 |
| 476 | put s 59 get r add row 76 |
| 477 | bc_node s 30 get s 59 get s 59 get r 51 BCNONE |
| 478 | bc_emit ins s 0 |
| 479 | end |
| 480 | end |
| 481 | bc_node s 8 get r 52 get r 41 get r 23 BCNONE |
| 482 | bc_emit ins s 0 |
| 483 | bc_wide ins s get r 49 get r 52 get r 40 1 |
| 484 | if eq get s 36 1 |
| 485 | for row ulong get s 34 |
| 486 | bc_imm ins s get r 52 get r 10 get r 41 row |
| 487 | bc_wide ins s get r 69 get r 52 get r 30 4 |
| 488 | put s 8 0 |
| 489 | bc_mem ins s 11 get r add row 64 get r 69 sg_kind row |
| 490 | end |
| 491 | end |
| 492 | for row ulong get s 34 |
| 493 | bc_imm ins s get r 52 get r 10 get r 42 sub ulong 4294967295 row |
| 494 | bc_shift ins s get r 53 get r 52 0 31 |
| 495 | bc_imm ins s get r 54 get r 53 get r 37 1 |
| 496 | bc_pred ins s get r 54 get r 10 |
| 497 | put s 54 get s 0 |
| 498 | bc_node s 54 BCNONE BCNONE BCNONE BCNONE |
| 499 | put s 22 2 |
| 500 | bc_emit ins s 9 |
| 501 | put s 55 bc_branch ins s add get s 0 1 true |
| 502 | if eq get s 36 1 |
| 503 | bc_node s 8 get r 52 get r add row 64 get r 23 BCNONE |
| 504 | bc_emit ins s 0 |
| 505 | bc_wide ins s get r 50 get r 52 get r 40 1 |
| 506 | else |
| 507 | bc_wide ins s get r 50 get r 23 get r 49 row |
| 508 | end |
| 509 | bc_node s 12 BCNONE get r 50 get r add row 76 BCNONE |
| 510 | put s 21 0 |
| 511 | bc_emit ins s 5 |
| 512 | put s 56 get s 0 |
| 513 | bc_node s 55 BCNONE BCNONE BCNONE BCNONE |
| 514 | bc_emit ins s 10 |
| 515 | bc_patch ins get s 55 get s 56 |
| 516 | bc_patch ins get s 54 add get s 56 1 |
| 517 | end |
| 518 | bc_imm ins s get r 41 get r 10 get r 41 get s 34 |
| 519 | bc_imm ins s get r 42 get r 10 get r 42 sub ulong 4294967296 get s 34 |
| 520 | bc_imm ins s get r 43 get r 10 get r 43 4294967295 |
| 521 | bc_pred ins s get r 43 get r 10 |
| 522 | at = bc_branch ins s get s 49 true |
| 523 | bc_imm ins s get r 27 get r 4 get r 27 1 |
| 524 | at = bc_branch ins s get s 47 false |
| 525 | bc_patch ins get s 48 get s 0 |
| 526 | bc_patch ins get s 46 get s 0 |
| 527 | bc_node s 45 BCNONE BCNONE BCNONE BCNONE |
| 528 | bc_emit ins s 7 |
| 529 | note Source tail is an IR self BRA with fixed control 0x000fc000. |
| 530 | bc_node s 46 BCNONE BCNONE BCNONE BCNONE |
| 531 | put s 22 shl ulong 1032192 32 |
| 532 | if lt get s 0 1024 |
| 533 | for k ulong 8 |
| 534 | put ins add mul get s 0 8 k get s add k 16 |
| 535 | end |
| 536 | put s 0 add get s 0 1 |
| 537 | else |
| 538 | put s 3 1 |
| 539 | end |
| 540 | end |
| 541 | fn bc_staged spec view ulong 16 ins edit ulong 8192 m edit ulong 2048 stats edit ulong 4 to uint |
| 542 | s = new ulong 64 0 |
| 543 | r = new ulong 128 18446744073709551615 |
| 544 | sg_clear ins m stats |
| 545 | if not sg_valid spec |
| 546 | ret 1 |
| 547 | end |
| 548 | for k ulong 5 |
| 549 | put s add k 32 get spec k |
| 550 | end |
| 551 | put s 37 div get s 32 mul get s 33 32 |
| 552 | put s 38 get s 37 |
| 553 | if eq rem get s 37 2 0 |
| 554 | put s 38 2 |
| 555 | end |
| 556 | put s 39 div mul get s 34 get s 33 get s 35 |
| 557 | put s 40 mul get s 33 32 |
| 558 | put s 41 mul get s 35 32 |
| 559 | put s 42 bc_log div ulong 128 get s 33 |
| 560 | put s 43 bc_log get s 34 |
| 561 | put s 44 bc_log get s 40 |
| 562 | put s 45 56 |
| 563 | if eq get s 33 16 |
| 564 | put s 45 57 |
| 565 | end |
| 566 | sg_regs m s r |
| 567 | sg_prologue ins s r |
| 568 | sg_loopregs m s r |
| 569 | sg_row ins s r |
| 570 | sg_pass ins s r |
| 571 | for us ulong get s 38 |
| 572 | sg_addresses ins s r m us |
| 573 | sg_stage ins s r m us |
| 574 | sg_compute ins s r us |
| 575 | end |
| 576 | sg_kend ins s r |
| 577 | sg_store ins s r |
| 578 | if ne get s 3 0 |
| 579 | sg_clear ins m stats |
| 580 | ret 2 |
| 581 | end |
| 582 | put stats 0 get s 0 |
| 583 | put stats 1 get s 4 |
| 584 | put stats 2 get s 5 |
| 585 | put stats 3 mul mul get s 34 128 get s 33 |
| 586 | ret 0 |
| 587 | end |