chkstk.S 1009 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. #include "../assembly.h"
  5. // _chkstk routine
  6. // This routine is windows specific
  7. // http://msdn.microsoft.com/en-us/library/ms648426.aspx
  8. // Notes from r227519
  9. // MSVC x64s __chkstk and cygmings ___chkstk_ms do not adjust %rsp
  10. // themselves. It also does not clobber %rax so we can reuse it when
  11. // adjusting %rsp.
  12. #ifdef __x86_64__
  13. .text
  14. .balign 4
  15. DEFINE_COMPILERRT_FUNCTION(___chkstk_ms)
  16. push %rcx
  17. push %rax
  18. cmp $0x1000,%rax
  19. lea 24(%rsp),%rcx
  20. jb 1f
  21. 2:
  22. sub $0x1000,%rcx
  23. test %rcx,(%rcx)
  24. sub $0x1000,%rax
  25. cmp $0x1000,%rax
  26. ja 2b
  27. 1:
  28. sub %rax,%rcx
  29. test %rcx,(%rcx)
  30. pop %rax
  31. pop %rcx
  32. ret
  33. END_COMPILERRT_FUNCTION(___chkstk_ms)
  34. #endif // __x86_64__