42 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 registers x16 and x17.12// Does not modify any memory or the stack pointer.13 14// mov x15, #256 // Number of bytes of stack, in units of 16 byte15// bl __chkstk16// sub sp, sp, x15, lsl #417 18#if defined(__aarch64__) || defined(__arm64ec__)19 20#ifdef __arm64ec__21#define CHKSTK_FUNC __chkstk_arm64ec22#else23#define CHKSTK_FUNC __chkstk24#endif25 26#define PAGE_SIZE 409627 28 .p2align 229DEFINE_COMPILERRT_FUNCTION(CHKSTK_FUNC)30 lsl x16, x15, #431 mov x17, sp321:33 sub x17, x17, #PAGE_SIZE34 subs x16, x16, #PAGE_SIZE35 ldr xzr, [x17]36 b.gt 1b37 38 ret39END_COMPILERRT_FUNCTION(CHKSTK_FUNC)40 41#endif // defined(__aarch64__) || defined(__arm64ec__)42