| 1 |
;; Machine description for AArch64 architecture. |
| 2 |
;; Copyright (C) 2009-2025 Free Software Foundation, Inc. |
| 3 |
;; Contributed by ARM Ltd. |
| 4 |
;; |
| 5 |
;; This file is part of GCC. |
| 6 |
;; |
| 7 |
;; GCC is free software; you can redistribute it and/or modify it |
| 8 |
;; under the terms of the GNU General Public License as published by |
| 9 |
;; the Free Software Foundation; either version 3, or (at your option) |
| 10 |
;; any later version. |
| 11 |
;; |
| 12 |
;; GCC is distributed in the hope that it will be useful, but |
| 13 |
;; WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 |
;; General Public License for more details. |
| 16 |
;; |
| 17 |
;; You should have received a copy of the GNU General Public License |
| 18 |
;; along with GCC; see the file COPYING3. If not see |
| 19 |
;; <http://www.gnu.org/licenses/>. |
| 20 |
|
| 21 |
;; Register numbers |
| 22 |
(define_constants |
| 23 |
[ |
| 24 |
(R0_REGNUM 0) |
| 25 |
(R1_REGNUM 1) |
| 26 |
(R2_REGNUM 2) |
| 27 |
(R3_REGNUM 3) |
| 28 |
(R4_REGNUM 4) |
| 29 |
(R5_REGNUM 5) |
| 30 |
(R6_REGNUM 6) |
| 31 |
(R7_REGNUM 7) |
| 32 |
(R8_REGNUM 8) |
| 33 |
(R9_REGNUM 9) |
| 34 |
(R10_REGNUM 10) |
| 35 |
(R11_REGNUM 11) |
| 36 |
(R12_REGNUM 12) |
| 37 |
(R13_REGNUM 13) |
| 38 |
(R14_REGNUM 14) |
| 39 |
(R15_REGNUM 15) |
| 40 |
(R16_REGNUM 16) |
| 41 |
(R17_REGNUM 17) |
| 42 |
(R18_REGNUM 18) |
| 43 |
(R19_REGNUM 19) |
| 44 |
(R20_REGNUM 20) |
| 45 |
(R21_REGNUM 21) |
| 46 |
(R22_REGNUM 22) |
| 47 |
(R23_REGNUM 23) |
| 48 |
(R24_REGNUM 24) |
| 49 |
(R25_REGNUM 25) |
| 50 |
(R26_REGNUM 26) |
| 51 |
(R27_REGNUM 27) |
| 52 |
(R28_REGNUM 28) |
| 53 |
(R29_REGNUM 29) |
| 54 |
(R30_REGNUM 30) |
| 55 |
(SP_REGNUM 31) |
| 56 |
(V0_REGNUM 32) |
| 57 |
(V1_REGNUM 33) |
| 58 |
(V2_REGNUM 34) |
| 59 |
(V3_REGNUM 35) |
| 60 |
(V4_REGNUM 36) |
| 61 |
(V5_REGNUM 37) |
| 62 |
(V6_REGNUM 38) |
| 63 |
(V7_REGNUM 39) |
| 64 |
(V8_REGNUM 40) |
| 65 |
(V9_REGNUM 41) |
| 66 |
(V10_REGNUM 42) |
| 67 |
(V11_REGNUM 43) |
| 68 |
(V12_REGNUM 44) |
| 69 |
(V13_REGNUM 45) |
| 70 |
(V14_REGNUM 46) |
| 71 |
(V15_REGNUM 47) |
| 72 |
(V16_REGNUM 48) |
| 73 |
(V17_REGNUM 49) |
| 74 |
(V18_REGNUM 50) |
| 75 |
(V19_REGNUM 51) |
| 76 |
(V20_REGNUM 52) |
| 77 |
(V21_REGNUM 53) |
| 78 |
(V22_REGNUM 54) |
| 79 |
(V23_REGNUM 55) |
| 80 |
(V24_REGNUM 56) |
| 81 |
(V25_REGNUM 57) |
| 82 |
(V26_REGNUM 58) |
| 83 |
(V27_REGNUM 59) |
| 84 |
(V28_REGNUM 60) |
| 85 |
(V29_REGNUM 61) |
| 86 |
(V30_REGNUM 62) |
| 87 |
(V31_REGNUM 63) |
| 88 |
(SFP_REGNUM 64) |
| 89 |
(AP_REGNUM 65) |
| 90 |
(CC_REGNUM 66) |
| 91 |
;; Defined only to make the DWARF description simpler. |
| 92 |
(VG_REGNUM 67) |
| 93 |
(P0_REGNUM 68) |
| 94 |
(P1_REGNUM 69) |
| 95 |
(P2_REGNUM 70) |
| 96 |
(P3_REGNUM 71) |
| 97 |
(P4_REGNUM 72) |
| 98 |
(P5_REGNUM 73) |
| 99 |
(P6_REGNUM 74) |
| 100 |
(P7_REGNUM 75) |
| 101 |
(P8_REGNUM 76) |
| 102 |
(P9_REGNUM 77) |
| 103 |
(P10_REGNUM 78) |
| 104 |
(P11_REGNUM 79) |
| 105 |
(P12_REGNUM 80) |
| 106 |
(P13_REGNUM 81) |
| 107 |
(P14_REGNUM 82) |
| 108 |
(P15_REGNUM 83) |
| 109 |
(LAST_SAVED_REGNUM 83) |
| 110 |
|
| 111 |
;; Floating Point Mode Register, used in FP8 insns. |
| 112 |
(FPM_REGNUM 84) |
| 113 |
|
| 114 |
(FFR_REGNUM 85) |
| 115 |
;; "FFR token": a fake register used for representing the scheduling |
| 116 |
;; restrictions on FFR-related operations. |
| 117 |
(FFRT_REGNUM 86) |
| 118 |
|
| 119 |
;; ---------------------------------------------------------------- |
| 120 |
;; Fake registers |
| 121 |
;; ---------------------------------------------------------------- |
| 122 |
;; These registers represent abstract things, rather than real |
| 123 |
;; architected registers. |
| 124 |
|
| 125 |
;; Sometimes we use placeholder instructions to mark where later |
| 126 |
;; ABI-related lowering is needed. These placeholders read and |
| 127 |
;; write this register. Instructions that depend on the lowering |
| 128 |
;; read the register. |
| 129 |
(LOWERING_REGNUM 87) |
| 130 |
|
| 131 |
;; Represents the contents of the current function's TPIDR2 block, |
| 132 |
;; in abstract form. |
| 133 |
(TPIDR2_BLOCK_REGNUM 88) |
| 134 |
|
| 135 |
;; Holds the value that the current function wants PSTATE.ZA to be. |
| 136 |
;; The actual value can sometimes vary, because it does not track |
| 137 |
;; changes to PSTATE.ZA that happen during a lazy save and restore. |
| 138 |
;; Those effects are instead tracked by ZA_SAVED_REGNUM. |
| 139 |
;; |
| 140 |
;; Sequences also write to this register if they synchronize the |
| 141 |
;; actual contents of ZA and PSTATE.ZA with the current function's |
| 142 |
;; ZA_REGNUM and SME_STATE_REGNUM. Conceptually, these extra writes |
| 143 |
;; do not change the value of SME_STATE_REGNUM. They simply act as |
| 144 |
;; sequencing points. They means that all direct accesses to ZA can |
| 145 |
;; depend only on ZA_REGNUM and SME_STATE_REGNUM, rather than also |
| 146 |
;; depending on ZA_SAVED_REGNUM etc. |
| 147 |
(SME_STATE_REGNUM 89) |
| 148 |
|
| 149 |
;; Instructions write to this register if they set TPIDR2_EL0 to a |
| 150 |
;; well-defined value. Instructions read from the register if they |
| 151 |
;; depend on the result of such writes. |
| 152 |
;; |
| 153 |
;; The register does not model the architected TPIDR2_ELO, just the |
| 154 |
;; current function's management of it. |
| 155 |
(TPIDR2_SETUP_REGNUM 90) |
| 156 |
|
| 157 |
;; Represents the property "has an incoming lazy save been committed?". |
| 158 |
(ZA_FREE_REGNUM 91) |
| 159 |
|
| 160 |
;; Represents the property "are the current function's ZA contents |
| 161 |
;; stored in the lazy save buffer, rather than in ZA itself?". |
| 162 |
(ZA_SAVED_REGNUM 92) |
| 163 |
|
| 164 |
;; Represents the contents of the current function's ZA state in |
| 165 |
;; abstract form. At various times in the function, these contents |
| 166 |
;; might be stored in ZA itself, or in the function's lazy save buffer. |
| 167 |
;; |
| 168 |
;; The contents persist even when the architected ZA is off. Private-ZA |
| 169 |
;; functions have no effect on its contents. |
| 170 |
(ZA_REGNUM 93) |
| 171 |
|
| 172 |
;; Similarly represents the contents of the current function's ZT0 state. |
| 173 |
(ZT0_REGNUM 94) |
| 174 |
|
| 175 |
(FIRST_FAKE_REGNUM LOWERING_REGNUM) |
| 176 |
(LAST_FAKE_REGNUM ZT0_REGNUM) |
| 177 |
;; ---------------------------------------------------------------- |
| 178 |
|
| 179 |
;; The pair of scratch registers used for stack probing with -fstack-check. |
| 180 |
;; Leave R9 alone as a possible choice for the static chain. |
| 181 |
;; Note that the use of these registers is mutually exclusive with the use |
| 182 |
;; of STACK_CLASH_SVE_CFA_REGNUM, which is for -fstack-clash-protection |
| 183 |
;; rather than -fstack-check. |
| 184 |
(PROBE_STACK_FIRST_REGNUM 10) |
| 185 |
(PROBE_STACK_SECOND_REGNUM 11) |
| 186 |
;; Scratch register used by stack clash protection to calculate |
| 187 |
;; SVE CFA offsets during probing. |
| 188 |
(STACK_CLASH_SVE_CFA_REGNUM 11) |
| 189 |
;; Scratch registers for prologue/epilogue use. |
| 190 |
(EP0_REGNUM 12) |
| 191 |
(EP1_REGNUM 13) |
| 192 |
;; A couple of call-clobbered registers that we need to reserve when |
| 193 |
;; tracking speculation this is not ABI, so is subject to change. |
| 194 |
(SPECULATION_SCRATCH_REGNUM 14) |
| 195 |
(SPECULATION_TRACKER_REGNUM 15) |
| 196 |
;; Scratch registers used in frame layout. |
| 197 |
(IP0_REGNUM 16) |
| 198 |
(IP1_REGNUM 17) |
| 199 |
(FP_REGNUM 29) |
| 200 |
(LR_REGNUM 30) |
| 201 |
] |
| 202 |
) |
| 203 |
|
| 204 |
(define_c_enum "unspec" [ |
| 205 |
UNSPEC_AUTIA1716 |
| 206 |
UNSPEC_AUTIB1716 |
| 207 |
UNSPEC_AUTIASP |
| 208 |
UNSPEC_AUTIBSP |
| 209 |
UNSPEC_BSL |
| 210 |
UNSPEC_CALLEE_ABI |
| 211 |
UNSPEC_CASESI |
| 212 |
UNSPEC_COMBINE |
| 213 |
UNSPEC_CPYMEM |
| 214 |
UNSPEC_CRC32B |
| 215 |
UNSPEC_CRC32CB |
| 216 |
UNSPEC_CRC32CH |
| 217 |
UNSPEC_CRC32CW |
| 218 |
UNSPEC_CRC32CX |
| 219 |
UNSPEC_CRC32H |
| 220 |
UNSPEC_CRC32W |
| 221 |
UNSPEC_CRC32X |
| 222 |
UNSPEC_DUP |
| 223 |
UNSPEC_DUP_LANE |
| 224 |
UNSPEC_FCVTZS |
| 225 |
UNSPEC_FCVTZU |
| 226 |
UNSPEC_FJCVTZS |
| 227 |
UNSPEC_FRINT32Z |
| 228 |
UNSPEC_FRINT32X |
| 229 |
UNSPEC_FRINT64Z |
| 230 |
UNSPEC_FRINT64X |
| 231 |
UNSPEC_URECPE |
| 232 |
UNSPEC_FRECPE |
| 233 |
UNSPEC_FRECPS |
| 234 |
UNSPEC_FRECPX |
| 235 |
UNSPEC_FRINTA |
| 236 |
UNSPEC_FRINTI |
| 237 |
UNSPEC_FRINTM |
| 238 |
UNSPEC_FRINTN |
| 239 |
UNSPEC_FRINTP |
| 240 |
UNSPEC_FRINTX |
| 241 |
UNSPEC_FRINTZ |
| 242 |
UNSPEC_GET_LANE |
| 243 |
UNSPEC_GOTSMALLPIC |
| 244 |
UNSPEC_GOTSMALLPIC28K |
| 245 |
UNSPEC_GOTSMALLTLS |
| 246 |
UNSPEC_GOTTINYPIC |
| 247 |
UNSPEC_GOTTINYTLS |
| 248 |
UNSPEC_STP |
| 249 |
UNSPEC_LDP_FST |
| 250 |
UNSPEC_LDP_SND |
| 251 |
UNSPEC_LD1 |
| 252 |
UNSPEC_LD1_DUP |
| 253 |
UNSPEC_LD1x2 |
| 254 |
UNSPEC_LD1x3 |
| 255 |
UNSPEC_LD1x4 |
| 256 |
UNSPEC_LD2 |
| 257 |
UNSPEC_LD2_DREG |
| 258 |
UNSPEC_LD2_DUP |
| 259 |
UNSPEC_LD3 |
| 260 |
UNSPEC_LD3_DREG |
| 261 |
UNSPEC_LD3_DUP |
| 262 |
UNSPEC_LD4 |
| 263 |
UNSPEC_LD4_DREG |
| 264 |
UNSPEC_LD4_DUP |
| 265 |
UNSPEC_LD2_LANE |
| 266 |
UNSPEC_LD3_LANE |
| 267 |
UNSPEC_LD4_LANE |
| 268 |
UNSPEC_LD64B |
| 269 |
UNSPEC_ST64B |
| 270 |
UNSPEC_ST64BV |
| 271 |
UNSPEC_ST64BV_RET |
| 272 |
UNSPEC_ST64BV0 |
| 273 |
UNSPEC_ST64BV0_RET |
| 274 |
UNSPEC_MB |
| 275 |
UNSPEC_MOVMEM |
| 276 |
UNSPEC_NOP |
| 277 |
UNSPEC_PACIA1716 |
| 278 |
UNSPEC_PACIB1716 |
| 279 |
UNSPEC_PACIASP |
| 280 |
UNSPEC_PACIBSP |
| 281 |
UNSPEC_PRLG_STK |
| 282 |
UNSPEC_REV |
| 283 |
UNSPEC_REV_PRED |
| 284 |
UNSPEC_SADALP |
| 285 |
UNSPEC_SCVTF |
| 286 |
UNSPEC_SET_LANE |
| 287 |
UNSPEC_SETMEM |
| 288 |
UNSPEC_SISD_NEG |
| 289 |
UNSPEC_SISD_SSHL |
| 290 |
UNSPEC_SISD_USHL |
| 291 |
UNSPEC_SSHL_2S |
| 292 |
UNSPEC_ST1 |
| 293 |
UNSPEC_ST1_LANE |
| 294 |
UNSPEC_ST1x2 |
| 295 |
UNSPEC_ST1x3 |
| 296 |
UNSPEC_ST1x4 |
| 297 |
UNSPEC_ST2 |
| 298 |
UNSPEC_ST3 |
| 299 |
UNSPEC_ST4 |
| 300 |
UNSPEC_ST2_LANE |
| 301 |
UNSPEC_ST3_LANE |
| 302 |
UNSPEC_ST4_LANE |
| 303 |
UNSPEC_TLS |
| 304 |
UNSPEC_TLSDESC |
| 305 |
UNSPEC_TLSLE12 |
| 306 |
UNSPEC_TLSLE24 |
| 307 |
UNSPEC_TLSLE32 |
| 308 |
UNSPEC_TLSLE48 |
| 309 |
UNSPEC_UADALP |
| 310 |
UNSPEC_UCVTF |
| 311 |
UNSPEC_USHL_2S |
| 312 |
UNSPEC_VSTRUCTDUMMY |
| 313 |
UNSPEC_SSP_SYSREG |
| 314 |
UNSPEC_SP_SET |
| 315 |
UNSPEC_SP_TEST |
| 316 |
UNSPEC_RSQRT |
| 317 |
UNSPEC_RSQRTE |
| 318 |
UNSPEC_RSQRTS |
| 319 |
UNSPEC_NZCV |
| 320 |
UNSPEC_XPACLRI |
| 321 |
UNSPEC_LD1_SVE |
| 322 |
UNSPEC_ST1_SVE |
| 323 |
UNSPEC_LDNT1_SVE |
| 324 |
UNSPEC_STNT1_SVE |
| 325 |
UNSPEC_LD1RQ |
| 326 |
UNSPEC_LD1_GATHER |
| 327 |
UNSPEC_LDFF1_GATHER |
| 328 |
UNSPEC_LDNT1_GATHER |
| 329 |
UNSPEC_ST1_SCATTER |
| 330 |
UNSPEC_STNT1_SCATTER |
| 331 |
UNSPEC_PRED_X |
| 332 |
UNSPEC_PRED_Z |
| 333 |
UNSPEC_PTEST |
| 334 |
UNSPEC_PTRUE |
| 335 |
UNSPEC_UNPACKSHI |
| 336 |
UNSPEC_UNPACKUHI |
| 337 |
UNSPEC_UNPACKSLO |
| 338 |
UNSPEC_UNPACKULO |
| 339 |
UNSPEC_PACK |
| 340 |
UNSPEC_VCREATE |
| 341 |
UNSPEC_VEC_COPY |
| 342 |
UNSPEC_WHILEGE |
| 343 |
UNSPEC_WHILEGT |
| 344 |
UNSPEC_WHILEHI |
| 345 |
UNSPEC_WHILEHS |
| 346 |
UNSPEC_WHILELE |
| 347 |
UNSPEC_WHILELO |
| 348 |
UNSPEC_WHILELS |
| 349 |
UNSPEC_WHILELT |
| 350 |
UNSPEC_WHILERW |
| 351 |
UNSPEC_WHILEWR |
| 352 |
UNSPEC_LDN |
| 353 |
UNSPEC_STN |
| 354 |
UNSPEC_INSR |
| 355 |
UNSPEC_CLASTA |
| 356 |
UNSPEC_CLASTB |
| 357 |
UNSPEC_FADDA |
| 358 |
UNSPEC_REV_SUBREG |
| 359 |
UNSPEC_REINTERPRET |
| 360 |
UNSPEC_SPECULATION_TRACKER |
| 361 |
UNSPEC_SPECULATION_TRACKER_REV |
| 362 |
UNSPEC_COPYSIGN |
| 363 |
UNSPEC_TTEST ; Represent transaction test. |
| 364 |
UNSPEC_UPDATE_FFR |
| 365 |
UNSPEC_UPDATE_FFRT |
| 366 |
UNSPEC_RDFFR |
| 367 |
UNSPEC_WRFFR |
| 368 |
UNSPEC_WRITE_FPMR |
| 369 |
UNSPEC_SYSREG_RDI |
| 370 |
UNSPEC_SYSREG_RTI |
| 371 |
UNSPEC_SYSREG_WDI |
| 372 |
UNSPEC_SYSREG_WTI |
| 373 |
UNSPEC_PLDX |
| 374 |
;; Represents an SVE-style lane index, in which the indexing applies |
| 375 |
;; within the containing 128-bit block. |
| 376 |
UNSPEC_SVE_LANE_SELECT |
| 377 |
UNSPEC_SVE_CNT_PAT |
| 378 |
UNSPEC_SVE_PREFETCH |
| 379 |
UNSPEC_SVE_PREFETCH_GATHER |
| 380 |
UNSPEC_SVE_COMPACT |
| 381 |
UNSPEC_SVE_SPLICE |
| 382 |
UNSPEC_GEN_TAG ; Generate a 4-bit MTE tag. |
| 383 |
UNSPEC_GEN_TAG_RND ; Generate a random 4-bit MTE tag. |
| 384 |
UNSPEC_TAG_SPACE ; Translate address to MTE tag address space. |
| 385 |
UNSPEC_LD1RO |
| 386 |
UNSPEC_SALT_ADDR |
| 387 |
UNSPEC_SAVE_NZCV |
| 388 |
UNSPEC_RESTORE_NZCV |
| 389 |
UNSPECV_PATCHABLE_AREA |
| 390 |
UNSPEC_LDAP1_LANE |
| 391 |
UNSPEC_STL1_LANE |
| 392 |
;; Wraps a constant integer that should be multiplied by the number |
| 393 |
;; of quadwords in an SME vector. |
| 394 |
UNSPEC_SME_VQ |
| 395 |
]) |
| 396 |
|
| 397 |
(define_c_enum "unspecv" [ |
| 398 |
UNSPECV_EH_RETURN ; Represent EH_RETURN |
| 399 |
UNSPECV_GET_FPCR ; Represent fetch of FPCR content. |
| 400 |
UNSPECV_SET_FPCR ; Represent assign of FPCR content. |
| 401 |
UNSPECV_GET_FPSR ; Represent fetch of FPSR content. |
| 402 |
UNSPECV_SET_FPSR ; Represent assign of FPSR content. |
| 403 |
UNSPECV_BLOCKAGE ; Represent a blockage |
| 404 |
UNSPECV_PROBE_STACK_RANGE ; Represent stack range probing. |
| 405 |
UNSPECV_SPECULATION_BARRIER ; Represent speculation barrier. |
| 406 |
UNSPECV_BTI_NOARG ; Represent BTI. |
| 407 |
UNSPECV_BTI_C ; Represent BTI c. |
| 408 |
UNSPECV_BTI_J ; Represent BTI j. |
| 409 |
UNSPECV_BTI_JC ; Represent BTI jc. |
| 410 |
UNSPECV_CHKFEAT ; Represent CHKFEAT X16. |
| 411 |
UNSPECV_GCSPR ; Represent MRS Xn, GCSPR_EL0 |
| 412 |
UNSPECV_GCSPOPM ; Represent GCSPOPM. |
| 413 |
UNSPECV_GCSSS1 ; Represent GCSSS1 Xt. |
| 414 |
UNSPECV_GCSSS2 ; Represent GCSSS2 Xt. |
| 415 |
UNSPECV_TSTART ; Represent transaction start. |
| 416 |
UNSPECV_TCOMMIT ; Represent transaction commit. |
| 417 |
UNSPECV_TCANCEL ; Represent transaction cancel. |
| 418 |
UNSPEC_RNDR ; Represent RNDR |
| 419 |
UNSPEC_RNDRRS ; Represent RNDRRS |
| 420 |
] |
| 421 |
) |
| 422 |
|
| 423 |
;; These constants are used as a const_int in various SVE unspecs |
| 424 |
;; to indicate whether the governing predicate is known to be a PTRUE. |
| 425 |
(define_constants |
| 426 |
[; Indicates that the predicate might not be a PTRUE. |
| 427 |
(SVE_MAYBE_NOT_PTRUE 0) |
| 428 |
|
| 429 |
; Indicates that the predicate is known to be a PTRUE. |
| 430 |
(SVE_KNOWN_PTRUE 1)]) |
| 431 |
|
| 432 |
;; These constants are used as a const_int in predicated SVE FP arithmetic |
| 433 |
;; to indicate whether the operation is allowed to make additional lanes |
| 434 |
;; active without worrying about the effect on faulting behavior. |
| 435 |
(define_constants |
| 436 |
[; Indicates either that all lanes are active or that the instruction may |
| 437 |
; operate on inactive inputs even if doing so could induce a fault. |
| 438 |
(SVE_RELAXED_GP 0) |
| 439 |
|
| 440 |
; Indicates that some lanes might be inactive and that the instruction |
| 441 |
; must not operate on inactive inputs if doing so could induce a fault. |
| 442 |
(SVE_STRICT_GP 1)]) |
| 443 |
|
| 444 |
(include "constraints.md") |
| 445 |
(include "predicates.md") |
| 446 |
(include "iterators.md") |
| 447 |
|
| 448 |
;; ------------------------------------------------------------------- |
| 449 |
;; Instruction types and attributes |
| 450 |
;; ------------------------------------------------------------------- |
| 451 |
|
| 452 |
; The "type" attribute is included here from AArch32 backend to be able |
| 453 |
; to share pipeline descriptions. |
| 454 |
(include "../arm/types.md") |
| 455 |
|
| 456 |
;; It is important to set the fp or simd attributes to yes when a pattern |
| 457 |
;; alternative uses the FP or SIMD register files, usually signified by use of |
| 458 |
;; the 'w' constraint. This will ensure that the alternative will be |
| 459 |
;; disabled when compiling with -mgeneral-regs-only or with the +nofp/+nosimd |
| 460 |
;; architecture extensions. If all the alternatives in a pattern use the |
| 461 |
;; FP or SIMD registers then the pattern predicate should include TARGET_FLOAT |
| 462 |
;; or TARGET_SIMD. |
| 463 |
|
| 464 |
;; Attributes of the architecture required to support the instruction (or |
| 465 |
;; alternative). This attribute is used to compute attribute "enabled", use type |
| 466 |
;; "any" to enable an alternative in all cases. |
| 467 |
;; |
| 468 |
;; As a convenience, "fp_q" means "fp" + the ability to move between |
| 469 |
;; Q registers and is equivalent to "simd". |
| 470 |
|
| 471 |
(define_enum "arches" [any rcpc8_4 fp fp_q base_simd nobase_simd |
| 472 |
simd nosimd sve fp16 sme]) |
| 473 |
|
| 474 |
(define_enum_attr "arch" "arches" (const_string "any")) |
| 475 |
|
| 476 |
;; Whether a normal INSN in fact contains a call. Sometimes we represent |
| 477 |
;; calls to functions that use an ad-hoc ABI as normal insns, both for |
| 478 |
;; optimization reasons and to avoid the need to describe the ABI to |
| 479 |
;; target-independent code. |
| 480 |
(define_attr "is_call" "no,yes" (const_string "no")) |
| 481 |
|
| 482 |
;; Indicates whether we want to enable the pattern with an optional early |
| 483 |
;; clobber for SVE predicates. |
| 484 |
(define_attr "pred_clobber" "any,no,yes" (const_string "any")) |
| 485 |
|
| 486 |
;; [For compatibility with Arm in pipeline models] |
| 487 |
;; Attribute that specifies whether or not the instruction touches fp |
| 488 |
;; registers. |
| 489 |
;; Note that this attribute is not used anywhere in either the arm or aarch64 |
| 490 |
;; backends except in the scheduling description for xgene1. In that |
| 491 |
;; scheduling description this attribute is used to subclass the load_4 and |
| 492 |
;; load_8 types. |
| 493 |
(define_attr "fp" "no,yes" |
| 494 |
(if_then_else |
| 495 |
(eq_attr "arch" "fp") |
| 496 |
(const_string "yes") |
| 497 |
(const_string "no"))) |
| 498 |
|
| 499 |
(define_attr "arch_enabled" "no,yes" |
| 500 |
(if_then_else |
| 501 |
(and |
| 502 |
(ior |
| 503 |
(and |
| 504 |
(eq_attr "pred_clobber" "no") |
| 505 |
(match_test "!TARGET_SVE_PRED_CLOBBER")) |
| 506 |
(and |
| 507 |
(eq_attr "pred_clobber" "yes") |
| 508 |
(match_test "TARGET_SVE_PRED_CLOBBER")) |
| 509 |
(eq_attr "pred_clobber" "any")) |
| 510 |
|
| 511 |
(ior |
| 512 |
(eq_attr "arch" "any") |
| 513 |
|
| 514 |
(and (eq_attr "arch" "rcpc8_4") |
| 515 |
(match_test "TARGET_RCPC2")) |
| 516 |
|
| 517 |
(and (eq_attr "arch" "fp") |
| 518 |
(match_test "TARGET_FLOAT")) |
| 519 |
|
| 520 |
(and (eq_attr "arch" "base_simd") |
| 521 |
(match_test "TARGET_BASE_SIMD")) |
| 522 |
|
| 523 |
(and (eq_attr "arch" "nobase_simd") |
| 524 |
(match_test "!TARGET_BASE_SIMD")) |
| 525 |
|
| 526 |
(and (eq_attr "arch" "fp_q, simd") |
| 527 |
(match_test "TARGET_SIMD")) |
| 528 |
|
| 529 |
(and (eq_attr "arch" "nosimd") |
| 530 |
(match_test "!TARGET_SIMD")) |
| 531 |
|
| 532 |
(and (eq_attr "arch" "fp16") |
| 533 |
(match_test "TARGET_FP_F16INST")) |
| 534 |
|
| 535 |
(and (eq_attr "arch" "sve") |
| 536 |
(match_test "TARGET_SVE")) |
| 537 |
|
| 538 |
(and (eq_attr "arch" "sme") |
| 539 |
(match_test "TARGET_SME")))) |
| 540 |
(const_string "yes") |
| 541 |
(const_string "no"))) |
| 542 |
|
| 543 |
;; True if this a bfloat16 operation. Only used for certain instructions. |
| 544 |
(define_attr "is_bf16" "false,true" (const_string "false")) |
| 545 |
|
| 546 |
;; True if this alternative uses an SVE instruction in which the operands |
| 547 |
;; are reversed. This can happen for naturally commutative operations |
| 548 |
;; such as FADD, or when using things like FSUBR in preference to FSUB, |
| 549 |
;; or similarly when using things like FMAD in preference to FMLA. |
| 550 |
(define_attr "is_rev" "false,true" (const_string "false")) |
| 551 |
|
| 552 |
;; True if this operation supports is_rev-style instructions for bfloat16. |
| 553 |
(define_attr "supports_bf16_rev" "false,true" (const_string "false")) |
| 554 |
|
| 555 |
;; Selectively enable alternatives based on the mode of the operation. |
| 556 |
(define_attr "mode_enabled" "false,true" |
| 557 |
(cond [(and (eq_attr "is_bf16" "true") |
| 558 |
(eq_attr "is_rev" "true") |
| 559 |
(eq_attr "supports_bf16_rev" "false")) |
| 560 |
(const_string "false")] |
| 561 |
(const_string "true"))) |
| 562 |
|
| 563 |
;; Attribute that controls whether an alternative is enabled or not. |
| 564 |
(define_attr "enabled" "no,yes" |
| 565 |
(if_then_else (and (eq_attr "arch_enabled" "yes") |
| 566 |
(eq_attr "mode_enabled" "true")) |
| 567 |
(const_string "yes") |
| 568 |
(const_string "no"))) |
| 569 |
|
| 570 |
;; Attribute that specifies whether we are dealing with a branch to a |
| 571 |
;; label that is far away, i.e. further away than the maximum/minimum |
| 572 |
;; representable in a signed 21-bits number. |
| 573 |
;; 0 :=: no |
| 574 |
;; 1 :=: yes |
| 575 |
(define_attr "far_branch" "" (const_int 0)) |
| 576 |
|
| 577 |
;; Attribute that specifies whether the alternative uses MOVPRFX. |
| 578 |
(define_attr "movprfx" "no,yes" (const_string "no")) |
| 579 |
|
| 580 |
;; Attribute to specify that an alternative has the length of a single |
| 581 |
;; instruction plus a speculation barrier. |
| 582 |
(define_attr "sls_length" "none,retbr,casesi" (const_string "none")) |
| 583 |
|
| 584 |
(define_attr "length" "" |
| 585 |
(cond [(eq_attr "movprfx" "yes") |
| 586 |
(const_int 8) |
| 587 |
|
| 588 |
(eq_attr "sls_length" "retbr") |
| 589 |
(cond [(match_test "!aarch64_harden_sls_retbr_p ()") (const_int 4) |
| 590 |
(match_test "TARGET_SB") (const_int 8)] |
| 591 |
(const_int 12)) |
| 592 |
|
| 593 |
(eq_attr "sls_length" "casesi") |
| 594 |
(cond [(match_test "!aarch64_harden_sls_retbr_p ()") (const_int 16) |
| 595 |
(match_test "TARGET_SB") (const_int 20)] |
| 596 |
(const_int 24)) |
| 597 |
] |
| 598 |
(const_int 4))) |
| 599 |
|
| 600 |
;; Strictly for compatibility with AArch32 in pipeline models, since AArch64 has |
| 601 |
;; no predicated insns. |
| 602 |
(define_attr "predicated" "yes,no" (const_string "no")) |
| 603 |
|
| 604 |
;; Set to true on an insn that requires the speculation tracking state to be |
| 605 |
;; in the tracking register before the insn issues. Otherwise the compiler |
| 606 |
;; may chose to hold the tracking state encoded in SP. |
| 607 |
(define_attr "speculation_barrier" "true,false" (const_string "false")) |
| 608 |
|
| 609 |
;; This attribute is attached to multi-register instructions that have |
| 610 |
;; two forms: one in which the registers are consecutive and one in |
| 611 |
;; which they are strided. The consecutive and strided forms have |
| 612 |
;; different define_insns, with different operands. The mapping between |
| 613 |
;; the RTL of the consecutive form and the RTL of the strided form varies |
| 614 |
;; from one type of instruction to another. |
| 615 |
;; |
| 616 |
;; The attribute gives two pieces of information: |
| 617 |
;; - does the current instruction have consecutive or strided registers? |
| 618 |
;; - what kind of RTL rewrite is needed to move between forms? |
| 619 |
;; |
| 620 |
;; For example, all consecutive LD*1 instructions have the same basic |
| 621 |
;; RTL structure. The same applies to all strided LD*1 instructions. |
| 622 |
;; The RTL mapping therefore applies at LD1 granularity, rather than |
| 623 |
;; being broken down into individual types of load. |
| 624 |
(define_attr "stride_type" |
| 625 |
"none,ld1_consecutive,ld1_strided,st1_consecutive,st1_strided" |
| 626 |
(const_string "none")) |
| 627 |
|
| 628 |
;; Attribute used to identify load pair and store pair instructions. |
| 629 |
;; Currently the attribute is only applied to the non-writeback ldp/stp |
| 630 |
;; patterns. |
| 631 |
(define_attr "ldpstp" "ldp,stp,none" (const_string "none")) |
| 632 |
|
| 633 |
;; ------------------------------------------------------------------- |
| 634 |
;; Pipeline descriptions and scheduling |
| 635 |
;; ------------------------------------------------------------------- |
| 636 |
|
| 637 |
;; Processor types. |
| 638 |
(include "aarch64-tune.md") |
| 639 |
|
| 640 |
;; Scheduling |
| 641 |
(include "../arm/cortex-a53.md") |
| 642 |
(include "../arm/cortex-a57.md") |
| 643 |
(include "../arm/exynos-m1.md") |
| 644 |
(include "thunderx.md") |
| 645 |
(include "../arm/xgene1.md") |
| 646 |
(include "thunderx2t99.md") |
| 647 |
(include "tsv110.md") |
| 648 |
(include "thunderx3t110.md") |
| 649 |
|
| 650 |
;; ------------------------------------------------------------------- |
| 651 |
;; Jumps and other miscellaneous insns |
| 652 |
;; ------------------------------------------------------------------- |
| 653 |
|
| 654 |
(define_insn "aarch64_read_sysregdi" |
| 655 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 656 |
(unspec_volatile:DI [(match_operand 1 "aarch64_sysreg_string" "")] |
| 657 |
UNSPEC_SYSREG_RDI))] |
| 658 |
"" |
| 659 |
"mrs\t%x0, %1" |
| 660 |
) |
| 661 |
|
| 662 |
(define_insn "aarch64_read_sysregti" |
| 663 |
[(set (match_operand:TI 0 "register_operand" "=r") |
| 664 |
(unspec_volatile:TI [(match_operand 1 "aarch64_sysreg_string" "")] |
| 665 |
UNSPEC_SYSREG_RTI))] |
| 666 |
"TARGET_D128" |
| 667 |
"mrrs\t%x0, %H0, %x1" |
| 668 |
) |
| 669 |
|
| 670 |
(define_insn "aarch64_write_sysregdi" |
| 671 |
[(unspec_volatile:DI [(match_operand 0 "aarch64_sysreg_string" "") |
| 672 |
(match_operand:DI 1 "aarch64_reg_or_zero" "rZ")] |
| 673 |
UNSPEC_SYSREG_WDI)] |
| 674 |
"" |
| 675 |
"msr\t%0, %x1" |
| 676 |
) |
| 677 |
|
| 678 |
(define_insn "aarch64_write_sysregti" |
| 679 |
[(unspec_volatile:TI [(match_operand 0 "aarch64_sysreg_string" "") |
| 680 |
(match_operand:TI 1 "register_operand" "r")] |
| 681 |
UNSPEC_SYSREG_WTI)] |
| 682 |
"TARGET_D128" |
| 683 |
"msrr\t%x0, %x1, %H1" |
| 684 |
) |
| 685 |
|
| 686 |
(define_insn "indirect_jump" |
| 687 |
[(set (pc) (match_operand:DI 0 "register_operand" "r"))] |
| 688 |
"" |
| 689 |
{ |
| 690 |
output_asm_insn ("br\\t%0", operands); |
| 691 |
return aarch64_sls_barrier (aarch64_harden_sls_retbr_p ()); |
| 692 |
} |
| 693 |
[(set_attr "type" "branch") |
| 694 |
(set_attr "sls_length" "retbr")] |
| 695 |
) |
| 696 |
|
| 697 |
(define_insn "jump" |
| 698 |
[(set (pc) (label_ref (match_operand 0 "" "")))] |
| 699 |
"" |
| 700 |
"b\\t%l0" |
| 701 |
[(set_attr "type" "branch")] |
| 702 |
) |
| 703 |
|
| 704 |
(define_expand "cbranch<mode>4" |
| 705 |
[(set (pc) (if_then_else (match_operator 0 "aarch64_comparison_operator" |
| 706 |
[(match_operand:GPI 1 "register_operand") |
| 707 |
(match_operand:GPI 2 "aarch64_plus_operand")]) |
| 708 |
(label_ref (match_operand 3 "" "")) |
| 709 |
(pc)))] |
| 710 |
"" |
| 711 |
" |
| 712 |
operands[1] = aarch64_gen_compare_reg (GET_CODE (operands[0]), operands[1], |
| 713 |
operands[2]); |
| 714 |
operands[2] = const0_rtx; |
| 715 |
" |
| 716 |
) |
| 717 |
|
| 718 |
(define_expand "cbranch<mode>4" |
| 719 |
[(set (pc) (if_then_else (match_operator 0 "aarch64_comparison_operator" |
| 720 |
[(match_operand:GPF 1 "register_operand") |
| 721 |
(match_operand:GPF 2 "aarch64_fp_compare_operand")]) |
| 722 |
(label_ref (match_operand 3 "" "")) |
| 723 |
(pc)))] |
| 724 |
"" |
| 725 |
" |
| 726 |
operands[1] = aarch64_gen_compare_reg (GET_CODE (operands[0]), operands[1], |
| 727 |
operands[2]); |
| 728 |
operands[2] = const0_rtx; |
| 729 |
" |
| 730 |
) |
| 731 |
|
| 732 |
(define_expand "cbranchcc4" |
| 733 |
[(set (pc) (if_then_else |
| 734 |
(match_operator 0 "aarch64_comparison_operator" |
| 735 |
[(match_operand 1 "cc_register") |
| 736 |
(match_operand 2 "const0_operand")]) |
| 737 |
(label_ref (match_operand 3 "" "")) |
| 738 |
(pc)))] |
| 739 |
"" |
| 740 |
"") |
| 741 |
|
| 742 |
(define_insn "@ccmp<CC_ONLY:mode><GPI:mode>" |
| 743 |
[(set (match_operand:CC_ONLY 1 "cc_register") |
| 744 |
(if_then_else:CC_ONLY |
| 745 |
(match_operator 4 "aarch64_comparison_operator" |
| 746 |
[(match_operand 0 "cc_register") |
| 747 |
(const_int 0)]) |
| 748 |
(compare:CC_ONLY |
| 749 |
(match_operand:GPI 2 "register_operand") |
| 750 |
(match_operand:GPI 3 "aarch64_ccmp_operand")) |
| 751 |
(unspec:CC_ONLY |
| 752 |
[(match_operand 5 "immediate_operand")] |
| 753 |
UNSPEC_NZCV)))] |
| 754 |
"" |
| 755 |
{@ [ cons: 2 , 3 ; attrs: type ] |
| 756 |
[ r , r ; alus_sreg ] ccmp\t%<w>2, %<w>3, %k5, %m4 |
| 757 |
[ r , Uss ; alus_imm ] ccmp\t%<w>2, %3, %k5, %m4 |
| 758 |
[ r , Usn ; alus_imm ] ccmn\t%<w>2, #%n3, %k5, %m4 |
| 759 |
} |
| 760 |
) |
| 761 |
|
| 762 |
(define_insn "@ccmp<CCFP_CCFPE:mode><GPF:mode>" |
| 763 |
[(set (match_operand:CCFP_CCFPE 1 "cc_register" "") |
| 764 |
(if_then_else:CCFP_CCFPE |
| 765 |
(match_operator 4 "aarch64_comparison_operator" |
| 766 |
[(match_operand 0 "cc_register" "") |
| 767 |
(const_int 0)]) |
| 768 |
(compare:CCFP_CCFPE |
| 769 |
(match_operand:GPF 2 "register_operand" "w") |
| 770 |
(match_operand:GPF 3 "register_operand" "w")) |
| 771 |
(unspec:CCFP_CCFPE |
| 772 |
[(match_operand 5 "immediate_operand")] |
| 773 |
UNSPEC_NZCV)))] |
| 774 |
"TARGET_FLOAT" |
| 775 |
"fccmp<e>\\t%<s>2, %<s>3, %k5, %m4" |
| 776 |
[(set_attr "type" "fccmp<s>")] |
| 777 |
) |
| 778 |
|
| 779 |
(define_insn "@ccmp<CC_ONLY:mode><GPI:mode>_rev" |
| 780 |
[(set (match_operand:CC_ONLY 1 "cc_register") |
| 781 |
(if_then_else:CC_ONLY |
| 782 |
(match_operator 4 "aarch64_comparison_operator" |
| 783 |
[(match_operand 0 "cc_register") |
| 784 |
(const_int 0)]) |
| 785 |
(unspec:CC_ONLY |
| 786 |
[(match_operand 5 "immediate_operand")] |
| 787 |
UNSPEC_NZCV) |
| 788 |
(compare:CC_ONLY |
| 789 |
(match_operand:GPI 2 "register_operand") |
| 790 |
(match_operand:GPI 3 "aarch64_ccmp_operand"))))] |
| 791 |
"" |
| 792 |
{@ [ cons: 2 , 3 ; attrs: type ] |
| 793 |
[ r , r ; alus_sreg ] ccmp\t%<w>2, %<w>3, %k5, %M4 |
| 794 |
[ r , Uss ; alus_imm ] ccmp\t%<w>2, %3, %k5, %M4 |
| 795 |
[ r , Usn ; alus_imm ] ccmn\t%<w>2, #%n3, %k5, %M4 |
| 796 |
} |
| 797 |
) |
| 798 |
|
| 799 |
(define_insn "@ccmp<CCFP_CCFPE:mode><GPF:mode>_rev" |
| 800 |
[(set (match_operand:CCFP_CCFPE 1 "cc_register" "") |
| 801 |
(if_then_else:CCFP_CCFPE |
| 802 |
(match_operator 4 "aarch64_comparison_operator" |
| 803 |
[(match_operand 0 "cc_register" "") |
| 804 |
(const_int 0)]) |
| 805 |
(unspec:CCFP_CCFPE |
| 806 |
[(match_operand 5 "immediate_operand")] |
| 807 |
UNSPEC_NZCV) |
| 808 |
(compare:CCFP_CCFPE |
| 809 |
(match_operand:GPF 2 "register_operand" "w") |
| 810 |
(match_operand:GPF 3 "register_operand" "w"))))] |
| 811 |
"TARGET_FLOAT" |
| 812 |
"fccmp<e>\\t%<s>2, %<s>3, %k5, %M4" |
| 813 |
[(set_attr "type" "fccmp<s>")] |
| 814 |
) |
| 815 |
|
| 816 |
;; Expansion of signed mod by a power of 2 using CSNEG. |
| 817 |
;; For x0 % n where n is a power of 2 produce: |
| 818 |
;; negs x1, x0 |
| 819 |
;; and x0, x0, #(n - 1) |
| 820 |
;; and x1, x1, #(n - 1) |
| 821 |
;; csneg x0, x0, x1, mi |
| 822 |
|
| 823 |
(define_expand "mod<mode>3" |
| 824 |
[(match_operand:GPI 0 "register_operand") |
| 825 |
(match_operand:GPI 1 "register_operand") |
| 826 |
(match_operand:GPI 2 "const_int_operand")] |
| 827 |
"" |
| 828 |
{ |
| 829 |
HOST_WIDE_INT val = INTVAL (operands[2]); |
| 830 |
|
| 831 |
if (val <= 0 |
| 832 |
|| exact_log2 (val) <= 0 |
| 833 |
|| !aarch64_bitmask_imm (val - 1, <MODE>mode)) |
| 834 |
FAIL; |
| 835 |
|
| 836 |
rtx mask = GEN_INT (val - 1); |
| 837 |
|
| 838 |
/* In the special case of x0 % 2 we can do the even shorter: |
| 839 |
cmp x0, xzr |
| 840 |
and x0, x0, 1 |
| 841 |
cneg x0, x0, lt. */ |
| 842 |
if (val == 2) |
| 843 |
{ |
| 844 |
rtx masked = gen_reg_rtx (<MODE>mode); |
| 845 |
rtx ccreg = aarch64_gen_compare_reg (LT, operands[1], const0_rtx); |
| 846 |
emit_insn (gen_and<mode>3 (masked, operands[1], mask)); |
| 847 |
rtx x = gen_rtx_LT (VOIDmode, ccreg, const0_rtx); |
| 848 |
emit_insn (gen_csneg3<mode>_insn (operands[0], x, masked, masked)); |
| 849 |
DONE; |
| 850 |
} |
| 851 |
|
| 852 |
rtx neg_op = gen_reg_rtx (<MODE>mode); |
| 853 |
rtx_insn *insn = emit_insn (gen_neg<mode>2_compare0 (neg_op, operands[1])); |
| 854 |
|
| 855 |
/* Extract the condition register and mode. */ |
| 856 |
rtx cmp = XVECEXP (PATTERN (insn), 0, 0); |
| 857 |
rtx cc_reg = SET_DEST (cmp); |
| 858 |
rtx cond = gen_rtx_GE (VOIDmode, cc_reg, const0_rtx); |
| 859 |
|
| 860 |
rtx masked_pos = gen_reg_rtx (<MODE>mode); |
| 861 |
emit_insn (gen_and<mode>3 (masked_pos, operands[1], mask)); |
| 862 |
|
| 863 |
rtx masked_neg = gen_reg_rtx (<MODE>mode); |
| 864 |
emit_insn (gen_and<mode>3 (masked_neg, neg_op, mask)); |
| 865 |
|
| 866 |
emit_insn (gen_csneg3<mode>_insn (operands[0], cond, |
| 867 |
masked_neg, masked_pos)); |
| 868 |
DONE; |
| 869 |
} |
| 870 |
) |
| 871 |
|
| 872 |
(define_insn "condjump" |
| 873 |
[(set (pc) (if_then_else (match_operator 0 "aarch64_comparison_operator" |
| 874 |
[(match_operand 1 "cc_register" "") (const_int 0)]) |
| 875 |
(label_ref (match_operand 2 "" "")) |
| 876 |
(pc)))] |
| 877 |
"" |
| 878 |
{ |
| 879 |
/* GCC's traditional style has been to use "beq" instead of "b.eq", etc., |
| 880 |
but the "." is required for SVE conditions. */ |
| 881 |
bool use_dot_p = GET_MODE (operands[1]) == CC_NZCmode; |
| 882 |
if (get_attr_length (insn) == 8) |
| 883 |
return aarch64_gen_far_branch (operands, 2, "Lbcond", |
| 884 |
use_dot_p ? "b.%M0\\t" : "b%M0\\t"); |
| 885 |
else |
| 886 |
return use_dot_p ? "b.%m0\\t%l2" : "b%m0\\t%l2"; |
| 887 |
} |
| 888 |
[(set_attr "type" "branch") |
| 889 |
(set (attr "length") |
| 890 |
(if_then_else (and (ge (minus (match_dup 2) (pc)) (const_int -1048576)) |
| 891 |
(lt (minus (match_dup 2) (pc)) (const_int 1048572))) |
| 892 |
(const_int 4) |
| 893 |
(const_int 8))) |
| 894 |
(set (attr "far_branch") |
| 895 |
(if_then_else (and (ge (minus (match_dup 2) (pc)) (const_int -1048576)) |
| 896 |
(lt (minus (match_dup 2) (pc)) (const_int 1048572))) |
| 897 |
(const_int 0) |
| 898 |
(const_int 1)))] |
| 899 |
) |
| 900 |
|
| 901 |
;; For a 24-bit immediate CST we can optimize the compare for equality |
| 902 |
;; and branch sequence from: |
| 903 |
;; mov x0, #imm1 |
| 904 |
;; movk x0, #imm2, lsl 16 /* x0 contains CST. */ |
| 905 |
;; cmp x1, x0 |
| 906 |
;; b<ne,eq> .Label |
| 907 |
;; into the shorter: |
| 908 |
;; sub x0, x1, #(CST & 0xfff000) |
| 909 |
;; subs x0, x0, #(CST & 0x000fff) |
| 910 |
;; b<ne,eq> .Label |
| 911 |
(define_insn_and_split "*compare_condjump<GPI:mode>" |
| 912 |
[(set (pc) (if_then_else (EQL |
| 913 |
(match_operand:GPI 0 "register_operand" "r") |
| 914 |
(match_operand:GPI 1 "aarch64_imm24" "n")) |
| 915 |
(label_ref:P (match_operand 2 "" "")) |
| 916 |
(pc)))] |
| 917 |
"!aarch64_move_imm (INTVAL (operands[1]), <GPI:MODE>mode) |
| 918 |
&& !aarch64_plus_operand (operands[1], <GPI:MODE>mode) |
| 919 |
&& !reload_completed" |
| 920 |
"#" |
| 921 |
"&& true" |
| 922 |
[(const_int 0)] |
| 923 |
{ |
| 924 |
HOST_WIDE_INT lo_imm = UINTVAL (operands[1]) & 0xfff; |
| 925 |
HOST_WIDE_INT hi_imm = UINTVAL (operands[1]) & 0xfff000; |
| 926 |
rtx tmp = gen_reg_rtx (<GPI:MODE>mode); |
| 927 |
emit_insn (gen_add<GPI:mode>3 (tmp, operands[0], GEN_INT (-hi_imm))); |
| 928 |
emit_insn (gen_add<GPI:mode>3_compare0 (tmp, tmp, GEN_INT (-lo_imm))); |
| 929 |
rtx cc_reg = gen_rtx_REG (CC_NZmode, CC_REGNUM); |
| 930 |
rtx cmp_rtx = gen_rtx_fmt_ee (<EQL:CMP>, <GPI:MODE>mode, |
| 931 |
cc_reg, const0_rtx); |
| 932 |
emit_jump_insn (gen_condjump (cmp_rtx, cc_reg, operands[2])); |
| 933 |
DONE; |
| 934 |
} |
| 935 |
) |
| 936 |
|
| 937 |
(define_expand "casesi" |
| 938 |
[(match_operand:SI 0 "register_operand") ; Index |
| 939 |
(match_operand:SI 1 "const_int_operand") ; Lower bound |
| 940 |
(match_operand:SI 2 "const_int_operand") ; Total range |
| 941 |
(match_operand:DI 3 "" "") ; Table label |
| 942 |
(match_operand:DI 4 "" "")] ; Out of range label |
| 943 |
"" |
| 944 |
{ |
| 945 |
if (operands[1] != const0_rtx) |
| 946 |
{ |
| 947 |
rtx reg = gen_reg_rtx (SImode); |
| 948 |
|
| 949 |
/* Canonical RTL says that if you have: |
| 950 |
|
| 951 |
(minus (X) (CONST)) |
| 952 |
|
| 953 |
then this should be emitted as: |
| 954 |
|
| 955 |
(plus (X) (-CONST)) |
| 956 |
|
| 957 |
The use of trunc_int_for_mode ensures that the resulting |
| 958 |
constant can be represented in SImode, this is important |
| 959 |
for the corner case where operand[1] is INT_MIN. */ |
| 960 |
|
| 961 |
operands[1] |
| 962 |
= GEN_INT (trunc_int_for_mode (-UINTVAL (operands[1]), SImode)); |
| 963 |
|
| 964 |
if (!(*insn_data[CODE_FOR_addsi3].operand[2].predicate) |
| 965 |
(operands[1], SImode)) |
| 966 |
operands[1] = force_reg (SImode, operands[1]); |
| 967 |
emit_insn (gen_addsi3 (reg, operands[0], operands[1])); |
| 968 |
operands[0] = reg; |
| 969 |
} |
| 970 |
|
| 971 |
if (!aarch64_plus_operand (operands[2], SImode)) |
| 972 |
operands[2] = force_reg (SImode, operands[2]); |
| 973 |
emit_jump_insn (gen_cbranchsi4 (gen_rtx_GTU (SImode, const0_rtx, |
| 974 |
const0_rtx), |
| 975 |
operands[0], operands[2], operands[4])); |
| 976 |
|
| 977 |
operands[2] = force_reg (DImode, gen_rtx_LABEL_REF (DImode, operands[3])); |
| 978 |
operands[2] |
| 979 |
= gen_rtx_UNSPEC (Pmode, gen_rtvec (2, operands[2], operands[0]), |
| 980 |
UNSPEC_CASESI); |
| 981 |
operands[2] = gen_rtx_MEM (DImode, operands[2]); |
| 982 |
MEM_READONLY_P (operands[2]) = 1; |
| 983 |
MEM_NOTRAP_P (operands[2]) = 1; |
| 984 |
emit_jump_insn (gen_casesi_dispatch (operands[2], operands[3])); |
| 985 |
DONE; |
| 986 |
} |
| 987 |
) |
| 988 |
|
| 989 |
(define_expand "casesi_dispatch" |
| 990 |
[(parallel |
| 991 |
[(set (pc) (match_operand:DI 0 "")) |
| 992 |
(clobber (reg:CC CC_REGNUM)) |
| 993 |
(clobber (match_scratch:DI 2)) |
| 994 |
(clobber (match_scratch:DI 3)) |
| 995 |
(use (label_ref:DI (match_operand 1 "")))])] |
| 996 |
"") |
| 997 |
|
| 998 |
(define_insn "*casesi_dispatch" |
| 999 |
[(parallel |
| 1000 |
[(set (pc) |
| 1001 |
(mem:DI (unspec [(match_operand:DI 0 "register_operand" "r") |
| 1002 |
(match_operand:SI 1 "register_operand" "r")] |
| 1003 |
UNSPEC_CASESI))) |
| 1004 |
(clobber (reg:CC CC_REGNUM)) |
| 1005 |
(clobber (match_scratch:DI 3 "=r")) |
| 1006 |
(clobber (match_scratch:DI 4 "=r")) |
| 1007 |
(use (label_ref:DI (match_operand 2 "" "")))])] |
| 1008 |
"" |
| 1009 |
"* |
| 1010 |
return aarch64_output_casesi (operands); |
| 1011 |
" |
| 1012 |
[(set_attr "sls_length" "casesi") |
| 1013 |
(set_attr "type" "branch")] |
| 1014 |
) |
| 1015 |
|
| 1016 |
(define_insn "nop" |
| 1017 |
[(unspec[(const_int 0)] UNSPEC_NOP)] |
| 1018 |
"" |
| 1019 |
"nop" |
| 1020 |
[(set_attr "type" "no_insn")] |
| 1021 |
) |
| 1022 |
|
| 1023 |
(define_insn "prefetch" |
| 1024 |
[(prefetch (match_operand:DI 0 "aarch64_prefetch_operand" "Dp") |
| 1025 |
(match_operand:QI 1 "const_int_operand" "") |
| 1026 |
(match_operand:QI 2 "const_int_operand" ""))] |
| 1027 |
"" |
| 1028 |
{ |
| 1029 |
const char * pftype[2][4] = |
| 1030 |
{ |
| 1031 |
{"prfm\\tPLDL1STRM, %0", |
| 1032 |
"prfm\\tPLDL3KEEP, %0", |
| 1033 |
"prfm\\tPLDL2KEEP, %0", |
| 1034 |
"prfm\\tPLDL1KEEP, %0"}, |
| 1035 |
{"prfm\\tPSTL1STRM, %0", |
| 1036 |
"prfm\\tPSTL3KEEP, %0", |
| 1037 |
"prfm\\tPSTL2KEEP, %0", |
| 1038 |
"prfm\\tPSTL1KEEP, %0"}, |
| 1039 |
}; |
| 1040 |
|
| 1041 |
int locality = INTVAL (operands[2]); |
| 1042 |
|
| 1043 |
gcc_assert (IN_RANGE (locality, 0, 3)); |
| 1044 |
|
| 1045 |
/* PRFM accepts the same addresses as a 64-bit LDR so wrap |
| 1046 |
the address into a DImode MEM so that aarch64_print_operand knows |
| 1047 |
how to print it. */ |
| 1048 |
operands[0] = gen_rtx_MEM (DImode, operands[0]); |
| 1049 |
return pftype[INTVAL (operands[1]) & 1][locality]; |
| 1050 |
} |
| 1051 |
[(set_attr "type" "load_4")] |
| 1052 |
) |
| 1053 |
|
| 1054 |
(define_insn "aarch64_pldx" |
| 1055 |
[(unspec [(match_operand 0 "" "") |
| 1056 |
(match_operand:DI 1 "aarch64_prefetch_operand" "Dp")] UNSPEC_PLDX)] |
| 1057 |
"" |
| 1058 |
{ |
| 1059 |
operands[1] = gen_rtx_MEM (DImode, operands[1]); |
| 1060 |
return "prfm\\t%0, %1"; |
| 1061 |
} |
| 1062 |
[(set_attr "type" "load_4")] |
| 1063 |
) |
| 1064 |
|
| 1065 |
(define_insn "trap" |
| 1066 |
[(trap_if (const_int 1) (const_int 8))] |
| 1067 |
"" |
| 1068 |
"brk #1000" |
| 1069 |
[(set_attr "type" "trap")]) |
| 1070 |
|
| 1071 |
(define_expand "prologue" |
| 1072 |
[(clobber (const_int 0))] |
| 1073 |
"" |
| 1074 |
" |
| 1075 |
aarch64_expand_prologue (); |
| 1076 |
DONE; |
| 1077 |
" |
| 1078 |
) |
| 1079 |
|
| 1080 |
(define_expand "epilogue" |
| 1081 |
[(clobber (const_int 0))] |
| 1082 |
"" |
| 1083 |
" |
| 1084 |
aarch64_expand_epilogue (nullptr); |
| 1085 |
DONE; |
| 1086 |
" |
| 1087 |
) |
| 1088 |
|
| 1089 |
(define_insn "*do_return" |
| 1090 |
[(return)] |
| 1091 |
"" |
| 1092 |
{ |
| 1093 |
const char *ret = NULL; |
| 1094 |
if (aarch64_return_address_signing_enabled () |
| 1095 |
&& (TARGET_PAUTH)) |
| 1096 |
{ |
| 1097 |
if (aarch64_ra_sign_key == AARCH64_KEY_B) |
| 1098 |
ret = "retab"; |
| 1099 |
else |
| 1100 |
ret = "retaa"; |
| 1101 |
} |
| 1102 |
else |
| 1103 |
ret = "ret"; |
| 1104 |
output_asm_insn (ret, operands); |
| 1105 |
return aarch64_sls_barrier (aarch64_harden_sls_retbr_p ()); |
| 1106 |
} |
| 1107 |
[(set_attr "type" "branch") |
| 1108 |
(set_attr "sls_length" "retbr")] |
| 1109 |
) |
| 1110 |
|
| 1111 |
(define_expand "return" |
| 1112 |
[(simple_return)] |
| 1113 |
"aarch64_use_return_insn_p ()" |
| 1114 |
"" |
| 1115 |
) |
| 1116 |
|
| 1117 |
(define_insn "simple_return" |
| 1118 |
[(simple_return)] |
| 1119 |
"aarch64_use_simple_return_insn_p ()" |
| 1120 |
{ |
| 1121 |
output_asm_insn ("ret", operands); |
| 1122 |
return aarch64_sls_barrier (aarch64_harden_sls_retbr_p ()); |
| 1123 |
} |
| 1124 |
[(set_attr "type" "branch") |
| 1125 |
(set_attr "sls_length" "retbr")] |
| 1126 |
) |
| 1127 |
|
| 1128 |
(define_insn "aarch64_cb<optab><mode>1" |
| 1129 |
[(set (pc) (if_then_else (EQL (match_operand:GPI 0 "register_operand" "r") |
| 1130 |
(const_int 0)) |
| 1131 |
(label_ref (match_operand 1 "" "")) |
| 1132 |
(pc)))] |
| 1133 |
"!aarch64_track_speculation" |
| 1134 |
{ |
| 1135 |
if (get_attr_length (insn) == 8) |
| 1136 |
return aarch64_gen_far_branch (operands, 1, "Lcb", "<inv_cb>\\t%<w>0, "); |
| 1137 |
else |
| 1138 |
return "<cbz>\\t%<w>0, %l1"; |
| 1139 |
} |
| 1140 |
[(set_attr "type" "branch") |
| 1141 |
(set (attr "length") |
| 1142 |
(if_then_else (and (ge (minus (match_dup 1) (pc)) (const_int -1048576)) |
| 1143 |
(lt (minus (match_dup 1) (pc)) (const_int 1048572))) |
| 1144 |
(const_int 4) |
| 1145 |
(const_int 8))) |
| 1146 |
(set (attr "far_branch") |
| 1147 |
(if_then_else (and (ge (minus (match_dup 2) (pc)) (const_int -1048576)) |
| 1148 |
(lt (minus (match_dup 2) (pc)) (const_int 1048572))) |
| 1149 |
(const_int 0) |
| 1150 |
(const_int 1)))] |
| 1151 |
) |
| 1152 |
|
| 1153 |
(define_expand "tbranch_<code><mode>3" |
| 1154 |
[(set (pc) (if_then_else |
| 1155 |
(EQL (match_operand:SHORT 0 "register_operand") |
| 1156 |
(match_operand 1 "const0_operand")) |
| 1157 |
(label_ref (match_operand 2 "")) |
| 1158 |
(pc)))] |
| 1159 |
"" |
| 1160 |
{ |
| 1161 |
rtx bitvalue = gen_reg_rtx (<ZEROM>mode); |
| 1162 |
rtx reg = gen_lowpart (<ZEROM>mode, operands[0]); |
| 1163 |
rtx val = gen_int_mode (HOST_WIDE_INT_1U << UINTVAL (operands[1]), <MODE>mode); |
| 1164 |
emit_insn (gen_and<zerom>3 (bitvalue, reg, val)); |
| 1165 |
operands[1] = const0_rtx; |
| 1166 |
operands[0] = aarch64_gen_compare_reg (<CODE>, bitvalue, |
| 1167 |
operands[1]); |
| 1168 |
}) |
| 1169 |
|
| 1170 |
(define_insn "@aarch64_tb<optab><ALLI:mode><GPI:mode>" |
| 1171 |
[(set (pc) (if_then_else |
| 1172 |
(EQL (zero_extract:GPI (match_operand:ALLI 0 "register_operand" "r") |
| 1173 |
(const_int 1) |
| 1174 |
(match_operand 1 |
| 1175 |
"aarch64_simd_shift_imm_<ALLI:mode>" "n")) |
| 1176 |
(const_int 0)) |
| 1177 |
(label_ref (match_operand 2 "" "")) |
| 1178 |
(pc))) |
| 1179 |
(clobber (reg:CC CC_REGNUM))] |
| 1180 |
"!aarch64_track_speculation" |
| 1181 |
{ |
| 1182 |
if (get_attr_length (insn) == 8) |
| 1183 |
{ |
| 1184 |
if (get_attr_far_branch (insn) == 1) |
| 1185 |
return aarch64_gen_far_branch (operands, 2, "Ltb", |
| 1186 |
"<inv_tb>\\t%<ALLI:w>0, %1, "); |
| 1187 |
else |
| 1188 |
{ |
| 1189 |
operands[1] = GEN_INT (HOST_WIDE_INT_1U << UINTVAL (operands[1])); |
| 1190 |
return "tst\t%<ALLI:w>0, %1\;<bcond>\t%l2"; |
| 1191 |
} |
| 1192 |
} |
| 1193 |
else |
| 1194 |
return "<tbz>\t%<ALLI:w>0, %1, %l2"; |
| 1195 |
} |
| 1196 |
[(set_attr "type" "branch") |
| 1197 |
(set (attr "length") |
| 1198 |
(if_then_else (and (ge (minus (match_dup 2) (pc)) (const_int -32768)) |
| 1199 |
(lt (minus (match_dup 2) (pc)) (const_int 32764))) |
| 1200 |
(const_int 4) |
| 1201 |
(const_int 8))) |
| 1202 |
(set (attr "far_branch") |
| 1203 |
(if_then_else (and (ge (minus (match_dup 2) (pc)) (const_int -1048576)) |
| 1204 |
(lt (minus (match_dup 2) (pc)) (const_int 1048572))) |
| 1205 |
(const_int 0) |
| 1206 |
(const_int 1)))] |
| 1207 |
|
| 1208 |
) |
| 1209 |
|
| 1210 |
(define_insn "*cb<optab><mode>1" |
| 1211 |
[(set (pc) (if_then_else (LTGE (match_operand:ALLI 0 "register_operand" "r") |
| 1212 |
(const_int 0)) |
| 1213 |
(label_ref (match_operand 1 "" "")) |
| 1214 |
(pc))) |
| 1215 |
(clobber (reg:CC CC_REGNUM))] |
| 1216 |
"!aarch64_track_speculation" |
| 1217 |
{ |
| 1218 |
if (get_attr_length (insn) == 8) |
| 1219 |
{ |
| 1220 |
if (get_attr_far_branch (insn) == 1) |
| 1221 |
return aarch64_gen_far_branch (operands, 1, "Ltb", |
| 1222 |
"<inv_tb>\\t%<w>0, <sizem1>, "); |
| 1223 |
else |
| 1224 |
{ |
| 1225 |
char buf[64]; |
| 1226 |
uint64_t val = ((uint64_t) 1) |
| 1227 |
<< (GET_MODE_SIZE (<MODE>mode) * BITS_PER_UNIT - 1); |
| 1228 |
sprintf (buf, "tst\t%%<w>0, %" PRId64, val); |
| 1229 |
output_asm_insn (buf, operands); |
| 1230 |
return "<bcond>\t%l1"; |
| 1231 |
} |
| 1232 |
} |
| 1233 |
else |
| 1234 |
return "<tbz>\t%<w>0, <sizem1>, %l1"; |
| 1235 |
} |
| 1236 |
[(set_attr "type" "branch") |
| 1237 |
(set (attr "length") |
| 1238 |
(if_then_else (and (ge (minus (match_dup 1) (pc)) (const_int -32768)) |
| 1239 |
(lt (minus (match_dup 1) (pc)) (const_int 32764))) |
| 1240 |
(const_int 4) |
| 1241 |
(const_int 8))) |
| 1242 |
(set (attr "far_branch") |
| 1243 |
(if_then_else (and (ge (minus (match_dup 1) (pc)) (const_int -1048576)) |
| 1244 |
(lt (minus (match_dup 1) (pc)) (const_int 1048572))) |
| 1245 |
(const_int 0) |
| 1246 |
(const_int 1)))] |
| 1247 |
) |
| 1248 |
|
| 1249 |
(define_expand "save_stack_nonlocal" |
| 1250 |
[(set (match_operand 0 "memory_operand") |
| 1251 |
(match_operand 1 "register_operand"))] |
| 1252 |
"" |
| 1253 |
{ |
| 1254 |
rtx stack_slot = adjust_address (operands[0], Pmode, 0); |
| 1255 |
emit_move_insn (stack_slot, operands[1]); |
| 1256 |
|
| 1257 |
if (aarch64_gcs_enabled ()) |
| 1258 |
{ |
| 1259 |
/* Save GCS with code like |
| 1260 |
mov x16, 1 |
| 1261 |
chkfeat x16 |
| 1262 |
tbnz x16, 0, .L_done |
| 1263 |
mrs tmp, gcspr_el0 |
| 1264 |
str tmp, [%0, 8] |
| 1265 |
.L_done: */ |
| 1266 |
|
| 1267 |
rtx done_label = gen_label_rtx (); |
| 1268 |
rtx r16 = gen_rtx_REG (DImode, R16_REGNUM); |
| 1269 |
emit_move_insn (r16, const1_rtx); |
| 1270 |
emit_insn (gen_aarch64_chkfeat ()); |
| 1271 |
emit_insn (gen_tbranch_neqi3 (r16, const0_rtx, done_label)); |
| 1272 |
rtx gcs_slot = adjust_address (operands[0], Pmode, GET_MODE_SIZE (Pmode)); |
| 1273 |
rtx gcs = gen_reg_rtx (Pmode); |
| 1274 |
emit_insn (gen_aarch64_load_gcspr (gcs)); |
| 1275 |
emit_move_insn (gcs_slot, gcs); |
| 1276 |
emit_label (done_label); |
| 1277 |
} |
| 1278 |
DONE; |
| 1279 |
}) |
| 1280 |
|
| 1281 |
(define_expand "restore_stack_nonlocal" |
| 1282 |
[(set (match_operand 0 "register_operand" "") |
| 1283 |
(match_operand 1 "memory_operand" ""))] |
| 1284 |
"" |
| 1285 |
{ |
| 1286 |
rtx stack_slot = adjust_address (operands[1], Pmode, 0); |
| 1287 |
emit_move_insn (operands[0], stack_slot); |
| 1288 |
|
| 1289 |
if (aarch64_gcs_enabled ()) |
| 1290 |
{ |
| 1291 |
/* Restore GCS with code like |
| 1292 |
mov x16, 1 |
| 1293 |
chkfeat x16 |
| 1294 |
tbnz x16, 0, .L_done |
| 1295 |
ldr tmp1, [%1, 8] |
| 1296 |
mrs tmp2, gcspr_el0 |
| 1297 |
subs tmp2, tmp1, tmp2 |
| 1298 |
b.eq .L_done |
| 1299 |
.L_loop: |
| 1300 |
gcspopm |
| 1301 |
subs tmp2, tmp2, 8 |
| 1302 |
b.ne .L_loop |
| 1303 |
.L_done: */ |
| 1304 |
|
| 1305 |
rtx loop_label = gen_label_rtx (); |
| 1306 |
rtx done_label = gen_label_rtx (); |
| 1307 |
rtx r16 = gen_rtx_REG (DImode, R16_REGNUM); |
| 1308 |
emit_move_insn (r16, const1_rtx); |
| 1309 |
emit_insn (gen_aarch64_chkfeat ()); |
| 1310 |
emit_insn (gen_tbranch_neqi3 (r16, const0_rtx, done_label)); |
| 1311 |
rtx gcs_slot = adjust_address (operands[1], Pmode, GET_MODE_SIZE (Pmode)); |
| 1312 |
rtx gcs_old = gen_reg_rtx (Pmode); |
| 1313 |
emit_move_insn (gcs_old, gcs_slot); |
| 1314 |
rtx gcs_now = gen_reg_rtx (Pmode); |
| 1315 |
emit_insn (gen_aarch64_load_gcspr (gcs_now)); |
| 1316 |
emit_insn (gen_subdi3_compare1 (gcs_now, gcs_old, gcs_now)); |
| 1317 |
rtx cc_reg = gen_rtx_REG (CC_NZmode, CC_REGNUM); |
| 1318 |
rtx cmp_rtx = gen_rtx_fmt_ee (EQ, DImode, cc_reg, const0_rtx); |
| 1319 |
emit_jump_insn (gen_condjump (cmp_rtx, cc_reg, done_label)); |
| 1320 |
emit_label (loop_label); |
| 1321 |
emit_insn (gen_aarch64_gcspopm_xzr ()); |
| 1322 |
emit_insn (gen_adddi3_compare0 (gcs_now, gcs_now, GEN_INT (-8))); |
| 1323 |
cc_reg = gen_rtx_REG (CC_NZmode, CC_REGNUM); |
| 1324 |
cmp_rtx = gen_rtx_fmt_ee (NE, DImode, cc_reg, const0_rtx); |
| 1325 |
emit_jump_insn (gen_condjump (cmp_rtx, cc_reg, loop_label)); |
| 1326 |
emit_label (done_label); |
| 1327 |
} |
| 1328 |
DONE; |
| 1329 |
}) |
| 1330 |
|
| 1331 |
;; ------------------------------------------------------------------- |
| 1332 |
;; Subroutine calls and sibcalls |
| 1333 |
;; ------------------------------------------------------------------- |
| 1334 |
|
| 1335 |
(define_expand "call" |
| 1336 |
[(parallel |
| 1337 |
[(call (match_operand 0 "memory_operand") |
| 1338 |
(match_operand 1 "general_operand")) |
| 1339 |
(unspec:DI [(match_operand 2)] UNSPEC_CALLEE_ABI) |
| 1340 |
(clobber (reg:DI LR_REGNUM))])] |
| 1341 |
"" |
| 1342 |
" |
| 1343 |
{ |
| 1344 |
aarch64_expand_call (NULL_RTX, operands[0], operands[2], false); |
| 1345 |
DONE; |
| 1346 |
}" |
| 1347 |
) |
| 1348 |
|
| 1349 |
(define_insn "*call_insn" |
| 1350 |
[(call (mem:DI (match_operand:DI 0 "aarch64_call_insn_operand")) |
| 1351 |
(match_operand 1 "" "")) |
| 1352 |
(unspec:DI [(match_operand:DI 2 "const_int_operand")] UNSPEC_CALLEE_ABI) |
| 1353 |
(clobber (reg:DI LR_REGNUM))] |
| 1354 |
"" |
| 1355 |
{@ [ cons: 0 ; attrs: type ] |
| 1356 |
[ Ucr ; call ] << aarch64_indirect_call_asm (operands[0]); |
| 1357 |
[ Usf ; call ] bl\t%c0 |
| 1358 |
} |
| 1359 |
) |
| 1360 |
|
| 1361 |
(define_expand "call_value" |
| 1362 |
[(parallel |
| 1363 |
[(set (match_operand 0 "") |
| 1364 |
(call (match_operand 1 "memory_operand") |
| 1365 |
(match_operand 2 "general_operand"))) |
| 1366 |
(unspec:DI [(match_operand 3)] UNSPEC_CALLEE_ABI) |
| 1367 |
(clobber (reg:DI LR_REGNUM))])] |
| 1368 |
"" |
| 1369 |
" |
| 1370 |
{ |
| 1371 |
aarch64_expand_call (operands[0], operands[1], operands[3], false); |
| 1372 |
DONE; |
| 1373 |
}" |
| 1374 |
) |
| 1375 |
|
| 1376 |
(define_insn "*call_value_insn" |
| 1377 |
[(set (match_operand 0 "" "") |
| 1378 |
(call (mem:DI (match_operand:DI 1 "aarch64_call_insn_operand")) |
| 1379 |
(match_operand 2 "" ""))) |
| 1380 |
(unspec:DI [(match_operand:DI 3 "const_int_operand")] UNSPEC_CALLEE_ABI) |
| 1381 |
(clobber (reg:DI LR_REGNUM))] |
| 1382 |
"" |
| 1383 |
{@ [ cons: 1 ; attrs: type ] |
| 1384 |
[ Ucr ; call ] << aarch64_indirect_call_asm (operands[1]); |
| 1385 |
[ Usf ; call ] bl\t%c1 |
| 1386 |
} |
| 1387 |
) |
| 1388 |
|
| 1389 |
(define_expand "sibcall" |
| 1390 |
[(parallel |
| 1391 |
[(call (match_operand 0 "memory_operand") |
| 1392 |
(match_operand 1 "general_operand")) |
| 1393 |
(unspec:DI [(match_operand 2)] UNSPEC_CALLEE_ABI) |
| 1394 |
(return)])] |
| 1395 |
"" |
| 1396 |
{ |
| 1397 |
aarch64_expand_call (NULL_RTX, operands[0], operands[2], true); |
| 1398 |
DONE; |
| 1399 |
} |
| 1400 |
) |
| 1401 |
|
| 1402 |
(define_expand "sibcall_value" |
| 1403 |
[(parallel |
| 1404 |
[(set (match_operand 0 "") |
| 1405 |
(call (match_operand 1 "memory_operand") |
| 1406 |
(match_operand 2 "general_operand"))) |
| 1407 |
(unspec:DI [(match_operand 3)] UNSPEC_CALLEE_ABI) |
| 1408 |
(return)])] |
| 1409 |
"" |
| 1410 |
{ |
| 1411 |
aarch64_expand_call (operands[0], operands[1], operands[3], true); |
| 1412 |
DONE; |
| 1413 |
} |
| 1414 |
) |
| 1415 |
|
| 1416 |
(define_insn "*sibcall_insn" |
| 1417 |
[(call (mem:DI (match_operand:DI 0 "aarch64_call_insn_operand" "Ucs, Usf")) |
| 1418 |
(match_operand 1 "")) |
| 1419 |
(unspec:DI [(match_operand:DI 2 "const_int_operand")] UNSPEC_CALLEE_ABI) |
| 1420 |
(return)] |
| 1421 |
"SIBLING_CALL_P (insn)" |
| 1422 |
{ |
| 1423 |
if (which_alternative == 0) |
| 1424 |
{ |
| 1425 |
output_asm_insn ("br\\t%0", operands); |
| 1426 |
return aarch64_sls_barrier (aarch64_harden_sls_retbr_p ()); |
| 1427 |
} |
| 1428 |
return "b\\t%c0"; |
| 1429 |
} |
| 1430 |
[(set_attr "type" "branch, branch") |
| 1431 |
(set_attr "sls_length" "retbr,none")] |
| 1432 |
) |
| 1433 |
|
| 1434 |
(define_insn "*sibcall_value_insn" |
| 1435 |
[(set (match_operand 0 "") |
| 1436 |
(call (mem:DI |
| 1437 |
(match_operand:DI 1 "aarch64_call_insn_operand" "Ucs, Usf")) |
| 1438 |
(match_operand 2 ""))) |
| 1439 |
(unspec:DI [(match_operand:DI 3 "const_int_operand")] UNSPEC_CALLEE_ABI) |
| 1440 |
(return)] |
| 1441 |
"SIBLING_CALL_P (insn)" |
| 1442 |
{ |
| 1443 |
if (which_alternative == 0) |
| 1444 |
{ |
| 1445 |
output_asm_insn ("br\\t%1", operands); |
| 1446 |
return aarch64_sls_barrier (aarch64_harden_sls_retbr_p ()); |
| 1447 |
} |
| 1448 |
return "b\\t%c1"; |
| 1449 |
} |
| 1450 |
[(set_attr "type" "branch, branch") |
| 1451 |
(set_attr "sls_length" "retbr,none")] |
| 1452 |
) |
| 1453 |
|
| 1454 |
;; Call subroutine returning any type. |
| 1455 |
|
| 1456 |
(define_expand "untyped_call" |
| 1457 |
[(parallel [(call (match_operand 0 "") |
| 1458 |
(const_int 0)) |
| 1459 |
(match_operand 1 "") |
| 1460 |
(match_operand 2 "")])] |
| 1461 |
"" |
| 1462 |
{ |
| 1463 |
int i; |
| 1464 |
|
| 1465 |
/* Generate a PARALLEL that contains all of the register results. |
| 1466 |
The offsets are somewhat arbitrary, since we don't know the |
| 1467 |
actual return type. The main thing we need to avoid is having |
| 1468 |
overlapping byte ranges, since those might give the impression |
| 1469 |
that two registers are known to have data in common. */ |
| 1470 |
rtvec rets = rtvec_alloc (XVECLEN (operands[2], 0)); |
| 1471 |
poly_int64 offset = 0; |
| 1472 |
for (i = 0; i < XVECLEN (operands[2], 0); i++) |
| 1473 |
{ |
| 1474 |
rtx reg = SET_SRC (XVECEXP (operands[2], 0, i)); |
| 1475 |
gcc_assert (REG_P (reg)); |
| 1476 |
rtx offset_rtx = gen_int_mode (offset, Pmode); |
| 1477 |
rtx piece = gen_rtx_EXPR_LIST (VOIDmode, reg, offset_rtx); |
| 1478 |
RTVEC_ELT (rets, i) = piece; |
| 1479 |
offset += GET_MODE_SIZE (GET_MODE (reg)); |
| 1480 |
} |
| 1481 |
rtx ret = gen_rtx_PARALLEL (VOIDmode, rets); |
| 1482 |
|
| 1483 |
/* Untyped calls always use the default ABI. It's only possible to use |
| 1484 |
ABI variants if we know the type of the target function. */ |
| 1485 |
emit_call_insn (gen_call_value (ret, operands[0], const0_rtx, const0_rtx)); |
| 1486 |
|
| 1487 |
for (i = 0; i < XVECLEN (operands[2], 0); i++) |
| 1488 |
{ |
| 1489 |
rtx set = XVECEXP (operands[2], 0, i); |
| 1490 |
emit_move_insn (SET_DEST (set), SET_SRC (set)); |
| 1491 |
} |
| 1492 |
|
| 1493 |
/* The optimizer does not know that the call sets the function value |
| 1494 |
registers we stored in the result block. We avoid problems by |
| 1495 |
claiming that all hard registers are used and clobbered at this |
| 1496 |
point. */ |
| 1497 |
emit_insn (gen_blockage ()); |
| 1498 |
DONE; |
| 1499 |
}) |
| 1500 |
|
| 1501 |
;; ------------------------------------------------------------------- |
| 1502 |
;; Moves |
| 1503 |
;; ------------------------------------------------------------------- |
| 1504 |
|
| 1505 |
(define_expand "mov<mode>" |
| 1506 |
[(set (match_operand:SHORT 0 "nonimmediate_operand") |
| 1507 |
(match_operand:SHORT 1 "general_operand"))] |
| 1508 |
"" |
| 1509 |
" |
| 1510 |
if (GET_CODE (operands[0]) == MEM && operands[1] != const0_rtx) |
| 1511 |
operands[1] = force_reg (<MODE>mode, operands[1]); |
| 1512 |
|
| 1513 |
if (GET_CODE (operands[1]) == CONST_POLY_INT) |
| 1514 |
{ |
| 1515 |
aarch64_expand_mov_immediate (operands[0], operands[1]); |
| 1516 |
DONE; |
| 1517 |
} |
| 1518 |
" |
| 1519 |
) |
| 1520 |
|
| 1521 |
(define_insn "*mov<mode>_aarch64" |
| 1522 |
[(set (match_operand:SHORT 0 "nonimmediate_operand") |
| 1523 |
(match_operand:SHORT 1 "aarch64_mov_operand"))] |
| 1524 |
"(register_operand (operands[0], <MODE>mode) |
| 1525 |
|| aarch64_reg_or_zero (operands[1], <MODE>mode))" |
| 1526 |
{@ [cons: =0, 1; attrs: type, arch] |
| 1527 |
[w, Z ; neon_move , simd ] movi\t%0.<Vbtype>, #0 |
| 1528 |
[r, r ; mov_reg , * ] mov\t%w0, %w1 |
| 1529 |
[r, M ; mov_imm , * ] mov\t%w0, %1 |
| 1530 |
[w, D<hq>; neon_move , simd ] << aarch64_output_scalar_simd_mov_immediate (operands[1], <MODE>mode); |
| 1531 |
/* The "mov_imm" type for CNT is just a placeholder. */ |
| 1532 |
[r, Usv ; mov_imm , sve ] << aarch64_output_sve_cnt_immediate ("cnt", "%x0", operands[1]); |
| 1533 |
[r, Usr ; mov_imm , sve ] << aarch64_output_sve_rdvl (operands[1]); |
| 1534 |
[r, m ; load_4 , * ] ldr<size>\t%w0, %1 |
| 1535 |
[w, m ; load_4 , * ] ldr\t%<size>0, %1 |
| 1536 |
[m, r Z ; store_4 , * ] str<size>\\t%w1, %0 |
| 1537 |
[m, w ; store_4 , * ] str\t%<size>1, %0 |
| 1538 |
[r, w ; neon_to_gp<q> , base_simd ] umov\t%w0, %1.<v>[0] |
| 1539 |
[r, w ; neon_to_gp<q> , nobase_simd] fmov\t%w0, %s1 |
| 1540 |
[w, r Z ; neon_from_gp<q>, simd ] dup\t%0.<Vallxd>, %w1 |
| 1541 |
[w, r Z ; neon_from_gp<q>, nosimd ] fmov\t%s0, %w1 |
| 1542 |
[w, w ; neon_dup , simd ] dup\t%<Vetype>0, %1.<v>[0] |
| 1543 |
[w, w ; neon_dup , nosimd ] fmov\t%s0, %s1 |
| 1544 |
[Umv, rZ ; mrs , * ] msr\t%0, %x1 |
| 1545 |
[r, Umv ; mrs , * ] mrs\t%x0, %1 |
| 1546 |
} |
| 1547 |
) |
| 1548 |
|
| 1549 |
(define_expand "mov<mode>" |
| 1550 |
[(set (match_operand:GPI 0 "nonimmediate_operand") |
| 1551 |
(match_operand:GPI 1 "general_operand"))] |
| 1552 |
"" |
| 1553 |
" |
| 1554 |
if (MEM_P (operands[0]) && !MEM_VOLATILE_P (operands[0]) |
| 1555 |
&& CONST_INT_P (operands[1]) && <MODE>mode == DImode |
| 1556 |
&& aarch64_split_dimode_const_store (operands[0], operands[1])) |
| 1557 |
DONE; |
| 1558 |
|
| 1559 |
if (GET_CODE (operands[0]) == MEM && operands[1] != const0_rtx) |
| 1560 |
operands[1] = force_reg (<MODE>mode, operands[1]); |
| 1561 |
|
| 1562 |
/* Lower moves of symbolic constants into individual instructions. |
| 1563 |
Doing this now is sometimes necessary for correctness, since some |
| 1564 |
sequences require temporary pseudo registers. Lowering now is also |
| 1565 |
often better for optimization, since more RTL passes get the |
| 1566 |
chance to optimize the individual instructions. |
| 1567 |
|
| 1568 |
When called after RA, also split multi-instruction moves into |
| 1569 |
smaller pieces now, since we can't be sure that sure that there |
| 1570 |
will be a following split pass. */ |
| 1571 |
if (CONST_INT_P (operands[1]) |
| 1572 |
? (reload_completed |
| 1573 |
&& !aarch64_mov_imm_operand (operands[1], <MODE>mode)) |
| 1574 |
: CONSTANT_P (operands[1])) |
| 1575 |
{ |
| 1576 |
aarch64_expand_mov_immediate (operands[0], operands[1]); |
| 1577 |
DONE; |
| 1578 |
} |
| 1579 |
" |
| 1580 |
) |
| 1581 |
|
| 1582 |
(define_insn_and_split "*movsi_aarch64" |
| 1583 |
[(set (match_operand:SI 0 "nonimmediate_operand") |
| 1584 |
(match_operand:SI 1 "aarch64_mov_operand"))] |
| 1585 |
"(register_operand (operands[0], SImode) |
| 1586 |
|| aarch64_reg_or_zero (operands[1], SImode))" |
| 1587 |
{@ [cons: =0, 1; attrs: type, arch, length] |
| 1588 |
[w , Z ; neon_move, simd, 4] movi\t%0.2d, #0 |
| 1589 |
[r k, r ; mov_reg , * , 4] mov\t%w0, %w1 |
| 1590 |
[r , k ; mov_reg , * , 4] ^ |
| 1591 |
[r , M ; mov_imm , * , 4] mov\t%w0, %1 |
| 1592 |
[r , n ; mov_imm , * ,16] # |
| 1593 |
/* The "mov_imm" type for CNT is just a placeholder. */ |
| 1594 |
[r , Usv; mov_imm , sve , 4] << aarch64_output_sve_cnt_immediate ("cnt", "%x0", operands[1]); |
| 1595 |
[r , Usr; mov_imm , sve, 4] << aarch64_output_sve_rdvl (operands[1]); |
| 1596 |
[r , UsR; mov_imm , sme, 4] << aarch64_output_rdsvl (operands[1]); |
| 1597 |
[r , m ; load_4 , * , 4] ldr\t%w0, %1 |
| 1598 |
[w , m ; load_4 , fp , 4] ldr\t%s0, %1 |
| 1599 |
[m , r Z; store_4 , * , 4] str\t%w1, %0 |
| 1600 |
[m , w ; store_4 , fp , 4] str\t%s1, %0 |
| 1601 |
[r , Usw; load_4 , * , 8] adrp\t%x0, %A1\;ldr\t%w0, [%x0, %L1] |
| 1602 |
[r , Usa; adr , * , 4] adr\t%x0, %c1 |
| 1603 |
[r , Ush; adr , * , 4] adrp\t%x0, %A1 |
| 1604 |
[w , r Z; f_mcr , fp , 4] fmov\t%s0, %w1 |
| 1605 |
[r , w ; f_mrc , fp , 4] fmov\t%w0, %s1 |
| 1606 |
[w , w ; fmov , fp , 4] fmov\t%s0, %s1 |
| 1607 |
[w , Ds ; neon_move, simd, 4] << aarch64_output_scalar_simd_mov_immediate (operands[1], SImode); |
| 1608 |
[Umv, rZ ; mrs , * , 4] msr\t%0, %x1 |
| 1609 |
[r, Umv ; mrs , * , 4] mrs\t%x0, %1 |
| 1610 |
} |
| 1611 |
"CONST_INT_P (operands[1]) && !aarch64_move_imm (INTVAL (operands[1]), SImode) |
| 1612 |
&& REG_P (operands[0]) && GP_REGNUM_P (REGNO (operands[0]))" |
| 1613 |
[(const_int 0)] |
| 1614 |
{ |
| 1615 |
aarch64_expand_mov_immediate (operands[0], operands[1]); |
| 1616 |
DONE; |
| 1617 |
} |
| 1618 |
) |
| 1619 |
|
| 1620 |
(define_insn_and_split "*movdi_aarch64" |
| 1621 |
[(set (match_operand:DI 0 "nonimmediate_operand") |
| 1622 |
(match_operand:DI 1 "aarch64_mov_operand"))] |
| 1623 |
"(register_operand (operands[0], DImode) |
| 1624 |
|| aarch64_reg_or_zero (operands[1], DImode))" |
| 1625 |
{@ [cons: =0, 1; attrs: type, arch, length] |
| 1626 |
[w, Z ; neon_move, simd, 4] movi\t%0.2d, #0 |
| 1627 |
[r, r ; mov_reg , * , 4] mov\t%x0, %x1 |
| 1628 |
[k, r ; mov_reg , * , 4] mov\t%0, %x1 |
| 1629 |
[r, k ; mov_reg , * , 4] mov\t%x0, %1 |
| 1630 |
[r, O ; mov_imm , * , 4] << aarch64_is_mov_xn_imm (INTVAL (operands[1])) ? "mov\t%x0, %1" : "mov\t%w0, %1"; |
| 1631 |
[r, n ; mov_imm , * ,16] # |
| 1632 |
/* The "mov_imm" type for CNT is just a placeholder. */ |
| 1633 |
[r, Usv ; mov_imm , sve , 4] << aarch64_output_sve_cnt_immediate ("cnt", "%x0", operands[1]); |
| 1634 |
[r, Usr ; mov_imm , sve, 4] << aarch64_output_sve_rdvl (operands[1]); |
| 1635 |
[r, UsR ; mov_imm , sme, 4] << aarch64_output_rdsvl (operands[1]); |
| 1636 |
[r, m ; load_8 , * , 4] ldr\t%x0, %1 |
| 1637 |
[w, m ; load_8 , fp , 4] ldr\t%d0, %1 |
| 1638 |
[m, r Z ; store_8 , * , 4] str\t%x1, %0 |
| 1639 |
[m, w ; store_8 , fp , 4] str\t%d1, %0 |
| 1640 |
[r, Usw ; load_8 , * , 8] << TARGET_ILP32 ? "adrp\t%0, %A1\;ldr\t%w0, [%0, %L1]" : "adrp\t%0, %A1\;ldr\t%0, [%0, %L1]"; |
| 1641 |
[r, Usa ; adr , * , 4] adr\t%x0, %c1 |
| 1642 |
[r, Ush ; adr , * , 4] adrp\t%x0, %A1 |
| 1643 |
[w, r Z ; f_mcr , fp , 4] fmov\t%d0, %x1 |
| 1644 |
[r, w ; f_mrc , fp , 4] fmov\t%x0, %d1 |
| 1645 |
[w, w ; fmov , fp , 4] fmov\t%d0, %d1 |
| 1646 |
[w, Dd ; neon_move, simd, 4] << aarch64_output_scalar_simd_mov_immediate (operands[1], DImode); |
| 1647 |
[w, Dx ; neon_move, simd, 8] # |
| 1648 |
[Umv, rZ; mrs , * , 4] msr\t%0, %x1 |
| 1649 |
[r, Umv ; mrs , * , 4] mrs\t%0, %1 |
| 1650 |
} |
| 1651 |
"CONST_INT_P (operands[1]) |
| 1652 |
&& REG_P (operands[0]) |
| 1653 |
&& ((!aarch64_move_imm (INTVAL (operands[1]), DImode) |
| 1654 |
&& GP_REGNUM_P (REGNO (operands[0]))) |
| 1655 |
|| (aarch64_simd_special_constant_p (operands[1], DImode) |
| 1656 |
&& FP_REGNUM_P (REGNO (operands[0]))))" |
| 1657 |
[(const_int 0)] |
| 1658 |
{ |
| 1659 |
if (GP_REGNUM_P (REGNO (operands[0]))) |
| 1660 |
aarch64_expand_mov_immediate (operands[0], operands[1]); |
| 1661 |
else |
| 1662 |
aarch64_maybe_generate_simd_constant (operands[0], operands[1], DImode); |
| 1663 |
DONE; |
| 1664 |
} |
| 1665 |
) |
| 1666 |
|
| 1667 |
(define_insn "insv_imm<mode>" |
| 1668 |
[(set (zero_extract:GPI (match_operand:GPI 0 "register_operand" "+r") |
| 1669 |
(const_int 16) |
| 1670 |
(match_operand:GPI 1 "const_int_operand" "n")) |
| 1671 |
(match_operand:GPI 2 "const_int_operand" "n"))] |
| 1672 |
"UINTVAL (operands[1]) < GET_MODE_BITSIZE (<MODE>mode) |
| 1673 |
&& UINTVAL (operands[1]) % 16 == 0" |
| 1674 |
"movk\\t%<w>0, %X2, lsl %1" |
| 1675 |
[(set_attr "type" "mov_imm")] |
| 1676 |
) |
| 1677 |
|
| 1678 |
;; Match MOVK as a normal AND and IOR operation. |
| 1679 |
(define_insn "aarch64_movk<mode>" |
| 1680 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 1681 |
(ior:GPI (and:GPI (match_operand:GPI 1 "register_operand" "0") |
| 1682 |
(match_operand:GPI 2 "const_int_operand")) |
| 1683 |
(match_operand:GPI 3 "const_int_operand")))] |
| 1684 |
"aarch64_movk_shift (rtx_mode_t (operands[2], <MODE>mode), |
| 1685 |
rtx_mode_t (operands[3], <MODE>mode)) >= 0" |
| 1686 |
{ |
| 1687 |
int shift = aarch64_movk_shift (rtx_mode_t (operands[2], <MODE>mode), |
| 1688 |
rtx_mode_t (operands[3], <MODE>mode)); |
| 1689 |
operands[2] = gen_int_mode (UINTVAL (operands[3]) >> shift, SImode); |
| 1690 |
operands[3] = gen_int_mode (shift, SImode); |
| 1691 |
return "movk\\t%<w>0, #%X2, lsl %3"; |
| 1692 |
} |
| 1693 |
[(set_attr "type" "mov_imm")] |
| 1694 |
) |
| 1695 |
|
| 1696 |
(define_expand "movti" |
| 1697 |
[(set (match_operand:TI 0 "nonimmediate_operand") |
| 1698 |
(match_operand:TI 1 "general_operand"))] |
| 1699 |
"" |
| 1700 |
" |
| 1701 |
if (GET_CODE (operands[0]) == MEM && operands[1] != const0_rtx) |
| 1702 |
operands[1] = force_reg (TImode, operands[1]); |
| 1703 |
|
| 1704 |
if (GET_CODE (operands[1]) == CONST_POLY_INT) |
| 1705 |
{ |
| 1706 |
emit_move_insn (gen_lowpart (DImode, operands[0]), |
| 1707 |
gen_lowpart (DImode, operands[1])); |
| 1708 |
emit_move_insn (gen_highpart (DImode, operands[0]), const0_rtx); |
| 1709 |
DONE; |
| 1710 |
} |
| 1711 |
" |
| 1712 |
) |
| 1713 |
|
| 1714 |
(define_insn "*movti_aarch64" |
| 1715 |
[(set (match_operand:TI 0 |
| 1716 |
"nonimmediate_operand" "= r,w,w,w, r,w,w,r,m,m,w,m") |
| 1717 |
(match_operand:TI 1 |
| 1718 |
"aarch64_movti_operand" " rUti,Z,Z,r, w,w,w,m,r,Z,m,w"))] |
| 1719 |
"(register_operand (operands[0], TImode) |
| 1720 |
|| aarch64_reg_or_zero (operands[1], TImode))" |
| 1721 |
"@ |
| 1722 |
# |
| 1723 |
movi\\t%0.2d, #0 |
| 1724 |
fmov\t%d0, xzr |
| 1725 |
# |
| 1726 |
# |
| 1727 |
mov\\t%0.16b, %1.16b |
| 1728 |
mov\\t%Z0.d, %Z1.d |
| 1729 |
ldp\\t%0, %H0, %1 |
| 1730 |
stp\\t%1, %H1, %0 |
| 1731 |
stp\\txzr, xzr, %0 |
| 1732 |
ldr\\t%q0, %1 |
| 1733 |
str\\t%q1, %0" |
| 1734 |
[(set_attr "type" "multiple,neon_move,f_mcr,f_mcr,f_mrc,neon_logic_q,*,\ |
| 1735 |
load_16,store_16,store_16,\ |
| 1736 |
load_16,store_16") |
| 1737 |
(set_attr "length" "8,4,4,8,8,4,4,4,4,4,4,4") |
| 1738 |
(set_attr "arch" "*,simd,*,*,*,simd,sve,*,*,*,fp,fp")] |
| 1739 |
) |
| 1740 |
|
| 1741 |
;; Split a TImode register-register or register-immediate move into |
| 1742 |
;; its component DImode pieces, taking care to handle overlapping |
| 1743 |
;; source and dest registers. |
| 1744 |
(define_split |
| 1745 |
[(set (match_operand:TI 0 "register_operand" "") |
| 1746 |
(match_operand:TI 1 "aarch64_reg_or_imm" ""))] |
| 1747 |
"reload_completed && aarch64_split_128bit_move_p (operands[0], operands[1])" |
| 1748 |
[(const_int 0)] |
| 1749 |
{ |
| 1750 |
aarch64_split_128bit_move (operands[0], operands[1]); |
| 1751 |
DONE; |
| 1752 |
}) |
| 1753 |
|
| 1754 |
(define_expand "mov<mode>" |
| 1755 |
[(set (match_operand:GPF_TF_F16_MOV 0 "nonimmediate_operand") |
| 1756 |
(match_operand:GPF_TF_F16_MOV 1 "general_operand"))] |
| 1757 |
"" |
| 1758 |
{ |
| 1759 |
if (!TARGET_FLOAT) |
| 1760 |
{ |
| 1761 |
aarch64_err_no_fpadvsimd (<MODE>mode); |
| 1762 |
machine_mode intmode |
| 1763 |
= int_mode_for_size (GET_MODE_BITSIZE (<MODE>mode), 0).require (); |
| 1764 |
emit_move_insn (gen_lowpart (intmode, operands[0]), |
| 1765 |
gen_lowpart (intmode, operands[1])); |
| 1766 |
DONE; |
| 1767 |
} |
| 1768 |
|
| 1769 |
if (GET_CODE (operands[0]) == MEM |
| 1770 |
&& ! (GET_CODE (operands[1]) == CONST_DOUBLE |
| 1771 |
&& aarch64_float_const_zero_rtx_p (operands[1]))) |
| 1772 |
operands[1] = force_reg (<MODE>mode, operands[1]); |
| 1773 |
|
| 1774 |
if (GET_CODE (operands[1]) == CONST_DOUBLE |
| 1775 |
&& can_create_pseudo_p () |
| 1776 |
&& !aarch64_can_const_movi_rtx_p (operands[1], <MODE>mode) |
| 1777 |
&& !aarch64_float_const_representable_p (operands[1]) |
| 1778 |
&& !aarch64_float_const_zero_rtx_p (operands[1]) |
| 1779 |
&& aarch64_float_const_rtx_p (operands[1])) |
| 1780 |
{ |
| 1781 |
unsigned HOST_WIDE_INT ival; |
| 1782 |
bool res = aarch64_reinterpret_float_as_int (operands[1], &ival); |
| 1783 |
gcc_assert (res); |
| 1784 |
|
| 1785 |
machine_mode intmode |
| 1786 |
= int_mode_for_size (GET_MODE_BITSIZE (<MODE>mode), 0).require (); |
| 1787 |
rtx tmp = gen_reg_rtx (intmode); |
| 1788 |
emit_move_insn (tmp, gen_int_mode (ival, intmode)); |
| 1789 |
emit_move_insn (operands[0], gen_lowpart (<MODE>mode, tmp)); |
| 1790 |
DONE; |
| 1791 |
} |
| 1792 |
} |
| 1793 |
) |
| 1794 |
|
| 1795 |
(define_insn "*mov<mode>_aarch64" |
| 1796 |
[(set (match_operand:HFBF 0 "nonimmediate_operand") |
| 1797 |
(match_operand:HFBF 1 "general_operand"))] |
| 1798 |
"aarch64_valid_fp_move (operands[0], operands[1], <MODE>mode)" |
| 1799 |
{@ [ cons: =0 , 1 ; attrs: type , arch ] |
| 1800 |
[ w , Y ; neon_move , simd ] movi\t%0.4h, #0 |
| 1801 |
[ w , ?rY ; f_mcr , fp16 ] fmov\t%h0, %w1 |
| 1802 |
[ w , ?r ; neon_move , simd ] dup\t%w0.4h, %w1 |
| 1803 |
[ w , ?rY ; f_mcr , * ] fmov\t%s0, %w1 |
| 1804 |
[ ?r , w ; neon_to_gp , simd ] umov\t%w0, %1.h[0] |
| 1805 |
[ ?r , w ; f_mrc , * ] fmov\t%w0, %s1 |
| 1806 |
[ w , w ; neon_move , simd ] mov\t%0.h[0], %1.h[0] |
| 1807 |
[ w , w ; fmov , * ] fmov\t%s0, %s1 |
| 1808 |
[ w , Ufc ; fconsts , fp16 ] fmov\t%h0, %1 |
| 1809 |
[ w , Uvi ; neon_move , simd ] << aarch64_output_scalar_simd_mov_immediate (operands[1], HImode); |
| 1810 |
[ w , m ; f_loads , * ] ldr\t%h0, %1 |
| 1811 |
[ m , w ; f_stores , * ] str\t%h1, %0 |
| 1812 |
[ r , m ; load_4 , * ] ldrh\t%w0, %1 |
| 1813 |
[ m , rY ; store_4 , * ] strh\t%w1, %0 |
| 1814 |
[ r , r ; mov_reg , * ] mov\t%w0, %w1 |
| 1815 |
} |
| 1816 |
) |
| 1817 |
|
| 1818 |
(define_insn "*mov<mode>_aarch64" |
| 1819 |
[(set (match_operand:SFD 0 "nonimmediate_operand") |
| 1820 |
(match_operand:SFD 1 "general_operand"))] |
| 1821 |
"aarch64_valid_fp_move (operands[0], operands[1], <MODE>mode)" |
| 1822 |
{@ [ cons: =0 , 1 ; attrs: type , arch ] |
| 1823 |
[ w , Y ; neon_move , simd ] movi\t%0.2s, #0 |
| 1824 |
[ w , ?rY ; f_mcr , * ] fmov\t%s0, %w1 |
| 1825 |
[ ?r , w ; f_mrc , * ] fmov\t%w0, %s1 |
| 1826 |
[ w , w ; fmov , * ] fmov\t%s0, %s1 |
| 1827 |
[ w , Ufc ; fconsts , * ] fmov\t%s0, %1 |
| 1828 |
[ w , Uvi ; neon_move , simd ] << aarch64_output_scalar_simd_mov_immediate (operands[1], SImode); |
| 1829 |
[ w , m ; f_loads , * ] ldr\t%s0, %1 |
| 1830 |
[ m , w ; f_stores , * ] str\t%s1, %0 |
| 1831 |
[ r , m ; load_4 , * ] ldr\t%w0, %1 |
| 1832 |
[ m , rY ; store_4 , * ] str\t%w1, %0 |
| 1833 |
[ r , r ; mov_reg , * ] mov\t%w0, %w1 |
| 1834 |
[ r , M ; fconsts , * ] mov\t%w0, %1 |
| 1835 |
} |
| 1836 |
) |
| 1837 |
|
| 1838 |
(define_insn "*mov<mode>_aarch64" |
| 1839 |
[(set (match_operand:DFD 0 "nonimmediate_operand") |
| 1840 |
(match_operand:DFD 1 "general_operand"))] |
| 1841 |
"aarch64_valid_fp_move (operands[0], operands[1], <MODE>mode)" |
| 1842 |
{@ [ cons: =0 , 1 ; attrs: type , arch ] |
| 1843 |
[ w , Y ; neon_move , simd ] movi\t%d0, #0 |
| 1844 |
[ w , ?rY ; f_mcr , * ] fmov\t%d0, %x1 |
| 1845 |
[ ?r , w ; f_mrc , * ] fmov\t%x0, %d1 |
| 1846 |
[ w , w ; fmov , * ] fmov\t%d0, %d1 |
| 1847 |
[ w , Ufc ; fconstd , * ] fmov\t%d0, %1 |
| 1848 |
[ w , Uvi ; neon_move , simd ] << aarch64_output_scalar_simd_mov_immediate (operands[1], DImode); |
| 1849 |
[ w , m ; f_loadd , * ] ldr\t%d0, %1 |
| 1850 |
[ m , w ; f_stored , * ] str\t%d1, %0 |
| 1851 |
[ r , m ; load_8 , * ] ldr\t%x0, %1 |
| 1852 |
[ m , rY ; store_8 , * ] str\t%x1, %0 |
| 1853 |
[ r , r ; mov_reg , * ] mov\t%x0, %x1 |
| 1854 |
[ r , O ; fconstd , * ] << aarch64_is_mov_xn_imm (INTVAL (operands[1])) ? "mov\t%x0, %1" : "mov\t%w0, %1"; |
| 1855 |
} |
| 1856 |
) |
| 1857 |
|
| 1858 |
(define_insn "*mov<mode>_aarch64" |
| 1859 |
[(set (match_operand:TFD 0 |
| 1860 |
"nonimmediate_operand" "=w,w,?r ,w ,?r,w,?w,w,m,?r,m ,m") |
| 1861 |
(match_operand:TFD 1 |
| 1862 |
"general_operand" " w,w,?rY,?r,w ,Y,Y ,m,w,m ,?r,Y"))] |
| 1863 |
"TARGET_FLOAT && (register_operand (operands[0], <MODE>mode) |
| 1864 |
|| aarch64_reg_or_fp_zero (operands[1], <MODE>mode))" |
| 1865 |
"@ |
| 1866 |
mov\\t%0.16b, %1.16b |
| 1867 |
mov\\t%Z0.d, %Z1.d |
| 1868 |
# |
| 1869 |
# |
| 1870 |
# |
| 1871 |
movi\\t%0.2d, #0 |
| 1872 |
fmov\\t%s0, wzr |
| 1873 |
ldr\\t%q0, %1 |
| 1874 |
str\\t%q1, %0 |
| 1875 |
ldp\\t%0, %H0, %1 |
| 1876 |
stp\\t%1, %H1, %0 |
| 1877 |
stp\\txzr, xzr, %0" |
| 1878 |
[(set_attr "type" "logic_reg,*,multiple,f_mcr,f_mrc,neon_move_q,f_mcr,\ |
| 1879 |
f_loadd,f_stored,load_16,store_16,store_16") |
| 1880 |
(set_attr "length" "4,4,8,8,8,4,4,4,4,4,4,4") |
| 1881 |
(set_attr "arch" "simd,sve,*,*,*,simd,*,*,*,*,*,*")] |
| 1882 |
) |
| 1883 |
|
| 1884 |
(define_split |
| 1885 |
[(set (match_operand:TFD 0 "register_operand" "") |
| 1886 |
(match_operand:TFD 1 "nonmemory_operand" ""))] |
| 1887 |
"reload_completed && aarch64_split_128bit_move_p (operands[0], operands[1])" |
| 1888 |
[(const_int 0)] |
| 1889 |
{ |
| 1890 |
aarch64_split_128bit_move (operands[0], operands[1]); |
| 1891 |
DONE; |
| 1892 |
} |
| 1893 |
) |
| 1894 |
|
| 1895 |
;; The preferred way of writing to the FPMR is to test whether it already |
| 1896 |
;; has the desired value and branch around the write if so. This reduces |
| 1897 |
;; the number of redundant FPMR writes caused by ABI boundaries, such as in: |
| 1898 |
;; |
| 1899 |
;; for (...) |
| 1900 |
;; fp8_kernel (..., fpmr_value); |
| 1901 |
;; |
| 1902 |
;; Without this optimization, fp8_kernel would set FPMR to fpmr_value each |
| 1903 |
;; time that it is called. |
| 1904 |
;; |
| 1905 |
;; We do this as a split so that hardreg_pre can optimize the moves first. |
| 1906 |
(define_split |
| 1907 |
[(set (reg:DI FPM_REGNUM) |
| 1908 |
(match_operand:DI 0 "aarch64_reg_or_zero"))] |
| 1909 |
"TARGET_FP8 && !TARGET_CHEAP_FPMR_WRITE && can_create_pseudo_p ()" |
| 1910 |
[(const_int 0)] |
| 1911 |
{ |
| 1912 |
auto label = gen_label_rtx (); |
| 1913 |
rtx current = copy_to_reg (gen_rtx_REG (DImode, FPM_REGNUM)); |
| 1914 |
rtx cond = gen_rtx_EQ (VOIDmode, current, operands[0]); |
| 1915 |
emit_jump_insn (gen_cbranchdi4 (cond, current, operands[0], label)); |
| 1916 |
emit_insn (gen_aarch64_write_fpmr (operands[0])); |
| 1917 |
emit_label (label); |
| 1918 |
DONE; |
| 1919 |
} |
| 1920 |
) |
| 1921 |
|
| 1922 |
;; A write to the FPMR that is already protected by a conditional branch. |
| 1923 |
;; Since this instruction is introduced late, it shouldn't matter too much |
| 1924 |
;; that we're using an unspec for a move. |
| 1925 |
(define_insn "aarch64_write_fpmr" |
| 1926 |
[(set (reg:DI FPM_REGNUM) |
| 1927 |
(unspec:DI [(match_operand:DI 0 "aarch64_reg_or_zero" "rZ")] |
| 1928 |
UNSPEC_WRITE_FPMR))] |
| 1929 |
"TARGET_FP8" |
| 1930 |
"msr\tfpmr, %x0" |
| 1931 |
) |
| 1932 |
|
| 1933 |
(define_expand "aarch64_cpymemdi" |
| 1934 |
[(parallel |
| 1935 |
[(set (match_operand 2) (const_int 0)) |
| 1936 |
(clobber (match_dup 3)) |
| 1937 |
(clobber (match_dup 4)) |
| 1938 |
(clobber (reg:CC CC_REGNUM)) |
| 1939 |
(set (match_operand 0) |
| 1940 |
(unspec:BLK [(match_operand 1) (match_dup 2)] UNSPEC_CPYMEM))])] |
| 1941 |
"TARGET_MOPS" |
| 1942 |
{ |
| 1943 |
operands[3] = XEXP (operands[0], 0); |
| 1944 |
operands[4] = XEXP (operands[1], 0); |
| 1945 |
} |
| 1946 |
) |
| 1947 |
|
| 1948 |
(define_insn "*aarch64_cpymemdi" |
| 1949 |
[(set (match_operand:DI 2 "register_operand" "+&r") (const_int 0)) |
| 1950 |
(clobber (match_operand:DI 0 "register_operand" "+&r")) |
| 1951 |
(clobber (match_operand:DI 1 "register_operand" "+&r")) |
| 1952 |
(clobber (reg:CC CC_REGNUM)) |
| 1953 |
(set (mem:BLK (match_dup 0)) |
| 1954 |
(unspec:BLK [(mem:BLK (match_dup 1)) (match_dup 2)] UNSPEC_CPYMEM))] |
| 1955 |
"TARGET_MOPS" |
| 1956 |
"cpyfp\t[%x0]!, [%x1]!, %x2!\;cpyfm\t[%x0]!, [%x1]!, %x2!\;cpyfe\t[%x0]!, [%x1]!, %x2!" |
| 1957 |
[(set_attr "length" "12")] |
| 1958 |
) |
| 1959 |
|
| 1960 |
;; 0 is dst |
| 1961 |
;; 1 is src |
| 1962 |
;; 2 is size of copy in bytes |
| 1963 |
;; 3 is alignment |
| 1964 |
|
| 1965 |
(define_expand "cpymemdi" |
| 1966 |
[(match_operand:BLK 0 "memory_operand") |
| 1967 |
(match_operand:BLK 1 "memory_operand") |
| 1968 |
(match_operand:DI 2 "general_operand") |
| 1969 |
(match_operand:DI 3 "immediate_operand")] |
| 1970 |
"" |
| 1971 |
{ |
| 1972 |
if (aarch64_expand_cpymem (operands, false)) |
| 1973 |
DONE; |
| 1974 |
FAIL; |
| 1975 |
} |
| 1976 |
) |
| 1977 |
|
| 1978 |
(define_expand "aarch64_movmemdi" |
| 1979 |
[(parallel |
| 1980 |
[(set (match_operand 2) (const_int 0)) |
| 1981 |
(clobber (match_dup 3)) |
| 1982 |
(clobber (match_dup 4)) |
| 1983 |
(clobber (reg:CC CC_REGNUM)) |
| 1984 |
(set (match_operand 0) |
| 1985 |
(unspec:BLK [(match_operand 1) (match_dup 2)] UNSPEC_MOVMEM))])] |
| 1986 |
"TARGET_MOPS" |
| 1987 |
{ |
| 1988 |
operands[3] = XEXP (operands[0], 0); |
| 1989 |
operands[4] = XEXP (operands[1], 0); |
| 1990 |
} |
| 1991 |
) |
| 1992 |
|
| 1993 |
(define_insn "*aarch64_movmemdi" |
| 1994 |
[(parallel [ |
| 1995 |
(set (match_operand:DI 2 "register_operand" "+&r") (const_int 0)) |
| 1996 |
(clobber (match_operand:DI 0 "register_operand" "+&r")) |
| 1997 |
(clobber (match_operand:DI 1 "register_operand" "+&r")) |
| 1998 |
(clobber (reg:CC CC_REGNUM)) |
| 1999 |
(set (mem:BLK (match_dup 0)) |
| 2000 |
(unspec:BLK [(mem:BLK (match_dup 1)) (match_dup 2)] UNSPEC_MOVMEM))])] |
| 2001 |
"TARGET_MOPS" |
| 2002 |
"cpyp\t[%x0]!, [%x1]!, %x2!\;cpym\t[%x0]!, [%x1]!, %x2!\;cpye\t[%x0]!, [%x1]!, %x2!" |
| 2003 |
[(set_attr "length" "12")] |
| 2004 |
) |
| 2005 |
|
| 2006 |
;; 0 is dst |
| 2007 |
;; 1 is src |
| 2008 |
;; 2 is size of copy in bytes |
| 2009 |
;; 3 is alignment |
| 2010 |
|
| 2011 |
(define_expand "movmemdi" |
| 2012 |
[(match_operand:BLK 0 "memory_operand") |
| 2013 |
(match_operand:BLK 1 "memory_operand") |
| 2014 |
(match_operand:DI 2 "general_operand") |
| 2015 |
(match_operand:DI 3 "immediate_operand")] |
| 2016 |
"" |
| 2017 |
{ |
| 2018 |
if (aarch64_expand_cpymem (operands, true)) |
| 2019 |
DONE; |
| 2020 |
FAIL; |
| 2021 |
} |
| 2022 |
) |
| 2023 |
|
| 2024 |
(define_expand "aarch64_setmemdi" |
| 2025 |
[(parallel |
| 2026 |
[(set (match_operand 2) (const_int 0)) |
| 2027 |
(clobber (match_dup 3)) |
| 2028 |
(clobber (reg:CC CC_REGNUM)) |
| 2029 |
(set (match_operand 0) |
| 2030 |
(unspec:BLK [(match_operand 1) |
| 2031 |
(match_dup 2)] UNSPEC_SETMEM))])] |
| 2032 |
"TARGET_MOPS" |
| 2033 |
{ |
| 2034 |
operands[3] = XEXP (operands[0], 0); |
| 2035 |
} |
| 2036 |
) |
| 2037 |
|
| 2038 |
(define_insn "*aarch64_setmemdi" |
| 2039 |
[(set (match_operand:DI 2 "register_operand" "+&r") (const_int 0)) |
| 2040 |
(clobber (match_operand:DI 0 "register_operand" "+&r")) |
| 2041 |
(clobber (reg:CC CC_REGNUM)) |
| 2042 |
(set (mem:BLK (match_dup 0)) |
| 2043 |
(unspec:BLK [(match_operand:QI 1 "aarch64_reg_or_zero" "rZ") |
| 2044 |
(match_dup 2)] UNSPEC_SETMEM))] |
| 2045 |
"TARGET_MOPS" |
| 2046 |
"setp\t[%x0]!, %x2!, %x1\;setm\t[%x0]!, %x2!, %x1\;sete\t[%x0]!, %x2!, %x1" |
| 2047 |
[(set_attr "length" "12")] |
| 2048 |
) |
| 2049 |
|
| 2050 |
;; 0 is dst |
| 2051 |
;; 1 is val |
| 2052 |
;; 2 is size of copy in bytes |
| 2053 |
;; 3 is alignment |
| 2054 |
(define_expand "setmemdi" |
| 2055 |
[(set (match_operand:BLK 0 "memory_operand") ;; Dest |
| 2056 |
(match_operand:QI 2 "nonmemory_operand")) ;; Value |
| 2057 |
(use (match_operand:DI 1 "general_operand")) ;; Length |
| 2058 |
(match_operand 3 "immediate_operand")] ;; Align |
| 2059 |
"" |
| 2060 |
{ |
| 2061 |
if (aarch64_expand_setmem (operands)) |
| 2062 |
DONE; |
| 2063 |
|
| 2064 |
FAIL; |
| 2065 |
}) |
| 2066 |
|
| 2067 |
(define_insn "*load_pair_<ldst_sz>" |
| 2068 |
[(set (match_operand:GPI 0 "aarch64_ldp_reg_operand") |
| 2069 |
(unspec [ |
| 2070 |
(match_operand:<VPAIR> 1 "aarch64_mem_pair_lanes_operand") |
| 2071 |
] UNSPEC_LDP_FST)) |
| 2072 |
(set (match_operand:GPI 2 "aarch64_ldp_reg_operand") |
| 2073 |
(unspec [ |
| 2074 |
(match_dup 1) |
| 2075 |
] UNSPEC_LDP_SND))] |
| 2076 |
"" |
| 2077 |
{@ [cons: =0, 1, =2; attrs: type, arch] |
| 2078 |
[ r, Umn, r; load_<ldpstp_sz>, * ] ldp\t%<w>0, %<w>2, %y1 |
| 2079 |
[ w, Umn, w; neon_load1_2reg, fp ] ldp\t%<v>0, %<v>2, %y1 |
| 2080 |
} |
| 2081 |
[(set_attr "ldpstp" "ldp")] |
| 2082 |
) |
| 2083 |
|
| 2084 |
(define_insn "*load_pair_16" |
| 2085 |
[(set (match_operand:TI 0 "aarch64_ldp_reg_operand" "=w") |
| 2086 |
(unspec [ |
| 2087 |
(match_operand:V2x16QI 1 "aarch64_mem_pair_lanes_operand" "Umn") |
| 2088 |
] UNSPEC_LDP_FST)) |
| 2089 |
(set (match_operand:TI 2 "aarch64_ldp_reg_operand" "=w") |
| 2090 |
(unspec [ |
| 2091 |
(match_dup 1) |
| 2092 |
] UNSPEC_LDP_SND))] |
| 2093 |
"TARGET_FLOAT" |
| 2094 |
"ldp\\t%q0, %q2, %y1" |
| 2095 |
[(set_attr "type" "neon_ldp_q") |
| 2096 |
(set_attr "fp" "yes") |
| 2097 |
(set_attr "ldpstp" "ldp")] |
| 2098 |
) |
| 2099 |
|
| 2100 |
(define_insn "*store_pair_<ldst_sz>" |
| 2101 |
[(set (match_operand:<VPAIR> 0 "aarch64_mem_pair_lanes_operand") |
| 2102 |
(unspec:<VPAIR> |
| 2103 |
[(match_operand:GPI 1 "aarch64_stp_reg_operand") |
| 2104 |
(match_operand:GPI 2 "aarch64_stp_reg_operand")] UNSPEC_STP))] |
| 2105 |
"" |
| 2106 |
{@ [cons: =0, 1, 2; attrs: type , arch] |
| 2107 |
[ Umn, rYZ, rYZ; store_<ldpstp_sz>, * ] stp\t%<w>1, %<w>2, %y0 |
| 2108 |
[ Umn, w, w; neon_store1_2reg , fp ] stp\t%<v>1, %<v>2, %y0 |
| 2109 |
} |
| 2110 |
[(set_attr "ldpstp" "stp")] |
| 2111 |
) |
| 2112 |
|
| 2113 |
(define_insn "*store_pair_16" |
| 2114 |
[(set (match_operand:V2x16QI 0 "aarch64_mem_pair_lanes_operand" "=Umn") |
| 2115 |
(unspec:V2x16QI |
| 2116 |
[(match_operand:TI 1 "aarch64_ldp_reg_operand" "w") |
| 2117 |
(match_operand:TI 2 "aarch64_ldp_reg_operand" "w")] UNSPEC_STP))] |
| 2118 |
"TARGET_FLOAT" |
| 2119 |
"stp\t%q1, %q2, %y0" |
| 2120 |
[(set_attr "type" "neon_stp_q") |
| 2121 |
(set_attr "fp" "yes") |
| 2122 |
(set_attr "ldpstp" "stp")] |
| 2123 |
) |
| 2124 |
|
| 2125 |
;; Writeback load/store pair patterns. |
| 2126 |
;; |
| 2127 |
;; Note that modes in the patterns [SI DI TI] are used only as a proxy for their |
| 2128 |
;; size; aarch64_ldp_reg_operand and aarch64_mem_pair_operator are special |
| 2129 |
;; predicates which accept a wide range of operand modes, with the requirement |
| 2130 |
;; that the contextual (pattern) mode is of the same size as the operand mode. |
| 2131 |
|
| 2132 |
;; Load pair with post-index writeback. This is primarily used in function |
| 2133 |
;; epilogues. |
| 2134 |
(define_insn "*loadwb_post_pair_<ldst_sz>" |
| 2135 |
[(set (match_operand 0 "pmode_register_operand") |
| 2136 |
(match_operator 7 "pmode_plus_operator" [ |
| 2137 |
(match_operand 1 "pmode_register_operand") |
| 2138 |
(match_operand 4 "const_int_operand")])) |
| 2139 |
(set (match_operand:GPI 2 "aarch64_ldp_reg_operand") |
| 2140 |
(match_operator 5 "memory_operand" [(match_dup 1)])) |
| 2141 |
(set (match_operand:GPI 3 "aarch64_ldp_reg_operand") |
| 2142 |
(match_operator 6 "memory_operand" [ |
| 2143 |
(match_operator 8 "pmode_plus_operator" [ |
| 2144 |
(match_dup 1) |
| 2145 |
(const_int <ldst_sz>)])]))] |
| 2146 |
"aarch64_mem_pair_offset (operands[4], <MODE>mode)" |
| 2147 |
{@ [cons: =0, 1, =2, =3; attrs: type] |
| 2148 |
[ rk, 0, r, r; load_<ldpstp_sz>] ldp\t%<w>2, %<w>3, [%1], %4 |
| 2149 |
[ rk, 0, w, w; neon_load1_2reg ] ldp\t%<v>2, %<v>3, [%1], %4 |
| 2150 |
} |
| 2151 |
) |
| 2152 |
|
| 2153 |
;; q-register variant of the above |
| 2154 |
(define_insn "*loadwb_post_pair_16" |
| 2155 |
[(set (match_operand 0 "pmode_register_operand" "=rk") |
| 2156 |
(match_operator 7 "pmode_plus_operator" [ |
| 2157 |
(match_operand 1 "pmode_register_operand" "0") |
| 2158 |
(match_operand 4 "const_int_operand")])) |
| 2159 |
(set (match_operand:TI 2 "aarch64_ldp_reg_operand" "=w") |
| 2160 |
(match_operator 5 "memory_operand" [(match_dup 1)])) |
| 2161 |
(set (match_operand:TI 3 "aarch64_ldp_reg_operand" "=w") |
| 2162 |
(match_operator 6 "memory_operand" |
| 2163 |
[(match_operator 8 "pmode_plus_operator" [ |
| 2164 |
(match_dup 1) |
| 2165 |
(const_int 16)])]))] |
| 2166 |
"TARGET_FLOAT |
| 2167 |
&& aarch64_mem_pair_offset (operands[4], TImode)" |
| 2168 |
"ldp\t%q2, %q3, [%1], %4" |
| 2169 |
[(set_attr "type" "neon_ldp_q")] |
| 2170 |
) |
| 2171 |
|
| 2172 |
;; Load pair with pre-index writeback. |
| 2173 |
(define_insn "*loadwb_pre_pair_<ldst_sz>" |
| 2174 |
[(set (match_operand 0 "pmode_register_operand") |
| 2175 |
(match_operator 8 "pmode_plus_operator" [ |
| 2176 |
(match_operand 1 "pmode_register_operand") |
| 2177 |
(match_operand 4 "const_int_operand")])) |
| 2178 |
(set (match_operand:GPI 2 "aarch64_ldp_reg_operand") |
| 2179 |
(match_operator 6 "memory_operand" [ |
| 2180 |
(match_operator 9 "pmode_plus_operator" [ |
| 2181 |
(match_dup 1) |
| 2182 |
(match_dup 4) |
| 2183 |
])])) |
| 2184 |
(set (match_operand:GPI 3 "aarch64_ldp_reg_operand") |
| 2185 |
(match_operator 7 "memory_operand" [ |
| 2186 |
(match_operator 10 "pmode_plus_operator" [ |
| 2187 |
(match_dup 1) |
| 2188 |
(match_operand 5 "const_int_operand") |
| 2189 |
])]))] |
| 2190 |
"aarch64_mem_pair_offset (operands[4], <MODE>mode) |
| 2191 |
&& known_eq (INTVAL (operands[5]), |
| 2192 |
INTVAL (operands[4]) + GET_MODE_SIZE (<MODE>mode))" |
| 2193 |
{@ [cons: =0, 1, =2, =3; attrs: type ] |
| 2194 |
[ &rk, 0, r, r; load_<ldpstp_sz>] ldp\t%<w>2, %<w>3, [%0, %4]! |
| 2195 |
[ rk, 0, w, w; neon_load1_2reg ] ldp\t%<v>2, %<v>3, [%0, %4]! |
| 2196 |
} |
| 2197 |
) |
| 2198 |
|
| 2199 |
;; q-register variant of the above |
| 2200 |
(define_insn "*loadwb_pre_pair_16" |
| 2201 |
[(set (match_operand 0 "pmode_register_operand" "=&rk") |
| 2202 |
(match_operator 8 "pmode_plus_operator" [ |
| 2203 |
(match_operand 1 "pmode_register_operand" "0") |
| 2204 |
(match_operand 4 "const_int_operand")])) |
| 2205 |
(set (match_operand:TI 2 "aarch64_ldp_reg_operand" "=w") |
| 2206 |
(match_operator 6 "memory_operand" [ |
| 2207 |
(match_operator 9 "pmode_plus_operator" [ |
| 2208 |
(match_dup 1) |
| 2209 |
(match_dup 4) |
| 2210 |
])])) |
| 2211 |
(set (match_operand:TI 3 "aarch64_ldp_reg_operand" "=w") |
| 2212 |
(match_operator 7 "memory_operand" [ |
| 2213 |
(match_operator 10 "pmode_plus_operator" [ |
| 2214 |
(match_dup 1) |
| 2215 |
(match_operand 5 "const_int_operand") |
| 2216 |
])]))] |
| 2217 |
"TARGET_FLOAT |
| 2218 |
&& aarch64_mem_pair_offset (operands[4], TImode) |
| 2219 |
&& known_eq (INTVAL (operands[5]), INTVAL (operands[4]) + 16)" |
| 2220 |
"ldp\t%q2, %q3, [%0, %4]!" |
| 2221 |
[(set_attr "type" "neon_ldp_q")] |
| 2222 |
) |
| 2223 |
|
| 2224 |
;; Store pair with pre-index writeback. This is primarily used in function |
| 2225 |
;; prologues. |
| 2226 |
(define_insn "*storewb_pre_pair_<ldst_sz>" |
| 2227 |
[(set (match_operand 0 "pmode_register_operand") |
| 2228 |
(match_operator 6 "pmode_plus_operator" [ |
| 2229 |
(match_operand 1 "pmode_register_operand") |
| 2230 |
(match_operand 4 "const_int_operand") |
| 2231 |
])) |
| 2232 |
(set (match_operator:GPI 7 "aarch64_mem_pair_operator" [ |
| 2233 |
(match_operator 8 "pmode_plus_operator" [ |
| 2234 |
(match_dup 0) |
| 2235 |
(match_dup 4) |
| 2236 |
])]) |
| 2237 |
(match_operand:GPI 2 "aarch64_stp_reg_operand")) |
| 2238 |
(set (match_operator:GPI 9 "aarch64_mem_pair_operator" [ |
| 2239 |
(match_operator 10 "pmode_plus_operator" [ |
| 2240 |
(match_dup 0) |
| 2241 |
(match_operand 5 "const_int_operand") |
| 2242 |
])]) |
| 2243 |
(match_operand:GPI 3 "aarch64_stp_reg_operand"))] |
| 2244 |
"aarch64_mem_pair_offset (operands[4], <MODE>mode) |
| 2245 |
&& known_eq (INTVAL (operands[5]), |
| 2246 |
INTVAL (operands[4]) + GET_MODE_SIZE (<MODE>mode)) |
| 2247 |
&& !reg_overlap_mentioned_p (operands[0], operands[2]) |
| 2248 |
&& !reg_overlap_mentioned_p (operands[0], operands[3])" |
| 2249 |
{@ [cons: =0, 1, 2, 3; attrs: type ] |
| 2250 |
[ &rk, 0, rYZ, rYZ; store_<ldpstp_sz>] stp\t%<w>2, %<w>3, [%0, %4]! |
| 2251 |
[ rk, 0, w, w; neon_store1_2reg ] stp\t%<v>2, %<v>3, [%0, %4]! |
| 2252 |
} |
| 2253 |
) |
| 2254 |
|
| 2255 |
;; q-register variant of the above. |
| 2256 |
(define_insn "*storewb_pre_pair_16" |
| 2257 |
[(set (match_operand 0 "pmode_register_operand" "=&rk") |
| 2258 |
(match_operator 6 "pmode_plus_operator" [ |
| 2259 |
(match_operand 1 "pmode_register_operand" "0") |
| 2260 |
(match_operand 4 "const_int_operand") |
| 2261 |
])) |
| 2262 |
(set (match_operator:TI 7 "aarch64_mem_pair_operator" [ |
| 2263 |
(match_operator 8 "pmode_plus_operator" [ |
| 2264 |
(match_dup 0) |
| 2265 |
(match_dup 4) |
| 2266 |
])]) |
| 2267 |
(match_operand:TI 2 "aarch64_ldp_reg_operand" "w")) |
| 2268 |
(set (match_operator:TI 9 "aarch64_mem_pair_operator" [ |
| 2269 |
(match_operator 10 "pmode_plus_operator" [ |
| 2270 |
(match_dup 0) |
| 2271 |
(match_operand 5 "const_int_operand") |
| 2272 |
])]) |
| 2273 |
(match_operand:TI 3 "aarch64_ldp_reg_operand" "w"))] |
| 2274 |
"TARGET_FLOAT |
| 2275 |
&& aarch64_mem_pair_offset (operands[4], TImode) |
| 2276 |
&& known_eq (INTVAL (operands[5]), INTVAL (operands[4]) + 16) |
| 2277 |
&& !reg_overlap_mentioned_p (operands[0], operands[2]) |
| 2278 |
&& !reg_overlap_mentioned_p (operands[0], operands[3])" |
| 2279 |
"stp\\t%q2, %q3, [%0, %4]!" |
| 2280 |
[(set_attr "type" "neon_stp_q")] |
| 2281 |
) |
| 2282 |
|
| 2283 |
;; Store pair with post-index writeback. |
| 2284 |
(define_insn "*storewb_post_pair_<ldst_sz>" |
| 2285 |
[(set (match_operand 0 "pmode_register_operand") |
| 2286 |
(match_operator 5 "pmode_plus_operator" [ |
| 2287 |
(match_operand 1 "pmode_register_operand") |
| 2288 |
(match_operand 4 "const_int_operand") |
| 2289 |
])) |
| 2290 |
(set (match_operator:GPI 6 "aarch64_mem_pair_operator" [(match_dup 1)]) |
| 2291 |
(match_operand 2 "aarch64_stp_reg_operand")) |
| 2292 |
(set (match_operator:GPI 7 "aarch64_mem_pair_operator" [ |
| 2293 |
(match_operator 8 "pmode_plus_operator" [ |
| 2294 |
(match_dup 0) |
| 2295 |
(const_int <ldst_sz>) |
| 2296 |
])]) |
| 2297 |
(match_operand 3 "aarch64_stp_reg_operand"))] |
| 2298 |
"aarch64_mem_pair_offset (operands[4], <MODE>mode) |
| 2299 |
&& !reg_overlap_mentioned_p (operands[0], operands[2]) |
| 2300 |
&& !reg_overlap_mentioned_p (operands[0], operands[3])" |
| 2301 |
{@ [cons: =0, 1, 2, 3; attrs: type ] |
| 2302 |
[ rk, 0, rYZ, rYZ; store_<ldpstp_sz>] stp\t%<w>2, %<w>3, [%0], %4 |
| 2303 |
[ rk, 0, w, w; neon_store1_2reg ] stp\t%<v>2, %<v>3, [%0], %4 |
| 2304 |
} |
| 2305 |
) |
| 2306 |
|
| 2307 |
;; Store pair with post-index writeback. |
| 2308 |
(define_insn "*storewb_post_pair_16" |
| 2309 |
[(set (match_operand 0 "pmode_register_operand" "=rk") |
| 2310 |
(match_operator 5 "pmode_plus_operator" [ |
| 2311 |
(match_operand 1 "pmode_register_operand" "0") |
| 2312 |
(match_operand 4 "const_int_operand") |
| 2313 |
])) |
| 2314 |
(set (match_operator:TI 6 "aarch64_mem_pair_operator" [(match_dup 1)]) |
| 2315 |
(match_operand:TI 2 "aarch64_ldp_reg_operand" "w")) |
| 2316 |
(set (match_operator:TI 7 "aarch64_mem_pair_operator" [ |
| 2317 |
(match_operator 8 "pmode_plus_operator" [ |
| 2318 |
(match_dup 0) |
| 2319 |
(const_int 16) |
| 2320 |
])]) |
| 2321 |
(match_operand:TI 3 "aarch64_ldp_reg_operand" "w"))] |
| 2322 |
"TARGET_FLOAT |
| 2323 |
&& aarch64_mem_pair_offset (operands[4], TImode) |
| 2324 |
&& !reg_overlap_mentioned_p (operands[0], operands[2]) |
| 2325 |
&& !reg_overlap_mentioned_p (operands[0], operands[3])" |
| 2326 |
"stp\t%q2, %q3, [%0], %4" |
| 2327 |
[(set_attr "type" "neon_stp_q")] |
| 2328 |
) |
| 2329 |
|
| 2330 |
;; ------------------------------------------------------------------- |
| 2331 |
;; Sign/Zero extension |
| 2332 |
;; ------------------------------------------------------------------- |
| 2333 |
|
| 2334 |
(define_expand "<optab>sidi2" |
| 2335 |
[(set (match_operand:DI 0 "register_operand") |
| 2336 |
(ANY_EXTEND:DI (match_operand:SI 1 "nonimmediate_operand")))] |
| 2337 |
"" |
| 2338 |
) |
| 2339 |
|
| 2340 |
(define_insn "*extendsidi2_aarch64" |
| 2341 |
[(set (match_operand:DI 0 "register_operand") |
| 2342 |
(sign_extend:DI (match_operand:SI 1 "nonimmediate_operand")))] |
| 2343 |
"" |
| 2344 |
{@ [ cons: =0 , 1 ; attrs: type ] |
| 2345 |
[ r , r ; extend ] sxtw\t%0, %w1 |
| 2346 |
[ r , m ; load_4 ] ldrsw\t%0, %1 |
| 2347 |
} |
| 2348 |
) |
| 2349 |
|
| 2350 |
(define_insn "*load_pair_extendsidi2_aarch64" |
| 2351 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 2352 |
(sign_extend:DI (unspec:SI [ |
| 2353 |
(match_operand:V2x4QI 1 "aarch64_mem_pair_lanes_operand" "Umn") |
| 2354 |
] UNSPEC_LDP_FST))) |
| 2355 |
(set (match_operand:DI 2 "register_operand" "=r") |
| 2356 |
(sign_extend:DI (unspec:SI [ |
| 2357 |
(match_dup 1) |
| 2358 |
] UNSPEC_LDP_SND)))] |
| 2359 |
"" |
| 2360 |
"ldpsw\\t%0, %2, %y1" |
| 2361 |
[(set_attr "type" "load_8")] |
| 2362 |
) |
| 2363 |
|
| 2364 |
(define_insn "*zero_extendsidi2_aarch64" |
| 2365 |
[(set (match_operand:DI 0 "register_operand") |
| 2366 |
(zero_extend:DI (match_operand:SI 1 "nonimmediate_operand")))] |
| 2367 |
"" |
| 2368 |
{@ [ cons: =0 , 1 ; attrs: type , arch ] |
| 2369 |
[ r , r ; mov_reg , * ] uxtw\t%0, %w1 |
| 2370 |
[ r , m ; load_4 , * ] ldr\t%w0, %1 |
| 2371 |
[ w , r ; f_mcr , fp ] fmov\t%s0, %w1 |
| 2372 |
[ w , m ; f_loads , fp ] ldr\t%s0, %1 |
| 2373 |
[ r , w ; f_mrc , fp ] fmov\t%w0, %s1 |
| 2374 |
[ w , w ; fmov , fp ] fmov\t%s0, %s1 |
| 2375 |
} |
| 2376 |
) |
| 2377 |
|
| 2378 |
(define_insn "*load_pair_zero_extendsidi2_aarch64" |
| 2379 |
[(set (match_operand:DI 0 "register_operand") |
| 2380 |
(zero_extend:DI (unspec:SI [ |
| 2381 |
(match_operand:V2x4QI 1 "aarch64_mem_pair_lanes_operand") |
| 2382 |
] UNSPEC_LDP_FST))) |
| 2383 |
(set (match_operand:DI 2 "register_operand") |
| 2384 |
(zero_extend:DI (unspec:SI [ |
| 2385 |
(match_dup 1) |
| 2386 |
] UNSPEC_LDP_SND)))] |
| 2387 |
"" |
| 2388 |
{@ [ cons: =0 , 1 , =2; attrs: type , arch] |
| 2389 |
[ r , Umn , r ; load_8 , * ] ldp\t%w0, %w2, %y1 |
| 2390 |
[ w , Umn , w ; neon_load1_2reg, fp ] ldp\t%s0, %s2, %y1 |
| 2391 |
} |
| 2392 |
) |
| 2393 |
|
| 2394 |
(define_expand "<ANY_EXTEND:optab><SHORT:mode><GPI:mode>2" |
| 2395 |
[(set (match_operand:GPI 0 "register_operand") |
| 2396 |
(ANY_EXTEND:GPI (match_operand:SHORT 1 "nonimmediate_operand")))] |
| 2397 |
"" |
| 2398 |
) |
| 2399 |
|
| 2400 |
(define_insn "*extend<SHORT:mode><GPI:mode>2_aarch64" |
| 2401 |
[(set (match_operand:GPI 0 "register_operand") |
| 2402 |
(sign_extend:GPI (match_operand:SHORT 1 "nonimmediate_operand")))] |
| 2403 |
"" |
| 2404 |
{@ [ cons: =0 , 1 ; attrs: type , arch ] |
| 2405 |
[ r , r ; extend , * ] sxt<SHORT:size>\t%<GPI:w>0, %w1 |
| 2406 |
[ r , m ; load_4 , * ] ldrs<SHORT:size>\t%<GPI:w>0, %1 |
| 2407 |
[ r , w ; neon_to_gp , fp ] smov\t%<GPI:w>0, %1.<SHORT:size>[0] |
| 2408 |
} |
| 2409 |
) |
| 2410 |
|
| 2411 |
(define_insn "*zero_extend<SHORT:mode><GPI:mode>2_aarch64" |
| 2412 |
[(set (match_operand:GPI 0 "register_operand") |
| 2413 |
(zero_extend:GPI (match_operand:SHORT 1 "nonimmediate_operand")))] |
| 2414 |
"" |
| 2415 |
{@ [ cons: =0 , 1 ; attrs: type , arch ] |
| 2416 |
[ r , r ; logic_imm , * ] and\t%<GPI:w>0, %<GPI:w>1, <SHORT:short_mask> |
| 2417 |
[ r , m ; load_4 , * ] ldr<SHORT:size>\t%w0, %1 |
| 2418 |
[ w , m ; f_loads , fp ] ldr\t%<SHORT:size>0, %1 |
| 2419 |
[ r , w ; neon_to_gp , fp ] umov\t%w0, %1.<SHORT:size>[0] |
| 2420 |
} |
| 2421 |
) |
| 2422 |
|
| 2423 |
(define_expand "<optab>qihi2" |
| 2424 |
[(set (match_operand:HI 0 "register_operand") |
| 2425 |
(ANY_EXTEND:HI (match_operand:QI 1 "nonimmediate_operand")))] |
| 2426 |
"" |
| 2427 |
) |
| 2428 |
|
| 2429 |
(define_insn "*extendqihi2_aarch64" |
| 2430 |
[(set (match_operand:HI 0 "register_operand") |
| 2431 |
(sign_extend:HI (match_operand:QI 1 "nonimmediate_operand")))] |
| 2432 |
"" |
| 2433 |
{@ [ cons: =0 , 1 ; attrs: type ] |
| 2434 |
[ r , r ; extend ] sxtb\t%w0, %w1 |
| 2435 |
[ r , m ; load_4 ] ldrsb\t%w0, %1 |
| 2436 |
} |
| 2437 |
) |
| 2438 |
|
| 2439 |
(define_insn "*zero_extendqihi2_aarch64" |
| 2440 |
[(set (match_operand:HI 0 "register_operand") |
| 2441 |
(zero_extend:HI (match_operand:QI 1 "nonimmediate_operand")))] |
| 2442 |
"" |
| 2443 |
{@ [ cons: =0 , 1 ; attrs: type ] |
| 2444 |
[ r , r ; logic_imm ] and\t%w0, %w1, 255 |
| 2445 |
[ r , m ; load_4 ] ldrb\t%w0, %1 |
| 2446 |
} |
| 2447 |
) |
| 2448 |
|
| 2449 |
;; ------------------------------------------------------------------- |
| 2450 |
;; Simple arithmetic |
| 2451 |
;; ------------------------------------------------------------------- |
| 2452 |
|
| 2453 |
(define_expand "add<mode>3" |
| 2454 |
[(set |
| 2455 |
(match_operand:GPI 0 "register_operand") |
| 2456 |
(plus:GPI (match_operand:GPI 1 "register_operand") |
| 2457 |
(match_operand:GPI 2 "aarch64_pluslong_or_poly_operand")))] |
| 2458 |
"" |
| 2459 |
{ |
| 2460 |
/* If operands[1] is a subreg extract the inner RTX. */ |
| 2461 |
rtx op1 = REG_P (operands[1]) ? operands[1] : SUBREG_REG (operands[1]); |
| 2462 |
|
| 2463 |
/* If the constant is too large for a single instruction and isn't frame |
| 2464 |
based, split off the immediate so it is available for CSE. */ |
| 2465 |
if (!aarch64_plus_immediate (operands[2], <MODE>mode) |
| 2466 |
&& !(TARGET_SVE && aarch64_sve_plus_immediate (operands[2], <MODE>mode)) |
| 2467 |
&& can_create_pseudo_p () |
| 2468 |
&& (!REG_P (op1) |
| 2469 |
|| !REGNO_PTR_FRAME_P (REGNO (op1)))) |
| 2470 |
operands[2] = force_reg (<MODE>mode, operands[2]); |
| 2471 |
/* Some tunings prefer to avoid VL-based operations. |
| 2472 |
Split off the poly immediate here. The rtx costs hook will reject attempts |
| 2473 |
to combine them back. */ |
| 2474 |
else if (GET_CODE (operands[2]) == CONST_POLY_INT |
| 2475 |
&& can_create_pseudo_p () |
| 2476 |
&& (aarch64_tune_params.extra_tuning_flags |
| 2477 |
& AARCH64_EXTRA_TUNE_CSE_SVE_VL_CONSTANTS)) |
| 2478 |
operands[2] = force_reg (<MODE>mode, operands[2]); |
| 2479 |
/* Expand polynomial additions now if the destination is the stack |
| 2480 |
pointer, since we don't want to use that as a temporary. */ |
| 2481 |
else if (operands[0] == stack_pointer_rtx |
| 2482 |
&& aarch64_split_add_offset_immediate (operands[2], <MODE>mode)) |
| 2483 |
{ |
| 2484 |
aarch64_split_add_offset (<MODE>mode, operands[0], operands[1], |
| 2485 |
operands[2], NULL_RTX, NULL_RTX); |
| 2486 |
DONE; |
| 2487 |
} |
| 2488 |
}) |
| 2489 |
|
| 2490 |
(define_insn "*add<mode>3_aarch64" |
| 2491 |
[(set |
| 2492 |
(match_operand:GPI 0 "register_operand") |
| 2493 |
(plus:GPI |
| 2494 |
(match_operand:GPI 1 "register_operand") |
| 2495 |
(match_operand:GPI 2 "aarch64_pluslong_operand")))] |
| 2496 |
"" |
| 2497 |
{@ [ cons: =0 , %1 , 2 ; attrs: type , arch ] |
| 2498 |
[ rk , rk , I ; alu_imm , * ] add\t%<w>0, %<w>1, %2 |
| 2499 |
[ rk , rk , r ; alu_sreg , * ] add\t%<w>0, %<w>1, %<w>2 |
| 2500 |
[ w , w , w ; neon_add , simd ] add\t%<rtn>0<vas>, %<rtn>1<vas>, %<rtn>2<vas> |
| 2501 |
[ rk , rk , J ; alu_imm , * ] sub\t%<w>0, %<w>1, #%n2 |
| 2502 |
[ r , rk , Uaa ; multiple , * ] # |
| 2503 |
[ r , 0 , Uai ; alu_imm , sve ] << aarch64_output_sve_scalar_inc_dec (operands[2]); |
| 2504 |
[ rk , rk , Uav ; alu_imm , sve ] << aarch64_output_sve_addvl_addpl (operands[2]); |
| 2505 |
[ rk , rk , UaV ; alu_imm , sme ] << aarch64_output_addsvl_addspl (operands[2]); |
| 2506 |
} |
| 2507 |
;; The "alu_imm" types for INC/DEC and ADDVL/ADDPL are just placeholders. |
| 2508 |
) |
| 2509 |
|
| 2510 |
;; zero_extend version of above |
| 2511 |
(define_insn "*addsi3_aarch64_uxtw" |
| 2512 |
[(set |
| 2513 |
(match_operand:DI 0 "register_operand") |
| 2514 |
(zero_extend:DI |
| 2515 |
(plus:SI (match_operand:SI 1 "register_operand") |
| 2516 |
(match_operand:SI 2 "aarch64_pluslong_operand"))))] |
| 2517 |
"" |
| 2518 |
{@ [ cons: =0 , %1 , 2 ; attrs: type ] |
| 2519 |
[ rk , rk , I ; alu_imm ] add\t%w0, %w1, %2 |
| 2520 |
[ rk , rk , r ; alu_sreg ] add\t%w0, %w1, %w2 |
| 2521 |
[ rk , rk , J ; alu_imm ] sub\t%w0, %w1, #%n2 |
| 2522 |
[ r , rk , Uaa ; multiple ] # |
| 2523 |
} |
| 2524 |
) |
| 2525 |
|
| 2526 |
;; If there's a free register, and we can load the constant with a |
| 2527 |
;; single instruction, do so. This has a chance to improve scheduling. |
| 2528 |
(define_peephole2 |
| 2529 |
[(match_scratch:GPI 3 "r") |
| 2530 |
(set (match_operand:GPI 0 "register_operand") |
| 2531 |
(plus:GPI |
| 2532 |
(match_operand:GPI 1 "register_operand") |
| 2533 |
(match_operand:GPI 2 "aarch64_pluslong_strict_immedate")))] |
| 2534 |
"aarch64_move_imm (INTVAL (operands[2]), <MODE>mode)" |
| 2535 |
[(set (match_dup 3) (match_dup 2)) |
| 2536 |
(set (match_dup 0) (plus:GPI (match_dup 1) (match_dup 3)))] |
| 2537 |
) |
| 2538 |
|
| 2539 |
(define_peephole2 |
| 2540 |
[(match_scratch:SI 3 "r") |
| 2541 |
(set (match_operand:DI 0 "register_operand") |
| 2542 |
(zero_extend:DI |
| 2543 |
(plus:SI |
| 2544 |
(match_operand:SI 1 "register_operand") |
| 2545 |
(match_operand:SI 2 "aarch64_pluslong_strict_immedate"))))] |
| 2546 |
"aarch64_move_imm (INTVAL (operands[2]), SImode)" |
| 2547 |
[(set (match_dup 3) (match_dup 2)) |
| 2548 |
(set (match_dup 0) (zero_extend:DI (plus:SI (match_dup 1) (match_dup 3))))] |
| 2549 |
) |
| 2550 |
|
| 2551 |
;; After peephole2 has had a chance to run, split any remaining long |
| 2552 |
;; additions into two add immediates. |
| 2553 |
(define_split |
| 2554 |
[(set (match_operand:GPI 0 "register_operand") |
| 2555 |
(plus:GPI |
| 2556 |
(match_operand:GPI 1 "register_operand") |
| 2557 |
(match_operand:GPI 2 "aarch64_pluslong_strict_immedate")))] |
| 2558 |
"epilogue_completed" |
| 2559 |
[(set (match_dup 0) (plus:GPI (match_dup 1) (match_dup 3))) |
| 2560 |
(set (match_dup 0) (plus:GPI (match_dup 0) (match_dup 4)))] |
| 2561 |
{ |
| 2562 |
HOST_WIDE_INT i = INTVAL (operands[2]); |
| 2563 |
HOST_WIDE_INT s = (i >= 0 ? i & 0xfff : -(-i & 0xfff)); |
| 2564 |
operands[3] = GEN_INT (i - s); |
| 2565 |
operands[4] = GEN_INT (s); |
| 2566 |
} |
| 2567 |
) |
| 2568 |
|
| 2569 |
;; Match addition of polynomial offsets that require one temporary, for which |
| 2570 |
;; we can use the early-clobbered destination register. This is a separate |
| 2571 |
;; pattern so that the early clobber doesn't affect register allocation |
| 2572 |
;; for other forms of addition. However, we still need to provide an |
| 2573 |
;; all-register alternative, in case the offset goes out of range after |
| 2574 |
;; elimination. For completeness we might as well provide all GPR-based |
| 2575 |
;; alternatives from the main pattern. |
| 2576 |
;; |
| 2577 |
;; We don't have a pattern for additions requiring two temporaries since at |
| 2578 |
;; present LRA doesn't allow new scratches to be added during elimination. |
| 2579 |
;; Such offsets should be rare anyway. |
| 2580 |
;; |
| 2581 |
;; ??? But if we added LRA support for new scratches, much of the ugliness |
| 2582 |
;; here would go away. We could just handle all polynomial constants in |
| 2583 |
;; this pattern. |
| 2584 |
(define_insn_and_split "*add<mode>3_poly_1" |
| 2585 |
[(set |
| 2586 |
(match_operand:GPI 0 "register_operand") |
| 2587 |
(plus:GPI |
| 2588 |
(match_operand:GPI 1 "register_operand") |
| 2589 |
(match_operand:GPI 2 "aarch64_pluslong_or_poly_operand")))] |
| 2590 |
"TARGET_SVE && operands[0] != stack_pointer_rtx" |
| 2591 |
{@ [ cons: =0 , %1 , 2 ; attrs: type ] |
| 2592 |
[ r , rk , I ; alu_imm ] add\t%<w>0, %<w>1, %2 |
| 2593 |
[ r , rk , r ; alu_sreg ] add\t%<w>0, %<w>1, %<w>2 |
| 2594 |
[ r , rk , J ; alu_imm ] sub\t%<w>0, %<w>1, #%n2 |
| 2595 |
[ r , rk , Uaa ; multiple ] # |
| 2596 |
[ r , 0 , Uai ; alu_imm ] << aarch64_output_sve_scalar_inc_dec (operands[2]); |
| 2597 |
[ r , rk , Uav ; alu_imm ] << aarch64_output_sve_addvl_addpl (operands[2]); |
| 2598 |
[ &r , rk , Uat ; multiple ] # |
| 2599 |
} |
| 2600 |
"&& epilogue_completed |
| 2601 |
&& !reg_overlap_mentioned_p (operands[0], operands[1]) |
| 2602 |
&& aarch64_split_add_offset_immediate (operands[2], <MODE>mode)" |
| 2603 |
[(const_int 0)] |
| 2604 |
{ |
| 2605 |
aarch64_split_add_offset (<MODE>mode, operands[0], operands[1], |
| 2606 |
operands[2], operands[0], NULL_RTX); |
| 2607 |
DONE; |
| 2608 |
} |
| 2609 |
;; The "alu_imm" types for INC/DEC and ADDVL/ADDPL are just placeholders. |
| 2610 |
) |
| 2611 |
|
| 2612 |
(define_split |
| 2613 |
[(set (match_operand:DI 0 "register_operand") |
| 2614 |
(zero_extend:DI |
| 2615 |
(plus:SI |
| 2616 |
(match_operand:SI 1 "register_operand") |
| 2617 |
(match_operand:SI 2 "aarch64_pluslong_strict_immedate"))))] |
| 2618 |
"epilogue_completed" |
| 2619 |
[(set (match_dup 5) (plus:SI (match_dup 1) (match_dup 3))) |
| 2620 |
(set (match_dup 0) (zero_extend:DI (plus:SI (match_dup 5) (match_dup 4))))] |
| 2621 |
{ |
| 2622 |
HOST_WIDE_INT i = INTVAL (operands[2]); |
| 2623 |
HOST_WIDE_INT s = (i >= 0 ? i & 0xfff : -(-i & 0xfff)); |
| 2624 |
operands[3] = GEN_INT (i - s); |
| 2625 |
operands[4] = GEN_INT (s); |
| 2626 |
operands[5] = gen_lowpart (SImode, operands[0]); |
| 2627 |
} |
| 2628 |
) |
| 2629 |
|
| 2630 |
(define_expand "addv<mode>4" |
| 2631 |
[(match_operand:GPI 0 "register_operand") |
| 2632 |
(match_operand:GPI 1 "register_operand") |
| 2633 |
(match_operand:GPI 2 "aarch64_plus_operand") |
| 2634 |
(label_ref (match_operand 3 "" ""))] |
| 2635 |
"" |
| 2636 |
{ |
| 2637 |
if (CONST_INT_P (operands[2])) |
| 2638 |
emit_insn (gen_add<mode>3_compareV_imm (operands[0], operands[1], |
| 2639 |
operands[2])); |
| 2640 |
else |
| 2641 |
emit_insn (gen_add<mode>3_compareV (operands[0], operands[1], operands[2])); |
| 2642 |
aarch64_gen_unlikely_cbranch (NE, CC_Vmode, operands[3]); |
| 2643 |
|
| 2644 |
DONE; |
| 2645 |
}) |
| 2646 |
|
| 2647 |
(define_expand "uaddv<mode>4" |
| 2648 |
[(match_operand:GPI 0 "register_operand") |
| 2649 |
(match_operand:GPI 1 "register_operand") |
| 2650 |
(match_operand:GPI 2 "register_operand") |
| 2651 |
(label_ref (match_operand 3 "" ""))] |
| 2652 |
"" |
| 2653 |
{ |
| 2654 |
emit_insn (gen_add<mode>3_compareC (operands[0], operands[1], operands[2])); |
| 2655 |
aarch64_gen_unlikely_cbranch (LTU, CC_Cmode, operands[3]); |
| 2656 |
|
| 2657 |
DONE; |
| 2658 |
}) |
| 2659 |
|
| 2660 |
(define_expand "addti3" |
| 2661 |
[(set (match_operand:TI 0 "register_operand") |
| 2662 |
(plus:TI (match_operand:TI 1 "register_operand") |
| 2663 |
(match_operand:TI 2 "aarch64_reg_or_imm")))] |
| 2664 |
"" |
| 2665 |
{ |
| 2666 |
rtx low_dest, op1_low, op2_low, high_dest, op1_high, op2_high; |
| 2667 |
|
| 2668 |
aarch64_addti_scratch_regs (operands[1], operands[2], |
| 2669 |
&low_dest, &op1_low, &op2_low, |
| 2670 |
&high_dest, &op1_high, &op2_high); |
| 2671 |
|
| 2672 |
if (op2_low == const0_rtx) |
| 2673 |
{ |
| 2674 |
low_dest = op1_low; |
| 2675 |
if (!aarch64_pluslong_operand (op2_high, DImode)) |
| 2676 |
op2_high = force_reg (DImode, op2_high); |
| 2677 |
emit_insn (gen_adddi3 (high_dest, op1_high, op2_high)); |
| 2678 |
} |
| 2679 |
else |
| 2680 |
{ |
| 2681 |
emit_insn (gen_adddi3_compareC (low_dest, op1_low, |
| 2682 |
force_reg (DImode, op2_low))); |
| 2683 |
emit_insn (gen_adddi3_carryin (high_dest, op1_high, |
| 2684 |
force_reg (DImode, op2_high))); |
| 2685 |
} |
| 2686 |
|
| 2687 |
emit_move_insn (gen_lowpart (DImode, operands[0]), low_dest); |
| 2688 |
emit_move_insn (gen_highpart (DImode, operands[0]), high_dest); |
| 2689 |
|
| 2690 |
DONE; |
| 2691 |
}) |
| 2692 |
|
| 2693 |
(define_expand "addvti4" |
| 2694 |
[(match_operand:TI 0 "register_operand") |
| 2695 |
(match_operand:TI 1 "register_operand") |
| 2696 |
(match_operand:TI 2 "aarch64_reg_or_imm") |
| 2697 |
(label_ref (match_operand 3 "" ""))] |
| 2698 |
"" |
| 2699 |
{ |
| 2700 |
rtx low_dest, op1_low, op2_low, high_dest, op1_high, op2_high; |
| 2701 |
|
| 2702 |
aarch64_addti_scratch_regs (operands[1], operands[2], |
| 2703 |
&low_dest, &op1_low, &op2_low, |
| 2704 |
&high_dest, &op1_high, &op2_high); |
| 2705 |
|
| 2706 |
if (op2_low == const0_rtx) |
| 2707 |
{ |
| 2708 |
low_dest = op1_low; |
| 2709 |
emit_insn (gen_adddi3_compareV (high_dest, op1_high, |
| 2710 |
force_reg (DImode, op2_high))); |
| 2711 |
} |
| 2712 |
else |
| 2713 |
{ |
| 2714 |
emit_insn (gen_adddi3_compareC (low_dest, op1_low, |
| 2715 |
force_reg (DImode, op2_low))); |
| 2716 |
emit_insn (gen_adddi3_carryinV (high_dest, op1_high, |
| 2717 |
force_reg (DImode, op2_high))); |
| 2718 |
} |
| 2719 |
|
| 2720 |
emit_move_insn (gen_lowpart (DImode, operands[0]), low_dest); |
| 2721 |
emit_move_insn (gen_highpart (DImode, operands[0]), high_dest); |
| 2722 |
|
| 2723 |
aarch64_gen_unlikely_cbranch (NE, CC_Vmode, operands[3]); |
| 2724 |
DONE; |
| 2725 |
}) |
| 2726 |
|
| 2727 |
(define_expand "uaddvti4" |
| 2728 |
[(match_operand:TI 0 "register_operand") |
| 2729 |
(match_operand:TI 1 "register_operand") |
| 2730 |
(match_operand:TI 2 "aarch64_reg_or_imm") |
| 2731 |
(label_ref (match_operand 3 "" ""))] |
| 2732 |
"" |
| 2733 |
{ |
| 2734 |
rtx low_dest, op1_low, op2_low, high_dest, op1_high, op2_high; |
| 2735 |
|
| 2736 |
aarch64_addti_scratch_regs (operands[1], operands[2], |
| 2737 |
&low_dest, &op1_low, &op2_low, |
| 2738 |
&high_dest, &op1_high, &op2_high); |
| 2739 |
|
| 2740 |
if (op2_low == const0_rtx) |
| 2741 |
{ |
| 2742 |
low_dest = op1_low; |
| 2743 |
emit_insn (gen_adddi3_compareC (high_dest, op1_high, |
| 2744 |
force_reg (DImode, op2_high))); |
| 2745 |
} |
| 2746 |
else |
| 2747 |
{ |
| 2748 |
emit_insn (gen_adddi3_compareC (low_dest, op1_low, |
| 2749 |
force_reg (DImode, op2_low))); |
| 2750 |
emit_insn (gen_adddi3_carryinC (high_dest, op1_high, |
| 2751 |
force_reg (DImode, op2_high))); |
| 2752 |
} |
| 2753 |
|
| 2754 |
emit_move_insn (gen_lowpart (DImode, operands[0]), low_dest); |
| 2755 |
emit_move_insn (gen_highpart (DImode, operands[0]), high_dest); |
| 2756 |
|
| 2757 |
aarch64_gen_unlikely_cbranch (GEU, CC_ADCmode, operands[3]); |
| 2758 |
DONE; |
| 2759 |
}) |
| 2760 |
|
| 2761 |
(define_insn "add<mode>3_compare0" |
| 2762 |
[(set (reg:CC_NZ CC_REGNUM) |
| 2763 |
(compare:CC_NZ |
| 2764 |
(plus:GPI (match_operand:GPI 1 "register_operand") |
| 2765 |
(match_operand:GPI 2 "aarch64_plus_operand")) |
| 2766 |
(const_int 0))) |
| 2767 |
(set (match_operand:GPI 0 "register_operand") |
| 2768 |
(plus:GPI (match_dup 1) (match_dup 2)))] |
| 2769 |
"" |
| 2770 |
{@ [ cons: =0 , %1 , 2 ; attrs: type ] |
| 2771 |
[ r , rk , r ; alus_sreg ] adds\t%<w>0, %<w>1, %<w>2 |
| 2772 |
[ r , rk , I ; alus_imm ] adds\t%<w>0, %<w>1, %2 |
| 2773 |
[ r , rk , J ; alus_imm ] subs\t%<w>0, %<w>1, #%n2 |
| 2774 |
} |
| 2775 |
) |
| 2776 |
|
| 2777 |
;; zero_extend version of above |
| 2778 |
(define_insn "*addsi3_compare0_uxtw" |
| 2779 |
[(set (reg:CC_NZ CC_REGNUM) |
| 2780 |
(compare:CC_NZ |
| 2781 |
(plus:SI (match_operand:SI 1 "register_operand") |
| 2782 |
(match_operand:SI 2 "aarch64_plus_operand")) |
| 2783 |
(const_int 0))) |
| 2784 |
(set (match_operand:DI 0 "register_operand") |
| 2785 |
(zero_extend:DI (plus:SI (match_dup 1) (match_dup 2))))] |
| 2786 |
"" |
| 2787 |
{@ [ cons: =0 , %1 , 2 ; attrs: type ] |
| 2788 |
[ r , rk , r ; alus_sreg ] adds\t%w0, %w1, %w2 |
| 2789 |
[ r , rk , I ; alus_imm ] adds\t%w0, %w1, %2 |
| 2790 |
[ r , rk , J ; alus_imm ] subs\t%w0, %w1, #%n2 |
| 2791 |
} |
| 2792 |
) |
| 2793 |
|
| 2794 |
(define_insn "*add<mode>3_compareC_cconly" |
| 2795 |
[(set (reg:CC_C CC_REGNUM) |
| 2796 |
(compare:CC_C |
| 2797 |
(plus:GPI |
| 2798 |
(match_operand:GPI 0 "register_operand") |
| 2799 |
(match_operand:GPI 1 "aarch64_plus_operand")) |
| 2800 |
(match_dup 0)))] |
| 2801 |
"" |
| 2802 |
{@ [ cons: 0 , 1 ; attrs: type ] |
| 2803 |
[ r , r ; alus_sreg ] cmn\t%<w>0, %<w>1 |
| 2804 |
[ r , I ; alus_imm ] cmn\t%<w>0, %1 |
| 2805 |
[ r , J ; alus_imm ] cmp\t%<w>0, #%n1 |
| 2806 |
} |
| 2807 |
) |
| 2808 |
|
| 2809 |
(define_insn "add<mode>3_compareC" |
| 2810 |
[(set (reg:CC_C CC_REGNUM) |
| 2811 |
(compare:CC_C |
| 2812 |
(plus:GPI |
| 2813 |
(match_operand:GPI 1 "register_operand") |
| 2814 |
(match_operand:GPI 2 "aarch64_plus_operand")) |
| 2815 |
(match_dup 1))) |
| 2816 |
(set (match_operand:GPI 0 "register_operand") |
| 2817 |
(plus:GPI (match_dup 1) (match_dup 2)))] |
| 2818 |
"" |
| 2819 |
{@ [ cons: =0 , 1 , 2 ; attrs: type ] |
| 2820 |
[ r , rk , r ; alus_sreg ] adds\t%<w>0, %<w>1, %<w>2 |
| 2821 |
[ r , rk , I ; alus_imm ] adds\t%<w>0, %<w>1, %2 |
| 2822 |
[ r , rk , J ; alus_imm ] subs\t%<w>0, %<w>1, #%n2 |
| 2823 |
} |
| 2824 |
) |
| 2825 |
|
| 2826 |
(define_insn "*add<mode>3_compareV_cconly_imm" |
| 2827 |
[(set (reg:CC_V CC_REGNUM) |
| 2828 |
(compare:CC_V |
| 2829 |
(plus:<DWI> |
| 2830 |
(sign_extend:<DWI> (match_operand:GPI 0 "register_operand")) |
| 2831 |
(match_operand:<DWI> 1 "const_scalar_int_operand")) |
| 2832 |
(sign_extend:<DWI> |
| 2833 |
(plus:GPI |
| 2834 |
(match_dup 0) |
| 2835 |
(match_operand:GPI 2 "aarch64_plus_immediate")))))] |
| 2836 |
"INTVAL (operands[1]) == INTVAL (operands[2])" |
| 2837 |
{@ [ cons: 0 , 2 ] |
| 2838 |
[ r , I ] cmn\t%<w>0, %<w>1 |
| 2839 |
[ r , J ] cmp\t%<w>0, #%n1 |
| 2840 |
} |
| 2841 |
[(set_attr "type" "alus_imm")] |
| 2842 |
) |
| 2843 |
|
| 2844 |
(define_insn "*add<mode>3_compareV_cconly" |
| 2845 |
[(set (reg:CC_V CC_REGNUM) |
| 2846 |
(compare:CC_V |
| 2847 |
(plus:<DWI> |
| 2848 |
(sign_extend:<DWI> (match_operand:GPI 0 "register_operand" "r")) |
| 2849 |
(sign_extend:<DWI> (match_operand:GPI 1 "register_operand" "r"))) |
| 2850 |
(sign_extend:<DWI> (plus:GPI (match_dup 0) (match_dup 1)))))] |
| 2851 |
"" |
| 2852 |
"cmn\\t%<w>0, %<w>1" |
| 2853 |
[(set_attr "type" "alus_sreg")] |
| 2854 |
) |
| 2855 |
|
| 2856 |
(define_insn "add<mode>3_compareV_imm" |
| 2857 |
[(set (reg:CC_V CC_REGNUM) |
| 2858 |
(compare:CC_V |
| 2859 |
(plus:<DWI> |
| 2860 |
(sign_extend:<DWI> |
| 2861 |
(match_operand:GPI 1 "register_operand")) |
| 2862 |
(match_operand:GPI 2 "aarch64_plus_immediate")) |
| 2863 |
(sign_extend:<DWI> |
| 2864 |
(plus:GPI (match_dup 1) (match_dup 2))))) |
| 2865 |
(set (match_operand:GPI 0 "register_operand") |
| 2866 |
(plus:GPI (match_dup 1) (match_dup 2)))] |
| 2867 |
"" |
| 2868 |
{@ [ cons: =0 , 1 , 2 ; attrs: type ] |
| 2869 |
[ r , rk , I ; alus_imm ] adds\t%<w>0, %<w>1, %<w>2 |
| 2870 |
[ r , rk , J ; alus_imm ] subs\t%<w>0, %<w>1, #%n2 |
| 2871 |
} |
| 2872 |
) |
| 2873 |
|
| 2874 |
(define_insn "add<mode>3_compareV" |
| 2875 |
[(set (reg:CC_V CC_REGNUM) |
| 2876 |
(compare:CC_V |
| 2877 |
(plus:<DWI> |
| 2878 |
(sign_extend:<DWI> (match_operand:GPI 1 "register_operand" "rk")) |
| 2879 |
(sign_extend:<DWI> (match_operand:GPI 2 "register_operand" "r"))) |
| 2880 |
(sign_extend:<DWI> (plus:GPI (match_dup 1) (match_dup 2))))) |
| 2881 |
(set (match_operand:GPI 0 "register_operand" "=r") |
| 2882 |
(plus:GPI (match_dup 1) (match_dup 2)))] |
| 2883 |
"" |
| 2884 |
"adds\\t%<w>0, %<w>1, %<w>2" |
| 2885 |
[(set_attr "type" "alus_sreg")] |
| 2886 |
) |
| 2887 |
|
| 2888 |
(define_insn "*adds_shift_imm_<mode>" |
| 2889 |
[(set (reg:CC_NZ CC_REGNUM) |
| 2890 |
(compare:CC_NZ |
| 2891 |
(plus:GPI (ASHIFT:GPI |
| 2892 |
(match_operand:GPI 1 "register_operand" "r") |
| 2893 |
(match_operand:QI 2 "aarch64_shift_imm_<mode>" "n")) |
| 2894 |
(match_operand:GPI 3 "register_operand" "r")) |
| 2895 |
(const_int 0))) |
| 2896 |
(set (match_operand:GPI 0 "register_operand" "=r") |
| 2897 |
(plus:GPI (ASHIFT:GPI (match_dup 1) (match_dup 2)) |
| 2898 |
(match_dup 3)))] |
| 2899 |
"" |
| 2900 |
"adds\\t%<w>0, %<w>3, %<w>1, <shift> %2" |
| 2901 |
[(set_attr "type" "alus_shift_imm")] |
| 2902 |
) |
| 2903 |
|
| 2904 |
(define_insn "*subs_shift_imm_<mode>" |
| 2905 |
[(set (reg:CC_NZ CC_REGNUM) |
| 2906 |
(compare:CC_NZ |
| 2907 |
(minus:GPI (match_operand:GPI 1 "register_operand" "r") |
| 2908 |
(ASHIFT:GPI |
| 2909 |
(match_operand:GPI 2 "register_operand" "r") |
| 2910 |
(match_operand:QI 3 "aarch64_shift_imm_<mode>" "n"))) |
| 2911 |
(const_int 0))) |
| 2912 |
(set (match_operand:GPI 0 "register_operand" "=r") |
| 2913 |
(minus:GPI (match_dup 1) |
| 2914 |
(ASHIFT:GPI (match_dup 2) (match_dup 3))))] |
| 2915 |
"" |
| 2916 |
"subs\\t%<w>0, %<w>1, %<w>2, <shift> %3" |
| 2917 |
[(set_attr "type" "alus_shift_imm")] |
| 2918 |
) |
| 2919 |
|
| 2920 |
(define_insn "*adds_<optab><ALLX:mode>_<GPI:mode>" |
| 2921 |
[(set (reg:CC_NZ CC_REGNUM) |
| 2922 |
(compare:CC_NZ |
| 2923 |
(plus:GPI |
| 2924 |
(ANY_EXTEND:GPI (match_operand:ALLX 1 "register_operand" "r")) |
| 2925 |
(match_operand:GPI 2 "register_operand" "rk")) |
| 2926 |
(const_int 0))) |
| 2927 |
(set (match_operand:GPI 0 "register_operand" "=r") |
| 2928 |
(plus:GPI (ANY_EXTEND:GPI (match_dup 1)) (match_dup 2)))] |
| 2929 |
"" |
| 2930 |
"adds\\t%<GPI:w>0, %<GPI:w>2, %w1, <su>xt<ALLX:size>" |
| 2931 |
[(set_attr "type" "alus_ext")] |
| 2932 |
) |
| 2933 |
|
| 2934 |
(define_insn "*subs_<optab><ALLX:mode>_<GPI:mode>" |
| 2935 |
[(set (reg:CC_NZ CC_REGNUM) |
| 2936 |
(compare:CC_NZ |
| 2937 |
(minus:GPI (match_operand:GPI 1 "register_operand" "rk") |
| 2938 |
(ANY_EXTEND:GPI |
| 2939 |
(match_operand:ALLX 2 "register_operand" "r"))) |
| 2940 |
(const_int 0))) |
| 2941 |
(set (match_operand:GPI 0 "register_operand" "=r") |
| 2942 |
(minus:GPI (match_dup 1) (ANY_EXTEND:GPI (match_dup 2))))] |
| 2943 |
"" |
| 2944 |
"subs\\t%<GPI:w>0, %<GPI:w>1, %w2, <su>xt<ALLX:size>" |
| 2945 |
[(set_attr "type" "alus_ext")] |
| 2946 |
) |
| 2947 |
|
| 2948 |
(define_insn "*adds_<optab><ALLX:mode>_shift_<GPI:mode>" |
| 2949 |
[(set (reg:CC_NZ CC_REGNUM) |
| 2950 |
(compare:CC_NZ |
| 2951 |
(plus:GPI (ashift:GPI |
| 2952 |
(ANY_EXTEND:GPI |
| 2953 |
(match_operand:ALLX 1 "register_operand" "r")) |
| 2954 |
(match_operand 2 "aarch64_imm3" "Ui3")) |
| 2955 |
(match_operand:GPI 3 "register_operand" "rk")) |
| 2956 |
(const_int 0))) |
| 2957 |
(set (match_operand:GPI 0 "register_operand" "=rk") |
| 2958 |
(plus:GPI (ashift:GPI (ANY_EXTEND:GPI (match_dup 1)) |
| 2959 |
(match_dup 2)) |
| 2960 |
(match_dup 3)))] |
| 2961 |
"" |
| 2962 |
"adds\\t%<GPI:w>0, %<GPI:w>3, %w1, <su>xt<ALLX:size> %2" |
| 2963 |
[(set_attr "type" "alus_ext")] |
| 2964 |
) |
| 2965 |
|
| 2966 |
(define_insn "*subs_<optab><ALLX:mode>_shift_<GPI:mode>" |
| 2967 |
[(set (reg:CC_NZ CC_REGNUM) |
| 2968 |
(compare:CC_NZ |
| 2969 |
(minus:GPI (match_operand:GPI 1 "register_operand" "rk") |
| 2970 |
(ashift:GPI |
| 2971 |
(ANY_EXTEND:GPI |
| 2972 |
(match_operand:ALLX 2 "register_operand" "r")) |
| 2973 |
(match_operand 3 "aarch64_imm3" "Ui3"))) |
| 2974 |
(const_int 0))) |
| 2975 |
(set (match_operand:GPI 0 "register_operand" "=rk") |
| 2976 |
(minus:GPI (match_dup 1) |
| 2977 |
(ashift:GPI (ANY_EXTEND:GPI (match_dup 2)) |
| 2978 |
(match_dup 3))))] |
| 2979 |
"" |
| 2980 |
"subs\\t%<GPI:w>0, %<GPI:w>1, %w2, <su>xt<ALLX:size> %3" |
| 2981 |
[(set_attr "type" "alus_ext")] |
| 2982 |
) |
| 2983 |
|
| 2984 |
(define_insn "*add<mode>3nr_compare0" |
| 2985 |
[(set (reg:CC_NZ CC_REGNUM) |
| 2986 |
(compare:CC_NZ |
| 2987 |
(plus:GPI (match_operand:GPI 0 "register_operand") |
| 2988 |
(match_operand:GPI 1 "aarch64_plus_operand")) |
| 2989 |
(const_int 0)))] |
| 2990 |
"" |
| 2991 |
{@ [ cons: %0 , 1 ; attrs: type ] |
| 2992 |
[ r , r ; alus_sreg ] cmn\t%<w>0, %<w>1 |
| 2993 |
[ r , I ; alus_imm ] cmn\t%<w>0, %1 |
| 2994 |
[ r , J ; alus_imm ] cmp\t%<w>0, #%n1 |
| 2995 |
} |
| 2996 |
) |
| 2997 |
|
| 2998 |
(define_insn "aarch64_sub<mode>_compare0" |
| 2999 |
[(set (reg:CC_NZ CC_REGNUM) |
| 3000 |
(compare:CC_NZ |
| 3001 |
(minus:GPI (match_operand:GPI 0 "register_operand" "r") |
| 3002 |
(match_operand:GPI 1 "aarch64_plus_operand" "r")) |
| 3003 |
(const_int 0)))] |
| 3004 |
"" |
| 3005 |
"cmp\\t%<w>0, %<w>1" |
| 3006 |
[(set_attr "type" "alus_sreg")] |
| 3007 |
) |
| 3008 |
|
| 3009 |
(define_insn "*compare_neg<mode>" |
| 3010 |
[(set (reg:CC_Z CC_REGNUM) |
| 3011 |
(compare:CC_Z |
| 3012 |
(neg:GPI (match_operand:GPI 0 "register_operand" "r")) |
| 3013 |
(match_operand:GPI 1 "register_operand" "r")))] |
| 3014 |
"" |
| 3015 |
"cmn\\t%<w>1, %<w>0" |
| 3016 |
[(set_attr "type" "alus_sreg")] |
| 3017 |
) |
| 3018 |
|
| 3019 |
(define_insn "*add_<shift>_<mode>" |
| 3020 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 3021 |
(plus:GPI (ASHIFT:GPI (match_operand:GPI 1 "register_operand" "r") |
| 3022 |
(match_operand:QI 2 "aarch64_shift_imm_<mode>" "n")) |
| 3023 |
(match_operand:GPI 3 "register_operand" "r")))] |
| 3024 |
"" |
| 3025 |
"add\\t%<w>0, %<w>3, %<w>1, <shift> %2" |
| 3026 |
[(set_attr "autodetect_type" "alu_shift_<shift>_op2")] |
| 3027 |
) |
| 3028 |
|
| 3029 |
;; zero_extend version of above |
| 3030 |
(define_insn "*add_<shift>_si_uxtw" |
| 3031 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 3032 |
(zero_extend:DI |
| 3033 |
(plus:SI (ASHIFT:SI (match_operand:SI 1 "register_operand" "r") |
| 3034 |
(match_operand:QI 2 "aarch64_shift_imm_si" "n")) |
| 3035 |
(match_operand:SI 3 "register_operand" "r"))))] |
| 3036 |
"" |
| 3037 |
"add\\t%w0, %w3, %w1, <shift> %2" |
| 3038 |
[(set_attr "autodetect_type" "alu_shift_<shift>_op2")] |
| 3039 |
) |
| 3040 |
|
| 3041 |
(define_insn "*add_<optab><ALLX:mode>_<GPI:mode>" |
| 3042 |
[(set (match_operand:GPI 0 "register_operand" "=rk") |
| 3043 |
(plus:GPI (ANY_EXTEND:GPI (match_operand:ALLX 1 "register_operand" "r")) |
| 3044 |
(match_operand:GPI 2 "register_operand" "r")))] |
| 3045 |
"" |
| 3046 |
"add\\t%<GPI:w>0, %<GPI:w>2, %w1, <su>xt<ALLX:size>" |
| 3047 |
[(set_attr "type" "alu_ext")] |
| 3048 |
) |
| 3049 |
|
| 3050 |
;; zero_extend version of above |
| 3051 |
(define_insn "*add_<optab><SHORT:mode>_si_uxtw" |
| 3052 |
[(set (match_operand:DI 0 "register_operand" "=rk") |
| 3053 |
(zero_extend:DI |
| 3054 |
(plus:SI (ANY_EXTEND:SI (match_operand:SHORT 1 "register_operand" "r")) |
| 3055 |
(match_operand:GPI 2 "register_operand" "r"))))] |
| 3056 |
"" |
| 3057 |
"add\\t%w0, %w2, %w1, <su>xt<SHORT:size>" |
| 3058 |
[(set_attr "type" "alu_ext")] |
| 3059 |
) |
| 3060 |
|
| 3061 |
(define_insn "*add_<optab><ALLX:mode>_shft_<GPI:mode>" |
| 3062 |
[(set (match_operand:GPI 0 "register_operand" "=rk") |
| 3063 |
(plus:GPI (ashift:GPI (ANY_EXTEND:GPI |
| 3064 |
(match_operand:ALLX 1 "register_operand" "r")) |
| 3065 |
(match_operand 2 "aarch64_imm3" "Ui3")) |
| 3066 |
(match_operand:GPI 3 "register_operand" "r")))] |
| 3067 |
"" |
| 3068 |
"add\\t%<GPI:w>0, %<GPI:w>3, %w1, <su>xt<ALLX:size> %2" |
| 3069 |
[(set_attr "type" "alu_ext")] |
| 3070 |
) |
| 3071 |
|
| 3072 |
;; zero_extend version of above |
| 3073 |
(define_insn "*add_<optab><SHORT:mode>_shft_si_uxtw" |
| 3074 |
[(set (match_operand:DI 0 "register_operand" "=rk") |
| 3075 |
(zero_extend:DI |
| 3076 |
(plus:SI (ashift:SI (ANY_EXTEND:SI |
| 3077 |
(match_operand:SHORT 1 "register_operand" "r")) |
| 3078 |
(match_operand 2 "aarch64_imm3" "Ui3")) |
| 3079 |
(match_operand:SI 3 "register_operand" "r"))))] |
| 3080 |
"" |
| 3081 |
"add\\t%w0, %w3, %w1, <su>xt<SHORT:size> %2" |
| 3082 |
[(set_attr "type" "alu_ext")] |
| 3083 |
) |
| 3084 |
|
| 3085 |
(define_expand "add<mode>3_carryin" |
| 3086 |
[(set (match_operand:GPI 0 "register_operand") |
| 3087 |
(plus:GPI |
| 3088 |
(plus:GPI |
| 3089 |
(ltu:GPI (reg:CC_C CC_REGNUM) (const_int 0)) |
| 3090 |
(match_operand:GPI 1 "aarch64_reg_or_zero")) |
| 3091 |
(match_operand:GPI 2 "aarch64_reg_or_zero")))] |
| 3092 |
"" |
| 3093 |
"" |
| 3094 |
) |
| 3095 |
|
| 3096 |
;; Note that add with carry with two zero inputs is matched by cset, |
| 3097 |
;; and that add with carry with one zero input is matched by cinc. |
| 3098 |
|
| 3099 |
(define_insn "*add<mode>3_carryin" |
| 3100 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 3101 |
(plus:GPI |
| 3102 |
(plus:GPI |
| 3103 |
(match_operand:GPI 3 "aarch64_carry_operation" "") |
| 3104 |
(match_operand:GPI 1 "register_operand" "r")) |
| 3105 |
(match_operand:GPI 2 "register_operand" "r")))] |
| 3106 |
"" |
| 3107 |
"adc\\t%<w>0, %<w>1, %<w>2" |
| 3108 |
[(set_attr "type" "adc_reg")] |
| 3109 |
) |
| 3110 |
|
| 3111 |
;; zero_extend version of above |
| 3112 |
(define_insn "*addsi3_carryin_uxtw" |
| 3113 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 3114 |
(zero_extend:DI |
| 3115 |
(plus:SI |
| 3116 |
(plus:SI |
| 3117 |
(match_operand:SI 3 "aarch64_carry_operation" "") |
| 3118 |
(match_operand:SI 1 "register_operand" "r")) |
| 3119 |
(match_operand:SI 2 "register_operand" "r"))))] |
| 3120 |
"" |
| 3121 |
"adc\\t%w0, %w1, %w2" |
| 3122 |
[(set_attr "type" "adc_reg")] |
| 3123 |
) |
| 3124 |
|
| 3125 |
(define_expand "add<mode>3_carryinC" |
| 3126 |
[(parallel |
| 3127 |
[(set (match_dup 3) |
| 3128 |
(compare:CC_ADC |
| 3129 |
(plus:<DWI> |
| 3130 |
(plus:<DWI> |
| 3131 |
(match_dup 4) |
| 3132 |
(zero_extend:<DWI> |
| 3133 |
(match_operand:GPI 1 "register_operand"))) |
| 3134 |
(zero_extend:<DWI> |
| 3135 |
(match_operand:GPI 2 "register_operand"))) |
| 3136 |
(match_dup 6))) |
| 3137 |
(set (match_operand:GPI 0 "register_operand") |
| 3138 |
(plus:GPI |
| 3139 |
(plus:GPI (match_dup 5) (match_dup 1)) |
| 3140 |
(match_dup 2)))])] |
| 3141 |
"" |
| 3142 |
{ |
| 3143 |
operands[3] = gen_rtx_REG (CC_ADCmode, CC_REGNUM); |
| 3144 |
rtx ccin = gen_rtx_REG (CC_Cmode, CC_REGNUM); |
| 3145 |
operands[4] = gen_rtx_LTU (<DWI>mode, ccin, const0_rtx); |
| 3146 |
operands[5] = gen_rtx_LTU (<MODE>mode, ccin, const0_rtx); |
| 3147 |
operands[6] = immed_wide_int_const (wi::shwi (1, <DWI>mode) |
| 3148 |
<< GET_MODE_BITSIZE (<MODE>mode), |
| 3149 |
TImode); |
| 3150 |
}) |
| 3151 |
|
| 3152 |
(define_insn "*add<mode>3_carryinC_zero" |
| 3153 |
[(set (reg:CC_ADC CC_REGNUM) |
| 3154 |
(compare:CC_ADC |
| 3155 |
(plus:<DWI> |
| 3156 |
(match_operand:<DWI> 2 "aarch64_carry_operation" "") |
| 3157 |
(zero_extend:<DWI> (match_operand:GPI 1 "register_operand" "r"))) |
| 3158 |
(match_operand 4 "const_scalar_int_operand" ""))) |
| 3159 |
(set (match_operand:GPI 0 "register_operand" "=r") |
| 3160 |
(plus:GPI (match_operand:GPI 3 "aarch64_carry_operation" "") |
| 3161 |
(match_dup 1)))] |
| 3162 |
"rtx_mode_t (operands[4], <DWI>mode) |
| 3163 |
== (wi::shwi (1, <DWI>mode) << (unsigned) GET_MODE_BITSIZE (<MODE>mode))" |
| 3164 |
"adcs\\t%<w>0, %<w>1, <w>zr" |
| 3165 |
[(set_attr "type" "adc_reg")] |
| 3166 |
) |
| 3167 |
|
| 3168 |
(define_insn "*add<mode>3_carryinC" |
| 3169 |
[(set (reg:CC_ADC CC_REGNUM) |
| 3170 |
(compare:CC_ADC |
| 3171 |
(plus:<DWI> |
| 3172 |
(plus:<DWI> |
| 3173 |
(match_operand:<DWI> 3 "aarch64_carry_operation" "") |
| 3174 |
(zero_extend:<DWI> (match_operand:GPI 1 "register_operand" "r"))) |
| 3175 |
(zero_extend:<DWI> (match_operand:GPI 2 "register_operand" "r"))) |
| 3176 |
(match_operand 5 "const_scalar_int_operand" ""))) |
| 3177 |
(set (match_operand:GPI 0 "register_operand" "=r") |
| 3178 |
(plus:GPI |
| 3179 |
(plus:GPI (match_operand:GPI 4 "aarch64_carry_operation" "") |
| 3180 |
(match_dup 1)) |
| 3181 |
(match_dup 2)))] |
| 3182 |
"rtx_mode_t (operands[5], <DWI>mode) |
| 3183 |
== (wi::shwi (1, <DWI>mode) << (unsigned) GET_MODE_BITSIZE (<MODE>mode))" |
| 3184 |
"adcs\\t%<w>0, %<w>1, %<w>2" |
| 3185 |
[(set_attr "type" "adc_reg")] |
| 3186 |
) |
| 3187 |
|
| 3188 |
(define_expand "add<mode>3_carryinV" |
| 3189 |
[(parallel |
| 3190 |
[(set (reg:CC_V CC_REGNUM) |
| 3191 |
(compare:CC_V |
| 3192 |
(plus:<DWI> |
| 3193 |
(plus:<DWI> |
| 3194 |
(match_dup 3) |
| 3195 |
(sign_extend:<DWI> |
| 3196 |
(match_operand:GPI 1 "register_operand"))) |
| 3197 |
(sign_extend:<DWI> |
| 3198 |
(match_operand:GPI 2 "register_operand"))) |
| 3199 |
(sign_extend:<DWI> |
| 3200 |
(plus:GPI |
| 3201 |
(plus:GPI (match_dup 4) (match_dup 1)) |
| 3202 |
(match_dup 2))))) |
| 3203 |
(set (match_operand:GPI 0 "register_operand") |
| 3204 |
(plus:GPI |
| 3205 |
(plus:GPI (match_dup 4) (match_dup 1)) |
| 3206 |
(match_dup 2)))])] |
| 3207 |
"" |
| 3208 |
{ |
| 3209 |
rtx cc = gen_rtx_REG (CC_Cmode, CC_REGNUM); |
| 3210 |
operands[3] = gen_rtx_LTU (<DWI>mode, cc, const0_rtx); |
| 3211 |
operands[4] = gen_rtx_LTU (<MODE>mode, cc, const0_rtx); |
| 3212 |
}) |
| 3213 |
|
| 3214 |
(define_insn "*add<mode>3_carryinV_zero" |
| 3215 |
[(set (reg:CC_V CC_REGNUM) |
| 3216 |
(compare:CC_V |
| 3217 |
(plus:<DWI> |
| 3218 |
(match_operand:<DWI> 2 "aarch64_carry_operation" "") |
| 3219 |
(sign_extend:<DWI> (match_operand:GPI 1 "register_operand" "r"))) |
| 3220 |
(sign_extend:<DWI> |
| 3221 |
(plus:GPI |
| 3222 |
(match_operand:GPI 3 "aarch64_carry_operation" "") |
| 3223 |
(match_dup 1))))) |
| 3224 |
(set (match_operand:GPI 0 "register_operand" "=r") |
| 3225 |
(plus:GPI (match_dup 3) (match_dup 1)))] |
| 3226 |
"" |
| 3227 |
"adcs\\t%<w>0, %<w>1, <w>zr" |
| 3228 |
[(set_attr "type" "adc_reg")] |
| 3229 |
) |
| 3230 |
|
| 3231 |
(define_insn "*add<mode>3_carryinV" |
| 3232 |
[(set (reg:CC_V CC_REGNUM) |
| 3233 |
(compare:CC_V |
| 3234 |
(plus:<DWI> |
| 3235 |
(plus:<DWI> |
| 3236 |
(match_operand:<DWI> 3 "aarch64_carry_operation" "") |
| 3237 |
(sign_extend:<DWI> (match_operand:GPI 1 "register_operand" "r"))) |
| 3238 |
(sign_extend:<DWI> (match_operand:GPI 2 "register_operand" "r"))) |
| 3239 |
(sign_extend:<DWI> |
| 3240 |
(plus:GPI |
| 3241 |
(plus:GPI |
| 3242 |
(match_operand:GPI 4 "aarch64_carry_operation" "") |
| 3243 |
(match_dup 1)) |
| 3244 |
(match_dup 2))))) |
| 3245 |
(set (match_operand:GPI 0 "register_operand" "=r") |
| 3246 |
(plus:GPI |
| 3247 |
(plus:GPI (match_dup 4) (match_dup 1)) |
| 3248 |
(match_dup 2)))] |
| 3249 |
"" |
| 3250 |
"adcs\\t%<w>0, %<w>1, %<w>2" |
| 3251 |
[(set_attr "type" "adc_reg")] |
| 3252 |
) |
| 3253 |
|
| 3254 |
(define_insn "*add_uxt<mode>_shift2" |
| 3255 |
[(set (match_operand:GPI 0 "register_operand" "=rk") |
| 3256 |
(plus:GPI (and:GPI |
| 3257 |
(ashift:GPI (match_operand:GPI 1 "register_operand" "r") |
| 3258 |
(match_operand 2 "aarch64_imm3" "Ui3")) |
| 3259 |
(match_operand 3 "const_int_operand" "n")) |
| 3260 |
(match_operand:GPI 4 "register_operand" "r")))] |
| 3261 |
"aarch64_uxt_size (INTVAL (operands[2]), INTVAL (operands[3])) != 0" |
| 3262 |
"* |
| 3263 |
operands[3] = GEN_INT (aarch64_uxt_size (INTVAL(operands[2]), |
| 3264 |
INTVAL (operands[3]))); |
| 3265 |
return \"add\t%<w>0, %<w>4, %w1, uxt%e3 %2\";" |
| 3266 |
[(set_attr "type" "alu_ext")] |
| 3267 |
) |
| 3268 |
|
| 3269 |
;; zero_extend version of above |
| 3270 |
(define_insn "*add_uxtsi_shift2_uxtw" |
| 3271 |
[(set (match_operand:DI 0 "register_operand" "=rk") |
| 3272 |
(zero_extend:DI |
| 3273 |
(plus:SI (and:SI |
| 3274 |
(ashift:SI (match_operand:SI 1 "register_operand" "r") |
| 3275 |
(match_operand 2 "aarch64_imm3" "Ui3")) |
| 3276 |
(match_operand 3 "const_int_operand" "n")) |
| 3277 |
(match_operand:SI 4 "register_operand" "r"))))] |
| 3278 |
"aarch64_uxt_size (INTVAL (operands[2]), INTVAL (operands[3])) != 0" |
| 3279 |
"* |
| 3280 |
operands[3] = GEN_INT (aarch64_uxt_size (INTVAL (operands[2]), |
| 3281 |
INTVAL (operands[3]))); |
| 3282 |
return \"add\t%w0, %w4, %w1, uxt%e3 %2\";" |
| 3283 |
[(set_attr "type" "alu_ext")] |
| 3284 |
) |
| 3285 |
|
| 3286 |
(define_insn "subsi3" |
| 3287 |
[(set (match_operand:SI 0 "register_operand" "=rk") |
| 3288 |
(minus:SI (match_operand:SI 1 "register_operand" "rk") |
| 3289 |
(match_operand:SI 2 "register_operand" "r")))] |
| 3290 |
"" |
| 3291 |
"sub\\t%w0, %w1, %w2" |
| 3292 |
[(set_attr "type" "alu_sreg")] |
| 3293 |
) |
| 3294 |
|
| 3295 |
;; zero_extend version of above |
| 3296 |
(define_insn "*subsi3_uxtw" |
| 3297 |
[(set (match_operand:DI 0 "register_operand" "=rk") |
| 3298 |
(zero_extend:DI |
| 3299 |
(minus:SI (match_operand:SI 1 "register_operand" "rk") |
| 3300 |
(match_operand:SI 2 "register_operand" "r"))))] |
| 3301 |
"" |
| 3302 |
"sub\\t%w0, %w1, %w2" |
| 3303 |
[(set_attr "type" "alu_sreg")] |
| 3304 |
) |
| 3305 |
|
| 3306 |
(define_insn "subdi3" |
| 3307 |
[(set (match_operand:DI 0 "register_operand") |
| 3308 |
(minus:DI (match_operand:DI 1 "register_operand") |
| 3309 |
(match_operand:DI 2 "register_operand")))] |
| 3310 |
"" |
| 3311 |
{@ [ cons: =0 , 1 , 2 ; attrs: type , arch ] |
| 3312 |
[ rk , rk , r ; alu_sreg , * ] sub\t%x0, %x1, %x2 |
| 3313 |
[ w , w , w ; neon_sub , simd ] sub\t%d0, %d1, %d2 |
| 3314 |
} |
| 3315 |
) |
| 3316 |
|
| 3317 |
(define_expand "subv<GPI:mode>4" |
| 3318 |
[(match_operand:GPI 0 "register_operand") |
| 3319 |
(match_operand:GPI 1 "register_operand") |
| 3320 |
(match_operand:GPI 2 "aarch64_plus_operand") |
| 3321 |
(label_ref (match_operand 3 "" ""))] |
| 3322 |
"" |
| 3323 |
{ |
| 3324 |
if (CONST_INT_P (operands[2])) |
| 3325 |
emit_insn (gen_subv<mode>_imm (operands[0], operands[1], operands[2])); |
| 3326 |
else |
| 3327 |
emit_insn (gen_subv<mode>_insn (operands[0], operands[1], operands[2])); |
| 3328 |
aarch64_gen_unlikely_cbranch (NE, CC_Vmode, operands[3]); |
| 3329 |
|
| 3330 |
DONE; |
| 3331 |
}) |
| 3332 |
|
| 3333 |
(define_insn "subv<GPI:mode>_insn" |
| 3334 |
[(set (reg:CC_V CC_REGNUM) |
| 3335 |
(compare:CC_V |
| 3336 |
(sign_extend:<DWI> |
| 3337 |
(minus:GPI |
| 3338 |
(match_operand:GPI 1 "register_operand" "rk") |
| 3339 |
(match_operand:GPI 2 "register_operand" "r"))) |
| 3340 |
(minus:<DWI> (sign_extend:<DWI> (match_dup 1)) |
| 3341 |
(sign_extend:<DWI> (match_dup 2))))) |
| 3342 |
(set (match_operand:GPI 0 "register_operand" "=r") |
| 3343 |
(minus:GPI (match_dup 1) (match_dup 2)))] |
| 3344 |
"" |
| 3345 |
"subs\\t%<w>0, %<w>1, %<w>2" |
| 3346 |
[(set_attr "type" "alus_sreg")] |
| 3347 |
) |
| 3348 |
|
| 3349 |
(define_insn "subv<GPI:mode>_imm" |
| 3350 |
[(set (reg:CC_V CC_REGNUM) |
| 3351 |
(compare:CC_V |
| 3352 |
(sign_extend:<DWI> |
| 3353 |
(minus:GPI |
| 3354 |
(match_operand:GPI 1 "register_operand") |
| 3355 |
(match_operand:GPI 2 "aarch64_plus_immediate"))) |
| 3356 |
(minus:<DWI> (sign_extend:<DWI> (match_dup 1)) |
| 3357 |
(match_dup 2)))) |
| 3358 |
(set (match_operand:GPI 0 "register_operand") |
| 3359 |
(minus:GPI (match_dup 1) (match_dup 2)))] |
| 3360 |
"" |
| 3361 |
{@ [ cons: =0 , 1 , 2 ] |
| 3362 |
[ r , rk , I ] subs\t%<w>0, %<w>1, %2 |
| 3363 |
[ r , rk , J ] adds\t%<w>0, %<w>1, #%n2 |
| 3364 |
} |
| 3365 |
[(set_attr "type" "alus_sreg")] |
| 3366 |
) |
| 3367 |
|
| 3368 |
(define_expand "negv<GPI:mode>3" |
| 3369 |
[(match_operand:GPI 0 "register_operand") |
| 3370 |
(match_operand:GPI 1 "register_operand") |
| 3371 |
(label_ref (match_operand 2 "" ""))] |
| 3372 |
"" |
| 3373 |
{ |
| 3374 |
emit_insn (gen_negv<mode>_insn (operands[0], operands[1])); |
| 3375 |
aarch64_gen_unlikely_cbranch (NE, CC_Vmode, operands[2]); |
| 3376 |
|
| 3377 |
DONE; |
| 3378 |
} |
| 3379 |
) |
| 3380 |
|
| 3381 |
(define_insn "negv<GPI:mode>_insn" |
| 3382 |
[(set (reg:CC_V CC_REGNUM) |
| 3383 |
(compare:CC_V |
| 3384 |
(sign_extend:<DWI> |
| 3385 |
(neg:GPI (match_operand:GPI 1 "register_operand" "r"))) |
| 3386 |
(neg:<DWI> (sign_extend:<DWI> (match_dup 1))))) |
| 3387 |
(set (match_operand:GPI 0 "register_operand" "=r") |
| 3388 |
(neg:GPI (match_dup 1)))] |
| 3389 |
"" |
| 3390 |
"negs\\t%<w>0, %<w>1" |
| 3391 |
[(set_attr "type" "alus_sreg")] |
| 3392 |
) |
| 3393 |
|
| 3394 |
(define_insn "negv<GPI:mode>_cmp_only" |
| 3395 |
[(set (reg:CC_V CC_REGNUM) |
| 3396 |
(compare:CC_V |
| 3397 |
(sign_extend:<DWI> |
| 3398 |
(neg:GPI (match_operand:GPI 0 "register_operand" "r"))) |
| 3399 |
(neg:<DWI> (sign_extend:<DWI> (match_dup 0)))))] |
| 3400 |
"" |
| 3401 |
"negs\\t%<w>zr, %<w>0" |
| 3402 |
[(set_attr "type" "alus_sreg")] |
| 3403 |
) |
| 3404 |
|
| 3405 |
(define_insn "*cmpv<GPI:mode>_insn" |
| 3406 |
[(set (reg:CC_V CC_REGNUM) |
| 3407 |
(compare:CC_V |
| 3408 |
(sign_extend:<DWI> |
| 3409 |
(minus:GPI (match_operand:GPI 0 "register_operand") |
| 3410 |
(match_operand:GPI 1 "aarch64_plus_operand"))) |
| 3411 |
(minus:<DWI> (sign_extend:<DWI> (match_dup 0)) |
| 3412 |
(sign_extend:<DWI> (match_dup 1)))))] |
| 3413 |
"" |
| 3414 |
{@ [ cons: 0 , 1 ] |
| 3415 |
[ r , r ] cmp\t%<w>0, %<w>1 |
| 3416 |
[ r , I ] cmp\t%<w>0, %1 |
| 3417 |
[ r , J ] cmp\t%<w>0, #%n1 |
| 3418 |
} |
| 3419 |
[(set_attr "type" "alus_sreg")] |
| 3420 |
) |
| 3421 |
|
| 3422 |
(define_expand "usubv<mode>4" |
| 3423 |
[(match_operand:GPI 0 "register_operand") |
| 3424 |
(match_operand:GPI 1 "aarch64_reg_or_zero") |
| 3425 |
(match_operand:GPI 2 "aarch64_reg_or_zero") |
| 3426 |
(label_ref (match_operand 3 "" ""))] |
| 3427 |
"" |
| 3428 |
{ |
| 3429 |
emit_insn (gen_sub<mode>3_compare1 (operands[0], operands[1], operands[2])); |
| 3430 |
aarch64_gen_unlikely_cbranch (LTU, CCmode, operands[3]); |
| 3431 |
|
| 3432 |
DONE; |
| 3433 |
}) |
| 3434 |
|
| 3435 |
(define_expand "subti3" |
| 3436 |
[(set (match_operand:TI 0 "register_operand") |
| 3437 |
(minus:TI (match_operand:TI 1 "aarch64_reg_or_zero") |
| 3438 |
(match_operand:TI 2 "register_operand")))] |
| 3439 |
"" |
| 3440 |
{ |
| 3441 |
rtx low_dest, op1_low, op2_low, high_dest, op1_high, op2_high; |
| 3442 |
|
| 3443 |
aarch64_subvti_scratch_regs (operands[1], operands[2], |
| 3444 |
&low_dest, &op1_low, &op2_low, |
| 3445 |
&high_dest, &op1_high, &op2_high); |
| 3446 |
|
| 3447 |
emit_insn (gen_subdi3_compare1 (low_dest, op1_low, op2_low)); |
| 3448 |
emit_insn (gen_subdi3_carryin (high_dest, op1_high, op2_high)); |
| 3449 |
|
| 3450 |
emit_move_insn (gen_lowpart (DImode, operands[0]), low_dest); |
| 3451 |
emit_move_insn (gen_highpart (DImode, operands[0]), high_dest); |
| 3452 |
DONE; |
| 3453 |
}) |
| 3454 |
|
| 3455 |
(define_expand "subvti4" |
| 3456 |
[(match_operand:TI 0 "register_operand") |
| 3457 |
(match_operand:TI 1 "register_operand") |
| 3458 |
(match_operand:TI 2 "aarch64_reg_or_imm") |
| 3459 |
(label_ref (match_operand 3 "" ""))] |
| 3460 |
"" |
| 3461 |
{ |
| 3462 |
rtx low_dest, op1_low, op2_low, high_dest, op1_high, op2_high; |
| 3463 |
|
| 3464 |
aarch64_subvti_scratch_regs (operands[1], operands[2], |
| 3465 |
&low_dest, &op1_low, &op2_low, |
| 3466 |
&high_dest, &op1_high, &op2_high); |
| 3467 |
aarch64_expand_subvti (operands[0], low_dest, op1_low, op2_low, |
| 3468 |
high_dest, op1_high, op2_high, false); |
| 3469 |
|
| 3470 |
aarch64_gen_unlikely_cbranch (NE, CC_Vmode, operands[3]); |
| 3471 |
DONE; |
| 3472 |
}) |
| 3473 |
|
| 3474 |
(define_expand "usubvti4" |
| 3475 |
[(match_operand:TI 0 "register_operand") |
| 3476 |
(match_operand:TI 1 "register_operand") |
| 3477 |
(match_operand:TI 2 "aarch64_reg_or_imm") |
| 3478 |
(label_ref (match_operand 3 "" ""))] |
| 3479 |
"" |
| 3480 |
{ |
| 3481 |
rtx low_dest, op1_low, op2_low, high_dest, op1_high, op2_high; |
| 3482 |
|
| 3483 |
aarch64_subvti_scratch_regs (operands[1], operands[2], |
| 3484 |
&low_dest, &op1_low, &op2_low, |
| 3485 |
&high_dest, &op1_high, &op2_high); |
| 3486 |
aarch64_expand_subvti (operands[0], low_dest, op1_low, op2_low, |
| 3487 |
high_dest, op1_high, op2_high, true); |
| 3488 |
|
| 3489 |
aarch64_gen_unlikely_cbranch (LTU, CCmode, operands[3]); |
| 3490 |
DONE; |
| 3491 |
}) |
| 3492 |
|
| 3493 |
(define_expand "negvti3" |
| 3494 |
[(match_operand:TI 0 "register_operand") |
| 3495 |
(match_operand:TI 1 "register_operand") |
| 3496 |
(label_ref (match_operand 2 "" ""))] |
| 3497 |
"" |
| 3498 |
{ |
| 3499 |
emit_insn (gen_negdi_carryout (gen_lowpart (DImode, operands[0]), |
| 3500 |
gen_lowpart (DImode, operands[1]))); |
| 3501 |
emit_insn (gen_negvdi_carryinV (gen_highpart (DImode, operands[0]), |
| 3502 |
gen_highpart (DImode, operands[1]))); |
| 3503 |
aarch64_gen_unlikely_cbranch (NE, CC_Vmode, operands[2]); |
| 3504 |
|
| 3505 |
DONE; |
| 3506 |
} |
| 3507 |
) |
| 3508 |
|
| 3509 |
(define_insn "negdi_carryout" |
| 3510 |
[(set (reg:CC CC_REGNUM) |
| 3511 |
(compare:CC |
| 3512 |
(const_int 0) (match_operand:DI 1 "register_operand" "r"))) |
| 3513 |
(set (match_operand:DI 0 "register_operand" "=r") |
| 3514 |
(neg:DI (match_dup 1)))] |
| 3515 |
"" |
| 3516 |
"negs\\t%0, %1" |
| 3517 |
[(set_attr "type" "alus_sreg")] |
| 3518 |
) |
| 3519 |
|
| 3520 |
(define_insn "negvdi_carryinV" |
| 3521 |
[(set (reg:CC_V CC_REGNUM) |
| 3522 |
(compare:CC_V |
| 3523 |
(neg:TI (plus:TI |
| 3524 |
(ltu:TI (reg:CC CC_REGNUM) (const_int 0)) |
| 3525 |
(sign_extend:TI (match_operand:DI 1 "register_operand" "r")))) |
| 3526 |
(sign_extend:TI |
| 3527 |
(neg:DI (plus:DI (ltu:DI (reg:CC CC_REGNUM) (const_int 0)) |
| 3528 |
(match_dup 1)))))) |
| 3529 |
(set (match_operand:DI 0 "register_operand" "=r") |
| 3530 |
(neg:DI (plus:DI (ltu:DI (reg:CC CC_REGNUM) (const_int 0)) |
| 3531 |
(match_dup 1))))] |
| 3532 |
"" |
| 3533 |
"ngcs\\t%0, %1" |
| 3534 |
[(set_attr "type" "alus_sreg")] |
| 3535 |
) |
| 3536 |
|
| 3537 |
(define_insn "*sub<mode>3_compare0" |
| 3538 |
[(set (reg:CC_NZ CC_REGNUM) |
| 3539 |
(compare:CC_NZ (minus:GPI (match_operand:GPI 1 "register_operand" "rk") |
| 3540 |
(match_operand:GPI 2 "register_operand" "r")) |
| 3541 |
(const_int 0))) |
| 3542 |
(set (match_operand:GPI 0 "register_operand" "=r") |
| 3543 |
(minus:GPI (match_dup 1) (match_dup 2)))] |
| 3544 |
"" |
| 3545 |
"subs\\t%<w>0, %<w>1, %<w>2" |
| 3546 |
[(set_attr "type" "alus_sreg")] |
| 3547 |
) |
| 3548 |
|
| 3549 |
;; zero_extend version of above |
| 3550 |
(define_insn "*subsi3_compare0_uxtw" |
| 3551 |
[(set (reg:CC_NZ CC_REGNUM) |
| 3552 |
(compare:CC_NZ (minus:SI (match_operand:SI 1 "register_operand" "rk") |
| 3553 |
(match_operand:SI 2 "register_operand" "r")) |
| 3554 |
(const_int 0))) |
| 3555 |
(set (match_operand:DI 0 "register_operand" "=r") |
| 3556 |
(zero_extend:DI (minus:SI (match_dup 1) (match_dup 2))))] |
| 3557 |
"" |
| 3558 |
"subs\\t%w0, %w1, %w2" |
| 3559 |
[(set_attr "type" "alus_sreg")] |
| 3560 |
) |
| 3561 |
|
| 3562 |
(define_insn "sub<mode>3_compare1_imm" |
| 3563 |
[(set (reg:CC CC_REGNUM) |
| 3564 |
(compare:CC |
| 3565 |
(match_operand:GPI 1 "register_operand") |
| 3566 |
(match_operand:GPI 2 "aarch64_plus_immediate"))) |
| 3567 |
(set (match_operand:GPI 0 "register_operand") |
| 3568 |
(plus:GPI |
| 3569 |
(match_dup 1) |
| 3570 |
(match_operand:GPI 3 "aarch64_plus_immediate")))] |
| 3571 |
"UINTVAL (operands[2]) == -UINTVAL (operands[3])" |
| 3572 |
{@ [ cons: =0 , 1 , 2 , 3 ] |
| 3573 |
[ r , rk , I , J ] subs\t%<w>0, %<w>1, %2 |
| 3574 |
[ r , rk , J , I ] adds\t%<w>0, %<w>1, #%n2 |
| 3575 |
} |
| 3576 |
[(set_attr "type" "alus_imm")] |
| 3577 |
) |
| 3578 |
|
| 3579 |
(define_insn "sub<mode>3_compare1" |
| 3580 |
[(set (reg:CC CC_REGNUM) |
| 3581 |
(compare:CC |
| 3582 |
(match_operand:GPI 1 "aarch64_reg_or_zero" "rkZ") |
| 3583 |
(match_operand:GPI 2 "aarch64_reg_or_zero" "rZ"))) |
| 3584 |
(set (match_operand:GPI 0 "register_operand" "=r") |
| 3585 |
(minus:GPI (match_dup 1) (match_dup 2)))] |
| 3586 |
"" |
| 3587 |
"subs\\t%<w>0, %<w>1, %<w>2" |
| 3588 |
[(set_attr "type" "alus_sreg")] |
| 3589 |
) |
| 3590 |
|
| 3591 |
(define_peephole2 |
| 3592 |
[(set (match_operand:GPI 0 "aarch64_general_reg") |
| 3593 |
(minus:GPI (match_operand:GPI 1 "aarch64_reg_or_zero") |
| 3594 |
(match_operand:GPI 2 "aarch64_reg_or_zero"))) |
| 3595 |
(set (reg:CC CC_REGNUM) |
| 3596 |
(compare:CC |
| 3597 |
(match_dup 1) |
| 3598 |
(match_dup 2)))] |
| 3599 |
"!reg_overlap_mentioned_p (operands[0], operands[1]) |
| 3600 |
&& !reg_overlap_mentioned_p (operands[0], operands[2])" |
| 3601 |
[(const_int 0)] |
| 3602 |
{ |
| 3603 |
emit_insn (gen_sub<mode>3_compare1 (operands[0], operands[1], |
| 3604 |
operands[2])); |
| 3605 |
DONE; |
| 3606 |
} |
| 3607 |
) |
| 3608 |
|
| 3609 |
;; Same as the above peephole but with the compare and minus in |
| 3610 |
;; swapped order. The restriction on overlap between operand 0 |
| 3611 |
;; and operands 1 and 2 doesn't apply here. |
| 3612 |
(define_peephole2 |
| 3613 |
[(set (reg:CC CC_REGNUM) |
| 3614 |
(compare:CC |
| 3615 |
(match_operand:GPI 1 "aarch64_reg_or_zero") |
| 3616 |
(match_operand:GPI 2 "aarch64_reg_or_zero"))) |
| 3617 |
(set (match_operand:GPI 0 "aarch64_general_reg") |
| 3618 |
(minus:GPI (match_dup 1) |
| 3619 |
(match_dup 2)))] |
| 3620 |
"" |
| 3621 |
[(const_int 0)] |
| 3622 |
{ |
| 3623 |
emit_insn (gen_sub<mode>3_compare1 (operands[0], operands[1], |
| 3624 |
operands[2])); |
| 3625 |
DONE; |
| 3626 |
} |
| 3627 |
) |
| 3628 |
|
| 3629 |
(define_peephole2 |
| 3630 |
[(set (match_operand:GPI 0 "aarch64_general_reg") |
| 3631 |
(plus:GPI (match_operand:GPI 1 "register_operand") |
| 3632 |
(match_operand:GPI 2 "aarch64_plus_immediate"))) |
| 3633 |
(set (reg:CC CC_REGNUM) |
| 3634 |
(compare:CC |
| 3635 |
(match_dup 1) |
| 3636 |
(match_operand:GPI 3 "const_int_operand")))] |
| 3637 |
"!reg_overlap_mentioned_p (operands[0], operands[1]) |
| 3638 |
&& INTVAL (operands[3]) == -INTVAL (operands[2])" |
| 3639 |
[(const_int 0)] |
| 3640 |
{ |
| 3641 |
emit_insn (gen_sub<mode>3_compare1_imm (operands[0], operands[1], |
| 3642 |
operands[3], operands[2])); |
| 3643 |
DONE; |
| 3644 |
} |
| 3645 |
) |
| 3646 |
|
| 3647 |
;; Same as the above peephole but with the compare and minus in |
| 3648 |
;; swapped order. The restriction on overlap between operand 0 |
| 3649 |
;; and operands 1 doesn't apply here. |
| 3650 |
(define_peephole2 |
| 3651 |
[(set (reg:CC CC_REGNUM) |
| 3652 |
(compare:CC |
| 3653 |
(match_operand:GPI 1 "register_operand") |
| 3654 |
(match_operand:GPI 3 "const_int_operand"))) |
| 3655 |
(set (match_operand:GPI 0 "aarch64_general_reg") |
| 3656 |
(plus:GPI (match_dup 1) |
| 3657 |
(match_operand:GPI 2 "aarch64_plus_immediate")))] |
| 3658 |
"INTVAL (operands[3]) == -INTVAL (operands[2])" |
| 3659 |
[(const_int 0)] |
| 3660 |
{ |
| 3661 |
emit_insn (gen_sub<mode>3_compare1_imm (operands[0], operands[1], |
| 3662 |
operands[3], operands[2])); |
| 3663 |
DONE; |
| 3664 |
} |
| 3665 |
) |
| 3666 |
|
| 3667 |
(define_insn "*sub_<shift>_<mode>" |
| 3668 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 3669 |
(minus:GPI (match_operand:GPI 3 "register_operand" "r") |
| 3670 |
(ASHIFT:GPI |
| 3671 |
(match_operand:GPI 1 "register_operand" "r") |
| 3672 |
(match_operand:QI 2 "aarch64_shift_imm_<mode>" "n"))))] |
| 3673 |
"" |
| 3674 |
"sub\\t%<w>0, %<w>3, %<w>1, <shift> %2" |
| 3675 |
[(set_attr "autodetect_type" "alu_shift_<shift>_op2")] |
| 3676 |
) |
| 3677 |
|
| 3678 |
;; zero_extend version of above |
| 3679 |
(define_insn "*sub_<shift>_si_uxtw" |
| 3680 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 3681 |
(zero_extend:DI |
| 3682 |
(minus:SI (match_operand:SI 3 "register_operand" "r") |
| 3683 |
(ASHIFT:SI |
| 3684 |
(match_operand:SI 1 "register_operand" "r") |
| 3685 |
(match_operand:QI 2 "aarch64_shift_imm_si" "n")))))] |
| 3686 |
"" |
| 3687 |
"sub\\t%w0, %w3, %w1, <shift> %2" |
| 3688 |
[(set_attr "autodetect_type" "alu_shift_<shift>_op2")] |
| 3689 |
) |
| 3690 |
|
| 3691 |
(define_insn "*sub_<optab><ALLX:mode>_<GPI:mode>" |
| 3692 |
[(set (match_operand:GPI 0 "register_operand" "=rk") |
| 3693 |
(minus:GPI (match_operand:GPI 1 "register_operand" "rk") |
| 3694 |
(ANY_EXTEND:GPI |
| 3695 |
(match_operand:ALLX 2 "register_operand" "r"))))] |
| 3696 |
"" |
| 3697 |
"sub\\t%<GPI:w>0, %<GPI:w>1, %w2, <su>xt<ALLX:size>" |
| 3698 |
[(set_attr "type" "alu_ext")] |
| 3699 |
) |
| 3700 |
|
| 3701 |
;; zero_extend version of above |
| 3702 |
(define_insn "*sub_<optab><SHORT:mode>_si_uxtw" |
| 3703 |
[(set (match_operand:DI 0 "register_operand" "=rk") |
| 3704 |
(zero_extend:DI |
| 3705 |
(minus:SI (match_operand:SI 1 "register_operand" "rk") |
| 3706 |
(ANY_EXTEND:SI |
| 3707 |
(match_operand:SHORT 2 "register_operand" "r")))))] |
| 3708 |
"" |
| 3709 |
"sub\\t%w0, %w1, %w2, <su>xt<SHORT:size>" |
| 3710 |
[(set_attr "type" "alu_ext")] |
| 3711 |
) |
| 3712 |
|
| 3713 |
(define_insn "*sub_<optab><ALLX:mode>_shft_<GPI:mode>" |
| 3714 |
[(set (match_operand:GPI 0 "register_operand" "=rk") |
| 3715 |
(minus:GPI (match_operand:GPI 1 "register_operand" "rk") |
| 3716 |
(ashift:GPI (ANY_EXTEND:GPI |
| 3717 |
(match_operand:ALLX 2 "register_operand" "r")) |
| 3718 |
(match_operand 3 "aarch64_imm3" "Ui3"))))] |
| 3719 |
"" |
| 3720 |
"sub\\t%<GPI:w>0, %<GPI:w>1, %w2, <su>xt<ALLX:size> %3" |
| 3721 |
[(set_attr "type" "alu_ext")] |
| 3722 |
) |
| 3723 |
|
| 3724 |
;; zero_extend version of above |
| 3725 |
(define_insn "*sub_<optab><SHORT:mode>_shft_si_uxtw" |
| 3726 |
[(set (match_operand:DI 0 "register_operand" "=rk") |
| 3727 |
(zero_extend:DI |
| 3728 |
(minus:SI (match_operand:SI 1 "register_operand" "rk") |
| 3729 |
(ashift:SI (ANY_EXTEND:SI |
| 3730 |
(match_operand:SHORT 2 "register_operand" "r")) |
| 3731 |
(match_operand 3 "aarch64_imm3" "Ui3")))))] |
| 3732 |
"" |
| 3733 |
"sub\\t%w0, %w1, %w2, <su>xt<SHORT:size> %3" |
| 3734 |
[(set_attr "type" "alu_ext")] |
| 3735 |
) |
| 3736 |
|
| 3737 |
;; The hardware description is op1 + ~op2 + C. |
| 3738 |
;; = op1 + (-op2 + 1) + (1 - !C) |
| 3739 |
;; = op1 - op2 - 1 + 1 - !C |
| 3740 |
;; = op1 - op2 - !C. |
| 3741 |
;; We describe the latter. |
| 3742 |
|
| 3743 |
(define_insn "*sub<mode>3_carryin0" |
| 3744 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 3745 |
(minus:GPI |
| 3746 |
(match_operand:GPI 1 "aarch64_reg_or_zero" "rZ") |
| 3747 |
(match_operand:GPI 2 "aarch64_borrow_operation" "")))] |
| 3748 |
"" |
| 3749 |
"sbc\\t%<w>0, %<w>1, <w>zr" |
| 3750 |
[(set_attr "type" "adc_reg")] |
| 3751 |
) |
| 3752 |
|
| 3753 |
;; zero_extend version of the above |
| 3754 |
(define_insn "*subsi3_carryin_uxtw" |
| 3755 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 3756 |
(zero_extend:DI |
| 3757 |
(minus:SI |
| 3758 |
(match_operand:SI 1 "aarch64_reg_or_zero" "rZ") |
| 3759 |
(match_operand:SI 2 "aarch64_borrow_operation" ""))))] |
| 3760 |
"" |
| 3761 |
"sbc\\t%w0, %w1, wzr" |
| 3762 |
[(set_attr "type" "adc_reg")] |
| 3763 |
) |
| 3764 |
|
| 3765 |
(define_expand "sub<mode>3_carryin" |
| 3766 |
[(set (match_operand:GPI 0 "register_operand") |
| 3767 |
(minus:GPI |
| 3768 |
(minus:GPI |
| 3769 |
(match_operand:GPI 1 "aarch64_reg_or_zero") |
| 3770 |
(match_operand:GPI 2 "register_operand")) |
| 3771 |
(ltu:GPI (reg:CC CC_REGNUM) (const_int 0))))] |
| 3772 |
"" |
| 3773 |
"" |
| 3774 |
) |
| 3775 |
|
| 3776 |
(define_insn "*sub<mode>3_carryin" |
| 3777 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 3778 |
(minus:GPI |
| 3779 |
(minus:GPI |
| 3780 |
(match_operand:GPI 1 "aarch64_reg_or_zero" "rZ") |
| 3781 |
(match_operand:GPI 2 "register_operand" "r")) |
| 3782 |
(match_operand:GPI 3 "aarch64_borrow_operation" "")))] |
| 3783 |
|
| 3784 |
"" |
| 3785 |
"sbc\\t%<w>0, %<w>1, %<w>2" |
| 3786 |
[(set_attr "type" "adc_reg")] |
| 3787 |
) |
| 3788 |
|
| 3789 |
;; zero_extend version of the above |
| 3790 |
(define_insn "*subsi3_carryin_uxtw" |
| 3791 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 3792 |
(zero_extend:DI |
| 3793 |
(minus:SI |
| 3794 |
(minus:SI |
| 3795 |
(match_operand:SI 1 "aarch64_reg_or_zero" "rZ") |
| 3796 |
(match_operand:SI 2 "register_operand" "r")) |
| 3797 |
(match_operand:SI 3 "aarch64_borrow_operation" ""))))] |
| 3798 |
|
| 3799 |
"" |
| 3800 |
"sbc\\t%w0, %w1, %w2" |
| 3801 |
[(set_attr "type" "adc_reg")] |
| 3802 |
) |
| 3803 |
|
| 3804 |
(define_insn "*sub<mode>3_carryin_alt" |
| 3805 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 3806 |
(minus:GPI |
| 3807 |
(minus:GPI |
| 3808 |
(match_operand:GPI 1 "aarch64_reg_or_zero" "rZ") |
| 3809 |
(match_operand:GPI 3 "aarch64_borrow_operation" "")) |
| 3810 |
(match_operand:GPI 2 "register_operand" "r")))] |
| 3811 |
"" |
| 3812 |
"sbc\\t%<w>0, %<w>1, %<w>2" |
| 3813 |
[(set_attr "type" "adc_reg")] |
| 3814 |
) |
| 3815 |
|
| 3816 |
;; zero_extend version of the above |
| 3817 |
(define_insn "*subsi3_carryin_alt_uxtw" |
| 3818 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 3819 |
(zero_extend:DI |
| 3820 |
(minus:SI |
| 3821 |
(minus:SI |
| 3822 |
(match_operand:SI 1 "aarch64_reg_or_zero" "rZ") |
| 3823 |
(match_operand:SI 3 "aarch64_borrow_operation" "")) |
| 3824 |
(match_operand:SI 2 "register_operand" "r"))))] |
| 3825 |
"" |
| 3826 |
"sbc\\t%w0, %w1, %w2" |
| 3827 |
[(set_attr "type" "adc_reg")] |
| 3828 |
) |
| 3829 |
|
| 3830 |
(define_expand "usub<GPI:mode>3_carryinC" |
| 3831 |
[(parallel |
| 3832 |
[(set (reg:CC CC_REGNUM) |
| 3833 |
(compare:CC |
| 3834 |
(zero_extend:<DWI> |
| 3835 |
(match_operand:GPI 1 "aarch64_reg_or_zero")) |
| 3836 |
(plus:<DWI> |
| 3837 |
(zero_extend:<DWI> |
| 3838 |
(match_operand:GPI 2 "register_operand")) |
| 3839 |
(ltu:<DWI> (reg:CC CC_REGNUM) (const_int 0))))) |
| 3840 |
(set (match_operand:GPI 0 "register_operand") |
| 3841 |
(minus:GPI |
| 3842 |
(minus:GPI (match_dup 1) (match_dup 2)) |
| 3843 |
(ltu:GPI (reg:CC CC_REGNUM) (const_int 0))))])] |
| 3844 |
"" |
| 3845 |
) |
| 3846 |
|
| 3847 |
(define_insn "*usub<GPI:mode>3_carryinC_z1" |
| 3848 |
[(set (reg:CC CC_REGNUM) |
| 3849 |
(compare:CC |
| 3850 |
(const_int 0) |
| 3851 |
(plus:<DWI> |
| 3852 |
(zero_extend:<DWI> |
| 3853 |
(match_operand:GPI 1 "register_operand" "r")) |
| 3854 |
(match_operand:<DWI> 2 "aarch64_borrow_operation" "")))) |
| 3855 |
(set (match_operand:GPI 0 "register_operand" "=r") |
| 3856 |
(minus:GPI |
| 3857 |
(neg:GPI (match_dup 1)) |
| 3858 |
(match_operand:GPI 3 "aarch64_borrow_operation" "")))] |
| 3859 |
"" |
| 3860 |
"sbcs\\t%<w>0, <w>zr, %<w>1" |
| 3861 |
[(set_attr "type" "adc_reg")] |
| 3862 |
) |
| 3863 |
|
| 3864 |
(define_insn "*usub<GPI:mode>3_carryinC_z2" |
| 3865 |
[(set (reg:CC CC_REGNUM) |
| 3866 |
(compare:CC |
| 3867 |
(zero_extend:<DWI> |
| 3868 |
(match_operand:GPI 1 "register_operand" "r")) |
| 3869 |
(match_operand:<DWI> 2 "aarch64_borrow_operation" ""))) |
| 3870 |
(set (match_operand:GPI 0 "register_operand" "=r") |
| 3871 |
(minus:GPI |
| 3872 |
(match_dup 1) |
| 3873 |
(match_operand:GPI 3 "aarch64_borrow_operation" "")))] |
| 3874 |
"" |
| 3875 |
"sbcs\\t%<w>0, %<w>1, <w>zr" |
| 3876 |
[(set_attr "type" "adc_reg")] |
| 3877 |
) |
| 3878 |
|
| 3879 |
(define_insn "*usub<GPI:mode>3_carryinC" |
| 3880 |
[(set (reg:CC CC_REGNUM) |
| 3881 |
(compare:CC |
| 3882 |
(zero_extend:<DWI> |
| 3883 |
(match_operand:GPI 1 "register_operand" "r")) |
| 3884 |
(plus:<DWI> |
| 3885 |
(zero_extend:<DWI> |
| 3886 |
(match_operand:GPI 2 "register_operand" "r")) |
| 3887 |
(match_operand:<DWI> 3 "aarch64_borrow_operation" "")))) |
| 3888 |
(set (match_operand:GPI 0 "register_operand" "=r") |
| 3889 |
(minus:GPI |
| 3890 |
(minus:GPI (match_dup 1) (match_dup 2)) |
| 3891 |
(match_operand:GPI 4 "aarch64_borrow_operation" "")))] |
| 3892 |
"" |
| 3893 |
"sbcs\\t%<w>0, %<w>1, %<w>2" |
| 3894 |
[(set_attr "type" "adc_reg")] |
| 3895 |
) |
| 3896 |
|
| 3897 |
(define_expand "sub<GPI:mode>3_carryinV" |
| 3898 |
[(parallel |
| 3899 |
[(set (reg:CC_V CC_REGNUM) |
| 3900 |
(compare:CC_V |
| 3901 |
(minus:<DWI> |
| 3902 |
(sign_extend:<DWI> |
| 3903 |
(match_operand:GPI 1 "aarch64_reg_or_zero")) |
| 3904 |
(plus:<DWI> |
| 3905 |
(sign_extend:<DWI> |
| 3906 |
(match_operand:GPI 2 "register_operand")) |
| 3907 |
(ltu:<DWI> (reg:CC CC_REGNUM) (const_int 0)))) |
| 3908 |
(sign_extend:<DWI> |
| 3909 |
(minus:GPI (match_dup 1) |
| 3910 |
(plus:GPI (ltu:GPI (reg:CC CC_REGNUM) (const_int 0)) |
| 3911 |
(match_dup 2)))))) |
| 3912 |
(set (match_operand:GPI 0 "register_operand") |
| 3913 |
(minus:GPI |
| 3914 |
(minus:GPI (match_dup 1) (match_dup 2)) |
| 3915 |
(ltu:GPI (reg:CC CC_REGNUM) (const_int 0))))])] |
| 3916 |
"" |
| 3917 |
) |
| 3918 |
|
| 3919 |
(define_insn "*sub<mode>3_carryinV_z2" |
| 3920 |
[(set (reg:CC_V CC_REGNUM) |
| 3921 |
(compare:CC_V |
| 3922 |
(minus:<DWI> |
| 3923 |
(sign_extend:<DWI> (match_operand:GPI 1 "register_operand" "r")) |
| 3924 |
(match_operand:<DWI> 2 "aarch64_borrow_operation" "")) |
| 3925 |
(sign_extend:<DWI> |
| 3926 |
(minus:GPI (match_dup 1) |
| 3927 |
(match_operand:GPI 3 "aarch64_borrow_operation" ""))))) |
| 3928 |
(set (match_operand:GPI 0 "register_operand" "=r") |
| 3929 |
(minus:GPI |
| 3930 |
(match_dup 1) (match_dup 3)))] |
| 3931 |
"" |
| 3932 |
"sbcs\\t%<w>0, %<w>1, <w>zr" |
| 3933 |
[(set_attr "type" "adc_reg")] |
| 3934 |
) |
| 3935 |
|
| 3936 |
(define_insn "*sub<mode>3_carryinV" |
| 3937 |
[(set (reg:CC_V CC_REGNUM) |
| 3938 |
(compare:CC_V |
| 3939 |
(minus:<DWI> |
| 3940 |
(sign_extend:<DWI> |
| 3941 |
(match_operand:GPI 1 "register_operand" "r")) |
| 3942 |
(plus:<DWI> |
| 3943 |
(sign_extend:<DWI> |
| 3944 |
(match_operand:GPI 2 "register_operand" "r")) |
| 3945 |
(match_operand:<DWI> 3 "aarch64_borrow_operation" ""))) |
| 3946 |
(sign_extend:<DWI> |
| 3947 |
(minus:GPI |
| 3948 |
(match_dup 1) |
| 3949 |
(plus:GPI (match_operand:GPI 4 "aarch64_borrow_operation" "") |
| 3950 |
(match_dup 2)))))) |
| 3951 |
(set (match_operand:GPI 0 "register_operand" "=r") |
| 3952 |
(minus:GPI |
| 3953 |
(minus:GPI (match_dup 1) (match_dup 2)) |
| 3954 |
(match_dup 4)))] |
| 3955 |
"" |
| 3956 |
"sbcs\\t%<w>0, %<w>1, %<w>2" |
| 3957 |
[(set_attr "type" "adc_reg")] |
| 3958 |
) |
| 3959 |
|
| 3960 |
(define_insn "*sub_uxt<mode>_shift2" |
| 3961 |
[(set (match_operand:GPI 0 "register_operand" "=rk") |
| 3962 |
(minus:GPI (match_operand:GPI 4 "register_operand" "rk") |
| 3963 |
(and:GPI |
| 3964 |
(ashift:GPI (match_operand:GPI 1 "register_operand" "r") |
| 3965 |
(match_operand 2 "aarch64_imm3" "Ui3")) |
| 3966 |
(match_operand 3 "const_int_operand" "n"))))] |
| 3967 |
"aarch64_uxt_size (INTVAL (operands[2]),INTVAL (operands[3])) != 0" |
| 3968 |
"* |
| 3969 |
operands[3] = GEN_INT (aarch64_uxt_size (INTVAL (operands[2]), |
| 3970 |
INTVAL (operands[3]))); |
| 3971 |
return \"sub\t%<w>0, %<w>4, %w1, uxt%e3 %2\";" |
| 3972 |
[(set_attr "type" "alu_ext")] |
| 3973 |
) |
| 3974 |
|
| 3975 |
;; zero_extend version of above |
| 3976 |
(define_insn "*sub_uxtsi_shift2_uxtw" |
| 3977 |
[(set (match_operand:DI 0 "register_operand" "=rk") |
| 3978 |
(zero_extend:DI |
| 3979 |
(minus:SI (match_operand:SI 4 "register_operand" "rk") |
| 3980 |
(and:SI |
| 3981 |
(ashift:SI (match_operand:SI 1 "register_operand" "r") |
| 3982 |
(match_operand 2 "aarch64_imm3" "Ui3")) |
| 3983 |
(match_operand 3 "const_int_operand" "n")))))] |
| 3984 |
"aarch64_uxt_size (INTVAL (operands[2]),INTVAL (operands[3])) != 0" |
| 3985 |
"* |
| 3986 |
operands[3] = GEN_INT (aarch64_uxt_size (INTVAL (operands[2]), |
| 3987 |
INTVAL (operands[3]))); |
| 3988 |
return \"sub\t%w0, %w4, %w1, uxt%e3 %2\";" |
| 3989 |
[(set_attr "type" "alu_ext")] |
| 3990 |
) |
| 3991 |
|
| 3992 |
(define_insn "*aarch64_abs<mode>2_cssc_insn" |
| 3993 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 3994 |
(abs:GPI (match_operand:GPI 1 "register_operand" "r")))] |
| 3995 |
"TARGET_CSSC" |
| 3996 |
"abs\\t%<w>0, %<w>1" |
| 3997 |
[(set_attr "type" "alu_sreg")] |
| 3998 |
) |
| 3999 |
|
| 4000 |
(define_expand "abs<mode>2" |
| 4001 |
[(set (match_operand:GPI 0 "register_operand") |
| 4002 |
(abs:GPI (match_operand:GPI 1 "register_operand")))] |
| 4003 |
"" |
| 4004 |
{ |
| 4005 |
if (!TARGET_CSSC) |
| 4006 |
{ |
| 4007 |
rtx ccreg = aarch64_gen_compare_reg (LT, operands[1], const0_rtx); |
| 4008 |
rtx x = gen_rtx_LT (VOIDmode, ccreg, const0_rtx); |
| 4009 |
emit_insn (gen_csneg3<mode>_insn (operands[0], x, operands[1], operands[1])); |
| 4010 |
DONE; |
| 4011 |
} |
| 4012 |
} |
| 4013 |
) |
| 4014 |
|
| 4015 |
(define_insn "neg<mode>2" |
| 4016 |
[(set (match_operand:GPI 0 "register_operand") |
| 4017 |
(neg:GPI (match_operand:GPI 1 "register_operand")))] |
| 4018 |
"" |
| 4019 |
{@ [ cons: =0 , 1 ; attrs: type , arch ] |
| 4020 |
[ r , r ; alu_sreg , * ] neg\t%<w>0, %<w>1 |
| 4021 |
[ w , w ; neon_neg<q> , simd ] neg\t%<rtn>0<vas>, %<rtn>1<vas> |
| 4022 |
} |
| 4023 |
) |
| 4024 |
|
| 4025 |
;; zero_extend version of above |
| 4026 |
(define_insn "*negsi2_uxtw" |
| 4027 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 4028 |
(zero_extend:DI (neg:SI (match_operand:SI 1 "register_operand" "r"))))] |
| 4029 |
"" |
| 4030 |
"neg\\t%w0, %w1" |
| 4031 |
[(set_attr "type" "alu_sreg")] |
| 4032 |
) |
| 4033 |
|
| 4034 |
(define_insn "*ngc<mode>" |
| 4035 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 4036 |
(minus:GPI |
| 4037 |
(neg:GPI (match_operand:GPI 2 "aarch64_borrow_operation" "")) |
| 4038 |
(match_operand:GPI 1 "register_operand" "r")))] |
| 4039 |
"" |
| 4040 |
"ngc\\t%<w>0, %<w>1" |
| 4041 |
[(set_attr "type" "adc_reg")] |
| 4042 |
) |
| 4043 |
|
| 4044 |
(define_insn "*ngcsi_uxtw" |
| 4045 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 4046 |
(zero_extend:DI |
| 4047 |
(minus:SI |
| 4048 |
(neg:SI (match_operand:SI 2 "aarch64_borrow_operation" "")) |
| 4049 |
(match_operand:SI 1 "register_operand" "r"))))] |
| 4050 |
"" |
| 4051 |
"ngc\\t%w0, %w1" |
| 4052 |
[(set_attr "type" "adc_reg")] |
| 4053 |
) |
| 4054 |
|
| 4055 |
(define_insn "neg<mode>2_compare0" |
| 4056 |
[(set (reg:CC_NZ CC_REGNUM) |
| 4057 |
(compare:CC_NZ (neg:GPI (match_operand:GPI 1 "register_operand" "r")) |
| 4058 |
(const_int 0))) |
| 4059 |
(set (match_operand:GPI 0 "register_operand" "=r") |
| 4060 |
(neg:GPI (match_dup 1)))] |
| 4061 |
"" |
| 4062 |
"negs\\t%<w>0, %<w>1" |
| 4063 |
[(set_attr "type" "alus_sreg")] |
| 4064 |
) |
| 4065 |
|
| 4066 |
;; zero_extend version of above |
| 4067 |
(define_insn "*negsi2_compare0_uxtw" |
| 4068 |
[(set (reg:CC_NZ CC_REGNUM) |
| 4069 |
(compare:CC_NZ (neg:SI (match_operand:SI 1 "register_operand" "r")) |
| 4070 |
(const_int 0))) |
| 4071 |
(set (match_operand:DI 0 "register_operand" "=r") |
| 4072 |
(zero_extend:DI (neg:SI (match_dup 1))))] |
| 4073 |
"" |
| 4074 |
"negs\\t%w0, %w1" |
| 4075 |
[(set_attr "type" "alus_sreg")] |
| 4076 |
) |
| 4077 |
|
| 4078 |
(define_insn "*neg_<shift><mode>3_compare0" |
| 4079 |
[(set (reg:CC_NZ CC_REGNUM) |
| 4080 |
(compare:CC_NZ |
| 4081 |
(neg:GPI (ASHIFT:GPI |
| 4082 |
(match_operand:GPI 1 "register_operand" "r") |
| 4083 |
(match_operand:QI 2 "aarch64_shift_imm_<mode>" "n"))) |
| 4084 |
(const_int 0))) |
| 4085 |
(set (match_operand:GPI 0 "register_operand" "=r") |
| 4086 |
(neg:GPI (ASHIFT:GPI (match_dup 1) (match_dup 2))))] |
| 4087 |
"" |
| 4088 |
"negs\\t%<w>0, %<w>1, <shift> %2" |
| 4089 |
[(set_attr "type" "alus_shift_imm")] |
| 4090 |
) |
| 4091 |
|
| 4092 |
(define_insn "*neg_<shift>_<mode>2" |
| 4093 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 4094 |
(neg:GPI (ASHIFT:GPI |
| 4095 |
(match_operand:GPI 1 "register_operand" "r") |
| 4096 |
(match_operand:QI 2 "aarch64_shift_imm_<mode>" "n"))))] |
| 4097 |
"" |
| 4098 |
"neg\\t%<w>0, %<w>1, <shift> %2" |
| 4099 |
[(set_attr "autodetect_type" "alu_shift_<shift>_op2")] |
| 4100 |
) |
| 4101 |
|
| 4102 |
;; zero_extend version of above |
| 4103 |
(define_insn "*neg_<shift>_si2_uxtw" |
| 4104 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 4105 |
(zero_extend:DI |
| 4106 |
(neg:SI (ASHIFT:SI |
| 4107 |
(match_operand:SI 1 "register_operand" "r") |
| 4108 |
(match_operand:QI 2 "aarch64_shift_imm_si" "n")))))] |
| 4109 |
"" |
| 4110 |
"neg\\t%w0, %w1, <shift> %2" |
| 4111 |
[(set_attr "autodetect_type" "alu_shift_<shift>_op2")] |
| 4112 |
) |
| 4113 |
|
| 4114 |
(define_insn "*neg_asr_si2_extr" |
| 4115 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 4116 |
(neg:SI (match_operator:SI 4 "subreg_lowpart_operator" |
| 4117 |
[(sign_extract:DI |
| 4118 |
(match_operand:DI 1 "register_operand" "r") |
| 4119 |
(match_operand 3 "aarch64_simd_shift_imm_offset_si" "n") |
| 4120 |
(match_operand 2 "aarch64_simd_shift_imm_offset_si" "n"))])))] |
| 4121 |
"INTVAL (operands[2]) + INTVAL (operands[3]) == 32" |
| 4122 |
"neg\\t%w0, %w1, asr %2" |
| 4123 |
[(set_attr "autodetect_type" "alu_shift_asr_op2")] |
| 4124 |
) |
| 4125 |
|
| 4126 |
(define_insn "mul<mode>3" |
| 4127 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 4128 |
(mult:GPI (match_operand:GPI 1 "register_operand" "r") |
| 4129 |
(match_operand:GPI 2 "register_operand" "r")))] |
| 4130 |
"" |
| 4131 |
"mul\\t%<w>0, %<w>1, %<w>2" |
| 4132 |
[(set_attr "type" "mul")] |
| 4133 |
) |
| 4134 |
|
| 4135 |
;; zero_extend version of above |
| 4136 |
(define_insn "*mulsi3_uxtw" |
| 4137 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 4138 |
(zero_extend:DI |
| 4139 |
(mult:SI (match_operand:SI 1 "register_operand" "r") |
| 4140 |
(match_operand:SI 2 "register_operand" "r"))))] |
| 4141 |
"" |
| 4142 |
"mul\\t%w0, %w1, %w2" |
| 4143 |
[(set_attr "type" "mul")] |
| 4144 |
) |
| 4145 |
|
| 4146 |
(define_insn "madd<mode>" |
| 4147 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 4148 |
(plus:GPI (mult:GPI (match_operand:GPI 1 "register_operand" "r") |
| 4149 |
(match_operand:GPI 2 "register_operand" "r")) |
| 4150 |
(match_operand:GPI 3 "register_operand" "r")))] |
| 4151 |
"" |
| 4152 |
"madd\\t%<w>0, %<w>1, %<w>2, %<w>3" |
| 4153 |
[(set_attr "type" "mla")] |
| 4154 |
) |
| 4155 |
|
| 4156 |
;; zero_extend version of above |
| 4157 |
(define_insn "*maddsi_uxtw" |
| 4158 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 4159 |
(zero_extend:DI |
| 4160 |
(plus:SI (mult:SI (match_operand:SI 1 "register_operand" "r") |
| 4161 |
(match_operand:SI 2 "register_operand" "r")) |
| 4162 |
(match_operand:SI 3 "register_operand" "r"))))] |
| 4163 |
"" |
| 4164 |
"madd\\t%w0, %w1, %w2, %w3" |
| 4165 |
[(set_attr "type" "mla")] |
| 4166 |
) |
| 4167 |
|
| 4168 |
(define_insn "*msub<mode>" |
| 4169 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 4170 |
(minus:GPI (match_operand:GPI 3 "register_operand" "r") |
| 4171 |
(mult:GPI (match_operand:GPI 1 "register_operand" "r") |
| 4172 |
(match_operand:GPI 2 "register_operand" "r"))))] |
| 4173 |
|
| 4174 |
"" |
| 4175 |
"msub\\t%<w>0, %<w>1, %<w>2, %<w>3" |
| 4176 |
[(set_attr "type" "mla")] |
| 4177 |
) |
| 4178 |
|
| 4179 |
;; zero_extend version of above |
| 4180 |
(define_insn "*msubsi_uxtw" |
| 4181 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 4182 |
(zero_extend:DI |
| 4183 |
(minus:SI (match_operand:SI 3 "register_operand" "r") |
| 4184 |
(mult:SI (match_operand:SI 1 "register_operand" "r") |
| 4185 |
(match_operand:SI 2 "register_operand" "r")))))] |
| 4186 |
|
| 4187 |
"" |
| 4188 |
"msub\\t%w0, %w1, %w2, %w3" |
| 4189 |
[(set_attr "type" "mla")] |
| 4190 |
) |
| 4191 |
|
| 4192 |
(define_insn "*mul<mode>_neg" |
| 4193 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 4194 |
(mult:GPI (neg:GPI (match_operand:GPI 1 "register_operand" "r")) |
| 4195 |
(match_operand:GPI 2 "register_operand" "r")))] |
| 4196 |
|
| 4197 |
"" |
| 4198 |
"mneg\\t%<w>0, %<w>1, %<w>2" |
| 4199 |
[(set_attr "type" "mul")] |
| 4200 |
) |
| 4201 |
|
| 4202 |
;; zero_extend version of above |
| 4203 |
(define_insn "*mulsi_neg_uxtw" |
| 4204 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 4205 |
(zero_extend:DI |
| 4206 |
(mult:SI (neg:SI (match_operand:SI 1 "register_operand" "r")) |
| 4207 |
(match_operand:SI 2 "register_operand" "r"))))] |
| 4208 |
|
| 4209 |
"" |
| 4210 |
"mneg\\t%w0, %w1, %w2" |
| 4211 |
[(set_attr "type" "mul")] |
| 4212 |
) |
| 4213 |
|
| 4214 |
(define_insn "<su_optab>mulsidi3" |
| 4215 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 4216 |
(mult:DI (ANY_EXTEND:DI (match_operand:SI 1 "register_operand" "r")) |
| 4217 |
(ANY_EXTEND:DI (match_operand:SI 2 "register_operand" "r"))))] |
| 4218 |
"" |
| 4219 |
"<su>mull\\t%0, %w1, %w2" |
| 4220 |
[(set_attr "type" "<su>mull")] |
| 4221 |
) |
| 4222 |
|
| 4223 |
(define_insn "<su_optab>maddsidi4" |
| 4224 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 4225 |
(plus:DI (mult:DI |
| 4226 |
(ANY_EXTEND:DI (match_operand:SI 1 "register_operand" "r")) |
| 4227 |
(ANY_EXTEND:DI (match_operand:SI 2 "register_operand" "r"))) |
| 4228 |
(match_operand:DI 3 "register_operand" "r")))] |
| 4229 |
"" |
| 4230 |
"<su>maddl\\t%0, %w1, %w2, %3" |
| 4231 |
[(set_attr "type" "<su>mlal")] |
| 4232 |
) |
| 4233 |
|
| 4234 |
(define_insn "<su_optab>msubsidi4" |
| 4235 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 4236 |
(minus:DI |
| 4237 |
(match_operand:DI 3 "register_operand" "r") |
| 4238 |
(mult:DI (ANY_EXTEND:DI (match_operand:SI 1 "register_operand" "r")) |
| 4239 |
(ANY_EXTEND:DI |
| 4240 |
(match_operand:SI 2 "register_operand" "r")))))] |
| 4241 |
"" |
| 4242 |
"<su>msubl\\t%0, %w1, %w2, %3" |
| 4243 |
[(set_attr "type" "<su>mlal")] |
| 4244 |
) |
| 4245 |
|
| 4246 |
(define_insn "*<su_optab>mulsidi_neg" |
| 4247 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 4248 |
(mult:DI (neg:DI |
| 4249 |
(ANY_EXTEND:DI (match_operand:SI 1 "register_operand" "r"))) |
| 4250 |
(ANY_EXTEND:DI (match_operand:SI 2 "register_operand" "r"))))] |
| 4251 |
"" |
| 4252 |
"<su>mnegl\\t%0, %w1, %w2" |
| 4253 |
[(set_attr "type" "<su>mull")] |
| 4254 |
) |
| 4255 |
|
| 4256 |
(define_expand "<su_optab>mulditi3" |
| 4257 |
[(set (match_operand:TI 0 "register_operand") |
| 4258 |
(mult:TI (ANY_EXTEND:TI (match_operand:DI 1 "register_operand")) |
| 4259 |
(ANY_EXTEND:TI (match_operand:DI 2 "register_operand"))))] |
| 4260 |
"" |
| 4261 |
{ |
| 4262 |
rtx low = gen_reg_rtx (DImode); |
| 4263 |
emit_insn (gen_muldi3 (low, operands[1], operands[2])); |
| 4264 |
|
| 4265 |
rtx high = gen_reg_rtx (DImode); |
| 4266 |
emit_insn (gen_<su>muldi3_highpart (high, operands[1], operands[2])); |
| 4267 |
|
| 4268 |
emit_move_insn (gen_lowpart (DImode, operands[0]), low); |
| 4269 |
emit_move_insn (gen_highpart (DImode, operands[0]), high); |
| 4270 |
DONE; |
| 4271 |
}) |
| 4272 |
|
| 4273 |
;; The default expansion of multi3 using umuldi3_highpart will perform |
| 4274 |
;; the additions in an order that fails to combine into two madd insns. |
| 4275 |
(define_expand "multi3" |
| 4276 |
[(set (match_operand:TI 0 "register_operand") |
| 4277 |
(mult:TI (match_operand:TI 1 "register_operand") |
| 4278 |
(match_operand:TI 2 "register_operand")))] |
| 4279 |
"" |
| 4280 |
{ |
| 4281 |
rtx l0 = gen_reg_rtx (DImode); |
| 4282 |
rtx l1 = gen_lowpart (DImode, operands[1]); |
| 4283 |
rtx l2 = gen_lowpart (DImode, operands[2]); |
| 4284 |
rtx h0 = gen_reg_rtx (DImode); |
| 4285 |
rtx h1 = gen_highpart (DImode, operands[1]); |
| 4286 |
rtx h2 = gen_highpart (DImode, operands[2]); |
| 4287 |
|
| 4288 |
emit_insn (gen_muldi3 (l0, l1, l2)); |
| 4289 |
emit_insn (gen_umuldi3_highpart (h0, l1, l2)); |
| 4290 |
emit_insn (gen_madddi (h0, h1, l2, h0)); |
| 4291 |
emit_insn (gen_madddi (h0, l1, h2, h0)); |
| 4292 |
|
| 4293 |
emit_move_insn (gen_lowpart (DImode, operands[0]), l0); |
| 4294 |
emit_move_insn (gen_highpart (DImode, operands[0]), h0); |
| 4295 |
DONE; |
| 4296 |
}) |
| 4297 |
|
| 4298 |
(define_insn "<su>muldi3_highpart" |
| 4299 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 4300 |
(truncate:DI |
| 4301 |
(lshiftrt:TI |
| 4302 |
(mult:TI |
| 4303 |
(ANY_EXTEND:TI (match_operand:DI 1 "register_operand" "r")) |
| 4304 |
(ANY_EXTEND:TI (match_operand:DI 2 "register_operand" "r"))) |
| 4305 |
(const_int 64))))] |
| 4306 |
"" |
| 4307 |
"<su>mulh\\t%0, %1, %2" |
| 4308 |
[(set_attr "type" "<su>mull")] |
| 4309 |
) |
| 4310 |
|
| 4311 |
(define_insn "<su_optab>div<mode>3" |
| 4312 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 4313 |
(ANY_DIV:GPI (match_operand:GPI 1 "register_operand" "r") |
| 4314 |
(match_operand:GPI 2 "register_operand" "r")))] |
| 4315 |
"" |
| 4316 |
"<su>div\\t%<w>0, %<w>1, %<w>2" |
| 4317 |
[(set_attr "type" "<su>div")] |
| 4318 |
) |
| 4319 |
|
| 4320 |
;; zero_extend version of above |
| 4321 |
(define_insn "*<su_optab>divsi3_uxtw" |
| 4322 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 4323 |
(zero_extend:DI |
| 4324 |
(ANY_DIV:SI (match_operand:SI 1 "register_operand" "r") |
| 4325 |
(match_operand:SI 2 "register_operand" "r"))))] |
| 4326 |
"" |
| 4327 |
"<su>div\\t%w0, %w1, %w2" |
| 4328 |
[(set_attr "type" "<su>div")] |
| 4329 |
) |
| 4330 |
|
| 4331 |
;; ------------------------------------------------------------------- |
| 4332 |
;; Comparison insns |
| 4333 |
;; ------------------------------------------------------------------- |
| 4334 |
|
| 4335 |
(define_insn "cmp<mode>" |
| 4336 |
[(set (reg:CC CC_REGNUM) |
| 4337 |
(compare:CC (match_operand:GPI 0 "register_operand") |
| 4338 |
(match_operand:GPI 1 "aarch64_plus_operand")))] |
| 4339 |
"" |
| 4340 |
{@ [ cons: 0 , 1 ; attrs: type ] |
| 4341 |
[ rk , r ; alus_sreg ] cmp\t%<w>0, %<w>1 |
| 4342 |
[ rk , I ; alus_imm ] cmp\t%<w>0, %1 |
| 4343 |
[ rk , J ; alus_imm ] cmn\t%<w>0, #%n1 |
| 4344 |
} |
| 4345 |
) |
| 4346 |
|
| 4347 |
(define_insn "fcmp<mode>" |
| 4348 |
[(set (reg:CCFP CC_REGNUM) |
| 4349 |
(compare:CCFP (match_operand:GPF 0 "register_operand") |
| 4350 |
(match_operand:GPF 1 "aarch64_fp_compare_operand")))] |
| 4351 |
"TARGET_FLOAT" |
| 4352 |
{@ [ cons: 0 , 1 ] |
| 4353 |
[ w , Y ] fcmp\t%<s>0, #0.0 |
| 4354 |
[ w , w ] fcmp\t%<s>0, %<s>1 |
| 4355 |
} |
| 4356 |
[(set_attr "type" "fcmp<s>")] |
| 4357 |
) |
| 4358 |
|
| 4359 |
(define_insn "fcmpe<mode>" |
| 4360 |
[(set (reg:CCFPE CC_REGNUM) |
| 4361 |
(compare:CCFPE (match_operand:GPF 0 "register_operand") |
| 4362 |
(match_operand:GPF 1 "aarch64_fp_compare_operand")))] |
| 4363 |
"TARGET_FLOAT" |
| 4364 |
{@ [ cons: 0 , 1 ] |
| 4365 |
[ w , Y ] fcmpe\t%<s>0, #0.0 |
| 4366 |
[ w , w ] fcmpe\t%<s>0, %<s>1 |
| 4367 |
} |
| 4368 |
[(set_attr "type" "fcmp<s>")] |
| 4369 |
) |
| 4370 |
|
| 4371 |
(define_insn "*cmp_swp_<shift>_reg<mode>" |
| 4372 |
[(set (reg:CC_SWP CC_REGNUM) |
| 4373 |
(compare:CC_SWP (ASHIFT:GPI |
| 4374 |
(match_operand:GPI 0 "register_operand" "r") |
| 4375 |
(match_operand:QI 1 "aarch64_shift_imm_<mode>" "n")) |
| 4376 |
(match_operand:GPI 2 "aarch64_reg_or_zero" "rZ")))] |
| 4377 |
"" |
| 4378 |
"cmp\\t%<w>2, %<w>0, <shift> %1" |
| 4379 |
[(set_attr "type" "alus_shift_imm")] |
| 4380 |
) |
| 4381 |
|
| 4382 |
(define_insn "*cmp_swp_<optab><ALLX:mode>_reg<GPI:mode>" |
| 4383 |
[(set (reg:CC_SWP CC_REGNUM) |
| 4384 |
(compare:CC_SWP (ANY_EXTEND:GPI |
| 4385 |
(match_operand:ALLX 0 "register_operand" "r")) |
| 4386 |
(match_operand:GPI 1 "register_operand" "r")))] |
| 4387 |
"" |
| 4388 |
"cmp\\t%<GPI:w>1, %w0, <su>xt<ALLX:size>" |
| 4389 |
[(set_attr "type" "alus_ext")] |
| 4390 |
) |
| 4391 |
|
| 4392 |
(define_insn "*cmp_swp_<optab><ALLX:mode>_shft_<GPI:mode>" |
| 4393 |
[(set (reg:CC_SWP CC_REGNUM) |
| 4394 |
(compare:CC_SWP (ashift:GPI |
| 4395 |
(ANY_EXTEND:GPI |
| 4396 |
(match_operand:ALLX 0 "register_operand" "r")) |
| 4397 |
(match_operand 1 "aarch64_imm3" "Ui3")) |
| 4398 |
(match_operand:GPI 2 "register_operand" "r")))] |
| 4399 |
"" |
| 4400 |
"cmp\\t%<GPI:w>2, %w0, <su>xt<ALLX:size> %1" |
| 4401 |
[(set_attr "type" "alus_ext")] |
| 4402 |
) |
| 4403 |
|
| 4404 |
;; ------------------------------------------------------------------- |
| 4405 |
;; Store-flag and conditional select insns |
| 4406 |
;; ------------------------------------------------------------------- |
| 4407 |
|
| 4408 |
(define_expand "cstore<mode>4" |
| 4409 |
[(set (match_operand:SI 0 "register_operand") |
| 4410 |
(match_operator:SI 1 "aarch64_comparison_operator" |
| 4411 |
[(match_operand:GPI 2 "register_operand") |
| 4412 |
(match_operand:GPI 3 "aarch64_plus_operand")]))] |
| 4413 |
"" |
| 4414 |
" |
| 4415 |
operands[2] = aarch64_gen_compare_reg (GET_CODE (operands[1]), operands[2], |
| 4416 |
operands[3]); |
| 4417 |
operands[3] = const0_rtx; |
| 4418 |
" |
| 4419 |
) |
| 4420 |
|
| 4421 |
(define_expand "cstorecc4" |
| 4422 |
[(set (match_operand:SI 0 "register_operand") |
| 4423 |
(match_operator 1 "aarch64_comparison_operator_mode" |
| 4424 |
[(match_operand 2 "cc_register") |
| 4425 |
(match_operand 3 "const0_operand")]))] |
| 4426 |
"" |
| 4427 |
"{ |
| 4428 |
emit_insn (gen_rtx_SET (operands[0], operands[1])); |
| 4429 |
DONE; |
| 4430 |
}") |
| 4431 |
|
| 4432 |
|
| 4433 |
(define_expand "cstore<mode>4" |
| 4434 |
[(set (match_operand:SI 0 "register_operand") |
| 4435 |
(match_operator:SI 1 "aarch64_comparison_operator_mode" |
| 4436 |
[(match_operand:GPF 2 "register_operand") |
| 4437 |
(match_operand:GPF 3 "aarch64_fp_compare_operand")]))] |
| 4438 |
"" |
| 4439 |
" |
| 4440 |
operands[2] = aarch64_gen_compare_reg (GET_CODE (operands[1]), operands[2], |
| 4441 |
operands[3]); |
| 4442 |
operands[3] = const0_rtx; |
| 4443 |
" |
| 4444 |
) |
| 4445 |
|
| 4446 |
(define_insn "aarch64_cstore<mode>" |
| 4447 |
[(set (match_operand:ALLI 0 "register_operand" "=r") |
| 4448 |
(match_operator:ALLI 1 "aarch64_comparison_operator_mode" |
| 4449 |
[(match_operand 2 "cc_register" "") (const_int 0)]))] |
| 4450 |
"" |
| 4451 |
"cset\\t%<w>0, %m1" |
| 4452 |
[(set_attr "type" "csel")] |
| 4453 |
) |
| 4454 |
|
| 4455 |
;; For a 24-bit immediate CST we can optimize the compare for equality |
| 4456 |
;; and branch sequence from: |
| 4457 |
;; mov x0, #imm1 |
| 4458 |
;; movk x0, #imm2, lsl 16 /* x0 contains CST. */ |
| 4459 |
;; cmp x1, x0 |
| 4460 |
;; cset x2, <ne,eq> |
| 4461 |
;; into the shorter: |
| 4462 |
;; sub x0, x1, #(CST & 0xfff000) |
| 4463 |
;; subs x0, x0, #(CST & 0x000fff) |
| 4464 |
;; cset x2, <ne, eq>. |
| 4465 |
(define_insn_and_split "*compare_cstore<mode>_insn" |
| 4466 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 4467 |
(EQL:GPI (match_operand:GPI 1 "register_operand" "r") |
| 4468 |
(match_operand:GPI 2 "aarch64_imm24" "n"))) |
| 4469 |
(clobber (reg:CC CC_REGNUM))] |
| 4470 |
"!aarch64_move_imm (INTVAL (operands[2]), <MODE>mode) |
| 4471 |
&& !aarch64_plus_operand (operands[2], <MODE>mode) |
| 4472 |
&& !reload_completed" |
| 4473 |
"#" |
| 4474 |
"&& true" |
| 4475 |
[(const_int 0)] |
| 4476 |
{ |
| 4477 |
HOST_WIDE_INT lo_imm = UINTVAL (operands[2]) & 0xfff; |
| 4478 |
HOST_WIDE_INT hi_imm = UINTVAL (operands[2]) & 0xfff000; |
| 4479 |
rtx tmp = gen_reg_rtx (<MODE>mode); |
| 4480 |
emit_insn (gen_add<mode>3 (tmp, operands[1], GEN_INT (-hi_imm))); |
| 4481 |
emit_insn (gen_add<mode>3_compare0 (tmp, tmp, GEN_INT (-lo_imm))); |
| 4482 |
rtx cc_reg = gen_rtx_REG (CC_NZmode, CC_REGNUM); |
| 4483 |
rtx cmp_rtx = gen_rtx_fmt_ee (<EQL:CMP>, <MODE>mode, cc_reg, const0_rtx); |
| 4484 |
emit_insn (gen_aarch64_cstore<mode> (operands[0], cmp_rtx, cc_reg)); |
| 4485 |
DONE; |
| 4486 |
} |
| 4487 |
[(set_attr "type" "csel")] |
| 4488 |
) |
| 4489 |
|
| 4490 |
;; zero_extend version of the above |
| 4491 |
(define_insn "*cstoresi_insn_uxtw" |
| 4492 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 4493 |
(zero_extend:DI |
| 4494 |
(match_operator:SI 1 "aarch64_comparison_operator_mode" |
| 4495 |
[(match_operand 2 "cc_register" "") (const_int 0)])))] |
| 4496 |
"" |
| 4497 |
"cset\\t%w0, %m1" |
| 4498 |
[(set_attr "type" "csel")] |
| 4499 |
) |
| 4500 |
|
| 4501 |
(define_insn "cstore<mode>_neg" |
| 4502 |
[(set (match_operand:ALLI 0 "register_operand" "=r") |
| 4503 |
(neg:ALLI (match_operator:ALLI 1 "aarch64_comparison_operator_mode" |
| 4504 |
[(match_operand 2 "cc_register" "") (const_int 0)])))] |
| 4505 |
"" |
| 4506 |
"csetm\\t%<w>0, %m1" |
| 4507 |
[(set_attr "type" "csel")] |
| 4508 |
) |
| 4509 |
|
| 4510 |
;; zero_extend version of the above |
| 4511 |
(define_insn "*cstoresi_neg_uxtw" |
| 4512 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 4513 |
(zero_extend:DI |
| 4514 |
(neg:SI (match_operator:SI 1 "aarch64_comparison_operator_mode" |
| 4515 |
[(match_operand 2 "cc_register" "") (const_int 0)]))))] |
| 4516 |
"" |
| 4517 |
"csetm\\t%w0, %m1" |
| 4518 |
[(set_attr "type" "csel")] |
| 4519 |
) |
| 4520 |
|
| 4521 |
(define_expand "cmov<mode>6" |
| 4522 |
[(set (match_operand:GPI 0 "register_operand") |
| 4523 |
(if_then_else:GPI |
| 4524 |
(match_operator 1 "aarch64_comparison_operator" |
| 4525 |
[(match_operand:GPI 2 "register_operand") |
| 4526 |
(match_operand:GPI 3 "aarch64_plus_operand")]) |
| 4527 |
(match_operand:GPI 4 "register_operand") |
| 4528 |
(match_operand:GPI 5 "register_operand")))] |
| 4529 |
"" |
| 4530 |
" |
| 4531 |
operands[2] = aarch64_gen_compare_reg (GET_CODE (operands[1]), operands[2], |
| 4532 |
operands[3]); |
| 4533 |
operands[3] = const0_rtx; |
| 4534 |
" |
| 4535 |
) |
| 4536 |
|
| 4537 |
(define_expand "cmov<mode>6" |
| 4538 |
[(set (match_operand:GPF 0 "register_operand") |
| 4539 |
(if_then_else:GPF |
| 4540 |
(match_operator 1 "aarch64_comparison_operator" |
| 4541 |
[(match_operand:GPF 2 "register_operand") |
| 4542 |
(match_operand:GPF 3 "aarch64_fp_compare_operand")]) |
| 4543 |
(match_operand:GPF 4 "register_operand") |
| 4544 |
(match_operand:GPF 5 "register_operand")))] |
| 4545 |
"" |
| 4546 |
" |
| 4547 |
operands[2] = aarch64_gen_compare_reg (GET_CODE (operands[1]), operands[2], |
| 4548 |
operands[3]); |
| 4549 |
operands[3] = const0_rtx; |
| 4550 |
" |
| 4551 |
) |
| 4552 |
|
| 4553 |
(define_insn "*cmov<mode>_insn" |
| 4554 |
[(set (match_operand:ALLI 0 "register_operand") |
| 4555 |
(if_then_else:ALLI |
| 4556 |
(match_operator 1 "aarch64_comparison_operator" |
| 4557 |
[(match_operand 2 "cc_register") (const_int 0)]) |
| 4558 |
(match_operand:ALLI 3 "aarch64_reg_zero_or_m1_or_1") |
| 4559 |
(match_operand:ALLI 4 "aarch64_reg_zero_or_m1_or_1")))] |
| 4560 |
"!((operands[3] == const1_rtx && operands[4] == constm1_rtx) |
| 4561 |
|| (operands[3] == constm1_rtx && operands[4] == const1_rtx))" |
| 4562 |
;; Final two alternatives should be unreachable, but included for completeness |
| 4563 |
{@ [ cons: =0 , 3 , 4 ; attrs: type ] |
| 4564 |
[ r , rZ , rZ ; csel ] csel\t%<w>0, %<w>3, %<w>4, %m1 |
| 4565 |
[ r , rZ , UsM ; csel ] csinv\t%<w>0, %<w>3, <w>zr, %m1 |
| 4566 |
[ r , UsM , rZ ; csel ] csinv\t%<w>0, %<w>4, <w>zr, %M1 |
| 4567 |
[ r , rZ , Ui1 ; csel ] csinc\t%<w>0, %<w>3, <w>zr, %m1 |
| 4568 |
[ r , Ui1 , rZ ; csel ] csinc\t%<w>0, %<w>4, <w>zr, %M1 |
| 4569 |
[ r , UsM , UsM ; mov_imm ] mov\t%<w>0, -1 |
| 4570 |
[ r , Ui1 , Ui1 ; mov_imm ] mov\t%<w>0, 1 |
| 4571 |
} |
| 4572 |
) |
| 4573 |
|
| 4574 |
;; zero_extend version of above |
| 4575 |
(define_insn "*cmovsi_insn_uxtw" |
| 4576 |
[(set (match_operand:DI 0 "register_operand") |
| 4577 |
(zero_extend:DI |
| 4578 |
(if_then_else:SI |
| 4579 |
(match_operator 1 "aarch64_comparison_operator" |
| 4580 |
[(match_operand 2 "cc_register") (const_int 0)]) |
| 4581 |
(match_operand:SI 3 "aarch64_reg_zero_or_m1_or_1") |
| 4582 |
(match_operand:SI 4 "aarch64_reg_zero_or_m1_or_1"))))] |
| 4583 |
"!((operands[3] == const1_rtx && operands[4] == constm1_rtx) |
| 4584 |
|| (operands[3] == constm1_rtx && operands[4] == const1_rtx))" |
| 4585 |
;; Final two alternatives should be unreachable, but included for completeness |
| 4586 |
{@ [ cons: =0 , 3 , 4 ; attrs: type ] |
| 4587 |
[ r , rZ , rZ ; csel ] csel\t%w0, %w3, %w4, %m1 |
| 4588 |
[ r , rZ , UsM ; csel ] csinv\t%w0, %w3, wzr, %m1 |
| 4589 |
[ r , UsM , rZ ; csel ] csinv\t%w0, %w4, wzr, %M1 |
| 4590 |
[ r , rZ , Ui1 ; csel ] csinc\t%w0, %w3, wzr, %m1 |
| 4591 |
[ r , Ui1 , rZ ; csel ] csinc\t%w0, %w4, wzr, %M1 |
| 4592 |
[ r , UsM , UsM ; mov_imm ] mov\t%w0, -1 |
| 4593 |
[ r , Ui1 , Ui1 ; mov_imm ] mov\t%w0, 1 |
| 4594 |
} |
| 4595 |
) |
| 4596 |
|
| 4597 |
;; There are two canonical forms for `cmp ? -1 : a`. |
| 4598 |
;; This is the second form and is here to help combine. |
| 4599 |
;; Support `-(cmp) | a` into `cmp ? -1 : a` to be canonical in the backend. |
| 4600 |
(define_insn_and_split "*cmov<mode>_insn_m1" |
| 4601 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 4602 |
(ior:GPI |
| 4603 |
(neg:GPI |
| 4604 |
(match_operator:GPI 1 "aarch64_comparison_operator" |
| 4605 |
[(match_operand 2 "cc_register" "") (const_int 0)])) |
| 4606 |
(match_operand 3 "register_operand" "r")))] |
| 4607 |
"" |
| 4608 |
"#" |
| 4609 |
"&& true" |
| 4610 |
[(set (match_dup 0) |
| 4611 |
(if_then_else:GPI (match_dup 1) |
| 4612 |
(const_int -1) |
| 4613 |
(match_dup 3)))] |
| 4614 |
{} |
| 4615 |
[(set_attr "type" "csel")] |
| 4616 |
) |
| 4617 |
|
| 4618 |
(define_insn "*cmovdi_insn_uxtw" |
| 4619 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 4620 |
(if_then_else:DI |
| 4621 |
(match_operator 1 "aarch64_comparison_operator" |
| 4622 |
[(match_operand 2 "cc_register" "") (const_int 0)]) |
| 4623 |
(zero_extend:DI (match_operand:SI 3 "register_operand" "r")) |
| 4624 |
(zero_extend:DI (match_operand:SI 4 "register_operand" "r"))))] |
| 4625 |
"" |
| 4626 |
"csel\\t%w0, %w3, %w4, %m1" |
| 4627 |
[(set_attr "type" "csel")] |
| 4628 |
) |
| 4629 |
|
| 4630 |
(define_insn "*cmov<mode>_insn" |
| 4631 |
[(set (match_operand:GPF 0 "register_operand" "=w") |
| 4632 |
(if_then_else:GPF |
| 4633 |
(match_operator 1 "aarch64_comparison_operator" |
| 4634 |
[(match_operand 2 "cc_register" "") (const_int 0)]) |
| 4635 |
(match_operand:GPF 3 "register_operand" "w") |
| 4636 |
(match_operand:GPF 4 "register_operand" "w")))] |
| 4637 |
"TARGET_FLOAT" |
| 4638 |
"fcsel\\t%<s>0, %<s>3, %<s>4, %m1" |
| 4639 |
[(set_attr "type" "fcsel")] |
| 4640 |
) |
| 4641 |
|
| 4642 |
(define_expand "mov<mode>cc" |
| 4643 |
[(set (match_operand:ALLI 0 "register_operand") |
| 4644 |
(if_then_else:ALLI (match_operand 1 "aarch64_comparison_operator") |
| 4645 |
(match_operand:ALLI 2 "register_operand") |
| 4646 |
(match_operand:ALLI 3 "register_operand")))] |
| 4647 |
"" |
| 4648 |
{ |
| 4649 |
rtx ccreg; |
| 4650 |
enum rtx_code code = GET_CODE (operands[1]); |
| 4651 |
|
| 4652 |
if (code == UNEQ || code == LTGT) |
| 4653 |
FAIL; |
| 4654 |
|
| 4655 |
ccreg = aarch64_gen_compare_reg (code, XEXP (operands[1], 0), |
| 4656 |
XEXP (operands[1], 1)); |
| 4657 |
operands[1] = gen_rtx_fmt_ee (code, VOIDmode, ccreg, const0_rtx); |
| 4658 |
} |
| 4659 |
) |
| 4660 |
|
| 4661 |
(define_expand "mov<GPF:mode><GPI:mode>cc" |
| 4662 |
[(set (match_operand:GPI 0 "register_operand") |
| 4663 |
(if_then_else:GPI (match_operand 1 "aarch64_comparison_operator") |
| 4664 |
(match_operand:GPF 2 "register_operand") |
| 4665 |
(match_operand:GPF 3 "register_operand")))] |
| 4666 |
"" |
| 4667 |
{ |
| 4668 |
rtx ccreg; |
| 4669 |
enum rtx_code code = GET_CODE (operands[1]); |
| 4670 |
|
| 4671 |
if (code == UNEQ || code == LTGT) |
| 4672 |
FAIL; |
| 4673 |
|
| 4674 |
ccreg = aarch64_gen_compare_reg (code, XEXP (operands[1], 0), |
| 4675 |
XEXP (operands[1], 1)); |
| 4676 |
operands[1] = gen_rtx_fmt_ee (code, VOIDmode, ccreg, const0_rtx); |
| 4677 |
} |
| 4678 |
) |
| 4679 |
|
| 4680 |
(define_expand "mov<mode>cc" |
| 4681 |
[(set (match_operand:GPF 0 "register_operand") |
| 4682 |
(if_then_else:GPF (match_operand 1 "aarch64_comparison_operator") |
| 4683 |
(match_operand:GPF 2 "register_operand") |
| 4684 |
(match_operand:GPF 3 "register_operand")))] |
| 4685 |
"" |
| 4686 |
{ |
| 4687 |
rtx ccreg; |
| 4688 |
enum rtx_code code = GET_CODE (operands[1]); |
| 4689 |
|
| 4690 |
if (code == UNEQ || code == LTGT) |
| 4691 |
FAIL; |
| 4692 |
|
| 4693 |
ccreg = aarch64_gen_compare_reg (code, XEXP (operands[1], 0), |
| 4694 |
XEXP (operands[1], 1)); |
| 4695 |
operands[1] = gen_rtx_fmt_ee (code, VOIDmode, ccreg, const0_rtx); |
| 4696 |
} |
| 4697 |
) |
| 4698 |
|
| 4699 |
(define_expand "<neg_not_op><mode>cc" |
| 4700 |
[(set (match_operand:GPI 0 "register_operand") |
| 4701 |
(if_then_else:GPI (match_operand 1 "aarch64_comparison_operator") |
| 4702 |
(NEG_NOT:GPI (match_operand:GPI 2 "register_operand")) |
| 4703 |
(match_operand:GPI 3 "register_operand")))] |
| 4704 |
"" |
| 4705 |
{ |
| 4706 |
rtx ccreg; |
| 4707 |
enum rtx_code code = GET_CODE (operands[1]); |
| 4708 |
|
| 4709 |
if (code == UNEQ || code == LTGT) |
| 4710 |
FAIL; |
| 4711 |
|
| 4712 |
ccreg = aarch64_gen_compare_reg (code, XEXP (operands[1], 0), |
| 4713 |
XEXP (operands[1], 1)); |
| 4714 |
operands[1] = gen_rtx_fmt_ee (code, VOIDmode, ccreg, const0_rtx); |
| 4715 |
} |
| 4716 |
) |
| 4717 |
|
| 4718 |
;; CRC32 instructions. |
| 4719 |
(define_insn "aarch64_<crc_variant>" |
| 4720 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 4721 |
(unspec:SI [(match_operand:SI 1 "register_operand" "r") |
| 4722 |
(match_operand:<crc_mode> 2 "register_operand" "r")] |
| 4723 |
CRC))] |
| 4724 |
"TARGET_CRC32" |
| 4725 |
{ |
| 4726 |
if (GET_MODE_BITSIZE (<crc_mode>mode) >= 64) |
| 4727 |
return "<crc_variant>\\t%w0, %w1, %x2"; |
| 4728 |
else |
| 4729 |
return "<crc_variant>\\t%w0, %w1, %w2"; |
| 4730 |
} |
| 4731 |
[(set_attr "type" "crc")] |
| 4732 |
) |
| 4733 |
|
| 4734 |
;; Reversed CRC |
| 4735 |
(define_expand "crc_rev<ALLI:mode><ALLX:mode>4" |
| 4736 |
[;; return value (calculated CRC) |
| 4737 |
(match_operand:ALLX 0 "register_operand" "=r") |
| 4738 |
;; initial CRC |
| 4739 |
(match_operand:ALLX 1 "register_operand" "r") |
| 4740 |
;; data |
| 4741 |
(match_operand:ALLI 2 "register_operand" "r") |
| 4742 |
;; polynomial without leading 1 |
| 4743 |
(match_operand:ALLX 3 "const_int_operand")] |
| 4744 |
"" |
| 4745 |
{ |
| 4746 |
/* If the polynomial is the same as the polynomial of crc32c* instruction, |
| 4747 |
put that instruction. crc32c uses iSCSI polynomial. */ |
| 4748 |
if (TARGET_CRC32 && INTVAL (operands[3]) == 0x1EDC6F41 |
| 4749 |
&& <ALLX:MODE>mode == SImode) |
| 4750 |
emit_insn (gen_aarch64_crc32c<ALLI:crc_data_type> (operands[0], |
| 4751 |
operands[1], |
| 4752 |
operands[2])); |
| 4753 |
/* If the polynomial is the same as the polynomial of crc32* instruction, |
| 4754 |
put that instruction. crc32 uses HDLC etc. polynomial. */ |
| 4755 |
else if (TARGET_CRC32 && INTVAL (operands[3]) == 0x04C11DB7 |
| 4756 |
&& <ALLX:MODE>mode == SImode) |
| 4757 |
emit_insn (gen_aarch64_crc32<ALLI:crc_data_type> (operands[0], |
| 4758 |
operands[1], |
| 4759 |
operands[2])); |
| 4760 |
else if (TARGET_AES && <ALLI:sizen> <= <ALLX:sizen>) |
| 4761 |
aarch64_expand_reversed_crc_using_pmull (<ALLX:MODE>mode, |
| 4762 |
<ALLI:MODE>mode, |
| 4763 |
operands); |
| 4764 |
else |
| 4765 |
/* Otherwise, generate table-based CRC. */ |
| 4766 |
expand_reversed_crc_table_based (operands[0], operands[1], operands[2], |
| 4767 |
operands[3], <ALLI:MODE>mode, |
| 4768 |
generate_reflecting_code_standard); |
| 4769 |
DONE; |
| 4770 |
} |
| 4771 |
) |
| 4772 |
|
| 4773 |
;; Bit-forward CRC |
| 4774 |
(define_expand "crc<ALLI:mode><ALLX:mode>4" |
| 4775 |
[;; return value (calculated CRC) |
| 4776 |
(match_operand:ALLX 0 "register_operand" "=r") |
| 4777 |
;; initial CRC |
| 4778 |
(match_operand:ALLX 1 "register_operand" "r") |
| 4779 |
;; data |
| 4780 |
(match_operand:ALLI 2 "register_operand" "r") |
| 4781 |
;; polynomial without leading 1 |
| 4782 |
(match_operand:ALLX 3 "const_int_operand")] |
| 4783 |
"TARGET_AES && <ALLI:sizen> <= <ALLX:sizen>" |
| 4784 |
{ |
| 4785 |
aarch64_expand_crc_using_pmull (<ALLX:MODE>mode, <ALLI:MODE>mode, |
| 4786 |
operands); |
| 4787 |
DONE; |
| 4788 |
} |
| 4789 |
) |
| 4790 |
|
| 4791 |
(define_insn "*csinc2<mode>_insn" |
| 4792 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 4793 |
(plus:GPI (match_operand 2 "aarch64_comparison_operation" "") |
| 4794 |
(match_operand:GPI 1 "register_operand" "r")))] |
| 4795 |
"" |
| 4796 |
"cinc\\t%<w>0, %<w>1, %m2" |
| 4797 |
[(set_attr "type" "csel")] |
| 4798 |
) |
| 4799 |
|
| 4800 |
(define_insn "csinc3<mode>_insn" |
| 4801 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 4802 |
(if_then_else:GPI |
| 4803 |
(match_operand 1 "aarch64_comparison_operation" "") |
| 4804 |
(plus:GPI (match_operand:GPI 2 "register_operand" "r") |
| 4805 |
(const_int 1)) |
| 4806 |
(match_operand:GPI 3 "aarch64_reg_or_zero" "rZ")))] |
| 4807 |
"" |
| 4808 |
"csinc\\t%<w>0, %<w>3, %<w>2, %M1" |
| 4809 |
[(set_attr "type" "csel")] |
| 4810 |
) |
| 4811 |
|
| 4812 |
(define_insn "*csinv3<mode>_insn" |
| 4813 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 4814 |
(if_then_else:GPI |
| 4815 |
(match_operand 1 "aarch64_comparison_operation" "") |
| 4816 |
(not:GPI (match_operand:GPI 2 "register_operand" "r")) |
| 4817 |
(match_operand:GPI 3 "aarch64_reg_or_zero" "rZ")))] |
| 4818 |
"" |
| 4819 |
"csinv\\t%<w>0, %<w>3, %<w>2, %M1" |
| 4820 |
[(set_attr "type" "csel")] |
| 4821 |
) |
| 4822 |
|
| 4823 |
(define_insn "*cs<neg_not_cs>3_uxtw_insn4" |
| 4824 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 4825 |
(zero_extend:DI |
| 4826 |
(if_then_else:SI |
| 4827 |
(match_operand 1 "aarch64_comparison_operation" "") |
| 4828 |
(NEG_NOT:SI (match_operand:SI 2 "register_operand" "r")) |
| 4829 |
(match_operand:SI 3 "aarch64_reg_or_zero" "rZ"))))] |
| 4830 |
"" |
| 4831 |
"cs<neg_not_cs>\\t%w0, %w3, %w2, %M1" |
| 4832 |
[(set_attr "type" "csel")] |
| 4833 |
) |
| 4834 |
|
| 4835 |
(define_insn "csneg3<mode>_insn" |
| 4836 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 4837 |
(if_then_else:GPI |
| 4838 |
(match_operand 1 "aarch64_comparison_operation" "") |
| 4839 |
(neg:GPI (match_operand:GPI 2 "register_operand" "r")) |
| 4840 |
(match_operand:GPI 3 "aarch64_reg_or_zero" "rZ")))] |
| 4841 |
"" |
| 4842 |
"csneg\\t%<w>0, %<w>3, %<w>2, %M1" |
| 4843 |
[(set_attr "type" "csel")] |
| 4844 |
) |
| 4845 |
|
| 4846 |
(define_insn "*csinv3_uxtw_insn1" |
| 4847 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 4848 |
(if_then_else:DI |
| 4849 |
(match_operand 1 "aarch64_comparison_operation" "") |
| 4850 |
(zero_extend:DI |
| 4851 |
(match_operand:SI 2 "register_operand" "r")) |
| 4852 |
(zero_extend:DI |
| 4853 |
(NEG_NOT:SI (match_operand:SI 3 "register_operand" "r")))))] |
| 4854 |
"" |
| 4855 |
"cs<neg_not_cs>\\t%w0, %w2, %w3, %m1" |
| 4856 |
[(set_attr "type" "csel")] |
| 4857 |
) |
| 4858 |
|
| 4859 |
(define_insn "*csinv3_uxtw_insn2" |
| 4860 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 4861 |
(if_then_else:DI |
| 4862 |
(match_operand 1 "aarch64_comparison_operation" "") |
| 4863 |
(zero_extend:DI |
| 4864 |
(NEG_NOT:SI (match_operand:SI 2 "register_operand" "r"))) |
| 4865 |
(zero_extend:DI |
| 4866 |
(match_operand:SI 3 "register_operand" "r"))))] |
| 4867 |
"" |
| 4868 |
"cs<neg_not_cs>\\t%w0, %w3, %w2, %M1" |
| 4869 |
[(set_attr "type" "csel")] |
| 4870 |
) |
| 4871 |
|
| 4872 |
(define_insn "*csinv3_uxtw_insn3" |
| 4873 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 4874 |
(if_then_else:DI |
| 4875 |
(match_operand 1 "aarch64_comparison_operation" "") |
| 4876 |
(zero_extend:DI |
| 4877 |
(NEG_NOT:SI (match_operand:SI 2 "register_operand" "r"))) |
| 4878 |
(const_int 0)))] |
| 4879 |
"" |
| 4880 |
"cs<neg_not_cs>\\t%w0, wzr, %w2, %M1" |
| 4881 |
[(set_attr "type" "csel")] |
| 4882 |
) |
| 4883 |
|
| 4884 |
;; There are two canonical forms for `cmp ? ~a : a`. |
| 4885 |
;; This is the second form and is here to help combine. |
| 4886 |
;; Support `-(cmp) ^ a` into `cmp ? ~a : a` |
| 4887 |
;; The second pattern is to support the zero extend'ed version. |
| 4888 |
|
| 4889 |
(define_insn_and_split "*cmov<mode>_insn_insv" |
| 4890 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 4891 |
(xor:GPI |
| 4892 |
(neg:GPI |
| 4893 |
(match_operator:GPI 1 "aarch64_comparison_operator" |
| 4894 |
[(match_operand 2 "cc_register" "") (const_int 0)])) |
| 4895 |
(match_operand:GPI 3 "general_operand" "r")))] |
| 4896 |
"" |
| 4897 |
"#" |
| 4898 |
"&& true" |
| 4899 |
[(set (match_dup 0) |
| 4900 |
(if_then_else:GPI (match_dup 1) |
| 4901 |
(not:GPI (match_dup 3)) |
| 4902 |
(match_dup 3)))] |
| 4903 |
{ |
| 4904 |
/* After reload this will be a nop due to the constraint. */ |
| 4905 |
operands[3] = force_reg (<MODE>mode, operands[3]); |
| 4906 |
} |
| 4907 |
[(set_attr "type" "csel")] |
| 4908 |
) |
| 4909 |
|
| 4910 |
(define_insn_and_split "*cmov_uxtw_insn_insv" |
| 4911 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 4912 |
(zero_extend:DI |
| 4913 |
(xor:SI |
| 4914 |
(neg:SI |
| 4915 |
(match_operator:SI 1 "aarch64_comparison_operator" |
| 4916 |
[(match_operand 2 "cc_register" "") (const_int 0)])) |
| 4917 |
(match_operand:SI 3 "general_operand" "r"))))] |
| 4918 |
"" |
| 4919 |
"#" |
| 4920 |
"&& true" |
| 4921 |
[(set (match_dup 0) |
| 4922 |
(if_then_else:DI (match_dup 1) |
| 4923 |
(zero_extend:DI (not:SI (match_dup 3))) |
| 4924 |
(zero_extend:DI (match_dup 3))))] |
| 4925 |
{ |
| 4926 |
operands[3] = force_reg (SImode, operands[3]); |
| 4927 |
} |
| 4928 |
[(set_attr "type" "csel")] |
| 4929 |
) |
| 4930 |
|
| 4931 |
;; If X can be loaded by a single CNT[BHWD] instruction, |
| 4932 |
;; |
| 4933 |
;; A = UMAX (B, X) |
| 4934 |
;; |
| 4935 |
;; is equivalent to: |
| 4936 |
;; |
| 4937 |
;; TMP = UQDEC[BHWD] (B, X) |
| 4938 |
;; A = TMP + X |
| 4939 |
;; |
| 4940 |
;; Defining the pattern this way means that: |
| 4941 |
;; |
| 4942 |
;; A = UMAX (B, X) - X |
| 4943 |
;; |
| 4944 |
;; becomes: |
| 4945 |
;; |
| 4946 |
;; TMP1 = UQDEC[BHWD] (B, X) |
| 4947 |
;; TMP2 = TMP1 + X |
| 4948 |
;; A = TMP2 - X |
| 4949 |
;; |
| 4950 |
;; which combine can optimize to: |
| 4951 |
;; |
| 4952 |
;; A = UQDEC[BHWD] (B, X) |
| 4953 |
;; |
| 4954 |
;; We don't use match_operand predicates because the order of the operands |
| 4955 |
;; can vary: the CNT[BHWD] constant will come first if the other operand is |
| 4956 |
;; a simpler constant (such as a CONST_INT), otherwise it will come second. |
| 4957 |
(define_expand "umax<mode>3" |
| 4958 |
[(set (match_operand:GPI 0 "register_operand") |
| 4959 |
(umax:GPI (match_operand:GPI 1 "") |
| 4960 |
(match_operand:GPI 2 "")))] |
| 4961 |
"TARGET_SVE || TARGET_CSSC" |
| 4962 |
{ |
| 4963 |
if (aarch64_sve_cnt_immediate (operands[1], <MODE>mode)) |
| 4964 |
std::swap (operands[1], operands[2]); |
| 4965 |
else if (aarch64_sve_cnt_immediate (operands[2], <MODE>mode)) |
| 4966 |
; |
| 4967 |
else if (TARGET_CSSC) |
| 4968 |
{ |
| 4969 |
if (aarch64_uminmax_immediate (operands[1], <MODE>mode)) |
| 4970 |
std::swap (operands[1], operands[2]); |
| 4971 |
operands[1] = force_reg (<MODE>mode, operands[1]); |
| 4972 |
if (!aarch64_uminmax_operand (operands[2], <MODE>mode)) |
| 4973 |
operands[2] = force_reg (<MODE>mode, operands[2]); |
| 4974 |
emit_move_insn (operands[0], gen_rtx_UMAX (<MODE>mode, operands[1], |
| 4975 |
operands[2])); |
| 4976 |
DONE; |
| 4977 |
} |
| 4978 |
else |
| 4979 |
FAIL; |
| 4980 |
rtx temp = gen_reg_rtx (<MODE>mode); |
| 4981 |
operands[1] = force_reg (<MODE>mode, operands[1]); |
| 4982 |
emit_insn (gen_aarch64_uqdec<mode> (temp, operands[1], operands[2])); |
| 4983 |
emit_insn (gen_add<mode>3 (operands[0], temp, operands[2])); |
| 4984 |
DONE; |
| 4985 |
} |
| 4986 |
) |
| 4987 |
|
| 4988 |
;; Saturating unsigned subtraction of a CNT[BHWD] immediate. |
| 4989 |
(define_insn "aarch64_uqdec<mode>" |
| 4990 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 4991 |
(minus:GPI |
| 4992 |
(umax:GPI (match_operand:GPI 1 "register_operand" "0") |
| 4993 |
(match_operand:GPI 2 "aarch64_sve_cnt_immediate" "Usv")) |
| 4994 |
(match_dup 2)))] |
| 4995 |
"TARGET_SVE" |
| 4996 |
{ |
| 4997 |
return aarch64_output_sve_cnt_immediate ("uqdec", "%<w>0", operands[2]); |
| 4998 |
} |
| 4999 |
) |
| 5000 |
|
| 5001 |
;; Implement MAX/MIN (A, B) - C using SUBS/ADDS followed by CSEL/CSINV/CSINC. |
| 5002 |
;; See aarch64_maxmin_plus_const for details about the supported cases. |
| 5003 |
(define_insn_and_split "*aarch64_minmax_plus" |
| 5004 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 5005 |
(plus:GPI |
| 5006 |
(MAXMIN:GPI |
| 5007 |
(match_operand:GPI 1 "register_operand" "r") |
| 5008 |
(match_operand:GPI 2 "const_int_operand")) |
| 5009 |
(match_operand:GPI 3 "aarch64_plus_immediate"))) |
| 5010 |
(clobber (reg:CC CC_REGNUM))] |
| 5011 |
"aarch64_maxmin_plus_const (<CODE>, operands, false)" |
| 5012 |
"#" |
| 5013 |
"&& 1" |
| 5014 |
[(parallel |
| 5015 |
[(set (reg:CC CC_REGNUM) |
| 5016 |
(compare:CC (match_dup 1) (match_dup 4))) |
| 5017 |
(set (match_dup 6) |
| 5018 |
(plus:GPI (match_dup 1) (match_dup 3)))]) |
| 5019 |
(set (match_dup 0) |
| 5020 |
(if_then_else:GPI (match_dup 5) (match_dup 6) (match_dup 7)))] |
| 5021 |
{ |
| 5022 |
if (!aarch64_maxmin_plus_const (<CODE>, operands, true)) |
| 5023 |
gcc_unreachable (); |
| 5024 |
} |
| 5025 |
[(set_attr "length" "8")] |
| 5026 |
) |
| 5027 |
|
| 5028 |
;; ------------------------------------------------------------------- |
| 5029 |
;; Logical operations |
| 5030 |
;; ------------------------------------------------------------------- |
| 5031 |
|
| 5032 |
|
| 5033 |
(define_insn_and_split "*aarch64_and<mode>_imm2" |
| 5034 |
[(set (match_operand:GPI 0 "register_operand" "=rk") |
| 5035 |
(and:GPI (match_operand:GPI 1 "register_operand" "%r") |
| 5036 |
(match_operand:GPI 2 "aarch64_logical_and_immediate" "<lconst2>")))] |
| 5037 |
"" |
| 5038 |
"#" |
| 5039 |
"true" |
| 5040 |
[(const_int 0)] |
| 5041 |
{ |
| 5042 |
HOST_WIDE_INT val = INTVAL (operands[2]); |
| 5043 |
rtx imm1 = GEN_INT (aarch64_and_split_imm1 (val)); |
| 5044 |
rtx imm2 = GEN_INT (aarch64_and_split_imm2 (val)); |
| 5045 |
|
| 5046 |
emit_insn (gen_and<mode>3 (operands[0], operands[1], imm1)); |
| 5047 |
emit_insn (gen_and<mode>3 (operands[0], operands[0], imm2)); |
| 5048 |
DONE; |
| 5049 |
} |
| 5050 |
) |
| 5051 |
|
| 5052 |
(define_insn "<optab><mode>3" |
| 5053 |
[(set (match_operand:GPI 0 "register_operand") |
| 5054 |
(LOGICAL:GPI (match_operand:GPI 1 "register_operand") |
| 5055 |
(match_operand:GPI 2 "aarch64_logical_operand")))] |
| 5056 |
"" |
| 5057 |
{@ [ cons: =0 , %1 , 2 ; attrs: type , arch ] |
| 5058 |
[ r , r , r ; logic_reg , * ] <logical>\t%<w>0, %<w>1, %<w>2 |
| 5059 |
[ rk , r , <lconst> ; logic_imm , * ] <logical>\t%<w>0, %<w>1, %2 |
| 5060 |
[ w , 0 , <lconst> ; * , sve ] <logical>\t%Z0.<s>, %Z0.<s>, #%2 |
| 5061 |
[ w , w , w ; neon_logic , simd ] <logical>\t%0.<Vbtype>, %1.<Vbtype>, %2.<Vbtype> |
| 5062 |
} |
| 5063 |
) |
| 5064 |
|
| 5065 |
;; zero_extend version of above |
| 5066 |
(define_insn "*<optab>si3_uxtw" |
| 5067 |
[(set (match_operand:DI 0 "register_operand") |
| 5068 |
(zero_extend:DI |
| 5069 |
(LOGICAL:SI (match_operand:SI 1 "register_operand") |
| 5070 |
(match_operand:SI 2 "aarch64_logical_operand"))))] |
| 5071 |
"" |
| 5072 |
{@ [ cons: =0 , %1 , 2 ; attrs: type ] |
| 5073 |
[ r , r , r ; logic_reg ] <logical>\t%w0, %w1, %w2 |
| 5074 |
[ rk , r , K ; logic_imm ] <logical>\t%w0, %w1, %2 |
| 5075 |
} |
| 5076 |
) |
| 5077 |
|
| 5078 |
(define_insn "*and<mode>3_compare0" |
| 5079 |
[(set (reg:CC_NZV CC_REGNUM) |
| 5080 |
(compare:CC_NZV |
| 5081 |
(and:GPI (match_operand:GPI 1 "register_operand") |
| 5082 |
(match_operand:GPI 2 "aarch64_logical_operand")) |
| 5083 |
(const_int 0))) |
| 5084 |
(set (match_operand:GPI 0 "register_operand") |
| 5085 |
(and:GPI (match_dup 1) (match_dup 2)))] |
| 5086 |
"" |
| 5087 |
{@ [ cons: =0 , %1 , 2 ; attrs: type ] |
| 5088 |
[ r , r , r ; logics_reg ] ands\t%<w>0, %<w>1, %<w>2 |
| 5089 |
[ r , r , <lconst> ; logics_imm ] ands\t%<w>0, %<w>1, %2 |
| 5090 |
} |
| 5091 |
) |
| 5092 |
|
| 5093 |
;; zero_extend version of above |
| 5094 |
(define_insn "*andsi3_compare0_uxtw" |
| 5095 |
[(set (reg:CC_NZV CC_REGNUM) |
| 5096 |
(compare:CC_NZV |
| 5097 |
(and:SI (match_operand:SI 1 "register_operand") |
| 5098 |
(match_operand:SI 2 "aarch64_logical_operand")) |
| 5099 |
(const_int 0))) |
| 5100 |
(set (match_operand:DI 0 "register_operand") |
| 5101 |
(zero_extend:DI (and:SI (match_dup 1) (match_dup 2))))] |
| 5102 |
"" |
| 5103 |
{@ [ cons: =0 , %1 , 2 ; attrs: type ] |
| 5104 |
[ r , r , r ; logics_reg ] ands\t%w0, %w1, %w2 |
| 5105 |
[ r , r , K ; logics_imm ] ands\t%w0, %w1, %2 |
| 5106 |
} |
| 5107 |
) |
| 5108 |
|
| 5109 |
(define_insn "*and_<SHIFT:optab><mode>3_compare0" |
| 5110 |
[(set (reg:CC_NZV CC_REGNUM) |
| 5111 |
(compare:CC_NZV |
| 5112 |
(and:GPI (SHIFT:GPI |
| 5113 |
(match_operand:GPI 1 "register_operand" "r") |
| 5114 |
(match_operand:QI 2 "aarch64_shift_imm_<mode>" "n")) |
| 5115 |
(match_operand:GPI 3 "register_operand" "r")) |
| 5116 |
(const_int 0))) |
| 5117 |
(set (match_operand:GPI 0 "register_operand" "=r") |
| 5118 |
(and:GPI (SHIFT:GPI (match_dup 1) (match_dup 2)) (match_dup 3)))] |
| 5119 |
"" |
| 5120 |
{ |
| 5121 |
if (<SHIFT:is_rotl>) |
| 5122 |
operands[2] = GEN_INT (<sizen> - UINTVAL (operands[2])); |
| 5123 |
return "ands\\t%<w>0, %<w>3, %<w>1, <SHIFT:shift> %2"; |
| 5124 |
} |
| 5125 |
[(set_attr "type" "logics_shift_imm")] |
| 5126 |
) |
| 5127 |
|
| 5128 |
;; zero_extend version of above |
| 5129 |
(define_insn "*and_<SHIFT:optab>si3_compare0_uxtw" |
| 5130 |
[(set (reg:CC_NZV CC_REGNUM) |
| 5131 |
(compare:CC_NZV |
| 5132 |
(and:SI (SHIFT:SI |
| 5133 |
(match_operand:SI 1 "register_operand" "r") |
| 5134 |
(match_operand:QI 2 "aarch64_shift_imm_si" "n")) |
| 5135 |
(match_operand:SI 3 "register_operand" "r")) |
| 5136 |
(const_int 0))) |
| 5137 |
(set (match_operand:DI 0 "register_operand" "=r") |
| 5138 |
(zero_extend:DI (and:SI (SHIFT:SI (match_dup 1) (match_dup 2)) |
| 5139 |
(match_dup 3))))] |
| 5140 |
"" |
| 5141 |
{ |
| 5142 |
if (<SHIFT:is_rotl>) |
| 5143 |
operands[2] = GEN_INT (32 - UINTVAL (operands[2])); |
| 5144 |
return "ands\\t%w0, %w3, %w1, <SHIFT:shift> %2"; |
| 5145 |
} |
| 5146 |
[(set_attr "type" "logics_shift_imm")] |
| 5147 |
) |
| 5148 |
|
| 5149 |
(define_insn "<LOGICAL:optab>_<SHIFT:optab><mode>3" |
| 5150 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 5151 |
(LOGICAL:GPI (SHIFT:GPI |
| 5152 |
(match_operand:GPI 1 "register_operand" "r") |
| 5153 |
(match_operand:QI 2 "aarch64_shift_imm_<mode>" "n")) |
| 5154 |
(match_operand:GPI 3 "register_operand" "r")))] |
| 5155 |
"" |
| 5156 |
{ |
| 5157 |
if (<SHIFT:is_rotl>) |
| 5158 |
operands[2] = GEN_INT (<sizen> - UINTVAL (operands[2])); |
| 5159 |
return "<LOGICAL:logical>\\t%<w>0, %<w>3, %<w>1, <SHIFT:shift> %2"; |
| 5160 |
} |
| 5161 |
[(set_attr "type" "logic_shift_imm")] |
| 5162 |
) |
| 5163 |
|
| 5164 |
(define_split |
| 5165 |
[(set (match_operand:GPI 0 "register_operand") |
| 5166 |
(LOGICAL_OR_PLUS:GPI |
| 5167 |
(and:GPI |
| 5168 |
(lshiftrt:GPI (match_operand:GPI 1 "register_operand") |
| 5169 |
(match_operand:QI 2 "aarch64_shift_imm_<mode>")) |
| 5170 |
(match_operand:GPI 3 "aarch64_logical_immediate")) |
| 5171 |
(match_operand:GPI 4 "register_operand")))] |
| 5172 |
"can_create_pseudo_p () |
| 5173 |
&& aarch64_bitmask_imm (UINTVAL (operands[3]) << UINTVAL (operands[2]), |
| 5174 |
<MODE>mode)" |
| 5175 |
[(set (match_dup 5) (and:GPI (match_dup 1) (match_dup 6))) |
| 5176 |
(set (match_dup 0) (LOGICAL_OR_PLUS:GPI |
| 5177 |
(lshiftrt:GPI (match_dup 5) (match_dup 2)) |
| 5178 |
(match_dup 4)))] |
| 5179 |
{ |
| 5180 |
operands[5] = gen_reg_rtx (<MODE>mode); |
| 5181 |
operands[6] |
| 5182 |
= gen_int_mode (UINTVAL (operands[3]) << UINTVAL (operands[2]), |
| 5183 |
<MODE>mode); |
| 5184 |
} |
| 5185 |
) |
| 5186 |
|
| 5187 |
(define_split |
| 5188 |
[(set (match_operand:GPI 0 "register_operand") |
| 5189 |
(LOGICAL_OR_PLUS:GPI |
| 5190 |
(and:GPI (ashift:GPI (match_operand:GPI 1 "register_operand") |
| 5191 |
(match_operand:QI 2 "aarch64_shift_imm_<mode>")) |
| 5192 |
(match_operand:GPI 3 "const_int_operand")) |
| 5193 |
(zero_extend:GPI (match_operand 4 "register_operand"))))] |
| 5194 |
"can_create_pseudo_p () |
| 5195 |
&& ((paradoxical_subreg_p (operands[1]) |
| 5196 |
&& rtx_equal_p (SUBREG_REG (operands[1]), operands[4])) |
| 5197 |
|| (REG_P (operands[1]) |
| 5198 |
&& REG_P (operands[4]) |
| 5199 |
&& REGNO (operands[1]) == REGNO (operands[4]))) |
| 5200 |
&& (trunc_int_for_mode (GET_MODE_MASK (GET_MODE (operands[4])) |
| 5201 |
<< INTVAL (operands[2]), <MODE>mode) |
| 5202 |
== INTVAL (operands[3])) |
| 5203 |
&& (<CODE> != PLUS |
| 5204 |
|| (GET_MODE_MASK (GET_MODE (operands[4])) |
| 5205 |
& INTVAL (operands[3])) == 0)" |
| 5206 |
[(set (match_dup 5) (zero_extend:GPI (match_dup 4))) |
| 5207 |
(set (match_dup 0) (match_dup 6))] |
| 5208 |
{ |
| 5209 |
operands[5] = gen_reg_rtx (<MODE>mode); |
| 5210 |
rtx shift = gen_rtx_ASHIFT (<MODE>mode, operands[5], operands[2]); |
| 5211 |
rtx_code new_code = (<CODE> == PLUS ? IOR : <CODE>); |
| 5212 |
operands[6] = gen_rtx_fmt_ee (new_code, <MODE>mode, shift, operands[5]); |
| 5213 |
} |
| 5214 |
) |
| 5215 |
|
| 5216 |
(define_split |
| 5217 |
[(set (match_operand:GPI 0 "register_operand") |
| 5218 |
(LOGICAL_OR_PLUS:GPI |
| 5219 |
(and:GPI (ashift:GPI (match_operand:GPI 1 "register_operand") |
| 5220 |
(match_operand:QI 2 "aarch64_shift_imm_<mode>")) |
| 5221 |
(match_operand:GPI 4 "const_int_operand")) |
| 5222 |
(and:GPI (match_dup 1) (match_operand:GPI 3 "const_int_operand"))))] |
| 5223 |
"can_create_pseudo_p () |
| 5224 |
&& pow2_or_zerop (UINTVAL (operands[3]) + 1) |
| 5225 |
&& (trunc_int_for_mode (UINTVAL (operands[3]) |
| 5226 |
<< INTVAL (operands[2]), <MODE>mode) |
| 5227 |
== INTVAL (operands[4])) |
| 5228 |
&& (<CODE> != PLUS |
| 5229 |
|| (INTVAL (operands[4]) & INTVAL (operands[3])) == 0)" |
| 5230 |
[(set (match_dup 5) (and:GPI (match_dup 1) (match_dup 3))) |
| 5231 |
(set (match_dup 0) (match_dup 6))] |
| 5232 |
{ |
| 5233 |
operands[5] = gen_reg_rtx (<MODE>mode); |
| 5234 |
rtx shift = gen_rtx_ASHIFT (<MODE>mode, operands[5], operands[2]); |
| 5235 |
rtx_code new_code = (<CODE> == PLUS ? IOR : <CODE>); |
| 5236 |
operands[6] = gen_rtx_fmt_ee (new_code, <MODE>mode, shift, operands[5]); |
| 5237 |
} |
| 5238 |
) |
| 5239 |
|
| 5240 |
(define_split |
| 5241 |
[(set (match_operand:GPI 0 "register_operand") |
| 5242 |
(LOGICAL:GPI |
| 5243 |
(ashift:GPI (sign_extend:GPI (match_operand 1 "register_operand")) |
| 5244 |
(match_operand:QI 2 "aarch64_shift_imm_<mode>")) |
| 5245 |
(sign_extend:GPI (match_dup 1))))] |
| 5246 |
"can_create_pseudo_p ()" |
| 5247 |
[(set (match_dup 3) (sign_extend:GPI (match_dup 1))) |
| 5248 |
(set (match_dup 0) (LOGICAL:GPI (ashift:GPI (match_dup 3) (match_dup 2)) |
| 5249 |
(match_dup 3)))] |
| 5250 |
"operands[3] = gen_reg_rtx (<MODE>mode);" |
| 5251 |
) |
| 5252 |
|
| 5253 |
;; zero_extend versions of above |
| 5254 |
(define_insn "*<LOGICAL:optab>_<SHIFT:optab>si3_uxtw" |
| 5255 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 5256 |
(zero_extend:DI |
| 5257 |
(LOGICAL:SI (SHIFT:SI |
| 5258 |
(match_operand:SI 1 "register_operand" "r") |
| 5259 |
(match_operand:QI 2 "aarch64_shift_imm_si" "n")) |
| 5260 |
(match_operand:SI 3 "register_operand" "r"))))] |
| 5261 |
"" |
| 5262 |
{ |
| 5263 |
if (<SHIFT:is_rotl>) |
| 5264 |
operands[2] = GEN_INT (32 - UINTVAL (operands[2])); |
| 5265 |
return "<LOGICAL:logical>\\t%w0, %w3, %w1, <SHIFT:shift> %2"; |
| 5266 |
} |
| 5267 |
[(set_attr "type" "logic_shift_imm")] |
| 5268 |
) |
| 5269 |
|
| 5270 |
(define_insn "one_cmpl<mode>2" |
| 5271 |
[(set (match_operand:GPI 0 "register_operand") |
| 5272 |
(not:GPI (match_operand:GPI 1 "register_operand")))] |
| 5273 |
"" |
| 5274 |
{@ [ cons: =0 , 1 ; attrs: type , arch ] |
| 5275 |
[ r , r ; logic_reg , * ] mvn\t%<w>0, %<w>1 |
| 5276 |
[ w , w ; neon_logic , simd ] mvn\t%0.8b, %1.8b |
| 5277 |
} |
| 5278 |
) |
| 5279 |
|
| 5280 |
(define_insn "*one_cmpl_zero_extend" |
| 5281 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 5282 |
(zero_extend:DI |
| 5283 |
(not:SI (match_operand:SI 1 "register_operand" "r"))))] |
| 5284 |
"" |
| 5285 |
"mvn\\t%w0, %w1" |
| 5286 |
[(set_attr "type" "logic_reg")] |
| 5287 |
) |
| 5288 |
|
| 5289 |
(define_insn "*one_cmpl_<optab><mode>2" |
| 5290 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 5291 |
(not:GPI (SHIFT:GPI (match_operand:GPI 1 "register_operand" "r") |
| 5292 |
(match_operand:QI 2 "aarch64_shift_imm_<mode>" "n"))))] |
| 5293 |
"" |
| 5294 |
{ |
| 5295 |
if (<SHIFT:is_rotl>) |
| 5296 |
operands[2] = GEN_INT (<sizen> - UINTVAL (operands[2])); |
| 5297 |
return "mvn\\t%<w>0, %<w>1, <shift> %2"; |
| 5298 |
} |
| 5299 |
[(set_attr "type" "logic_shift_imm")] |
| 5300 |
) |
| 5301 |
|
| 5302 |
;; Binary logical operators negating one operand, i.e. (a & !b), (a | !b). |
| 5303 |
|
| 5304 |
(define_insn "<NLOGICAL:optab>n<mode>3" |
| 5305 |
[(set (match_operand:GPI 0 "register_operand") |
| 5306 |
(NLOGICAL:GPI (not:GPI (match_operand:GPI 2 "register_operand")) |
| 5307 |
(match_operand:GPI 1 "register_operand")))] |
| 5308 |
"" |
| 5309 |
{@ [ cons: =0 , 1 , 2 ; attrs: type , arch ] |
| 5310 |
[ r , r , r ; logic_reg , * ] <NLOGICAL:nlogical>\t%<w>0, %<w>1, %<w>2 |
| 5311 |
[ w , w , w ; neon_logic , simd ] <NLOGICAL:nlogical>\t%0.<Vbtype>, %1.<Vbtype>, %2.<Vbtype> |
| 5312 |
} |
| 5313 |
) |
| 5314 |
|
| 5315 |
(define_insn "*<NLOGICAL:optab>nsidi3_ze" |
| 5316 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 5317 |
(zero_extend:DI |
| 5318 |
(NLOGICAL:SI (not:SI (match_operand:SI 1 "register_operand" "r")) |
| 5319 |
(match_operand:SI 2 "register_operand" "r"))))] |
| 5320 |
"" |
| 5321 |
"<NLOGICAL:nlogical>\\t%w0, %w2, %w1" |
| 5322 |
[(set_attr "type" "logic_reg")] |
| 5323 |
) |
| 5324 |
|
| 5325 |
(define_insn "*xor_one_cmplsidi3_ze" |
| 5326 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 5327 |
(zero_extend:DI |
| 5328 |
(not:SI (xor:SI (match_operand:SI 1 "register_operand" "r") |
| 5329 |
(match_operand:SI 2 "register_operand" "r")))))] |
| 5330 |
"" |
| 5331 |
"eon\\t%w0, %w1, %w2" |
| 5332 |
[(set_attr "type" "logic_reg")] |
| 5333 |
) |
| 5334 |
|
| 5335 |
;; (xor (not a) b) is simplify_rtx-ed down to (not (xor a b)). |
| 5336 |
;; eon does not operate on SIMD registers so the vector variant must be split. |
| 5337 |
(define_insn_and_split "*xor_one_cmpl<mode>3" |
| 5338 |
[(set (match_operand:GPI 0 "register_operand" "=r,w") |
| 5339 |
(not:GPI (xor:GPI (match_operand:GPI 1 "register_operand" "r,?w") |
| 5340 |
(match_operand:GPI 2 "register_operand" "r,w"))))] |
| 5341 |
"" |
| 5342 |
"@ |
| 5343 |
eon\\t%<w>0, %<w>1, %<w>2 |
| 5344 |
#" |
| 5345 |
"reload_completed && FP_REGNUM_P (REGNO (operands[0]))" ;; For SIMD registers. |
| 5346 |
[(set (match_operand:GPI 0 "register_operand" "=w") |
| 5347 |
(xor:GPI (match_operand:GPI 1 "register_operand" "w") |
| 5348 |
(match_operand:GPI 2 "register_operand" "w"))) |
| 5349 |
(set (match_dup 0) (not:GPI (match_dup 0)))] |
| 5350 |
"" |
| 5351 |
[(set_attr "type" "logic_reg,multiple") |
| 5352 |
(set_attr "arch" "*,simd")] |
| 5353 |
) |
| 5354 |
|
| 5355 |
(define_insn "*and_one_cmpl<mode>3_compare0" |
| 5356 |
[(set (reg:CC_NZV CC_REGNUM) |
| 5357 |
(compare:CC_NZV |
| 5358 |
(and:GPI (not:GPI |
| 5359 |
(match_operand:GPI 1 "register_operand" "r")) |
| 5360 |
(match_operand:GPI 2 "register_operand" "r")) |
| 5361 |
(const_int 0))) |
| 5362 |
(set (match_operand:GPI 0 "register_operand" "=r") |
| 5363 |
(and:GPI (not:GPI (match_dup 1)) (match_dup 2)))] |
| 5364 |
"" |
| 5365 |
"bics\\t%<w>0, %<w>2, %<w>1" |
| 5366 |
[(set_attr "type" "logics_reg")] |
| 5367 |
) |
| 5368 |
|
| 5369 |
;; zero_extend version of above |
| 5370 |
(define_insn "*and_one_cmplsi3_compare0_uxtw" |
| 5371 |
[(set (reg:CC_NZV CC_REGNUM) |
| 5372 |
(compare:CC_NZV |
| 5373 |
(and:SI (not:SI |
| 5374 |
(match_operand:SI 1 "register_operand" "r")) |
| 5375 |
(match_operand:SI 2 "register_operand" "r")) |
| 5376 |
(const_int 0))) |
| 5377 |
(set (match_operand:DI 0 "register_operand" "=r") |
| 5378 |
(zero_extend:DI (and:SI (not:SI (match_dup 1)) (match_dup 2))))] |
| 5379 |
"" |
| 5380 |
"bics\\t%w0, %w2, %w1" |
| 5381 |
[(set_attr "type" "logics_reg")] |
| 5382 |
) |
| 5383 |
|
| 5384 |
(define_insn "*and_one_cmpl<mode>3_compare0_no_reuse" |
| 5385 |
[(set (reg:CC_NZV CC_REGNUM) |
| 5386 |
(compare:CC_NZV |
| 5387 |
(and:GPI (not:GPI |
| 5388 |
(match_operand:GPI 0 "register_operand" "r")) |
| 5389 |
(match_operand:GPI 1 "register_operand" "r")) |
| 5390 |
(const_int 0)))] |
| 5391 |
"" |
| 5392 |
"bics\\t<w>zr, %<w>1, %<w>0" |
| 5393 |
[(set_attr "type" "logics_reg")] |
| 5394 |
) |
| 5395 |
|
| 5396 |
(define_insn "<LOGICAL:optab>_one_cmpl_<SHIFT:optab><mode>3" |
| 5397 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 5398 |
(LOGICAL:GPI (not:GPI |
| 5399 |
(SHIFT:GPI |
| 5400 |
(match_operand:GPI 1 "register_operand" "r") |
| 5401 |
(match_operand:QI 2 "aarch64_shift_imm_<mode>" "n"))) |
| 5402 |
(match_operand:GPI 3 "register_operand" "r")))] |
| 5403 |
"" |
| 5404 |
{ |
| 5405 |
if (<SHIFT:is_rotl>) |
| 5406 |
operands[2] = GEN_INT (<sizen> - UINTVAL (operands[2])); |
| 5407 |
return "<LOGICAL:nlogical>\\t%<w>0, %<w>3, %<w>1, <SHIFT:shift> %2"; |
| 5408 |
} |
| 5409 |
[(set_attr "type" "logic_shift_imm")] |
| 5410 |
) |
| 5411 |
|
| 5412 |
;; Zero-extend version of the above. |
| 5413 |
(define_insn "<LOGICAL:optab>_one_cmpl_<SHIFT:optab>sidi_uxtw" |
| 5414 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 5415 |
(zero_extend:DI (LOGICAL:SI (not:SI |
| 5416 |
(SHIFT:SI |
| 5417 |
(match_operand:SI 1 "register_operand" "r") |
| 5418 |
(match_operand:QI 2 "aarch64_shift_imm_si" "n"))) |
| 5419 |
(match_operand:SI 3 "register_operand" "r"))))] |
| 5420 |
"" |
| 5421 |
{ |
| 5422 |
if (<SHIFT:is_rotl>) |
| 5423 |
operands[2] = GEN_INT (32 - UINTVAL (operands[2])); |
| 5424 |
return "<LOGICAL:nlogical>\\t%w0, %w3, %w1, <SHIFT:shift> %2"; |
| 5425 |
} |
| 5426 |
[(set_attr "type" "logic_shift_imm")] |
| 5427 |
) |
| 5428 |
|
| 5429 |
(define_insn "*eor_one_cmpl_<SHIFT:optab><mode>3_alt" |
| 5430 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 5431 |
(not:GPI (xor:GPI |
| 5432 |
(SHIFT:GPI |
| 5433 |
(match_operand:GPI 1 "register_operand" "r") |
| 5434 |
(match_operand:QI 2 "aarch64_shift_imm_<mode>" "n")) |
| 5435 |
(match_operand:GPI 3 "register_operand" "r"))))] |
| 5436 |
"" |
| 5437 |
{ |
| 5438 |
if (<SHIFT:is_rotl>) |
| 5439 |
operands[2] = GEN_INT (<sizen> - UINTVAL (operands[2])); |
| 5440 |
return "eon\\t%<w>0, %<w>3, %<w>1, <SHIFT:shift> %2"; |
| 5441 |
} |
| 5442 |
[(set_attr "type" "logic_shift_imm")] |
| 5443 |
) |
| 5444 |
|
| 5445 |
;; Zero-extend version of the above. |
| 5446 |
(define_insn "*eor_one_cmpl_<SHIFT:optab>sidi3_alt_ze" |
| 5447 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 5448 |
(zero_extend:DI |
| 5449 |
(not:SI (xor:SI |
| 5450 |
(SHIFT:SI |
| 5451 |
(match_operand:SI 1 "register_operand" "r") |
| 5452 |
(match_operand:QI 2 "aarch64_shift_imm_si" "n")) |
| 5453 |
(match_operand:SI 3 "register_operand" "r")))))] |
| 5454 |
"" |
| 5455 |
{ |
| 5456 |
if (<SHIFT:is_rotl>) |
| 5457 |
operands[2] = GEN_INT (32 - UINTVAL (operands[2])); |
| 5458 |
return "eon\\t%w0, %w3, %w1, <SHIFT:shift> %2"; |
| 5459 |
} |
| 5460 |
[(set_attr "type" "logic_shift_imm")] |
| 5461 |
) |
| 5462 |
|
| 5463 |
(define_insn "*and_one_cmpl_<SHIFT:optab><mode>3_compare0" |
| 5464 |
[(set (reg:CC_NZV CC_REGNUM) |
| 5465 |
(compare:CC_NZV |
| 5466 |
(and:GPI (not:GPI |
| 5467 |
(SHIFT:GPI |
| 5468 |
(match_operand:GPI 1 "register_operand" "r") |
| 5469 |
(match_operand:QI 2 "aarch64_shift_imm_<mode>" "n"))) |
| 5470 |
(match_operand:GPI 3 "register_operand" "r")) |
| 5471 |
(const_int 0))) |
| 5472 |
(set (match_operand:GPI 0 "register_operand" "=r") |
| 5473 |
(and:GPI (not:GPI |
| 5474 |
(SHIFT:GPI |
| 5475 |
(match_dup 1) (match_dup 2))) (match_dup 3)))] |
| 5476 |
"" |
| 5477 |
{ |
| 5478 |
if (<SHIFT:is_rotl>) |
| 5479 |
operands[2] = GEN_INT (<sizen> - UINTVAL (operands[2])); |
| 5480 |
return "bics\\t%<w>0, %<w>3, %<w>1, <SHIFT:shift> %2"; |
| 5481 |
} |
| 5482 |
[(set_attr "type" "logics_shift_imm")] |
| 5483 |
) |
| 5484 |
|
| 5485 |
;; zero_extend version of above |
| 5486 |
(define_insn "*and_one_cmpl_<SHIFT:optab>si3_compare0_uxtw" |
| 5487 |
[(set (reg:CC_NZV CC_REGNUM) |
| 5488 |
(compare:CC_NZV |
| 5489 |
(and:SI (not:SI |
| 5490 |
(SHIFT:SI |
| 5491 |
(match_operand:SI 1 "register_operand" "r") |
| 5492 |
(match_operand:QI 2 "aarch64_shift_imm_si" "n"))) |
| 5493 |
(match_operand:SI 3 "register_operand" "r")) |
| 5494 |
(const_int 0))) |
| 5495 |
(set (match_operand:DI 0 "register_operand" "=r") |
| 5496 |
(zero_extend:DI (and:SI |
| 5497 |
(not:SI |
| 5498 |
(SHIFT:SI (match_dup 1) (match_dup 2))) (match_dup 3))))] |
| 5499 |
"" |
| 5500 |
{ |
| 5501 |
if (<SHIFT:is_rotl>) |
| 5502 |
operands[2] = GEN_INT (32 - UINTVAL (operands[2])); |
| 5503 |
return "bics\\t%w0, %w3, %w1, <SHIFT:shift> %2"; |
| 5504 |
} |
| 5505 |
[(set_attr "type" "logics_shift_imm")] |
| 5506 |
) |
| 5507 |
|
| 5508 |
(define_insn "*and_one_cmpl_<SHIFT:optab><mode>3_compare0_no_reuse" |
| 5509 |
[(set (reg:CC_NZV CC_REGNUM) |
| 5510 |
(compare:CC_NZV |
| 5511 |
(and:GPI (not:GPI |
| 5512 |
(SHIFT:GPI |
| 5513 |
(match_operand:GPI 0 "register_operand" "r") |
| 5514 |
(match_operand:QI 1 "aarch64_shift_imm_<mode>" "n"))) |
| 5515 |
(match_operand:GPI 2 "register_operand" "r")) |
| 5516 |
(const_int 0)))] |
| 5517 |
"" |
| 5518 |
{ |
| 5519 |
if (<SHIFT:is_rotl>) |
| 5520 |
operands[1] = GEN_INT (<sizen> - UINTVAL (operands[1])); |
| 5521 |
return "bics\\t<w>zr, %<w>2, %<w>0, <SHIFT:shift> %1"; |
| 5522 |
} |
| 5523 |
[(set_attr "type" "logics_shift_imm")] |
| 5524 |
) |
| 5525 |
|
| 5526 |
(define_insn "clz<mode>2" |
| 5527 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 5528 |
(clz:GPI (match_operand:GPI 1 "register_operand" "r")))] |
| 5529 |
"" |
| 5530 |
"clz\\t%<w>0, %<w>1" |
| 5531 |
[(set_attr "type" "clz")] |
| 5532 |
) |
| 5533 |
|
| 5534 |
(define_expand "ffs<mode>2" |
| 5535 |
[(match_operand:GPI 0 "register_operand") |
| 5536 |
(match_operand:GPI 1 "register_operand")] |
| 5537 |
"" |
| 5538 |
{ |
| 5539 |
rtx ccreg = aarch64_gen_compare_reg (EQ, operands[1], const0_rtx); |
| 5540 |
rtx x = gen_rtx_NE (VOIDmode, ccreg, const0_rtx); |
| 5541 |
|
| 5542 |
emit_insn (gen_aarch64_rbit (<MODE>mode, operands[0], operands[1])); |
| 5543 |
emit_insn (gen_clz<mode>2 (operands[0], operands[0])); |
| 5544 |
emit_insn (gen_csinc3<mode>_insn (operands[0], x, operands[0], const0_rtx)); |
| 5545 |
DONE; |
| 5546 |
} |
| 5547 |
) |
| 5548 |
|
| 5549 |
(define_insn "*aarch64_popcount<mode>2_cssc_insn" |
| 5550 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 5551 |
(popcount:GPI (match_operand:GPI 1 "register_operand" "r")))] |
| 5552 |
"TARGET_CSSC" |
| 5553 |
"cnt\\t%<w>0, %<w>1" |
| 5554 |
[(set_attr "type" "clz")] |
| 5555 |
) |
| 5556 |
|
| 5557 |
;; The CSSC instructions can do popcount in the GP registers directly through |
| 5558 |
;; CNT. If it is not available then we can use CNT on the Advanced SIMD side |
| 5559 |
;; through: |
| 5560 |
;; MOV v.1d, x0 |
| 5561 |
;; CNT v1.8b, v.8b |
| 5562 |
;; ADDV b2, v1.8b |
| 5563 |
;; MOV w0, v2.b[0] |
| 5564 |
|
| 5565 |
(define_expand "popcount<mode>2" |
| 5566 |
[(set (match_operand:ALLI 0 "register_operand") |
| 5567 |
(popcount:ALLI (match_operand:ALLI 1 "register_operand")))] |
| 5568 |
"TARGET_CSSC ? GET_MODE_BITSIZE (<MODE>mode) >= 32 : TARGET_SIMD" |
| 5569 |
{ |
| 5570 |
if (!TARGET_CSSC && TARGET_SVE && <MODE>mode != QImode) |
| 5571 |
{ |
| 5572 |
rtx tmp = gen_reg_rtx (<VEC_POP_MODE>mode); |
| 5573 |
rtx op1 = gen_lowpart (<VEC_POP_MODE>mode, operands[1]); |
| 5574 |
emit_insn (gen_popcount<vec_pop_mode>2 (tmp, op1)); |
| 5575 |
emit_move_insn (operands[0], gen_lowpart (<MODE>mode, tmp)); |
| 5576 |
DONE; |
| 5577 |
} |
| 5578 |
|
| 5579 |
if (!TARGET_CSSC) |
| 5580 |
{ |
| 5581 |
rtx v = gen_reg_rtx (V8QImode); |
| 5582 |
rtx v1 = gen_reg_rtx (V8QImode); |
| 5583 |
rtx in = operands[1]; |
| 5584 |
rtx out = operands[0]; |
| 5585 |
/* SImode and HImode should be zero extended to DImode. |
| 5586 |
popcount does not change if we have extra zeros. */ |
| 5587 |
if (<MODE>mode == SImode || <MODE>mode == HImode) |
| 5588 |
in = convert_to_mode (DImode, in, true); |
| 5589 |
|
| 5590 |
emit_move_insn (v, gen_lowpart (V8QImode, in)); |
| 5591 |
emit_insn (gen_popcountv8qi2 (v1, v)); |
| 5592 |
/* QImode, just extract from the v8qi vector. */ |
| 5593 |
if (<MODE>mode == QImode) |
| 5594 |
emit_move_insn (out, gen_lowpart (QImode, v1)); |
| 5595 |
/* HI and SI, reduction is zero extended to SImode. */ |
| 5596 |
else if (<MODE>mode == SImode || <MODE>mode == HImode) |
| 5597 |
{ |
| 5598 |
rtx out1 = gen_reg_rtx (SImode); |
| 5599 |
emit_insn (gen_aarch64_zero_extendsi_reduc_plus_v8qi (out1, v1)); |
| 5600 |
emit_move_insn (out, gen_lowpart (<MODE>mode, out1)); |
| 5601 |
} |
| 5602 |
/* DImode, reduction is zero extended to DImode. */ |
| 5603 |
else |
| 5604 |
{ |
| 5605 |
gcc_assert (<MODE>mode == DImode); |
| 5606 |
emit_insn (gen_aarch64_zero_extenddi_reduc_plus_v8qi (out, v1)); |
| 5607 |
} |
| 5608 |
DONE; |
| 5609 |
} |
| 5610 |
}) |
| 5611 |
|
| 5612 |
(define_expand "popcountti2" |
| 5613 |
[(match_operand:DI 0 "register_operand") |
| 5614 |
(match_operand:TI 1 "register_operand")] |
| 5615 |
"TARGET_SIMD && !TARGET_CSSC" |
| 5616 |
{ |
| 5617 |
rtx v = gen_reg_rtx (V16QImode); |
| 5618 |
rtx v1 = gen_reg_rtx (V16QImode); |
| 5619 |
emit_move_insn (v, gen_lowpart (V16QImode, operands[1])); |
| 5620 |
emit_insn (gen_popcountv16qi2 (v1, v)); |
| 5621 |
emit_insn (gen_aarch64_zero_extenddi_reduc_plus_v16qi (operands[0], v1)); |
| 5622 |
DONE; |
| 5623 |
}) |
| 5624 |
|
| 5625 |
(define_insn "clrsb<mode>2" |
| 5626 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 5627 |
(clrsb:GPI (match_operand:GPI 1 "register_operand" "r")))] |
| 5628 |
"" |
| 5629 |
"cls\\t%<w>0, %<w>1" |
| 5630 |
[(set_attr "type" "clz")] |
| 5631 |
) |
| 5632 |
|
| 5633 |
(define_insn "@aarch64_rbit<mode>" |
| 5634 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 5635 |
(bitreverse:GPI (match_operand:GPI 1 "register_operand" "r")))] |
| 5636 |
"" |
| 5637 |
"rbit\\t%<w>0, %<w>1" |
| 5638 |
[(set_attr "type" "rbit")] |
| 5639 |
) |
| 5640 |
|
| 5641 |
;; Split after reload into RBIT + CLZ. Since RBIT is represented as an UNSPEC |
| 5642 |
;; it is unlikely to fold with any other operation, so keep this as a CTZ |
| 5643 |
;; expression and split after reload to enable scheduling them apart if |
| 5644 |
;; needed. For TARGET_CSSC we have a single CTZ instruction that can do this. |
| 5645 |
|
| 5646 |
(define_insn_and_split "ctz<mode>2" |
| 5647 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 5648 |
(ctz:GPI (match_operand:GPI 1 "register_operand" "r")))] |
| 5649 |
"" |
| 5650 |
{ return TARGET_CSSC ? "ctz\\t%<w>0, %<w>1" : "#"; } |
| 5651 |
"reload_completed && !TARGET_CSSC" |
| 5652 |
[(const_int 0)] |
| 5653 |
" |
| 5654 |
emit_insn (gen_aarch64_rbit (<MODE>mode, operands[0], operands[1])); |
| 5655 |
emit_insn (gen_clz<mode>2 (operands[0], operands[0])); |
| 5656 |
DONE; |
| 5657 |
") |
| 5658 |
|
| 5659 |
(define_insn "*and<mode>_compare0" |
| 5660 |
[(set (reg:CC_Z CC_REGNUM) |
| 5661 |
(compare:CC_Z |
| 5662 |
(match_operand:SHORT 0 "register_operand" "r") |
| 5663 |
(const_int 0)))] |
| 5664 |
"" |
| 5665 |
"tst\\t%<w>0, <short_mask>" |
| 5666 |
[(set_attr "type" "logics_imm")] |
| 5667 |
) |
| 5668 |
|
| 5669 |
(define_insn "*ands<GPI:mode>_compare0" |
| 5670 |
[(set (reg:CC_Z CC_REGNUM) |
| 5671 |
(compare:CC_Z |
| 5672 |
(zero_extend:GPI (match_operand:SHORT 1 "register_operand" "r")) |
| 5673 |
(const_int 0))) |
| 5674 |
(set (match_operand:GPI 0 "register_operand" "=r") |
| 5675 |
(zero_extend:GPI (match_dup 1)))] |
| 5676 |
"" |
| 5677 |
"ands\\t%<GPI:w>0, %<GPI:w>1, <short_mask>" |
| 5678 |
[(set_attr "type" "alus_imm")] |
| 5679 |
) |
| 5680 |
|
| 5681 |
(define_insn "@aarch64_and<mode>3nr_compare0" |
| 5682 |
[(set (reg:CC_NZV CC_REGNUM) |
| 5683 |
(compare:CC_NZV |
| 5684 |
(and:GPI (match_operand:GPI 0 "register_operand") |
| 5685 |
(match_operand:GPI 1 "aarch64_logical_operand")) |
| 5686 |
(const_int 0)))] |
| 5687 |
"" |
| 5688 |
{@ [ cons: %0 , 1 ; attrs: type ] |
| 5689 |
[ r , r ; logics_reg ] tst\t%<w>0, %<w>1 |
| 5690 |
[ r , <lconst> ; logics_imm ] tst\t%<w>0, %1 |
| 5691 |
} |
| 5692 |
) |
| 5693 |
|
| 5694 |
(define_split |
| 5695 |
[(set (reg:CC_NZV CC_REGNUM) |
| 5696 |
(compare:CC_NZV |
| 5697 |
(and:GPI (match_operand:GPI 0 "register_operand") |
| 5698 |
(match_operand:GPI 1 "aarch64_mov_imm_operand")) |
| 5699 |
(const_int 0))) |
| 5700 |
(clobber (match_operand:SI 2 "register_operand"))] |
| 5701 |
"" |
| 5702 |
[(set (match_dup 2) (match_dup 1)) |
| 5703 |
(set (reg:CC_NZV CC_REGNUM) |
| 5704 |
(compare:CC_NZV |
| 5705 |
(and:GPI (match_dup 0) |
| 5706 |
(match_dup 2)) |
| 5707 |
(const_int 0)))] |
| 5708 |
) |
| 5709 |
|
| 5710 |
(define_insn "*and<mode>3nr_compare0_zextract" |
| 5711 |
[(set (reg:CC_Z CC_REGNUM) |
| 5712 |
(compare:CC_Z |
| 5713 |
(zero_extract:GPI (match_operand:GPI 0 "register_operand" "r") |
| 5714 |
(match_operand:GPI 1 "const_int_operand" "n") |
| 5715 |
(match_operand:GPI 2 "const_int_operand" "n")) |
| 5716 |
(const_int 0)))] |
| 5717 |
"INTVAL (operands[1]) > 0 |
| 5718 |
&& ((INTVAL (operands[1]) + INTVAL (operands[2])) |
| 5719 |
<= GET_MODE_BITSIZE (<MODE>mode)) |
| 5720 |
&& aarch64_bitmask_imm ( |
| 5721 |
UINTVAL (aarch64_mask_from_zextract_ops (operands[1], |
| 5722 |
operands[2])), |
| 5723 |
<MODE>mode)" |
| 5724 |
{ |
| 5725 |
operands[1] |
| 5726 |
= aarch64_mask_from_zextract_ops (operands[1], operands[2]); |
| 5727 |
return "tst\\t%<w>0, %1"; |
| 5728 |
} |
| 5729 |
[(set_attr "type" "logics_shift_imm")] |
| 5730 |
) |
| 5731 |
|
| 5732 |
(define_insn "*and_<SHIFT:optab><mode>3nr_compare0" |
| 5733 |
[(set (reg:CC_NZV CC_REGNUM) |
| 5734 |
(compare:CC_NZV |
| 5735 |
(and:GPI (SHIFT:GPI |
| 5736 |
(match_operand:GPI 0 "register_operand" "r") |
| 5737 |
(match_operand:QI 1 "aarch64_shift_imm_<mode>" "n")) |
| 5738 |
(match_operand:GPI 2 "register_operand" "r")) |
| 5739 |
(const_int 0)))] |
| 5740 |
"" |
| 5741 |
{ |
| 5742 |
if (<SHIFT:is_rotl>) |
| 5743 |
operands[1] = GEN_INT (<sizen> - UINTVAL (operands[1])); |
| 5744 |
return "tst\\t%<w>2, %<w>0, <SHIFT:shift> %1"; |
| 5745 |
} |
| 5746 |
[(set_attr "type" "logics_shift_imm")] |
| 5747 |
) |
| 5748 |
|
| 5749 |
(define_split |
| 5750 |
[(set (reg:CC_NZV CC_REGNUM) |
| 5751 |
(compare:CC_NZV |
| 5752 |
(and:GPI (SHIFT:GPI |
| 5753 |
(match_operand:GPI 0 "register_operand") |
| 5754 |
(match_operand:QI 1 "aarch64_shift_imm_<mode>")) |
| 5755 |
(match_operand:GPI 2 "aarch64_mov_imm_operand")) |
| 5756 |
(const_int 0))) |
| 5757 |
(clobber (match_operand:SI 3 "register_operand"))] |
| 5758 |
"" |
| 5759 |
[(set (match_dup 3) (match_dup 2)) |
| 5760 |
(set (reg:CC_NZV CC_REGNUM) |
| 5761 |
(compare:CC_NZV |
| 5762 |
(and:GPI (SHIFT:GPI |
| 5763 |
(match_dup 0) |
| 5764 |
(match_dup 1)) |
| 5765 |
(match_dup 3)) |
| 5766 |
(const_int 0)))] |
| 5767 |
) |
| 5768 |
|
| 5769 |
;; ------------------------------------------------------------------- |
| 5770 |
;; Shifts |
| 5771 |
;; ------------------------------------------------------------------- |
| 5772 |
|
| 5773 |
(define_expand "<optab><mode>3" |
| 5774 |
[(set (match_operand:GPI 0 "register_operand") |
| 5775 |
(ASHIFT:GPI (match_operand:GPI 1 "register_operand") |
| 5776 |
(match_operand:QI 2 "aarch64_reg_or_imm")))] |
| 5777 |
"" |
| 5778 |
{ |
| 5779 |
if (CONST_INT_P (operands[2])) |
| 5780 |
{ |
| 5781 |
operands[2] = GEN_INT (INTVAL (operands[2]) |
| 5782 |
& (GET_MODE_BITSIZE (<MODE>mode) - 1)); |
| 5783 |
|
| 5784 |
if (operands[2] == const0_rtx) |
| 5785 |
{ |
| 5786 |
emit_insn (gen_mov<mode> (operands[0], operands[1])); |
| 5787 |
DONE; |
| 5788 |
} |
| 5789 |
} |
| 5790 |
} |
| 5791 |
) |
| 5792 |
|
| 5793 |
(define_expand "ashl<mode>3" |
| 5794 |
[(set (match_operand:SHORT 0 "register_operand") |
| 5795 |
(ashift:SHORT (match_operand:SHORT 1 "register_operand") |
| 5796 |
(match_operand:QI 2 "const_int_operand")))] |
| 5797 |
"" |
| 5798 |
{ |
| 5799 |
operands[2] = GEN_INT (INTVAL (operands[2]) & GET_MODE_MASK (<MODE>mode)); |
| 5800 |
|
| 5801 |
if (operands[2] == const0_rtx) |
| 5802 |
{ |
| 5803 |
emit_insn (gen_mov<mode> (operands[0], operands[1])); |
| 5804 |
DONE; |
| 5805 |
} |
| 5806 |
} |
| 5807 |
) |
| 5808 |
|
| 5809 |
(define_expand "rotr<mode>3" |
| 5810 |
[(set (match_operand:GPI 0 "register_operand") |
| 5811 |
(rotatert:GPI (match_operand:GPI 1 "register_operand") |
| 5812 |
(match_operand:QI 2 "aarch64_reg_or_imm")))] |
| 5813 |
"" |
| 5814 |
{ |
| 5815 |
if (CONST_INT_P (operands[2])) |
| 5816 |
{ |
| 5817 |
operands[2] = GEN_INT (INTVAL (operands[2]) |
| 5818 |
& (GET_MODE_BITSIZE (<MODE>mode) - 1)); |
| 5819 |
|
| 5820 |
if (operands[2] == const0_rtx) |
| 5821 |
{ |
| 5822 |
emit_insn (gen_mov<mode> (operands[0], operands[1])); |
| 5823 |
DONE; |
| 5824 |
} |
| 5825 |
} |
| 5826 |
} |
| 5827 |
) |
| 5828 |
|
| 5829 |
(define_expand "rotl<mode>3" |
| 5830 |
[(set (match_operand:GPI 0 "register_operand") |
| 5831 |
(rotatert:GPI (match_operand:GPI 1 "register_operand") |
| 5832 |
(match_operand:QI 2 "aarch64_reg_or_imm")))] |
| 5833 |
"" |
| 5834 |
{ |
| 5835 |
/* (SZ - cnt) % SZ == -cnt % SZ */ |
| 5836 |
if (CONST_INT_P (operands[2])) |
| 5837 |
{ |
| 5838 |
operands[2] = GEN_INT ((-UINTVAL (operands[2])) |
| 5839 |
& (GET_MODE_BITSIZE (<MODE>mode) - 1)); |
| 5840 |
if (operands[2] == const0_rtx) |
| 5841 |
{ |
| 5842 |
emit_insn (gen_mov<mode> (operands[0], operands[1])); |
| 5843 |
DONE; |
| 5844 |
} |
| 5845 |
} |
| 5846 |
else |
| 5847 |
operands[2] = expand_simple_unop (QImode, NEG, operands[2], |
| 5848 |
NULL_RTX, 1); |
| 5849 |
} |
| 5850 |
) |
| 5851 |
|
| 5852 |
;; When the LSL, LSR, ASR, ROR instructions operate on all register arguments |
| 5853 |
;; they truncate the shift/rotate amount by the size of the registers they |
| 5854 |
;; operate on: 32 for W-regs, 64 for X-regs. This allows us to optimise away |
| 5855 |
;; such redundant masking instructions. GCC can do that automatically when |
| 5856 |
;; SHIFT_COUNT_TRUNCATED is true, but we can't enable it for TARGET_SIMD |
| 5857 |
;; because some of the SISD shift alternatives don't perform this truncations. |
| 5858 |
;; So this pattern exists to catch such cases. |
| 5859 |
|
| 5860 |
(define_insn "*aarch64_<optab>_reg_<mode>3_mask1" |
| 5861 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 5862 |
(SHIFT:GPI |
| 5863 |
(match_operand:GPI 1 "register_operand" "r") |
| 5864 |
(match_operator 4 "subreg_lowpart_operator" |
| 5865 |
[(and:GPI (match_operand:GPI 2 "register_operand" "r") |
| 5866 |
(match_operand 3 "const_int_operand" "n"))])))] |
| 5867 |
"(~INTVAL (operands[3]) & (GET_MODE_BITSIZE (<MODE>mode) - 1)) == 0" |
| 5868 |
"<shift>\t%<w>0, %<w>1, %<w>2" |
| 5869 |
[(set_attr "type" "shift_reg")] |
| 5870 |
) |
| 5871 |
|
| 5872 |
(define_insn_and_split "*aarch64_<optab>_reg_<mode>3_neg_mask2" |
| 5873 |
[(set (match_operand:GPI 0 "register_operand" "=&r") |
| 5874 |
(SHIFT:GPI |
| 5875 |
(match_operand:GPI 1 "register_operand" "r") |
| 5876 |
(match_operator 4 "subreg_lowpart_operator" |
| 5877 |
[(neg:SI (and:SI (match_operand:SI 2 "register_operand" "r") |
| 5878 |
(match_operand 3 "const_int_operand" "n")))])))] |
| 5879 |
"((~INTVAL (operands[3]) & (GET_MODE_BITSIZE (<MODE>mode) - 1)) == 0)" |
| 5880 |
"#" |
| 5881 |
"&& true" |
| 5882 |
[(const_int 0)] |
| 5883 |
{ |
| 5884 |
rtx tmp = (can_create_pseudo_p () ? gen_reg_rtx (SImode) |
| 5885 |
: lowpart_subreg (SImode, operands[0], <MODE>mode)); |
| 5886 |
emit_insn (gen_negsi2 (tmp, operands[2])); |
| 5887 |
|
| 5888 |
rtx and_op = gen_rtx_AND (SImode, tmp, operands[3]); |
| 5889 |
rtx subreg_tmp = gen_rtx_SUBREG (GET_MODE (operands[4]), and_op, |
| 5890 |
SUBREG_BYTE (operands[4])); |
| 5891 |
emit_insn (gen_<optab><mode>3 (operands[0], operands[1], subreg_tmp)); |
| 5892 |
DONE; |
| 5893 |
} |
| 5894 |
) |
| 5895 |
|
| 5896 |
(define_insn_and_split "*aarch64_ashl_reg_<mode>3_minus_mask" |
| 5897 |
[(set (match_operand:GPI 0 "register_operand" "=&r") |
| 5898 |
(ashift:GPI |
| 5899 |
(match_operand:GPI 1 "register_operand" "r") |
| 5900 |
(minus:QI (match_operand 2 "const_int_operand" "n") |
| 5901 |
(match_operator 5 "subreg_lowpart_operator" |
| 5902 |
[(and:SI (match_operand:SI 3 "register_operand" "r") |
| 5903 |
(match_operand 4 "const_int_operand" "n"))]))))] |
| 5904 |
"((~INTVAL (operands[4]) & (GET_MODE_BITSIZE (<MODE>mode) - 1)) == 0) |
| 5905 |
&& INTVAL (operands[2]) == GET_MODE_BITSIZE (<MODE>mode)" |
| 5906 |
"#" |
| 5907 |
"&& true" |
| 5908 |
[(const_int 0)] |
| 5909 |
{ |
| 5910 |
rtx tmp = (can_create_pseudo_p () ? gen_reg_rtx (SImode) |
| 5911 |
: operands[0]); |
| 5912 |
|
| 5913 |
emit_insn (gen_negsi2 (tmp, operands[3])); |
| 5914 |
|
| 5915 |
rtx and_op = gen_rtx_AND (SImode, tmp, operands[4]); |
| 5916 |
rtx subreg_tmp = gen_rtx_SUBREG (GET_MODE (operands[5]), and_op, |
| 5917 |
SUBREG_BYTE (operands[5])); |
| 5918 |
|
| 5919 |
emit_insn (gen_ashl<mode>3 (operands[0], operands[1], subreg_tmp)); |
| 5920 |
DONE; |
| 5921 |
} |
| 5922 |
) |
| 5923 |
|
| 5924 |
(define_insn "*aarch64_<optab>_reg_di3_mask2" |
| 5925 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 5926 |
(SHIFT:DI |
| 5927 |
(match_operand:DI 1 "register_operand" "r") |
| 5928 |
(match_operator 4 "subreg_lowpart_operator" |
| 5929 |
[(and:SI (match_operand:SI 2 "register_operand" "r") |
| 5930 |
(match_operand 3 "const_int_operand" "n"))])))] |
| 5931 |
"((~INTVAL (operands[3]) & (GET_MODE_BITSIZE (DImode) - 1)) == 0)" |
| 5932 |
{ |
| 5933 |
rtx xop[3]; |
| 5934 |
xop[0] = operands[0]; |
| 5935 |
xop[1] = operands[1]; |
| 5936 |
xop[2] = gen_lowpart (GET_MODE (operands[4]), operands[2]); |
| 5937 |
output_asm_insn ("<shift>\t%x0, %x1, %x2", xop); |
| 5938 |
return ""; |
| 5939 |
} |
| 5940 |
[(set_attr "type" "shift_reg")] |
| 5941 |
) |
| 5942 |
|
| 5943 |
(define_insn_and_split "*aarch64_<optab>_reg_minus<mode>3" |
| 5944 |
[(set (match_operand:GPI 0 "register_operand" "=&r") |
| 5945 |
(ASHIFT:GPI |
| 5946 |
(match_operand:GPI 1 "register_operand" "r") |
| 5947 |
(minus:QI (match_operand 2 "const_int_operand" "n") |
| 5948 |
(match_operand:QI 3 "register_operand" "r"))))] |
| 5949 |
"INTVAL (operands[2]) == GET_MODE_BITSIZE (<MODE>mode)" |
| 5950 |
"#" |
| 5951 |
"&& true" |
| 5952 |
[(const_int 0)] |
| 5953 |
{ |
| 5954 |
rtx subreg_tmp = gen_lowpart (SImode, operands[3]); |
| 5955 |
|
| 5956 |
rtx tmp = (can_create_pseudo_p () ? gen_reg_rtx (SImode) |
| 5957 |
: gen_lowpart (SImode, operands[0])); |
| 5958 |
|
| 5959 |
emit_insn (gen_negsi2 (tmp, subreg_tmp)); |
| 5960 |
|
| 5961 |
rtx and_op = gen_rtx_AND (SImode, tmp, |
| 5962 |
GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - 1)); |
| 5963 |
|
| 5964 |
rtx subreg_tmp2 = gen_lowpart_SUBREG (QImode, and_op); |
| 5965 |
|
| 5966 |
emit_insn (gen_<optab><mode>3 (operands[0], operands[1], subreg_tmp2)); |
| 5967 |
DONE; |
| 5968 |
} |
| 5969 |
[(set_attr "length" "8")] |
| 5970 |
) |
| 5971 |
|
| 5972 |
;; Logical left shift using SISD or Integer instruction |
| 5973 |
(define_insn "*aarch64_ashl_sisd_or_int_<mode>3" |
| 5974 |
[(set (match_operand:GPI 0 "register_operand") |
| 5975 |
(ashift:GPI |
| 5976 |
(match_operand:GPI 1 "register_operand") |
| 5977 |
(match_operand:QI 2 "aarch64_reg_or_shift_imm_<mode>")))] |
| 5978 |
"" |
| 5979 |
{@ [ cons: =0 , 1 , 2 ; attrs: type , arch ] |
| 5980 |
[ r , r , Us<cmode> ; bfx , * ] lsl\t%<w>0, %<w>1, %2 |
| 5981 |
[ r , r , r ; shift_reg , * ] lsl\t%<w>0, %<w>1, %<w>2 |
| 5982 |
[ w , w , Us<cmode> ; neon_shift_imm<q> , simd ] shl\t%<rtn>0<vas>, %<rtn>1<vas>, %2 |
| 5983 |
[ w , w , w ; neon_shift_reg<q> , simd ] ushl\t%<rtn>0<vas>, %<rtn>1<vas>, %<rtn>2<vas> |
| 5984 |
} |
| 5985 |
) |
| 5986 |
|
| 5987 |
;; Logical right shift using SISD or Integer instruction |
| 5988 |
(define_insn "*aarch64_lshr_sisd_or_int_<mode>3" |
| 5989 |
[(set (match_operand:GPI 0 "register_operand") |
| 5990 |
(lshiftrt:GPI |
| 5991 |
(match_operand:GPI 1 "register_operand") |
| 5992 |
(match_operand:QI 2 "aarch64_reg_or_shift_imm_<mode>")))] |
| 5993 |
"" |
| 5994 |
{@ [ cons: =0 , 1 , 2 ; attrs: type , arch ] |
| 5995 |
[ r , r , Us<cmode> ; bfx , * ] lsr\t%<w>0, %<w>1, %2 |
| 5996 |
[ r , r , r ; shift_reg , * ] lsr\t%<w>0, %<w>1, %<w>2 |
| 5997 |
[ w , w , Us<cmode_simd> ; neon_shift_imm<q> , simd ] ushr\t%<rtn>0<vas>, %<rtn>1<vas>, %2 |
| 5998 |
[ &w , w , w ; neon_shift_reg<q> , simd ] # |
| 5999 |
[ &w , w , 0 ; neon_shift_reg<q> , simd ] # |
| 6000 |
} |
| 6001 |
) |
| 6002 |
|
| 6003 |
(define_split |
| 6004 |
[(set (match_operand:DI 0 "aarch64_simd_register") |
| 6005 |
(lshiftrt:DI |
| 6006 |
(match_operand:DI 1 "aarch64_simd_register") |
| 6007 |
(match_operand:QI 2 "aarch64_simd_register")))] |
| 6008 |
"TARGET_SIMD && reload_completed" |
| 6009 |
[(set (match_dup 3) |
| 6010 |
(unspec:QI [(match_dup 2)] UNSPEC_SISD_NEG)) |
| 6011 |
(set (match_dup 0) |
| 6012 |
(unspec:DI [(match_dup 1) (match_dup 3)] UNSPEC_SISD_USHL))] |
| 6013 |
{ |
| 6014 |
operands[3] = gen_lowpart (QImode, operands[0]); |
| 6015 |
} |
| 6016 |
) |
| 6017 |
|
| 6018 |
(define_split |
| 6019 |
[(set (match_operand:SI 0 "aarch64_simd_register") |
| 6020 |
(lshiftrt:SI |
| 6021 |
(match_operand:SI 1 "aarch64_simd_register") |
| 6022 |
(match_operand:QI 2 "aarch64_simd_register")))] |
| 6023 |
"TARGET_SIMD && reload_completed" |
| 6024 |
[(set (match_dup 3) |
| 6025 |
(unspec:QI [(match_dup 2)] UNSPEC_SISD_NEG)) |
| 6026 |
(set (match_dup 0) |
| 6027 |
(unspec:SI [(match_dup 1) (match_dup 3)] UNSPEC_USHL_2S))] |
| 6028 |
{ |
| 6029 |
operands[3] = gen_lowpart (QImode, operands[0]); |
| 6030 |
} |
| 6031 |
) |
| 6032 |
|
| 6033 |
;; Arithmetic right shift using SISD or Integer instruction |
| 6034 |
(define_insn "*aarch64_ashr_sisd_or_int_<mode>3" |
| 6035 |
[(set (match_operand:GPI 0 "register_operand") |
| 6036 |
(ashiftrt:GPI |
| 6037 |
(match_operand:GPI 1 "register_operand") |
| 6038 |
(match_operand:QI 2 "aarch64_reg_or_shift_imm_di")))] |
| 6039 |
"" |
| 6040 |
{@ [ cons: =0 , 1 , 2 ; attrs: type , arch ] |
| 6041 |
[ r , r , Us<cmode> ; bfx , * ] asr\t%<w>0, %<w>1, %2 |
| 6042 |
[ r , r , r ; shift_reg , * ] asr\t%<w>0, %<w>1, %<w>2 |
| 6043 |
[ w , w , Us<cmode_simd> ; neon_shift_imm<q> , simd ] sshr\t%<rtn>0<vas>, %<rtn>1<vas>, %2 |
| 6044 |
[ &w , w , w ; neon_shift_reg<q> , simd ] # |
| 6045 |
[ &w , w , 0 ; neon_shift_reg<q> , simd ] # |
| 6046 |
} |
| 6047 |
) |
| 6048 |
|
| 6049 |
(define_split |
| 6050 |
[(set (match_operand:DI 0 "aarch64_simd_register") |
| 6051 |
(ashiftrt:DI |
| 6052 |
(match_operand:DI 1 "aarch64_simd_register") |
| 6053 |
(match_operand:QI 2 "aarch64_simd_register")))] |
| 6054 |
"TARGET_SIMD && reload_completed" |
| 6055 |
[(set (match_dup 3) |
| 6056 |
(unspec:QI [(match_dup 2)] UNSPEC_SISD_NEG)) |
| 6057 |
(set (match_dup 0) |
| 6058 |
(unspec:DI [(match_dup 1) (match_dup 3)] UNSPEC_SISD_SSHL))] |
| 6059 |
{ |
| 6060 |
operands[3] = gen_lowpart (QImode, operands[0]); |
| 6061 |
} |
| 6062 |
) |
| 6063 |
|
| 6064 |
(define_split |
| 6065 |
[(set (match_operand:SI 0 "aarch64_simd_register") |
| 6066 |
(ashiftrt:SI |
| 6067 |
(match_operand:SI 1 "aarch64_simd_register") |
| 6068 |
(match_operand:QI 2 "aarch64_simd_register")))] |
| 6069 |
"TARGET_SIMD && reload_completed" |
| 6070 |
[(set (match_dup 3) |
| 6071 |
(unspec:QI [(match_dup 2)] UNSPEC_SISD_NEG)) |
| 6072 |
(set (match_dup 0) |
| 6073 |
(unspec:SI [(match_dup 1) (match_dup 3)] UNSPEC_SSHL_2S))] |
| 6074 |
{ |
| 6075 |
operands[3] = gen_lowpart (QImode, operands[0]); |
| 6076 |
} |
| 6077 |
) |
| 6078 |
|
| 6079 |
(define_insn "*aarch64_sisd_ushl" |
| 6080 |
[(set (match_operand:DI 0 "register_operand" "=w") |
| 6081 |
(unspec:DI [(match_operand:DI 1 "register_operand" "w") |
| 6082 |
(match_operand:QI 2 "register_operand" "w")] |
| 6083 |
UNSPEC_SISD_USHL))] |
| 6084 |
"TARGET_SIMD" |
| 6085 |
"ushl\t%d0, %d1, %d2" |
| 6086 |
[(set_attr "type" "neon_shift_reg")] |
| 6087 |
) |
| 6088 |
|
| 6089 |
(define_insn "*aarch64_ushl_2s" |
| 6090 |
[(set (match_operand:SI 0 "register_operand" "=w") |
| 6091 |
(unspec:SI [(match_operand:SI 1 "register_operand" "w") |
| 6092 |
(match_operand:QI 2 "register_operand" "w")] |
| 6093 |
UNSPEC_USHL_2S))] |
| 6094 |
"TARGET_SIMD" |
| 6095 |
"ushl\t%0.2s, %1.2s, %2.2s" |
| 6096 |
[(set_attr "type" "neon_shift_reg")] |
| 6097 |
) |
| 6098 |
|
| 6099 |
(define_insn "*aarch64_sisd_sshl" |
| 6100 |
[(set (match_operand:DI 0 "register_operand" "=w") |
| 6101 |
(unspec:DI [(match_operand:DI 1 "register_operand" "w") |
| 6102 |
(match_operand:QI 2 "register_operand" "w")] |
| 6103 |
UNSPEC_SISD_SSHL))] |
| 6104 |
"TARGET_SIMD" |
| 6105 |
"sshl\t%d0, %d1, %d2" |
| 6106 |
[(set_attr "type" "neon_shift_reg")] |
| 6107 |
) |
| 6108 |
|
| 6109 |
(define_insn "*aarch64_sshl_2s" |
| 6110 |
[(set (match_operand:SI 0 "register_operand" "=w") |
| 6111 |
(unspec:SI [(match_operand:SI 1 "register_operand" "w") |
| 6112 |
(match_operand:QI 2 "register_operand" "w")] |
| 6113 |
UNSPEC_SSHL_2S))] |
| 6114 |
"TARGET_SIMD" |
| 6115 |
"sshl\t%0.2s, %1.2s, %2.2s" |
| 6116 |
[(set_attr "type" "neon_shift_reg")] |
| 6117 |
) |
| 6118 |
|
| 6119 |
(define_insn "*aarch64_sisd_neg_qi" |
| 6120 |
[(set (match_operand:QI 0 "register_operand" "=w") |
| 6121 |
(unspec:QI [(match_operand:QI 1 "register_operand" "w")] |
| 6122 |
UNSPEC_SISD_NEG))] |
| 6123 |
"TARGET_SIMD" |
| 6124 |
"neg\t%d0, %d1" |
| 6125 |
[(set_attr "type" "neon_neg")] |
| 6126 |
) |
| 6127 |
|
| 6128 |
;; Rotate right |
| 6129 |
(define_insn "*ror<mode>3_insn" |
| 6130 |
[(set (match_operand:GPI 0 "register_operand") |
| 6131 |
(rotatert:GPI |
| 6132 |
(match_operand:GPI 1 "register_operand") |
| 6133 |
(match_operand:QI 2 "aarch64_reg_or_shift_imm_<mode>")))] |
| 6134 |
"" |
| 6135 |
{@ [ cons: =0 , 1 , 2 ; attrs: type ] |
| 6136 |
[ r , r , Us<cmode> ; rotate_imm ] ror\t%<w>0, %<w>1, %2 |
| 6137 |
[ r , r , r ; shift_reg ] ror\t%<w>0, %<w>1, %<w>2 |
| 6138 |
} |
| 6139 |
) |
| 6140 |
|
| 6141 |
(define_insn "*rol<mode>3_insn" |
| 6142 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 6143 |
(rotate:GPI (match_operand:GPI 1 "register_operand" "r") |
| 6144 |
(match_operand 2 "const_int_operand" "n")))] |
| 6145 |
"UINTVAL (operands[2]) < GET_MODE_BITSIZE (<MODE>mode)" |
| 6146 |
{ |
| 6147 |
operands[3] = GEN_INT (<sizen> - UINTVAL (operands[2])); |
| 6148 |
return "ror\\t%<w>0, %<w>1, %3"; |
| 6149 |
} |
| 6150 |
[(set_attr "type" "rotate_imm")] |
| 6151 |
) |
| 6152 |
|
| 6153 |
;; zero_extend version of shifts |
| 6154 |
(define_insn "*<optab>si3_insn_uxtw" |
| 6155 |
[(set (match_operand:DI 0 "register_operand") |
| 6156 |
(zero_extend:DI (SHIFT_no_rotate:SI |
| 6157 |
(match_operand:SI 1 "register_operand") |
| 6158 |
(match_operand:QI 2 "aarch64_reg_or_shift_imm_si"))))] |
| 6159 |
"" |
| 6160 |
{@ [ cons: =0 , 1 , 2 ; attrs: type ] |
| 6161 |
[ r , r , Uss ; bfx ] <shift>\t%w0, %w1, %2 |
| 6162 |
[ r , r , r ; shift_reg ] <shift>\t%w0, %w1, %w2 |
| 6163 |
} |
| 6164 |
) |
| 6165 |
|
| 6166 |
;; zero_extend version of rotate right |
| 6167 |
(define_insn "*rorsi3_insn_uxtw" |
| 6168 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 6169 |
(zero_extend:DI |
| 6170 |
(rotatert:SI (match_operand:SI 1 "register_operand" "r") |
| 6171 |
(match_operand 2 "const_int_operand" "n"))))] |
| 6172 |
"UINTVAL (operands[2]) < 32" |
| 6173 |
"ror\\t%w0, %w1, %2" |
| 6174 |
[(set_attr "type" "rotate_imm")] |
| 6175 |
) |
| 6176 |
|
| 6177 |
;; zero_extend version of rotate left |
| 6178 |
(define_insn "*rolsi3_insn_uxtw" |
| 6179 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 6180 |
(zero_extend:DI |
| 6181 |
(rotate:SI (match_operand:SI 1 "register_operand" "r") |
| 6182 |
(match_operand 2 "const_int_operand" "n"))))] |
| 6183 |
"UINTVAL (operands[2]) < 32" |
| 6184 |
{ |
| 6185 |
operands[2] = GEN_INT (32 - UINTVAL (operands[2])); |
| 6186 |
return "ror\\t%w0, %w1, %2"; |
| 6187 |
} |
| 6188 |
[(set_attr "type" "rotate_imm")] |
| 6189 |
) |
| 6190 |
|
| 6191 |
(define_insn "*<optab><mode>3_insn" |
| 6192 |
[(set (match_operand:SHORT 0 "register_operand" "=r") |
| 6193 |
(ASHIFT:SHORT (match_operand:SHORT 1 "register_operand" "r") |
| 6194 |
(match_operand 2 "const_int_operand" "n")))] |
| 6195 |
"UINTVAL (operands[2]) < GET_MODE_BITSIZE (<MODE>mode)" |
| 6196 |
{ |
| 6197 |
operands[3] = GEN_INT (<sizen> - UINTVAL (operands[2])); |
| 6198 |
return "<bfshift>\t%w0, %w1, %2, %3"; |
| 6199 |
} |
| 6200 |
[(set_attr "type" "bfx")] |
| 6201 |
) |
| 6202 |
|
| 6203 |
(define_insn "*extr<mode>5_insn" |
| 6204 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 6205 |
(any_or_plus:GPI |
| 6206 |
(ashift:GPI (match_operand:GPI 1 "register_operand" "r") |
| 6207 |
(match_operand 3 "const_int_operand" "n")) |
| 6208 |
(lshiftrt:GPI (match_operand:GPI 2 "register_operand" "r") |
| 6209 |
(match_operand 4 "const_int_operand" "n"))))] |
| 6210 |
"UINTVAL (operands[3]) < GET_MODE_BITSIZE (<MODE>mode) && |
| 6211 |
(UINTVAL (operands[3]) + UINTVAL (operands[4]) == GET_MODE_BITSIZE (<MODE>mode))" |
| 6212 |
"extr\\t%<w>0, %<w>1, %<w>2, %4" |
| 6213 |
[(set_attr "type" "rotate_imm")] |
| 6214 |
) |
| 6215 |
|
| 6216 |
;; There are no canonicalisation rules for ashift and lshiftrt inside an ior |
| 6217 |
;; so we have to match both orderings. |
| 6218 |
(define_insn "*extr<mode>5_insn_alt" |
| 6219 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 6220 |
(any_or_plus:GPI |
| 6221 |
(lshiftrt:GPI (match_operand:GPI 2 "register_operand" "r") |
| 6222 |
(match_operand 4 "const_int_operand" "n")) |
| 6223 |
(ashift:GPI (match_operand:GPI 1 "register_operand" "r") |
| 6224 |
(match_operand 3 "const_int_operand" "n"))))] |
| 6225 |
"UINTVAL (operands[3]) < GET_MODE_BITSIZE (<MODE>mode) |
| 6226 |
&& (UINTVAL (operands[3]) + UINTVAL (operands[4]) |
| 6227 |
== GET_MODE_BITSIZE (<MODE>mode))" |
| 6228 |
"extr\\t%<w>0, %<w>1, %<w>2, %4" |
| 6229 |
[(set_attr "type" "rotate_imm")] |
| 6230 |
) |
| 6231 |
|
| 6232 |
;; zero_extend version of the above |
| 6233 |
(define_insn "*extrsi5_insn_uxtw" |
| 6234 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 6235 |
(zero_extend:DI |
| 6236 |
(any_or_plus:SI |
| 6237 |
(ashift:SI (match_operand:SI 1 "register_operand" "r") |
| 6238 |
(match_operand 3 "const_int_operand" "n")) |
| 6239 |
(lshiftrt:SI (match_operand:SI 2 "register_operand" "r") |
| 6240 |
(match_operand 4 "const_int_operand" "n")))))] |
| 6241 |
"UINTVAL (operands[3]) < 32 && |
| 6242 |
(UINTVAL (operands[3]) + UINTVAL (operands[4]) == 32)" |
| 6243 |
"extr\\t%w0, %w1, %w2, %4" |
| 6244 |
[(set_attr "type" "rotate_imm")] |
| 6245 |
) |
| 6246 |
|
| 6247 |
(define_insn "*extrsi5_insn_uxtw_alt" |
| 6248 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 6249 |
(zero_extend:DI |
| 6250 |
(any_or_plus:SI |
| 6251 |
(lshiftrt:SI (match_operand:SI 2 "register_operand" "r") |
| 6252 |
(match_operand 4 "const_int_operand" "n")) |
| 6253 |
(ashift:SI (match_operand:SI 1 "register_operand" "r") |
| 6254 |
(match_operand 3 "const_int_operand" "n")))))] |
| 6255 |
"UINTVAL (operands[3]) < 32 && |
| 6256 |
(UINTVAL (operands[3]) + UINTVAL (operands[4]) == 32)" |
| 6257 |
"extr\\t%w0, %w1, %w2, %4" |
| 6258 |
[(set_attr "type" "rotate_imm")] |
| 6259 |
) |
| 6260 |
|
| 6261 |
(define_insn "*extrsi5_insn_di" |
| 6262 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 6263 |
(any_or_plus:SI (ashift:SI (match_operand:SI 1 "register_operand" "r") |
| 6264 |
(match_operand 3 "const_int_operand" "n")) |
| 6265 |
(match_operator:SI 6 "subreg_lowpart_operator" |
| 6266 |
[(zero_extract:DI |
| 6267 |
(match_operand:DI 2 "register_operand" "r") |
| 6268 |
(match_operand 5 "const_int_operand" "n") |
| 6269 |
(match_operand 4 "const_int_operand" "n"))])))] |
| 6270 |
"UINTVAL (operands[3]) < 32 |
| 6271 |
&& UINTVAL (operands[3]) + UINTVAL (operands[4]) == 32 |
| 6272 |
&& INTVAL (operands[3]) == INTVAL (operands[5])" |
| 6273 |
"extr\\t%w0, %w1, %w2, %4" |
| 6274 |
[(set_attr "type" "rotate_imm")] |
| 6275 |
) |
| 6276 |
|
| 6277 |
(define_insn "*<ANY_EXTEND:optab><GPI:mode>_ashl<SHORT:mode>" |
| 6278 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 6279 |
(ANY_EXTEND:GPI |
| 6280 |
(ashift:SHORT (match_operand:SHORT 1 "register_operand" "r") |
| 6281 |
(match_operand 2 "const_int_operand" "n"))))] |
| 6282 |
"UINTVAL (operands[2]) < GET_MODE_BITSIZE (<SHORT:MODE>mode)" |
| 6283 |
{ |
| 6284 |
operands[3] = GEN_INT (<SHORT:sizen> - UINTVAL (operands[2])); |
| 6285 |
return "<su>bfiz\t%<GPI:w>0, %<GPI:w>1, %2, %3"; |
| 6286 |
} |
| 6287 |
[(set_attr "type" "bfx")] |
| 6288 |
) |
| 6289 |
|
| 6290 |
(define_insn "*zero_extend<GPI:mode>_lshr<SHORT:mode>" |
| 6291 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 6292 |
(zero_extend:GPI |
| 6293 |
(lshiftrt:SHORT (match_operand:SHORT 1 "register_operand" "r") |
| 6294 |
(match_operand 2 "const_int_operand" "n"))))] |
| 6295 |
"UINTVAL (operands[2]) < GET_MODE_BITSIZE (<SHORT:MODE>mode)" |
| 6296 |
{ |
| 6297 |
operands[3] = GEN_INT (<SHORT:sizen> - UINTVAL (operands[2])); |
| 6298 |
return "ubfx\t%<GPI:w>0, %<GPI:w>1, %2, %3"; |
| 6299 |
} |
| 6300 |
[(set_attr "type" "bfx")] |
| 6301 |
) |
| 6302 |
|
| 6303 |
(define_insn "*extend<GPI:mode>_ashr<SHORT:mode>" |
| 6304 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 6305 |
(sign_extend:GPI |
| 6306 |
(ashiftrt:SHORT (match_operand:SHORT 1 "register_operand" "r") |
| 6307 |
(match_operand 2 "const_int_operand" "n"))))] |
| 6308 |
"UINTVAL (operands[2]) < GET_MODE_BITSIZE (<SHORT:MODE>mode)" |
| 6309 |
{ |
| 6310 |
operands[3] = GEN_INT (<SHORT:sizen> - UINTVAL (operands[2])); |
| 6311 |
return "sbfx\\t%<GPI:w>0, %<GPI:w>1, %2, %3"; |
| 6312 |
} |
| 6313 |
[(set_attr "type" "bfx")] |
| 6314 |
) |
| 6315 |
|
| 6316 |
;; ------------------------------------------------------------------- |
| 6317 |
;; Bitfields |
| 6318 |
;; ------------------------------------------------------------------- |
| 6319 |
|
| 6320 |
(define_expand "<optab>" |
| 6321 |
[(set (match_operand:DI 0 "register_operand") |
| 6322 |
(ANY_EXTRACT:DI (match_operand:DI 1 "register_operand") |
| 6323 |
(match_operand 2 |
| 6324 |
"aarch64_simd_shift_imm_offset_di") |
| 6325 |
(match_operand 3 "aarch64_simd_shift_imm_di")))] |
| 6326 |
"" |
| 6327 |
{ |
| 6328 |
if (!IN_RANGE (INTVAL (operands[2]) + INTVAL (operands[3]), |
| 6329 |
1, GET_MODE_BITSIZE (DImode) - 1)) |
| 6330 |
FAIL; |
| 6331 |
} |
| 6332 |
) |
| 6333 |
|
| 6334 |
|
| 6335 |
(define_insn "*<optab><mode>" |
| 6336 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 6337 |
(ANY_EXTRACT:GPI (match_operand:GPI 1 "register_operand" "r") |
| 6338 |
(match_operand 2 |
| 6339 |
"aarch64_simd_shift_imm_offset_<mode>" "n") |
| 6340 |
(match_operand 3 |
| 6341 |
"aarch64_simd_shift_imm_<mode>" "n")))] |
| 6342 |
"IN_RANGE (INTVAL (operands[2]) + INTVAL (operands[3]), |
| 6343 |
1, GET_MODE_BITSIZE (<MODE>mode) - 1)" |
| 6344 |
"<su>bfx\\t%<w>0, %<w>1, %3, %2" |
| 6345 |
[(set_attr "type" "bfx")] |
| 6346 |
) |
| 6347 |
|
| 6348 |
;; When the bit position and width add up to 32 we can use a W-reg LSR |
| 6349 |
;; instruction taking advantage of the implicit zero-extension of the X-reg. |
| 6350 |
(define_split |
| 6351 |
[(set (match_operand:DI 0 "register_operand") |
| 6352 |
(zero_extract:DI (match_operand:DI 1 "register_operand") |
| 6353 |
(match_operand 2 |
| 6354 |
"aarch64_simd_shift_imm_offset_di") |
| 6355 |
(match_operand 3 |
| 6356 |
"aarch64_simd_shift_imm_di")))] |
| 6357 |
"IN_RANGE (INTVAL (operands[2]) + INTVAL (operands[3]), 1, |
| 6358 |
GET_MODE_BITSIZE (DImode) - 1) |
| 6359 |
&& (INTVAL (operands[2]) + INTVAL (operands[3])) |
| 6360 |
== GET_MODE_BITSIZE (SImode)" |
| 6361 |
[(set (match_dup 0) |
| 6362 |
(zero_extend:DI (lshiftrt:SI (match_dup 4) (match_dup 3))))] |
| 6363 |
{ |
| 6364 |
operands[4] = gen_lowpart (SImode, operands[1]); |
| 6365 |
} |
| 6366 |
) |
| 6367 |
|
| 6368 |
;; Bitfield Insert (insv) |
| 6369 |
(define_expand "insv<mode>" |
| 6370 |
[(set (zero_extract:GPI (match_operand:GPI 0 "register_operand") |
| 6371 |
(match_operand 1 "const_int_operand") |
| 6372 |
(match_operand 2 "const_int_operand")) |
| 6373 |
(match_operand:GPI 3 "general_operand"))] |
| 6374 |
"" |
| 6375 |
{ |
| 6376 |
unsigned HOST_WIDE_INT width = UINTVAL (operands[1]); |
| 6377 |
unsigned HOST_WIDE_INT pos = UINTVAL (operands[2]); |
| 6378 |
rtx value = operands[3]; |
| 6379 |
|
| 6380 |
if (width == 0 || (pos + width) > GET_MODE_BITSIZE (<MODE>mode)) |
| 6381 |
FAIL; |
| 6382 |
|
| 6383 |
if (CONST_INT_P (value)) |
| 6384 |
{ |
| 6385 |
unsigned HOST_WIDE_INT mask = ((unsigned HOST_WIDE_INT)1 << width) - 1; |
| 6386 |
|
| 6387 |
/* Prefer AND/OR for inserting all zeros or all ones. */ |
| 6388 |
if ((UINTVAL (value) & mask) == 0 |
| 6389 |
|| (UINTVAL (value) & mask) == mask) |
| 6390 |
FAIL; |
| 6391 |
|
| 6392 |
/* 16-bit aligned 16-bit wide insert is handled by insv_imm. */ |
| 6393 |
if (width == 16 && (pos % 16) == 0) |
| 6394 |
DONE; |
| 6395 |
} |
| 6396 |
operands[3] = force_reg (<MODE>mode, value); |
| 6397 |
}) |
| 6398 |
|
| 6399 |
(define_insn "*insv_reg<mode>_<SUBDI_BITS>" |
| 6400 |
[(set (zero_extract:GPI (match_operand:GPI 0 "register_operand" "+r,w,?w") |
| 6401 |
(const_int SUBDI_BITS) |
| 6402 |
(match_operand 1 "const_int_operand")) |
| 6403 |
(match_operand:GPI 2 "register_operand" "r,w,r"))] |
| 6404 |
"multiple_p (UINTVAL (operands[1]), <SUBDI_BITS>) |
| 6405 |
&& UINTVAL (operands[1]) + <SUBDI_BITS> <= <GPI:sizen>" |
| 6406 |
{ |
| 6407 |
if (which_alternative == 0) |
| 6408 |
return "bfi\t%<w>0, %<w>2, %1, <SUBDI_BITS>"; |
| 6409 |
|
| 6410 |
operands[1] = gen_int_mode (UINTVAL (operands[1]) / <SUBDI_BITS>, SImode); |
| 6411 |
if (which_alternative == 1) |
| 6412 |
return "ins\t%0.<bits_etype>[%1], %2.<bits_etype>[0]"; |
| 6413 |
return "ins\t%0.<bits_etype>[%1], %w2"; |
| 6414 |
} |
| 6415 |
[(set_attr "type" "bfm,neon_ins_q,neon_ins_q") |
| 6416 |
(set_attr "arch" "*,simd,simd")] |
| 6417 |
) |
| 6418 |
|
| 6419 |
(define_insn "*insv_reg<mode>" |
| 6420 |
[(set (zero_extract:GPI (match_operand:GPI 0 "register_operand" "+r") |
| 6421 |
(match_operand 1 "const_int_operand" "n") |
| 6422 |
(match_operand 2 "const_int_operand" "n")) |
| 6423 |
(match_operand:GPI 3 "register_operand" "r"))] |
| 6424 |
"!(UINTVAL (operands[1]) == 0 |
| 6425 |
|| (UINTVAL (operands[2]) + UINTVAL (operands[1]) |
| 6426 |
> GET_MODE_BITSIZE (<MODE>mode)))" |
| 6427 |
"bfi\\t%<w>0, %<w>3, %2, %1" |
| 6428 |
[(set_attr "type" "bfm")] |
| 6429 |
) |
| 6430 |
|
| 6431 |
(define_insn_and_split "*aarch64_bfi<GPI:mode><ALLX:mode>_<SUBDI_BITS>" |
| 6432 |
[(set (zero_extract:GPI (match_operand:GPI 0 "register_operand" "+r,w,?w") |
| 6433 |
(const_int SUBDI_BITS) |
| 6434 |
(match_operand 1 "const_int_operand")) |
| 6435 |
(zero_extend:GPI (match_operand:ALLX 2 "register_operand" "r,w,r")))] |
| 6436 |
"<SUBDI_BITS> <= <ALLX:sizen> |
| 6437 |
&& multiple_p (UINTVAL (operands[1]), <SUBDI_BITS>) |
| 6438 |
&& UINTVAL (operands[1]) + <SUBDI_BITS> <= <GPI:sizen>" |
| 6439 |
"#" |
| 6440 |
"&& 1" |
| 6441 |
[(set (zero_extract:GPI (match_dup 0) |
| 6442 |
(const_int SUBDI_BITS) |
| 6443 |
(match_dup 1)) |
| 6444 |
(match_dup 2))] |
| 6445 |
{ |
| 6446 |
operands[2] = force_lowpart_subreg (<GPI:MODE>mode, operands[2], |
| 6447 |
<ALLX:MODE>mode); |
| 6448 |
} |
| 6449 |
[(set_attr "type" "bfm,neon_ins_q,neon_ins_q") |
| 6450 |
(set_attr "arch" "*,simd,simd")] |
| 6451 |
) |
| 6452 |
|
| 6453 |
(define_insn "*aarch64_bfi<GPI:mode><ALLX:mode>4" |
| 6454 |
[(set (zero_extract:GPI (match_operand:GPI 0 "register_operand" "+r") |
| 6455 |
(match_operand 1 "const_int_operand" "n") |
| 6456 |
(match_operand 2 "const_int_operand" "n")) |
| 6457 |
(zero_extend:GPI (match_operand:ALLX 3 "register_operand" "r")))] |
| 6458 |
"UINTVAL (operands[1]) <= <ALLX:sizen>" |
| 6459 |
"bfi\\t%<GPI:w>0, %<GPI:w>3, %2, %1" |
| 6460 |
[(set_attr "type" "bfm")] |
| 6461 |
) |
| 6462 |
|
| 6463 |
(define_insn_and_split "*aarch64_bfidi<ALLX:mode>_subreg_<SUBDI_BITS>" |
| 6464 |
[(set (zero_extract:DI (match_operand:DI 0 "register_operand" "+r,w,?w") |
| 6465 |
(const_int SUBDI_BITS) |
| 6466 |
(match_operand 1 "const_int_operand")) |
| 6467 |
(match_operator:DI 2 "subreg_lowpart_operator" |
| 6468 |
[(zero_extend:SI |
| 6469 |
(match_operand:ALLX 3 "register_operand" "r,w,r"))]))] |
| 6470 |
"<SUBDI_BITS> <= <ALLX:sizen> |
| 6471 |
&& multiple_p (UINTVAL (operands[1]), <SUBDI_BITS>) |
| 6472 |
&& UINTVAL (operands[1]) + <SUBDI_BITS> <= 64" |
| 6473 |
"#" |
| 6474 |
"&& 1" |
| 6475 |
[(set (zero_extract:DI (match_dup 0) |
| 6476 |
(const_int SUBDI_BITS) |
| 6477 |
(match_dup 1)) |
| 6478 |
(match_dup 2))] |
| 6479 |
{ |
| 6480 |
operands[2] = lowpart_subreg (DImode, operands[3], <ALLX:MODE>mode); |
| 6481 |
} |
| 6482 |
[(set_attr "type" "bfm,neon_ins_q,neon_ins_q") |
| 6483 |
(set_attr "arch" "*,simd,simd")] |
| 6484 |
) |
| 6485 |
|
| 6486 |
;; Match a bfi instruction where the shift of OP3 means that we are |
| 6487 |
;; actually copying the least significant bits of OP3 into OP0 by way |
| 6488 |
;; of the AND masks and the IOR instruction. A similar instruction |
| 6489 |
;; with the two parts of the IOR swapped around was never triggered |
| 6490 |
;; in a bootstrap build and test of GCC so it was not included. |
| 6491 |
|
| 6492 |
(define_insn "*aarch64_bfi<GPI:mode>5_shift" |
| 6493 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 6494 |
(ior:GPI (and:GPI (match_operand:GPI 1 "register_operand" "0") |
| 6495 |
(match_operand:GPI 2 "const_int_operand" "n")) |
| 6496 |
(and:GPI (ashift:GPI |
| 6497 |
(match_operand:GPI 3 "register_operand" "r") |
| 6498 |
(match_operand:GPI 4 "aarch64_simd_shift_imm_<mode>" "n")) |
| 6499 |
(match_operand:GPI 5 "const_int_operand" "n"))))] |
| 6500 |
"aarch64_masks_and_shift_for_bfi_p (<MODE>mode, UINTVAL (operands[2]), |
| 6501 |
UINTVAL (operands[4]), |
| 6502 |
UINTVAL(operands[5]))" |
| 6503 |
"bfi\t%<GPI:w>0, %<GPI:w>3, %4, %P5" |
| 6504 |
[(set_attr "type" "bfm")] |
| 6505 |
) |
| 6506 |
|
| 6507 |
(define_insn "*aarch64_bfi<GPI:mode>5_shift_alt" |
| 6508 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 6509 |
(ior:GPI (and:GPI (ashift:GPI |
| 6510 |
(match_operand:GPI 1 "register_operand" "r") |
| 6511 |
(match_operand:GPI 2 "aarch64_simd_shift_imm_<mode>" "n")) |
| 6512 |
(match_operand:GPI 3 "const_int_operand" "n")) |
| 6513 |
(and:GPI (match_operand:GPI 4 "register_operand" "0") |
| 6514 |
(match_operand:GPI 5 "const_int_operand" "n"))))] |
| 6515 |
"aarch64_masks_and_shift_for_bfi_p (<MODE>mode, UINTVAL (operands[5]), |
| 6516 |
UINTVAL (operands[2]), |
| 6517 |
UINTVAL(operands[3]))" |
| 6518 |
"bfi\t%<GPI:w>0, %<GPI:w>1, %2, %P3" |
| 6519 |
[(set_attr "type" "bfm")] |
| 6520 |
) |
| 6521 |
|
| 6522 |
;; Like *aarch64_bfi<GPI:mode>5_shift but with no and of the ashift because |
| 6523 |
;; the shift is large enough to remove the need for an AND instruction. |
| 6524 |
|
| 6525 |
(define_insn "*aarch64_bfi<GPI:mode>4_noand" |
| 6526 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 6527 |
(ior:GPI (and:GPI (match_operand:GPI 1 "register_operand" "0") |
| 6528 |
(match_operand:GPI 2 "const_int_operand" "n")) |
| 6529 |
(ashift:GPI |
| 6530 |
(match_operand:GPI 3 "register_operand" "r") |
| 6531 |
(match_operand:GPI 4 "aarch64_simd_shift_imm_<mode>" "n"))))] |
| 6532 |
"aarch64_masks_and_shift_for_bfi_p (<MODE>mode, UINTVAL (operands[2]), |
| 6533 |
UINTVAL (operands[4]), |
| 6534 |
HOST_WIDE_INT_M1U << UINTVAL (operands[4]) )" |
| 6535 |
{ |
| 6536 |
operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - UINTVAL (operands[4])); |
| 6537 |
return "bfi\t%<GPI:w>0, %<GPI:w>3, %4, %5"; |
| 6538 |
} |
| 6539 |
[(set_attr "type" "bfm")] |
| 6540 |
) |
| 6541 |
|
| 6542 |
(define_insn "*aarch64_bfi<GPI:mode>4_noand_alt" |
| 6543 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 6544 |
(ior:GPI (ashift:GPI |
| 6545 |
(match_operand:GPI 1 "register_operand" "r") |
| 6546 |
(match_operand:GPI 2 "aarch64_simd_shift_imm_<mode>" "n")) |
| 6547 |
(and:GPI (match_operand:GPI 3 "register_operand" "0") |
| 6548 |
(match_operand:GPI 4 "const_int_operand" "n"))))] |
| 6549 |
"aarch64_masks_and_shift_for_bfi_p (<MODE>mode, UINTVAL (operands[4]), |
| 6550 |
UINTVAL (operands[2]), |
| 6551 |
HOST_WIDE_INT_M1U << UINTVAL (operands[2]) )" |
| 6552 |
{ |
| 6553 |
operands[5] = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - UINTVAL (operands[2])); |
| 6554 |
return "bfi\t%<GPI:w>0, %<GPI:w>1, %2, %5"; |
| 6555 |
} |
| 6556 |
[(set_attr "type" "bfm")] |
| 6557 |
) |
| 6558 |
|
| 6559 |
;; Like *aarch64_bfi<GPI:mode>5_shift but with no shifting, we are just |
| 6560 |
;; copying the least significant bits of OP3 to OP0. We need two versions |
| 6561 |
;; of the instruction to handle different checks on the constant values. |
| 6562 |
|
| 6563 |
(define_insn "*aarch64_bfi<GPI:mode>4_noshift" |
| 6564 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 6565 |
(ior:GPI (and:GPI (match_operand:GPI 1 "register_operand" "0") |
| 6566 |
(match_operand:GPI 2 "const_int_operand" "n")) |
| 6567 |
(and:GPI (match_operand:GPI 3 "register_operand" "r") |
| 6568 |
(match_operand:GPI 4 "const_int_operand" "n"))))] |
| 6569 |
"aarch64_masks_and_shift_for_bfi_p (<MODE>mode, UINTVAL (operands[2]), 0, |
| 6570 |
UINTVAL (operands[4]))" |
| 6571 |
"bfi\t%<GPI:w>0, %<GPI:w>3, 0, %P4" |
| 6572 |
[(set_attr "type" "bfm")] |
| 6573 |
) |
| 6574 |
|
| 6575 |
(define_insn "*aarch64_bfi<GPI:mode>4_noshift_alt" |
| 6576 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 6577 |
(ior:GPI (and:GPI (match_operand:GPI 3 "register_operand" "r") |
| 6578 |
(match_operand:GPI 4 "const_int_operand" "n")) |
| 6579 |
(and:GPI (match_operand:GPI 1 "register_operand" "0") |
| 6580 |
(match_operand:GPI 2 "const_int_operand" "n"))))] |
| 6581 |
"aarch64_masks_and_shift_for_bfi_p (<MODE>mode, UINTVAL (operands[2]), 0, |
| 6582 |
UINTVAL (operands[4]))" |
| 6583 |
"bfi\t%<GPI:w>0, %<GPI:w>3, 0, %P4" |
| 6584 |
[(set_attr "type" "bfm")] |
| 6585 |
) |
| 6586 |
|
| 6587 |
(define_insn "*aarch64_bfxil<mode>_extr" |
| 6588 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 6589 |
(ior:GPI (and:GPI (match_operand:GPI 1 "register_operand" "0") |
| 6590 |
(match_operand:GPI 2 "const_int_operand" "n")) |
| 6591 |
(zero_extract:GPI |
| 6592 |
(match_operand:GPI 3 "register_operand" "r") |
| 6593 |
(match_operand:GPI 4 "aarch64_simd_shift_imm_<mode>" "n") |
| 6594 |
(match_operand:GPI 5 "aarch64_simd_shift_imm_<mode>" "n"))))] |
| 6595 |
"UINTVAL (operands[2]) == HOST_WIDE_INT_M1U << INTVAL (operands[4]) |
| 6596 |
&& INTVAL (operands[4]) |
| 6597 |
&& (UINTVAL (operands[4]) + UINTVAL (operands[5]) |
| 6598 |
<= GET_MODE_BITSIZE (<MODE>mode))" |
| 6599 |
"bfxil\t%<GPI:w>0, %<GPI:w>3, %5, %4" |
| 6600 |
[(set_attr "type" "bfm")] |
| 6601 |
) |
| 6602 |
|
| 6603 |
(define_insn "*aarch64_bfxilsi_extrdi" |
| 6604 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 6605 |
(ior:SI (and:SI (match_operand:SI 1 "register_operand" "0") |
| 6606 |
(match_operand:SI 2 "const_int_operand" "n")) |
| 6607 |
(match_operator:SI 6 "subreg_lowpart_operator" |
| 6608 |
[(zero_extract:DI |
| 6609 |
(match_operand:DI 3 "register_operand" "r") |
| 6610 |
(match_operand:SI 4 "aarch64_simd_shift_imm_si" "n") |
| 6611 |
(match_operand:SI 5 "aarch64_simd_shift_imm_si" "n"))])))] |
| 6612 |
"UINTVAL (operands[2]) == HOST_WIDE_INT_M1U << INTVAL (operands[4]) |
| 6613 |
&& INTVAL (operands[4]) |
| 6614 |
&& UINTVAL (operands[4]) + UINTVAL (operands[5]) <= 32" |
| 6615 |
"bfxil\t%w0, %w3, %5, %4" |
| 6616 |
[(set_attr "type" "bfm")] |
| 6617 |
) |
| 6618 |
|
| 6619 |
(define_insn "*extr_insv_lower_reg<mode>" |
| 6620 |
[(set (zero_extract:GPI (match_operand:GPI 0 "register_operand" "+r") |
| 6621 |
(match_operand 1 "const_int_operand" "n") |
| 6622 |
(const_int 0)) |
| 6623 |
(zero_extract:GPI (match_operand:GPI 2 "register_operand" "r") |
| 6624 |
(match_dup 1) |
| 6625 |
(match_operand 3 "const_int_operand" "n")))] |
| 6626 |
"!(UINTVAL (operands[1]) == 0 |
| 6627 |
|| (UINTVAL (operands[3]) + UINTVAL (operands[1]) |
| 6628 |
> GET_MODE_BITSIZE (<MODE>mode)))" |
| 6629 |
"bfxil\\t%<w>0, %<w>2, %3, %1" |
| 6630 |
[(set_attr "type" "bfm")] |
| 6631 |
) |
| 6632 |
|
| 6633 |
(define_insn "*<optab><ALLX:mode>_shft_<GPI:mode>" |
| 6634 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 6635 |
(ashift:GPI (ANY_EXTEND:GPI |
| 6636 |
(match_operand:ALLX 1 "register_operand" "r")) |
| 6637 |
(match_operand 2 "const_int_operand" "n")))] |
| 6638 |
"UINTVAL (operands[2]) < <GPI:sizen>" |
| 6639 |
{ |
| 6640 |
operands[3] = (<ALLX:sizen> <= (<GPI:sizen> - UINTVAL (operands[2]))) |
| 6641 |
? GEN_INT (<ALLX:sizen>) |
| 6642 |
: GEN_INT (<GPI:sizen> - UINTVAL (operands[2])); |
| 6643 |
return "<su>bfiz\t%<GPI:w>0, %<GPI:w>1, %2, %3"; |
| 6644 |
} |
| 6645 |
[(set_attr "type" "bfx")] |
| 6646 |
) |
| 6647 |
|
| 6648 |
;; XXX We should match (any_extend (ashift)) here, like (and (ashift)) below |
| 6649 |
|
| 6650 |
(define_insn "*andim_ashift<mode>_bfiz" |
| 6651 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 6652 |
(and:GPI (ashift:GPI (match_operand:GPI 1 "register_operand" "r") |
| 6653 |
(match_operand 2 "const_int_operand" "n")) |
| 6654 |
(match_operand 3 "const_int_operand" "n")))] |
| 6655 |
"aarch64_mask_and_shift_for_ubfiz_p (<MODE>mode, operands[3], operands[2])" |
| 6656 |
"ubfiz\\t%<w>0, %<w>1, %2, %P3" |
| 6657 |
[(set_attr "type" "bfx")] |
| 6658 |
) |
| 6659 |
|
| 6660 |
;; Match sbfiz pattern in a shift left + shift right operation. |
| 6661 |
|
| 6662 |
(define_insn "*ashift<mode>_extv_bfiz" |
| 6663 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 6664 |
(ashift:GPI (sign_extract:GPI (match_operand:GPI 1 "register_operand" "r") |
| 6665 |
(match_operand 2 "aarch64_simd_shift_imm_offset_<mode>" "n") |
| 6666 |
(const_int 0)) |
| 6667 |
(match_operand 3 "aarch64_simd_shift_imm_<mode>" "n")))] |
| 6668 |
"IN_RANGE (INTVAL (operands[2]) + INTVAL (operands[3]), |
| 6669 |
1, GET_MODE_BITSIZE (<MODE>mode) - 1)" |
| 6670 |
"sbfiz\\t%<w>0, %<w>1, %3, %2" |
| 6671 |
[(set_attr "type" "bfx")] |
| 6672 |
) |
| 6673 |
|
| 6674 |
(define_insn "*ashiftsi_extvdi_bfiz" |
| 6675 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 6676 |
(ashift:SI |
| 6677 |
(match_operator:SI 4 "subreg_lowpart_operator" |
| 6678 |
[(sign_extract:DI |
| 6679 |
(match_operand:DI 1 "register_operand" "r") |
| 6680 |
(match_operand 2 "aarch64_simd_shift_imm_offset_si") |
| 6681 |
(const_int 0))]) |
| 6682 |
(match_operand 3 "aarch64_simd_shift_imm_si")))] |
| 6683 |
"IN_RANGE (INTVAL (operands[2]) + INTVAL (operands[3]), |
| 6684 |
1, GET_MODE_BITSIZE (SImode) - 1)" |
| 6685 |
"sbfiz\\t%w0, %w1, %3, %2" |
| 6686 |
[(set_attr "type" "bfx")] |
| 6687 |
) |
| 6688 |
|
| 6689 |
;; When the bit position and width of the equivalent extraction add up to 32 |
| 6690 |
;; we can use a W-reg LSL instruction taking advantage of the implicit |
| 6691 |
;; zero-extension of the X-reg. |
| 6692 |
(define_split |
| 6693 |
[(set (match_operand:DI 0 "register_operand") |
| 6694 |
(and:DI (ashift:DI (match_operand:DI 1 "register_operand") |
| 6695 |
(match_operand 2 "const_int_operand")) |
| 6696 |
(match_operand 3 "const_int_operand")))] |
| 6697 |
"aarch64_mask_and_shift_for_ubfiz_p (DImode, operands[3], operands[2]) |
| 6698 |
&& (INTVAL (operands[2]) + popcount_hwi (INTVAL (operands[3]))) |
| 6699 |
== GET_MODE_BITSIZE (SImode)" |
| 6700 |
[(set (match_dup 0) |
| 6701 |
(zero_extend:DI (ashift:SI (match_dup 4) (match_dup 2))))] |
| 6702 |
{ |
| 6703 |
operands[4] = gen_lowpart (SImode, operands[1]); |
| 6704 |
} |
| 6705 |
) |
| 6706 |
|
| 6707 |
(define_insn "bswap<mode>2" |
| 6708 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 6709 |
(bswap:GPI (match_operand:GPI 1 "register_operand" "r")))] |
| 6710 |
"" |
| 6711 |
"rev\\t%<w>0, %<w>1" |
| 6712 |
[(set_attr "type" "rev")] |
| 6713 |
) |
| 6714 |
|
| 6715 |
(define_insn "bswaphi2" |
| 6716 |
[(set (match_operand:HI 0 "register_operand" "=r") |
| 6717 |
(bswap:HI (match_operand:HI 1 "register_operand" "r")))] |
| 6718 |
"" |
| 6719 |
"rev16\\t%w0, %w1" |
| 6720 |
[(set_attr "type" "rev")] |
| 6721 |
) |
| 6722 |
|
| 6723 |
(define_insn "*aarch64_bfxil<mode>" |
| 6724 |
[(set (match_operand:GPI 0 "register_operand" "=r,r") |
| 6725 |
(ior:GPI (and:GPI (match_operand:GPI 1 "register_operand" "r,0") |
| 6726 |
(match_operand:GPI 3 "const_int_operand" "n, Ulc")) |
| 6727 |
(and:GPI (match_operand:GPI 2 "register_operand" "0,r") |
| 6728 |
(match_operand:GPI 4 "const_int_operand" "Ulc, n"))))] |
| 6729 |
"(INTVAL (operands[3]) == ~INTVAL (operands[4])) |
| 6730 |
&& (aarch64_high_bits_all_ones_p (INTVAL (operands[3])) |
| 6731 |
|| aarch64_high_bits_all_ones_p (INTVAL (operands[4])))" |
| 6732 |
{ |
| 6733 |
switch (which_alternative) |
| 6734 |
{ |
| 6735 |
case 0: |
| 6736 |
operands[3] = GEN_INT (ctz_hwi (~INTVAL (operands[3]))); |
| 6737 |
return "bfxil\\t%<w>0, %<w>1, 0, %3"; |
| 6738 |
case 1: |
| 6739 |
operands[3] = GEN_INT (ctz_hwi (~INTVAL (operands[4]))); |
| 6740 |
return "bfxil\\t%<w>0, %<w>2, 0, %3"; |
| 6741 |
default: |
| 6742 |
gcc_unreachable (); |
| 6743 |
} |
| 6744 |
} |
| 6745 |
[(set_attr "type" "bfm")] |
| 6746 |
) |
| 6747 |
|
| 6748 |
; Zero-extended version of above (aarch64_bfxil) |
| 6749 |
(define_insn "*aarch64_bfxilsi_uxtw" |
| 6750 |
[(set (match_operand:DI 0 "register_operand" "=r,r") |
| 6751 |
(zero_extend:DI (ior:SI (and:SI (match_operand:SI 1 "register_operand" |
| 6752 |
"r,0") |
| 6753 |
(match_operand:SI 3 "const_int_operand" "n, Ulc")) |
| 6754 |
(and:SI (match_operand:SI 2 "register_operand" "0,r") |
| 6755 |
(match_operand:SI 4 "const_int_operand" "Ulc, n")))))] |
| 6756 |
"(INTVAL (operands[3]) == ~INTVAL (operands[4])) |
| 6757 |
&& (aarch64_high_bits_all_ones_p (INTVAL (operands[3])) |
| 6758 |
|| aarch64_high_bits_all_ones_p (INTVAL (operands[4])))" |
| 6759 |
{ |
| 6760 |
switch (which_alternative) |
| 6761 |
{ |
| 6762 |
case 0: |
| 6763 |
operands[3] = GEN_INT (ctz_hwi (~INTVAL (operands[3]))); |
| 6764 |
return "bfxil\\t%w0, %w1, 0, %3"; |
| 6765 |
case 1: |
| 6766 |
operands[3] = GEN_INT (ctz_hwi (~INTVAL (operands[4]))); |
| 6767 |
return "bfxil\\t%w0, %w2, 0, %3"; |
| 6768 |
default: |
| 6769 |
gcc_unreachable (); |
| 6770 |
} |
| 6771 |
} |
| 6772 |
[(set_attr "type" "bfm")] |
| 6773 |
) |
| 6774 |
|
| 6775 |
;; There are no canonicalisation rules for the position of the lshiftrt, ashift |
| 6776 |
;; operations within an IOR/AND RTX, therefore we have two patterns matching |
| 6777 |
;; each valid permutation. |
| 6778 |
|
| 6779 |
(define_insn "aarch64_rev16<mode>2_alt1" |
| 6780 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 6781 |
(ior:GPI (and:GPI (ashift:GPI (match_operand:GPI 1 "register_operand" "r") |
| 6782 |
(const_int 8)) |
| 6783 |
(match_operand:GPI 3 "const_int_operand" "n")) |
| 6784 |
(and:GPI (lshiftrt:GPI (match_dup 1) |
| 6785 |
(const_int 8)) |
| 6786 |
(match_operand:GPI 2 "const_int_operand" "n"))))] |
| 6787 |
"aarch_rev16_shleft_mask_imm_p (operands[3], <MODE>mode) |
| 6788 |
&& aarch_rev16_shright_mask_imm_p (operands[2], <MODE>mode)" |
| 6789 |
"rev16\\t%<w>0, %<w>1" |
| 6790 |
[(set_attr "type" "rev")] |
| 6791 |
) |
| 6792 |
|
| 6793 |
(define_insn "*aarch64_rev16<mode>2_alt2" |
| 6794 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 6795 |
(ior:GPI (and:GPI (lshiftrt:GPI (match_operand:GPI 1 "register_operand" "r") |
| 6796 |
(const_int 8)) |
| 6797 |
(match_operand:GPI 2 "const_int_operand" "n")) |
| 6798 |
(and:GPI (ashift:GPI (match_dup 1) |
| 6799 |
(const_int 8)) |
| 6800 |
(match_operand:GPI 3 "const_int_operand" "n"))))] |
| 6801 |
"aarch_rev16_shleft_mask_imm_p (operands[3], <MODE>mode) |
| 6802 |
&& aarch_rev16_shright_mask_imm_p (operands[2], <MODE>mode)" |
| 6803 |
"rev16\\t%<w>0, %<w>1" |
| 6804 |
[(set_attr "type" "rev")] |
| 6805 |
) |
| 6806 |
|
| 6807 |
;; Similar pattern to match (rotate (bswap) 16) |
| 6808 |
(define_insn "aarch64_rev16si2_alt3" |
| 6809 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 6810 |
(rotate:SI (bswap:SI (match_operand:SI 1 "register_operand" "r")) |
| 6811 |
(const_int 16)))] |
| 6812 |
"" |
| 6813 |
"rev16\\t%w0, %w1" |
| 6814 |
[(set_attr "type" "rev")] |
| 6815 |
) |
| 6816 |
|
| 6817 |
;; zero_extend version of above |
| 6818 |
(define_insn "*bswapsi2_uxtw" |
| 6819 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 6820 |
(zero_extend:DI (bswap:SI (match_operand:SI 1 "register_operand" "r"))))] |
| 6821 |
"" |
| 6822 |
"rev\\t%w0, %w1" |
| 6823 |
[(set_attr "type" "rev")] |
| 6824 |
) |
| 6825 |
|
| 6826 |
;; Expander for __rev16 intrinsics. We have organic RTL patterns for rev16 above. |
| 6827 |
;; Use this expander to just create the shift constants needed. |
| 6828 |
(define_expand "@aarch64_rev16<mode>" |
| 6829 |
[(match_operand:GPI 0 "register_operand") |
| 6830 |
(match_operand:GPI 1 "register_operand")] |
| 6831 |
"" |
| 6832 |
{ |
| 6833 |
rtx left = gen_int_mode (HOST_WIDE_INT_C (0xff00ff00ff00ff00), <MODE>mode); |
| 6834 |
rtx right = gen_int_mode (HOST_WIDE_INT_C (0xff00ff00ff00ff), <MODE>mode); |
| 6835 |
emit_insn (gen_aarch64_rev16<mode>2_alt1 (operands[0], operands[1], |
| 6836 |
right, left)); |
| 6837 |
DONE; |
| 6838 |
} |
| 6839 |
) |
| 6840 |
|
| 6841 |
;; ------------------------------------------------------------------- |
| 6842 |
;; Floating-point intrinsics |
| 6843 |
;; ------------------------------------------------------------------- |
| 6844 |
|
| 6845 |
;; frint floating-point round to integral standard patterns. |
| 6846 |
;; Expands to btrunc, ceil, floor, nearbyint, rint, round, roundeven. |
| 6847 |
|
| 6848 |
(define_insn "<frint_pattern><mode>2" |
| 6849 |
[(set (match_operand:GPF_F16 0 "register_operand" "=w") |
| 6850 |
(unspec:GPF_F16 [(match_operand:GPF_F16 1 "register_operand" "w")] |
| 6851 |
FRINT))] |
| 6852 |
"TARGET_FLOAT" |
| 6853 |
"frint<frint_suffix>\\t%<s>0, %<s>1" |
| 6854 |
[(set_attr "type" "f_rint<stype>")] |
| 6855 |
) |
| 6856 |
|
| 6857 |
;; frcvt floating-point round to integer and convert standard patterns. |
| 6858 |
;; Expands to lbtrunc, lceil, lfloor, lround. |
| 6859 |
(define_insn "l<fcvt_pattern><su_optab><GPF_F16:mode><GPI:mode>2" |
| 6860 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 6861 |
(FIXUORS:GPI |
| 6862 |
(unspec:GPF_F16 [(match_operand:GPF_F16 1 "register_operand" "w")] |
| 6863 |
FCVT)))] |
| 6864 |
"TARGET_FLOAT" |
| 6865 |
"fcvt<frint_suffix><su>\\t%<GPI:w>0, %<GPF_F16:s>1" |
| 6866 |
[(set_attr "type" "f_cvtf2i")] |
| 6867 |
) |
| 6868 |
|
| 6869 |
(define_insn "*aarch64_fcvt<su_optab><GPF:mode><GPI:mode>2_mult" |
| 6870 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 6871 |
(FIXUORS:GPI |
| 6872 |
(mult:GPF |
| 6873 |
(match_operand:GPF 1 "register_operand" "w") |
| 6874 |
(match_operand:GPF 2 "aarch64_fp_pow2" "F"))))] |
| 6875 |
"TARGET_FLOAT |
| 6876 |
&& IN_RANGE (aarch64_fpconst_pow_of_2 (operands[2]), 1, |
| 6877 |
GET_MODE_BITSIZE (<GPI:MODE>mode))" |
| 6878 |
{ |
| 6879 |
int fbits = aarch64_fpconst_pow_of_2 (operands[2]); |
| 6880 |
char buf[64]; |
| 6881 |
snprintf (buf, 64, "fcvtz<su>\\t%%<GPI:w>0, %%<GPF:s>1, #%d", fbits); |
| 6882 |
output_asm_insn (buf, operands); |
| 6883 |
return ""; |
| 6884 |
} |
| 6885 |
[(set_attr "type" "f_cvtf2i")] |
| 6886 |
) |
| 6887 |
|
| 6888 |
;; fma - expand fma into patterns with the accumulator operand first since |
| 6889 |
;; reusing the accumulator results in better register allocation. |
| 6890 |
;; The register allocator considers copy preferences in operand order, |
| 6891 |
;; so this prefers fmadd s0, s1, s2, s0 over fmadd s1, s1, s2, s0. |
| 6892 |
|
| 6893 |
(define_expand "fma<mode>4" |
| 6894 |
[(set (match_operand:GPF_F16 0 "register_operand") |
| 6895 |
(fma:GPF_F16 (match_operand:GPF_F16 1 "register_operand") |
| 6896 |
(match_operand:GPF_F16 2 "register_operand") |
| 6897 |
(match_operand:GPF_F16 3 "register_operand")))] |
| 6898 |
"TARGET_FLOAT" |
| 6899 |
) |
| 6900 |
|
| 6901 |
(define_insn "*aarch64_fma<mode>4" |
| 6902 |
[(set (match_operand:GPF_F16 0 "register_operand" "=w") |
| 6903 |
(fma:GPF_F16 (match_operand:GPF_F16 2 "register_operand" "w") |
| 6904 |
(match_operand:GPF_F16 3 "register_operand" "w") |
| 6905 |
(match_operand:GPF_F16 1 "register_operand" "w")))] |
| 6906 |
"TARGET_FLOAT" |
| 6907 |
"fmadd\\t%<s>0, %<s>2, %<s>3, %<s>1" |
| 6908 |
[(set_attr "type" "fmac<stype>")] |
| 6909 |
) |
| 6910 |
|
| 6911 |
(define_expand "fnma<mode>4" |
| 6912 |
[(set (match_operand:GPF_F16 0 "register_operand") |
| 6913 |
(fma:GPF_F16 |
| 6914 |
(neg:GPF_F16 (match_operand:GPF_F16 1 "register_operand")) |
| 6915 |
(match_operand:GPF_F16 2 "register_operand") |
| 6916 |
(match_operand:GPF_F16 3 "register_operand")))] |
| 6917 |
"TARGET_FLOAT" |
| 6918 |
) |
| 6919 |
|
| 6920 |
(define_insn "*aarch64_fnma<mode>4" |
| 6921 |
[(set (match_operand:GPF_F16 0 "register_operand" "=w") |
| 6922 |
(fma:GPF_F16 |
| 6923 |
(neg:GPF_F16 (match_operand:GPF_F16 2 "register_operand" "w")) |
| 6924 |
(match_operand:GPF_F16 3 "register_operand" "w") |
| 6925 |
(match_operand:GPF_F16 1 "register_operand" "w")))] |
| 6926 |
"TARGET_FLOAT" |
| 6927 |
"fmsub\\t%<s>0, %<s>2, %<s>3, %<s>1" |
| 6928 |
[(set_attr "type" "fmac<stype>")] |
| 6929 |
) |
| 6930 |
|
| 6931 |
|
| 6932 |
(define_expand "fms<mode>4" |
| 6933 |
[(set (match_operand:GPF 0 "register_operand") |
| 6934 |
(fma:GPF (match_operand:GPF 1 "register_operand") |
| 6935 |
(match_operand:GPF 2 "register_operand") |
| 6936 |
(neg:GPF (match_operand:GPF 3 "register_operand"))))] |
| 6937 |
"TARGET_FLOAT" |
| 6938 |
) |
| 6939 |
|
| 6940 |
(define_insn "*aarch64_fms<mode>4" |
| 6941 |
[(set (match_operand:GPF 0 "register_operand" "=w") |
| 6942 |
(fma:GPF (match_operand:GPF 2 "register_operand" "w") |
| 6943 |
(match_operand:GPF 3 "register_operand" "w") |
| 6944 |
(neg:GPF (match_operand:GPF 1 "register_operand" "w"))))] |
| 6945 |
"TARGET_FLOAT" |
| 6946 |
"fnmsub\\t%<s>0, %<s>2, %<s>3, %<s>1" |
| 6947 |
[(set_attr "type" "fmac<s>")] |
| 6948 |
) |
| 6949 |
|
| 6950 |
(define_expand "fnms<mode>4" |
| 6951 |
[(set (match_operand:GPF 0 "register_operand") |
| 6952 |
(fma:GPF (neg:GPF (match_operand:GPF 1 "register_operand")) |
| 6953 |
(match_operand:GPF 2 "register_operand") |
| 6954 |
(neg:GPF (match_operand:GPF 3 "register_operand"))))] |
| 6955 |
"TARGET_FLOAT" |
| 6956 |
) |
| 6957 |
|
| 6958 |
(define_insn "*aarch64_fnms<mode>4" |
| 6959 |
[(set (match_operand:GPF 0 "register_operand" "=w") |
| 6960 |
(fma:GPF (neg:GPF (match_operand:GPF 2 "register_operand" "w")) |
| 6961 |
(match_operand:GPF 3 "register_operand" "w") |
| 6962 |
(neg:GPF (match_operand:GPF 1 "register_operand" "w"))))] |
| 6963 |
"TARGET_FLOAT" |
| 6964 |
"fnmadd\\t%<s>0, %<s>2, %<s>3, %<s>1" |
| 6965 |
[(set_attr "type" "fmac<s>")] |
| 6966 |
) |
| 6967 |
|
| 6968 |
;; If signed zeros are ignored, -(a * b + c) = -a * b - c. |
| 6969 |
(define_insn "*aarch64_fnmadd<mode>4" |
| 6970 |
[(set (match_operand:GPF 0 "register_operand" "=w") |
| 6971 |
(neg:GPF (fma:GPF (match_operand:GPF 2 "register_operand" "w") |
| 6972 |
(match_operand:GPF 3 "register_operand" "w") |
| 6973 |
(match_operand:GPF 1 "register_operand" "w"))))] |
| 6974 |
"!HONOR_SIGNED_ZEROS (<MODE>mode) && TARGET_FLOAT" |
| 6975 |
"fnmadd\\t%<s>0, %<s>2, %<s>3, %<s>1" |
| 6976 |
[(set_attr "type" "fmac<s>")] |
| 6977 |
) |
| 6978 |
|
| 6979 |
;; ------------------------------------------------------------------- |
| 6980 |
;; Floating-point conversions |
| 6981 |
;; ------------------------------------------------------------------- |
| 6982 |
|
| 6983 |
(define_insn "extendsfdf2" |
| 6984 |
[(set (match_operand:DF 0 "register_operand" "=w") |
| 6985 |
(float_extend:DF (match_operand:SF 1 "register_operand" "w")))] |
| 6986 |
"TARGET_FLOAT" |
| 6987 |
"fcvt\\t%d0, %s1" |
| 6988 |
[(set_attr "type" "f_cvt")] |
| 6989 |
) |
| 6990 |
|
| 6991 |
(define_insn "extendhfsf2" |
| 6992 |
[(set (match_operand:SF 0 "register_operand" "=w") |
| 6993 |
(float_extend:SF (match_operand:HF 1 "register_operand" "w")))] |
| 6994 |
"TARGET_FLOAT" |
| 6995 |
"fcvt\\t%s0, %h1" |
| 6996 |
[(set_attr "type" "f_cvt")] |
| 6997 |
) |
| 6998 |
|
| 6999 |
(define_insn "extendhfdf2" |
| 7000 |
[(set (match_operand:DF 0 "register_operand" "=w") |
| 7001 |
(float_extend:DF (match_operand:HF 1 "register_operand" "w")))] |
| 7002 |
"TARGET_FLOAT" |
| 7003 |
"fcvt\\t%d0, %h1" |
| 7004 |
[(set_attr "type" "f_cvt")] |
| 7005 |
) |
| 7006 |
|
| 7007 |
(define_insn "truncdfsf2" |
| 7008 |
[(set (match_operand:SF 0 "register_operand" "=w") |
| 7009 |
(float_truncate:SF (match_operand:DF 1 "register_operand" "w")))] |
| 7010 |
"TARGET_FLOAT" |
| 7011 |
"fcvt\\t%s0, %d1" |
| 7012 |
[(set_attr "type" "f_cvt")] |
| 7013 |
) |
| 7014 |
|
| 7015 |
(define_insn "truncsfhf2" |
| 7016 |
[(set (match_operand:HF 0 "register_operand" "=w") |
| 7017 |
(float_truncate:HF (match_operand:SF 1 "register_operand" "w")))] |
| 7018 |
"TARGET_FLOAT" |
| 7019 |
"fcvt\\t%h0, %s1" |
| 7020 |
[(set_attr "type" "f_cvt")] |
| 7021 |
) |
| 7022 |
|
| 7023 |
(define_insn "truncdfhf2" |
| 7024 |
[(set (match_operand:HF 0 "register_operand" "=w") |
| 7025 |
(float_truncate:HF (match_operand:DF 1 "register_operand" "w")))] |
| 7026 |
"TARGET_FLOAT" |
| 7027 |
"fcvt\\t%h0, %d1" |
| 7028 |
[(set_attr "type" "f_cvt")] |
| 7029 |
) |
| 7030 |
|
| 7031 |
;; Convert SF -> SI or DF -> DI while preferring w = w register constraints |
| 7032 |
;; and making r = w more expensive |
| 7033 |
|
| 7034 |
(define_insn "<optab>_trunc<fcvt_target><GPI:mode>2" |
| 7035 |
[(set (match_operand:GPI 0 "register_operand") |
| 7036 |
(FIXUORS:GPI (match_operand:<FCVT_TARGET> 1 "register_operand")))] |
| 7037 |
"TARGET_FLOAT" |
| 7038 |
{@ [ cons: =0 , 1 ; attrs: type , arch ] |
| 7039 |
[ w , w ; neon_fp_to_int_s , simd ] fcvtz<su>\t%<s>0, %<s>1 |
| 7040 |
[ ?r , w ; f_cvtf2i , fp ] fcvtz<su>\t%<w>0, %<s>1 |
| 7041 |
} |
| 7042 |
) |
| 7043 |
|
| 7044 |
;; Convert HF -> SI or DI |
| 7045 |
|
| 7046 |
(define_insn "<optab>_trunchf<GPI:mode>2" |
| 7047 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 7048 |
(FIXUORS:GPI (match_operand:HF 1 "register_operand" "w")))] |
| 7049 |
"TARGET_FP_F16INST" |
| 7050 |
"fcvtz<su>\t%<w>0, %h1" |
| 7051 |
[(set_attr "type" "f_cvtf2i")] |
| 7052 |
) |
| 7053 |
|
| 7054 |
;; Convert DF -> SI or SF -> DI which can only be accomplished with |
| 7055 |
;; input in a fp register and output in a integer register |
| 7056 |
|
| 7057 |
(define_insn "<optab>_trunc<fcvt_change_mode><GPI:mode>2" |
| 7058 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 7059 |
(FIXUORS:GPI (match_operand:<FCVT_CHANGE_MODE> 1 "register_operand" "w")))] |
| 7060 |
"TARGET_FLOAT" |
| 7061 |
"fcvtz<su>\t%<w>0, %<fpw>1" |
| 7062 |
[(set_attr "type" "f_cvtf2i")] |
| 7063 |
) |
| 7064 |
|
| 7065 |
(define_insn "*fix_to_zero_extend<mode>di2" |
| 7066 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 7067 |
(zero_extend:DI |
| 7068 |
(unsigned_fix:SI |
| 7069 |
(match_operand:GPF 1 "register_operand" "w"))))] |
| 7070 |
"TARGET_FLOAT" |
| 7071 |
"fcvtzu\t%w0, %<s>1" |
| 7072 |
[(set_attr "type" "f_cvtf2i")] |
| 7073 |
) |
| 7074 |
|
| 7075 |
;; Equal width integer to fp and multiply combine. |
| 7076 |
(define_insn "*aarch64_<su_optab>cvtf<fcvt_target><GPF:mode>2_mult" |
| 7077 |
[(set (match_operand:GPF 0 "register_operand" "=w,w") |
| 7078 |
(mult:GPF (FLOATUORS:GPF |
| 7079 |
(match_operand:<FCVT_TARGET> 1 "register_operand" "w,?r")) |
| 7080 |
(match_operand:GPF 2 "aarch64_fp_pow2_recip" "Dt,Dt")))] |
| 7081 |
"TARGET_FLOAT" |
| 7082 |
{ |
| 7083 |
operands[2] = GEN_INT (aarch64_fpconst_pow2_recip (operands[2])); |
| 7084 |
switch (which_alternative) |
| 7085 |
{ |
| 7086 |
case 0: |
| 7087 |
return "<su_optab>cvtf\t%<GPF:s>0, %<s>1, #%2"; |
| 7088 |
case 1: |
| 7089 |
return "<su_optab>cvtf\t%<GPF:s>0, %<w1>1, #%2"; |
| 7090 |
default: |
| 7091 |
gcc_unreachable (); |
| 7092 |
} |
| 7093 |
} |
| 7094 |
[(set_attr "type" "neon_int_to_fp_<Vetype>,f_cvti2f") |
| 7095 |
(set_attr "arch" "simd,fp")] |
| 7096 |
) |
| 7097 |
|
| 7098 |
;; Unequal width integer to fp and multiply combine. |
| 7099 |
(define_insn "*aarch64_<su_optab>cvtf<fcvt_iesize><GPF:mode>2_mult" |
| 7100 |
[(set (match_operand:GPF 0 "register_operand" "=w") |
| 7101 |
(mult:GPF (FLOATUORS:GPF |
| 7102 |
(match_operand:<FCVT_IESIZE> 1 "register_operand" "r")) |
| 7103 |
(match_operand:GPF 2 "aarch64_fp_pow2_recip" "Dt")))] |
| 7104 |
"TARGET_FLOAT" |
| 7105 |
{ |
| 7106 |
operands[2] = GEN_INT (aarch64_fpconst_pow2_recip (operands[2])); |
| 7107 |
return "<su_optab>cvtf\t%<GPF:s>0, %<w2>1, #%2"; |
| 7108 |
} |
| 7109 |
[(set_attr "type" "f_cvti2f")] |
| 7110 |
) |
| 7111 |
|
| 7112 |
;; Equal width integer to fp conversion. |
| 7113 |
(define_insn "<optab><fcvt_target><GPF:mode>2" |
| 7114 |
[(set (match_operand:GPF 0 "register_operand") |
| 7115 |
(FLOATUORS:GPF (match_operand:<FCVT_TARGET> 1 "register_operand")))] |
| 7116 |
"TARGET_FLOAT" |
| 7117 |
{@ [ cons: =0 , 1 ; attrs: type , arch ] |
| 7118 |
[ w , w ; neon_int_to_fp_<Vetype> , simd ] <su_optab>cvtf\t%<GPF:s>0, %<s>1 |
| 7119 |
[ w , ?r ; f_cvti2f , fp ] <su_optab>cvtf\t%<GPF:s>0, %<w1>1 |
| 7120 |
} |
| 7121 |
) |
| 7122 |
|
| 7123 |
;; Unequal width integer to fp conversions. |
| 7124 |
(define_insn "<optab><fcvt_iesize><GPF:mode>2" |
| 7125 |
[(set (match_operand:GPF 0 "register_operand" "=w") |
| 7126 |
(FLOATUORS:GPF (match_operand:<FCVT_IESIZE> 1 "register_operand" "r")))] |
| 7127 |
"TARGET_FLOAT" |
| 7128 |
"<su_optab>cvtf\t%<GPF:s>0, %<w2>1" |
| 7129 |
[(set_attr "type" "f_cvti2f")] |
| 7130 |
) |
| 7131 |
|
| 7132 |
;; If we do not have ARMv8.2-A 16-bit floating point extensions, the |
| 7133 |
;; midend will arrange for an SImode conversion to HFmode to first go |
| 7134 |
;; through DFmode, then to HFmode. But first it will try converting |
| 7135 |
;; to DImode then down, which would match our DImode pattern below and |
| 7136 |
;; give very poor code-generation. So, we must provide our own emulation |
| 7137 |
;; of the mid-end logic. |
| 7138 |
|
| 7139 |
(define_insn "aarch64_fp16_<optab><mode>hf2" |
| 7140 |
[(set (match_operand:HF 0 "register_operand" "=w") |
| 7141 |
(FLOATUORS:HF (match_operand:GPI 1 "register_operand" "r")))] |
| 7142 |
"TARGET_FP_F16INST" |
| 7143 |
"<su_optab>cvtf\t%h0, %<w>1" |
| 7144 |
[(set_attr "type" "f_cvti2f")] |
| 7145 |
) |
| 7146 |
|
| 7147 |
(define_expand "<optab>sihf2" |
| 7148 |
[(set (match_operand:HF 0 "register_operand") |
| 7149 |
(FLOATUORS:HF (match_operand:SI 1 "register_operand")))] |
| 7150 |
"TARGET_FLOAT" |
| 7151 |
{ |
| 7152 |
if (TARGET_FP_F16INST) |
| 7153 |
emit_insn (gen_aarch64_fp16_<optab>sihf2 (operands[0], operands[1])); |
| 7154 |
else |
| 7155 |
{ |
| 7156 |
rtx convert_target = gen_reg_rtx (DFmode); |
| 7157 |
emit_insn (gen_<optab>sidf2 (convert_target, operands[1])); |
| 7158 |
emit_insn (gen_truncdfhf2 (operands[0], convert_target)); |
| 7159 |
} |
| 7160 |
DONE; |
| 7161 |
} |
| 7162 |
) |
| 7163 |
|
| 7164 |
;; For DImode there is no wide enough floating-point mode that we |
| 7165 |
;; can convert through natively (TFmode would work, but requires a library |
| 7166 |
;; call). However, we know that any value >= 65504 will be rounded |
| 7167 |
;; to infinity on conversion. This is well within the range of SImode, so |
| 7168 |
;; we can: |
| 7169 |
;; Saturate to SImode. |
| 7170 |
;; Convert from that to DFmode |
| 7171 |
;; Convert from that to HFmode (phew!). |
| 7172 |
;; Note that the saturation to SImode requires the SIMD extensions. If |
| 7173 |
;; we ever need to provide this pattern where the SIMD extensions are not |
| 7174 |
;; available, we would need a different approach. |
| 7175 |
|
| 7176 |
(define_expand "<optab>dihf2" |
| 7177 |
[(set (match_operand:HF 0 "register_operand") |
| 7178 |
(FLOATUORS:HF (match_operand:DI 1 "register_operand")))] |
| 7179 |
"TARGET_FP_F16INST || TARGET_SIMD" |
| 7180 |
{ |
| 7181 |
if (TARGET_FP_F16INST) |
| 7182 |
emit_insn (gen_aarch64_fp16_<optab>dihf2 (operands[0], operands[1])); |
| 7183 |
else |
| 7184 |
{ |
| 7185 |
rtx sat_target = gen_reg_rtx (SImode); |
| 7186 |
emit_insn (gen_aarch64_<su_optab>qmovndi (sat_target, operands[1])); |
| 7187 |
emit_insn (gen_<optab>sihf2 (operands[0], sat_target)); |
| 7188 |
} |
| 7189 |
|
| 7190 |
DONE; |
| 7191 |
} |
| 7192 |
) |
| 7193 |
|
| 7194 |
;; Convert between fixed-point and floating-point (scalar modes) |
| 7195 |
|
| 7196 |
(define_insn "<FCVT_F2FIXED:fcvt_fixed_insn><GPF:mode>3" |
| 7197 |
[(set (match_operand:<GPF:FCVT_TARGET> 0 "register_operand") |
| 7198 |
(unspec:<GPF:FCVT_TARGET> [(match_operand:GPF 1 "register_operand") |
| 7199 |
(match_operand:SI 2 "immediate_operand")] |
| 7200 |
FCVT_F2FIXED))] |
| 7201 |
"" |
| 7202 |
{@ [ cons: =0 , 1 , 2 ; attrs: type , arch ] |
| 7203 |
[ r , w , i ; f_cvtf2i , fp ] <FCVT_F2FIXED:fcvt_fixed_insn>\t%<GPF:w1>0, %<GPF:s>1, #%2 |
| 7204 |
[ w , w , i ; neon_fp_to_int_<GPF:Vetype> , simd ] <FCVT_F2FIXED:fcvt_fixed_insn>\t%<GPF:s>0, %<GPF:s>1, #%2 |
| 7205 |
} |
| 7206 |
) |
| 7207 |
|
| 7208 |
(define_insn "<FCVT_FIXED2F:fcvt_fixed_insn><GPI:mode>3" |
| 7209 |
[(set (match_operand:<GPI:FCVT_TARGET> 0 "register_operand") |
| 7210 |
(unspec:<GPI:FCVT_TARGET> [(match_operand:GPI 1 "register_operand") |
| 7211 |
(match_operand:SI 2 "immediate_operand")] |
| 7212 |
FCVT_FIXED2F))] |
| 7213 |
"" |
| 7214 |
{@ [ cons: =0 , 1 , 2 ; attrs: type , arch ] |
| 7215 |
[ w , r , i ; f_cvti2f , fp ] <FCVT_FIXED2F:fcvt_fixed_insn>\t%<GPI:v>0, %<GPI:w>1, #%2 |
| 7216 |
[ w , w , i ; neon_int_to_fp_<GPI:Vetype> , simd ] <FCVT_FIXED2F:fcvt_fixed_insn>\t%<GPI:v>0, %<GPI:v>1, #%2 |
| 7217 |
} |
| 7218 |
) |
| 7219 |
|
| 7220 |
(define_insn "<FCVT_F2FIXED:fcvt_fixed_insn>hf<mode>3" |
| 7221 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 7222 |
(unspec:GPI [(match_operand:HF 1 "register_operand" "w") |
| 7223 |
(match_operand:SI 2 "immediate_operand" "i")] |
| 7224 |
FCVT_F2FIXED))] |
| 7225 |
"TARGET_FP_F16INST" |
| 7226 |
"<FCVT_F2FIXED:fcvt_fixed_insn>\t%<GPI:w>0, %h1, #%2" |
| 7227 |
[(set_attr "type" "f_cvtf2i")] |
| 7228 |
) |
| 7229 |
|
| 7230 |
(define_insn "<FCVT_FIXED2F:fcvt_fixed_insn><mode>hf3" |
| 7231 |
[(set (match_operand:HF 0 "register_operand" "=w") |
| 7232 |
(unspec:HF [(match_operand:GPI 1 "register_operand" "r") |
| 7233 |
(match_operand:SI 2 "immediate_operand" "i")] |
| 7234 |
FCVT_FIXED2F))] |
| 7235 |
"TARGET_FP_F16INST" |
| 7236 |
"<FCVT_FIXED2F:fcvt_fixed_insn>\t%h0, %<GPI:w>1, #%2" |
| 7237 |
[(set_attr "type" "f_cvti2f")] |
| 7238 |
) |
| 7239 |
|
| 7240 |
(define_insn "<FCVT_F2FIXED:fcvt_fixed_insn>hf3" |
| 7241 |
[(set (match_operand:HI 0 "register_operand" "=w") |
| 7242 |
(unspec:HI [(match_operand:HF 1 "register_operand" "w") |
| 7243 |
(match_operand:SI 2 "immediate_operand" "i")] |
| 7244 |
FCVT_F2FIXED))] |
| 7245 |
"TARGET_SIMD" |
| 7246 |
"<FCVT_F2FIXED:fcvt_fixed_insn>\t%h0, %h1, #%2" |
| 7247 |
[(set_attr "type" "neon_fp_to_int_s")] |
| 7248 |
) |
| 7249 |
|
| 7250 |
(define_insn "<FCVT_FIXED2F:fcvt_fixed_insn>hi3" |
| 7251 |
[(set (match_operand:HF 0 "register_operand" "=w") |
| 7252 |
(unspec:HF [(match_operand:HI 1 "register_operand" "w") |
| 7253 |
(match_operand:SI 2 "immediate_operand" "i")] |
| 7254 |
FCVT_FIXED2F))] |
| 7255 |
"TARGET_SIMD" |
| 7256 |
"<FCVT_FIXED2F:fcvt_fixed_insn>\t%h0, %h1, #%2" |
| 7257 |
[(set_attr "type" "neon_int_to_fp_s")] |
| 7258 |
) |
| 7259 |
|
| 7260 |
;; ------------------------------------------------------------------- |
| 7261 |
;; Floating-point arithmetic |
| 7262 |
;; ------------------------------------------------------------------- |
| 7263 |
|
| 7264 |
(define_insn "add<mode>3" |
| 7265 |
[(set (match_operand:GPF_F16 0 "register_operand" "=w") |
| 7266 |
(plus:GPF_F16 |
| 7267 |
(match_operand:GPF_F16 1 "register_operand" "w") |
| 7268 |
(match_operand:GPF_F16 2 "register_operand" "w")))] |
| 7269 |
"TARGET_FLOAT" |
| 7270 |
"fadd\\t%<s>0, %<s>1, %<s>2" |
| 7271 |
[(set_attr "type" "fadd<stype>")] |
| 7272 |
) |
| 7273 |
|
| 7274 |
(define_insn "sub<mode>3" |
| 7275 |
[(set (match_operand:GPF_F16 0 "register_operand" "=w") |
| 7276 |
(minus:GPF_F16 |
| 7277 |
(match_operand:GPF_F16 1 "register_operand" "w") |
| 7278 |
(match_operand:GPF_F16 2 "register_operand" "w")))] |
| 7279 |
"TARGET_FLOAT" |
| 7280 |
"fsub\\t%<s>0, %<s>1, %<s>2" |
| 7281 |
[(set_attr "type" "fadd<stype>")] |
| 7282 |
) |
| 7283 |
|
| 7284 |
(define_insn "mul<mode>3" |
| 7285 |
[(set (match_operand:GPF_F16 0 "register_operand" "=w") |
| 7286 |
(mult:GPF_F16 |
| 7287 |
(match_operand:GPF_F16 1 "register_operand" "w") |
| 7288 |
(match_operand:GPF_F16 2 "register_operand" "w")))] |
| 7289 |
"TARGET_FLOAT" |
| 7290 |
"fmul\\t%<s>0, %<s>1, %<s>2" |
| 7291 |
[(set_attr "type" "fmul<stype>")] |
| 7292 |
) |
| 7293 |
|
| 7294 |
(define_insn "*fnmul<mode>3" |
| 7295 |
[(set (match_operand:GPF 0 "register_operand" "=w") |
| 7296 |
(mult:GPF |
| 7297 |
(neg:GPF (match_operand:GPF 1 "register_operand" "w")) |
| 7298 |
(match_operand:GPF 2 "register_operand" "w")))] |
| 7299 |
"TARGET_FLOAT && !flag_rounding_math" |
| 7300 |
"fnmul\\t%<s>0, %<s>1, %<s>2" |
| 7301 |
[(set_attr "type" "fmul<s>")] |
| 7302 |
) |
| 7303 |
|
| 7304 |
(define_insn "*fnmul<mode>3" |
| 7305 |
[(set (match_operand:GPF 0 "register_operand" "=w") |
| 7306 |
(neg:GPF (mult:GPF |
| 7307 |
(match_operand:GPF 1 "register_operand" "w") |
| 7308 |
(match_operand:GPF 2 "register_operand" "w"))))] |
| 7309 |
"TARGET_FLOAT" |
| 7310 |
"fnmul\\t%<s>0, %<s>1, %<s>2" |
| 7311 |
[(set_attr "type" "fmul<s>")] |
| 7312 |
) |
| 7313 |
|
| 7314 |
(define_expand "div<mode>3" |
| 7315 |
[(set (match_operand:GPF_F16 0 "register_operand") |
| 7316 |
(div:GPF_F16 (match_operand:GPF_F16 1 "general_operand") |
| 7317 |
(match_operand:GPF_F16 2 "register_operand")))] |
| 7318 |
"TARGET_FLOAT" |
| 7319 |
{ |
| 7320 |
if (aarch64_emit_approx_div (operands[0], operands[1], operands[2])) |
| 7321 |
DONE; |
| 7322 |
|
| 7323 |
operands[1] = force_reg (<MODE>mode, operands[1]); |
| 7324 |
}) |
| 7325 |
|
| 7326 |
(define_insn "*div<mode>3" |
| 7327 |
[(set (match_operand:GPF_F16 0 "register_operand" "=w") |
| 7328 |
(div:GPF_F16 (match_operand:GPF_F16 1 "register_operand" "w") |
| 7329 |
(match_operand:GPF_F16 2 "register_operand" "w")))] |
| 7330 |
"TARGET_FLOAT" |
| 7331 |
"fdiv\\t%<s>0, %<s>1, %<s>2" |
| 7332 |
[(set_attr "type" "fdiv<stype>")] |
| 7333 |
) |
| 7334 |
|
| 7335 |
(define_insn "neg<mode>2" |
| 7336 |
[(set (match_operand:GPF_F16 0 "register_operand" "=w") |
| 7337 |
(neg:GPF_F16 (match_operand:GPF_F16 1 "register_operand" "w")))] |
| 7338 |
"TARGET_FLOAT" |
| 7339 |
"fneg\\t%<s>0, %<s>1" |
| 7340 |
[(set_attr "type" "ffarith<stype>")] |
| 7341 |
) |
| 7342 |
|
| 7343 |
(define_expand "sqrt<mode>2" |
| 7344 |
[(set (match_operand:GPF_F16 0 "register_operand") |
| 7345 |
(sqrt:GPF_F16 (match_operand:GPF_F16 1 "register_operand")))] |
| 7346 |
"TARGET_FLOAT" |
| 7347 |
{ |
| 7348 |
if (aarch64_emit_approx_sqrt (operands[0], operands[1], false)) |
| 7349 |
DONE; |
| 7350 |
}) |
| 7351 |
|
| 7352 |
(define_insn "*sqrt<mode>2" |
| 7353 |
[(set (match_operand:GPF_F16 0 "register_operand" "=w") |
| 7354 |
(sqrt:GPF_F16 (match_operand:GPF_F16 1 "register_operand" "w")))] |
| 7355 |
"TARGET_FLOAT" |
| 7356 |
"fsqrt\\t%<s>0, %<s>1" |
| 7357 |
[(set_attr "type" "fsqrt<stype>")] |
| 7358 |
) |
| 7359 |
|
| 7360 |
(define_insn "abs<mode>2" |
| 7361 |
[(set (match_operand:GPF_F16 0 "register_operand" "=w") |
| 7362 |
(abs:GPF_F16 (match_operand:GPF_F16 1 "register_operand" "w")))] |
| 7363 |
"TARGET_FLOAT" |
| 7364 |
"fabs\\t%<s>0, %<s>1" |
| 7365 |
[(set_attr "type" "ffarith<stype>")] |
| 7366 |
) |
| 7367 |
|
| 7368 |
;; Expander for integer smin, smax, umin. Mainly used to generate |
| 7369 |
;; straightforward RTL for TARGET_CSSC. When that is not available |
| 7370 |
;; FAIL and let the generic expanders generate the CMP + CSEL sequences, |
| 7371 |
;; except for the SMIN and SMAX with zero cases, for which we have a |
| 7372 |
;; single instruction even for the base architecture. |
| 7373 |
(define_expand "<optab><mode>3" |
| 7374 |
[(set (match_operand:GPI 0 "register_operand") |
| 7375 |
(MAXMIN_NOUMAX:GPI |
| 7376 |
(match_operand:GPI 1 "register_operand") |
| 7377 |
(match_operand:GPI 2 "aarch64_<su>minmax_operand")))] |
| 7378 |
"" |
| 7379 |
{ |
| 7380 |
if (!TARGET_CSSC) |
| 7381 |
{ |
| 7382 |
if (operands[2] != CONST0_RTX (<MODE>mode) |
| 7383 |
|| !(<CODE> == SMAX || <CODE> == SMIN)) |
| 7384 |
FAIL; |
| 7385 |
} |
| 7386 |
} |
| 7387 |
) |
| 7388 |
|
| 7389 |
(define_insn "*aarch64_<optab><mode>3_cssc" |
| 7390 |
[(set (match_operand:GPI 0 "register_operand") |
| 7391 |
(MAXMIN:GPI (match_operand:GPI 1 "register_operand") |
| 7392 |
(match_operand:GPI 2 "aarch64_<su>minmax_operand")))] |
| 7393 |
"TARGET_CSSC" |
| 7394 |
{@ [ cons: =0 , 1 , 2 ; attrs: type ] |
| 7395 |
[ r , r , r ; alu_sreg ] <optab>\t%<w>0, %<w>1, %<w>2 |
| 7396 |
[ r , r , U<su>m ; alu_imm ] <optab>\t%<w>0, %<w>1, %2 |
| 7397 |
} |
| 7398 |
) |
| 7399 |
|
| 7400 |
(define_insn "*aarch64_<optab><mode>3_zero" |
| 7401 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 7402 |
(FMAXMIN:GPI |
| 7403 |
(match_operand:GPI 1 "register_operand" "r") |
| 7404 |
(const_int 0)))] |
| 7405 |
"" |
| 7406 |
"<maxminand>\\t%<w>0, %<w>1, %<w>1, asr <sizem1>"; |
| 7407 |
[(set_attr "type" "logic_shift_imm")] |
| 7408 |
) |
| 7409 |
|
| 7410 |
;; Given that smax/smin do not specify the result when either input is NaN, |
| 7411 |
;; we could use either FMAXNM or FMAX for smax, and either FMINNM or FMIN |
| 7412 |
;; for smin. |
| 7413 |
|
| 7414 |
(define_insn "smax<mode>3" |
| 7415 |
[(set (match_operand:GPF 0 "register_operand" "=w") |
| 7416 |
(smax:GPF (match_operand:GPF 1 "register_operand" "w") |
| 7417 |
(match_operand:GPF 2 "register_operand" "w")))] |
| 7418 |
"TARGET_FLOAT" |
| 7419 |
"fmaxnm\\t%<s>0, %<s>1, %<s>2" |
| 7420 |
[(set_attr "type" "f_minmax<s>")] |
| 7421 |
) |
| 7422 |
|
| 7423 |
(define_insn "smin<mode>3" |
| 7424 |
[(set (match_operand:GPF 0 "register_operand" "=w") |
| 7425 |
(smin:GPF (match_operand:GPF 1 "register_operand" "w") |
| 7426 |
(match_operand:GPF 2 "register_operand" "w")))] |
| 7427 |
"TARGET_FLOAT" |
| 7428 |
"fminnm\\t%<s>0, %<s>1, %<s>2" |
| 7429 |
[(set_attr "type" "f_minmax<s>")] |
| 7430 |
) |
| 7431 |
|
| 7432 |
;; Scalar forms for fmax, fmin, fmaxnm, fminnm. |
| 7433 |
;; fmaxnm and fminnm are used for the fmax<mode>3 standard pattern names, |
| 7434 |
;; which implement the IEEE fmax ()/fmin () functions. |
| 7435 |
(define_insn "<fmaxmin><mode>3" |
| 7436 |
[(set (match_operand:GPF_F16 0 "register_operand" "=w") |
| 7437 |
(unspec:GPF_F16 [(match_operand:GPF_F16 1 "register_operand" "w") |
| 7438 |
(match_operand:GPF_F16 2 "register_operand" "w")] |
| 7439 |
FMAXMIN_UNS))] |
| 7440 |
"TARGET_FLOAT" |
| 7441 |
"<maxmin_uns_op>\\t%<s>0, %<s>1, %<s>2" |
| 7442 |
[(set_attr "type" "f_minmax<stype>")] |
| 7443 |
) |
| 7444 |
|
| 7445 |
(define_expand "lrint<GPF:mode><GPI:mode>2" |
| 7446 |
[(match_operand:GPI 0 "register_operand") |
| 7447 |
(match_operand:GPF 1 "register_operand")] |
| 7448 |
"TARGET_FLOAT |
| 7449 |
&& ((GET_MODE_BITSIZE (<GPF:MODE>mode) <= LONG_TYPE_SIZE) |
| 7450 |
|| !flag_trapping_math || flag_fp_int_builtin_inexact)" |
| 7451 |
{ |
| 7452 |
rtx cvt = gen_reg_rtx (<GPF:MODE>mode); |
| 7453 |
emit_insn (gen_rint<GPF:mode>2 (cvt, operands[1])); |
| 7454 |
emit_insn (gen_lbtrunc<GPF:mode><GPI:mode>2 (operands[0], cvt)); |
| 7455 |
DONE; |
| 7456 |
} |
| 7457 |
) |
| 7458 |
|
| 7459 |
;; For copysignf (x, y), we want to generate: |
| 7460 |
;; |
| 7461 |
;; movi v31.4s, 0x80, lsl 24 |
| 7462 |
;; bit v0.16b, v1.16b, v31.16b |
| 7463 |
;; |
| 7464 |
;; Because we expect these operations to nearly always operate on |
| 7465 |
;; floating-point values, we do not want the operation to be |
| 7466 |
;; simplified into a bit-field insert operation that operates on the |
| 7467 |
;; integer side, since typically that would involve three inter-bank |
| 7468 |
;; register copies. As we do not expect copysign to be followed by |
| 7469 |
;; other logical operations on the result, it seems preferable to keep |
| 7470 |
;; this as an unspec operation, rather than exposing the underlying |
| 7471 |
;; logic to the compiler. |
| 7472 |
|
| 7473 |
(define_expand "copysign<GPF:mode>3" |
| 7474 |
[(match_operand:GPF 0 "register_operand") |
| 7475 |
(match_operand:GPF 1 "register_operand") |
| 7476 |
(match_operand:GPF 2 "nonmemory_operand")] |
| 7477 |
"TARGET_SIMD" |
| 7478 |
{ |
| 7479 |
rtx sign = GEN_INT (HOST_WIDE_INT_M1U << (GET_MODE_BITSIZE (<MODE>mode) - 1)); |
| 7480 |
rtx v_bitmask = gen_const_vec_duplicate (<VQ_INT_EQUIV>mode, sign); |
| 7481 |
v_bitmask = force_reg (<VQ_INT_EQUIV>mode, v_bitmask); |
| 7482 |
|
| 7483 |
/* copysign (x, -1) should instead be expanded as orr with the signbit. */ |
| 7484 |
rtx op2_elt = unwrap_const_vec_duplicate (operands[2]); |
| 7485 |
|
| 7486 |
if (GET_CODE (op2_elt) == CONST_DOUBLE |
| 7487 |
&& real_isneg (CONST_DOUBLE_REAL_VALUE (op2_elt))) |
| 7488 |
{ |
| 7489 |
emit_insn (gen_ior<vq_int_equiv>3 ( |
| 7490 |
lowpart_subreg (<VQ_INT_EQUIV>mode, operands[0], <MODE>mode), |
| 7491 |
force_lowpart_subreg (<VQ_INT_EQUIV>mode, operands[1], <MODE>mode), |
| 7492 |
v_bitmask)); |
| 7493 |
DONE; |
| 7494 |
} |
| 7495 |
operands[2] = force_reg (<MODE>mode, operands[2]); |
| 7496 |
emit_insn (gen_copysign<mode>3_insn (operands[0], operands[1], operands[2], |
| 7497 |
v_bitmask)); |
| 7498 |
DONE; |
| 7499 |
} |
| 7500 |
) |
| 7501 |
|
| 7502 |
(define_insn "copysign<GPF:mode>3_insn" |
| 7503 |
[(set (match_operand:GPF 0 "register_operand") |
| 7504 |
(unspec:GPF [(match_operand:GPF 1 "register_operand") |
| 7505 |
(match_operand:GPF 2 "register_operand") |
| 7506 |
(match_operand:<VQ_INT_EQUIV> 3 "register_operand")] |
| 7507 |
UNSPEC_COPYSIGN))] |
| 7508 |
"TARGET_SIMD" |
| 7509 |
{@ [ cons: =0 , 1 , 2 , 3 ; attrs: type ] |
| 7510 |
[ w , w , w , 0 ; neon_bsl<q> ] bsl\t%0.<Vbtype>, %2.<Vbtype>, %1.<Vbtype> |
| 7511 |
[ w , 0 , w , w ; neon_bsl<q> ] bit\t%0.<Vbtype>, %2.<Vbtype>, %3.<Vbtype> |
| 7512 |
[ w , w , 0 , w ; neon_bsl<q> ] bif\t%0.<Vbtype>, %1.<Vbtype>, %3.<Vbtype> |
| 7513 |
} |
| 7514 |
) |
| 7515 |
|
| 7516 |
;; For xorsignf (x, y), we want to generate: |
| 7517 |
;; |
| 7518 |
;; movi v31.4s, 0x80, lsl 24 |
| 7519 |
;; and v31.16b, v31.16b, v1.16b |
| 7520 |
;; eor v0.16b, v31.16b, v0.16b |
| 7521 |
;; |
| 7522 |
|
| 7523 |
(define_expand "@xorsign<mode>3" |
| 7524 |
[(match_operand:GPF 0 "register_operand") |
| 7525 |
(match_operand:GPF 1 "register_operand") |
| 7526 |
(match_operand:GPF 2 "register_operand")] |
| 7527 |
"TARGET_SIMD" |
| 7528 |
{ |
| 7529 |
rtx tmp = gen_reg_rtx (<VCONQ>mode); |
| 7530 |
rtx op1 = force_lowpart_subreg (<VCONQ>mode, operands[1], <MODE>mode); |
| 7531 |
rtx op2 = force_lowpart_subreg (<VCONQ>mode, operands[2], <MODE>mode); |
| 7532 |
emit_insn (gen_xorsign3 (<VCONQ>mode, tmp, op1, op2)); |
| 7533 |
emit_move_insn (operands[0], |
| 7534 |
lowpart_subreg (<MODE>mode, tmp, <VCONQ>mode)); |
| 7535 |
DONE; |
| 7536 |
} |
| 7537 |
) |
| 7538 |
|
| 7539 |
;; ------------------------------------------------------------------- |
| 7540 |
;; Reload support |
| 7541 |
;; ------------------------------------------------------------------- |
| 7542 |
;; Reload Scalar Floating point modes from constant pool. |
| 7543 |
;; The AArch64 port doesn't have __int128 constant move support. |
| 7544 |
;; The patterns need constraints due to TARGET_SECONDARY_RELOAD hook. |
| 7545 |
(define_expand "@aarch64_reload_movcp<GPF_TF:mode><P:mode>" |
| 7546 |
[(set (match_operand:GPF_TF 0 "register_operand" "=w") |
| 7547 |
(mem:GPF_TF (match_operand 1 "aarch64_constant_pool_symref" "S"))) |
| 7548 |
(clobber (match_operand:P 2 "register_operand" "=&r"))] |
| 7549 |
"TARGET_FLOAT" |
| 7550 |
{ |
| 7551 |
aarch64_expand_mov_immediate (operands[2], XEXP (operands[1], 0)); |
| 7552 |
emit_move_insn (operands[0], gen_rtx_MEM (<GPF_TF:MODE>mode, operands[2])); |
| 7553 |
DONE; |
| 7554 |
} |
| 7555 |
) |
| 7556 |
|
| 7557 |
;; Reload Vector modes from constant pool. |
| 7558 |
(define_expand "@aarch64_reload_movcp<VALL:mode><P:mode>" |
| 7559 |
[(set (match_operand:VALL 0 "register_operand" "=w") |
| 7560 |
(mem:VALL (match_operand 1 "aarch64_constant_pool_symref" "S"))) |
| 7561 |
(clobber (match_operand:P 2 "register_operand" "=&r"))] |
| 7562 |
"TARGET_FLOAT" |
| 7563 |
{ |
| 7564 |
aarch64_expand_mov_immediate (operands[2], XEXP (operands[1], 0)); |
| 7565 |
emit_move_insn (operands[0], gen_rtx_MEM (<VALL:MODE>mode, operands[2])); |
| 7566 |
DONE; |
| 7567 |
} |
| 7568 |
) |
| 7569 |
|
| 7570 |
(define_expand "@aarch64_reload_mov<mode>" |
| 7571 |
[(set (match_operand:VTX 0 "register_operand" "=w") |
| 7572 |
(match_operand:VTX 1 "register_operand" "w")) |
| 7573 |
(clobber (match_operand:DI 2 "register_operand" "=&r")) |
| 7574 |
] |
| 7575 |
"TARGET_FLOAT" |
| 7576 |
{ |
| 7577 |
rtx op0 = simplify_gen_subreg (TImode, operands[0], <MODE>mode, 0); |
| 7578 |
rtx op1 = simplify_gen_subreg (TImode, operands[1], <MODE>mode, 0); |
| 7579 |
gen_aarch64_movtilow_tilow (op0, op1); |
| 7580 |
gen_aarch64_movdi_tihigh (operands[2], op1); |
| 7581 |
gen_aarch64_movtihigh_di (op0, operands[2]); |
| 7582 |
DONE; |
| 7583 |
} |
| 7584 |
) |
| 7585 |
|
| 7586 |
;; The following secondary reload helpers patterns are invoked |
| 7587 |
;; after or during reload as we don't want these patterns to start |
| 7588 |
;; kicking in during the combiner. |
| 7589 |
|
| 7590 |
(define_insn "@aarch64_movdi_<mode>low" |
| 7591 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 7592 |
(zero_extract:DI (match_operand:TX 1 "register_operand" "w") |
| 7593 |
(const_int 64) (const_int 0)))] |
| 7594 |
"TARGET_FLOAT && (reload_completed || reload_in_progress)" |
| 7595 |
"fmov\\t%x0, %d1" |
| 7596 |
[(set_attr "type" "f_mrc") |
| 7597 |
(set_attr "length" "4") |
| 7598 |
]) |
| 7599 |
|
| 7600 |
(define_insn "@aarch64_movdi_<mode>high" |
| 7601 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 7602 |
(zero_extract:DI (match_operand:TX 1 "register_operand" "w") |
| 7603 |
(const_int 64) (const_int 64)))] |
| 7604 |
"TARGET_FLOAT && (reload_completed || reload_in_progress)" |
| 7605 |
"fmov\\t%x0, %1.d[1]" |
| 7606 |
[(set_attr "type" "f_mrc") |
| 7607 |
(set_attr "length" "4") |
| 7608 |
]) |
| 7609 |
|
| 7610 |
(define_insn "@aarch64_mov<mode>high_di" |
| 7611 |
[(set (zero_extract:TX (match_operand:TX 0 "register_operand" "+w") |
| 7612 |
(const_int 64) (const_int 64)) |
| 7613 |
(zero_extend:TX (match_operand:DI 1 "register_operand" "r")))] |
| 7614 |
"TARGET_FLOAT && (reload_completed || reload_in_progress)" |
| 7615 |
"fmov\\t%0.d[1], %x1" |
| 7616 |
[(set_attr "type" "f_mcr") |
| 7617 |
(set_attr "length" "4") |
| 7618 |
]) |
| 7619 |
|
| 7620 |
(define_insn "@aarch64_mov<mode>low_di" |
| 7621 |
[(set (match_operand:TX 0 "register_operand" "=w") |
| 7622 |
(zero_extend:TX (match_operand:DI 1 "register_operand" "r")))] |
| 7623 |
"TARGET_FLOAT && (reload_completed || reload_in_progress)" |
| 7624 |
"fmov\\t%d0, %x1" |
| 7625 |
[(set_attr "type" "f_mcr") |
| 7626 |
(set_attr "length" "4") |
| 7627 |
]) |
| 7628 |
|
| 7629 |
(define_insn "aarch64_movtilow_tilow" |
| 7630 |
[(set (match_operand:TI 0 "register_operand" "=w") |
| 7631 |
(zero_extend:TI |
| 7632 |
(truncate:DI (match_operand:TI 1 "register_operand" "w"))))] |
| 7633 |
"TARGET_FLOAT && (reload_completed || reload_in_progress)" |
| 7634 |
"fmov\\t%d0, %d1" |
| 7635 |
[(set_attr "type" "fmov") |
| 7636 |
(set_attr "length" "4") |
| 7637 |
]) |
| 7638 |
|
| 7639 |
;; There is a deliberate reason why the parameters of high and lo_sum's |
| 7640 |
;; don't have modes for ADRP and ADD instructions. This is to allow high |
| 7641 |
;; and lo_sum's to be used with the labels defining the jump tables in |
| 7642 |
;; rodata section. |
| 7643 |
|
| 7644 |
(define_expand "add_losym" |
| 7645 |
[(set (match_operand 0 "register_operand") |
| 7646 |
(lo_sum (match_operand 1 "register_operand") |
| 7647 |
(match_operand 2 "aarch64_valid_symref")))] |
| 7648 |
"" |
| 7649 |
{ |
| 7650 |
machine_mode mode = GET_MODE (operands[0]); |
| 7651 |
|
| 7652 |
emit_insn ((mode == DImode |
| 7653 |
? gen_add_losym_di |
| 7654 |
: gen_add_losym_si) (operands[0], |
| 7655 |
operands[1], |
| 7656 |
operands[2])); |
| 7657 |
DONE; |
| 7658 |
}) |
| 7659 |
|
| 7660 |
(define_insn "add_losym_<mode>" |
| 7661 |
[(set (match_operand:P 0 "register_operand" "=r") |
| 7662 |
(lo_sum:P (match_operand:P 1 "register_operand" "r") |
| 7663 |
(match_operand 2 "aarch64_valid_symref" "S")))] |
| 7664 |
"" |
| 7665 |
"add\\t%<w>0, %<w>1, :lo12:%c2" |
| 7666 |
[(set_attr "type" "alu_imm")] |
| 7667 |
) |
| 7668 |
|
| 7669 |
(define_insn "ldr_got_small_28k_<mode>" |
| 7670 |
[(set (match_operand:PTR 0 "register_operand" "=r") |
| 7671 |
(unspec:PTR [(mem:PTR (lo_sum:PTR |
| 7672 |
(match_operand:PTR 1 "register_operand" "r") |
| 7673 |
(match_operand:PTR 2 "aarch64_valid_symref" "S")))] |
| 7674 |
UNSPEC_GOTSMALLPIC28K))] |
| 7675 |
"" |
| 7676 |
"ldr\\t%<w>0, [%1, #:<got_modifier>:%c2]" |
| 7677 |
[(set_attr "type" "load_<ldst_sz>")] |
| 7678 |
) |
| 7679 |
|
| 7680 |
(define_insn "ldr_got_small_28k_sidi" |
| 7681 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 7682 |
(zero_extend:DI |
| 7683 |
(unspec:SI [(mem:SI (lo_sum:DI |
| 7684 |
(match_operand:DI 1 "register_operand" "r") |
| 7685 |
(match_operand:DI 2 "aarch64_valid_symref" "S")))] |
| 7686 |
UNSPEC_GOTSMALLPIC28K)))] |
| 7687 |
"TARGET_ILP32" |
| 7688 |
"ldr\\t%w0, [%1, #:gotpage_lo14:%c2]" |
| 7689 |
[(set_attr "type" "load_4")] |
| 7690 |
) |
| 7691 |
|
| 7692 |
(define_insn "@ldr_got_tiny_<mode>" |
| 7693 |
[(set (match_operand:PTR 0 "register_operand" "=r") |
| 7694 |
(unspec:PTR [(match_operand:PTR 1 "aarch64_valid_symref" "S")] |
| 7695 |
UNSPEC_GOTTINYPIC))] |
| 7696 |
"" |
| 7697 |
"ldr\t%<w>0, %L1" |
| 7698 |
[(set_attr "type" "load_<ldst_sz>")] |
| 7699 |
) |
| 7700 |
|
| 7701 |
(define_insn "ldr_got_tiny_sidi" |
| 7702 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 7703 |
(zero_extend:DI |
| 7704 |
(unspec:SI [(match_operand:DI 1 "aarch64_valid_symref" "S")] |
| 7705 |
UNSPEC_GOTTINYPIC)))] |
| 7706 |
"TARGET_ILP32" |
| 7707 |
"ldr\t%w0, %L1" |
| 7708 |
[(set_attr "type" "load_4")] |
| 7709 |
) |
| 7710 |
|
| 7711 |
(define_insn "aarch64_load_tp_hard" |
| 7712 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 7713 |
(unspec:DI [(const_int 0)] UNSPEC_TLS))] |
| 7714 |
"" |
| 7715 |
"* return aarch64_output_load_tp (operands[0]);" |
| 7716 |
[(set_attr "type" "mrs")] |
| 7717 |
) |
| 7718 |
|
| 7719 |
;; The TLS ABI specifically requires that the compiler does not schedule |
| 7720 |
;; instructions in the TLS stubs, in order to enable linker relaxation. |
| 7721 |
;; Therefore we treat the stubs as an atomic sequence. |
| 7722 |
(define_expand "tlsgd_small_<mode>" |
| 7723 |
[(parallel [(set (match_operand:PTR 0 "register_operand") |
| 7724 |
(call (mem:DI (match_dup 2)) (const_int 1))) |
| 7725 |
(unspec:DI [(const_int 0)] UNSPEC_CALLEE_ABI) |
| 7726 |
(unspec:DI [(match_operand 1 "aarch64_valid_symref")] UNSPEC_GOTSMALLTLS) |
| 7727 |
(clobber (reg:DI LR_REGNUM))])] |
| 7728 |
"" |
| 7729 |
{ |
| 7730 |
operands[2] = aarch64_tls_get_addr (); |
| 7731 |
}) |
| 7732 |
|
| 7733 |
(define_insn "*tlsgd_small_<mode>" |
| 7734 |
[(set (match_operand:PTR 0 "register_operand" "") |
| 7735 |
(call (mem:DI (match_operand:DI 2 "" "")) (const_int 1))) |
| 7736 |
(unspec:DI [(const_int 0)] UNSPEC_CALLEE_ABI) |
| 7737 |
(unspec:DI [(match_operand 1 "aarch64_valid_symref" "S")] UNSPEC_GOTSMALLTLS) |
| 7738 |
(clobber (reg:DI LR_REGNUM)) |
| 7739 |
] |
| 7740 |
"" |
| 7741 |
"adrp\\tx0, %A1\;add\\tx0, x0, %L1\;bl\\t%2\;nop" |
| 7742 |
[(set_attr "type" "call") |
| 7743 |
(set_attr "length" "16")]) |
| 7744 |
|
| 7745 |
(define_insn "tlsie_small_<mode>" |
| 7746 |
[(set (match_operand:PTR 0 "register_operand" "=r") |
| 7747 |
(unspec:PTR [(match_operand 1 "aarch64_tls_ie_symref" "S")] |
| 7748 |
UNSPEC_GOTSMALLTLS))] |
| 7749 |
"" |
| 7750 |
"adrp\\t%0, %A1\;ldr\\t%<w>0, [%0, #%L1]" |
| 7751 |
[(set_attr "type" "load_4") |
| 7752 |
(set_attr "length" "8")] |
| 7753 |
) |
| 7754 |
|
| 7755 |
(define_insn "tlsie_small_sidi" |
| 7756 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 7757 |
(zero_extend:DI |
| 7758 |
(unspec:SI [(match_operand 1 "aarch64_tls_ie_symref" "S")] |
| 7759 |
UNSPEC_GOTSMALLTLS)))] |
| 7760 |
"" |
| 7761 |
"adrp\\t%0, %A1\;ldr\\t%w0, [%0, #%L1]" |
| 7762 |
[(set_attr "type" "load_4") |
| 7763 |
(set_attr "length" "8")] |
| 7764 |
) |
| 7765 |
|
| 7766 |
(define_insn "tlsie_tiny_<mode>" |
| 7767 |
[(set (match_operand:PTR 0 "register_operand" "=&r") |
| 7768 |
(unspec:PTR [(match_operand 1 "aarch64_tls_ie_symref" "S") |
| 7769 |
(match_operand:PTR 2 "register_operand" "r")] |
| 7770 |
UNSPEC_GOTTINYTLS))] |
| 7771 |
"" |
| 7772 |
"ldr\\t%<w>0, %L1\;add\\t%<w>0, %<w>0, %<w>2" |
| 7773 |
[(set_attr "type" "multiple") |
| 7774 |
(set_attr "length" "8")] |
| 7775 |
) |
| 7776 |
|
| 7777 |
(define_insn "tlsie_tiny_sidi" |
| 7778 |
[(set (match_operand:DI 0 "register_operand" "=&r") |
| 7779 |
(zero_extend:DI |
| 7780 |
(unspec:SI [(match_operand 1 "aarch64_tls_ie_symref" "S") |
| 7781 |
(match_operand:DI 2 "register_operand" "r") |
| 7782 |
] |
| 7783 |
UNSPEC_GOTTINYTLS)))] |
| 7784 |
"" |
| 7785 |
"ldr\\t%w0, %L1\;add\\t%w0, %w0, %w2" |
| 7786 |
[(set_attr "type" "multiple") |
| 7787 |
(set_attr "length" "8")] |
| 7788 |
) |
| 7789 |
|
| 7790 |
(define_insn "tlsle12_<mode>" |
| 7791 |
[(set (match_operand:P 0 "register_operand" "=r") |
| 7792 |
(unspec:P [(match_operand:P 1 "register_operand" "r") |
| 7793 |
(match_operand 2 "aarch64_tls_le_symref" "S")] |
| 7794 |
UNSPEC_TLSLE12))] |
| 7795 |
"" |
| 7796 |
"add\\t%<w>0, %<w>1, #%L2"; |
| 7797 |
[(set_attr "type" "alu_sreg") |
| 7798 |
(set_attr "length" "4")] |
| 7799 |
) |
| 7800 |
|
| 7801 |
(define_insn "tlsle24_<mode>" |
| 7802 |
[(set (match_operand:P 0 "register_operand" "=r") |
| 7803 |
(unspec:P [(match_operand:P 1 "register_operand" "r") |
| 7804 |
(match_operand 2 "aarch64_tls_le_symref" "S")] |
| 7805 |
UNSPEC_TLSLE24))] |
| 7806 |
"" |
| 7807 |
"add\\t%<w>0, %<w>1, #%G2, lsl #12\;add\\t%<w>0, %<w>0, #%L2" |
| 7808 |
[(set_attr "type" "multiple") |
| 7809 |
(set_attr "length" "8")] |
| 7810 |
) |
| 7811 |
|
| 7812 |
(define_insn "tlsle32_<mode>" |
| 7813 |
[(set (match_operand:P 0 "register_operand" "=r") |
| 7814 |
(unspec:P [(match_operand 1 "aarch64_tls_le_symref" "S")] |
| 7815 |
UNSPEC_TLSLE32))] |
| 7816 |
"" |
| 7817 |
"movz\\t%<w>0, #:tprel_g1:%1\;movk\\t%<w>0, #:tprel_g0_nc:%1" |
| 7818 |
[(set_attr "type" "multiple") |
| 7819 |
(set_attr "length" "8")] |
| 7820 |
) |
| 7821 |
|
| 7822 |
(define_insn "tlsle48_<mode>" |
| 7823 |
[(set (match_operand:P 0 "register_operand" "=r") |
| 7824 |
(unspec:P [(match_operand 1 "aarch64_tls_le_symref" "S")] |
| 7825 |
UNSPEC_TLSLE48))] |
| 7826 |
"" |
| 7827 |
"movz\\t%<w>0, #:tprel_g2:%1\;movk\\t%<w>0, #:tprel_g1_nc:%1\;movk\\t%<w>0, #:tprel_g0_nc:%1" |
| 7828 |
[(set_attr "type" "multiple") |
| 7829 |
(set_attr "length" "12")] |
| 7830 |
) |
| 7831 |
|
| 7832 |
(define_expand "tlsdesc_small_<mode>" |
| 7833 |
[(unspec:PTR [(match_operand 0 "aarch64_valid_symref")] UNSPEC_TLSDESC)] |
| 7834 |
"TARGET_TLS_DESC" |
| 7835 |
{ |
| 7836 |
if (TARGET_SVE) |
| 7837 |
{ |
| 7838 |
rtx abi = aarch64_gen_callee_cookie (AARCH64_ISA_MODE, |
| 7839 |
aarch64_tlsdesc_abi_id (), |
| 7840 |
false); |
| 7841 |
rtx_insn *call |
| 7842 |
= emit_call_insn (gen_tlsdesc_small_sve_<mode> (operands[0], abi)); |
| 7843 |
RTL_CONST_CALL_P (call) = 1; |
| 7844 |
} |
| 7845 |
else |
| 7846 |
emit_insn (gen_tlsdesc_small_advsimd_<mode> (operands[0])); |
| 7847 |
DONE; |
| 7848 |
} |
| 7849 |
) |
| 7850 |
|
| 7851 |
;; tlsdesc calls preserve all core and Advanced SIMD registers except |
| 7852 |
;; R0 and LR. |
| 7853 |
(define_insn "tlsdesc_small_advsimd_<mode>" |
| 7854 |
[(set (reg:PTR R0_REGNUM) |
| 7855 |
(unspec:PTR [(match_operand 0 "aarch64_valid_symref" "S")] |
| 7856 |
UNSPEC_TLSDESC)) |
| 7857 |
(clobber (reg:DI LR_REGNUM)) |
| 7858 |
(clobber (reg:CC CC_REGNUM)) |
| 7859 |
(clobber (match_scratch:DI 1 "=r")) |
| 7860 |
(use (reg:DI FP_REGNUM))] |
| 7861 |
"TARGET_TLS_DESC && !TARGET_SVE" |
| 7862 |
"adrp\\tx0, %A0\;ldr\\t%<w>1, [x0, #%L0]\;add\\t<w>0, <w>0, %L0\;.tlsdesccall\\t%0\;blr\\t%1" |
| 7863 |
[(set_attr "type" "call") |
| 7864 |
(set_attr "length" "16")]) |
| 7865 |
|
| 7866 |
;; For SVE, model tlsdesc calls as normal calls, with the callee ABI |
| 7867 |
;; describing the extra call-preserved guarantees. This would work |
| 7868 |
;; for non-SVE too, but avoiding a call is probably better if we can. |
| 7869 |
(define_insn "tlsdesc_small_sve_<mode>" |
| 7870 |
[(set (reg:PTR R0_REGNUM) |
| 7871 |
(call (mem:DI (unspec:PTR |
| 7872 |
[(match_operand 0 "aarch64_valid_symref")] |
| 7873 |
UNSPEC_TLSDESC)) |
| 7874 |
(const_int 0))) |
| 7875 |
(unspec:DI [(match_operand:DI 1 "const_int_operand")] UNSPEC_CALLEE_ABI) |
| 7876 |
(clobber (reg:DI LR_REGNUM))] |
| 7877 |
"TARGET_TLS_DESC && TARGET_SVE" |
| 7878 |
"adrp\\tx0, %A0\;ldr\\t<w>30, [x0, #%L0]\;add\\t<w>0, <w>0, %L0\;.tlsdesccall\\t%0\;blr\\tx30" |
| 7879 |
[(set_attr "type" "call") |
| 7880 |
(set_attr "length" "16")]) |
| 7881 |
|
| 7882 |
(define_insn "stack_tie" |
| 7883 |
[(set (mem:BLK (scratch)) |
| 7884 |
(unspec:BLK [(reg:DI SP_REGNUM) |
| 7885 |
(match_operand:DI 0 "register_operand" "rk") |
| 7886 |
(match_operand:DI 1 "const_int_operand")] |
| 7887 |
UNSPEC_PRLG_STK))] |
| 7888 |
"REGNO (operands[0]) == INTVAL (operands[1])" |
| 7889 |
"" |
| 7890 |
[(set_attr "length" "0")] |
| 7891 |
) |
| 7892 |
|
| 7893 |
(define_insn "aarch64_fjcvtzs" |
| 7894 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 7895 |
(unspec:SI [(match_operand:DF 1 "register_operand" "w")] |
| 7896 |
UNSPEC_FJCVTZS)) |
| 7897 |
(clobber (reg:CC CC_REGNUM))] |
| 7898 |
"TARGET_JSCVT" |
| 7899 |
"fjcvtzs\\t%w0, %d1" |
| 7900 |
[(set_attr "type" "f_cvtf2i")] |
| 7901 |
) |
| 7902 |
|
| 7903 |
;; Pointer authentication patterns are always provided. On targets that |
| 7904 |
;; don't implement FEAT_PAuth these HINT instructions operate as NOPs. |
| 7905 |
;; This lets the user write portable software which authenticates pointers |
| 7906 |
;; when run on something which implements FEAT_PAuth, and which runs |
| 7907 |
;; correctly, but does not authenticate pointers, where FEAT_PAuth is not |
| 7908 |
;; implemented. |
| 7909 |
|
| 7910 |
;; Signing/Authenticating R30 using SP as the salt. |
| 7911 |
|
| 7912 |
(define_insn "<pauth_mnem_prefix>sp" |
| 7913 |
[(set (reg:DI R30_REGNUM) |
| 7914 |
(unspec:DI [(reg:DI R30_REGNUM) (reg:DI SP_REGNUM)] PAUTH_LR_SP))] |
| 7915 |
"" |
| 7916 |
"hint\t<pauth_hint_num> // <pauth_mnem_prefix>sp"; |
| 7917 |
) |
| 7918 |
|
| 7919 |
;; Signing/Authenticating X17 using X16 as the salt. |
| 7920 |
|
| 7921 |
(define_insn "<pauth_mnem_prefix>1716" |
| 7922 |
[(set (reg:DI R17_REGNUM) |
| 7923 |
(unspec:DI [(reg:DI R17_REGNUM) (reg:DI R16_REGNUM)] PAUTH_17_16))] |
| 7924 |
"" |
| 7925 |
"hint\t<pauth_hint_num> // <pauth_mnem_prefix>1716"; |
| 7926 |
) |
| 7927 |
|
| 7928 |
;; Stripping the signature in R30. |
| 7929 |
|
| 7930 |
(define_insn "xpaclri" |
| 7931 |
[(set (reg:DI R30_REGNUM) (unspec:DI [(reg:DI R30_REGNUM)] UNSPEC_XPACLRI))] |
| 7932 |
"" |
| 7933 |
"hint\t7 // xpaclri" |
| 7934 |
) |
| 7935 |
|
| 7936 |
;; Save X30 in the X18-based POST_INC stack (consistent with clang). |
| 7937 |
(define_expand "scs_push" |
| 7938 |
[(set (mem:DI (post_inc:DI (reg:DI R18_REGNUM))) |
| 7939 |
(reg:DI R30_REGNUM))]) |
| 7940 |
|
| 7941 |
;; Load X30 form the X18-based PRE_DEC stack (consistent with clang). |
| 7942 |
(define_expand "scs_pop" |
| 7943 |
[(set (reg:DI R30_REGNUM) |
| 7944 |
(mem:DI (pre_dec:DI (reg:DI R18_REGNUM))))]) |
| 7945 |
|
| 7946 |
;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and |
| 7947 |
;; all of memory. This blocks insns from being moved across this point. |
| 7948 |
|
| 7949 |
(define_insn "blockage" |
| 7950 |
[(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)] |
| 7951 |
"" |
| 7952 |
"" |
| 7953 |
[(set_attr "length" "0") |
| 7954 |
(set_attr "type" "block")] |
| 7955 |
) |
| 7956 |
|
| 7957 |
(define_insn "probe_stack_range" |
| 7958 |
[(set (match_operand:DI 0 "register_operand" "=rk") |
| 7959 |
(unspec_volatile:DI [(match_operand:DI 1 "register_operand" "0") |
| 7960 |
(match_operand:DI 2 "register_operand" "r")] |
| 7961 |
UNSPECV_PROBE_STACK_RANGE))] |
| 7962 |
"" |
| 7963 |
{ |
| 7964 |
return aarch64_output_probe_stack_range (operands[0], operands[2]); |
| 7965 |
} |
| 7966 |
[(set_attr "length" "32")] |
| 7967 |
) |
| 7968 |
|
| 7969 |
;; This instruction is used to generate the stack clash stack adjustment and |
| 7970 |
;; probing loop. We can't change the control flow during prologue and epilogue |
| 7971 |
;; code generation. So we must emit a volatile unspec and expand it later on. |
| 7972 |
|
| 7973 |
(define_insn "@probe_sve_stack_clash_<mode>" |
| 7974 |
[(set (match_operand:P 0 "register_operand" "=rk") |
| 7975 |
(unspec_volatile:P [(match_operand:P 1 "register_operand" "0") |
| 7976 |
(match_operand:P 2 "register_operand" "r") |
| 7977 |
(match_operand:P 3 "const_int_operand" "n") |
| 7978 |
(match_operand:P 4 "aarch64_plus_immediate" "L")] |
| 7979 |
UNSPECV_PROBE_STACK_RANGE))] |
| 7980 |
"TARGET_SVE" |
| 7981 |
{ |
| 7982 |
return aarch64_output_probe_sve_stack_clash (operands[0], operands[2], |
| 7983 |
operands[3], operands[4]); |
| 7984 |
} |
| 7985 |
[(set_attr "length" "28")] |
| 7986 |
) |
| 7987 |
|
| 7988 |
;; Named pattern for expanding thread pointer reference. |
| 7989 |
(define_expand "get_thread_pointerdi" |
| 7990 |
[(match_operand:DI 0 "register_operand")] |
| 7991 |
"" |
| 7992 |
{ |
| 7993 |
rtx tmp = aarch64_load_tp (operands[0]); |
| 7994 |
if (tmp != operands[0]) |
| 7995 |
emit_move_insn (operands[0], tmp); |
| 7996 |
DONE; |
| 7997 |
}) |
| 7998 |
|
| 7999 |
;; Defined for -mstack-protector-guard=sysreg, which goes through this |
| 8000 |
;; pattern rather than stack_protect_combined_set. Our implementation |
| 8001 |
;; of the latter can handle both. |
| 8002 |
(define_expand "stack_protect_set" |
| 8003 |
[(match_operand 0 "memory_operand") |
| 8004 |
(match_operand 1 "")] |
| 8005 |
"" |
| 8006 |
{ |
| 8007 |
emit_insn (gen_stack_protect_combined_set (operands[0], operands[1])); |
| 8008 |
DONE; |
| 8009 |
}) |
| 8010 |
|
| 8011 |
(define_expand "stack_protect_combined_set" |
| 8012 |
[(match_operand 0 "memory_operand") |
| 8013 |
(match_operand 1 "")] |
| 8014 |
"" |
| 8015 |
{ |
| 8016 |
machine_mode mode = GET_MODE (operands[0]); |
| 8017 |
operands[1] = aarch64_stack_protect_canary_mem (mode, operands[1], |
| 8018 |
AARCH64_SALT_SSP_SET); |
| 8019 |
emit_insn ((mode == DImode |
| 8020 |
? gen_stack_protect_set_di |
| 8021 |
: gen_stack_protect_set_si) (operands[0], operands[1])); |
| 8022 |
DONE; |
| 8023 |
}) |
| 8024 |
|
| 8025 |
;; Operand 1 is either AARCH64_SALT_SSP_SET or AARCH64_SALT_SSP_TEST. |
| 8026 |
(define_insn "reg_stack_protect_address_<mode>" |
| 8027 |
[(set (match_operand:PTR 0 "register_operand" "=r") |
| 8028 |
(unspec:PTR [(match_operand 1 "const_int_operand")] |
| 8029 |
UNSPEC_SSP_SYSREG))] |
| 8030 |
"aarch64_stack_protector_guard != SSP_GLOBAL" |
| 8031 |
{ |
| 8032 |
char buf[150]; |
| 8033 |
snprintf (buf, 150, "mrs\\t%%<w>0, %s", |
| 8034 |
aarch64_stack_protector_guard_reg_str); |
| 8035 |
output_asm_insn (buf, operands); |
| 8036 |
return ""; |
| 8037 |
} |
| 8038 |
[(set_attr "type" "mrs")]) |
| 8039 |
|
| 8040 |
;; DO NOT SPLIT THIS PATTERN. It is important for security reasons that the |
| 8041 |
;; canary value does not live beyond the life of this sequence. |
| 8042 |
(define_insn "stack_protect_set_<mode>" |
| 8043 |
[(set (match_operand:PTR 0 "memory_operand" "=m") |
| 8044 |
(unspec:PTR [(match_operand:PTR 1 "memory_operand" "m")] |
| 8045 |
UNSPEC_SP_SET)) |
| 8046 |
(set (match_scratch:PTR 2 "=&r") (const_int 0))] |
| 8047 |
"" |
| 8048 |
"ldr\\t%<w>2, %1\;str\\t%<w>2, %0\;mov\t%<w>2, 0" |
| 8049 |
[(set_attr "length" "12") |
| 8050 |
(set_attr "type" "multiple")]) |
| 8051 |
|
| 8052 |
;; Defined for -mstack-protector-guard=sysreg, which goes through this |
| 8053 |
;; pattern rather than stack_protect_combined_test. Our implementation |
| 8054 |
;; of the latter can handle both. |
| 8055 |
(define_expand "stack_protect_test" |
| 8056 |
[(match_operand 0 "memory_operand") |
| 8057 |
(match_operand 1 "") |
| 8058 |
(match_operand 2)] |
| 8059 |
"" |
| 8060 |
{ |
| 8061 |
emit_insn (gen_stack_protect_combined_test (operands[0], operands[1], |
| 8062 |
operands[2])); |
| 8063 |
DONE; |
| 8064 |
}) |
| 8065 |
|
| 8066 |
(define_expand "stack_protect_combined_test" |
| 8067 |
[(match_operand 0 "memory_operand") |
| 8068 |
(match_operand 1 "") |
| 8069 |
(match_operand 2)] |
| 8070 |
"" |
| 8071 |
{ |
| 8072 |
machine_mode mode = GET_MODE (operands[0]); |
| 8073 |
operands[1] = aarch64_stack_protect_canary_mem (mode, operands[1], |
| 8074 |
AARCH64_SALT_SSP_TEST); |
| 8075 |
emit_insn ((mode == DImode |
| 8076 |
? gen_stack_protect_test_di |
| 8077 |
: gen_stack_protect_test_si) (operands[0], operands[1])); |
| 8078 |
|
| 8079 |
rtx cc_reg = gen_rtx_REG (CCmode, CC_REGNUM); |
| 8080 |
emit_jump_insn (gen_condjump (gen_rtx_EQ (VOIDmode, cc_reg, const0_rtx), |
| 8081 |
cc_reg, operands[2])); |
| 8082 |
DONE; |
| 8083 |
}) |
| 8084 |
|
| 8085 |
;; DO NOT SPLIT THIS PATTERN. It is important for security reasons that the |
| 8086 |
;; canary value does not live beyond the end of this sequence. |
| 8087 |
(define_insn "stack_protect_test_<mode>" |
| 8088 |
[(set (reg:CC CC_REGNUM) |
| 8089 |
(unspec:CC [(match_operand:PTR 0 "memory_operand" "m") |
| 8090 |
(match_operand:PTR 1 "memory_operand" "m")] |
| 8091 |
UNSPEC_SP_TEST)) |
| 8092 |
(clobber (match_scratch:PTR 2 "=&r")) |
| 8093 |
(clobber (match_scratch:PTR 3 "=&r"))] |
| 8094 |
"" |
| 8095 |
"ldr\t%<w>2, %0\;ldr\t%<w>3, %1\;subs\t%<w>2, %<w>2, %<w>3\;mov\t%3, 0" |
| 8096 |
[(set_attr "length" "16") |
| 8097 |
(set_attr "type" "multiple")]) |
| 8098 |
|
| 8099 |
;; Write into the Floating-point Status or Control Register. |
| 8100 |
(define_insn "@aarch64_set_<fpscr_name><GPI:mode>" |
| 8101 |
[(unspec_volatile [(match_operand:GPI 0 "register_operand" "r")] SET_FPSCR)] |
| 8102 |
"" |
| 8103 |
"msr\\t<fpscr_name>, %0" |
| 8104 |
[(set_attr "type" "mrs")]) |
| 8105 |
|
| 8106 |
;; Read into the Floating-point Status or Control Register. |
| 8107 |
(define_insn "@aarch64_get_<fpscr_name><GPI:mode>" |
| 8108 |
[(set (match_operand:GPI 0 "register_operand" "=r") |
| 8109 |
(unspec_volatile:GPI [(const_int 0)] GET_FPSCR))] |
| 8110 |
"" |
| 8111 |
"mrs\\t%0, <fpscr_name>" |
| 8112 |
[(set_attr "type" "mrs")]) |
| 8113 |
|
| 8114 |
;; Define the subtract-one-and-jump insns so loop.c |
| 8115 |
;; knows what to generate. |
| 8116 |
(define_expand "doloop_end" |
| 8117 |
[(use (match_operand 0 "" "")) ; loop pseudo |
| 8118 |
(use (match_operand 1 "" ""))] ; label |
| 8119 |
"optimize > 0 && flag_modulo_sched" |
| 8120 |
{ |
| 8121 |
rtx s0; |
| 8122 |
rtx bcomp; |
| 8123 |
rtx loc_ref; |
| 8124 |
rtx cc_reg; |
| 8125 |
rtx insn; |
| 8126 |
rtx cmp; |
| 8127 |
|
| 8128 |
/* Currently SMS relies on the do-loop pattern to recognize loops |
| 8129 |
where (1) the control part consists of all insns defining and/or |
| 8130 |
using a certain 'count' register and (2) the loop count can be |
| 8131 |
adjusted by modifying this register prior to the loop. |
| 8132 |
??? The possible introduction of a new block to initialize the |
| 8133 |
new IV can potentially affect branch optimizations. */ |
| 8134 |
|
| 8135 |
if (GET_MODE (operands[0]) != DImode) |
| 8136 |
FAIL; |
| 8137 |
|
| 8138 |
s0 = operands [0]; |
| 8139 |
insn = emit_insn (gen_adddi3_compare0 (s0, s0, GEN_INT (-1))); |
| 8140 |
|
| 8141 |
cmp = XVECEXP (PATTERN (insn), 0, 0); |
| 8142 |
cc_reg = SET_DEST (cmp); |
| 8143 |
bcomp = gen_rtx_NE (VOIDmode, cc_reg, const0_rtx); |
| 8144 |
loc_ref = gen_rtx_LABEL_REF (VOIDmode, operands [1]); |
| 8145 |
emit_jump_insn (gen_rtx_SET (pc_rtx, |
| 8146 |
gen_rtx_IF_THEN_ELSE (VOIDmode, bcomp, |
| 8147 |
loc_ref, pc_rtx))); |
| 8148 |
DONE; |
| 8149 |
}) |
| 8150 |
|
| 8151 |
;; Track speculation through conditional branches. We assume that |
| 8152 |
;; SPECULATION_TRACKER_REGNUM is reserved for this purpose when necessary. |
| 8153 |
(define_insn "speculation_tracker" |
| 8154 |
[(set (reg:DI SPECULATION_TRACKER_REGNUM) |
| 8155 |
(unspec:DI [(reg:DI SPECULATION_TRACKER_REGNUM) (match_operand 0)] |
| 8156 |
UNSPEC_SPECULATION_TRACKER))] |
| 8157 |
"" |
| 8158 |
{ |
| 8159 |
operands[1] = gen_rtx_REG (DImode, SPECULATION_TRACKER_REGNUM); |
| 8160 |
output_asm_insn ("csel\\t%1, %1, xzr, %m0", operands); |
| 8161 |
return ""; |
| 8162 |
} |
| 8163 |
[(set_attr "type" "csel")] |
| 8164 |
) |
| 8165 |
|
| 8166 |
;; Like speculation_tracker, but track the inverse condition. |
| 8167 |
(define_insn "speculation_tracker_rev" |
| 8168 |
[(set (reg:DI SPECULATION_TRACKER_REGNUM) |
| 8169 |
(unspec:DI [(reg:DI SPECULATION_TRACKER_REGNUM) (match_operand 0)] |
| 8170 |
UNSPEC_SPECULATION_TRACKER_REV))] |
| 8171 |
"" |
| 8172 |
{ |
| 8173 |
operands[1] = gen_rtx_REG (DImode, SPECULATION_TRACKER_REGNUM); |
| 8174 |
output_asm_insn ("csel\\t%1, %1, xzr, %M0", operands); |
| 8175 |
return ""; |
| 8176 |
} |
| 8177 |
[(set_attr "type" "csel")] |
| 8178 |
) |
| 8179 |
|
| 8180 |
;; BTI <target> instructions |
| 8181 |
(define_insn "bti_noarg" |
| 8182 |
[(unspec_volatile [(const_int 0)] UNSPECV_BTI_NOARG)] |
| 8183 |
"" |
| 8184 |
"hint\t32 // bti" |
| 8185 |
[(set_attr "type" "no_insn")] |
| 8186 |
) |
| 8187 |
|
| 8188 |
(define_insn "bti_c" |
| 8189 |
[(unspec_volatile [(const_int 0)] UNSPECV_BTI_C)] |
| 8190 |
"" |
| 8191 |
"hint\t34 // bti c" |
| 8192 |
[(set_attr "type" "no_insn")] |
| 8193 |
) |
| 8194 |
|
| 8195 |
(define_insn "bti_j" |
| 8196 |
[(unspec_volatile [(const_int 0)] UNSPECV_BTI_J)] |
| 8197 |
"" |
| 8198 |
"hint\t36 // bti j" |
| 8199 |
[(set_attr "type" "no_insn")] |
| 8200 |
) |
| 8201 |
|
| 8202 |
(define_insn "bti_jc" |
| 8203 |
[(unspec_volatile [(const_int 0)] UNSPECV_BTI_JC)] |
| 8204 |
"" |
| 8205 |
"hint\t38 // bti jc" |
| 8206 |
[(set_attr "type" "no_insn")] |
| 8207 |
) |
| 8208 |
|
| 8209 |
;; Hard speculation barrier. |
| 8210 |
(define_insn "speculation_barrier" |
| 8211 |
[(unspec_volatile [(const_int 0)] UNSPECV_SPECULATION_BARRIER)] |
| 8212 |
"" |
| 8213 |
"isb\;dsb\\tsy" |
| 8214 |
[(set_attr "length" "8") |
| 8215 |
(set_attr "type" "block") |
| 8216 |
(set_attr "speculation_barrier" "true")] |
| 8217 |
) |
| 8218 |
|
| 8219 |
;; Support for __builtin_speculation_safe_value when we have speculation |
| 8220 |
;; tracking enabled. Use the speculation tracker to decide whether to |
| 8221 |
;; copy operand 1 to the target, or to copy the fail value (operand 2). |
| 8222 |
(define_expand "@despeculate_copy<ALLI_TI:mode>" |
| 8223 |
[(set (match_operand:ALLI_TI 0 "register_operand") |
| 8224 |
(unspec_volatile:ALLI_TI |
| 8225 |
[(match_operand:ALLI_TI 1 "register_operand") |
| 8226 |
(match_operand:ALLI_TI 2 "aarch64_reg_or_zero") |
| 8227 |
(use (reg:DI SPECULATION_TRACKER_REGNUM)) |
| 8228 |
(clobber (reg:CC CC_REGNUM))] UNSPECV_SPECULATION_BARRIER))] |
| 8229 |
"" |
| 8230 |
" |
| 8231 |
{ |
| 8232 |
if (operands[2] == const0_rtx) |
| 8233 |
{ |
| 8234 |
rtx tracker; |
| 8235 |
if (<MODE>mode == TImode) |
| 8236 |
tracker = gen_rtx_REG (DImode, SPECULATION_TRACKER_REGNUM); |
| 8237 |
else |
| 8238 |
tracker = gen_rtx_REG (<MODE>mode, SPECULATION_TRACKER_REGNUM); |
| 8239 |
|
| 8240 |
emit_insn (gen_despeculate_simple<mode> (operands[0], operands[1], |
| 8241 |
tracker)); |
| 8242 |
DONE; |
| 8243 |
} |
| 8244 |
} |
| 8245 |
" |
| 8246 |
) |
| 8247 |
|
| 8248 |
;; Patterns to match despeculate_copy<mode>. Note that "hint 0x14" is the |
| 8249 |
;; encoding for CSDB, but will work in older versions of the assembler. |
| 8250 |
(define_insn "*despeculate_copy<ALLI:mode>_insn" |
| 8251 |
[(set (match_operand:ALLI 0 "register_operand" "=r") |
| 8252 |
(unspec_volatile:ALLI |
| 8253 |
[(match_operand:ALLI 1 "register_operand" "r") |
| 8254 |
(match_operand:ALLI 2 "aarch64_reg_or_zero" "rZ") |
| 8255 |
(use (reg:DI SPECULATION_TRACKER_REGNUM)) |
| 8256 |
(clobber (reg:CC CC_REGNUM))] UNSPECV_SPECULATION_BARRIER))] |
| 8257 |
"" |
| 8258 |
{ |
| 8259 |
operands[3] = gen_rtx_REG (DImode, SPECULATION_TRACKER_REGNUM); |
| 8260 |
output_asm_insn ("cmp\\t%3, #0\;csel\\t%<w>0, %<w>1, %<w>2, ne\;hint\t0x14 // csdb", |
| 8261 |
operands); |
| 8262 |
return ""; |
| 8263 |
} |
| 8264 |
[(set_attr "length" "12") |
| 8265 |
(set_attr "type" "block") |
| 8266 |
(set_attr "speculation_barrier" "true")] |
| 8267 |
) |
| 8268 |
|
| 8269 |
;; Pattern to match despeculate_copyti |
| 8270 |
(define_insn "*despeculate_copyti_insn" |
| 8271 |
[(set (match_operand:TI 0 "register_operand" "=r") |
| 8272 |
(unspec_volatile:TI |
| 8273 |
[(match_operand:TI 1 "register_operand" "r") |
| 8274 |
(match_operand:TI 2 "aarch64_reg_or_zero" "rZ") |
| 8275 |
(use (reg:DI SPECULATION_TRACKER_REGNUM)) |
| 8276 |
(clobber (reg:CC CC_REGNUM))] UNSPECV_SPECULATION_BARRIER))] |
| 8277 |
"" |
| 8278 |
{ |
| 8279 |
operands[3] = gen_rtx_REG (DImode, SPECULATION_TRACKER_REGNUM); |
| 8280 |
output_asm_insn |
| 8281 |
("cmp\\t%3, #0\;csel\\t%0, %1, %2, ne\;csel\\t%H0, %H1, %H2, ne\;hint\t0x14 // csdb", |
| 8282 |
operands); |
| 8283 |
return ""; |
| 8284 |
} |
| 8285 |
[(set_attr "length" "16") |
| 8286 |
(set_attr "type" "block") |
| 8287 |
(set_attr "speculation_barrier" "true")] |
| 8288 |
) |
| 8289 |
|
| 8290 |
(define_insn "despeculate_simple<ALLI:mode>" |
| 8291 |
[(set (match_operand:ALLI 0 "register_operand" "=r") |
| 8292 |
(unspec_volatile:ALLI |
| 8293 |
[(match_operand:ALLI 1 "register_operand" "r") |
| 8294 |
(use (match_operand:ALLI 2 "register_operand" ""))] |
| 8295 |
UNSPECV_SPECULATION_BARRIER))] |
| 8296 |
"" |
| 8297 |
"and\\t%<w>0, %<w>1, %<w>2\;hint\t0x14 // csdb" |
| 8298 |
[(set_attr "type" "block") |
| 8299 |
(set_attr "length" "8") |
| 8300 |
(set_attr "speculation_barrier" "true")] |
| 8301 |
) |
| 8302 |
|
| 8303 |
(define_insn "despeculate_simpleti" |
| 8304 |
[(set (match_operand:TI 0 "register_operand" "=r") |
| 8305 |
(unspec_volatile:TI |
| 8306 |
[(match_operand:TI 1 "register_operand" "r") |
| 8307 |
(use (match_operand:DI 2 "register_operand" ""))] |
| 8308 |
UNSPECV_SPECULATION_BARRIER))] |
| 8309 |
"" |
| 8310 |
"and\\t%0, %1, %2\;and\\t%H0, %H1, %2\;hint\t0x14 // csdb" |
| 8311 |
[(set_attr "type" "block") |
| 8312 |
(set_attr "length" "12") |
| 8313 |
(set_attr "speculation_barrier" "true")] |
| 8314 |
) |
| 8315 |
|
| 8316 |
(define_insn "aarch64_<frintnzs_op><mode>" |
| 8317 |
[(set (match_operand:VSFDF 0 "register_operand" "=w") |
| 8318 |
(unspec:VSFDF [(match_operand:VSFDF 1 "register_operand" "w")] |
| 8319 |
FRINTNZX))] |
| 8320 |
"TARGET_FRINT && TARGET_FLOAT |
| 8321 |
&& !(VECTOR_MODE_P (<MODE>mode) && !TARGET_SIMD)" |
| 8322 |
"<frintnzs_op>\\t%<v>0<Vmtype>, %<v>1<Vmtype>" |
| 8323 |
[(set_attr "type" "f_rint<stype>")] |
| 8324 |
) |
| 8325 |
|
| 8326 |
;; Transactional Memory Extension (TME) instructions. |
| 8327 |
|
| 8328 |
(define_insn "tstart" |
| 8329 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 8330 |
(unspec_volatile:DI [(const_int 0)] UNSPECV_TSTART)) |
| 8331 |
(clobber (mem:BLK (scratch)))] |
| 8332 |
"TARGET_TME" |
| 8333 |
"tstart\\t%0" |
| 8334 |
[(set_attr "type" "tme")] |
| 8335 |
) |
| 8336 |
|
| 8337 |
(define_insn "ttest" |
| 8338 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 8339 |
(unspec_volatile:DI [(const_int 0)] UNSPEC_TTEST)) |
| 8340 |
(clobber (mem:BLK (scratch)))] |
| 8341 |
"TARGET_TME" |
| 8342 |
"ttest\\t%0" |
| 8343 |
[(set_attr "type" "tme")] |
| 8344 |
) |
| 8345 |
|
| 8346 |
(define_insn "tcommit" |
| 8347 |
[(unspec_volatile:BLK [(const_int 0)] UNSPECV_TCOMMIT) |
| 8348 |
(clobber (mem:BLK (scratch)))] |
| 8349 |
"TARGET_TME" |
| 8350 |
"tcommit" |
| 8351 |
[(set_attr "type" "tme")] |
| 8352 |
) |
| 8353 |
|
| 8354 |
(define_insn "tcancel" |
| 8355 |
[(unspec_volatile:BLK |
| 8356 |
[(match_operand 0 "const_int_operand" "n")] UNSPECV_TCANCEL) |
| 8357 |
(clobber (mem:BLK (scratch)))] |
| 8358 |
"TARGET_TME && (UINTVAL (operands[0]) <= 65535)" |
| 8359 |
"tcancel\\t#%0" |
| 8360 |
[(set_attr "type" "tme")] |
| 8361 |
) |
| 8362 |
|
| 8363 |
(define_insn "aarch64_rndr" |
| 8364 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 8365 |
(unspec_volatile:DI [(const_int 0)] UNSPEC_RNDR)) |
| 8366 |
(set (reg:CC_Z CC_REGNUM) |
| 8367 |
(unspec_volatile:CC_Z [(const_int 0)] UNSPEC_RNDR))] |
| 8368 |
"TARGET_RNG" |
| 8369 |
"mrs\t%0, RNDR" |
| 8370 |
[(set_attr "type" "mrs")] |
| 8371 |
) |
| 8372 |
|
| 8373 |
(define_insn "aarch64_rndrrs" |
| 8374 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 8375 |
(unspec_volatile:DI [(const_int 0)] UNSPEC_RNDRRS)) |
| 8376 |
(set (reg:CC_Z CC_REGNUM) |
| 8377 |
(unspec_volatile:CC_Z [(const_int 0)] UNSPEC_RNDRRS))] |
| 8378 |
"TARGET_RNG" |
| 8379 |
"mrs\t%0, RNDRRS" |
| 8380 |
[(set_attr "type" "mrs")] |
| 8381 |
) |
| 8382 |
|
| 8383 |
;; Memory Tagging Extension (MTE) instructions. |
| 8384 |
|
| 8385 |
(define_insn "irg" |
| 8386 |
[(set (match_operand:DI 0 "register_operand" "=rk") |
| 8387 |
(ior:DI |
| 8388 |
(and:DI (match_operand:DI 1 "register_operand" "rk") |
| 8389 |
(const_int -1080863910568919041)) ;; 0xf0ff... |
| 8390 |
(ashift:DI (unspec:QI [(match_operand:DI 2 "register_operand" "r")] |
| 8391 |
UNSPEC_GEN_TAG_RND) |
| 8392 |
(const_int 56))))] |
| 8393 |
"TARGET_MEMTAG" |
| 8394 |
"irg\\t%0, %1, %2" |
| 8395 |
[(set_attr "type" "memtag")] |
| 8396 |
) |
| 8397 |
|
| 8398 |
(define_insn "gmi" |
| 8399 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 8400 |
(ior:DI (ashift:DI |
| 8401 |
(const_int 1) |
| 8402 |
(and:QI (lshiftrt:DI |
| 8403 |
(match_operand:DI 1 "register_operand" "rk") |
| 8404 |
(const_int 56)) (const_int 15))) |
| 8405 |
(match_operand:DI 2 "register_operand" "r")))] |
| 8406 |
"TARGET_MEMTAG" |
| 8407 |
"gmi\\t%0, %1, %2" |
| 8408 |
[(set_attr "type" "memtag")] |
| 8409 |
) |
| 8410 |
|
| 8411 |
(define_insn "addg" |
| 8412 |
[(set (match_operand:DI 0 "register_operand" "=rk") |
| 8413 |
(ior:DI |
| 8414 |
(and:DI (plus:DI (match_operand:DI 1 "register_operand" "rk") |
| 8415 |
(match_operand:DI 2 "aarch64_granule16_uimm6" "i")) |
| 8416 |
(const_int -1080863910568919041)) ;; 0xf0ff... |
| 8417 |
(ashift:DI |
| 8418 |
(unspec:QI |
| 8419 |
[(and:QI (lshiftrt:DI (match_dup 1) (const_int 56)) (const_int 15)) |
| 8420 |
(match_operand:QI 3 "aarch64_memtag_tag_offset" "i")] |
| 8421 |
UNSPEC_GEN_TAG) |
| 8422 |
(const_int 56))))] |
| 8423 |
"TARGET_MEMTAG" |
| 8424 |
"addg\\t%0, %1, #%2, #%3" |
| 8425 |
[(set_attr "type" "memtag")] |
| 8426 |
) |
| 8427 |
|
| 8428 |
(define_insn "subp" |
| 8429 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 8430 |
(minus:DI |
| 8431 |
(and:DI (match_operand:DI 1 "register_operand" "rk") |
| 8432 |
(const_int 72057594037927935)) ;; 0x00ff... |
| 8433 |
(and:DI (match_operand:DI 2 "register_operand" "rk") |
| 8434 |
(const_int 72057594037927935))))] ;; 0x00ff... |
| 8435 |
"TARGET_MEMTAG" |
| 8436 |
"subp\\t%0, %1, %2" |
| 8437 |
[(set_attr "type" "memtag")] |
| 8438 |
) |
| 8439 |
|
| 8440 |
;; LDG will use the 16-byte aligned value of the address. |
| 8441 |
(define_insn "ldg" |
| 8442 |
[(set (match_operand:DI 0 "register_operand" "+r") |
| 8443 |
(ior:DI |
| 8444 |
(and:DI (match_dup 0) (const_int -1080863910568919041)) ;; 0xf0ff... |
| 8445 |
(ashift:DI |
| 8446 |
(mem:QI (unspec:DI |
| 8447 |
[(and:DI (plus:DI (match_operand:DI 1 "register_operand" "rk") |
| 8448 |
(match_operand:DI 2 "aarch64_granule16_simm9" "i")) |
| 8449 |
(const_int -16))] UNSPEC_TAG_SPACE)) |
| 8450 |
(const_int 56))))] |
| 8451 |
"TARGET_MEMTAG" |
| 8452 |
"ldg\\t%0, [%1, #%2]" |
| 8453 |
[(set_attr "type" "memtag")] |
| 8454 |
) |
| 8455 |
|
| 8456 |
;; STG doesn't align the address but aborts with alignment fault |
| 8457 |
;; when the address is not 16-byte aligned. |
| 8458 |
(define_insn "stg" |
| 8459 |
[(set (mem:QI (unspec:DI |
| 8460 |
[(plus:DI (match_operand:DI 1 "register_operand" "rk") |
| 8461 |
(match_operand:DI 2 "aarch64_granule16_simm9" "i"))] |
| 8462 |
UNSPEC_TAG_SPACE)) |
| 8463 |
(and:QI (lshiftrt:DI (match_operand:DI 0 "register_operand" "rk") |
| 8464 |
(const_int 56)) (const_int 15)))] |
| 8465 |
"TARGET_MEMTAG" |
| 8466 |
"stg\\t%0, [%1, #%2]" |
| 8467 |
[(set_attr "type" "memtag")] |
| 8468 |
) |
| 8469 |
|
| 8470 |
;; Load/Store 64-bit (LS64) instructions. |
| 8471 |
(define_insn "ld64b" |
| 8472 |
[(set (match_operand:V8DI 0 "register_operand" "=r") |
| 8473 |
(unspec_volatile:V8DI |
| 8474 |
[(mem:V8DI (match_operand:DI 1 "register_operand" "r"))] |
| 8475 |
UNSPEC_LD64B) |
| 8476 |
)] |
| 8477 |
"TARGET_LS64" |
| 8478 |
"ld64b\\t%0, [%1]" |
| 8479 |
[(set_attr "type" "ls64")] |
| 8480 |
) |
| 8481 |
|
| 8482 |
(define_insn "st64b" |
| 8483 |
[(set (mem:V8DI (match_operand:DI 0 "register_operand" "r")) |
| 8484 |
(unspec_volatile:V8DI [(match_operand:V8DI 1 "register_operand" "r")] |
| 8485 |
UNSPEC_ST64B) |
| 8486 |
)] |
| 8487 |
"TARGET_LS64" |
| 8488 |
"st64b\\t%1, [%0]" |
| 8489 |
[(set_attr "type" "ls64")] |
| 8490 |
) |
| 8491 |
|
| 8492 |
(define_insn "st64bv" |
| 8493 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 8494 |
(unspec_volatile:DI [(const_int 0)] UNSPEC_ST64BV_RET)) |
| 8495 |
(set (mem:V8DI (match_operand:DI 1 "register_operand" "r")) |
| 8496 |
(unspec_volatile:V8DI [(match_operand:V8DI 2 "register_operand" "r")] |
| 8497 |
UNSPEC_ST64BV) |
| 8498 |
)] |
| 8499 |
"TARGET_LS64" |
| 8500 |
"st64bv\\t%0, %2, [%1]" |
| 8501 |
[(set_attr "type" "ls64")] |
| 8502 |
) |
| 8503 |
|
| 8504 |
(define_insn "st64bv0" |
| 8505 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 8506 |
(unspec_volatile:DI [(const_int 0)] UNSPEC_ST64BV0_RET)) |
| 8507 |
(set (mem:V8DI (match_operand:DI 1 "register_operand" "r")) |
| 8508 |
(unspec_volatile:V8DI [(match_operand:V8DI 2 "register_operand" "r")] |
| 8509 |
UNSPEC_ST64BV0) |
| 8510 |
)] |
| 8511 |
"TARGET_LS64" |
| 8512 |
"st64bv0\\t%0, %2, [%1]" |
| 8513 |
[(set_attr "type" "ls64")] |
| 8514 |
) |
| 8515 |
|
| 8516 |
(define_insn "patchable_area" |
| 8517 |
[(unspec_volatile [(match_operand 0 "const_int_operand") |
| 8518 |
(match_operand 1 "const_int_operand")] |
| 8519 |
UNSPECV_PATCHABLE_AREA)] |
| 8520 |
"" |
| 8521 |
{ |
| 8522 |
aarch64_output_patchable_area (INTVAL (operands[0]), |
| 8523 |
INTVAL (operands[1]) != 0); |
| 8524 |
return ""; |
| 8525 |
} |
| 8526 |
[(set (attr "length") (symbol_ref "INTVAL (operands[0])"))] |
| 8527 |
) |
| 8528 |
|
| 8529 |
(define_insn "aarch64_save_nzcv" |
| 8530 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 8531 |
(unspec:DI [(reg:CC CC_REGNUM)] UNSPEC_SAVE_NZCV))] |
| 8532 |
"" |
| 8533 |
"mrs\t%0, nzcv" |
| 8534 |
) |
| 8535 |
|
| 8536 |
(define_insn "aarch64_restore_nzcv" |
| 8537 |
[(set (reg:CC CC_REGNUM) |
| 8538 |
(unspec:CC [(match_operand:DI 0 "register_operand" "r")] |
| 8539 |
UNSPEC_RESTORE_NZCV))] |
| 8540 |
"" |
| 8541 |
"msr\tnzcv, %0" |
| 8542 |
) |
| 8543 |
|
| 8544 |
;; CHKFEAT instruction |
| 8545 |
(define_insn "aarch64_chkfeat" |
| 8546 |
[(set (reg:DI R16_REGNUM) |
| 8547 |
(unspec_volatile:DI [(reg:DI R16_REGNUM)] UNSPECV_CHKFEAT))] |
| 8548 |
"" |
| 8549 |
"hint\\t40 // chkfeat x16" |
| 8550 |
) |
| 8551 |
|
| 8552 |
;; Guarded Control Stack (GCS) instructions |
| 8553 |
(define_insn "aarch64_load_gcspr" |
| 8554 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 8555 |
(unspec_volatile:DI [(const_int 0)] UNSPECV_GCSPR))] |
| 8556 |
"" |
| 8557 |
"mrs\\t%0, s3_3_c2_c5_1 // gcspr_el0" |
| 8558 |
[(set_attr "type" "mrs")] |
| 8559 |
) |
| 8560 |
|
| 8561 |
(define_insn "aarch64_gcspopm" |
| 8562 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 8563 |
(unspec_volatile:DI [(match_operand:DI 1 "register_operand" "0")] UNSPECV_GCSPOPM))] |
| 8564 |
"" |
| 8565 |
"sysl\\t%0, #3, c7, c7, #1 // gcspopm" |
| 8566 |
) |
| 8567 |
|
| 8568 |
(define_insn "aarch64_gcspopm_xzr" |
| 8569 |
[(unspec_volatile [(const_int 0)] UNSPECV_GCSPOPM)] |
| 8570 |
"" |
| 8571 |
"sysl\\txzr, #3, c7, c7, #1 // gcspopm" |
| 8572 |
) |
| 8573 |
|
| 8574 |
(define_insn "aarch64_gcsss1" |
| 8575 |
[(unspec_volatile [(match_operand:DI 0 "register_operand" "r")] UNSPECV_GCSSS1)] |
| 8576 |
"" |
| 8577 |
"sys\\t#3, c7, c7, #2, %0 // gcsss1" |
| 8578 |
) |
| 8579 |
|
| 8580 |
(define_insn "aarch64_gcsss2" |
| 8581 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 8582 |
(unspec_volatile:DI [(match_operand:DI 1 "register_operand" "0")] UNSPECV_GCSSS2))] |
| 8583 |
"" |
| 8584 |
"sysl\\t%0, #3, c7, c7, #3 // gcsss2" |
| 8585 |
) |
| 8586 |
|
| 8587 |
;; AdvSIMD Stuff |
| 8588 |
(include "aarch64-simd.md") |
| 8589 |
|
| 8590 |
;; Atomic Operations |
| 8591 |
(include "atomics.md") |
| 8592 |
|
| 8593 |
;; ldp/stp peephole patterns |
| 8594 |
(include "aarch64-ldpstp.md") |
| 8595 |
|
| 8596 |
;; SVE. |
| 8597 |
(include "aarch64-sve.md") |
| 8598 |
|
| 8599 |
;; SVE2. |
| 8600 |
(include "aarch64-sve2.md") |
| 8601 |
|
| 8602 |
;; SME and extensions |
| 8603 |
(include "aarch64-sme.md") |