1*3cab2bb3Spatrick// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 2*3cab2bb3Spatrick// See https://llvm.org/LICENSE.txt for license information. 3*3cab2bb3Spatrick// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4*3cab2bb3Spatrick 5*3cab2bb3Spatrick#include "../assembly.h" 6*3cab2bb3Spatrick 7*3cab2bb3Spatrick// __chkstk routine 8*3cab2bb3Spatrick// This routine is windows specific. 9*3cab2bb3Spatrick// http://msdn.microsoft.com/en-us/library/ms648426.aspx 10*3cab2bb3Spatrick 11*3cab2bb3Spatrick// This clobbers registers x16 and x17. 12*3cab2bb3Spatrick// Does not modify any memory or the stack pointer. 13*3cab2bb3Spatrick 14*3cab2bb3Spatrick// mov x15, #256 // Number of bytes of stack, in units of 16 byte 15*3cab2bb3Spatrick// bl __chkstk 16*3cab2bb3Spatrick// sub sp, sp, x15, lsl #4 17*3cab2bb3Spatrick 18*3cab2bb3Spatrick#ifdef __aarch64__ 19*3cab2bb3Spatrick 20*3cab2bb3Spatrick#define PAGE_SIZE 4096 21*3cab2bb3Spatrick 22*3cab2bb3Spatrick .p2align 2 23*3cab2bb3SpatrickDEFINE_COMPILERRT_FUNCTION(__chkstk) 24*3cab2bb3Spatrick lsl x16, x15, #4 25*3cab2bb3Spatrick mov x17, sp 26*3cab2bb3Spatrick1: 27*3cab2bb3Spatrick sub x17, x17, #PAGE_SIZE 28*3cab2bb3Spatrick subs x16, x16, #PAGE_SIZE 29*3cab2bb3Spatrick ldr xzr, [x17] 30*3cab2bb3Spatrick b.gt 1b 31*3cab2bb3Spatrick 32*3cab2bb3Spatrick ret 33*3cab2bb3SpatrickEND_COMPILERRT_FUNCTION(__chkstk) 34*3cab2bb3Spatrick 35*3cab2bb3Spatrick#endif // __aarch64__ 36