common_entry_exit_abi1.S 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. //===----------------------Hexagon builtin routine ------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. // Functions that implement common sequences in function prologues and epilogues
  9. // used to save code size
  10. .macro FUNCTION_BEGIN name
  11. .text
  12. .globl \name
  13. .type \name, @function
  14. .falign
  15. \name:
  16. .endm
  17. .macro FUNCTION_END name
  18. .size \name, . - \name
  19. .endm
  20. .macro FALLTHROUGH_TAIL_CALL name0 name1
  21. .size \name0, . - \name0
  22. .globl \name1
  23. .type \name1, @function
  24. .falign
  25. \name1:
  26. .endm
  27. // Save r25:24 at fp+#-8 and r27:26 at fp+#-16.
  28. // The compiler knows that the __save_* functions clobber LR. No other
  29. // registers should be used without informing the compiler.
  30. // Since we can only issue one store per packet, we don't hurt performance by
  31. // simply jumping to the right point in this sequence of stores.
  32. FUNCTION_BEGIN __save_r24_through_r27
  33. memd(fp+#-16) = r27:26
  34. FALLTHROUGH_TAIL_CALL __save_r24_through_r27 __save_r24_through_r25
  35. {
  36. memd(fp+#-8) = r25:24
  37. jumpr lr
  38. }
  39. FUNCTION_END __save_r24_through_r25
  40. // For each of the *_before_tailcall functions, jumpr lr is executed in parallel
  41. // with deallocframe. That way, the return gets the old value of lr, which is
  42. // where these functions need to return, and at the same time, lr gets the value
  43. // it needs going into the tail call.
  44. FUNCTION_BEGIN __restore_r24_through_r27_and_deallocframe_before_tailcall
  45. r27:26 = memd(fp+#-16)
  46. FALLTHROUGH_TAIL_CALL __restore_r24_through_r27_and_deallocframe_before_tailcall __restore_r24_through_r25_and_deallocframe_before_tailcall
  47. {
  48. r25:24 = memd(fp+#-8)
  49. deallocframe
  50. jumpr lr
  51. }
  52. FUNCTION_END __restore_r24_through_r25_and_deallocframe_before_tailcall
  53. // Here we use the extra load bandwidth to restore LR early, allowing the return
  54. // to occur in parallel with the deallocframe.
  55. FUNCTION_BEGIN __restore_r24_through_r27_and_deallocframe
  56. {
  57. lr = memw(fp+#4)
  58. r27:26 = memd(fp+#-16)
  59. }
  60. {
  61. r25:24 = memd(fp+#-8)
  62. deallocframe
  63. jumpr lr
  64. }
  65. FUNCTION_END __restore_r24_through_r27_and_deallocframe
  66. // Here the load bandwidth is maximized.
  67. FUNCTION_BEGIN __restore_r24_through_r25_and_deallocframe
  68. {
  69. r25:24 = memd(fp+#-8)
  70. deallocframe
  71. }
  72. jumpr lr
  73. FUNCTION_END __restore_r24_through_r25_and_deallocframe