aboutsummaryrefslogtreecommitdiff
path: root/lib/alloca86_64.S
blob: 684a3e933adce366c6040b43c75fdb34d26e7520 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* ---------------------------------------------- */
/* alloca86_64.S */

#include "../config.h"

.globl alloca

alloca:
    pop     %rdx
    mov     %rdi,%rax
    add     $15,%rax
    and     $-16,%rax
    jz      p3

#ifdef TCC_TARGET_PE
    /* XXX: not tested */
p1:
    cmp     $4096,%rax
    jle     p2
    sub     $4096,%rsp
    sub     $4096,%rax
    test    %rax,(%rsp)
    jmp p1
p2:
#endif

    sub     %rax,%rsp
    mov     %rsp,%rax
p3:
    push    %rdx
    ret

/* ---------------------------------------------- */