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
omega-mv / gpu / nvidia / om / codegen / cg_pfhost.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note kind 0 router: a=k,b=e,c=t|(mutant<<32); kind 1 combine: a=h,b=top-k,c=mutant. |
| 3 | note All configuration decisions, allocation shapes, loops, instruction fields and scheduling are Omega. |
| 4 | fn ph_rl_valid cf view ulong 64 to bool |
| 5 | if or lt get cf 0 128 gt get cf 0 16384 |
| 6 | ret false |
| 7 | end |
| 8 | if ne rem get cf 0 128 0 |
| 9 | ret false |
| 10 | end |
| 11 | if or lt get cf 1 32 gt get cf 1 1024 |
| 12 | ret false |
| 13 | end |
| 14 | if ne rem get cf 1 32 0 |
| 15 | ret false |
| 16 | end |
| 17 | if or lt get cf 2 1 gt get cf 2 16 |
| 18 | ret false |
| 19 | end |
| 20 | if ne rem get cf 2 div get cf 1 32 0 |
| 21 | ret false |
| 22 | end |
| 23 | if gt mul mul add div get cf 0 4 1 get cf 1 16 2147483647 |
| 24 | ret false |
| 25 | end |
| 26 | ret le get cf 3 2 |
| 27 | end |
| 28 | fn cg_pfhost kind ulong a ulong b ulong c ulong ins edit ulong 8192 meta edit ulong 512 to int |
| 29 | st = new ulong 16 0 |
| 30 | cf = new ulong 64 0 |
| 31 | put cf 0 a |
| 32 | put cf 1 b |
| 33 | if eq kind 0 |
| 34 | put cf 2 and c 4294967295 |
| 35 | put cf 3 shr c 32 |
| 36 | if not ph_rl_valid cf |
| 37 | ret 1 |
| 38 | end |
| 39 | put cf 4 div b 32 |
| 40 | put cf 5 div get cf 2 get cf 4 |
| 41 | put cf 6 div a 128 |
| 42 | put cf 7 mul b 16 |
| 43 | if eq get cf 3 2 |
| 44 | put cf 6 sub get cf 6 1 |
| 45 | end |
| 46 | if eq get cf 6 0 |
| 47 | ret 1 |
| 48 | end |
| 49 | ph_rl_meta cf meta |
| 50 | ph_rl_body ins st cf meta |
| 51 | ret 0 |
| 52 | end |
| 53 | if eq kind 1 |
| 54 | if or lt a 128 gt a 4096 |
| 55 | ret 1 |
| 56 | end |
| 57 | if ne rem a 128 0 |
| 58 | ret 1 |
| 59 | end |
| 60 | if or lt b 4 gt b 16 |
| 61 | ret 1 |
| 62 | end |
| 63 | if or ne rem b 4 0 gt c 2 |
| 64 | ret 1 |
| 65 | end |
| 66 | put cf 3 c |
| 67 | put cf 4 div b 4 |
| 68 | put cf 5 b |
| 69 | if eq c 2 |
| 70 | put cf 5 sub b 1 |
| 71 | end |
| 72 | ph_mc_meta cf meta |
| 73 | ph_mc_body ins st cf meta |
| 74 | ret 0 |
| 75 | end |
| 76 | ret 1 |
| 77 | end |