Skip to content

Commit c27de5b

Browse files
committed
Add missing chkstk.S files from r242539
llvm-svn: 242540
1 parent fbfed86 commit c27de5b

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// This file is dual licensed under the MIT and the University of Illinois Open
2+
// Source Licenses. See LICENSE.TXT for details.
3+
4+
#include "../assembly.h"
5+
6+
// _chkstk routine
7+
// This routine is windows specific
8+
// http://msdn.microsoft.com/en-us/library/ms648426.aspx
9+
10+
#ifdef __i386__
11+
12+
.text
13+
.balign 4
14+
DEFINE_COMPILERRT_FUNCTION(__chkstk_ms)
15+
push %ecx
16+
push %eax
17+
cmp $0x1000,%eax
18+
lea 12(%esp),%ecx
19+
jb 1f
20+
2:
21+
sub $0x1000,%ecx
22+
orl $0,(%ecx)
23+
sub $0x1000,%eax
24+
cmp $0x1000,%eax
25+
ja 2b
26+
1:
27+
sub %eax,%ecx
28+
orl $0,(%ecx)
29+
pop %eax
30+
pop %ecx
31+
ret
32+
END_COMPILERRT_FUNCTION(__chkstk_ms)
33+
34+
#endif // __i386__
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// This file is dual licensed under the MIT and the University of Illinois Open
2+
// Source Licenses. See LICENSE.TXT for details.
3+
4+
#include "../assembly.h"
5+
6+
// _chkstk routine
7+
// This routine is windows specific
8+
// http://msdn.microsoft.com/en-us/library/ms648426.aspx
9+
10+
// Notes from r227519
11+
// MSVC x64s __chkstk and cygmings ___chkstk_ms do not adjust %rsp
12+
// themselves. It also does not clobber %rax so we can reuse it when
13+
// adjusting %rsp.
14+
15+
#ifdef __x86_64__
16+
17+
.text
18+
.balign 4
19+
DEFINE_COMPILERRT_FUNCTION(___chkstk_ms)
20+
push %rcx
21+
push %rax
22+
cmp $0x1000,%rax
23+
lea 24(%rsp),%rcx
24+
jb 1f
25+
2:
26+
sub $0x1000,%rcx
27+
orl $0,(%rcx)
28+
sub $0x1000,%rax
29+
cmp $0x1000,%rax
30+
ja 2b
31+
1:
32+
sub %rax,%rcx
33+
orl $0,(%rcx)
34+
pop %rax
35+
pop %rcx
36+
ret
37+
END_COMPILERRT_FUNCTION(___chkstk_ms)
38+
39+
#endif // __x86_64__

0 commit comments

Comments
 (0)