Home | History | Annotate | Line # | Download | only in sh
      1   1.1  mrg ;; DFA scheduling description for ST40-300.
      2  1.12  mrg ;; Copyright (C) 2004-2022 Free Software Foundation, Inc.
      3   1.1  mrg 
      4   1.1  mrg ;; This file is part of GCC.
      5   1.1  mrg 
      6   1.1  mrg ;; GCC is free software; you can redistribute it and/or modify
      7   1.1  mrg ;; it under the terms of the GNU General Public License as published by
      8   1.1  mrg ;; the Free Software Foundation; either version 3, or (at your option)
      9   1.1  mrg ;; any later version.
     10   1.1  mrg 
     11   1.1  mrg ;; GCC is distributed in the hope that it will be useful,
     12   1.1  mrg ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
     13   1.1  mrg ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14   1.1  mrg ;; GNU General Public License for more details.
     15   1.1  mrg 
     16   1.1  mrg ;; You should have received a copy of the GNU General Public License
     17   1.1  mrg ;; along with GCC; see the file COPYING3.  If not see
     18   1.1  mrg ;; <http://www.gnu.org/licenses/>.
     19   1.1  mrg 
     20   1.1  mrg ;; Load and store instructions save a cycle if they are aligned on a
     21   1.1  mrg ;; four byte boundary.  Using a function unit for stores encourages
     22   1.1  mrg ;; gcc to separate load and store instructions by one instruction,
     23   1.1  mrg ;; which makes it more likely that the linker will be able to word
     24   1.1  mrg ;; align them when relaxing.
     25   1.1  mrg 
     26   1.1  mrg ;; The following description models the ST40-300 pipeline using the DFA based
     27   1.1  mrg ;; scheduler.
     28   1.1  mrg 
     29   1.1  mrg ;; Two automata are defined to reduce number of states
     30   1.1  mrg ;; which a single large automaton will have. (Factoring)
     31   1.1  mrg 
     32   1.1  mrg (define_automaton "sh4_300_inst_pipeline,sh4_300_fpu_pipe")
     33   1.1  mrg 
     34   1.1  mrg ;; This unit is basically the decode unit of the processor.
     35   1.1  mrg ;; Since SH4 is a dual issue machine,it is as if there are two
     36   1.1  mrg ;; units so that any insn can be processed by either one
     37   1.1  mrg ;; of the decoding unit.
     38   1.1  mrg (define_cpu_unit "sh4_300_pipe_01,sh4_300_pipe_02" "sh4_300_inst_pipeline")
     39   1.1  mrg 
     40   1.1  mrg ;; The floating point units.
     41   1.1  mrg (define_cpu_unit "sh4_300_fpt,sh4_300_fpu,sh4_300_fds" "sh4_300_fpu_pipe")
     42   1.1  mrg 
     43   1.1  mrg ;; integer multiplier unit
     44   1.1  mrg (define_cpu_unit "sh4_300_mul" "sh4_300_inst_pipeline")
     45   1.1  mrg 
     46   1.1  mrg ;; LS unit
     47   1.1  mrg (define_cpu_unit "sh4_300_ls" "sh4_300_inst_pipeline")
     48   1.1  mrg 
     49   1.1  mrg ;; The address calculator used for branch instructions.
     50   1.1  mrg ;; This will be reserved after "issue" of branch instructions
     51   1.1  mrg ;; and this is to make sure that no two branch instructions
     52   1.1  mrg ;; can be issued in parallel.
     53   1.1  mrg (define_cpu_unit "sh4_300_br" "sh4_300_inst_pipeline")
     54   1.1  mrg 
     55   1.1  mrg ;; ----------------------------------------------------
     56   1.1  mrg ;; This reservation is to simplify the dual issue description.
     57   1.1  mrg 
     58   1.1  mrg (define_reservation  "sh4_300_issue"  "sh4_300_pipe_01|sh4_300_pipe_02")
     59   1.1  mrg 
     60   1.1  mrg (define_reservation "all" "sh4_300_pipe_01+sh4_300_pipe_02")
     61   1.1  mrg 
     62   1.1  mrg ;;(define_insn_reservation "nil" 0 (eq_attr "type" "nil") "nothing")
     63   1.1  mrg 
     64   1.1  mrg ;; MOV RM,RN / MOV #imm8,RN / STS PR,RN
     65   1.1  mrg (define_insn_reservation "sh4_300_mov" 0
     66   1.1  mrg   (and (eq_attr "pipe_model" "sh4_300")
     67   1.1  mrg        (eq_attr "type" "move,movi8,prget"))
     68   1.1  mrg   "sh4_300_issue")
     69   1.1  mrg 
     70   1.1  mrg ;; Fixed STS from MACL / MACH
     71   1.1  mrg (define_insn_reservation "sh4_300_mac_gp" 0
     72   1.1  mrg   (and (eq_attr "pipe_model" "sh4_300")
     73   1.1  mrg        (eq_attr "type" "mac_gp"))
     74   1.1  mrg   "sh4_300_issue+sh4_300_mul")
     75   1.1  mrg 
     76   1.1  mrg ;; Fixed LDS to MACL / MACH
     77   1.1  mrg (define_insn_reservation "sh4_300_gp_mac" 1
     78   1.1  mrg   (and (eq_attr "pipe_model" "sh4_300")
     79   1.1  mrg        (eq_attr "type" "gp_mac"))
     80   1.1  mrg   "sh4_300_issue+sh4_300_mul")
     81   1.1  mrg 
     82   1.1  mrg ;; Instructions without specific resource requirements with latency 1.
     83   1.1  mrg (define_insn_reservation "sh4_300_simple_arith" 1
     84   1.1  mrg   (and (eq_attr "pipe_model" "sh4_300")
     85   1.1  mrg        (eq_attr "type" "mt_group,arith,dyn_shift,prset"))
     86   1.1  mrg   "sh4_300_issue")
     87   1.1  mrg 
     88   1.1  mrg ;; Load and store instructions have no alignment peculiarities for the ST40-300,
     89   1.1  mrg ;; but they use the load-store unit, which they share with the fmove type
     90   1.1  mrg ;; insns (fldi[01]; fmov frn,frm; flds; fsts; fabs; fneg) .
     91   1.1  mrg ;; Loads have a latency of three.
     92   1.1  mrg 
     93   1.1  mrg ;; Load Store instructions.
     94   1.1  mrg (define_insn_reservation "sh4_300_load" 3
     95   1.1  mrg   (and (eq_attr "pipe_model" "sh4_300")
     96   1.1  mrg        (eq_attr "type" "load,pcload,load_si,pcload_si,pload"))
     97   1.1  mrg   "sh4_300_issue+sh4_300_ls")
     98   1.1  mrg 
     99   1.1  mrg (define_insn_reservation "sh4_300_mac_load" 3
    100   1.1  mrg   (and (eq_attr "pipe_model" "sh4_300")
    101   1.1  mrg        (eq_attr "type" "mem_mac"))
    102   1.1  mrg   "sh4_300_issue+sh4_300_ls+sh4_300_mul")
    103   1.1  mrg 
    104   1.1  mrg (define_insn_reservation "sh4_300_fload" 4
    105   1.1  mrg   (and (eq_attr "pipe_model" "sh4_300")
    106   1.1  mrg        (eq_attr "type" "fload,pcfload"))
    107   1.1  mrg   "sh4_300_issue+sh4_300_ls+sh4_300_fpt")
    108   1.1  mrg 
    109   1.1  mrg ;; sh_adjust_cost describes the reduced latency of the feeding insns of a store.
    110   1.1  mrg ;; The latency of an auto-increment register is 1; the latency of the memory
    111   1.1  mrg ;; output is not actually considered here anyway.
    112   1.1  mrg (define_insn_reservation "sh4_300_store" 1
    113   1.1  mrg   (and (eq_attr "pipe_model" "sh4_300")
    114   1.1  mrg        (eq_attr "type" "store,pstore"))
    115   1.1  mrg   "sh4_300_issue+sh4_300_ls")
    116   1.1  mrg 
    117   1.1  mrg (define_insn_reservation "sh4_300_fstore" 1
    118   1.1  mrg   (and (eq_attr "pipe_model" "sh4_300")
    119   1.1  mrg        (eq_attr "type" "fstore"))
    120   1.1  mrg   "sh4_300_issue+sh4_300_ls+sh4_300_fpt")
    121   1.1  mrg 
    122   1.1  mrg ;; Fixed STS.L from MACL / MACH
    123   1.1  mrg (define_insn_reservation "sh4_300_mac_store" 1
    124   1.1  mrg   (and (eq_attr "pipe_model" "sh4_300")
    125   1.1  mrg        (eq_attr "type" "mac_mem"))
    126   1.1  mrg   "sh4_300_issue+sh4_300_mul+sh4_300_ls")
    127   1.1  mrg 
    128   1.1  mrg (define_insn_reservation "sh4_300_gp_fpul" 2
    129   1.1  mrg   (and (eq_attr "pipe_model" "sh4_300")
    130   1.1  mrg        (eq_attr "type" "gp_fpul"))
    131   1.1  mrg   "sh4_300_issue+sh4_300_fpt")
    132   1.1  mrg 
    133   1.1  mrg (define_insn_reservation "sh4_300_fpul_gp" 1
    134   1.1  mrg   (and (eq_attr "pipe_model" "sh4_300")
    135   1.1  mrg        (eq_attr "type" "fpul_gp"))
    136   1.1  mrg   "sh4_300_issue+sh4_300_fpt")
    137   1.1  mrg 
    138   1.1  mrg ;; Branch (BF,BF/S,BT,BT/S,BRA)
    139   1.1  mrg ;; Branch Far (JMP,RTS,BRAF)
    140   1.1  mrg ;; Group:	BR
    141   1.1  mrg ;; When displacement is 0 for BF / BT, we have effectively conditional
    142   1.1  mrg ;; execution of one instruction, without pipeline disruption.
    143   1.1  mrg ;; Otherwise, the latency depends on prediction success.
    144   1.1  mrg ;; We can't really do much with the latency, even if we could express it,
    145   1.1  mrg ;; but the pairing restrictions are useful to take into account.
    146   1.1  mrg ;; ??? If the branch is likely, and not paired with a preceding insn,
    147   1.1  mrg ;; or likely and likely not predicted, we might want to fill the delay slot.
    148   1.1  mrg ;; However, there appears to be no machinery to make the compiler
    149   1.1  mrg ;; recognize these scenarios.
    150   1.1  mrg (define_insn_reservation "sh4_300_branch"  1
    151   1.1  mrg   (and (eq_attr "pipe_model" "sh4_300")
    152   1.1  mrg        (eq_attr "type" "cbranch,jump,return,jump_ind"))
    153   1.1  mrg   "sh4_300_issue+sh4_300_br")
    154   1.1  mrg 
    155   1.1  mrg ;; RTE
    156   1.1  mrg (define_insn_reservation "sh4_300_return_from_exp" 9
    157   1.1  mrg   (and (eq_attr "pipe_model" "sh4_300")
    158   1.1  mrg        (eq_attr "type" "rte"))
    159   1.1  mrg   "sh4_300_pipe_01+sh4_300_pipe_02*9")
    160   1.1  mrg 
    161   1.1  mrg ;; OCBP, OCBWB
    162   1.1  mrg ;; Group:	CO
    163   1.1  mrg ;; Latency: 	1-5
    164   1.1  mrg ;; Issue Rate: 	1
    165   1.3  mrg ;; cwb is used for the sequence
    166   1.3  mrg ;;	ocbwb  @%0
    167   1.3  mrg ;;	extu.w %0,%2
    168   1.3  mrg ;;	or     %1,%2
    169   1.3  mrg ;;	mov.l  %0,@%2
    170   1.1  mrg ;; This description is likely inexact, but this pattern should not actually
    171   1.1  mrg ;; appear when compiling for sh4-300; we should use isbi instead.
    172   1.1  mrg ;; If a -mtune option is added later, we should use the icache array
    173   1.1  mrg ;; dispatch method instead.
    174   1.1  mrg (define_insn_reservation "sh4_300_ocbwb"  3
    175   1.1  mrg   (and (eq_attr "pipe_model" "sh4_300")
    176   1.1  mrg        (eq_attr "type" "cwb"))
    177   1.1  mrg   "all*3")
    178   1.1  mrg 
    179   1.1  mrg ;; JSR,BSR,BSRF
    180   1.1  mrg ;; Calls have a mandatory delay slot, which we'd like to fill with an insn
    181   1.1  mrg ;; that can be paired with the call itself.
    182   1.1  mrg ;; Scheduling runs before reorg, so we approximate this by saying that we
    183   1.1  mrg ;; want the call to be paired with a preceding insn.
    184   1.1  mrg ;; In most cases, the insn that loads the address of the call should have
    185   1.1  mrg ;; a nonzero latency (mov rn,rm doesn't make sense since we could use rn
    186   1.1  mrg ;; for the address then).  Thus, a preceding insn that can be paired with
    187   1.1  mrg ;; a call should be eligible for the delay slot.
    188   1.1  mrg ;;
    189   1.1  mrg ;; calls introduce a longisch delay that is likely to flush the pipelines
    190   1.1  mrg ;; of the caller's instructions.  Ordinary functions tend to end with a
    191   1.1  mrg ;; load to restore a register (in the delay slot of rts), while sfuncs
    192   1.1  mrg ;; tend to end with an EX or MT insn.  But that is not actually relevant,
    193   1.1  mrg ;; since there are no instructions that contend for memory access early.
    194   1.1  mrg ;; We could, of course, provide exact scheduling information for specific
    195   1.1  mrg ;; sfuncs, if that should prove useful.
    196   1.1  mrg (define_insn_reservation "sh4_300_call" 16
    197   1.1  mrg   (and (eq_attr "pipe_model" "sh4_300")
    198   1.1  mrg        (eq_attr "type" "call,sfunc"))
    199   1.1  mrg   "sh4_300_issue+sh4_300_br,all*15")
    200   1.1  mrg 
    201   1.1  mrg ;; FMOV.S / FMOV.D
    202   1.1  mrg (define_insn_reservation "sh4_300_fmov" 1
    203   1.1  mrg   (and (eq_attr "pipe_model" "sh4_300")
    204   1.1  mrg        (eq_attr "type" "fmove"))
    205   1.1  mrg   "sh4_300_issue+sh4_300_fpt")
    206   1.1  mrg 
    207   1.1  mrg ;; LDS to FPSCR
    208   1.1  mrg (define_insn_reservation "sh4_300_fpscr_load" 8
    209   1.1  mrg   (and (eq_attr "pipe_model" "sh4_300")
    210   1.1  mrg        (eq_attr "type" "gp_fpscr"))
    211   1.1  mrg   "sh4_300_issue+sh4_300_fpu+sh4_300_fpt")
    212   1.1  mrg 
    213   1.1  mrg ;; LDS.L to FPSCR
    214   1.1  mrg (define_insn_reservation "sh4_300_fpscr_load_mem" 8
    215   1.1  mrg   (and (eq_attr "pipe_model" "sh4_300")
    216   1.1  mrg        (eq_attr "type"  "mem_fpscr"))
    217   1.1  mrg   "sh4_300_issue+sh4_300_fpu+sh4_300_fpt+sh4_300_ls")
    218   1.1  mrg 
    219   1.1  mrg 
    221   1.1  mrg ;; Fixed point multiplication (DMULS.L DMULU.L MUL.L MULS.W,MULU.W)
    222   1.1  mrg (define_insn_reservation "multi" 2
    223   1.1  mrg   (and (eq_attr "pipe_model" "sh4_300")
    224   1.1  mrg        (eq_attr "type" "smpy,dmpy"))
    225   1.1  mrg   "sh4_300_issue+sh4_300_mul")
    226   1.1  mrg 
    227   1.1  mrg ;; FPCHG, FRCHG, FSCHG
    228   1.1  mrg (define_insn_reservation "fpscr_toggle"  1
    229   1.1  mrg   (and (eq_attr "pipe_model" "sh4_300")
    230   1.1  mrg        (eq_attr "type" "fpscr_toggle"))
    231   1.1  mrg   "sh4_300_issue+sh4_300_fpu+sh4_300_fpt")
    232   1.1  mrg 
    233   1.1  mrg ;; FCMP/EQ, FCMP/GT
    234   1.1  mrg (define_insn_reservation "fp_cmp"  3
    235   1.1  mrg   (and (eq_attr "pipe_model" "sh4_300")
    236   1.1  mrg        (eq_attr "type" "fp_cmp,dfp_cmp"))
    237   1.1  mrg   "sh4_300_issue+sh4_300_fpu")
    238   1.1  mrg 
    239   1.1  mrg ;; Single precision floating point (FADD,FLOAT,FMAC,FMUL,FSUB,FTRC)
    240   1.1  mrg ;; Double-precision floating-point (FADD,FCNVDS,FCNVSD,FLOAT,FSUB,FTRC)
    241   1.1  mrg (define_insn_reservation "fp_arith"  6
    242   1.1  mrg   (and (eq_attr "pipe_model" "sh4_300")
    243   1.1  mrg        (eq_attr "type" "fp,ftrc_s,dfp_arith,dfp_conv"))
    244   1.1  mrg   "sh4_300_issue+sh4_300_fpu")
    245   1.1  mrg 
    246   1.1  mrg ;; Single Precision FDIV/SQRT
    247   1.1  mrg (define_insn_reservation "fp_div" 19
    248   1.1  mrg   (and (eq_attr "pipe_model" "sh4_300")
    249   1.1  mrg        (eq_attr "type" "fdiv"))
    250   1.1  mrg   "sh4_300_issue+sh4_300_fpu+sh4_300_fds,sh4_300_fds*15")
    251   1.1  mrg 
    252   1.1  mrg ;; Double-precision floating-point FMUL
    253   1.1  mrg (define_insn_reservation "dfp_mul" 9
    254   1.1  mrg   (and (eq_attr "pipe_model" "sh4_300")
    255   1.1  mrg        (eq_attr "type" "dfp_mul"))
    256   1.1  mrg   "sh4_300_issue+sh4_300_fpu,sh4_300_fpu*3")
    257   1.1  mrg 
    258   1.1  mrg ;; Double precision FDIV/SQRT
    259   1.1  mrg (define_insn_reservation "dp_div" 35
    260   1.1  mrg   (and (eq_attr "pipe_model" "sh4_300")
    261   1.1  mrg        (eq_attr "type" "dfdiv"))
    262   1.1  mrg   "sh4_300_issue+sh4_300_fpu+sh4_300_fds,sh4_300_fds*31")
    263   1.1  mrg 
    264   1.1  mrg ;; ??? We don't really want these for sh4-300.
    265   1.1  mrg ;; this pattern itself is likely to finish in 3 cycles, but also
    266   1.1  mrg ;; to disrupt branch prediction for taken branches for the following
    267   1.1  mrg ;; condbranch.
    268   1.1  mrg (define_insn_reservation "sh4_300_arith3" 5
    269   1.1  mrg   (and (eq_attr "pipe_model" "sh4_300")
    270   1.1  mrg        (eq_attr "type" "arith3"))
    271   1.1  mrg   "sh4_300_issue,all*4")
    272   1.1  mrg 
    273   1.1  mrg ;; arith3b insns without brach redirection make use of the 0-offset 0-latency
    274   1.1  mrg ;; branch feature, and thus schedule the same no matter if the branch is taken
    275   1.1  mrg ;; or not.  If the branch is redirected, the taken branch might take longer,
    276   1.1  mrg ;; but then, we don't have to take the next branch.
    277   1.1  mrg ;; ??? should we suppress branch redirection for sh4-300 to improve branch
    278   1.1  mrg ;; target hit rates?
    279   1.1  mrg (define_insn_reservation "arith3b" 2
    280   1.1  mrg   (and (eq_attr "pipe_model" "sh4")
    281   1.1  mrg        (eq_attr "type" "arith3"))
    282              "issue,all")
    283