microblaze-enable-dwarf-eh-support.patch 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. Fetched from Xilinx gcc git at https://github.com/Xilinx/gcc
  2. From 23c35173490ac2d6348a668dfc9c1a6eb62171f2 Mon Sep 17 00:00:00 2001
  3. From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
  4. Date: Mon, 18 Jun 2012 20:18:13 +0200
  5. Subject: [PATCH] [Patch, microblaze]: Enable DWARF exception handling support.
  6. Changelog
  7. 2013-03-18 Edgar E. Iglesias <edgar.iglesias@xilinx.com>
  8. David Holsgrove <david.holsgrove@xilinx.com>
  9. * common/config/microblaze/microblaze-common.c: Remove
  10. TARGET_EXCEPT_UNWIND_INFO definition.
  11. * config/microblaze/microblaze-protos.h: Add
  12. microblaze_eh_return prototype.
  13. * gcc/config/microblaze/microblaze.c: (microblaze_must_save_register,
  14. microblaze_expand_epilogue, microblaze_return_addr): Handle
  15. calls_eh_return
  16. (microblaze_eh_return): New function.
  17. * gcc/config/microblaze/microblaze.h: Define RETURN_ADDR_OFFSET,
  18. EH_RETURN_DATA_REGNO, MB_EH_STACKADJ_REGNUM, EH_RETURN_STACKADJ_RTX,
  19. ASM_PREFERRED_EH_DATA_FORMAT
  20. * gcc/config/microblaze/microblaze.md: Define eh_return pattern.
  21. Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
  22. Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
  23. ---
  24. gcc/common/config/microblaze/microblaze-common.c | 3 ---
  25. gcc/config/microblaze/microblaze-protos.h | 1 +
  26. gcc/config/microblaze/microblaze.c | 29 ++++++++++++++++++++----
  27. gcc/config/microblaze/microblaze.h | 15 ++++++++++++
  28. gcc/config/microblaze/microblaze.md | 11 +++++++++
  29. 5 files changed, 52 insertions(+), 7 deletions(-)
  30. Index: b/gcc/common/config/microblaze/microblaze-common.c
  31. ===================================================================
  32. --- a/gcc/common/config/microblaze/microblaze-common.c
  33. +++ b/gcc/common/config/microblaze/microblaze-common.c
  34. @@ -37,7 +37,4 @@
  35. #undef TARGET_OPTION_OPTIMIZATION_TABLE
  36. #define TARGET_OPTION_OPTIMIZATION_TABLE microblaze_option_optimization_table
  37. -#undef TARGET_EXCEPT_UNWIND_INFO
  38. -#define TARGET_EXCEPT_UNWIND_INFO sjlj_except_unwind_info
  39. -
  40. struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER;
  41. Index: b/gcc/config/microblaze/microblaze-protos.h
  42. ===================================================================
  43. --- a/gcc/config/microblaze/microblaze-protos.h
  44. +++ b/gcc/config/microblaze/microblaze-protos.h
  45. @@ -56,6 +56,7 @@
  46. extern int symbol_mentioned_p (rtx);
  47. extern int label_mentioned_p (rtx);
  48. extern bool microblaze_cannot_force_const_mem (machine_mode, rtx);
  49. +extern void microblaze_eh_return (rtx op0);
  50. #endif /* RTX_CODE */
  51. /* Declare functions in microblaze-c.c. */
  52. Index: b/gcc/config/microblaze/microblaze.c
  53. ===================================================================
  54. --- a/gcc/config/microblaze/microblaze.c
  55. +++ b/gcc/config/microblaze/microblaze.c
  56. @@ -1959,6 +1959,11 @@
  57. if (frame_pointer_needed && (regno == HARD_FRAME_POINTER_REGNUM))
  58. return 1;
  59. + if (crtl->calls_eh_return
  60. + && regno == MB_ABI_SUB_RETURN_ADDR_REGNUM) {
  61. + return 1;
  62. + }
  63. +
  64. if (!crtl->is_leaf)
  65. {
  66. if (regno == MB_ABI_SUB_RETURN_ADDR_REGNUM)
  67. @@ -1986,6 +1991,13 @@
  68. return 1;
  69. }
  70. + if (crtl->calls_eh_return
  71. + && (regno == EH_RETURN_DATA_REGNO (0)
  72. + || regno == EH_RETURN_DATA_REGNO (1)))
  73. + {
  74. + return 1;
  75. + }
  76. +
  77. return 0;
  78. }
  79. @@ -3067,6 +3079,12 @@
  80. emit_insn (gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx, fsiz_rtx));
  81. }
  82. + if (crtl->calls_eh_return)
  83. + emit_insn (gen_addsi3 (stack_pointer_rtx,
  84. + stack_pointer_rtx,
  85. + gen_rtx_raw_REG (SImode,
  86. + MB_EH_STACKADJ_REGNUM)));
  87. +
  88. emit_jump_insn (gen_return_internal (gen_rtx_REG (Pmode, GP_REG_FIRST +
  89. MB_ABI_SUB_RETURN_ADDR_REGNUM)));
  90. }
  91. @@ -3364,10 +3382,13 @@
  92. if (count != 0)
  93. return NULL_RTX;
  94. - return gen_rtx_PLUS (Pmode,
  95. - get_hard_reg_initial_val (Pmode,
  96. - MB_ABI_SUB_RETURN_ADDR_REGNUM),
  97. - GEN_INT (8));
  98. + return get_hard_reg_initial_val (Pmode,
  99. + MB_ABI_SUB_RETURN_ADDR_REGNUM);
  100. +}
  101. +
  102. +void microblaze_eh_return (rtx op0)
  103. +{
  104. + emit_insn (gen_movsi(gen_rtx_MEM(Pmode, stack_pointer_rtx), op0));
  105. }
  106. /* Queue an .ident string in the queue of top-level asm statements.
  107. Index: b/gcc/config/microblaze/microblaze.h
  108. ===================================================================
  109. --- a/gcc/config/microblaze/microblaze.h
  110. +++ b/gcc/config/microblaze/microblaze.h
  111. @@ -184,6 +184,21 @@
  112. #define INCOMING_RETURN_ADDR_RTX \
  113. gen_rtx_REG (VOIDmode, GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM)
  114. +/* Specifies the offset from INCOMING_RETURN_ADDR_RTX and the actual return PC. */
  115. +#define RETURN_ADDR_OFFSET (8)
  116. +
  117. +/* Describe how we implement __builtin_eh_return. */
  118. +#define EH_RETURN_DATA_REGNO(N) (((N) < 2) ? MB_ABI_FIRST_ARG_REGNUM + (N) : INVALID_REGNUM)
  119. +
  120. +#define MB_EH_STACKADJ_REGNUM MB_ABI_INT_RETURN_VAL2_REGNUM
  121. +#define EH_RETURN_STACKADJ_RTX gen_rtx_REG (Pmode, MB_EH_STACKADJ_REGNUM)
  122. +
  123. +/* Select a format to encode pointers in exception handling data. CODE
  124. + is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is
  125. + true if the symbol may be affected by dynamic relocations. */
  126. +#define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \
  127. + ((flag_pic || GLOBAL) ? DW_EH_PE_aligned : DW_EH_PE_absptr)
  128. +
  129. /* Use DWARF 2 debugging information by default. */
  130. #define DWARF2_DEBUGGING_INFO
  131. #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
  132. Index: b/gcc/config/microblaze/microblaze.md
  133. ===================================================================
  134. --- a/gcc/config/microblaze/microblaze.md
  135. +++ b/gcc/config/microblaze/microblaze.md
  136. @@ -2272,4 +2272,15 @@
  137. (set_attr "mode" "SI")
  138. (set_attr "length" "4")])
  139. +; This is used in compiling the unwind routines.
  140. +(define_expand "eh_return"
  141. + [(use (match_operand 0 "general_operand" ""))]
  142. + ""
  143. + "
  144. +{
  145. + microblaze_eh_return(operands[0]);
  146. + DONE;
  147. +}")
  148. +
  149. (include "sync.md")
  150. +