(root)/
gcc-13.2.0/
gcc/
config/
loongarch/
loongarch-def.c
       1  /* LoongArch static properties.
       2     Copyright (C) 2021-2023 Free Software Foundation, Inc.
       3     Contributed by Loongson Ltd.
       4  
       5  This file is part of GCC.
       6  
       7  GCC is free software; you can redistribute it and/or modify
       8  it 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,
      13  but WITHOUT ANY WARRANTY; without even the implied warranty of
      14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      15  GNU 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  #include "loongarch-def.h"
      22  #include "loongarch-str.h"
      23  
      24  /* Default RTX cost initializer.  */
      25  #define COSTS_N_INSNS(N) ((N) * 4)
      26  #define DEFAULT_COSTS				\
      27      .fp_add		= COSTS_N_INSNS (1),	\
      28      .fp_mult_sf		= COSTS_N_INSNS (2),	\
      29      .fp_mult_df		= COSTS_N_INSNS (4),	\
      30      .fp_div_sf		= COSTS_N_INSNS (6),	\
      31      .fp_div_df		= COSTS_N_INSNS (8),	\
      32      .int_mult_si	= COSTS_N_INSNS (1),	\
      33      .int_mult_di	= COSTS_N_INSNS (1),	\
      34      .int_div_si		= COSTS_N_INSNS (4),	\
      35      .int_div_di		= COSTS_N_INSNS (6),	\
      36      .branch_cost	= 2,			\
      37      .memory_latency	= 4
      38  
      39  /* CPU property tables.  */
      40  const char*
      41  loongarch_cpu_strings[N_TUNE_TYPES] = {
      42    [CPU_NATIVE]		  = STR_CPU_NATIVE,
      43    [CPU_LOONGARCH64]	  = STR_CPU_LOONGARCH64,
      44    [CPU_LA464]		  = STR_CPU_LA464,
      45  };
      46  
      47  struct loongarch_isa
      48  loongarch_cpu_default_isa[N_ARCH_TYPES] = {
      49    [CPU_LOONGARCH64] = {
      50        .base = ISA_BASE_LA64V100,
      51        .fpu = ISA_EXT_FPU64,
      52    },
      53    [CPU_LA464] = {
      54        .base = ISA_BASE_LA64V100,
      55        .fpu = ISA_EXT_FPU64,
      56    },
      57  };
      58  
      59  struct loongarch_cache
      60  loongarch_cpu_cache[N_TUNE_TYPES] = {
      61    [CPU_LOONGARCH64] = {
      62        .l1d_line_size = 64,
      63        .l1d_size = 64,
      64        .l2d_size = 256,
      65        .simultaneous_prefetches = 4,
      66    },
      67    [CPU_LA464] = {
      68        .l1d_line_size = 64,
      69        .l1d_size = 64,
      70        .l2d_size = 256,
      71        .simultaneous_prefetches = 4,
      72    },
      73  };
      74  
      75  /* The following properties cannot be looked up directly using "cpucfg".
      76   So it is necessary to provide a default value for "unknown native"
      77   tune targets (i.e. -mtune=native while PRID does not correspond to
      78   any known "-mtune" type).  */
      79  
      80  struct loongarch_rtx_cost_data
      81  loongarch_cpu_rtx_cost_data[N_TUNE_TYPES] = {
      82    [CPU_NATIVE] = {
      83        DEFAULT_COSTS
      84    },
      85    [CPU_LOONGARCH64] = {
      86        DEFAULT_COSTS
      87    },
      88    [CPU_LA464] = {
      89        DEFAULT_COSTS
      90    },
      91  };
      92  
      93  /* RTX costs to use when optimizing for size.  */
      94  extern const struct loongarch_rtx_cost_data
      95  loongarch_rtx_cost_optimize_size = {
      96      .fp_add	      = 4,
      97      .fp_mult_sf	      = 4,
      98      .fp_mult_df	      = 4,
      99      .fp_div_sf	      = 4,
     100      .fp_div_df	      = 4,
     101      .int_mult_si      = 4,
     102      .int_mult_di      = 4,
     103      .int_div_si	      = 4,
     104      .int_div_di	      = 4,
     105      .branch_cost      = 2,
     106      .memory_latency   = 4,
     107  };
     108  
     109  int
     110  loongarch_cpu_issue_rate[N_TUNE_TYPES] = {
     111    [CPU_NATIVE]	      = 4,
     112    [CPU_LOONGARCH64]   = 4,
     113    [CPU_LA464]	      = 4,
     114  };
     115  
     116  int
     117  loongarch_cpu_multipass_dfa_lookahead[N_TUNE_TYPES] = {
     118    [CPU_NATIVE]	      = 4,
     119    [CPU_LOONGARCH64]   = 4,
     120    [CPU_LA464]	      = 4,
     121  };
     122  
     123  /* Wiring string definitions from loongarch-str.h to global arrays
     124     with standard index values from loongarch-opts.h, so we can
     125     print config-related messages and do ABI self-spec filtering
     126     from the driver in a self-consistent manner.  */
     127  
     128  const char*
     129  loongarch_isa_base_strings[N_ISA_BASE_TYPES] = {
     130    [ISA_BASE_LA64V100] = STR_ISA_BASE_LA64V100,
     131  };
     132  
     133  const char*
     134  loongarch_isa_ext_strings[N_ISA_EXT_TYPES] = {
     135    [ISA_EXT_FPU64] = STR_ISA_EXT_FPU64,
     136    [ISA_EXT_FPU32] = STR_ISA_EXT_FPU32,
     137    [ISA_EXT_NOFPU] = STR_ISA_EXT_NOFPU,
     138  };
     139  
     140  const char*
     141  loongarch_abi_base_strings[N_ABI_BASE_TYPES] = {
     142    [ABI_BASE_LP64D] = STR_ABI_BASE_LP64D,
     143    [ABI_BASE_LP64F] = STR_ABI_BASE_LP64F,
     144    [ABI_BASE_LP64S] = STR_ABI_BASE_LP64S,
     145  };
     146  
     147  const char*
     148  loongarch_abi_ext_strings[N_ABI_EXT_TYPES] = {
     149    [ABI_EXT_BASE] = STR_ABI_EXT_BASE,
     150  };
     151  
     152  const char*
     153  loongarch_cmodel_strings[] = {
     154    [CMODEL_NORMAL]	  = STR_CMODEL_NORMAL,
     155    [CMODEL_TINY]		  = STR_CMODEL_TINY,
     156    [CMODEL_TINY_STATIC]	  = STR_CMODEL_TS,
     157    [CMODEL_MEDIUM]	  = STR_CMODEL_MEDIUM,
     158    [CMODEL_LARGE]	  = STR_CMODEL_LARGE,
     159    [CMODEL_EXTREME]	  = STR_CMODEL_EXTREME,
     160  };
     161  
     162  const char*
     163  loongarch_switch_strings[] = {
     164    [SW_SOFT_FLOAT]	  = OPTSTR_SOFT_FLOAT,
     165    [SW_SINGLE_FLOAT]	  = OPTSTR_SINGLE_FLOAT,
     166    [SW_DOUBLE_FLOAT]	  = OPTSTR_DOUBLE_FLOAT,
     167  };
     168  
     169  
     170  /* ABI-related definitions.  */
     171  const struct loongarch_isa
     172  abi_minimal_isa[N_ABI_BASE_TYPES][N_ABI_EXT_TYPES] = {
     173    [ABI_BASE_LP64D] = {
     174        [ABI_EXT_BASE] = {.base = ISA_BASE_LA64V100, .fpu = ISA_EXT_FPU64},
     175    },
     176    [ABI_BASE_LP64F] = {
     177        [ABI_EXT_BASE] = {.base = ISA_BASE_LA64V100, .fpu = ISA_EXT_FPU32},
     178    },
     179    [ABI_BASE_LP64S] = {
     180        [ABI_EXT_BASE] = {.base = ISA_BASE_LA64V100, .fpu = ISA_EXT_NOFPU},
     181    },
     182  };