diff options
author | Nathan Rossi <nathan@nathanrossi.com> | 2016-09-27 23:48:23 +1000 |
---|---|---|
committer | Nathan Rossi <nathan@nathanrossi.com> | 2016-10-11 21:10:52 +1000 |
commit | e7cfe30e2a8fc15c27e0f319509e8e06f637c081 (patch) | |
tree | 71447748ee9dc1829f176b626d40506256bb3d3e /recipes-microblaze | |
parent | d904dafd51dd0f1ec2264b8dbcb7b637b4c5b11a (diff) | |
download | meta-xilinx-e7cfe30e2a8fc15c27e0f319509e8e06f637c081.tar.gz |
gcc-source: Add MicroBlaze DWARF exception support
This resolves some issues with unwind support needed for pthread.
Signed-off-by: Nathan Rossi <nathan@nathanrossi.com>
Diffstat (limited to 'recipes-microblaze')
-rw-r--r-- | recipes-microblaze/gcc/files/Enable-DWARF-exception-handling-support.patch | 167 | ||||
-rw-r--r-- | recipes-microblaze/gcc/gcc-source_6.%.bbappend | 1 |
2 files changed, 168 insertions, 0 deletions
diff --git a/recipes-microblaze/gcc/files/Enable-DWARF-exception-handling-support.patch b/recipes-microblaze/gcc/files/Enable-DWARF-exception-handling-support.patch new file mode 100644 index 00000000..4a16d2f7 --- /dev/null +++ b/recipes-microblaze/gcc/files/Enable-DWARF-exception-handling-support.patch | |||
@@ -0,0 +1,167 @@ | |||
1 | From 7a9ef06991e293be4d5ef2be1d9716a31f90447e 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] Enable DWARF exception handling support. | ||
5 | |||
6 | Changelog | ||
7 | |||
8 | 2013-03-18 Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
9 | David Holsgrove <david.holsgrove@xilinx.com> | ||
10 | |||
11 | * common/config/microblaze/microblaze-common.c: Remove | ||
12 | TARGET_EXCEPT_UNWIND_INFO definition. | ||
13 | * config/microblaze/microblaze-protos.h: Add | ||
14 | microblaze_eh_return prototype. | ||
15 | * gcc/config/microblaze/microblaze.c: (microblaze_must_save_register, | ||
16 | microblaze_expand_epilogue, microblaze_return_addr): Handle | ||
17 | calls_eh_return | ||
18 | (microblaze_eh_return): New function. | ||
19 | * gcc/config/microblaze/microblaze.h: Define RETURN_ADDR_OFFSET, | ||
20 | EH_RETURN_DATA_REGNO, MB_EH_STACKADJ_REGNUM, EH_RETURN_STACKADJ_RTX, | ||
21 | ASM_PREFERRED_EH_DATA_FORMAT | ||
22 | * gcc/config/microblaze/microblaze.md: Define eh_return pattern. | ||
23 | |||
24 | Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com> | ||
25 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com> | ||
26 | --- | ||
27 | gcc/common/config/microblaze/microblaze-common.c | 3 --- | ||
28 | gcc/config/microblaze/microblaze-protos.h | 1 + | ||
29 | gcc/config/microblaze/microblaze.c | 29 ++++++++++++++++++++---- | ||
30 | gcc/config/microblaze/microblaze.h | 15 ++++++++++++ | ||
31 | gcc/config/microblaze/microblaze.md | 11 +++++++++ | ||
32 | 5 files changed, 52 insertions(+), 7 deletions(-) | ||
33 | |||
34 | diff --git a/gcc/common/config/microblaze/microblaze-common.c b/gcc/common/config/microblaze/microblaze-common.c | ||
35 | index f369bc58d1..0e1bdc4f58 100644 | ||
36 | --- a/gcc/common/config/microblaze/microblaze-common.c | ||
37 | +++ b/gcc/common/config/microblaze/microblaze-common.c | ||
38 | @@ -37,7 +37,4 @@ static const struct default_options microblaze_option_optimization_table[] = | ||
39 | #undef TARGET_OPTION_OPTIMIZATION_TABLE | ||
40 | #define TARGET_OPTION_OPTIMIZATION_TABLE microblaze_option_optimization_table | ||
41 | |||
42 | -#undef TARGET_EXCEPT_UNWIND_INFO | ||
43 | -#define TARGET_EXCEPT_UNWIND_INFO sjlj_except_unwind_info | ||
44 | - | ||
45 | struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER; | ||
46 | diff --git a/gcc/config/microblaze/microblaze-protos.h b/gcc/config/microblaze/microblaze-protos.h | ||
47 | index 1cfaf08c1c..cc3b4619c4 100644 | ||
48 | --- a/gcc/config/microblaze/microblaze-protos.h | ||
49 | +++ b/gcc/config/microblaze/microblaze-protos.h | ||
50 | @@ -57,6 +57,7 @@ extern bool microblaze_tls_referenced_p (rtx); | ||
51 | extern int symbol_mentioned_p (rtx); | ||
52 | extern int label_mentioned_p (rtx); | ||
53 | extern bool microblaze_cannot_force_const_mem (machine_mode, rtx); | ||
54 | +extern void microblaze_eh_return (rtx op0); | ||
55 | #endif /* RTX_CODE */ | ||
56 | |||
57 | /* Declare functions in microblaze-c.c. */ | ||
58 | diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c | ||
59 | index baff67a89c..71f1495bae 100644 | ||
60 | --- a/gcc/config/microblaze/microblaze.c | ||
61 | +++ b/gcc/config/microblaze/microblaze.c | ||
62 | @@ -1924,6 +1924,11 @@ microblaze_must_save_register (int regno) | ||
63 | if (frame_pointer_needed && (regno == HARD_FRAME_POINTER_REGNUM)) | ||
64 | return 1; | ||
65 | |||
66 | + if (crtl->calls_eh_return | ||
67 | + && regno == MB_ABI_SUB_RETURN_ADDR_REGNUM) { | ||
68 | + return 1; | ||
69 | + } | ||
70 | + | ||
71 | if (!crtl->is_leaf) | ||
72 | { | ||
73 | if (regno == MB_ABI_SUB_RETURN_ADDR_REGNUM) | ||
74 | @@ -1951,6 +1956,13 @@ microblaze_must_save_register (int regno) | ||
75 | return 1; | ||
76 | } | ||
77 | |||
78 | + if (crtl->calls_eh_return | ||
79 | + && (regno == EH_RETURN_DATA_REGNO (0) | ||
80 | + || regno == EH_RETURN_DATA_REGNO (1))) | ||
81 | + { | ||
82 | + return 1; | ||
83 | + } | ||
84 | + | ||
85 | return 0; | ||
86 | } | ||
87 | |||
88 | @@ -3027,6 +3039,12 @@ microblaze_expand_epilogue (void) | ||
89 | emit_insn (gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx, fsiz_rtx)); | ||
90 | } | ||
91 | |||
92 | + if (crtl->calls_eh_return) | ||
93 | + emit_insn (gen_addsi3 (stack_pointer_rtx, | ||
94 | + stack_pointer_rtx, | ||
95 | + gen_rtx_REG (SImode, | ||
96 | + MB_EH_STACKADJ_REGNUM))); | ||
97 | + | ||
98 | emit_jump_insn (gen_return_internal (gen_rtx_REG (Pmode, GP_REG_FIRST + | ||
99 | MB_ABI_SUB_RETURN_ADDR_REGNUM))); | ||
100 | } | ||
101 | @@ -3324,10 +3342,13 @@ microblaze_return_addr (int count, rtx frame ATTRIBUTE_UNUSED) | ||
102 | if (count != 0) | ||
103 | return NULL_RTX; | ||
104 | |||
105 | - return gen_rtx_PLUS (Pmode, | ||
106 | - get_hard_reg_initial_val (Pmode, | ||
107 | - MB_ABI_SUB_RETURN_ADDR_REGNUM), | ||
108 | - GEN_INT (8)); | ||
109 | + return get_hard_reg_initial_val (Pmode, | ||
110 | + MB_ABI_SUB_RETURN_ADDR_REGNUM); | ||
111 | +} | ||
112 | + | ||
113 | +void microblaze_eh_return (rtx op0) | ||
114 | +{ | ||
115 | + emit_insn (gen_movsi(gen_rtx_MEM(Pmode, stack_pointer_rtx), op0)); | ||
116 | } | ||
117 | |||
118 | /* Queue an .ident string in the queue of top-level asm statements. | ||
119 | diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h | ||
120 | index e115c42839..4b0662024b 100644 | ||
121 | --- a/gcc/config/microblaze/microblaze.h | ||
122 | +++ b/gcc/config/microblaze/microblaze.h | ||
123 | @@ -184,6 +184,21 @@ extern enum pipeline_type microblaze_pipe; | ||
124 | #define INCOMING_RETURN_ADDR_RTX \ | ||
125 | gen_rtx_REG (VOIDmode, GP_REG_FIRST + MB_ABI_SUB_RETURN_ADDR_REGNUM) | ||
126 | |||
127 | +/* Specifies the offset from INCOMING_RETURN_ADDR_RTX and the actual return PC. */ | ||
128 | +#define RETURN_ADDR_OFFSET (8) | ||
129 | + | ||
130 | +/* Describe how we implement __builtin_eh_return. */ | ||
131 | +#define EH_RETURN_DATA_REGNO(N) (((N) < 2) ? MB_ABI_FIRST_ARG_REGNUM + (N) : INVALID_REGNUM) | ||
132 | + | ||
133 | +#define MB_EH_STACKADJ_REGNUM MB_ABI_INT_RETURN_VAL2_REGNUM | ||
134 | +#define EH_RETURN_STACKADJ_RTX gen_rtx_REG (Pmode, MB_EH_STACKADJ_REGNUM) | ||
135 | + | ||
136 | +/* Select a format to encode pointers in exception handling data. CODE | ||
137 | + is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is | ||
138 | + true if the symbol may be affected by dynamic relocations. */ | ||
139 | +#define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \ | ||
140 | + ((flag_pic || GLOBAL) ? DW_EH_PE_aligned : DW_EH_PE_absptr) | ||
141 | + | ||
142 | /* Use DWARF 2 debugging information by default. */ | ||
143 | #define DWARF2_DEBUGGING_INFO | ||
144 | #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG | ||
145 | diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md | ||
146 | index 85776237c1..b388d25741 100644 | ||
147 | --- a/gcc/config/microblaze/microblaze.md | ||
148 | +++ b/gcc/config/microblaze/microblaze.md | ||
149 | @@ -2324,4 +2324,15 @@ | ||
150 | (set_attr "mode" "SI") | ||
151 | (set_attr "length" "4")]) | ||
152 | |||
153 | +; This is used in compiling the unwind routines. | ||
154 | +(define_expand "eh_return" | ||
155 | + [(use (match_operand 0 "general_operand" ""))] | ||
156 | + "" | ||
157 | + " | ||
158 | +{ | ||
159 | + microblaze_eh_return(operands[0]); | ||
160 | + DONE; | ||
161 | +}") | ||
162 | + | ||
163 | (include "sync.md") | ||
164 | + | ||
165 | -- | ||
166 | 2.9.3 | ||
167 | |||
diff --git a/recipes-microblaze/gcc/gcc-source_6.%.bbappend b/recipes-microblaze/gcc/gcc-source_6.%.bbappend index 76b4f60c..b3e8c071 100644 --- a/recipes-microblaze/gcc/gcc-source_6.%.bbappend +++ b/recipes-microblaze/gcc/gcc-source_6.%.bbappend | |||
@@ -4,5 +4,6 @@ FILESEXTRAPATHS_append := "${THISDIR}/files:" | |||
4 | SRC_URI_append = " \ | 4 | SRC_URI_append = " \ |
5 | file://microblaze.md-Improve-adddi3-and-subdi3-insn-definit.patch \ | 5 | file://microblaze.md-Improve-adddi3-and-subdi3-insn-definit.patch \ |
6 | file://gcc-config-microblaze-Make-r21-fixed-due-to-Linux-AB.patch \ | 6 | file://gcc-config-microblaze-Make-r21-fixed-due-to-Linux-AB.patch \ |
7 | file://Enable-DWARF-exception-handling-support.patch \ | ||
7 | " | 8 | " |
8 | 9 | ||