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_em.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Pure decisions from omega_bw_em.h and omega_bw_em_q.h. C owns IR records and append. |
| 3 | note w: pending, held, control, unused. All control arithmetic has C uint32 wrap. |
| 4 | fn em_cw st uint wb uint rb uint wt uint to uint |
| 5 | ret or or or shl st 9 shl wb 14 shl rb 17 shl wt 20 |
| 6 | end |
| 7 | fn em_emit k long pred long w edit ulong 4 to long |
| 8 | wt = uint get w 0 |
| 9 | pn = wt |
| 10 | cw = uint 0 |
| 11 | if or eq k 0 eq k 6 |
| 12 | cw = em_cw 6 7 7 wt |
| 13 | pn = uint 0 |
| 14 | else |
| 15 | if eq k 1 |
| 16 | cw = em_cw 14 7 7 wt |
| 17 | pn = uint 0 |
| 18 | else |
| 19 | if or eq k 2 eq k 3 |
| 20 | if eq k 3 |
| 21 | wt = and wt 2 |
| 22 | pn = or pn 3 |
| 23 | else |
| 24 | pn = uint 3 |
| 25 | end |
| 26 | cw = or em_cw 4 0 1 wt 8192 |
| 27 | else |
| 28 | if eq k 4 |
| 29 | cw = or em_cw 4 2 7 wt 8192 |
| 30 | pn = uint 4 |
| 31 | else |
| 32 | if eq k 5 |
| 33 | cw = or em_cw 4 7 1 wt 8192 |
| 34 | pn = uint 2 |
| 35 | else |
| 36 | if or eq k 7 eq k 8 |
| 37 | cw = em_cw 5 7 7 wt |
| 38 | if eq pred 0 |
| 39 | pn = uint 0 |
| 40 | end |
| 41 | else |
| 42 | if eq k 9 |
| 43 | cw = or em_cw 1 7 7 wt 8192 |
| 44 | pn = uint 0 |
| 45 | else |
| 46 | if eq k 10 |
| 47 | cw = or em_cw 5 7 7 wt 8192 |
| 48 | pn = uint 0 |
| 49 | else |
| 50 | ret -1 |
| 51 | end |
| 52 | end |
| 53 | end |
| 54 | end |
| 55 | end |
| 56 | end |
| 57 | end |
| 58 | end |
| 59 | put w 0 ulong pn |
| 60 | put w 2 ulong cw |
| 61 | ret 0 |
| 62 | end |
| 63 | fn em_log v ulong to long |
| 64 | l = ulong 0 |
| 65 | while lt shl ulong 1 l v bound 32 |
| 66 | l = add l 1 |
| 67 | end |
| 68 | if eq shl ulong 1 l v |
| 69 | ret long l |
| 70 | end |
| 71 | ret -1 |
| 72 | end |
| 73 | fn cg_em act ulong a long b long c long w edit ulong 4 to long |
| 74 | if eq act 0 |
| 75 | ret em_emit a b w |
| 76 | end |
| 77 | if eq act 1 |
| 78 | sb = uint a |
| 79 | put w 2 ulong or em_cw 4 sb 1 and uint get w 0 2 8192 |
| 80 | put w 0 or get w 0 2 |
| 81 | put w 1 or get w 1 ulong shl uint 1 sb |
| 82 | ret 0 |
| 83 | end |
| 84 | if eq act 2 |
| 85 | mk = ulong shl uint 1 uint a |
| 86 | put w 0 or get w 0 and get w 1 mk |
| 87 | put w 1 and get w 1 xor mk 4294967295 |
| 88 | ret 0 |
| 89 | end |
| 90 | if eq act 3 |
| 91 | if ge a 4 |
| 92 | ret -1 |
| 93 | end |
| 94 | ret add a 1 |
| 95 | end |
| 96 | if eq act 4 |
| 97 | if le a 0 |
| 98 | ret -1 |
| 99 | end |
| 100 | ret sub a 1 |
| 101 | end |
| 102 | if eq act 5 |
| 103 | endval = long get w 3 |
| 104 | if ge endval 2147483648 |
| 105 | endval = sub endval 4294967296 |
| 106 | end |
| 107 | if and and ge a 0 lt a b and ge c b lt c endval |
| 108 | ret endval |
| 109 | end |
| 110 | ret c |
| 111 | end |
| 112 | if eq act 6 |
| 113 | ret em_log ulong a |
| 114 | end |
| 115 | if eq act 7 |
| 116 | put w 2 ulong em_cw uint a 7 7 uint get w 0 |
| 117 | put w 0 0 |
| 118 | ret 0 |
| 119 | end |
| 120 | if eq act 8 |
| 121 | ret sub a b |
| 122 | end |
| 123 | if eq act 9 |
| 124 | ret and a 31 |
| 125 | end |
| 126 | ret -1 |
| 127 | end |