Skip to content
This repository was archived by the owner on May 21, 2019. It is now read-only.

Commit 1d871d6

Browse files
committed
[builtins] Implement __chkstk for arm64 windows
Differential Revision: https://reviews.llvm.org/D41134 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@321151 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 16be70a commit 1d871d6

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

lib/builtins/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,12 @@ set(aarch64_SOURCES
446446
${GENERIC_TF_SOURCES}
447447
${GENERIC_SOURCES})
448448

449+
if (MINGW)
450+
set(aarch64_SOURCES
451+
${aarch64_SOURCES}
452+
aarch64/chkstk.S)
453+
endif()
454+
449455
set(armhf_SOURCES ${arm_SOURCES})
450456
set(armv7_SOURCES ${arm_SOURCES})
451457
set(armv7s_SOURCES ${arm_SOURCES})

lib/builtins/aarch64/chkstk.S

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+
// This clobbers registers x16 and x17.
11+
// Does not modify any memory or the stack pointer.
12+
13+
// mov x15, #256 // Number of bytes of stack, in units of 16 byte
14+
// bl __chkstk
15+
// sub sp, sp, x15, lsl #4
16+
17+
#ifdef __aarch64__
18+
19+
#define PAGE_SIZE 4096
20+
21+
.p2align 2
22+
DEFINE_COMPILERRT_FUNCTION(__chkstk)
23+
lsl x16, x15, #4
24+
mov x17, sp
25+
1:
26+
sub x17, x17, #PAGE_SIZE
27+
subs x16, x16, #PAGE_SIZE
28+
ldr xzr, [x17]
29+
b.gt 1b
30+
31+
ret
32+
END_COMPILERRT_FUNCTION(__chkstk)
33+
34+
#endif // __aarch64__

0 commit comments

Comments
 (0)