interplane.Get Omega
Read in your language

omega-bridge

Omega-first language interoperability: checked conversion backends and native language bindings

Brought by drakestapleton

branch main Branches Tags History

omega-bridge / tests / native / v2 / hoist.om

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