blob: 61d352617fcfd58b340c545b7fd0d02034dbd8bd [file] [log] [blame]
Andrew Geissler10fa1492020-12-11 16:25:29 -06001From 051d744c06ed3f11f603e37768eece57784c2583 Mon Sep 17 00:00:00 2001
Andrew Geissler84ad7c52020-06-27 00:00:16 -05002From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 26 Nov 2019 17:26:15 +0530
Andrew Geissler10fa1492020-12-11 16:25:29 -06004Subject: [PATCH 35/54] Fixed below issues:
Brad Bishop26bdd442019-08-16 17:08:17 -04005
Andrew Geissler84ad7c52020-06-27 00:00:16 -05006- Floating point print issues in 64bit mode
7- Dejagnu Jump related issues
8- Added dbl instruction
Andrew Geissler10fa1492020-12-11 16:25:29 -06009
10Conflicts:
11 gcc/config/microblaze/microblaze.md
Brad Bishop26bdd442019-08-16 17:08:17 -040012---
Andrew Geisslera9ff2b32020-10-16 10:11:54 -050013 gcc/config/microblaze/microblaze.c | 12 +++-
Brad Bishop26bdd442019-08-16 17:08:17 -040014 gcc/config/microblaze/microblaze.h | 7 +++
Andrew Geisslera9ff2b32020-10-16 10:11:54 -050015 gcc/config/microblaze/microblaze.md | 86 ++++++++++++++++++++++++-----
16 libgcc/config/microblaze/crti.S | 24 +++++++-
17 libgcc/config/microblaze/crtn.S | 13 +++++
Andrew Geissler84ad7c52020-06-27 00:00:16 -050018 5 files changed, 125 insertions(+), 17 deletions(-)
Brad Bishop26bdd442019-08-16 17:08:17 -040019
20diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
Andrew Geissler10fa1492020-12-11 16:25:29 -060021index 498c8ca191f..e32de46fa62 100644
Brad Bishop26bdd442019-08-16 17:08:17 -040022--- a/gcc/config/microblaze/microblaze.c
23+++ b/gcc/config/microblaze/microblaze.c
Andrew Geissler10fa1492020-12-11 16:25:29 -060024@@ -2473,7 +2473,12 @@ print_operand (FILE * file, rtx op, int letter)
Brad Bishop26bdd442019-08-16 17:08:17 -040025 if (code == CONST_DOUBLE)
26 {
27 if (GET_MODE (op) == DFmode)
28- REAL_VALUE_TO_TARGET_DOUBLE (*CONST_DOUBLE_REAL_VALUE (op), val);
29+ {
30+ if (TARGET_MB_64)
31+ REAL_VALUE_TO_TARGET_LONG_DOUBLE (*CONST_DOUBLE_REAL_VALUE (op), val);
32+ else
33+ REAL_VALUE_TO_TARGET_DOUBLE (*CONST_DOUBLE_REAL_VALUE (op), val);
34+ }
35 else
36 {
Andrew Geissler10fa1492020-12-11 16:25:29 -060037 REAL_VALUE_TO_TARGET_DOUBLE (*CONST_DOUBLE_REAL_VALUE (op), l);
38@@ -3876,7 +3881,10 @@ microblaze_expand_divide (rtx operands[])
Brad Bishop26bdd442019-08-16 17:08:17 -040039 gen_rtx_PLUS (QImode, regt1, div_table_rtx));
40
41 insn = emit_insn (gen_zero_extendqisi2(operands[0],mem_rtx));
42- jump = emit_jump_insn_after (gen_jump (div_end_label), insn);
43+ if (TARGET_MB_64)
44+ jump = emit_jump_insn_after (gen_jump_64 (div_end_label), insn);
45+ else
46+ jump = emit_jump_insn_after (gen_jump (div_end_label), insn);
47 JUMP_LABEL (jump) = div_end_label;
48 LABEL_NUSES (div_end_label) = 1;
49 emit_barrier ();
50diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
Andrew Geissler10fa1492020-12-11 16:25:29 -060051index f6ad4d9fc21..60c552958b8 100644
Brad Bishop26bdd442019-08-16 17:08:17 -040052--- a/gcc/config/microblaze/microblaze.h
53+++ b/gcc/config/microblaze/microblaze.h
Andrew Geissler84ad7c52020-06-27 00:00:16 -050054@@ -888,10 +888,17 @@ do { \
Brad Bishop26bdd442019-08-16 17:08:17 -040055 /* We do this to save a few 10s of code space that would be taken up
56 by the call_FUNC () wrappers, used by the generic CRT_CALL_STATIC_FUNCTION
57 definition in crtstuff.c. */
58+#ifdef __arch64__
59+#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
60+ asm ( SECTION_OP "\n" \
61+ "\tbrealid r15, " #FUNC "\n\t nop\n" \
62+ TEXT_SECTION_ASM_OP);
63+#else
64 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
65 asm ( SECTION_OP "\n" \
66 "\tbrlid r15, " #FUNC "\n\t nop\n" \
67 TEXT_SECTION_ASM_OP);
68+#endif
69
70 /* We need to group -lm as well, since some Newlib math functions
71 reference __errno! */
72diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
Andrew Geissler10fa1492020-12-11 16:25:29 -060073index e7c7cf3e8b5..74bb30cb9e8 100644
Brad Bishop26bdd442019-08-16 17:08:17 -040074--- a/gcc/config/microblaze/microblaze.md
75+++ b/gcc/config/microblaze/microblaze.md
Andrew Geissler84ad7c52020-06-27 00:00:16 -050076@@ -527,6 +527,15 @@
Brad Bishop26bdd442019-08-16 17:08:17 -040077 (set_attr "mode" "SF")
78 (set_attr "length" "4")])
79
80+(define_insn "floatdidf2"
81+ [(set (match_operand:DF 0 "register_operand" "=d")
82+ (float:DF (match_operand:DI 1 "register_operand" "d")))]
83+ "TARGET_MB_64"
84+ "dbl\t%0,%1"
85+ [(set_attr "type" "fcvt")
86+ (set_attr "mode" "DF")
87+ (set_attr "length" "4")])
88+
89 (define_insn "fix_truncsfsi2"
90 [(set (match_operand:SI 0 "register_operand" "=d")
91 (fix:SI (match_operand:SF 1 "register_operand" "d")))]
Andrew Geissler10fa1492020-12-11 16:25:29 -060092@@ -1301,7 +1310,7 @@
Brad Bishop26bdd442019-08-16 17:08:17 -040093 (define_insn "movdi_long_int"
94 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
95 (match_operand:DI 1 "general_operand" "i"))]
96- ""
97+ "TARGET_MB_64"
98 "addlik\t%0,r0,%h1\n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #li => la";
99 [(set_attr "type" "no_delay_arith")
100 (set_attr "mode" "DI")
Andrew Geissler10fa1492020-12-11 16:25:29 -0600101@@ -1584,7 +1593,7 @@
Brad Bishop26bdd442019-08-16 17:08:17 -0400102 return "ll%i1\t%0,%1";
103 case 3:
104 {
105- return "addlik\t%0,r0,%h1 \n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #Xfer Lo";
106+ return "addlik\t%0,r0,%j1 \n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%h1 #Xfer Lo";
107 }
108 case 5:
109 return "sl%i0\t%1,%0";
Andrew Geissler10fa1492020-12-11 16:25:29 -0600110@@ -2374,9 +2383,9 @@ else
Brad Bishop26bdd442019-08-16 17:08:17 -0400111
112 (define_insn "long_branch_compare"
113 [(set (pc)
114- (if_then_else (match_operator 0 "cmp_op"
115- [(match_operand 1 "register_operand" "d")
116- (match_operand 2 "register_operand" "d")
117+ (if_then_else (match_operator:DI 0 "cmp_op"
118+ [(match_operand:DI 1 "register_operand" "d")
119+ (match_operand:DI 2 "register_operand" "d")
120 ])
121 (label_ref (match_operand 3))
122 (pc)))
Andrew Geissler10fa1492020-12-11 16:25:29 -0600123@@ -2498,6 +2507,20 @@ else
Brad Bishop26bdd442019-08-16 17:08:17 -0400124 ;;----------------------------------------------------------------
125 ;; Unconditional branches
126 ;;----------------------------------------------------------------
127+(define_insn "jump_64"
128+ [(set (pc)
129+ (label_ref (match_operand 0 "" "")))]
130+ "TARGET_MB_64"
131+ {
132+ if (GET_CODE (operands[0]) == REG)
133+ return "brea%?\t%0";
134+ else
135+ return "breai%?\t%l0";
136+ }
137+ [(set_attr "type" "jump")
138+ (set_attr "mode" "none")
139+ (set_attr "length" "4")])
140+
141 (define_insn "jump"
142 [(set (pc)
143 (label_ref (match_operand 0 "" "")))]
Andrew Geissler10fa1492020-12-11 16:25:29 -0600144@@ -2543,17 +2566,25 @@ else
Brad Bishop26bdd442019-08-16 17:08:17 -0400145 {
Andrew Geissler84ad7c52020-06-27 00:00:16 -0500146 //gcc_assert (GET_MODE (operands[0]) == Pmode);
147
148- if (!flag_pic || TARGET_PIC_DATA_TEXT_REL)
Brad Bishop26bdd442019-08-16 17:08:17 -0400149- emit_jump_insn (gen_tablejump_internal1 (operands[0], operands[1]));
150- else
151- emit_jump_insn (gen_tablejump_internal3 (operands[0], operands[1]));
Andrew Geissler84ad7c52020-06-27 00:00:16 -0500152+ if (!flag_pic || TARGET_PIC_DATA_TEXT_REL) {
153+ if (!TARGET_MB_64)
Brad Bishop26bdd442019-08-16 17:08:17 -0400154+ emit_jump_insn (gen_tablejump_internal1 (operands[0], operands[1]));
Andrew Geissler84ad7c52020-06-27 00:00:16 -0500155+ else
Brad Bishop26bdd442019-08-16 17:08:17 -0400156+ emit_jump_insn (gen_tablejump_internal2 (operands[0], operands[1]));
157+ }
158+ else {
Andrew Geissler84ad7c52020-06-27 00:00:16 -0500159+ if (!TARGET_MB_64)
Brad Bishop26bdd442019-08-16 17:08:17 -0400160+ emit_jump_insn (gen_tablejump_internal3 (operands[0], operands[1]));
Andrew Geissler84ad7c52020-06-27 00:00:16 -0500161+ else
Brad Bishop26bdd442019-08-16 17:08:17 -0400162+ emit_jump_insn (gen_tablejump_internal4 (operands[0], operands[1]));
163+ }
164 DONE;
165 }
166 )
167
168 (define_insn "tablejump_internal1"
169 [(set (pc)
170- (match_operand 0 "register_operand" "d"))
171+ (match_operand:SI 0 "register_operand" "d"))
172 (use (label_ref (match_operand 1 "" "")))]
173 ""
174 "bra%?\t%0 "
Andrew Geissler10fa1492020-12-11 16:25:29 -0600175@@ -2561,11 +2592,21 @@ else
Brad Bishop26bdd442019-08-16 17:08:17 -0400176 (set_attr "mode" "none")
177 (set_attr "length" "4")])
178
179+(define_insn "tablejump_internal2"
180+ [(set (pc)
181+ (match_operand:DI 0 "register_operand" "d"))
182+ (use (label_ref (match_operand 1 "" "")))]
183+ "TARGET_MB_64"
184+ "bra%?\t%0 "
185+ [(set_attr "type" "jump")
186+ (set_attr "mode" "none")
187+ (set_attr "length" "4")])
188+
189 (define_expand "tablejump_internal3"
190 [(parallel [(set (pc)
191- (plus (match_operand 0 "register_operand" "d")
192- (label_ref (match_operand:SI 1 "" ""))))
193- (use (label_ref (match_dup 1)))])]
194+ (plus:SI (match_operand:SI 0 "register_operand" "d")
195+ (label_ref:SI (match_operand:SI 1 "" ""))))
196+ (use (label_ref:SI (match_dup 1)))])]
197 ""
198 ""
199 )
Andrew Geissler10fa1492020-12-11 16:25:29 -0600200@@ -2596,6 +2637,23 @@ else
Brad Bishop26bdd442019-08-16 17:08:17 -0400201 ""
202 )
203
204+(define_insn ""
205+ [(set (pc)
206+ (plus:DI (match_operand:DI 0 "register_operand" "d")
207+ (label_ref:DI (match_operand 1 "" ""))))
208+ (use (label_ref:DI (match_dup 1)))]
209+ "TARGET_MB_64 && NEXT_INSN (as_a <rtx_insn *> (operands[1])) != 0
210+ && GET_CODE (PATTERN (NEXT_INSN (as_a <rtx_insn *> (operands[1])))) == ADDR_DIFF_VEC
211+ && flag_pic"
212+ {
213+ output_asm_insn ("addlk\t%0,%0,r20",operands);
214+ return "bra%?\t%0";
215+}
216+ [(set_attr "type" "jump")
217+ (set_attr "mode" "none")
218+ (set_attr "length" "4")])
219+
220+
221 ;;----------------------------------------------------------------
222 ;; Function prologue/epilogue and stack allocation
223 ;;----------------------------------------------------------------
Andrew Geissler10fa1492020-12-11 16:25:29 -0600224@@ -3102,7 +3160,7 @@ else
Brad Bishop26bdd442019-08-16 17:08:17 -0400225 ;; The insn to set GOT. The hardcoded number "8" accounts for $pc difference
226 ;; between "mfs" and "addik" instructions.
227 (define_insn "set_got"
228- [(set (match_operand:SI 0 "register_operand" "=r")
229+ [(set (match_operand 0 "register_operand" "=r")
230 (unspec:SI [(const_int 0)] UNSPEC_SET_GOT))]
231 ""
232 "mfs\t%0,rpc\n\taddik\t%0,%0,_GLOBAL_OFFSET_TABLE_+8"
233diff --git a/libgcc/config/microblaze/crti.S b/libgcc/config/microblaze/crti.S
Andrew Geisslera9ff2b32020-10-16 10:11:54 -0500234index 005825f1ec5..b7436c7131f 100644
Brad Bishop26bdd442019-08-16 17:08:17 -0400235--- a/libgcc/config/microblaze/crti.S
236+++ b/libgcc/config/microblaze/crti.S
237@@ -33,11 +33,32 @@
238 .section .init, "ax"
239 .global __init
240
241+#ifdef __arch64__
242 .weak _stack
243- .set _stack, 0xffffffff
244+ .set _stack, 0xffffffffffffffff
245 .weak _stack_end
246 .set _stack_end, 0
247
248+ .align 3
249+__init:
250+ addlik r1, r1, -32
251+ sl r15, r0, r1
252+ addlik r11, r0, _stack
253+ mts rshr, r11
254+ addlik r11, r0, _stack_end
255+ mts rslr, r11
256+
257+ .section .fini, "ax"
258+ .global __fini
259+ .align 3
260+__fini:
261+ addlik r1, r1, -32
262+ sl r15, r0, r1
263+#else
264+ .weak _stack
265+ .set _stack, 0xffffffff
266+ .weak _stack_end
267+ .set _stack_end, 0
268 .align 2
269 __init:
270 addik r1, r1, -16
271@@ -53,3 +74,4 @@ __init:
272 __fini:
273 addik r1, r1, -16
274 sw r15, r0, r1
275+#endif
276diff --git a/libgcc/config/microblaze/crtn.S b/libgcc/config/microblaze/crtn.S
Andrew Geisslera9ff2b32020-10-16 10:11:54 -0500277index 5705eff9a4a..f1148ffebe4 100644
Brad Bishop26bdd442019-08-16 17:08:17 -0400278--- a/libgcc/config/microblaze/crtn.S
279+++ b/libgcc/config/microblaze/crtn.S
280@@ -29,7 +29,19 @@
281 .section .note.GNU-stack,"",%progbits
282 .previous
283 #endif
284+#ifdef __arch64__
285+ .section .init, "ax"
286+ ll r15, r0, r1
287+ addlik r1, r1, 32
288+ rtsd r15, 8
289+ nop
290
291+ .section .fini, "ax"
292+ ll r15, r0, r1
293+ addlik r1, r1, 32
294+ rtsd r15, 8
295+ nop
296+#else
297 .section .init, "ax"
298 lw r15, r0, r1
299 rtsd r15, 8
300@@ -39,3 +51,4 @@
301 lw r15, r0, r1
302 rtsd r15, 8
303 addik r1, r1, 16
304+#endif
305--
Andrew Geisslera9ff2b32020-10-16 10:11:54 -05003062.17.1
Brad Bishop26bdd442019-08-16 17:08:17 -0400307