36 lines · plain
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-exception4 5#include "../assembly.h"6 7// __chkstk routine8// This routine is windows specific.9// http://msdn.microsoft.com/en-us/library/ms648426.aspx10 11// This clobbers the register r12, and the condition codes, and uses r5 and r612// 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 byte16// bl __chkstk17// sub.w sp, sp, r418 19#define PAGE_SIZE 409620 21 .p2align 222DEFINE_COMPILERRT_FUNCTION(__chkstk)23 lsl r4, r4, #224 mov r12, sp25 push {r5, r6}26 mov r5, r4271:28 sub r12, r12, #PAGE_SIZE29 subs r5, r5, #PAGE_SIZE30 ldr r6, [r12]31 bgt 1b32 33 pop {r5, r6}34 bx lr35END_COMPILERRT_FUNCTION(__chkstk)36