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 / gpu / nvidia / om / codegen / cg_life.om

58 lines · 1293 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note life[2*v] is first_def, life[2*v+1] is last_use (signed C interval indices).
3note Extending after replay is equivalent to extending at each closing BRA: a later use already dominates that end.
4fn cl_u2l x ulong to long
5if lt x 9223372036854775808
6ret long x
7end
8ret sub long -1 long xor x 18446744073709551615
9end
10fn cl_i32 x ulong to long
11x = and x 4294967295
12if lt x 2147483648
13ret long x
14end
15ret sub long -1 long xor x 4294967295
16end
17fn lifext life edit ulong 512 n ulong s long e long to void
18for v ulong n
19b = mul v 2
20fd = cl_u2l get life b
21lu = cl_u2l get life add b 1
22if and ge fd 0 and lt fd s and ge lu s lt lu e
23put life add b 1 ulong e
24end
25end
26end
27fn lifhint life edit ulong 512 n ulong v ulong h ulong to ulong
28if eq h 0
29ret 0
30end
31b = mul v 2
32fd = cl_u2l get life b
33lu = cl_u2l get life add b 1
34if lt fd 0
35ret 10
36end
37if or lt h ulong fd or lt h ulong lu ge h n
38ret 10
39end
40put life add b 1 h
41ret 0
42end
43fn cg_life meta view ulong 512 life edit ulong 512 to ulong
44for l ulong get meta 5
45s = cl_i32 get meta add 16 mul l 2
46e = cl_i32 get meta add 17 mul l 2
47lifext life get meta 1 s e
48end
49if eq get meta 7 0
50ret 0
51end
52for v ulong get meta 1
53if ne lifhint life get meta 0 v get meta add 352 v 0
54ret 10
55end
56end
57ret 0
58end