| 1 |
;; Machine description for T-Head vendor extensions |
| 2 |
;; Copyright (C) 2021-2025 Free Software Foundation, Inc. |
| 3 |
|
| 4 |
;; This file is part of GCC. |
| 5 |
|
| 6 |
;; GCC is free software; you can redistribute it and/or modify |
| 7 |
;; it under the terms of the GNU General Public License as published by |
| 8 |
;; the Free Software Foundation; either version 3, or (at your option) |
| 9 |
;; any later version. |
| 10 |
|
| 11 |
;; GCC is distributed in the hope that it will be useful, |
| 12 |
;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
;; GNU General Public License for more details. |
| 15 |
|
| 16 |
;; You should have received a copy of the GNU General Public License |
| 17 |
;; along with GCC; see the file COPYING3. If not see |
| 18 |
;; <http://www.gnu.org/licenses/>. |
| 19 |
|
| 20 |
;; XTheadBa |
| 21 |
|
| 22 |
(define_insn "*th_addsl<mode>4" |
| 23 |
[(set (match_operand:X 0 "register_operand" "=r") |
| 24 |
(plus:X (ashift:X (match_operand:X 1 "register_operand" "r") |
| 25 |
(match_operand:QI 2 "imm123_operand" "Ds3")) |
| 26 |
(match_operand:X 3 "register_operand" "r")))] |
| 27 |
"TARGET_XTHEADBA" |
| 28 |
"th.addsl\t%0,%3,%1,%2" |
| 29 |
[(set_attr "type" "bitmanip") |
| 30 |
(set_attr "mode" "<X:MODE>")]) |
| 31 |
|
| 32 |
;; XTheadBb |
| 33 |
|
| 34 |
(define_insn "*th_srri<mode>3" |
| 35 |
[(set (match_operand:GPR 0 "register_operand" "=r") |
| 36 |
(rotatert:GPR (match_operand:GPR 1 "register_operand" "r") |
| 37 |
(match_operand 2 "const_int_operand" "n")))] |
| 38 |
"TARGET_XTHEADBB && (TARGET_64BIT || <MODE>mode == SImode)" |
| 39 |
{ |
| 40 |
bool wform = TARGET_64BIT && (<MODE>mode == SImode); |
| 41 |
operands[2] = GEN_INT (INTVAL (operands[2]) |
| 42 |
& (GET_MODE_BITSIZE (<MODE>mode) - 1)); |
| 43 |
return wform ? "th.srriw\t%0,%1,%2" : "th.srri\t%0,%1,%2"; |
| 44 |
} |
| 45 |
[(set_attr "type" "bitmanip") |
| 46 |
(set_attr "mode" "<GPR:MODE>")]) |
| 47 |
|
| 48 |
(define_insn "*th_ext<mode>4" |
| 49 |
[(set (match_operand:GPR 0 "register_operand" "=r") |
| 50 |
(sign_extract:GPR (match_operand:GPR 1 "register_operand" "r") |
| 51 |
(match_operand 2 "const_int_operand") |
| 52 |
(match_operand 3 "const_int_operand")))] |
| 53 |
"TARGET_XTHEADBB" |
| 54 |
{ |
| 55 |
operands[2] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[3]) - 1); |
| 56 |
return "th.ext\t%0,%1,%2,%3"; |
| 57 |
} |
| 58 |
[(set_attr "type" "bitmanip") |
| 59 |
(set_attr "mode" "<GPR:MODE>")]) |
| 60 |
|
| 61 |
(define_insn "*extendhi<SUPERQI:mode>2_th_ext" |
| 62 |
[(set (match_operand:SUPERQI 0 "register_operand" "=r,r") |
| 63 |
(sign_extend:SUPERQI |
| 64 |
(match_operand:HI 1 "nonimmediate_operand" "r,m")))] |
| 65 |
"TARGET_XTHEADBB && !TARGET_XTHEADMEMIDX" |
| 66 |
"@ |
| 67 |
th.ext\t%0,%1,15,0 |
| 68 |
lh\t%0,%1" |
| 69 |
[(set_attr "type" "bitmanip,load") |
| 70 |
(set_attr "mode" "<SUPERQI:MODE>")]) |
| 71 |
|
| 72 |
(define_insn "*extendqi<SUPERQI:mode>2_th_ext" |
| 73 |
[(set (match_operand:SUPERQI 0 "register_operand" "=r,r") |
| 74 |
(sign_extend:SUPERQI |
| 75 |
(match_operand:QI 1 "nonimmediate_operand" "r,m")))] |
| 76 |
"TARGET_XTHEADBB && !TARGET_XTHEADMEMIDX" |
| 77 |
"@ |
| 78 |
th.ext\t%0,%1,7,0 |
| 79 |
lb\t%0,%1" |
| 80 |
[(set_attr "type" "bitmanip,load") |
| 81 |
(set_attr "mode" "<SUPERQI:MODE>")]) |
| 82 |
|
| 83 |
(define_insn "*th_extu<mode>4" |
| 84 |
[(set (match_operand:GPR 0 "register_operand" "=r") |
| 85 |
(zero_extract:GPR (match_operand:GPR 1 "register_operand" "r") |
| 86 |
(match_operand 2 "const_int_operand") |
| 87 |
(match_operand 3 "const_int_operand")))] |
| 88 |
"TARGET_XTHEADBB |
| 89 |
&& (UINTVAL (operands[2]) + UINTVAL (operands[3]) |
| 90 |
<= GET_MODE_BITSIZE (<MODE>mode))" |
| 91 |
{ |
| 92 |
operands[2] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[3]) - 1); |
| 93 |
return "th.extu\t%0,%1,%2,%3"; |
| 94 |
} |
| 95 |
[(set_attr "type" "bitmanip") |
| 96 |
(set_attr "mode" "<GPR:MODE>")]) |
| 97 |
|
| 98 |
(define_insn "*zero_extendsidi2_th_extu" |
| 99 |
[(set (match_operand:DI 0 "register_operand" "=r,r") |
| 100 |
(zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "r,m")))] |
| 101 |
"TARGET_64BIT && TARGET_XTHEADBB && !TARGET_XTHEADMEMIDX" |
| 102 |
"@ |
| 103 |
th.extu\t%0,%1,31,0 |
| 104 |
lwu\t%0,%1" |
| 105 |
[(set_attr "type" "bitmanip,load") |
| 106 |
(set_attr "mode" "DI")]) |
| 107 |
|
| 108 |
(define_insn "*zero_extendhi<GPR:mode>2_th_extu" |
| 109 |
[(set (match_operand:GPR 0 "register_operand" "=r,r") |
| 110 |
(zero_extend:GPR (match_operand:HI 1 "nonimmediate_operand" "r,m")))] |
| 111 |
"TARGET_XTHEADBB && !TARGET_XTHEADMEMIDX" |
| 112 |
"@ |
| 113 |
th.extu\t%0,%1,15,0 |
| 114 |
lhu\t%0,%1" |
| 115 |
[(set_attr "type" "bitmanip,load") |
| 116 |
(set_attr "mode" "<GPR:MODE>")]) |
| 117 |
|
| 118 |
(define_insn "*th_clz<mode>2" |
| 119 |
[(set (match_operand:X 0 "register_operand" "=r") |
| 120 |
(clz:X (match_operand:X 1 "register_operand" "r")))] |
| 121 |
"TARGET_XTHEADBB" |
| 122 |
"th.ff1\t%0,%1" |
| 123 |
[(set_attr "type" "bitmanip") |
| 124 |
(set_attr "mode" "<X:MODE>")]) |
| 125 |
|
| 126 |
(define_insn "th_rev<mode>2" |
| 127 |
[(set (match_operand:GPR 0 "register_operand" "=r") |
| 128 |
(bswap:GPR (match_operand:GPR 1 "register_operand" "r")))] |
| 129 |
"TARGET_XTHEADBB && (TARGET_64BIT || <MODE>mode == SImode)" |
| 130 |
{ |
| 131 |
bool wform = TARGET_64BIT && (<MODE>mode == SImode); |
| 132 |
return wform ? "th.revw\t%0,%1" : "th.rev\t%0,%1"; |
| 133 |
} |
| 134 |
[(set_attr "type" "bitmanip") |
| 135 |
(set_attr "mode" "<GPR:MODE>")]) |
| 136 |
|
| 137 |
(define_insn "th_tstnbz<mode>2" |
| 138 |
[(set (match_operand:X 0 "register_operand" "=r") |
| 139 |
(unspec:X [(match_operand:X 1 "register_operand" "r")] UNSPEC_ORC_B))] |
| 140 |
"TARGET_XTHEADBB" |
| 141 |
"th.tstnbz\t%0,%1" |
| 142 |
[(set_attr "type" "bitmanip")]) |
| 143 |
|
| 144 |
;; XTheadBs |
| 145 |
|
| 146 |
(define_insn "*th_tst<mode>3" |
| 147 |
[(set (match_operand:X 0 "register_operand" "=r") |
| 148 |
(zero_extract:X (match_operand:X 1 "register_operand" "r") |
| 149 |
(const_int 1) |
| 150 |
(match_operand 2 "const_int_operand" "n")))] |
| 151 |
"TARGET_XTHEADBS && UINTVAL (operands[2]) < GET_MODE_BITSIZE (<MODE>mode)" |
| 152 |
"th.tst\t%0,%1,%2" |
| 153 |
[(set_attr "type" "bitmanip")]) |
| 154 |
|
| 155 |
;; XTheadCondMov |
| 156 |
|
| 157 |
(define_insn "*th_cond_mov<GPR:mode>" |
| 158 |
[(set (match_operand:GPR 0 "register_operand" "=r,r") |
| 159 |
(if_then_else:GPR |
| 160 |
(match_operator 4 "equality_operator" |
| 161 |
[(match_operand:X 1 "register_operand" "r,r") |
| 162 |
(const_int 0)]) |
| 163 |
(match_operand:GPR 2 "reg_or_0_operand" "rJ,0") |
| 164 |
(match_operand:GPR 3 "reg_or_0_operand" "0,rJ")))] |
| 165 |
"TARGET_XTHEADCONDMOV" |
| 166 |
{ |
| 167 |
if (which_alternative == 0) |
| 168 |
return "th.mv%C4z\t%0,%z2,%1"; |
| 169 |
|
| 170 |
/* Invert the condition and take else-block. */ |
| 171 |
rtx_code code = GET_CODE (operands[4]); |
| 172 |
code = (code == EQ) ? NE : EQ; |
| 173 |
operands[4] = gen_rtx_fmt_ee (code, VOIDmode, operands[1], const0_rtx); |
| 174 |
return "th.mv%C4z\t%0,%z3,%1"; |
| 175 |
} |
| 176 |
[(set_attr "type" "condmove") |
| 177 |
(set_attr "mode" "<GPR:MODE>")]) |
| 178 |
|
| 179 |
;; XTheadFmv |
| 180 |
|
| 181 |
;; In RV32, we lack fmv.x.d and fmv.d.x, but XTheadFmv has instructions |
| 182 |
;; that cover this case. |
| 183 |
|
| 184 |
(define_insn "th_fmv_hw_w_x" |
| 185 |
[(set (match_operand:DF 0 "register_operand" "=f") |
| 186 |
(unspec:DF [(match_operand:SI 1 "register_operand" "r") |
| 187 |
(match_operand:SI 2 "register_operand" "r")] |
| 188 |
UNSPEC_XTHEADFMV))] |
| 189 |
"!TARGET_64BIT && TARGET_XTHEADFMV" |
| 190 |
"fmv.w.x\t%0,%2\n\tth.fmv.hw.x\t%0,%1" |
| 191 |
[(set_attr "move_type" "move") |
| 192 |
(set_attr "type" "fmove") |
| 193 |
(set_attr "mode" "DF")]) |
| 194 |
|
| 195 |
(define_insn "th_fmv_x_w" |
| 196 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 197 |
(unspec:SI [(match_operand:DF 1 "register_operand" "f")] |
| 198 |
UNSPEC_XTHEADFMV))] |
| 199 |
"!TARGET_64BIT && TARGET_XTHEADFMV" |
| 200 |
"fmv.x.w\t%0,%1" |
| 201 |
[(set_attr "move_type" "move") |
| 202 |
(set_attr "type" "fmove") |
| 203 |
(set_attr "mode" "DF")]) |
| 204 |
|
| 205 |
(define_insn "th_fmv_x_hw" |
| 206 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 207 |
(unspec:SI [(match_operand:DF 1 "register_operand" "f")] |
| 208 |
UNSPEC_XTHEADFMV_HW))] |
| 209 |
"!TARGET_64BIT && TARGET_XTHEADFMV" |
| 210 |
"th.fmv.x.hw\t%0,%1" |
| 211 |
[(set_attr "move_type" "move") |
| 212 |
(set_attr "type" "fmove") |
| 213 |
(set_attr "mode" "DF")]) |
| 214 |
|
| 215 |
;; XTheadInt |
| 216 |
|
| 217 |
(define_constants |
| 218 |
[(T0_REGNUM 5) |
| 219 |
(T1_REGNUM 6) |
| 220 |
(T2_REGNUM 7) |
| 221 |
(A0_REGNUM 10) |
| 222 |
(A1_REGNUM 11) |
| 223 |
(A2_REGNUM 12) |
| 224 |
(A3_REGNUM 13) |
| 225 |
(A4_REGNUM 14) |
| 226 |
(A5_REGNUM 15) |
| 227 |
(A6_REGNUM 16) |
| 228 |
(A7_REGNUM 17) |
| 229 |
(T3_REGNUM 28) |
| 230 |
(T4_REGNUM 29) |
| 231 |
(T5_REGNUM 30) |
| 232 |
(T6_REGNUM 31) |
| 233 |
]) |
| 234 |
|
| 235 |
(define_insn "th_int_push" |
| 236 |
[(unspec_volatile [(const_int 0)] UNSPECV_XTHEADINT_PUSH) |
| 237 |
(use (reg:SI RETURN_ADDR_REGNUM)) |
| 238 |
(use (reg:SI T0_REGNUM)) |
| 239 |
(use (reg:SI T1_REGNUM)) |
| 240 |
(use (reg:SI T2_REGNUM)) |
| 241 |
(use (reg:SI A0_REGNUM)) |
| 242 |
(use (reg:SI A1_REGNUM)) |
| 243 |
(use (reg:SI A2_REGNUM)) |
| 244 |
(use (reg:SI A3_REGNUM)) |
| 245 |
(use (reg:SI A4_REGNUM)) |
| 246 |
(use (reg:SI A5_REGNUM)) |
| 247 |
(use (reg:SI A6_REGNUM)) |
| 248 |
(use (reg:SI A7_REGNUM)) |
| 249 |
(use (reg:SI T3_REGNUM)) |
| 250 |
(use (reg:SI T4_REGNUM)) |
| 251 |
(use (reg:SI T5_REGNUM)) |
| 252 |
(use (reg:SI T6_REGNUM))] |
| 253 |
"TARGET_XTHEADINT && !TARGET_64BIT" |
| 254 |
"th.ipush" |
| 255 |
[(set_attr "type" "store") |
| 256 |
(set_attr "mode" "SI")]) |
| 257 |
|
| 258 |
(define_insn "th_int_pop" |
| 259 |
[(unspec_volatile [(const_int 0)] UNSPECV_XTHEADINT_POP) |
| 260 |
(clobber (reg:SI RETURN_ADDR_REGNUM)) |
| 261 |
(clobber (reg:SI T0_REGNUM)) |
| 262 |
(clobber (reg:SI T1_REGNUM)) |
| 263 |
(clobber (reg:SI T2_REGNUM)) |
| 264 |
(clobber (reg:SI A0_REGNUM)) |
| 265 |
(clobber (reg:SI A1_REGNUM)) |
| 266 |
(clobber (reg:SI A2_REGNUM)) |
| 267 |
(clobber (reg:SI A3_REGNUM)) |
| 268 |
(clobber (reg:SI A4_REGNUM)) |
| 269 |
(clobber (reg:SI A5_REGNUM)) |
| 270 |
(clobber (reg:SI A6_REGNUM)) |
| 271 |
(clobber (reg:SI A7_REGNUM)) |
| 272 |
(clobber (reg:SI T3_REGNUM)) |
| 273 |
(clobber (reg:SI T4_REGNUM)) |
| 274 |
(clobber (reg:SI T5_REGNUM)) |
| 275 |
(clobber (reg:SI T6_REGNUM)) |
| 276 |
(return)] |
| 277 |
"TARGET_XTHEADINT && !TARGET_64BIT" |
| 278 |
"th.ipop" |
| 279 |
[(set_attr "type" "ret") |
| 280 |
(set_attr "mode" "SI")]) |
| 281 |
|
| 282 |
;; XTheadMac |
| 283 |
|
| 284 |
(define_insn "*th_mula<mode>" |
| 285 |
[(set (match_operand:X 0 "register_operand" "=r") |
| 286 |
(plus:X (mult:X (match_operand:X 1 "register_operand" "r") |
| 287 |
(match_operand:X 2 "register_operand" "r")) |
| 288 |
(match_operand:X 3 "register_operand" "0")))] |
| 289 |
"TARGET_XTHEADMAC" |
| 290 |
"th.mula\\t%0,%1,%2" |
| 291 |
[(set_attr "type" "imul") |
| 292 |
(set_attr "mode" "<MODE>")] |
| 293 |
) |
| 294 |
|
| 295 |
(define_insn "*th_mulawsi" |
| 296 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 297 |
(sign_extend:DI |
| 298 |
(plus:SI (mult:SI (match_operand:SI 1 "register_operand" "r") |
| 299 |
(match_operand:SI 2 "register_operand" "r")) |
| 300 |
(match_operand:SI 3 "register_operand" "0"))))] |
| 301 |
"TARGET_XTHEADMAC && TARGET_64BIT" |
| 302 |
"th.mulaw\\t%0,%1,%2" |
| 303 |
[(set_attr "type" "imul") |
| 304 |
(set_attr "mode" "SI")] |
| 305 |
) |
| 306 |
|
| 307 |
(define_insn "*th_mulawsi2" |
| 308 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 309 |
(plus:SI (mult:SI (match_operand:SI 1 "register_operand" "r") |
| 310 |
(match_operand:SI 2 "register_operand" "r")) |
| 311 |
(match_operand:SI 3 "register_operand" "0")))] |
| 312 |
"TARGET_XTHEADMAC && TARGET_64BIT" |
| 313 |
"th.mulaw\\t%0,%1,%2" |
| 314 |
[(set_attr "type" "imul") |
| 315 |
(set_attr "mode" "SI")] |
| 316 |
) |
| 317 |
|
| 318 |
(define_insn "*th_maddhisi4" |
| 319 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 320 |
(plus:SI |
| 321 |
(mult:SI |
| 322 |
(sign_extend:SI (match_operand:HI 1 "register_operand" " r")) |
| 323 |
(sign_extend:SI (match_operand:HI 2 "register_operand" " r"))) |
| 324 |
(match_operand:SI 3 "register_operand" " 0")))] |
| 325 |
"TARGET_XTHEADMAC" |
| 326 |
"th.mulah\\t%0,%1,%2" |
| 327 |
[(set_attr "type" "imul") |
| 328 |
(set_attr "mode" "SI")] |
| 329 |
) |
| 330 |
|
| 331 |
(define_insn "*th_sextw_maddhisi4" |
| 332 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 333 |
(sign_extend:DI |
| 334 |
(plus:SI |
| 335 |
(mult:SI |
| 336 |
(sign_extend:SI (match_operand:HI 1 "register_operand" " r")) |
| 337 |
(sign_extend:SI (match_operand:HI 2 "register_operand" " r"))) |
| 338 |
(match_operand:SI 3 "register_operand" " 0"))))] |
| 339 |
"TARGET_XTHEADMAC && TARGET_64BIT" |
| 340 |
"th.mulah\\t%0,%1,%2" |
| 341 |
[(set_attr "type" "imul") |
| 342 |
(set_attr "mode" "SI")] |
| 343 |
) |
| 344 |
|
| 345 |
(define_insn "*th_muls<mode>" |
| 346 |
[(set (match_operand:X 0 "register_operand" "=r") |
| 347 |
(minus:X (match_operand:X 3 "register_operand" "0") |
| 348 |
(mult:X (match_operand:X 1 "register_operand" "r") |
| 349 |
(match_operand:X 2 "register_operand" "r"))))] |
| 350 |
"TARGET_XTHEADMAC" |
| 351 |
"th.muls\\t%0,%1,%2" |
| 352 |
[(set_attr "type" "imul") |
| 353 |
(set_attr "mode" "<MODE>")] |
| 354 |
) |
| 355 |
|
| 356 |
(define_insn "*th_mulswsi" |
| 357 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 358 |
(sign_extend:DI |
| 359 |
(minus:SI (match_operand:SI 3 "register_operand" "0") |
| 360 |
(mult:SI (match_operand:SI 1 "register_operand" "r") |
| 361 |
(match_operand:SI 2 "register_operand" "r")))))] |
| 362 |
"TARGET_XTHEADMAC && TARGET_64BIT" |
| 363 |
"th.mulsw\\t%0,%1,%2" |
| 364 |
[(set_attr "type" "imul") |
| 365 |
(set_attr "mode" "SI")] |
| 366 |
) |
| 367 |
|
| 368 |
(define_insn "*th_mulswsi2" |
| 369 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 370 |
(minus:SI (match_operand:SI 3 "register_operand" "0") |
| 371 |
(mult:SI (match_operand:SI 1 "register_operand" "r") |
| 372 |
(match_operand:SI 2 "register_operand" "r"))))] |
| 373 |
"TARGET_XTHEADMAC && TARGET_64BIT" |
| 374 |
"th.mulsw\\t%0,%1,%2" |
| 375 |
[(set_attr "type" "imul") |
| 376 |
(set_attr "mode" "SI")] |
| 377 |
) |
| 378 |
|
| 379 |
(define_insn "*th_msubhisi4" |
| 380 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 381 |
(minus:SI (match_operand:SI 3 "register_operand" " 0") |
| 382 |
(mult:SI (sign_extend:SI (match_operand:HI 1 "register_operand" " r")) |
| 383 |
(sign_extend:SI (match_operand:HI 2 "register_operand" " r")))))] |
| 384 |
"TARGET_XTHEADMAC" |
| 385 |
"th.mulsh\\t%0,%1,%2" |
| 386 |
[(set_attr "type" "imul") |
| 387 |
(set_attr "mode" "SI")] |
| 388 |
) |
| 389 |
|
| 390 |
(define_insn "*th_sextw_msubhisi4" |
| 391 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 392 |
(sign_extend:DI |
| 393 |
(minus:SI (match_operand:SI 3 "register_operand" " 0") |
| 394 |
(mult:SI |
| 395 |
(sign_extend:SI (match_operand:HI 1 "register_operand" " r")) |
| 396 |
(sign_extend:SI (match_operand:HI 2 "register_operand" " r"))))))] |
| 397 |
"TARGET_XTHEADMAC && TARGET_64BIT" |
| 398 |
"th.mulsh\\t%0,%1,%2" |
| 399 |
[(set_attr "type" "imul") |
| 400 |
(set_attr "mode" "SI")] |
| 401 |
) |
| 402 |
|
| 403 |
;; XTheadMemPair |
| 404 |
|
| 405 |
;; MEMPAIR load 64/32 bit |
| 406 |
(define_insn "*th_mempair_load_<GPR:mode>2" |
| 407 |
[(set (match_operand:GPR 0 "register_operand" "=r") |
| 408 |
(match_operand:GPR 1 "memory_operand" "m")) |
| 409 |
(set (match_operand:GPR 2 "register_operand" "=r") |
| 410 |
(match_operand:GPR 3 "memory_operand" "m"))] |
| 411 |
"TARGET_XTHEADMEMPAIR && reload_completed |
| 412 |
&& th_mempair_operands_p (operands, true, <GPR:MODE>mode)" |
| 413 |
{ return th_mempair_output_move (operands, true, <GPR:MODE>mode, UNKNOWN); } |
| 414 |
[(set_attr "move_type" "load") |
| 415 |
(set_attr "type" "load") |
| 416 |
(set_attr "mode" "<GPR:MODE>")]) |
| 417 |
|
| 418 |
;; MEMPAIR store 64/32 bit |
| 419 |
(define_insn "*th_mempair_store_<GPR:mode>2" |
| 420 |
[(set (match_operand:GPR 0 "memory_operand" "=m") |
| 421 |
(match_operand:GPR 1 "register_operand" "r")) |
| 422 |
(set (match_operand:GPR 2 "memory_operand" "=m") |
| 423 |
(match_operand:GPR 3 "register_operand" "r"))] |
| 424 |
"TARGET_XTHEADMEMPAIR && reload_completed |
| 425 |
&& th_mempair_operands_p (operands, false, <GPR:MODE>mode)" |
| 426 |
{ return th_mempair_output_move (operands, false, <GPR:MODE>mode, UNKNOWN); } |
| 427 |
[(set_attr "move_type" "store") |
| 428 |
(set_attr "type" "store") |
| 429 |
(set_attr "mode" "<GPR:MODE>")]) |
| 430 |
|
| 431 |
;; MEMPAIR load DI extended signed SI |
| 432 |
(define_insn "*th_mempair_load_extendsidi2" |
| 433 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 434 |
(sign_extend:DI (match_operand:SI 1 "memory_operand" "m"))) |
| 435 |
(set (match_operand:DI 2 "register_operand" "=r") |
| 436 |
(sign_extend:DI (match_operand:SI 3 "memory_operand" "m")))] |
| 437 |
"TARGET_XTHEADMEMPAIR && TARGET_64BIT && reload_completed |
| 438 |
&& th_mempair_operands_p (operands, true, SImode)" |
| 439 |
{ return th_mempair_output_move (operands, true, SImode, SIGN_EXTEND); } |
| 440 |
[(set_attr "move_type" "load") |
| 441 |
(set_attr "type" "load") |
| 442 |
(set_attr "mode" "DI") |
| 443 |
(set_attr "length" "8")]) |
| 444 |
|
| 445 |
;; MEMPAIR load DI extended unsigned SI |
| 446 |
(define_insn "*th_mempair_load_zero_extendsidi2" |
| 447 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 448 |
(zero_extend:DI (match_operand:SI 1 "memory_operand" "m"))) |
| 449 |
(set (match_operand:DI 2 "register_operand" "=r") |
| 450 |
(zero_extend:DI (match_operand:SI 3 "memory_operand" "m")))] |
| 451 |
"TARGET_XTHEADMEMPAIR && TARGET_64BIT && reload_completed |
| 452 |
&& th_mempair_operands_p (operands, true, SImode)" |
| 453 |
{ return th_mempair_output_move (operands, true, SImode, ZERO_EXTEND); } |
| 454 |
[(set_attr "move_type" "load") |
| 455 |
(set_attr "type" "load") |
| 456 |
(set_attr "mode" "DI") |
| 457 |
(set_attr "length" "8")]) |
| 458 |
|
| 459 |
;; XTheadMemIdx |
| 460 |
|
| 461 |
(define_insn "*th_memidx_zero_extendqi<SUPERQI:mode>2" |
| 462 |
[(set (match_operand:SUPERQI 0 "register_operand" "=r,r,r,r,r,r") |
| 463 |
(zero_extend:SUPERQI |
| 464 |
(match_operand:QI 1 "nonimmediate_operand" |
| 465 |
" r,th_m_mia,th_m_mib,th_m_mir,th_m_miu,m")))] |
| 466 |
"TARGET_XTHEADMEMIDX" |
| 467 |
"@ |
| 468 |
andi\t%0,%1,0xff |
| 469 |
th.lbuia\t%0,%1 |
| 470 |
th.lbuib\t%0,%1 |
| 471 |
th.lrbu\t%0,%1 |
| 472 |
th.lurbu\t%0,%1 |
| 473 |
lbu\t%0,%1" |
| 474 |
[(set_attr "move_type" "andi,load,load,load,load,load") |
| 475 |
(set_attr "mode" "<SUPERQI:MODE>")]) |
| 476 |
|
| 477 |
(define_insn "*th_memidx_extendsidi2" |
| 478 |
[(set (match_operand:DI 0 "register_operand" "=r,r,r,r,r,r") |
| 479 |
(sign_extend:DI |
| 480 |
(match_operand:SI 1 "nonimmediate_operand" |
| 481 |
" r,th_m_mia,th_m_mib,th_m_mir,th_m_miu,m")))] |
| 482 |
"TARGET_64BIT && TARGET_XTHEADMEMIDX" |
| 483 |
"@ |
| 484 |
sext.w\t%0,%1 |
| 485 |
th.lwia\t%0,%1 |
| 486 |
th.lwib\t%0,%1 |
| 487 |
th.lrw\t%0,%1 |
| 488 |
th.lurw\t%0,%1 |
| 489 |
lw\t%0,%1" |
| 490 |
[(set_attr "move_type" "move,load,load,load,load,load") |
| 491 |
(set_attr "mode" "DI")]) |
| 492 |
|
| 493 |
;; XTheadMemIdx (without XTheadBb) |
| 494 |
|
| 495 |
(define_insn_and_split "*th_memidx_zero_extendsidi2" |
| 496 |
[(set (match_operand:DI 0 "register_operand" "=r,r,r,r,r,r") |
| 497 |
(zero_extend:DI |
| 498 |
(match_operand:SI 1 "nonimmediate_operand" |
| 499 |
" r,th_m_mia,th_m_mib,th_m_mir,th_m_miu,m")))] |
| 500 |
"TARGET_64BIT && TARGET_XTHEADMEMIDX && !TARGET_XTHEADBB" |
| 501 |
"@ |
| 502 |
# |
| 503 |
th.lwuia\t%0,%1 |
| 504 |
th.lwuib\t%0,%1 |
| 505 |
th.lrwu\t%0,%1 |
| 506 |
th.lurwu\t%0,%1 |
| 507 |
lwu\t%0,%1" |
| 508 |
"&& reload_completed |
| 509 |
&& REG_P (operands[1]) |
| 510 |
&& !paradoxical_subreg_p (operands[0])" |
| 511 |
[(set (match_dup 0) |
| 512 |
(ashift:DI (match_dup 1) (const_int 32))) |
| 513 |
(set (match_dup 0) |
| 514 |
(lshiftrt:DI (match_dup 0) (const_int 32)))] |
| 515 |
{ operands[1] = gen_lowpart (DImode, operands[1]); } |
| 516 |
[(set_attr "move_type" "shift_shift,load,load,load,load,load") |
| 517 |
(set_attr "mode" "DI")]) |
| 518 |
|
| 519 |
(define_insn_and_split "*th_memidx_zero_extendhi<GPR:mode>2" |
| 520 |
[(set (match_operand:GPR 0 "register_operand" "=r,r,r,r,r,r") |
| 521 |
(zero_extend:GPR |
| 522 |
(match_operand:HI 1 "nonimmediate_operand" |
| 523 |
" r,th_m_mia,th_m_mib,th_m_mir,th_m_miu,m")))] |
| 524 |
"TARGET_XTHEADMEMIDX && !TARGET_XTHEADBB" |
| 525 |
"@ |
| 526 |
# |
| 527 |
th.lhuia\t%0,%1 |
| 528 |
th.lhuib\t%0,%1 |
| 529 |
th.lrhu\t%0,%1 |
| 530 |
th.lurhu\t%0,%1 |
| 531 |
lhu\t%0,%1" |
| 532 |
"&& reload_completed |
| 533 |
&& REG_P (operands[1]) |
| 534 |
&& !paradoxical_subreg_p (operands[0])" |
| 535 |
[(set (match_dup 0) |
| 536 |
(ashift:GPR (match_dup 1) (match_dup 2))) |
| 537 |
(set (match_dup 0) |
| 538 |
(lshiftrt:GPR (match_dup 0) (match_dup 2)))] |
| 539 |
{ |
| 540 |
operands[1] = gen_lowpart (<GPR:MODE>mode, operands[1]); |
| 541 |
operands[2] = GEN_INT(GET_MODE_BITSIZE(<GPR:MODE>mode) - 16); |
| 542 |
} |
| 543 |
[(set_attr "move_type" "shift_shift,load,load,load,load,load") |
| 544 |
(set_attr "mode" "<GPR:MODE>")]) |
| 545 |
|
| 546 |
(define_insn_and_split "*th_memidx_extend<SHORT:mode><SUPERQI:mode>2" |
| 547 |
[(set (match_operand:SUPERQI 0 "register_operand" "=r,r,r,r,r,r") |
| 548 |
(sign_extend:SUPERQI |
| 549 |
(match_operand:SHORT 1 "nonimmediate_operand" |
| 550 |
" r,th_m_mia,th_m_mib,th_m_mir,th_m_miu,m")))] |
| 551 |
"TARGET_XTHEADMEMIDX && !TARGET_XTHEADBB" |
| 552 |
"@ |
| 553 |
# |
| 554 |
th.l<SHORT:size>ia\t%0,%1 |
| 555 |
th.l<SHORT:size>ib\t%0,%1 |
| 556 |
th.lr<SHORT:size>\t%0,%1 |
| 557 |
th.lur<SHORT:size>\t%0,%1 |
| 558 |
l<SHORT:size>\t%0,%1" |
| 559 |
"&& reload_completed |
| 560 |
&& REG_P (operands[1]) |
| 561 |
&& !paradoxical_subreg_p (operands[0])" |
| 562 |
[(set (match_dup 0) (ashift:SI (match_dup 1) (match_dup 2))) |
| 563 |
(set (match_dup 0) (ashiftrt:SI (match_dup 0) (match_dup 2)))] |
| 564 |
{ |
| 565 |
operands[0] = gen_lowpart (SImode, operands[0]); |
| 566 |
operands[1] = gen_lowpart (SImode, operands[1]); |
| 567 |
operands[2] = GEN_INT (GET_MODE_BITSIZE (SImode) |
| 568 |
- GET_MODE_BITSIZE (<SHORT:MODE>mode)); |
| 569 |
} |
| 570 |
[(set_attr "move_type" "shift_shift,load,load,load,load,load") |
| 571 |
(set_attr "mode" "SI")]) |
| 572 |
|
| 573 |
;; XTheadMemIdx (with XTheadBb) |
| 574 |
|
| 575 |
(define_insn "*th_memidx_bb_zero_extendsidi2" |
| 576 |
[(set (match_operand:DI 0 "register_operand" "=r,r,r,r,r,r") |
| 577 |
(zero_extend:DI |
| 578 |
(match_operand:SI 1 "nonimmediate_operand" |
| 579 |
" r,th_m_mia,th_m_mib,th_m_mir,th_m_miu,m")))] |
| 580 |
"TARGET_64BIT && TARGET_XTHEADMEMIDX && TARGET_XTHEADBB" |
| 581 |
"@ |
| 582 |
th.extu\t%0,%1,31,0 |
| 583 |
th.lwuia\t%0,%1 |
| 584 |
th.lwuib\t%0,%1 |
| 585 |
th.lrwu\t%0,%1 |
| 586 |
th.lurwu\t%0,%1 |
| 587 |
lwu\t%0,%1" |
| 588 |
[(set_attr "move_type" "shift_shift,load,load,load,load,load") |
| 589 |
(set_attr "mode" "DI")]) |
| 590 |
|
| 591 |
(define_insn "*th_memidx_bb_zero_extendhi<GPR:mode>2" |
| 592 |
[(set (match_operand:GPR 0 "register_operand" "=r,r,r,r,r,r") |
| 593 |
(zero_extend:GPR |
| 594 |
(match_operand:HI 1 "nonimmediate_operand" |
| 595 |
" r,th_m_mia,th_m_mib,th_m_mir,th_m_miu,m")))] |
| 596 |
"TARGET_XTHEADMEMIDX && TARGET_XTHEADBB" |
| 597 |
"@ |
| 598 |
th.extu\t%0,%1,15,0 |
| 599 |
th.lhuia\t%0,%1 |
| 600 |
th.lhuib\t%0,%1 |
| 601 |
th.lrhu\t%0,%1 |
| 602 |
th.lurhu\t%0,%1 |
| 603 |
lhu\t%0,%1" |
| 604 |
[(set_attr "move_type" "shift_shift,load,load,load,load,load") |
| 605 |
(set_attr "mode" "<GPR:MODE>")]) |
| 606 |
|
| 607 |
(define_insn "*th_memidx_bb_extendhi<GPR:mode>2" |
| 608 |
[(set (match_operand:GPR 0 "register_operand" "=r,r,r,r,r,r") |
| 609 |
(sign_extend:GPR |
| 610 |
(match_operand:HI 1 "nonimmediate_operand" |
| 611 |
" r,th_m_mia,th_m_mib,th_m_mir,th_m_miu,m")))] |
| 612 |
"TARGET_XTHEADMEMIDX && TARGET_XTHEADBB" |
| 613 |
"@ |
| 614 |
th.ext\t%0,%1,15,0 |
| 615 |
th.lhia\t%0,%1 |
| 616 |
th.lhib\t%0,%1 |
| 617 |
th.lrh\t%0,%1 |
| 618 |
th.lurh\t%0,%1 |
| 619 |
lh\t%0,%1" |
| 620 |
[(set_attr "move_type" "shift_shift,load,load,load,load,load") |
| 621 |
(set_attr "mode" "<GPR:MODE>")]) |
| 622 |
|
| 623 |
(define_insn "*th_memidx_bb_extendqi<SUPERQI:mode>2" |
| 624 |
[(set (match_operand:SUPERQI 0 "register_operand" "=r,r,r,r,r,r") |
| 625 |
(sign_extend:SUPERQI |
| 626 |
(match_operand:QI 1 "nonimmediate_operand" |
| 627 |
" r,th_m_mia,th_m_mib,th_m_mir,th_m_miu,m")))] |
| 628 |
"TARGET_XTHEADMEMIDX && TARGET_XTHEADBB" |
| 629 |
"@ |
| 630 |
th.ext\t%0,%1,7,0 |
| 631 |
th.lbia\t%0,%1 |
| 632 |
th.lbib\t%0,%1 |
| 633 |
th.lrb\t%0,%1 |
| 634 |
th.lurb\t%0,%1 |
| 635 |
lb\t%0,%1" |
| 636 |
[(set_attr "move_type" "shift_shift,load,load,load,load,load") |
| 637 |
(set_attr "mode" "<SUPERQI:MODE>")]) |
| 638 |
|
| 639 |
(include "thead-peephole.md") |