chkstk.S 913 B

1234567891011121314151617181920212223242526272829303132333435
  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. // This clobbers registers x16 and x17.
  9. // Does not modify any memory or the stack pointer.
  10. // mov x15, #256 // Number of bytes of stack, in units of 16 byte
  11. // bl __chkstk
  12. // sub sp, sp, x15, lsl #4
  13. #ifdef __aarch64__
  14. #define PAGE_SIZE 4096
  15. .p2align 2
  16. DEFINE_COMPILERRT_FUNCTION(__chkstk)
  17. lsl x16, x15, #4
  18. mov x17, sp
  19. 1:
  20. sub x17, x17, #PAGE_SIZE
  21. subs x16, x16, #PAGE_SIZE
  22. ldr xzr, [x17]
  23. b.gt 1b
  24. ret
  25. END_COMPILERRT_FUNCTION(__chkstk)
  26. #endif // __aarch64__