| 1 |
;; Copyright (C) 2024-2025 Free Software Foundation, Inc. |
| 2 |
|
| 3 |
;; This file is part of GCC. |
| 4 |
|
| 5 |
;; GCC is free software; you can redistribute it and/or modify it |
| 6 |
;; under the terms of the GNU General Public License as published |
| 7 |
;; by the Free Software Foundation; either version 3, or (at your |
| 8 |
;; option) any later version. |
| 9 |
|
| 10 |
;; GCC is distributed in the hope that it will be useful, but WITHOUT |
| 11 |
;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 12 |
;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public |
| 13 |
;; License for more details. |
| 14 |
|
| 15 |
;; You should have received a copy of the GNU General Public License |
| 16 |
;; along with GCC; see the file COPYING3. If not see |
| 17 |
;; <http://www.gnu.org/licenses/>. |
| 18 |
;; Vector load/store |
| 19 |
|
| 20 |
(define_automaton "vector_ooo") |
| 21 |
|
| 22 |
;; Separate issue queue for vector instructions. |
| 23 |
(define_cpu_unit "vxu_ooo_issue" "vector_ooo") |
| 24 |
|
| 25 |
;; Vector execution unit. |
| 26 |
(define_cpu_unit "vxu_ooo_alu" "vector_ooo") |
| 27 |
|
| 28 |
;; Vector subunit that does mult/div/sqrt. |
| 29 |
(define_cpu_unit "vxu_ooo_multicycle" "vector_ooo") |
| 30 |
|
| 31 |
(define_insn_reservation "vec_load" 6 |
| 32 |
(eq_attr "type" "vlde,vldm,vlds,vldux,vldox,vldff,vldr") |
| 33 |
"vxu_ooo_issue,vxu_ooo_alu") |
| 34 |
|
| 35 |
(define_insn_reservation "vec_store" 6 |
| 36 |
(eq_attr "type" "vste,vstm,vsts,vstux,vstox,vstr") |
| 37 |
"vxu_ooo_issue,vxu_ooo_alu") |
| 38 |
|
| 39 |
;; Vector segment loads/stores. |
| 40 |
(define_insn_reservation "vec_loadstore_seg" 10 |
| 41 |
(eq_attr "type" "vlsegde,vlsegds,vlsegdux,vlsegdox,vlsegdff,\ |
| 42 |
vssegte,vssegts,vssegtux,vssegtox") |
| 43 |
"vxu_ooo_issue,vxu_ooo_alu") |
| 44 |
|
| 45 |
;; Regular vector operations and integer comparisons. |
| 46 |
(define_insn_reservation "vec_alu" 3 |
| 47 |
(eq_attr "type" "vialu,viwalu,vext,vicalu,vshift,vnshift,viminmax,vicmp,\ |
| 48 |
vimov,vsalu,vaalu,vsshift,vnclip,vmov,vfmov,vector,\ |
| 49 |
vandn,vbrev,vbrev8,vrev8,vclz,vctz,vrol,vror,vwsll") |
| 50 |
"vxu_ooo_issue,vxu_ooo_alu") |
| 51 |
|
| 52 |
;; Vector float comparison, conversion etc. |
| 53 |
(define_insn_reservation "vec_fcmp" 3 |
| 54 |
(eq_attr "type" "vfrecp,vfminmax,vfcmp,vfsgnj,vfclass,vfcvtitof,\ |
| 55 |
vfcvtftoi,vfwcvtitof,vfwcvtftoi,vfwcvtftof,vfncvtitof,\ |
| 56 |
vfncvtftoi,vfncvtftof,vfncvtbf16,vfwcvtbf16") |
| 57 |
"vxu_ooo_issue,vxu_ooo_alu") |
| 58 |
|
| 59 |
;; Vector integer multiplication. |
| 60 |
(define_insn_reservation "vec_imul" 4 |
| 61 |
(eq_attr "type" "vimul,viwmul,vimuladd,viwmuladd,vsmul,vclmul,vclmulh,\ |
| 62 |
vghsh,vgmul") |
| 63 |
"vxu_ooo_issue,vxu_ooo_alu") |
| 64 |
|
| 65 |
;; Vector float addition. |
| 66 |
(define_insn_reservation "vec_fadd" 4 |
| 67 |
(eq_attr "type" "vfalu,vfwalu") |
| 68 |
"vxu_ooo_issue,vxu_ooo_alu") |
| 69 |
|
| 70 |
;; Vector float multiplication and FMA. |
| 71 |
(define_insn_reservation "vec_fmul" 6 |
| 72 |
(eq_attr "type" "vfmul,vfwmul,vfmuladd,vfwmuladd,vfwmaccbf16,sf_vqmacc,sf_vfnrclip") |
| 73 |
"vxu_ooo_issue,vxu_ooo_alu") |
| 74 |
|
| 75 |
;; Vector crypto, assumed to be a generic operation for now. |
| 76 |
(define_insn_reservation "vec_crypto" 4 |
| 77 |
(eq_attr "type" "crypto,vclz,vctz,vcpop") |
| 78 |
"vxu_ooo_issue,vxu_ooo_alu") |
| 79 |
|
| 80 |
;; Vector crypto, AES |
| 81 |
(define_insn_reservation "vec_crypto_aes" 4 |
| 82 |
(eq_attr "type" "vaesef,vaesem,vaesdf,vaesdm,vaeskf1,vaeskf2,vaesz") |
| 83 |
"vxu_ooo_issue,vxu_ooo_alu") |
| 84 |
|
| 85 |
;; Vector crypto, sha |
| 86 |
(define_insn_reservation "vec_crypto_sha" 4 |
| 87 |
(eq_attr "type" "vsha2ms,vsha2ch,vsha2cl") |
| 88 |
"vxu_ooo_issue,vxu_ooo_alu") |
| 89 |
|
| 90 |
;; Vector crypto, SM3/4 |
| 91 |
(define_insn_reservation "vec_crypto_sm" 4 |
| 92 |
(eq_attr "type" "vsm4k,vsm4r,vsm3me,vsm3c") |
| 93 |
"vxu_ooo_issue,vxu_ooo_alu") |
| 94 |
|
| 95 |
;; Vector permute. |
| 96 |
(define_insn_reservation "vec_perm" 3 |
| 97 |
(eq_attr "type" "vimerge,vfmerge,vslideup,vslidedown,vislide1up,\ |
| 98 |
vislide1down,vfslide1up,vfslide1down,vgather,vcompress") |
| 99 |
"vxu_ooo_issue,vxu_ooo_alu") |
| 100 |
|
| 101 |
;; Vector reduction. |
| 102 |
(define_insn_reservation "vec_reduction" 8 |
| 103 |
(eq_attr "type" "vired,viwred,vfredu,vfwredu") |
| 104 |
"vxu_ooo_issue,vxu_ooo_multicycle") |
| 105 |
|
| 106 |
;; Vector ordered reduction, assume the latency number is for |
| 107 |
;; a 128-bit vector. It is scaled in riscv_sched_adjust_cost |
| 108 |
;; for larger vectors. |
| 109 |
(define_insn_reservation "vec_ordered_reduction" 10 |
| 110 |
(eq_attr "type" "vfredo,vfwredo") |
| 111 |
"vxu_ooo_issue,vxu_ooo_multicycle*3") |
| 112 |
|
| 113 |
;; Vector integer division, assume not pipelined. |
| 114 |
(define_insn_reservation "vec_idiv" 16 |
| 115 |
(eq_attr "type" "vidiv") |
| 116 |
"vxu_ooo_issue,vxu_ooo_multicycle*3") |
| 117 |
|
| 118 |
;; Vector float divisions and sqrt, assume not pipelined. |
| 119 |
(define_insn_reservation "vec_float_divsqrt" 16 |
| 120 |
(eq_attr "type" "vfdiv,vfsqrt") |
| 121 |
"vxu_ooo_issue,vxu_ooo_multicycle*3") |
| 122 |
|
| 123 |
;; Vector mask operations. |
| 124 |
(define_insn_reservation "vec_mask" 2 |
| 125 |
(eq_attr "type" "vmalu,vmpop,vmffs,vmsfs,vmiota,vmidx,vimovvx,vimovxv,\ |
| 126 |
vfmovvf,vfmovfv") |
| 127 |
"vxu_ooo_issue,vxu_ooo_alu") |
| 128 |
|
| 129 |
;; Vector vsetvl. |
| 130 |
(define_insn_reservation "vec_vesetvl" 1 |
| 131 |
(eq_attr "type" "vsetvl,vsetvl_pre") |
| 132 |
"vxu_ooo_issue") |
| 133 |
|
| 134 |
;; Vector rounding mode setters, assume pipeline barrier. |
| 135 |
(define_insn_reservation "vec_setrm" 20 |
| 136 |
(eq_attr "type" "wrvxrm,wrfrm") |
| 137 |
"vxu_ooo_issue,vxu_ooo_issue*3") |
| 138 |
|
| 139 |
;; Vector read vlen/vlenb. |
| 140 |
(define_insn_reservation "vec_readlen" 4 |
| 141 |
(eq_attr "type" "rdvlenb,rdvl") |
| 142 |
"vxu_ooo_issue,vxu_ooo_issue") |
| 143 |
|