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_fields.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note ABI raw slots: op,dst,src1,src2,src3,ureg,imm,control,uniform,p0,not,bar,dsub,s1sub,s2sub,s3sub. |
| 3 | note kind 0 packs encoder records (bar at bit 8); kind 1 unpacks emitter records (bar at bit 48). |
| 4 | note kind 2 converts sixteen little-endian instruction bytes in raw to four u32 words. |
| 5 | fn cg_fields kind ulong raw edit ulong 16 rec edit ulong 8 to ulong |
| 6 | if eq kind 0 |
| 7 | for i ulong 6 |
| 8 | put rec i get raw i |
| 9 | end |
| 10 | put rec 6 or get raw 6 shl get raw 7 32 |
| 11 | f = or get raw 8 shl get raw 9 1 |
| 12 | f = or f shl get raw 10 2 |
| 13 | f = or f shl get raw 11 8 |
| 14 | for i ulong 4 |
| 15 | f = or f shl get raw add i 12 add 16 mul i 8 |
| 16 | end |
| 17 | put rec 7 f |
| 18 | ret 0 |
| 19 | end |
| 20 | if eq kind 1 |
| 21 | for i ulong 6 |
| 22 | put raw i get rec i |
| 23 | end |
| 24 | put raw 6 and get rec 6 4294967295 |
| 25 | put raw 7 shr get rec 6 32 |
| 26 | f = get rec 7 |
| 27 | put raw 8 and f 1 |
| 28 | put raw 9 and shr f 1 1 |
| 29 | put raw 10 and shr f 2 1 |
| 30 | put raw 11 and shr f 48 255 |
| 31 | for i ulong 4 |
| 32 | put raw add i 12 and shr f add 16 mul i 8 255 |
| 33 | end |
| 34 | ret 0 |
| 35 | end |
| 36 | if eq kind 2 |
| 37 | for i ulong 4 |
| 38 | b = mul i 4 |
| 39 | w = or get raw b shl get raw add b 1 8 |
| 40 | w = or w shl get raw add b 2 16 |
| 41 | w = or w shl get raw add b 3 24 |
| 42 | put raw i w |
| 43 | end |
| 44 | ret 0 |
| 45 | end |
| 46 | ret 4 |
| 47 | end |