]> git.proxmox.com Git - rustc.git/blob - vendor/psm/src/arch/x86_windows_gnu.s
New upstream version 1.45.0+dfsg1
[rustc.git] / vendor / psm / src / arch / x86_windows_gnu.s
1 /* FIXME: this works locally but not on appveyor??!? */
2
3 #include "psm.h"
4 /* NOTE: fastcall calling convention used on all x86 targets */
5
6 .text
7
8 .def @rust_psm_stack_direction@0
9 .scl 2
10 .type 32
11 .endef
12 .globl @rust_psm_stack_direction@0
13 .p2align 4
14 @rust_psm_stack_direction@0:
15 /* extern "fastcall" fn() -> u8 (%al) */
16 .cfi_startproc
17 movb $STACK_DIRECTION_DESCENDING, %al # always descending on x86_64
18 retl
19 .cfi_endproc
20
21
22 .def @rust_psm_stack_pointer@0
23 .scl 2
24 .type 32
25 .endef
26 .globl @rust_psm_stack_pointer@0
27 .p2align 4
28 @rust_psm_stack_pointer@0:
29 /* extern "fastcall" fn() -> *mut u8 (%rax) */
30 .cfi_startproc
31 leal 4(%esp), %eax
32 retl
33 .cfi_endproc
34
35
36 .def @rust_psm_replace_stack@16
37 .scl 2
38 .type 32
39 .endef
40 .globl @rust_psm_replace_stack@16
41 .p2align 4
42 @rust_psm_replace_stack@16:
43 /* extern "fastcall" fn(%ecx: usize, %edx: extern "fastcall" fn(usize), 4(%esp): *mut u8) */
44 .cfi_startproc
45 /*
46 All we gotta do is set the stack pointer to 4(%esp) & tail-call the callback in %edx
47
48 Note, that the callee expects the stack to be offset by 4 bytes (normally, a return address
49 would be store there) off the required stack alignment on entry. To offset the stack in such a
50 way we use the `calll` instruction, however it would also be possible to to use plain `jmpl` but
51 would require to adjust the stack manually, which cannot be easily done, because the stack
52 pointer argument is already stored in memory.
53 */
54 movl 8(%esp), %eax
55 mov %eax, %fs:0x08
56 movl 4(%esp), %esp
57 mov %esp, %fs:0x04
58 calll *%edx
59 ud2
60 .cfi_endproc
61
62
63 .def @rust_psm_on_stack@16
64 .scl 2
65 .type 32
66 .endef
67 .globl @rust_psm_on_stack@16
68 .p2align 4
69 @rust_psm_on_stack@20:
70 /* extern "fastcall" fn(%ecx: usize, %edx: usize, 4(%esp): extern "fastcall" fn(usize, usize), 8(%esp): *mut u8) */
71 .cfi_startproc
72 pushl %ebp
73 .cfi_def_cfa %esp, 8
74 .cfi_offset %ebp, -8
75 pushl %fs:0x04
76 .cfi_def_cfa %esp, 12
77 pushl %fs:0x08
78 .cfi_def_cfa %esp, 16
79 movl %esp, %ebp
80 .cfi_def_cfa_register %ebp
81
82 movl 24(%ebp), %eax
83 movl %eax, %fs:0x08
84 movl 20(%ebp), %esp
85 movl %esp, %fs:0x04
86 calll *16(%ebp)
87
88 movl %ebp, %esp
89 popl %fs:0x08
90 .cfi_def_cfa %esp, 12
91 popl %fs:0x04
92 .cfi_def_cfa %esp, 8
93 popl %ebp
94 .cfi_def_cfa %esp, 4
95 retl $12
96 .cfi_endproc
97