invokeNative_mips.s 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. .text
  6. .align 2
  7. .globl invokeNative
  8. .ent invokeNative
  9. .type invokeNative, @function
  10. /**
  11. * On function entry parameters:
  12. * $4 = func_ptr
  13. * $5 = args
  14. * $6 = arg_num
  15. */
  16. invokeNative:
  17. .frame $fp, 8, $0
  18. .mask 0x00000000, 0
  19. .fmask 0x00000000, 0
  20. /* Fixed part of frame */
  21. subu $sp, 8
  22. /* save registers */
  23. sw $31, 4($sp)
  24. sw $fp, 0($sp)
  25. /* set frame pointer to bottom of fixed frame */
  26. move $fp, $sp
  27. /* allocate enough stack space */
  28. sll $11, $6, 2 /* $11 == arg_num * 4 */
  29. subu $sp, $11
  30. /* make 8-byte aligned */
  31. and $sp, ~7
  32. move $9, $sp
  33. move $25, $4 /* $25 = func_ptr */
  34. push_args:
  35. beq $6, 0, done /* arg_num == 0 ? */
  36. lw $8, 0($5) /* $8 = *args */
  37. sw $8, 0($9) /* store $8 to stack */
  38. addu $5, 4 /* args++ */
  39. addu $9, 4 /* sp++ */
  40. subu $6, 1 /* arg_num-- */
  41. j push_args
  42. done:
  43. lw $4, 0($sp) /* Load $4..$7 from stack */
  44. lw $5, 4($sp)
  45. lw $6, 8($sp)
  46. lw $7, 12($sp)
  47. ldc1 $f12, 0($sp) /* Load $f12, $f13, $f14, $f15 */
  48. ldc1 $f14, 8($sp)
  49. jalr $25 /* call function */
  50. nop
  51. /* restore saved registers */
  52. move $sp, $fp
  53. lw $31, 4($sp)
  54. lw $fp, 0($sp)
  55. /* pop frame */
  56. addu $sp, $sp, 8
  57. j $31
  58. .end invokeNative
  59. #if defined(__linux__) && defined(__ELF__)
  60. .section .note.GNU-stack,"",%progbits
  61. #endif