]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/compiler-rt/lib/builtins/arm/chkstk.S
Merge clang 7.0.1 and several follow-up changes
[FreeBSD/FreeBSD.git] / contrib / compiler-rt / lib / builtins / arm / chkstk.S
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 the register r12, and the condition codes, and uses r5 and r6
11 // as temporaries by backing them up and restoring them afterwards.
12 // Does not modify any memory or the stack pointer.
13
14 //      movw    r4,  #256 // Number of bytes of stack, in units of 4 byte
15 //      bl      __chkstk
16 //      sub.w   sp, sp, r4
17
18 #define PAGE_SIZE 4096
19
20         .p2align 2
21 DEFINE_COMPILERRT_FUNCTION(__chkstk)
22         lsl    r4,  r4,  #2
23         mov    r12, sp
24         push   {r5, r6}
25         mov    r5,  r4
26 1:
27         sub    r12, r12, #PAGE_SIZE
28         subs   r5,  r5,  #PAGE_SIZE
29         ldr    r6,  [r12]
30         bgt    1b
31
32         pop    {r5, r6}
33         bx     lr
34 END_COMPILERRT_FUNCTION(__chkstk)