blob: d5fbf703ece53b26d88ccb674ee2591b5db0f394 [file] [log] [blame]
Andrew Geisslera9ff2b32020-10-16 10:11:54 -05001From c4d60b379c8d0a5621a0dc2a3a12fb40fe45e83e 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 Geisslera9ff2b32020-10-16 10:11:54 -05004Subject: [PATCH 40/58] 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
Brad Bishop26bdd442019-08-16 17:08:17 -04009---
Andrew Geisslera9ff2b32020-10-16 10:11:54 -050010 gcc/config/microblaze/microblaze.c | 12 +++-
Brad Bishop26bdd442019-08-16 17:08:17 -040011 gcc/config/microblaze/microblaze.h | 7 +++
Andrew Geisslera9ff2b32020-10-16 10:11:54 -050012 gcc/config/microblaze/microblaze.md | 86 ++++++++++++++++++++++++-----
13 libgcc/config/microblaze/crti.S | 24 +++++++-
14 libgcc/config/microblaze/crtn.S | 13 +++++
Andrew Geissler84ad7c52020-06-27 00:00:16 -050015 5 files changed, 125 insertions(+), 17 deletions(-)
Brad Bishop26bdd442019-08-16 17:08:17 -040016
17diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
Andrew Geisslera9ff2b32020-10-16 10:11:54 -050018index b94902b8fbb..12b1da852dd 100644
Brad Bishop26bdd442019-08-16 17:08:17 -040019--- a/gcc/config/microblaze/microblaze.c
20+++ b/gcc/config/microblaze/microblaze.c
Andrew Geisslera9ff2b32020-10-16 10:11:54 -050021@@ -2603,7 +2603,12 @@ print_operand (FILE * file, rtx op, int letter)
Brad Bishop26bdd442019-08-16 17:08:17 -040022 if (code == CONST_DOUBLE)
23 {
24 if (GET_MODE (op) == DFmode)
25- REAL_VALUE_TO_TARGET_DOUBLE (*CONST_DOUBLE_REAL_VALUE (op), val);
26+ {
27+ if (TARGET_MB_64)
28+ REAL_VALUE_TO_TARGET_LONG_DOUBLE (*CONST_DOUBLE_REAL_VALUE (op), val);
29+ else
30+ REAL_VALUE_TO_TARGET_DOUBLE (*CONST_DOUBLE_REAL_VALUE (op), val);
31+ }
32 else
33 {
34 REAL_VALUE_TO_TARGET_DOUBLE (*CONST_DOUBLE_REAL_VALUE (op), l);
Andrew Geisslera9ff2b32020-10-16 10:11:54 -050035@@ -4006,7 +4011,10 @@ microblaze_expand_divide (rtx operands[])
Brad Bishop26bdd442019-08-16 17:08:17 -040036 gen_rtx_PLUS (QImode, regt1, div_table_rtx));
37
38 insn = emit_insn (gen_zero_extendqisi2(operands[0],mem_rtx));
39- jump = emit_jump_insn_after (gen_jump (div_end_label), insn);
40+ if (TARGET_MB_64)
41+ jump = emit_jump_insn_after (gen_jump_64 (div_end_label), insn);
42+ else
43+ jump = emit_jump_insn_after (gen_jump (div_end_label), insn);
44 JUMP_LABEL (jump) = div_end_label;
45 LABEL_NUSES (div_end_label) = 1;
46 emit_barrier ();
47diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
Andrew Geisslera9ff2b32020-10-16 10:11:54 -050048index 1f6e2059545..a36e06316aa 100644
Brad Bishop26bdd442019-08-16 17:08:17 -040049--- a/gcc/config/microblaze/microblaze.h
50+++ b/gcc/config/microblaze/microblaze.h
Andrew Geissler84ad7c52020-06-27 00:00:16 -050051@@ -888,10 +888,17 @@ do { \
Brad Bishop26bdd442019-08-16 17:08:17 -040052 /* We do this to save a few 10s of code space that would be taken up
53 by the call_FUNC () wrappers, used by the generic CRT_CALL_STATIC_FUNCTION
54 definition in crtstuff.c. */
55+#ifdef __arch64__
56+#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
57+ asm ( SECTION_OP "\n" \
58+ "\tbrealid r15, " #FUNC "\n\t nop\n" \
59+ TEXT_SECTION_ASM_OP);
60+#else
61 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
62 asm ( SECTION_OP "\n" \
63 "\tbrlid r15, " #FUNC "\n\t nop\n" \
64 TEXT_SECTION_ASM_OP);
65+#endif
66
67 /* We need to group -lm as well, since some Newlib math functions
68 reference __errno! */
69diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
Andrew Geisslera9ff2b32020-10-16 10:11:54 -050070index 7cc26e7d786..013c77651c3 100644
Brad Bishop26bdd442019-08-16 17:08:17 -040071--- a/gcc/config/microblaze/microblaze.md
72+++ b/gcc/config/microblaze/microblaze.md
Andrew Geissler84ad7c52020-06-27 00:00:16 -050073@@ -527,6 +527,15 @@
Brad Bishop26bdd442019-08-16 17:08:17 -040074 (set_attr "mode" "SF")
75 (set_attr "length" "4")])
76
77+(define_insn "floatdidf2"
78+ [(set (match_operand:DF 0 "register_operand" "=d")
79+ (float:DF (match_operand:DI 1 "register_operand" "d")))]
80+ "TARGET_MB_64"
81+ "dbl\t%0,%1"
82+ [(set_attr "type" "fcvt")
83+ (set_attr "mode" "DF")
84+ (set_attr "length" "4")])
85+
86 (define_insn "fix_truncsfsi2"
87 [(set (match_operand:SI 0 "register_operand" "=d")
88 (fix:SI (match_operand:SF 1 "register_operand" "d")))]
Andrew Geissler84ad7c52020-06-27 00:00:16 -050089@@ -1300,7 +1309,7 @@
Brad Bishop26bdd442019-08-16 17:08:17 -040090 (define_insn "movdi_long_int"
91 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
92 (match_operand:DI 1 "general_operand" "i"))]
93- ""
94+ "TARGET_MB_64"
95 "addlik\t%0,r0,%h1\n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #li => la";
96 [(set_attr "type" "no_delay_arith")
97 (set_attr "mode" "DI")
Andrew Geissler84ad7c52020-06-27 00:00:16 -050098@@ -1583,7 +1592,7 @@
Brad Bishop26bdd442019-08-16 17:08:17 -040099 return "ll%i1\t%0,%1";
100 case 3:
101 {
102- return "addlik\t%0,r0,%h1 \n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #Xfer Lo";
103+ return "addlik\t%0,r0,%j1 \n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%h1 #Xfer Lo";
104 }
105 case 5:
106 return "sl%i0\t%1,%0";
Andrew Geissler84ad7c52020-06-27 00:00:16 -0500107@@ -2373,9 +2382,9 @@ else
Brad Bishop26bdd442019-08-16 17:08:17 -0400108
109 (define_insn "long_branch_compare"
110 [(set (pc)
111- (if_then_else (match_operator 0 "cmp_op"
112- [(match_operand 1 "register_operand" "d")
113- (match_operand 2 "register_operand" "d")
114+ (if_then_else (match_operator:DI 0 "cmp_op"
115+ [(match_operand:DI 1 "register_operand" "d")
116+ (match_operand:DI 2 "register_operand" "d")
117 ])
118 (label_ref (match_operand 3))
119 (pc)))
Andrew Geissler84ad7c52020-06-27 00:00:16 -0500120@@ -2497,6 +2506,20 @@ else
Brad Bishop26bdd442019-08-16 17:08:17 -0400121 ;;----------------------------------------------------------------
122 ;; Unconditional branches
123 ;;----------------------------------------------------------------
124+(define_insn "jump_64"
125+ [(set (pc)
126+ (label_ref (match_operand 0 "" "")))]
127+ "TARGET_MB_64"
128+ {
129+ if (GET_CODE (operands[0]) == REG)
130+ return "brea%?\t%0";
131+ else
132+ return "breai%?\t%l0";
133+ }
134+ [(set_attr "type" "jump")
135+ (set_attr "mode" "none")
136+ (set_attr "length" "4")])
137+
138 (define_insn "jump"
139 [(set (pc)
140 (label_ref (match_operand 0 "" "")))]
Andrew Geissler84ad7c52020-06-27 00:00:16 -0500141@@ -2542,17 +2565,25 @@ else
Brad Bishop26bdd442019-08-16 17:08:17 -0400142 {
Andrew Geissler84ad7c52020-06-27 00:00:16 -0500143 //gcc_assert (GET_MODE (operands[0]) == Pmode);
144
145- if (!flag_pic || TARGET_PIC_DATA_TEXT_REL)
Brad Bishop26bdd442019-08-16 17:08:17 -0400146- emit_jump_insn (gen_tablejump_internal1 (operands[0], operands[1]));
147- else
148- emit_jump_insn (gen_tablejump_internal3 (operands[0], operands[1]));
Andrew Geissler84ad7c52020-06-27 00:00:16 -0500149+ if (!flag_pic || TARGET_PIC_DATA_TEXT_REL) {
150+ if (!TARGET_MB_64)
Brad Bishop26bdd442019-08-16 17:08:17 -0400151+ emit_jump_insn (gen_tablejump_internal1 (operands[0], operands[1]));
Andrew Geissler84ad7c52020-06-27 00:00:16 -0500152+ else
Brad Bishop26bdd442019-08-16 17:08:17 -0400153+ emit_jump_insn (gen_tablejump_internal2 (operands[0], operands[1]));
154+ }
155+ else {
Andrew Geissler84ad7c52020-06-27 00:00:16 -0500156+ if (!TARGET_MB_64)
Brad Bishop26bdd442019-08-16 17:08:17 -0400157+ emit_jump_insn (gen_tablejump_internal3 (operands[0], operands[1]));
Andrew Geissler84ad7c52020-06-27 00:00:16 -0500158+ else
Brad Bishop26bdd442019-08-16 17:08:17 -0400159+ emit_jump_insn (gen_tablejump_internal4 (operands[0], operands[1]));
160+ }
161 DONE;
162 }
163 )
164
165 (define_insn "tablejump_internal1"
166 [(set (pc)
167- (match_operand 0 "register_operand" "d"))
168+ (match_operand:SI 0 "register_operand" "d"))
169 (use (label_ref (match_operand 1 "" "")))]
170 ""
171 "bra%?\t%0 "
Andrew Geissler84ad7c52020-06-27 00:00:16 -0500172@@ -2560,11 +2591,21 @@ else
Brad Bishop26bdd442019-08-16 17:08:17 -0400173 (set_attr "mode" "none")
174 (set_attr "length" "4")])
175
176+(define_insn "tablejump_internal2"
177+ [(set (pc)
178+ (match_operand:DI 0 "register_operand" "d"))
179+ (use (label_ref (match_operand 1 "" "")))]
180+ "TARGET_MB_64"
181+ "bra%?\t%0 "
182+ [(set_attr "type" "jump")
183+ (set_attr "mode" "none")
184+ (set_attr "length" "4")])
185+
186 (define_expand "tablejump_internal3"
187 [(parallel [(set (pc)
188- (plus (match_operand 0 "register_operand" "d")
189- (label_ref (match_operand:SI 1 "" ""))))
190- (use (label_ref (match_dup 1)))])]
191+ (plus:SI (match_operand:SI 0 "register_operand" "d")
192+ (label_ref:SI (match_operand:SI 1 "" ""))))
193+ (use (label_ref:SI (match_dup 1)))])]
194 ""
195 ""
196 )
Andrew Geissler84ad7c52020-06-27 00:00:16 -0500197@@ -2595,6 +2636,23 @@ else
Brad Bishop26bdd442019-08-16 17:08:17 -0400198 ""
199 )
200
201+(define_insn ""
202+ [(set (pc)
203+ (plus:DI (match_operand:DI 0 "register_operand" "d")
204+ (label_ref:DI (match_operand 1 "" ""))))
205+ (use (label_ref:DI (match_dup 1)))]
206+ "TARGET_MB_64 && NEXT_INSN (as_a <rtx_insn *> (operands[1])) != 0
207+ && GET_CODE (PATTERN (NEXT_INSN (as_a <rtx_insn *> (operands[1])))) == ADDR_DIFF_VEC
208+ && flag_pic"
209+ {
210+ output_asm_insn ("addlk\t%0,%0,r20",operands);
211+ return "bra%?\t%0";
212+}
213+ [(set_attr "type" "jump")
214+ (set_attr "mode" "none")
215+ (set_attr "length" "4")])
216+
217+
218 ;;----------------------------------------------------------------
219 ;; Function prologue/epilogue and stack allocation
220 ;;----------------------------------------------------------------
Andrew Geissler84ad7c52020-06-27 00:00:16 -0500221@@ -3101,7 +3159,7 @@ else
Brad Bishop26bdd442019-08-16 17:08:17 -0400222 ;; The insn to set GOT. The hardcoded number "8" accounts for $pc difference
223 ;; between "mfs" and "addik" instructions.
224 (define_insn "set_got"
225- [(set (match_operand:SI 0 "register_operand" "=r")
226+ [(set (match_operand 0 "register_operand" "=r")
227 (unspec:SI [(const_int 0)] UNSPEC_SET_GOT))]
228 ""
229 "mfs\t%0,rpc\n\taddik\t%0,%0,_GLOBAL_OFFSET_TABLE_+8"
230diff --git a/libgcc/config/microblaze/crti.S b/libgcc/config/microblaze/crti.S
Andrew Geisslera9ff2b32020-10-16 10:11:54 -0500231index 005825f1ec5..b7436c7131f 100644
Brad Bishop26bdd442019-08-16 17:08:17 -0400232--- a/libgcc/config/microblaze/crti.S
233+++ b/libgcc/config/microblaze/crti.S
234@@ -33,11 +33,32 @@
235 .section .init, "ax"
236 .global __init
237
238+#ifdef __arch64__
239 .weak _stack
240- .set _stack, 0xffffffff
241+ .set _stack, 0xffffffffffffffff
242 .weak _stack_end
243 .set _stack_end, 0
244
245+ .align 3
246+__init:
247+ addlik r1, r1, -32
248+ sl r15, r0, r1
249+ addlik r11, r0, _stack
250+ mts rshr, r11
251+ addlik r11, r0, _stack_end
252+ mts rslr, r11
253+
254+ .section .fini, "ax"
255+ .global __fini
256+ .align 3
257+__fini:
258+ addlik r1, r1, -32
259+ sl r15, r0, r1
260+#else
261+ .weak _stack
262+ .set _stack, 0xffffffff
263+ .weak _stack_end
264+ .set _stack_end, 0
265 .align 2
266 __init:
267 addik r1, r1, -16
268@@ -53,3 +74,4 @@ __init:
269 __fini:
270 addik r1, r1, -16
271 sw r15, r0, r1
272+#endif
273diff --git a/libgcc/config/microblaze/crtn.S b/libgcc/config/microblaze/crtn.S
Andrew Geisslera9ff2b32020-10-16 10:11:54 -0500274index 5705eff9a4a..f1148ffebe4 100644
Brad Bishop26bdd442019-08-16 17:08:17 -0400275--- a/libgcc/config/microblaze/crtn.S
276+++ b/libgcc/config/microblaze/crtn.S
277@@ -29,7 +29,19 @@
278 .section .note.GNU-stack,"",%progbits
279 .previous
280 #endif
281+#ifdef __arch64__
282+ .section .init, "ax"
283+ ll r15, r0, r1
284+ addlik r1, r1, 32
285+ rtsd r15, 8
286+ nop
287
288+ .section .fini, "ax"
289+ ll r15, r0, r1
290+ addlik r1, r1, 32
291+ rtsd r15, 8
292+ nop
293+#else
294 .section .init, "ax"
295 lw r15, r0, r1
296 rtsd r15, 8
297@@ -39,3 +51,4 @@
298 lw r15, r0, r1
299 rtsd r15, 8
300 addik r1, r1, 16
301+#endif
302--
Andrew Geisslera9ff2b32020-10-16 10:11:54 -05003032.17.1
Brad Bishop26bdd442019-08-16 17:08:17 -0400304