summaryrefslogtreecommitdiffstats
path: root/meta-microblaze/recipes-devtools/gcc/gcc-12/0033-Patch-MicroBlaze.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-microblaze/recipes-devtools/gcc/gcc-12/0033-Patch-MicroBlaze.patch')
-rw-r--r--meta-microblaze/recipes-devtools/gcc/gcc-12/0033-Patch-MicroBlaze.patch305
1 files changed, 305 insertions, 0 deletions
diff --git a/meta-microblaze/recipes-devtools/gcc/gcc-12/0033-Patch-MicroBlaze.patch b/meta-microblaze/recipes-devtools/gcc/gcc-12/0033-Patch-MicroBlaze.patch
new file mode 100644
index 00000000..9c9e4dd2
--- /dev/null
+++ b/meta-microblaze/recipes-devtools/gcc/gcc-12/0033-Patch-MicroBlaze.patch
@@ -0,0 +1,305 @@
1From 0a86428a345ed359f788a72a0e185053b598e908 Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 13 Sep 2022 15:28:58 +0530
4Subject: [PATCH 33/53] [Patch,MicroBlaze]: fixed below issues: - Floating
5 point print issues in 64bit mode - Dejagnu Jump related issues -
6 Added dbl instruction
7
8 Conflicts:
9 gcc/config/microblaze/microblaze.md
10---
11 gcc/config/microblaze/microblaze.cc | 12 +++-
12 gcc/config/microblaze/microblaze.h | 7 +++
13 gcc/config/microblaze/microblaze.md | 86 ++++++++++++++++++++++++-----
14 libgcc/config/microblaze/crti.S | 24 +++++++-
15 libgcc/config/microblaze/crtn.S | 13 +++++
16 5 files changed, 125 insertions(+), 17 deletions(-)
17
18diff --git a/gcc/config/microblaze/microblaze.cc b/gcc/config/microblaze/microblaze.cc
19index f1da145232a..7a08390a027 100644
20--- a/gcc/config/microblaze/microblaze.cc
21+++ b/gcc/config/microblaze/microblaze.cc
22@@ -2474,7 +2474,12 @@ print_operand (FILE * file, rtx op, int letter)
23 if (code == CONST_DOUBLE)
24 {
25 if (GET_MODE (op) == DFmode)
26- REAL_VALUE_TO_TARGET_DOUBLE (*CONST_DOUBLE_REAL_VALUE (op), val);
27+ {
28+ if (TARGET_MB_64)
29+ REAL_VALUE_TO_TARGET_LONG_DOUBLE (*CONST_DOUBLE_REAL_VALUE (op), val);
30+ else
31+ REAL_VALUE_TO_TARGET_DOUBLE (*CONST_DOUBLE_REAL_VALUE (op), val);
32+ }
33 else
34 {
35 REAL_VALUE_TO_TARGET_DOUBLE (*CONST_DOUBLE_REAL_VALUE (op), l);
36@@ -3877,7 +3882,10 @@ microblaze_expand_divide (rtx operands[])
37 gen_rtx_PLUS (QImode, regt1, div_table_rtx));
38
39 insn = emit_insn (gen_zero_extendqisi2(operands[0],mem_rtx));
40- jump = emit_jump_insn_after (gen_jump (div_end_label), insn);
41+ if (TARGET_MB_64)
42+ jump = emit_jump_insn_after (gen_jump_64 (div_end_label), insn);
43+ else
44+ jump = emit_jump_insn_after (gen_jump (div_end_label), insn);
45 JUMP_LABEL (jump) = div_end_label;
46 LABEL_NUSES (div_end_label) = 1;
47 emit_barrier ();
48diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
49index 5f30b8ac195..ac4ea43a706 100644
50--- a/gcc/config/microblaze/microblaze.h
51+++ b/gcc/config/microblaze/microblaze.h
52@@ -888,10 +888,17 @@ do { \
53 /* We do this to save a few 10s of code space that would be taken up
54 by the call_FUNC () wrappers, used by the generic CRT_CALL_STATIC_FUNCTION
55 definition in crtstuff.c. */
56+#ifdef __arch64__
57+#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
58+ asm ( SECTION_OP "\n" \
59+ "\tbrealid r15, " #FUNC "\n\t nop\n" \
60+ TEXT_SECTION_ASM_OP);
61+#else
62 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
63 asm ( SECTION_OP "\n" \
64 "\tbrlid r15, " #FUNC "\n\t nop\n" \
65 TEXT_SECTION_ASM_OP);
66+#endif
67
68 /* We need to group -lm as well, since some Newlib math functions
69 reference __errno! */
70diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
71index 4e5d21a1f4c..5a950b49591 100644
72--- a/gcc/config/microblaze/microblaze.md
73+++ b/gcc/config/microblaze/microblaze.md
74@@ -527,6 +527,15 @@
75 (set_attr "mode" "SF")
76 (set_attr "length" "4")])
77
78+(define_insn "floatdidf2"
79+ [(set (match_operand:DF 0 "register_operand" "=d")
80+ (float:DF (match_operand:DI 1 "register_operand" "d")))]
81+ "TARGET_MB_64"
82+ "dbl\t%0,%1"
83+ [(set_attr "type" "fcvt")
84+ (set_attr "mode" "DF")
85+ (set_attr "length" "4")])
86+
87 (define_insn "fix_truncsfsi2"
88 [(set (match_operand:SI 0 "register_operand" "=d")
89 (fix:SI (match_operand:SF 1 "register_operand" "d")))]
90@@ -1299,7 +1308,7 @@
91 (define_insn "movdi_long_int"
92 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
93 (match_operand:DI 1 "general_operand" "i"))]
94- ""
95+ "TARGET_MB_64"
96 "addlik\t%0,r0,%h1\n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #li => la";
97 [(set_attr "type" "no_delay_arith")
98 (set_attr "mode" "DI")
99@@ -1582,7 +1591,7 @@
100 return "ll%i1\t%0,%1";
101 case 3:
102 {
103- return "addlik\t%0,r0,%h1 \n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #Xfer Lo";
104+ return "addlik\t%0,r0,%j1 \n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%h1 #Xfer Lo";
105 }
106 case 5:
107 return "sl%i0\t%1,%0";
108@@ -2371,9 +2380,9 @@ else
109
110 (define_insn "long_branch_compare"
111 [(set (pc)
112- (if_then_else (match_operator 0 "cmp_op"
113- [(match_operand 1 "register_operand" "d")
114- (match_operand 2 "register_operand" "d")
115+ (if_then_else (match_operator:DI 0 "cmp_op"
116+ [(match_operand:DI 1 "register_operand" "d")
117+ (match_operand:DI 2 "register_operand" "d")
118 ])
119 (label_ref (match_operand 3))
120 (pc)))
121@@ -2495,6 +2504,20 @@ else
122 ;;----------------------------------------------------------------
123 ;; Unconditional branches
124 ;;----------------------------------------------------------------
125+(define_insn "jump_64"
126+ [(set (pc)
127+ (label_ref (match_operand 0 "" "")))]
128+ "TARGET_MB_64"
129+ {
130+ if (GET_CODE (operands[0]) == REG)
131+ return "brea%?\t%0";
132+ else
133+ return "breai%?\t%l0";
134+ }
135+ [(set_attr "type" "jump")
136+ (set_attr "mode" "none")
137+ (set_attr "length" "4")])
138+
139 (define_insn "jump"
140 [(set (pc)
141 (label_ref (match_operand 0 "" "")))]
142@@ -2540,17 +2563,25 @@ else
143 {
144 //gcc_assert (GET_MODE (operands[0]) == Pmode);
145
146- if (!flag_pic || TARGET_PIC_DATA_TEXT_REL)
147- emit_jump_insn (gen_tablejump_internal1 (operands[0], operands[1]));
148- else
149- emit_jump_insn (gen_tablejump_internal3 (operands[0], operands[1]));
150+ if (!flag_pic || TARGET_PIC_DATA_TEXT_REL) {
151+ if (!TARGET_MB_64)
152+ emit_jump_insn (gen_tablejump_internal1 (operands[0], operands[1]));
153+ else
154+ emit_jump_insn (gen_tablejump_internal2 (operands[0], operands[1]));
155+ }
156+ else {
157+ if (!TARGET_MB_64)
158+ emit_jump_insn (gen_tablejump_internal3 (operands[0], operands[1]));
159+ else
160+ emit_jump_insn (gen_tablejump_internal4 (operands[0], operands[1]));
161+ }
162 DONE;
163 }
164 )
165
166 (define_insn "tablejump_internal1"
167 [(set (pc)
168- (match_operand 0 "register_operand" "d"))
169+ (match_operand:SI 0 "register_operand" "d"))
170 (use (label_ref (match_operand 1 "" "")))]
171 ""
172 "bra%?\t%0 "
173@@ -2558,11 +2589,21 @@ else
174 (set_attr "mode" "none")
175 (set_attr "length" "4")])
176
177+(define_insn "tablejump_internal2"
178+ [(set (pc)
179+ (match_operand:DI 0 "register_operand" "d"))
180+ (use (label_ref (match_operand 1 "" "")))]
181+ "TARGET_MB_64"
182+ "bra%?\t%0 "
183+ [(set_attr "type" "jump")
184+ (set_attr "mode" "none")
185+ (set_attr "length" "4")])
186+
187 (define_expand "tablejump_internal3"
188 [(parallel [(set (pc)
189- (plus (match_operand 0 "register_operand" "d")
190- (label_ref (match_operand:SI 1 "" ""))))
191- (use (label_ref (match_dup 1)))])]
192+ (plus:SI (match_operand:SI 0 "register_operand" "d")
193+ (label_ref:SI (match_operand:SI 1 "" ""))))
194+ (use (label_ref:SI (match_dup 1)))])]
195 ""
196 ""
197 )
198@@ -2593,6 +2634,23 @@ else
199 ""
200 )
201
202+(define_insn ""
203+ [(set (pc)
204+ (plus:DI (match_operand:DI 0 "register_operand" "d")
205+ (label_ref:DI (match_operand 1 "" ""))))
206+ (use (label_ref:DI (match_dup 1)))]
207+ "TARGET_MB_64 && NEXT_INSN (as_a <rtx_insn *> (operands[1])) != 0
208+ && GET_CODE (PATTERN (NEXT_INSN (as_a <rtx_insn *> (operands[1])))) == ADDR_DIFF_VEC
209+ && flag_pic"
210+ {
211+ output_asm_insn ("addlk\t%0,%0,r20",operands);
212+ return "bra%?\t%0";
213+}
214+ [(set_attr "type" "jump")
215+ (set_attr "mode" "none")
216+ (set_attr "length" "4")])
217+
218+
219 ;;----------------------------------------------------------------
220 ;; Function prologue/epilogue and stack allocation
221 ;;----------------------------------------------------------------
222@@ -3101,7 +3159,7 @@ else
223 ;; The insn to set GOT. The hardcoded number "8" accounts for $pc difference
224 ;; between "mfs" and "addik" instructions.
225 (define_insn "set_got"
226- [(set (match_operand:SI 0 "register_operand" "=r")
227+ [(set (match_operand 0 "register_operand" "=r")
228 (unspec:SI [(const_int 0)] UNSPEC_SET_GOT))]
229 ""
230 "mfs\t%0,rpc\n\taddik\t%0,%0,_GLOBAL_OFFSET_TABLE_+8"
231diff --git a/libgcc/config/microblaze/crti.S b/libgcc/config/microblaze/crti.S
232index ec797e1bf17..15ebe68c277 100644
233--- a/libgcc/config/microblaze/crti.S
234+++ b/libgcc/config/microblaze/crti.S
235@@ -33,11 +33,32 @@
236 .section .init, "ax"
237 .global __init
238
239+#ifdef __arch64__
240 .weak _stack
241- .set _stack, 0xffffffff
242+ .set _stack, 0xffffffffffffffff
243 .weak _stack_end
244 .set _stack_end, 0
245
246+ .align 3
247+__init:
248+ addlik r1, r1, -32
249+ sl r15, r0, r1
250+ addlik r11, r0, _stack
251+ mts rshr, r11
252+ addlik r11, r0, _stack_end
253+ mts rslr, r11
254+
255+ .section .fini, "ax"
256+ .global __fini
257+ .align 3
258+__fini:
259+ addlik r1, r1, -32
260+ sl r15, r0, r1
261+#else
262+ .weak _stack
263+ .set _stack, 0xffffffff
264+ .weak _stack_end
265+ .set _stack_end, 0
266 .align 2
267 __init:
268 addik r1, r1, -16
269@@ -53,3 +74,4 @@ __init:
270 __fini:
271 addik r1, r1, -16
272 sw r15, r0, r1
273+#endif
274diff --git a/libgcc/config/microblaze/crtn.S b/libgcc/config/microblaze/crtn.S
275index 977b43b9436..9de3d4de13c 100644
276--- a/libgcc/config/microblaze/crtn.S
277+++ b/libgcc/config/microblaze/crtn.S
278@@ -29,7 +29,19 @@
279 .section .note.GNU-stack,"",%progbits
280 .previous
281 #endif
282+#ifdef __arch64__
283+ .section .init, "ax"
284+ ll r15, r0, r1
285+ addlik r1, r1, 32
286+ rtsd r15, 8
287+ nop
288
289+ .section .fini, "ax"
290+ ll r15, r0, r1
291+ addlik r1, r1, 32
292+ rtsd r15, 8
293+ nop
294+#else
295 .section .init, "ax"
296 lw r15, r0, r1
297 rtsd r15, 8
298@@ -39,3 +51,4 @@
299 lw r15, r0, r1
300 rtsd r15, 8
301 addik r1, r1, 16
302+#endif
303--
3042.37.1 (Apple Git-137.1)
305