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 / encoder / guard_spec_test.om

110 lines · 2331 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note guard_spec_test.om: the spec encoder sp_enc (om/encoder/bw_spec_sm121.om, used by om/components/encode.om
3note bc_encode for the q38 and validate paths) must match enc1 on the guard predicate (DRA-483, C1b).
4note Concatenate after bw_enc_sm121.om and bw_spec_sm121.om; mk/om-encoder.mk test-om-encoder-guard compiles it.
5note enc1's guards are pinned by guard_pred_test.om and the nvdisasm oracle; this gate carries them to sp_enc.
6note Every op 0..59 (the spec's coverage) is encoded unpredicated, @P0 and @!P0 with R4 <- R8, R12, R16, UR4 (imm 2
7note for BRA and BSSY, else 0) by both encoders: both must accept or both refuse, and accepted words must be equal.
8note Prints one line per differing form (op, form 0 none / 1 @P0 / 2 @!P0), then the count; exit 0 when none, else 1.
9text gsm1 "FAIL spec op "
10text gsm2 " form "
11text gsm3 "spec guard mismatches: "
12text gsnl "\n"
13
14fn gs_o op ulong f ulong o edit ulong 16 to void
15for j ulong 16
16put o j 0
17end
18put o 0 op
19put o 1 4
20put o 2 8
21put o 3 12
22put o 4 16
23put o 5 4
24if eq op 35
25note FSEL's src3 is its predicate selector, P0..P7 (the spec bounds it at 7; enc1 keeps its low 3 bits)
26put o 4 0
27end
28if or eq op 46 eq op 54
29put o 6 2
30end
31put o 12 1
32put o 13 1
33put o 14 1
34put o 15 1
35if ne f 0
36put o 9 1
37end
38if eq f 2
39put o 10 1
40end
41end
42
43fn gs_dec x ulong to void
44b = new uchar 20 0
45i = ulong 20
46v = x
47c = true
48while c bound 20
49i = sub i 1
50put b i uchar add 48 rem v 10
51v = div v 10
52if eq v 0
53c = false
54end
55end
56k = write 1 b i sub 20 i
57end
58
59fn gs_same a view ulong 4 b view ulong 4 to bool
60for k ulong 4
61if ne get a k get b k
62ret false
63end
64end
65ret true
66end
67
68note 1 when enc1 and sp_enc disagree on op with form f
69fn gs_one st edit ulong 3001 op ulong f ulong to ulong
70o = new ulong 16 0
71a = new ulong 4 0
72b = new ulong 4 0
73gs_o op f edit o
74r1 = enc1 view o edit a
75r2 = sp_enc st view o edit b
76if ne eq r1 0 eq r2 0
77ret 1
78end
79if ne r1 0
80ret 0
81end
82if gs_same view a view b
83ret 0
84end
85ret 1
86end
87
88fn main to int
89st = new ulong 3001 0
90bad = ulong 0
91for op ulong 60
92for f ulong 3
93if ne gs_one edit st op f 0
94k = write 1 gsm1 0 len gsm1
95gs_dec op
96k = write 1 gsm2 0 len gsm2
97gs_dec f
98k = write 1 gsnl 0 1
99bad = add bad 1
100end
101end
102end
103k = write 1 gsm3 0 len gsm3
104gs_dec bad
105k = write 1 gsnl 0 1
106if ne bad 0
107ret 1
108end
109ret 0
110end