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