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 / omc / tests / float / vreg.om

278 lines · 4029 bytes Raw Blame History
1note float locals live in v registers (the twin of their pool register): loop-carried sums, values kept
2note across calls whose callee uses the same twins, float arguments, register pressure, f32, -0.0, NaN,
3note FMOV immediate edge constants and conversions. Expected bit patterns computed outside this compiler.
4fn clob a f64 b f64 to f64
5p = mul a 2.0
6q = add p b
7r = sub q 0.5
8s = mul r r
9ret add s a
10end
11
12fn clob32 a f32 to f32
13p = mul a f32 4.0
14q = sub p a
15ret q
16end
17
18fn sum3 a f64 b f64 c f64 to f64
19ret add add a b c
20end
21
22fn t_loop to int
23s = f64 0.0
24for i ulong 10
25s = add s div f64 i 2.0
26end
27if ne bitcast ulong s bitcast ulong 22.5f64
28ret 1
29end
30v = f64 0.0
31while lt v 3.0
32v = add v 1.0
33end
34if ne bitcast ulong v bitcast ulong 3.0f64
35ret 2
36end
37ret 0
38end
39
40fn t_call to int
41x = f64 1.5
42y = f64 0.25
43z = clob x y
44if ne bitcast ulong x bitcast ulong 1.5f64
45ret 3
46end
47if ne bitcast ulong y bitcast ulong 0.25f64
48ret 4
49end
50if ne bitcast ulong z bitcast ulong 9.0625f64
51ret 5
52end
53w = sum3 x y z
54if ne bitcast ulong w bitcast ulong 10.8125f64
55ret 6
56end
57x = y
58x = x
59if ne bitcast ulong x bitcast ulong 0.25f64
60ret 7
61end
62x = clob y y
63if ne bitcast ulong x bitcast ulong 0.3125f64
64ret 8
65end
66ret 0
67end
68
69fn t_arr to int
70a = new f64 100 0.0
71for i ulong 100
72put a i mul f64 i 0.75
73end
74t = f64 0.0
75for i ulong 100
76t = add t get a i
77end
78if ne bitcast ulong t bitcast ulong 3712.5f64
79ret 9
80end
81b32 = new f32 8 f32 0.0
82acc = f32 0.0
83for i ulong 8
84put b32 i mul f32 i f32 0.5
85end
86for i ulong 8
87acc = add acc get b32 i
88end
89if ne bitcast uint acc 1096810496
90ret 10
91end
92ret 0
93end
94
95fn t_imm64 to int
96c1 = f64 31.0
97c2 = f64 0.125
98c3 = f64 -2.0
99c4 = f64 0.1328125
100if ne bitcast ulong c1 4629418941960159232
101ret 11
102end
103if ne bitcast ulong c2 4593671619917905920
104ret 12
105end
106if ne bitcast ulong c3 13835058055282163712
107ret 13
108end
109if ne bitcast ulong c4 4593953094894616576
110ret 14
111end
112c5 = f64 32.0
113c6 = f64 0.0625
114c7 = f64 -31.0
115c8 = f64 -0.125
116if ne bitcast ulong c5 4629700416936869888
117ret 15
118end
119if ne bitcast ulong c6 4589168020290535424
120ret 16
121end
122if ne bitcast ulong c7 13852790978814935040
123ret 17
124end
125if ne bitcast ulong c8 13817043656772681728
126ret 18
127end
128c9 = f64 0.0078125
129c10 = f64 256.0
130if ne bitcast ulong c9 4575657221408423936
131ret 36
132end
133if ne bitcast ulong c10 4643211215818981376
134ret 37
135end
136ret 0
137end
138
139fn t_imm32 to int
140k1 = f32 31.0
141k2 = f32 0.125
142k3 = f32 -2.0
143k4 = f32 32.0
144k5 = f32 0.0625
145if ne bitcast uint k1 1106771968
146ret 19
147end
148if ne bitcast uint k2 1040187392
149ret 20
150end
151if ne bitcast uint k3 3221225472
152ret 21
153end
154if ne bitcast uint k4 1107296256
155ret 22
156end
157if ne bitcast uint k5 1031798784
158ret 23
159end
160k6 = f32 0.0078125
161if ne bitcast uint k6 1006632960
162ret 38
163end
164ret 0
165end
166
167fn t_special to int
168nz = neg f64 0.0
169if ne bitcast ulong nz 9223372036854775808
170ret 24
171end
172nz2 = f64 -0.0
173if ne bitcast ulong nz2 9223372036854775808
174ret 25
175end
176n = div f64 0.0 f64 0.0
177if eq n n
178ret 26
179end
180if not ne n n
181ret 27
182end
183ret 0
184end
185
186fn t_f32 to int
187f = f32 0.75
188g = clob32 f
189if ne bitcast uint f 1061158912
190ret 28
191end
192if ne bitcast uint g 1074790400
193ret 29
194end
195d = f64 f32 0.1
196e = f32 d
197if ne bitcast uint e bitcast uint f32 0.1
198ret 30
199end
200x = f64 1.5
201m = int mul x 3.0
202if ne m 4
203ret 31
204end
205ret 0
206end
207
208fn t_intr to int
209q = fsqrt f64 6.25
210q = fabs neg q
211q2 = fmin q f64 2.0
212q3 = fmax q f64 2.0
213if ne bitcast ulong q bitcast ulong 2.5f64
214ret 32
215end
216if ne bitcast ulong q2 bitcast ulong 2.0f64
217ret 33
218end
219if ne bitcast ulong q3 bitcast ulong 2.5f64
220ret 34
221end
222ret 0
223end
224
225fn t_press to int
226h1 = f64 1.0
227h2 = f64 2.0
228h3 = f64 3.0
229h4 = f64 4.0
230h5 = f64 5.0
231h6 = f64 6.0
232h7 = f64 7.0
233h8 = f64 8.0
234h9 = clob h1 h2
235hs = add add h1 h2 add h3 h4
236hs = add hs add add h5 h6 add h7 h8
237hs = add hs h9
238if ne bitcast ulong hs bitcast ulong 49.25f64
239ret 35
240end
241ret 0
242end
243
244fn main to int
245r = t_loop
246if ne r 0
247ret r
248end
249r = t_call
250if ne r 0
251ret r
252end
253r = t_arr
254if ne r 0
255ret r
256end
257r = t_imm64
258if ne r 0
259ret r
260end
261r = t_imm32
262if ne r 0
263ret r
264end
265r = t_special
266if ne r 0
267ret r
268end
269r = t_f32
270if ne r 0
271ret r
272end
273r = t_intr
274if ne r 0
275ret r
276end
277ret t_press
278end