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_dec_emit.om

384 lines · 7529 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note Emitter for the DEC builder, eight-word IR wire ABI of omega_gpu_om_ir.h.
3note Infrastructure (av ob os rf rb imm ctl arg cw finish patch lopen lclose) follows cg_attn_emit.om.
4note Operand words: vreg or (vreg | subreg << 32); ALL is NOREG. m[3] holds the uniform descriptor register.
5const ALL ulong 18446744073709551615
6fn av m edit ulong 512 k ulong u ulong to ulong
7v = get m add 1 u
8if or and eq u 0 ge v 256 and ne u 0 ge v 32
9put m 4 1
10ret 0
11end
12put m add 1 u add v 1
13if eq u 0
14put m add 64 v k
15else
16put m add 320 v k
17end
18ret v
19end
20fn ob v ulong to ulong
21if eq and v 4294967295 4294967295
22ret ALL
23end
24ret and v 4294967295
25end
26fn os v ulong to ulong
27if eq v ALL
28ret 0
29end
30ret shr v 32
31end
32fn rf x edit ulong 8192 m view ulong 512 f ulong v ulong to void
33if ge get m 0 1024
34ret
35end
36put x add mul get m 0 8 f v
37end
38fn rb x edit ulong 8192 m view ulong 512 op ulong to void
39rf x m 0 op
40rf x m 1 ALL
41rf x m 2 ALL
42rf x m 3 ALL
43rf x m 4 ALL
44rf x m 5 ALL
45rf x m 6 0
46rf x m 7 0
47end
48fn imm x edit ulong 8192 m view ulong 512 v ulong to void
49rf x m 6 and v 4294967295
50end
51fn ctl x edit ulong 8192 m view ulong 512 v ulong to void
52if ge get m 0 1024
53ret
54end
55p = mul get m 0 8
56put x add p 6 or and get x add p 6 4294967295 shl v 32
57end
58fn arg x edit ulong 8192 m view ulong 512 f ulong v ulong to void
59if ge get m 0 1024
60ret
61end
62rf x m f ob v
63p = add mul get m 0 8 7
64sh = add mul sub f 1 8 16
65put x p or get x p shl os v sh
66end
67fn cw stall ulong wb ulong rd ulong wt ulong to ulong
68ret or or shl stall 9 shl wb 14 or shl rd 17 shl wt 20
69end
70note k: 0 FIXED 1 PRED 2 VAR 3 VAR_MORE 4 UVAR 5 STORE 6 SYNC 7 EXIT 8 BRA 9 BSSY 10 BSYNC
71fn finish x edit ulong 8192 m edit ulong 512 k ulong to void
72if ge get m 0 1024
73put m 4 1
74ret
75end
76wt = get m 7
77cc = cw 6 7 7 wt
78nx = ulong 0
79if eq k 1
80cc = cw 14 7 7 wt
81end
82if or eq k 2 eq k 3
83if eq k 3
84wt = and wt 2
85end
86cc = or cw 4 0 1 wt 8192
87nx = ulong 3
88if eq k 3
89nx = or get m 7 3
90end
91end
92if eq k 4
93cc = or cw 4 2 7 wt 8192
94nx = ulong 4
95end
96if eq k 5
97cc = or cw 4 7 1 wt 8192
98nx = ulong 2
99end
100if or eq k 7 eq k 8
101cc = cw 5 7 7 wt
102if ne and get x add mul get m 0 8 7 2 0
103nx = wt
104end
105end
106if eq k 9
107cc = or cw 1 7 7 wt 8192
108end
109if eq k 10
110cc = or cw 5 7 7 wt 8192
111end
112ctl x m cc
113put m 7 nx
114put m 0 add get m 0 1
115end
116fn patch x edit ulong 8192 at ulong target ulong to void
117if ge at 1024
118ret
119end
120p = add mul at 8 6
121put x p or and get x p 18446744069414584320 and sub target at 4294967295
122end
123fn lopen m edit ulong 512 to void
124d = get m 9
125if ge d 4
126put m 4 1
127ret
128end
129put m add 10 d get m 0
130put m 9 add d 1
131end
132fn lclose m edit ulong 512 to void
133if eq get m 9 0
134put m 4 1
135ret
136end
137d = sub get m 9 1
138put m 9 d
139n = get m 5
140put m add 16 mul n 2 get m add 10 d
141put m add 17 mul n 2 sub get m 0 1
142put m 5 add n 1
143end
144fn pk v ulong sb ulong to ulong
145ret or and v 4294967295 shl sb 32
146end
147fn nv m edit ulong 512 to ulong
148ret av m 1 0
149end
150fn nv64 m edit ulong 512 to ulong
151ret av m 2 0
152end
153fn nv128 m edit ulong 512 to ulong
154ret av m 4 0
155end
156fn nu64 m edit ulong 512 to ulong
157ret av m 2 1
158end
159fn e_ldcu x edit ulong 8192 m edit ulong 512 d ulong o ulong to void
160rb x m 7
161arg x m 1 d
162imm x m o
163rf x m 7 1
164finish x m 4
165end
166fn e_ldc64 x edit ulong 8192 m edit ulong 512 d ulong o ulong to void
167rb x m 5
168arg x m 1 d
169imm x m o
170finish x m 2
171end
172fn e_ldc32 x edit ulong 8192 m edit ulong 512 d ulong o ulong to void
173rb x m 4
174arg x m 1 d
175imm x m o
176finish x m 2
177end
178fn e_s2r x edit ulong 8192 m edit ulong 512 d ulong sr ulong to void
179rb x m 3
180arg x m 1 d
181imm x m sr
182finish x m 2
183end
184fn e_movi x edit ulong 8192 m edit ulong 512 d ulong v ulong to void
185rb x m 2
186arg x m 1 d
187imm x m v
188finish x m 0
189end
190fn e_movrz x edit ulong 8192 m edit ulong 512 d ulong to void
191rb x m 1
192arg x m 1 d
193finish x m 0
194end
195fn e_imadi x edit ulong 8192 m edit ulong 512 d ulong a ulong v ulong c ulong to void
196rb x m 8
197arg x m 1 d
198arg x m 2 a
199imm x m v
200arg x m 4 c
201finish x m 0
202end
203fn e_imadr x edit ulong 8192 m edit ulong 512 d ulong a ulong b ulong c ulong to void
204rb x m 8
205arg x m 1 d
206arg x m 2 a
207arg x m 3 b
208arg x m 4 c
209finish x m 0
210end
211fn e_imadw x edit ulong 8192 m edit ulong 512 d ulong a ulong v ulong c ulong to void
212rb x m 9
213arg x m 1 d
214arg x m 2 a
215imm x m v
216arg x m 4 c
217finish x m 0
218end
219fn e_mov x edit ulong 8192 m edit ulong 512 d ulong a ulong to void
220e_imadi x m d a 1 ALL
221end
222fn e_shr x edit ulong 8192 m edit ulong 512 d ulong a ulong v ulong to void
223rb x m 17
224arg x m 1 d
225arg x m 2 a
226imm x m v
227finish x m 0
228end
229fn e_andi x edit ulong 8192 m edit ulong 512 d ulong a ulong v ulong to void
230rb x m 18
231arg x m 1 d
232arg x m 2 a
233imm x m v
234finish x m 0
235end
236fn e_xorr x edit ulong 8192 m edit ulong 512 d ulong a ulong b ulong to void
237rb x m 29
238arg x m 1 d
239arg x m 2 a
240arg x m 3 b
241finish x m 0
242end
243fn e_lop3 x edit ulong 8192 m edit ulong 512 d ulong a ulong b ulong lut ulong to void
244rb x m 51
245arg x m 1 d
246arg x m 2 a
247arg x m 3 b
248imm x m lut
249finish x m 0
250end
251fn e_ldg x edit ulong 8192 m edit ulong 512 op ulong d ulong a ulong v ulong to void
252rb x m op
253arg x m 1 d
254arg x m 2 a
255imm x m v
256rf x m 5 get m 3
257finish x m 2
258end
259fn e_ldgm x edit ulong 8192 m edit ulong 512 op ulong d ulong a ulong v ulong to void
260rb x m op
261arg x m 1 d
262arg x m 2 a
263imm x m v
264rf x m 5 get m 3
265finish x m 3
266end
267fn e_stg x edit ulong 8192 m edit ulong 512 a ulong v ulong to void
268rb x m 12
269arg x m 2 a
270arg x m 3 v
271rf x m 5 get m 3
272finish x m 5
273end
274fn e_lds128 x edit ulong 8192 m edit ulong 512 d ulong a ulong v ulong f ulong to void
275rb x m 58
276arg x m 1 d
277arg x m 2 a
278imm x m v
279if ne f 0
280finish x m 2
281else
282finish x m 3
283end
284end
285fn e_lds32 x edit ulong 8192 m edit ulong 512 d ulong a ulong to void
286rb x m 49
287arg x m 1 d
288arg x m 2 a
289finish x m 2
290end
291fn e_sts32 x edit ulong 8192 m edit ulong 512 a ulong v ulong to void
292rb x m 50
293arg x m 2 a
294arg x m 3 v
295finish x m 5
296end
297fn e_bar x edit ulong 8192 m edit ulong 512 to void
298rb x m 48
299finish x m 6
300end
301note op 30 FADD, 32 FMUL, 36 FMNMX_MIN, 37 FMNMX_MAX
302fn e_fop x edit ulong 8192 m edit ulong 512 op ulong d ulong a ulong b ulong to void
303rb x m op
304arg x m 1 d
305arg x m 2 a
306arg x m 3 b
307finish x m 0
308end
309fn e_ffma x edit ulong 8192 m edit ulong 512 d ulong a ulong b ulong c ulong to void
310rb x m 33
311arg x m 1 d
312arg x m 2 a
313arg x m 3 b
314arg x m 4 c
315finish x m 0
316end
317note op 40 MUFU_RCP, 41 MUFU_RSQ, 47 MUFU_EX2
318fn e_mufu x edit ulong 8192 m edit ulong 512 op ulong d ulong a ulong to void
319rb x m op
320arg x m 1 d
321arg x m 2 a
322finish x m 2
323end
324fn e_shfl x edit ulong 8192 m edit ulong 512 d ulong a ulong o ulong to void
325rb x m 42
326arg x m 1 d
327arg x m 2 a
328imm x m o
329finish x m 2
330end
331fn e_isetp x edit ulong 8192 m edit ulong 512 a ulong b ulong to void
332rb x m 28
333arg x m 2 a
334arg x m 3 b
335finish x m 1
336end
337fn e_bra x edit ulong 8192 m edit ulong 512 t ulong to void
338at = get m 0
339rb x m 46
340imm x m sub t at
341finish x m 8
342end
343fn e_brafwd x edit ulong 8192 m edit ulong 512 to ulong
344at = get m 0
345rb x m 46
346imm x m 1
347rf x m 7 2
348finish x m 8
349ret at
350end
351note region_skip_if_p0: BSSY then the predicated BRA; returns the BSSY index (the BRA is the next record)
352fn e_rgn x edit ulong 8192 m edit ulong 512 to ulong
353at = get m 0
354rb x m 54
355imm x m 2
356finish x m 9
357b = e_brafwd x m
358if ne b add at 1
359put m 4 1
360end
361ret at
362end
363fn e_rend x edit ulong 8192 m edit ulong 512 r ulong to void
364at = get m 0
365rb x m 55
366finish x m 10
367patch x add r 1 at
368patch x r add at 1
369end
370fn e_tail x edit ulong 8192 m edit ulong 512 to void
371if ge get m 0 1024
372put m 4 1
373ret
374end
375rb x m 45
376finish x m 7
377if ge get m 0 1024
378put m 4 1
379ret
380end
381rb x m 46
382ctl x m 1032192
383put m 0 add get m 0 1
384end