blob: 8dce847642f4a026e8bb8cf22060ff58dacda591 [file] [log] [blame]
Andrew Geisslera9ff2b32020-10-16 10:11:54 -05001From e3b95d5646d4197bff81105c12bcbc5e7dba1725 Mon Sep 17 00:00:00 2001
Brad Bishop26bdd442019-08-16 17:08:17 -04002From: Nagaraju <nmekala@xilinx.com>
3Date: Thu, 18 Apr 2019 16:00:37 +0530
Andrew Geisslera9ff2b32020-10-16 10:11:54 -05004Subject: [PATCH 53/58] [Patch, microblaze]: MB-64 removal of barrel-shift
5 instructions from default
Brad Bishop26bdd442019-08-16 17:08:17 -04006
Andrew Geisslera9ff2b32020-10-16 10:11:54 -05007By default MB-64 is generatting barrel-shift instructions. It has been
8removed from default. Barrel-shift instructions will be generated only if
9barrel-shifter is enabled. Similarly to double instructions as well.
Brad Bishop26bdd442019-08-16 17:08:17 -040010
Andrew Geisslera9ff2b32020-10-16 10:11:54 -050011Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
Brad Bishop26bdd442019-08-16 17:08:17 -040012---
13 gcc/config/microblaze/microblaze.c | 2 +-
Andrew Geisslera9ff2b32020-10-16 10:11:54 -050014 gcc/config/microblaze/microblaze.md | 269 ++++++++++++++++++++++++++--
Brad Bishop26bdd442019-08-16 17:08:17 -040015 2 files changed, 252 insertions(+), 19 deletions(-)
16
17diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
Andrew Geisslera9ff2b32020-10-16 10:11:54 -050018index 12b1da852dd..5b4c21af365 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@@ -4000,7 +4000,7 @@ microblaze_expand_divide (rtx operands[])
Brad Bishop26bdd442019-08-16 17:08:17 -040022 emit_insn (gen_rtx_CLOBBER (Pmode, reg18));
23
24 if (TARGET_MB_64) {
25- emit_insn (gen_ashldi3_long (regt1, operands[1], GEN_INT(4)));
26+ emit_insn (gen_ashldi3 (regt1, operands[1], GEN_INT(4)));
27 emit_insn (gen_adddi3 (regt1, regt1, operands[2]));
28 }
29 else {
30diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
Andrew Geisslera9ff2b32020-10-16 10:11:54 -050031index 626eade9468..6cc62666269 100644
Brad Bishop26bdd442019-08-16 17:08:17 -040032--- a/gcc/config/microblaze/microblaze.md
33+++ b/gcc/config/microblaze/microblaze.md
Andrew Geissler84ad7c52020-06-27 00:00:16 -050034@@ -547,7 +547,7 @@
Brad Bishop26bdd442019-08-16 17:08:17 -040035 [(set (match_operand:DF 0 "register_operand" "=d")
36 (plus:DF (match_operand:DF 1 "register_operand" "d")
37 (match_operand:DF 2 "register_operand" "d")))]
38- "TARGET_MB_64"
39+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
40 "dadd\t%0,%1,%2"
41 [(set_attr "type" "fadd")
42 (set_attr "mode" "DF")
Andrew Geissler84ad7c52020-06-27 00:00:16 -050043@@ -557,7 +557,7 @@
Brad Bishop26bdd442019-08-16 17:08:17 -040044 [(set (match_operand:DF 0 "register_operand" "=d")
45 (minus:DF (match_operand:DF 1 "register_operand" "d")
46 (match_operand:DF 2 "register_operand" "d")))]
47- "TARGET_MB_64"
48+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
49 "drsub\t%0,%2,%1"
50 [(set_attr "type" "frsub")
51 (set_attr "mode" "DF")
Andrew Geissler84ad7c52020-06-27 00:00:16 -050052@@ -567,7 +567,7 @@
Brad Bishop26bdd442019-08-16 17:08:17 -040053 [(set (match_operand:DF 0 "register_operand" "=d")
54 (mult:DF (match_operand:DF 1 "register_operand" "d")
55 (match_operand:DF 2 "register_operand" "d")))]
56- "TARGET_MB_64"
57+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
58 "dmul\t%0,%1,%2"
59 [(set_attr "type" "fmul")
60 (set_attr "mode" "DF")
Andrew Geissler84ad7c52020-06-27 00:00:16 -050061@@ -577,7 +577,7 @@
Brad Bishop26bdd442019-08-16 17:08:17 -040062 [(set (match_operand:DF 0 "register_operand" "=d")
63 (div:DF (match_operand:DF 1 "register_operand" "d")
64 (match_operand:DF 2 "register_operand" "d")))]
65- "TARGET_MB_64"
66+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
67 "ddiv\t%0,%2,%1"
68 [(set_attr "type" "fdiv")
69 (set_attr "mode" "DF")
Andrew Geissler84ad7c52020-06-27 00:00:16 -050070@@ -587,7 +587,7 @@
Brad Bishop26bdd442019-08-16 17:08:17 -040071 (define_insn "sqrtdf2"
72 [(set (match_operand:DF 0 "register_operand" "=d")
73 (sqrt:DF (match_operand:DF 1 "register_operand" "d")))]
74- "TARGET_MB_64"
75+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
76 "dsqrt\t%0,%1"
77 [(set_attr "type" "fsqrt")
78 (set_attr "mode" "DF")
Andrew Geissler84ad7c52020-06-27 00:00:16 -050079@@ -596,7 +596,7 @@
Brad Bishop26bdd442019-08-16 17:08:17 -040080 (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+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
85 "dbl\t%0,%1"
86 [(set_attr "type" "fcvt")
87 (set_attr "mode" "DF")
Andrew Geissler84ad7c52020-06-27 00:00:16 -050088@@ -605,7 +605,7 @@
Brad Bishop26bdd442019-08-16 17:08:17 -040089 (define_insn "fix_truncdfdi2"
90 [(set (match_operand:DI 0 "register_operand" "=d")
91 (fix:DI (fix:DF (match_operand:DF 1 "register_operand" "d"))))]
92- "TARGET_MB_64"
93+ "TARGET_MB_64 && TARGET_HARD_FLOAT && TARGET_FLOAT_CONVERT"
94 "dlong\t%0,%1"
95 [(set_attr "type" "fcvt")
96 (set_attr "mode" "DI")
Andrew Geissler84ad7c52020-06-27 00:00:16 -050097@@ -1301,6 +1301,34 @@
Brad Bishop26bdd442019-08-16 17:08:17 -040098 (set_attr "mode" "DI")
99 (set_attr "length" "4")])
100
101+(define_insn "*movdi_internal2_bshift"
102+ [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d, d,d,R,m")
103+ (match_operand:DI 1 "move_src_operand" " d,I,Mnis,R,m,dJ,dJ"))]
104+ "TARGET_MB_64 && TARGET_BARREL_SHIFT"
105+ {
106+ switch (which_alternative)
107+ {
108+ case 0:
109+ return "addlk\t%0,%1,r0";
110+ case 1:
111+ case 2:
112+ if (GET_CODE (operands[1]) == CONST_INT &&
113+ (INTVAL (operands[1]) > (long long)549755813887 || INTVAL (operands[1]) < (long long)-549755813888))
114+ return "addlik\t%0,r0,%h1\n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #li => la";
115+ else
116+ return "addlik\t%0,r0,%1";
117+ case 3:
118+ case 4:
119+ return "ll%i1\t%0,%1";
120+ case 5:
121+ case 6:
122+ return "sl%i0\t%z1,%0";
123+ }
124+ }
125+ [(set_attr "type" "load,no_delay_load,no_delay_load,no_delay_load,no_delay_load,no_delay_store,no_delay_store")
126+ (set_attr "mode" "DI")
127+ (set_attr "length" "4,4,12,4,8,4,8")])
128+
129 (define_insn "*movdi_internal2"
130 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d, d,d,R,m")
131 (match_operand:DI 1 "move_src_operand" " d,I,Mnis,R,m,dJ,dJ"))]
Andrew Geissler84ad7c52020-06-27 00:00:16 -0500132@@ -1314,7 +1342,15 @@
Brad Bishop26bdd442019-08-16 17:08:17 -0400133 case 2:
134 if (GET_CODE (operands[1]) == CONST_INT &&
135 (INTVAL (operands[1]) > (long long)549755813887 || INTVAL (operands[1]) < (long long)-549755813888))
136- return "addlik\t%0,r0,%h1\n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #li => la";
137+ {
138+ operands[2] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
139+ output_asm_insn ("addlik\t%0,r0,%h1", operands);
140+ output_asm_insn ("addlik\t%2,r0,32", operands);
141+ output_asm_insn ("addlik\t%2,%2,-1", operands);
142+ output_asm_insn ("beaneid\t%2,.-8", operands);
143+ output_asm_insn ("addlk\t%0,%0,%0", operands);
144+ return "addlik\t%0,%0,%j1 #li => la";
145+ }
146 else
147 return "addlik\t%0,r0,%1";
148 case 3:
Andrew Geissler84ad7c52020-06-27 00:00:16 -0500149@@ -1388,7 +1424,7 @@
Brad Bishop26bdd442019-08-16 17:08:17 -0400150 (define_insn "movdi_long_int"
151 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
152 (match_operand:DI 1 "general_operand" "i"))]
153- "TARGET_MB_64"
154+ "TARGET_MB_64 && TARGET_BARREL_SHIFT"
155 "addlik\t%0,r0,%h1\n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%j1 #li => la";
156 [(set_attr "type" "no_delay_arith")
157 (set_attr "mode" "DI")
Andrew Geissler84ad7c52020-06-27 00:00:16 -0500158@@ -1655,6 +1691,33 @@
Brad Bishop26bdd442019-08-16 17:08:17 -0400159 ;; movdf_internal
160 ;; Applies to both TARGET_SOFT_FLOAT and TARGET_HARD_FLOAT
161 ;;
162+(define_insn "*movdf_internal_64_bshift"
163+ [(set (match_operand:DF 0 "nonimmediate_operand" "=d,d,d,d,d,m")
164+ (match_operand:DF 1 "general_operand" "d,dG,m,F,T,d"))]
165+ "TARGET_MB_64 && TARGET_BARREL_SHIFT"
166+ {
167+ switch (which_alternative)
168+ {
169+ case 0:
170+ return "addlk\t%0,%1,r0";
171+ case 1:
172+ return "addlk\t%0,r0,r0";
173+ case 2:
174+ case 4:
175+ return "ll%i1\t%0,%1";
176+ case 3:
177+ {
178+ return "addlik\t%0,r0,%j1 \n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%h1 #Xfer Lo";
179+ }
180+ case 5:
181+ return "sl%i0\t%1,%0";
182+ }
183+ gcc_unreachable ();
184+ }
185+ [(set_attr "type" "no_delay_move,no_delay_move,no_delay_load,no_delay_load,no_delay_load,no_delay_store")
186+ (set_attr "mode" "DF")
187+ (set_attr "length" "4,4,4,16,4,4")])
188+
189 (define_insn "*movdf_internal_64"
190 [(set (match_operand:DF 0 "nonimmediate_operand" "=d,d,d,d,d,m")
191 (match_operand:DF 1 "general_operand" "d,dG,m,F,T,d"))]
Andrew Geissler84ad7c52020-06-27 00:00:16 -0500192@@ -1671,7 +1734,13 @@
Brad Bishop26bdd442019-08-16 17:08:17 -0400193 return "ll%i1\t%0,%1";
194 case 3:
195 {
196- return "addlik\t%0,r0,%j1 \n\tbsllli\t%0,%0,32\n\taddlik\t%0,%0,%h1 #Xfer Lo";
197+ operands[2] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
198+ output_asm_insn ("addlik\t%0,r0,%h1", operands);
199+ output_asm_insn ("addlik\t%2,r0,32", operands);
200+ output_asm_insn ("addlik\t%2,%2,-1", operands);
201+ output_asm_insn ("beaneid\t%2,.-8", operands);
202+ output_asm_insn ("addlk\t%0,%0,%0", operands);
203+ return "addlik\t%0,%0,%j1 #li => la";
204 }
205 case 5:
206 return "sl%i0\t%1,%0";
Andrew Geissler84ad7c52020-06-27 00:00:16 -0500207@@ -1791,11 +1860,21 @@
Brad Bishop26bdd442019-08-16 17:08:17 -0400208 "TARGET_MB_64"
209 {
210 ;;if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
211-if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
212+if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && TARGET_BARREL_SHIFT)
213 {
214 emit_insn(gen_ashldi3_long (operands[0], operands[1],operands[2]));
215 DONE;
216 }
217+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && CONST_INT_P (operands[2]))
218+ {
219+ emit_insn(gen_ashldi3_const (operands[0], operands[1],operands[2]));
220+ DONE;
221+ }
222+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && GET_CODE (operands[2]) == REG)
223+ {
224+ emit_insn(gen_ashldi3_reg (operands[0], operands[1],operands[2]));
225+ DONE;
226+ }
227 else
228 FAIL;
229 }
Andrew Geissler84ad7c52020-06-27 00:00:16 -0500230@@ -1805,7 +1884,7 @@ else
Brad Bishop26bdd442019-08-16 17:08:17 -0400231 [(set (match_operand:DI 0 "register_operand" "=d,d")
232 (ashift:DI (match_operand:DI 1 "register_operand" "d,d")
233 (match_operand:DI 2 "arith_operand" "I,d")))]
234- "TARGET_MB_64"
235+ "TARGET_MB_64 && TARGET_BARREL_SHIFT"
236 "@
237 bsllli\t%0,%1,%2
238 bslll\t%0,%1,%2"
Andrew Geissler84ad7c52020-06-27 00:00:16 -0500239@@ -1813,6 +1892,51 @@ else
Brad Bishop26bdd442019-08-16 17:08:17 -0400240 (set_attr "mode" "DI,DI")
241 (set_attr "length" "4,4")]
242 )
243+
244+(define_insn "ashldi3_const"
245+ [(set (match_operand:DI 0 "register_operand" "=&d")
246+ (ashift:DI (match_operand:DI 1 "register_operand" "d")
247+ (match_operand:DI 2 "immediate_operand" "I")))]
248+ "TARGET_MB_64"
249+ {
250+ operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
251+
252+ output_asm_insn ("orli\t%3,r0,%2", operands);
253+ if (REGNO (operands[0]) != REGNO (operands[1]))
254+ output_asm_insn ("addlk\t%0,%1,r0", operands);
255+
256+ output_asm_insn ("addlik\t%3,%3,-1", operands);
257+ output_asm_insn ("beaneid\t%3,.-8", operands);
258+ return "addlk\t%0,%0,%0";
259+ }
260+ [(set_attr "type" "multi")
261+ (set_attr "mode" "DI")
262+ (set_attr "length" "20")]
263+)
264+
265+(define_insn "ashldi3_reg"
266+ [(set (match_operand:DI 0 "register_operand" "=&d")
267+ (ashift:DI (match_operand:DI 1 "register_operand" "d")
268+ (match_operand:DI 2 "register_operand" "d")))]
269+ "TARGET_MB_64"
270+ {
271+ operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
272+ output_asm_insn ("andli\t%3,%2,31", operands);
273+ if (REGNO (operands[0]) != REGNO (operands[1]))
274+ output_asm_insn ("addlk\t%0,r0,%1", operands);
275+ /* Exit the loop if zero shift. */
276+ output_asm_insn ("beaeqid\t%3,.+24", operands);
277+ /* Emit the loop. */
278+ output_asm_insn ("addlk\t%0,%0,r0", operands);
279+ output_asm_insn ("addlik\t%3,%3,-1", operands);
280+ output_asm_insn ("beaneid\t%3,.-8", operands);
281+ return "addlk\t%0,%0,%0";
282+ }
283+ [(set_attr "type" "multi")
284+ (set_attr "mode" "DI")
285+ (set_attr "length" "28")]
286+)
287+
288 ;; The following patterns apply when there is no barrel shifter present
289
290 (define_insn "*ashlsi3_with_mul_delay"
Andrew Geissler84ad7c52020-06-27 00:00:16 -0500291@@ -1946,11 +2070,21 @@ else
Brad Bishop26bdd442019-08-16 17:08:17 -0400292 "TARGET_MB_64"
293 {
294 ;;if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
295-if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
296+if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && TARGET_BARREL_SHIFT)
297 {
298 emit_insn(gen_ashrdi3_long (operands[0], operands[1],operands[2]));
299 DONE;
300 }
301+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && CONST_INT_P (operands[2]))
302+ {
303+ emit_insn(gen_ashrdi3_const (operands[0], operands[1],operands[2]));
304+ DONE;
305+ }
306+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && GET_CODE (operands[2]) == REG)
307+ {
308+ emit_insn(gen_ashrdi3_reg (operands[0], operands[1],operands[2]));
309+ DONE;
310+ }
311 else
312 FAIL;
313 }
Andrew Geissler84ad7c52020-06-27 00:00:16 -0500314@@ -1960,7 +2094,7 @@ else
Brad Bishop26bdd442019-08-16 17:08:17 -0400315 [(set (match_operand:DI 0 "register_operand" "=d,d")
316 (ashiftrt:DI (match_operand:DI 1 "register_operand" "d,d")
317 (match_operand:DI 2 "arith_operand" "I,d")))]
318- "TARGET_MB_64"
319+ "TARGET_MB_64 && TARGET_BARREL_SHIFT"
320 "@
321 bslrai\t%0,%1,%2
322 bslra\t%0,%1,%2"
Andrew Geissler84ad7c52020-06-27 00:00:16 -0500323@@ -1968,6 +2102,51 @@ else
Brad Bishop26bdd442019-08-16 17:08:17 -0400324 (set_attr "mode" "DI,DI")
325 (set_attr "length" "4,4")]
326 )
327+
328+(define_insn "ashrdi3_const"
329+ [(set (match_operand:DI 0 "register_operand" "=&d")
330+ (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
331+ (match_operand:DI 2 "immediate_operand" "I")))]
332+ "TARGET_MB_64"
333+ {
334+ operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
335+
336+ output_asm_insn ("orli\t%3,r0,%2", operands);
337+ if (REGNO (operands[0]) != REGNO (operands[1]))
338+ output_asm_insn ("addlk\t%0,%1,r0", operands);
339+
340+ output_asm_insn ("addlik\t%3,%3,-1", operands);
341+ output_asm_insn ("beaneid\t%3,.-8", operands);
342+ return "srla\t%0,%0";
343+ }
344+ [(set_attr "type" "arith")
345+ (set_attr "mode" "DI")
346+ (set_attr "length" "20")]
347+)
348+
349+(define_insn "ashrdi3_reg"
350+ [(set (match_operand:DI 0 "register_operand" "=&d")
351+ (ashiftrt:DI (match_operand:DI 1 "register_operand" "d")
352+ (match_operand:DI 2 "register_operand" "d")))]
353+ "TARGET_MB_64"
354+ {
355+ operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
356+ output_asm_insn ("andli\t%3,%2,31", operands);
357+ if (REGNO (operands[0]) != REGNO (operands[1]))
358+ output_asm_insn ("addlk\t%0,r0,%1", operands);
359+ /* Exit the loop if zero shift. */
360+ output_asm_insn ("beaeqid\t%3,.+24", operands);
361+ /* Emit the loop. */
362+ output_asm_insn ("addlk\t%0,%0,r0", operands);
363+ output_asm_insn ("addlik\t%3,%3,-1", operands);
364+ output_asm_insn ("beaneid\t%3,.-8", operands);
365+ return "srla\t%0,%0";
366+ }
367+ [(set_attr "type" "multi")
368+ (set_attr "mode" "DI")
369+ (set_attr "length" "28")]
370+)
371+
372 (define_expand "ashrsi3"
373 [(set (match_operand:SI 0 "register_operand" "=&d")
374 (ashiftrt:SI (match_operand:SI 1 "register_operand" "d")
Andrew Geissler84ad7c52020-06-27 00:00:16 -0500375@@ -2085,11 +2264,21 @@ else
Brad Bishop26bdd442019-08-16 17:08:17 -0400376 "TARGET_MB_64"
377 {
378 ;;if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
379-if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65)
380+if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && TARGET_BARREL_SHIFT)
381 {
382 emit_insn(gen_lshrdi3_long (operands[0], operands[1],operands[2]));
383 DONE;
384 }
385+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && CONST_INT_P (operands[2]))
386+ {
387+ emit_insn(gen_lshrdi3_const (operands[0], operands[1],operands[2]));
388+ DONE;
389+ }
390+else if(INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 65 && GET_CODE (operands[2]) == REG)
391+ {
392+ emit_insn(gen_lshrdi3_reg (operands[0], operands[1],operands[2]));
393+ DONE;
394+ }
395 else
396 FAIL;
397 }
Andrew Geissler84ad7c52020-06-27 00:00:16 -0500398@@ -2099,7 +2288,7 @@ else
Brad Bishop26bdd442019-08-16 17:08:17 -0400399 [(set (match_operand:DI 0 "register_operand" "=d,d")
400 (lshiftrt:DI (match_operand:DI 1 "register_operand" "d,d")
401 (match_operand:DI 2 "arith_operand" "I,d")))]
402- "TARGET_MB_64"
403+ "TARGET_MB_64 && TARGET_BARREL_SHIFT"
404 "@
405 bslrli\t%0,%1,%2
406 bslrl\t%0,%1,%2"
Andrew Geissler84ad7c52020-06-27 00:00:16 -0500407@@ -2108,6 +2297,50 @@ else
Brad Bishop26bdd442019-08-16 17:08:17 -0400408 (set_attr "length" "4,4")]
409 )
410
411+(define_insn "lshrdi3_const"
412+ [(set (match_operand:DI 0 "register_operand" "=&d")
413+ (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
414+ (match_operand:DI 2 "immediate_operand" "I")))]
415+ "TARGET_MB_64"
416+ {
417+ operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
418+
419+ output_asm_insn ("orli\t%3,r0,%2", operands);
420+ if (REGNO (operands[0]) != REGNO (operands[1]))
421+ output_asm_insn ("addlk\t%0,%1,r0", operands);
422+
423+ output_asm_insn ("addlik\t%3,%3,-1", operands);
424+ output_asm_insn ("beaneid\t%3,.-8", operands);
425+ return "srll\t%0,%0";
426+ }
427+ [(set_attr "type" "multi")
428+ (set_attr "mode" "DI")
429+ (set_attr "length" "20")]
430+)
431+
432+(define_insn "lshrdi3_reg"
433+ [(set (match_operand:DI 0 "register_operand" "=&d")
434+ (lshiftrt:DI (match_operand:DI 1 "register_operand" "d")
435+ (match_operand:DI 2 "register_operand" "d")))]
436+ "TARGET_MB_64"
437+ {
438+ operands[3] = gen_rtx_REG (DImode, MB_ABI_ASM_TEMP_REGNUM);
439+ output_asm_insn ("andli\t%3,%2,31", operands);
440+ if (REGNO (operands[0]) != REGNO (operands[1]))
441+ output_asm_insn ("addlk\t%0,r0,%1", operands);
442+ /* Exit the loop if zero shift. */
443+ output_asm_insn ("beaeqid\t%3,.+24", operands);
444+ /* Emit the loop. */
445+ output_asm_insn ("addlk\t%0,%0,r0", operands);
446+ output_asm_insn ("addlik\t%3,%3,-1", operands);
447+ output_asm_insn ("beaneid\t%3,.-8", operands);
448+ return "srll\t%0,%0";
449+ }
450+ [(set_attr "type" "multi")
451+ (set_attr "mode" "SI")
452+ (set_attr "length" "28")]
453+)
454+
455 (define_expand "lshrsi3"
456 [(set (match_operand:SI 0 "register_operand" "=&d")
457 (lshiftrt:SI (match_operand:SI 1 "register_operand" "d")
Andrew Geissler84ad7c52020-06-27 00:00:16 -0500458@@ -2235,7 +2468,7 @@ else
Brad Bishop26bdd442019-08-16 17:08:17 -0400459 (eq:DI
460 (match_operand:DI 1 "register_operand" "d")
461 (match_operand:DI 2 "register_operand" "d")))]
462- "TARGET_MB_64"
463+ "TARGET_MB_64 && TARGET_PATTERN_COMPARE"
464 "pcmpleq\t%0,%1,%2"
465 [(set_attr "type" "arith")
466 (set_attr "mode" "DI")
Andrew Geissler84ad7c52020-06-27 00:00:16 -0500467@@ -2247,7 +2480,7 @@ else
Brad Bishop26bdd442019-08-16 17:08:17 -0400468 (ne:DI
469 (match_operand:DI 1 "register_operand" "d")
470 (match_operand:DI 2 "register_operand" "d")))]
471- "TARGET_MB_64"
472+ "TARGET_MB_64 && TARGET_PATTERN_COMPARE"
473 "pcmplne\t%0,%1,%2"
474 [(set_attr "type" "arith")
475 (set_attr "mode" "DI")
476--
Andrew Geisslera9ff2b32020-10-16 10:11:54 -05004772.17.1
Brad Bishop26bdd442019-08-16 17:08:17 -0400478