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 / codegen / cg_invar.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note No value first defined in a closed loop may be read afterward before its next nonuniform definition. |
| 3 | fn invread ins view ulong 8192 b ulong v ulong to bool |
| 4 | ret or eq get ins add b 2 v or eq get ins add b 3 v eq get ins add b 4 v |
| 5 | end |
| 6 | fn invwrite ins view ulong 8192 b ulong v ulong to bool |
| 7 | ret and eq get ins add b 1 v eq and get ins add b 7 1 0 |
| 8 | end |
| 9 | fn invreg ins view ulong 8192 v ulong e ulong n ulong to bool |
| 10 | for i ulong n |
| 11 | if le i e |
| 12 | continue |
| 13 | end |
| 14 | b = mul i 8 |
| 15 | if invread ins b v |
| 16 | ret false |
| 17 | end |
| 18 | if invwrite ins b v |
| 19 | ret true |
| 20 | end |
| 21 | end |
| 22 | ret true |
| 23 | end |
| 24 | fn iv_u2l x ulong to long |
| 25 | if lt x 9223372036854775808 |
| 26 | ret long x |
| 27 | end |
| 28 | ret sub long -1 long xor x 18446744073709551615 |
| 29 | end |
| 30 | fn iv_i32 x ulong to long |
| 31 | x = and x 4294967295 |
| 32 | if lt x 2147483648 |
| 33 | ret long x |
| 34 | end |
| 35 | ret sub long -1 long xor x 4294967295 |
| 36 | end |
| 37 | fn invbound meta view ulong 512 l ulong to ulong |
| 38 | ret or and get meta add 16 mul l 2 4294967295 shl get meta add 17 mul l 2 32 |
| 39 | end |
| 40 | fn invloop ins view ulong 8192 life view ulong 512 a ulong b ulong to bool |
| 41 | s = iv_i32 b |
| 42 | e = shr b 32 |
| 43 | for v ulong shr a 32 |
| 44 | fd = iv_u2l get life mul v 2 |
| 45 | if and ge fd s le fd long e |
| 46 | if not invreg ins v e and a 4294967295 |
| 47 | ret false |
| 48 | end |
| 49 | end |
| 50 | end |
| 51 | ret true |
| 52 | end |
| 53 | fn cg_invar ins view ulong 8192 meta view ulong 512 life view ulong 512 to ulong |
| 54 | a = or get meta 0 shl get meta 1 32 |
| 55 | for l ulong get meta 5 |
| 56 | if not invloop ins life a invbound meta l |
| 57 | ret 6 |
| 58 | end |
| 59 | end |
| 60 | ret 0 |
| 61 | end |