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