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 / seed / ng / a64 / tests / fusion.om

199 lines · 3579 bytes Raw Blame History
1note Build with seed/ng/src/ir.om. Generates the deterministic fusion fixture consumed by rgate.
2note Every comparison and integer type, both branch directions, select operands, and all TBZ bit numbers.
3global fu_f uint 256
4global fu_t uint 256
5global fu_x ulong 256
6global fu_n uint 1
7global fu_buf uint 1
8fn fu_k b uint t uint x ulong to uint
9ret ir_res ir_op b 1 t x 0
10end
11fn fu_bin b uint op uint t uint x uint y uint to uint
12o = ir_op b op t 0 2
13ir_set o 0 x
14ir_set o 1 y
15ret ir_res o
16end
17fn fu_ret b uint tok uint v uint to void
18o = ir_op b 63 0 0 2
19ir_set o 0 tok
20ir_set o 1 v
21end
22fn fu_addf f uint t uint to void
23n = get fu_n 0
24put fu_f n f
25put fu_t n t
26put fu_x n 1
27put fu_n 0 add n 1
28end
29fn fu_cmp t uint op uint sel bool to void
30f = ir_fnew 0 0 5
31a = ir_fpar f t
32b = ir_fpar f t
33x = ir_blk f
34u = fu_k x 5 17
35v = fu_k x 5 23
36if not sel
37if or eq op 30 eq op 31
38b = fu_k x t 0
39end
40end
41c = fu_bin x op 1 a b
42if sel
43o = ir_op x 2 5 0 3
44ir_set o 0 c
45ir_set o 1 u
46ir_set o 2 v
47fu_ret x ir_ftok f ir_res o
48else
49bt = ir_blk f
50bf = ir_blk f
51o = ir_op x 61 0 0 4
52ir_set o 0 ir_ftok f
53ir_set o 1 c
54ir_set o 2 bt
55ir_set o 3 bf
56fu_ret bt ir_btok bt u
57fu_ret bf ir_btok bf v
58end
59fu_addf f t
60end
61fn fu_pad b uint to void
62j = ulong 0
63while lt j 9000 bound 9000
64unused = fu_k b 5 j
65j = add j 1
66end
67end
68fn fu_setbit bit ulong to void
69k = sub get fu_n 0 1
70put fu_x k shl ulong 1 bit
71end
72fn fu_bit bit ulong op uint to void
73f = ir_fnew 0 0 5
74a = ir_fpar f 5
75b = ir_fpar f 5
76x = ir_blk f
77z = fu_k x 5 0
78m = fu_k x 5 shl ulong 1 bit
79v = fu_bin x 16 5 a m
80c = fu_bin x op 1 v z
81bf = ir_blk f
82bt = ir_blk f
83o = ir_op x 61 0 0 4
84ir_set o 0 ir_ftok f
85ir_set o 1 c
86ir_set o 2 bt
87ir_set o 3 bf
88fu_ret bt ir_btok bt fu_k bt 5 17
89if and eq bit 63 eq op 31
90fu_pad bf
91end
92fu_ret bf ir_btok bf fu_k bf 5 23
93fu_addf f 5
94fu_setbit bit
95end
96fn fu_call b uint tok uint k uint a ulong to uint
97t = get fu_t k
98f = get fu_f k
99v = fu_k b t a
100z = fu_k b t 0
101o = ir_op b 64 5 0 4
102ir_set o 0 tok
103ir_set o 1 f
104ir_set o 2 v
105ir_set o 3 z
106ret o
107end
108fn fu_save b uint t uint k ulong v uint to uint
109r = get fu_buf 0
110i = fu_k b 5 k
111e = fu_k b 5 1
112o = ir_op b 79 0 3 4
113ir_set o 0 t
114ir_set o 1 r
115ir_set o 2 i
116ir_set o 3 e
117q = ir_op b 36 2 0 1
118ir_set q 0 v
119p = ir_op b 43 0 0 4
120ir_set p 0 ir_otok o
121ir_set p 1 r
122ir_set p 2 i
123ir_set p 3 ir_res q
124ret ir_otok p
125end
126fn fu_write b uint t uint to uint
127r = get fu_buf 0
128z = fu_k b 5 0
129n = fu_k b 5 mul ulong get fu_n 0 2
130o = ir_op b 80 0 3 4
131ir_set o 0 t
132ir_set o 1 r
133ir_set o 2 z
134ir_set o 3 n
135fd = fu_k b 8 1
136q = ir_op b 110 9 54 5
137ir_set q 0 ir_otok o
138ir_set q 1 fd
139ir_set q 2 r
140ir_set q 3 z
141ir_set q 4 n
142ret ir_otok q
143end
144fn fu_storage b uint to void
145arrty = ir_tarr 2 mul get fu_n 0 2
146rt = ir_tref arrty 1 0
147g = ir_glob arrty 0
148put fu_buf 0 ir_res ir_op b 52 rt ulong g 0
149end
150fn fu_main to void
151f = ir_fnew 2 0 8
152b = ir_blk f
153fu_storage b
154t = ir_ftok f
155s = fu_k b 5 0
156k = uint 0
157while lt k get fu_n 0 bound 256
158q = fu_call b t k get fu_x k
159t = ir_otok q
160s = fu_bin b 10 5 s ir_res q
161t = fu_save b t mul ulong k 2 ir_res q
162q = fu_call b t k 0
163t = ir_otok q
164s = fu_bin b 10 5 s ir_res q
165t = fu_save b t add mul ulong k 2 1 ir_res q
166k = add k 1
167end
168s = fu_bin b 16 5 s fu_k b 5 255
169o = ir_op b 36 8 0 1
170ir_set o 0 s
171t = fu_write b t
172fu_ret b t ir_res o
173end
174fn main to int
175ir_init
176put fu_n 0 0
177t = uint 2
178while lt t 10 bound 8
179op = uint 30
180while lt op 36 bound 6
181fu_cmp t op false
182fu_cmp t op true
183op = add op 1
184end
185t = add t 1
186end
187bit = ulong 0
188while lt bit 64 bound 64
189fu_bit bit 30
190fu_bit bit 31
191bit = add bit 1
192end
193fu_main
194n = ir_wr
195if eq ar_out 1 1 0 n 0
196ret 27
197end
198ret 0
199end