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 / components / bw_check.om

142 lines · 2343 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note Validate the existing IR, never translate to a second representation.
3fn bc_width m view ulong 2048 reg ulong width ulong to bool
4if ge reg 256
5ret false
6end
7ret eq get m reg width
8end
9fn bc_regcheck ins view ulong 8192 base ulong m view ulong 2048 to uint
10op = get ins base
11flags = get ins add base 7
12if gt op 59
13ret 1
14end
15if ne shr flags 48 0
16ret 1
17end
18for k ulong 4
19v = get ins add add base 1 k
20if ne v BCNONE
21if and eq k 0 ne and flags 1 0
22if ge v 32
23ret 2
24end
25v = add v 256
26else
27if ge v 256
28ret 2
29end
30end
31width = get m v
32if eq width 0
33ret 2
34end
35subreg = and shr flags add ulong 16 mul k 8 255
36if ge subreg width
37ret 2
38end
39end
40end
41u = get ins add base 5
42if ne u BCNONE
43if ge u 32
44ret 2
45end
46if eq get m add u 256 0
47ret 2
48end
49end
50ret 0
51end
52fn bc_type ins view ulong 8192 base ulong m view ulong 2048 to uint
53op = get ins base
54d = get ins add base 1
55a = get ins add base 2
56b = get ins add base 3
57c = get ins add base 4
58if or eq op 56 eq op 57
59width = ulong 2
60if eq op 57
61width = 4
62end
63if or eq bc_width m d width false eq bc_width m a 2 false
64ret 3
65end
66if eq d a
67ret 3
68end
69end
70if eq op 11
71note Scalar loads/stores may select one lane of a live pair/quad; bc_regcheck checks subreg bounds.
72if or eq d BCNONE eq bc_width m a 2 false
73ret 3
74end
75end
76if eq op 12
77if or eq bc_width m a 2 false eq b BCNONE
78ret 3
79end
80end
81if eq op 16
82if or eq bc_width m d 4 false eq bc_width m a 4 false
83ret 3
84end
85if eq bc_width m b 2 false
86ret 3
87end
88if and ne c BCNONE eq bc_width m c 4 false
89ret 3
90end
91end
92ret 0
93end
94fn bc_ctrlcheck ins view ulong 8192 i ulong n ulong to uint
95base = mul i 8
96op = get ins base
97if or eq op 46 eq op 54
98raw = and get ins add base 6 4294967295
99target = add i raw
100if ge raw 2147483648
101target = sub i sub ulong 4294967296 raw
102end
103if ge target n
104ret 4
105end
106if and eq op 54 le target i
107ret 4
108end
109end
110if or eq op 11 or eq op 56 eq op 57
111ctrl = shr get ins add base 6 32
112if ne and shr ctrl 17 7 1
113ret 5
114end
115wb = and shr ctrl 14 7
116if and ne wb 0 and ne wb 3 ne wb 4
117ret 5
118end
119end
120ret 0
121end
122fn bc_ircheck ins view ulong 8192 n ulong m view ulong 2048 to uint
123if or eq n 0 gt n 1024
124ret 1
125end
126for i ulong n
127base = mul i 8
128rc = bc_regcheck ins base m
129if ne rc 0
130ret rc
131end
132rc = bc_type ins base m
133if ne rc 0
134ret rc
135end
136rc = bc_ctrlcheck ins i n
137if ne rc 0
138ret rc
139end
140end
141ret 0
142end