Home | History | Annotate | Line # | Download | only in arm
      1   1.1  mrg ;; ARM 1026EJ-S Pipeline Description
      2  1.12  mrg ;; Copyright (C) 2003-2022 Free Software Foundation, Inc.
      3   1.1  mrg ;; Written by CodeSourcery, LLC.
      4   1.1  mrg ;;
      5   1.1  mrg ;; This file is part of GCC.
      6   1.1  mrg ;;
      7   1.1  mrg ;; GCC is free software; you can redistribute it and/or modify it
      8   1.1  mrg ;; under the terms of the GNU General Public License as published by
      9   1.1  mrg ;; the Free Software Foundation; either version 3, or (at your option)
     10   1.1  mrg ;; any later version.
     11   1.1  mrg ;;
     12   1.1  mrg ;; GCC is distributed in the hope that it will be useful, but
     13   1.1  mrg ;; WITHOUT ANY WARRANTY; without even the implied warranty of
     14   1.1  mrg ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     15   1.1  mrg ;; General Public License for more details.
     16   1.1  mrg ;;
     17   1.1  mrg ;; You should have received a copy of the GNU General Public License
     18   1.1  mrg ;; along with GCC; see the file COPYING3.  If not see
     19   1.1  mrg ;; <http://www.gnu.org/licenses/>.  */
     20   1.1  mrg 
     21   1.1  mrg ;; These descriptions are based on the information contained in the
     22   1.1  mrg ;; ARM1026EJ-S Technical Reference Manual, Copyright (c) 2003 ARM
     23   1.1  mrg ;; Limited.
     24   1.1  mrg ;;
     25   1.1  mrg 
     26   1.1  mrg ;; This automaton provides a pipeline description for the ARM
     27   1.1  mrg ;; 1026EJ-S core.
     28   1.1  mrg ;;
     29   1.1  mrg ;; The model given here assumes that the condition for all conditional
     30   1.1  mrg ;; instructions is "true", i.e., that all of the instructions are
     31   1.1  mrg ;; actually executed.
     32   1.1  mrg 
     33   1.1  mrg (define_automaton "arm1026ejs")
     34   1.1  mrg 
     35   1.1  mrg ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
     36   1.1  mrg ;; Pipelines
     37   1.1  mrg ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
     38   1.1  mrg 
     39   1.1  mrg ;; There are two pipelines:
     40   1.1  mrg ;; 
     41   1.1  mrg ;; - An Arithmetic Logic Unit (ALU) pipeline.
     42   1.1  mrg ;;
     43   1.1  mrg ;;   The ALU pipeline has fetch, issue, decode, execute, memory, and
     44   1.1  mrg ;;   write stages. We only need to model the execute, memory and write
     45   1.1  mrg ;;   stages.
     46   1.1  mrg ;;
     47   1.1  mrg ;; - A Load-Store Unit (LSU) pipeline.
     48   1.1  mrg ;;
     49   1.1  mrg ;;   The LSU pipeline has decode, execute, memory, and write stages.
     50   1.1  mrg ;;   We only model the execute, memory and write stages.
     51   1.1  mrg 
     52   1.1  mrg (define_cpu_unit "a_e,a_m,a_w" "arm1026ejs")
     53   1.1  mrg (define_cpu_unit "l_e,l_m,l_w" "arm1026ejs")
     54   1.1  mrg 
     55   1.1  mrg ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
     56   1.1  mrg ;; ALU Instructions
     57   1.1  mrg ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
     58   1.1  mrg 
     59   1.1  mrg ;; ALU instructions require three cycles to execute, and use the ALU
     60   1.1  mrg ;; pipeline in each of the three stages.  The results are available
     61   1.6  mrg ;; after the execute stage has finished.
     62   1.1  mrg ;;
     63   1.1  mrg ;; If the destination register is the PC, the pipelines are stalled
     64   1.1  mrg ;; for several cycles.  That case is not modeled here.
     65   1.1  mrg 
     66   1.1  mrg ;; ALU operations with no shifted operand
     67   1.1  mrg (define_insn_reservation "alu_op" 1 
     68   1.1  mrg  (and (eq_attr "tune" "arm1026ejs")
     69   1.5  mrg       (eq_attr "type" "alu_imm,alus_imm,logic_imm,logics_imm,\
     70   1.5  mrg                        alu_sreg,alus_sreg,logic_reg,logics_reg,\
     71   1.5  mrg                        adc_imm,adcs_imm,adc_reg,adcs_reg,\
     72   1.5  mrg                        adr,bfm,rev,\
     73   1.5  mrg                        shift_imm,shift_reg,\
     74   1.5  mrg                        mov_imm,mov_reg,mvn_imm,mvn_reg,\
     75  1.11  mrg                        multiple"))
     76   1.1  mrg  "a_e,a_m,a_w")
     77   1.1  mrg 
     78   1.1  mrg ;; ALU operations with a shift-by-constant operand
     79   1.1  mrg (define_insn_reservation "alu_shift_op" 1 
     80   1.1  mrg  (and (eq_attr "tune" "arm1026ejs")
     81  1.12  mrg       (eq_attr "type" "alu_shift_imm_lsl_1to4,alu_shift_imm_other,alus_shift_imm,\
     82   1.5  mrg                        logic_shift_imm,logics_shift_imm,\
     83   1.5  mrg                        extend,mov_shift,mvn_shift"))
     84   1.1  mrg  "a_e,a_m,a_w")
     85   1.1  mrg 
     86   1.1  mrg ;; ALU operations with a shift-by-register operand
     87   1.1  mrg ;; These really stall in the decoder, in order to read
     88   1.1  mrg ;; the shift value in a second cycle. Pretend we take two cycles in
     89   1.1  mrg ;; the execute stage.
     90   1.1  mrg (define_insn_reservation "alu_shift_reg_op" 2 
     91   1.1  mrg  (and (eq_attr "tune" "arm1026ejs")
     92   1.5  mrg       (eq_attr "type" "alu_shift_reg,alus_shift_reg,\
     93   1.5  mrg                        logic_shift_reg,logics_shift_reg,\
     94   1.5  mrg                        mov_shift_reg,mvn_shift_reg"))
     95   1.1  mrg  "a_e*2,a_m,a_w")
     96   1.1  mrg 
     97   1.1  mrg ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
     98   1.1  mrg ;; Multiplication Instructions
     99   1.1  mrg ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    100   1.1  mrg 
    101   1.1  mrg ;; Multiplication instructions loop in the execute stage until the
    102   1.1  mrg ;; instruction has been passed through the multiplier array enough
    103   1.1  mrg ;; times.
    104   1.1  mrg 
    105   1.1  mrg ;; The result of the "smul" and "smulw" instructions is not available
    106   1.1  mrg ;; until after the memory stage.
    107   1.1  mrg (define_insn_reservation "mult1" 2
    108   1.1  mrg  (and (eq_attr "tune" "arm1026ejs")
    109   1.5  mrg       (eq_attr "type" "smulxy,smulwy"))
    110   1.1  mrg  "a_e,a_m,a_w")
    111   1.1  mrg 
    112   1.1  mrg ;; The "smlaxy" and "smlawx" instructions require two iterations through
    113   1.1  mrg ;; the execute stage; the result is available immediately following
    114   1.1  mrg ;; the execute stage.
    115   1.1  mrg (define_insn_reservation "mult2" 2
    116   1.1  mrg  (and (eq_attr "tune" "arm1026ejs")
    117   1.5  mrg       (eq_attr "type" "smlaxy,smlalxy,smlawx"))
    118   1.1  mrg  "a_e*2,a_m,a_w")
    119   1.1  mrg 
    120   1.1  mrg ;; The "smlalxy", "mul", and "mla" instructions require two iterations
    121   1.1  mrg ;; through the execute stage; the result is not available until after
    122   1.1  mrg ;; the memory stage.
    123   1.1  mrg (define_insn_reservation "mult3" 3
    124   1.1  mrg  (and (eq_attr "tune" "arm1026ejs")
    125   1.5  mrg       (eq_attr "type" "smlalxy,mul,mla"))
    126   1.1  mrg  "a_e*2,a_m,a_w")
    127   1.1  mrg 
    128   1.1  mrg ;; The "muls" and "mlas" instructions loop in the execute stage for
    129   1.1  mrg ;; four iterations in order to set the flags.  The value result is
    130   1.1  mrg ;; available after three iterations.
    131   1.1  mrg (define_insn_reservation "mult4" 3
    132   1.1  mrg  (and (eq_attr "tune" "arm1026ejs")
    133   1.5  mrg       (eq_attr "type" "muls,mlas"))
    134   1.1  mrg  "a_e*4,a_m,a_w")
    135   1.1  mrg 
    136   1.1  mrg ;; Long multiply instructions that produce two registers of
    137   1.1  mrg ;; output (such as umull) make their results available in two cycles;
    138   1.1  mrg ;; the least significant word is available before the most significant
    139   1.1  mrg ;; word.  That fact is not modeled; instead, the instructions are
    140   1.3  mrg ;; described as if the entire result was available at the end of the
    141   1.1  mrg ;; cycle in which both words are available.
    142   1.1  mrg 
    143   1.1  mrg ;; The "umull", "umlal", "smull", and "smlal" instructions all take
    144   1.1  mrg ;; three iterations through the execute cycle, and make their results
    145   1.1  mrg ;; available after the memory cycle.
    146   1.1  mrg (define_insn_reservation "mult5" 4
    147   1.1  mrg  (and (eq_attr "tune" "arm1026ejs")
    148   1.5  mrg       (eq_attr "type" "umull,umlal,smull,smlal"))
    149   1.1  mrg  "a_e*3,a_m,a_w")
    150   1.1  mrg 
    151   1.1  mrg ;; The "umulls", "umlals", "smulls", and "smlals" instructions loop in
    152   1.1  mrg ;; the execute stage for five iterations in order to set the flags.
    153   1.1  mrg ;; The value result is available after four iterations.
    154   1.1  mrg (define_insn_reservation "mult6" 4
    155   1.1  mrg  (and (eq_attr "tune" "arm1026ejs")
    156   1.5  mrg       (eq_attr "type" "umulls,umlals,smulls,smlals"))
    157   1.1  mrg  "a_e*5,a_m,a_w")
    158   1.1  mrg 
    159   1.1  mrg ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    160   1.1  mrg ;; Load/Store Instructions
    161   1.1  mrg ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    162   1.1  mrg 
    163   1.1  mrg ;; The models for load/store instructions do not accurately describe
    164   1.1  mrg ;; the difference between operations with a base register writeback
    165   1.1  mrg ;; (such as "ldm!").  These models assume that all memory references
    166   1.1  mrg ;; hit in dcache.
    167   1.1  mrg 
    168   1.1  mrg ;; LSU instructions require six cycles to execute.  They use the ALU
    169   1.1  mrg ;; pipeline in all but the 5th cycle, and the LSU pipeline in cycles
    170   1.1  mrg ;; three through six.
    171   1.1  mrg ;; Loads and stores which use a scaled register offset or scaled
    172   1.1  mrg ;; register pre-indexed addressing mode take three cycles EXCEPT for
    173   1.1  mrg ;; those that are base + offset with LSL of 0 or 2, or base - offset
    174   1.1  mrg ;; with LSL of zero.  The remainder take 1 cycle to execute.
    175   1.1  mrg ;; For 4byte loads there is a bypass from the load stage
    176   1.1  mrg 
    177   1.1  mrg (define_insn_reservation "load1_op" 2
    178   1.1  mrg  (and (eq_attr "tune" "arm1026ejs")
    179   1.9  mrg       (eq_attr "type" "load_byte,load_4"))
    180   1.1  mrg  "a_e+l_e,l_m,a_w+l_w")
    181   1.1  mrg 
    182   1.1  mrg (define_insn_reservation "store1_op" 0
    183   1.1  mrg  (and (eq_attr "tune" "arm1026ejs")
    184   1.9  mrg       (eq_attr "type" "store_4"))
    185   1.1  mrg  "a_e+l_e,l_m,a_w+l_w")
    186   1.1  mrg 
    187   1.1  mrg ;; A load's result can be stored by an immediately following store
    188   1.1  mrg (define_bypass 1 "load1_op" "store1_op" "arm_no_early_store_addr_dep")
    189   1.1  mrg 
    190   1.1  mrg ;; On a LDM/STM operation, the LSU pipeline iterates until all of the
    191   1.1  mrg ;; registers have been processed.
    192   1.1  mrg ;;
    193   1.1  mrg ;; The time it takes to load the data depends on whether or not the
    194   1.1  mrg ;; base address is 64-bit aligned; if it is not, an additional cycle
    195   1.1  mrg ;; is required.  This model assumes that the address is always 64-bit
    196   1.1  mrg ;; aligned.  Because the processor can load two registers per cycle,
    197   1.1  mrg ;; that assumption means that we use the same instruction reservations
    198   1.1  mrg ;; for loading 2k and 2k - 1 registers.
    199   1.1  mrg ;;
    200   1.1  mrg ;; The ALU pipeline is stalled until the completion of the last memory
    201   1.1  mrg ;; stage in the LSU pipeline.  That is modeled by keeping the ALU
    202   1.1  mrg ;; execute stage busy until that point.
    203   1.1  mrg ;;
    204   1.1  mrg ;; As with ALU operations, if one of the destination registers is the
    205   1.1  mrg ;; PC, there are additional stalls; that is not modeled.
    206   1.1  mrg 
    207   1.1  mrg (define_insn_reservation "load2_op" 2
    208   1.1  mrg  (and (eq_attr "tune" "arm1026ejs")
    209   1.9  mrg       (eq_attr "type" "load_8"))
    210   1.1  mrg  "a_e+l_e,l_m,a_w+l_w")
    211   1.1  mrg 
    212   1.1  mrg (define_insn_reservation "store2_op" 0
    213   1.1  mrg  (and (eq_attr "tune" "arm1026ejs")
    214   1.9  mrg       (eq_attr "type" "store_8"))
    215   1.1  mrg  "a_e+l_e,l_m,a_w+l_w")
    216   1.1  mrg 
    217   1.1  mrg (define_insn_reservation "load34_op" 3
    218   1.1  mrg  (and (eq_attr "tune" "arm1026ejs")
    219   1.9  mrg       (eq_attr "type" "load_12,load_16"))
    220   1.1  mrg  "a_e+l_e,a_e+l_e+l_m,a_e+l_m,a_w+l_w")
    221   1.1  mrg 
    222   1.1  mrg (define_insn_reservation "store34_op" 0
    223   1.1  mrg  (and (eq_attr "tune" "arm1026ejs")
    224   1.9  mrg       (eq_attr "type" "store_12,store_16"))
    225   1.1  mrg  "a_e+l_e,a_e+l_e+l_m,a_e+l_m,a_w+l_w")
    226   1.1  mrg 
    227   1.1  mrg ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    228   1.1  mrg ;; Branch and Call Instructions
    229   1.1  mrg ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    230   1.1  mrg 
    231   1.1  mrg ;; Branch instructions are difficult to model accurately.  The ARM
    232   1.1  mrg ;; core can predict most branches.  If the branch is predicted
    233   1.1  mrg ;; correctly, and predicted early enough, the branch can be completely
    234   1.1  mrg ;; eliminated from the instruction stream.  Some branches can
    235   1.1  mrg ;; therefore appear to require zero cycles to execute.  We assume that
    236   1.1  mrg ;; all branches are predicted correctly, and that the latency is
    237   1.1  mrg ;; therefore the minimum value.
    238   1.1  mrg 
    239   1.1  mrg (define_insn_reservation "branch_op" 0
    240   1.1  mrg  (and (eq_attr "tune" "arm1026ejs")
    241   1.1  mrg       (eq_attr "type" "branch"))
    242   1.1  mrg  "nothing")
    243   1.1  mrg 
    244   1.1  mrg ;; The latency for a call is not predictable.  Therefore, we use 32 as
    245   1.1  mrg ;; roughly equivalent to positive infinity.
    246   1.1  mrg 
    247   1.1  mrg (define_insn_reservation "call_op" 32
    248   1.1  mrg  (and (eq_attr "tune" "arm1026ejs")
    249   1.1  mrg       (eq_attr "type" "call"))
    250   1.1  mrg  "nothing")
    251