invokeNative_mingw_x64.s 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  2. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  3. .text
  4. .align 2
  5. .globl invokeNative
  6. invokeNative:
  7. # %rcx func_ptr
  8. # %rdx argv
  9. # %r8 n_stacks
  10. push %rbp
  11. mov %rsp, %rbp
  12. mov %rcx, %r10 # func_ptr
  13. mov %rdx, %rax # argv
  14. mov %r8, %rcx # n_stacks
  15. # fill all fp args
  16. movsd 0(%rax), %xmm0
  17. movsd 8(%rax), %xmm1
  18. movsd 16(%rax), %xmm2
  19. movsd 24(%rax), %xmm3
  20. # check for stack args
  21. cmp $0, %rcx
  22. jz cycle_end
  23. mov %rsp, %rdx
  24. and $15, %rdx
  25. jz no_abort
  26. int $3
  27. no_abort:
  28. mov %rcx, %rdx
  29. and $1, %rdx
  30. shl $3, %rdx
  31. sub %rdx, %rsp
  32. # store stack args
  33. lea 56(%rax, %rcx, 8), %r9
  34. sub %rsp, %r9 # offset
  35. cycle:
  36. push (%rsp, %r9)
  37. loop cycle
  38. cycle_end:
  39. mov 32(%rax), %rcx
  40. mov 40(%rax), %rdx
  41. mov 48(%rax), %r8
  42. mov 56(%rax), %r9
  43. sub $32, %rsp # shadow space
  44. call *%r10
  45. leave
  46. ret