omega-bridge
Omega-first language interoperability: checked conversion backends and native language bindings
Brought by drakestapleton
omega-bridge / tests / native / v2 / hoist.om
| 1 | note hoist.om: an OM-2 unit for the native ABI v2 tests whose code writes callee-saved registers. An OM-2 omc |
| 2 | note with loop-constant hoisting (omega-mv perf/omc-loop-checks, omc 13ce76c2) keeps the seven literals of |
| 3 | note hadd's constant-count loop in x20..x26, the most it hoists, and inner's two in x20 and x21; inner's |
| 4 | note conversions with eleven values live are made in v8 and up, so they write d8..d15. caller.c checks that |
| 5 | note x19..x28 and d8..d15 keep the caller's values across a normal return and a trap 9 raised in inner, a |
| 6 | note callee of the exported function, after both functions wrote those registers. run.sh decodes the code |
| 7 | note and fails unless x20..x26 and some of d8..d15 are written and x19 and x29 are not. |
| 8 | om2 |
| 9 | fn inner k ulong to ulong |
| 10 | s = ulong 0 |
| 11 | for i ulong 64 |
| 12 | s = add s 50001 |
| 13 | s = sub s 50000 |
| 14 | end |
| 15 | b = add s 1 |
| 16 | c = add s 2 |
| 17 | d = add s 3 |
| 18 | e = add s 4 |
| 19 | f = add s 5 |
| 20 | g = add s 6 |
| 21 | h = add s 7 |
| 22 | j = add s 8 |
| 23 | x = ulong f64 add s 10 |
| 24 | y = ulong f32 f64 add s 11 |
| 25 | if ne k 0 |
| 26 | trap 9 |
| 27 | end |
| 28 | s = add s add b c |
| 29 | s = add s add d e |
| 30 | s = add s add f g |
| 31 | s = add s add h j |
| 32 | s = add s x |
| 33 | ret add s y |
| 34 | end |
| 35 | export fn hadd d edit ulong 64 k ulong to ulong |
| 36 | s = ulong 0 |
| 37 | for i ulong 64 |
| 38 | put d i add get d i 70000 |
| 39 | s = add s 90001 |
| 40 | s = sub s 80002 |
| 41 | s = add s 60003 |
| 42 | s = sub s 50004 |
| 43 | s = add s 40005 |
| 44 | s = sub s 30006 |
| 45 | end |
| 46 | ret add s inner k |
| 47 | end |