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// Notes from r227519 12// MSVC x64s __chkstk and cygmings ___chkstk_ms do not adjust %rsp 13// themselves. It also does not clobber %rax so we can reuse it when 14// adjusting %rsp. 15 16#ifdef __x86_64__ 17 18.text 19.balign 4 20DEFINE_COMPILERRT_FUNCTION(___chkstk_ms) 21DEFINE_COMPILERRT_FUNCTION(__chkstk) 22 push %rcx 23 push %rax 24 cmp $0x1000,%rax 25 lea 24(%rsp),%rcx 26 jb 1f 272: 28 sub $0x1000,%rcx 29 test %rcx,(%rcx) 30 sub $0x1000,%rax 31 cmp $0x1000,%rax 32 ja 2b 331: 34 sub %rax,%rcx 35 test %rcx,(%rcx) 36 pop %rax 37 pop %rcx 38 ret 39END_COMPILERRT_FUNCTION(__chkstk) 40END_COMPILERRT_FUNCTION(___chkstk_ms) 41 42#endif // __x86_64__ 43