interplane.Get Omega
Read in your language

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

branch main Branches Tags History

CUDApp / om / codegen / cg_fields.om

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