1 ;; Generic DFA-based pipeline description for LoongArch targets
2 ;; Copyright (C) 2021-2025 Free Software Foundation, Inc.
3 ;; Contributed by Loongson Ltd.
4 ;; Based on MIPS target for GNU compiler.
6 ;; This file is part of GCC.
8 ;; GCC is free software; you can redistribute it and/or modify it
9 ;; under the terms of the GNU General Public License as published
10 ;; by the Free Software Foundation; either version 3, or (at your
11 ;; option) any later version.
13 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
14 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16 ;; License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GCC; see the file COPYING3. If not see
20 ;; <http://www.gnu.org/licenses/>.
22 (define_automaton "alu,imuldiv")
24 (define_cpu_unit "alu" "alu")
25 (define_cpu_unit "imuldiv" "imuldiv")
27 ;; Ghost instructions produce no real code.
28 ;; They exist purely to express an effect on dataflow.
29 (define_insn_reservation "ghost" 0
30 (eq_attr "type" "ghost")
33 (define_insn_reservation "generic_alu" 1
34 (eq_attr "type" "unknown,prefetch,prefetchx,condmove,const,arith,
35 shift,slt,clz,trap,multi,nop,logical,signext,move")
38 (define_insn_reservation "generic_load" 3
39 (eq_attr "type" "load,fpload,fpidxload")
42 (define_insn_reservation "generic_store" 1
43 (eq_attr "type" "store,fpstore,fpidxstore")
46 (define_insn_reservation "generic_xfer" 2
47 (eq_attr "type" "mftg,mgtf")
50 (define_insn_reservation "generic_branch" 1
51 (eq_attr "type" "branch,jump,call")
54 (define_insn_reservation "generic_imul" 17
55 (eq_attr "type" "imul")
58 (define_insn_reservation "generic_fcvt" 1
59 (eq_attr "type" "fcvt")
62 (define_insn_reservation "generic_fmove" 2
63 (eq_attr "type" "fabs,fneg,fmove")
66 (define_insn_reservation "generic_fcmp" 3
67 (eq_attr "type" "fcmp")
70 (define_insn_reservation "generic_fadd" 4
71 (eq_attr "type" "fadd")
74 (define_insn_reservation "generic_fmul_single" 7
75 (and (eq_attr "type" "fmul,fmadd")
76 (eq_attr "mode" "SF"))
79 (define_insn_reservation "generic_fmul_double" 8
80 (and (eq_attr "type" "fmul,fmadd")
81 (eq_attr "mode" "DF"))
84 (define_insn_reservation "generic_fdiv_single" 23
85 (and (eq_attr "type" "fdiv,frdiv")
86 (eq_attr "mode" "SF"))
89 (define_insn_reservation "generic_fdiv_double" 36
90 (and (eq_attr "type" "fdiv,frdiv")
91 (eq_attr "mode" "DF"))
94 (define_insn_reservation "generic_fsqrt_single" 54
95 (and (eq_attr "type" "fsqrt,frsqrt")
96 (eq_attr "mode" "SF"))
99 (define_insn_reservation "generic_fsqrt_double" 112
100 (and (eq_attr "type" "fsqrt,frsqrt")
101 (eq_attr "mode" "DF"))
104 (define_insn_reservation "generic_atomic" 10
105 (eq_attr "type" "atomic")
108 ;; Sync loop consists of (in order)
109 ;; (1) optional sync,
110 ;; (2) LL instruction,
111 ;; (3) branch and 1-2 ALU instructions,
112 ;; (4) SC instruction,
113 ;; (5) branch and ALU instruction.
114 ;; The net result of this reservation is a big delay with a flush of
116 (define_insn_reservation "generic_sync_loop" 40
117 (eq_attr "type" "syncloop")