interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / gpu / nvidia / om / codegen / cg_qmma_patch.om

58 lines · 1186 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note Patch a single encoded instruction. Result zero untouched, one patched, two refused.
3note Word constants transcribed from the existing qmma oracle; see codegen migration documentation.
4fn cg_qmma_read p view uchar 16 off ulong to ulong
5v = ulong 0
6for i ulong 4
7v = or v shl ulong get p add off i mul i 8
8end
9ret v
10end
11fn cg_qmma_write p edit uchar 16 off ulong v ulong to void
12for i ulong 4
13put p add off i uchar and shr v mul i 8 255
14end
15end
16fn cg_qmma_patch op ulong imm ulong p edit uchar 16 to ulong
17if eq op 37
18if ne imm 1178940467
19ret 0
20end
21w0 = cg_qmma_read p 0
22w1 = cg_qmma_read p 4
23w2 = cg_qmma_read p 8
24if ne and w0 65535 29193
25ret 2
26end
27if ne and w1 4294967040 0
28ret 2
29end
30if ne w2 125829120
31ret 2
32end
33cg_qmma_write p 0 or and w0 4294901760 29246
34cg_qmma_write p 8 75526399
35ret 1
36end
37if ne op 16
38ret 0
39end
40if ne imm 1362114610
41ret 0
42end
43w0 = cg_qmma_read p 0
44w1 = cg_qmma_read p 4
45w2 = cg_qmma_read p 8
46if ne and w0 65535 29244
47ret 2
48end
49if ne and w1 4294967040 0
50ret 2
51end
52if ne and w2 4294967040 268288
53ret 2
54end
55cg_qmma_write p 0 or and w0 4294901760 29306
56cg_qmma_write p 8 or and w2 255 11264
57ret 1
58end