Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame^] | 1 | From e3b95d5646d4197bff81105c12bcbc5e7dba1725 Mon Sep 17 00:00:00 2001 |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 2 | From: Nagaraju <nmekala@xilinx.com> |
| 3 | Date: Thu, 18 Apr 2019 16:00:37 +0530 |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame^] | 4 | Subject: [PATCH 53/58] [Patch, microblaze]: MB-64 removal of barrel-shift |
| 5 | instructions from default |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 6 | |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame^] | 7 | By default MB-64 is generatting barrel-shift instructions. It has been |
| 8 | removed from default. Barrel-shift instructions will be generated only if |
| 9 | barrel-shifter is enabled. Similarly to double instructions as well. |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 10 | |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame^] | 11 | Signed-off-by :Nagaraju Mekala <nmekala@xilix.com> |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 12 | --- |
| 13 | gcc/config/microblaze/microblaze.c | 2 +- |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame^] | 14 | gcc/config/microblaze/microblaze.md | 269 ++++++++++++++++++++++++++-- |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 15 | 2 files changed, 252 insertions(+), 19 deletions(-) |
| 16 | |
| 17 | diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame^] | 18 | index 12b1da852dd..5b4c21af365 100644 |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 19 | --- a/gcc/config/microblaze/microblaze.c |
| 20 | +++ b/gcc/config/microblaze/microblaze.c |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame^] | 21 | @@ -4000,7 +4000,7 @@ microblaze_expand_divide (rtx operands[]) |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 22 | 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 { |
| 30 | diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame^] | 31 | index 626eade9468..6cc62666269 100644 |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 32 | --- a/gcc/config/microblaze/microblaze.md |
| 33 | +++ b/gcc/config/microblaze/microblaze.md |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 34 | @@ -547,7 +547,7 @@ |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 35 | [(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 Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 43 | @@ -557,7 +557,7 @@ |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 44 | [(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 Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 52 | @@ -567,7 +567,7 @@ |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 53 | [(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 Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 61 | @@ -577,7 +577,7 @@ |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 62 | [(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 Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 70 | @@ -587,7 +587,7 @@ |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 71 | (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 Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 79 | @@ -596,7 +596,7 @@ |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 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 | + "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 Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 88 | @@ -605,7 +605,7 @@ |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 89 | (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 Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 97 | @@ -1301,6 +1301,34 @@ |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 98 | (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 Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 132 | @@ -1314,7 +1342,15 @@ |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 133 | 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 Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 149 | @@ -1388,7 +1424,7 @@ |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 150 | (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 Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 158 | @@ -1655,6 +1691,33 @@ |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 159 | ;; 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 Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 192 | @@ -1671,7 +1734,13 @@ |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 193 | 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 Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 207 | @@ -1791,11 +1860,21 @@ |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 208 | "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 Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 230 | @@ -1805,7 +1884,7 @@ else |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 231 | [(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 Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 239 | @@ -1813,6 +1892,51 @@ else |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 240 | (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 Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 291 | @@ -1946,11 +2070,21 @@ else |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 292 | "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 Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 314 | @@ -1960,7 +2094,7 @@ else |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 315 | [(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 Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 323 | @@ -1968,6 +2102,51 @@ else |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 324 | (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 Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 375 | @@ -2085,11 +2264,21 @@ else |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 376 | "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 Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 398 | @@ -2099,7 +2288,7 @@ else |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 399 | [(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 Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 407 | @@ -2108,6 +2297,50 @@ else |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 408 | (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 Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 458 | @@ -2235,7 +2468,7 @@ else |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 459 | (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 Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 467 | @@ -2247,7 +2480,7 @@ else |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 468 | (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 Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame^] | 477 | 2.17.1 |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 478 | |