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

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