]> git.proxmox.com Git - ceph.git/blob - ceph/src/isa-l/igzip/heap_macros.asm
update sources to v12.1.1
[ceph.git] / ceph / src / isa-l / igzip / heap_macros.asm
1 ; heapify heap, heap_size, i, child, tmp1, tmp2, tmpd
2 %macro heapify2 7
3 %define %%heap %1 ; qword ptr
4 %define %%heap_size %2 ; dword
5 %define %%i %3 ; dword
6 %define %%child %4 ; dword
7 %define %%tmp1 %5 ; qword
8 %define %%tmp2 %6 ; qword
9 %define %%tmpd %7 ; dword
10 align 16
11 %%heapify1:
12 lea %%child, [%%i + %%i]
13 cmp %%child, %%heap_size
14 ja %%end_heapify1
15 mov %%tmp1, [%%heap + %%child]
16 mov %%tmpd, %%child
17 mov %%tmp2, [%%heap + %%child) + 8]
18 lea %%child, [%%child + 1]
19 cmove %%tmp2, %%tmp1
20 cmp %%tmp1, %%tmp2
21 cmovbe %%child, %%tmpd
22 cmovbe %%tmp2, %%tmp1
23 ; child is correct, %%tmp2 = heap[child]
24 mov %%tmp1, [%%heap + %%i]
25 cmp %%tmp1, %%tmp2
26 jbe %%end_heapify1
27 mov [%%heap + %%i], %%tmp2
28 mov [%%heap + %%child], %%tmp1
29 mov %%i, %%child
30 jmp %%heapify1
31 %%end_heapify1
32 %endm
33
34 ; heapify heap, heap_size, i, child, tmp1, tmp2, tmpd, tmp3
35 %macro heapify 8
36 %define %%heap %1 ; qword ptr
37 %define %%heap_size %2 ; qword
38 %define %%i %3 ; qword
39 %define %%child %4 ; qword
40 %define %%tmp1 %5 ; qword
41 %define %%tmp2 %6 ; qword
42 %define %%tmpd %7 ; qword
43 %define %%tmp3 %8
44 align 16
45 %%heapify1:
46 lea %%child, [%%i + %%i]
47 ; mov %%child, %%i
48 ; add %%child, %%child
49 cmp %%child, %%heap_size
50 ja %%end_heapify1
51 mov %%tmp1, [%%heap + %%child*8]
52 mov %%tmp2, [%%heap + %%child*8 + 8]
53 mov %%tmp3, [%%heap + %%i*8]
54 mov %%tmpd, %%child
55 add %%tmpd, 1
56
57 cmp %%tmp2, %%tmp1
58 cmovb %%child, %%tmpd
59 cmovb %%tmp1, %%tmp2
60 ; child is correct, tmp1 = heap[child]
61 cmp %%tmp3, %%tmp1
62 jbe %%end_heapify1
63 ; swap i and child
64 mov [%%heap + %%i*8], %%tmp1
65 mov [%%heap + %%child*8], %%tmp3
66 mov %%i, %%child
67 jmp %%heapify1
68 %%end_heapify1:
69 %endm