chkstk.S 1.0 KB

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 the register r12, and the condition codes, and uses r5 and r6
  9. // as temporaries by backing them up and restoring them afterwards.
  10. // Does not modify any memory or the stack pointer.
  11. // movw r4, #256 // Number of bytes of stack, in units of 4 byte
  12. // bl __chkstk
  13. // sub.w sp, sp, r4
  14. #define PAGE_SIZE 4096
  15. .p2align 2
  16. DEFINE_COMPILERRT_FUNCTION(__chkstk)
  17. lsl r4, r4, #2
  18. mov r12, sp
  19. push {r5, r6}
  20. mov r5, r4
  21. 1:
  22. sub r12, r12, #PAGE_SIZE
  23. subs r5, r5, #PAGE_SIZE
  24. ldr r6, [r12]
  25. bgt 1b
  26. pop {r5, r6}
  27. bx lr
  28. END_COMPILERRT_FUNCTION(__chkstk)