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 / fixture_verify.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Scalar ABI: a/b and c/d are memcpy-packed pairs of 32-bit golden words. |
| 3 | fn fv_bool b bool to ulong |
| 4 | if b |
| 5 | ret 1 |
| 6 | end |
| 7 | ret 0 |
| 8 | end |
| 9 | |
| 10 | fn fv_words a ulong b ulong c ulong d ulong mask ulong to ulong |
| 11 | if ne and mask 1 0 |
| 12 | if ne and a 4294967295 and c 4294967295 |
| 13 | ret 0 |
| 14 | end |
| 15 | end |
| 16 | if ne and mask 2 0 |
| 17 | if ne shr a 32 shr c 32 |
| 18 | ret 0 |
| 19 | end |
| 20 | end |
| 21 | if ne and mask 4 0 |
| 22 | if ne and b 4294967295 and d 4294967295 |
| 23 | ret 0 |
| 24 | end |
| 25 | end |
| 26 | if ne and mask 8 0 |
| 27 | if ne shr b 32 shr d 32 |
| 28 | ret 0 |
| 29 | end |
| 30 | end |
| 31 | ret 1 |
| 32 | end |
| 33 | |
| 34 | note Variable shifts are decomposed into proven literal shifts for the freest profile. |
| 35 | fn fv_shl val ulong cnt ulong to ulong |
| 36 | x = val |
| 37 | if ne and cnt 1 0 |
| 38 | x = shl x 1 |
| 39 | end |
| 40 | if ne and cnt 2 0 |
| 41 | x = shl x 2 |
| 42 | end |
| 43 | if ne and cnt 4 0 |
| 44 | x = shl x 4 |
| 45 | end |
| 46 | if ne and cnt 8 0 |
| 47 | x = shl x 8 |
| 48 | end |
| 49 | if ne and cnt 16 0 |
| 50 | x = shl x 16 |
| 51 | end |
| 52 | if ne and cnt 32 0 |
| 53 | x = shl x 32 |
| 54 | end |
| 55 | ret x |
| 56 | end |
| 57 | |
| 58 | fn fv_run op ulong a ulong b ulong c ulong d ulong e ulong to ulong |
| 59 | if eq op 0 |
| 60 | ret fv_words a b c d e |
| 61 | end |
| 62 | if eq op 7 |
| 63 | mask = ulong 7 |
| 64 | if ne shr d 32 0 |
| 65 | mask = 15 |
| 66 | end |
| 67 | ret fv_words a b c d mask |
| 68 | end |
| 69 | if eq op 1 |
| 70 | ret and sub ulong 0 add mul a 2 b 4294967295 |
| 71 | end |
| 72 | if eq op 2 |
| 73 | if eq b 0 |
| 74 | ret fv_bool ne a 0 |
| 75 | end |
| 76 | ret fv_bool eq a 0 |
| 77 | end |
| 78 | if eq op 3 |
| 79 | if eq e 0 |
| 80 | ret fv_bool eq and xor b d 4294967295 262144 |
| 81 | end |
| 82 | ret fv_bool and eq a c eq shr b 32 shr d 32 |
| 83 | end |
| 84 | if eq op 4 |
| 85 | ret fv_bool and eq a or c 288230376151711744 eq b d |
| 86 | end |
| 87 | if eq op 5 |
| 88 | x = fv_shl b c |
| 89 | y = fv_shl d e |
| 90 | ret or or a x y |
| 91 | end |
| 92 | if eq op 6 |
| 93 | if eq a b |
| 94 | ret c |
| 95 | end |
| 96 | ret d |
| 97 | end |
| 98 | ret 0 |
| 99 | end |