1// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 2// See https://llvm.org/LICENSE.txt for license information. 3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 5#include "../assembly.h" 6 7// __chkstk routine 8// This routine is windows specific. 9// http://msdn.microsoft.com/en-us/library/ms648426.aspx 10 11// This clobbers the register r12, and the condition codes, and uses r5 and r6 12// as temporaries by backing them up and restoring them afterwards. 13// Does not modify any memory or the stack pointer. 14 15// movw r4, #256 // Number of bytes of stack, in units of 4 byte 16// bl __chkstk 17// sub.w sp, sp, r4 18 19#define PAGE_SIZE 4096 20 21 .p2align 2 22DEFINE_COMPILERRT_FUNCTION(__chkstk) 23 lsl r4, r4, #2 24 mov r12, sp 25 push {r5, r6} 26 mov r5, r4 271: 28 sub r12, r12, #PAGE_SIZE 29 subs r5, r5, #PAGE_SIZE 30 ldr r6, [r12] 31 bgt 1b 32 33 pop {r5, r6} 34 bx lr 35END_COMPILERRT_FUNCTION(__chkstk) 36