omega-bridge
Omega-first language interoperability: checked conversion backends and native language bindings
Brought by drakestapleton
omega-bridge / tests / native / fsum.om
| 1 | note fsum: d[i] = a[i] + f16 h[i] in f32 for 4 lanes (h binary16 bits, converted here; zero and normal |
| 2 | note inputs), and returns the f32 bit pattern of d[0] + d[3]: an f32 view, a ushort view and an f32 edit array. |
| 3 | fn h2b h ushort to uint |
| 4 | v = uint h |
| 5 | s = shl and shr v 15 1 31 |
| 6 | e = and shr v 10 31 |
| 7 | m = and v 1023 |
| 8 | if eq e 0 |
| 9 | ret s |
| 10 | end |
| 11 | ret or or s shl add e 112 23 shl m 13 |
| 12 | end |
| 13 | fn fsum a view f32 4 h view ushort 4 d edit f32 4 to ulong |
| 14 | for i ulong 4 |
| 15 | put d i add get a i bitcast f32 h2b get h i |
| 16 | end |
| 17 | ret ulong bitcast uint add get d 0 get d 3 |
| 18 | end |