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_tern_common.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Exact public ternary spec policy, including the independent 16384-byte staging cap. |
| 3 | fn omega_ct_valid k ulong l ulong r ulong w ulong d ulong em ulong to ulong |
| 4 | if or eq k 0 gt k 16384 |
| 5 | ret 0 |
| 6 | end |
| 7 | if ne rem k 256 0 |
| 8 | ret 0 |
| 9 | end |
| 10 | n = div add k 8191 8192 |
| 11 | if ne rem k mul 256 n 0 |
| 12 | ret 0 |
| 13 | end |
| 14 | if eq l 0 |
| 15 | if and ne r 1 and ne r 2 ne r 4 |
| 16 | ret 0 |
| 17 | end |
| 18 | else |
| 19 | if or ne l 1 and ne r 2 ne r 4 |
| 20 | ret 0 |
| 21 | end |
| 22 | end |
| 23 | if or eq w 0 gt w 32 |
| 24 | ret 0 |
| 25 | end |
| 26 | if or eq d 0 gt d 16 |
| 27 | ret 0 |
| 28 | end |
| 29 | if ne rem div div k n 256 d 0 |
| 30 | ret 0 |
| 31 | end |
| 32 | if gt mul r d 16 |
| 33 | ret 0 |
| 34 | end |
| 35 | if gt and em 4294967295 1 |
| 36 | ret 0 |
| 37 | end |
| 38 | if and eq and em 4294967295 1 ne n 1 |
| 39 | ret 0 |
| 40 | end |
| 41 | if gt shr em 32 6 |
| 42 | ret 0 |
| 43 | end |
| 44 | ret 1 |
| 45 | end |
| 46 | fn omega_ct_coal k ulong r ulong w ulong to ulong |
| 47 | if ne div add k 8191 8192 1 |
| 48 | ret 0 |
| 49 | end |
| 50 | if gt mul mul 2 r w 32 |
| 51 | ret 0 |
| 52 | end |
| 53 | if gt add mul k 2 mul mul 16 r w 16384 |
| 54 | ret 0 |
| 55 | end |
| 56 | ret 1 |
| 57 | end |