[PR testsuite/116860] Testsuite adjustment for recently added tests
[official-gcc.git] / gcc / config / loongarch / loongarch-tune.h
blobe69173ebf79ee28f4fa39217c828edc5d48aa39b
1 /* Definitions for microarchitecture-related data structures.
2 Copyright (C) 2021-2025 Free Software Foundation, Inc.
3 Contributed by Loongson Ltd.
5 This file is part of GCC.
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.
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.
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/>. */
21 #ifndef LOONGARCH_TUNE_H
22 #define LOONGARCH_TUNE_H
24 #include "loongarch-def-array.h"
26 /* RTX costs of various operations on the different architectures. */
27 struct loongarch_rtx_cost_data
29 unsigned short fp_add;
30 unsigned short fp_mult_sf;
31 unsigned short fp_mult_df;
32 unsigned short fp_div_sf;
33 unsigned short fp_div_df;
34 unsigned short int_mult_si;
35 unsigned short int_mult_di;
36 unsigned short int_div_si;
37 unsigned short int_div_di;
38 unsigned short movcf2gr;
39 unsigned short movgr2cf;
40 unsigned short branch_cost;
41 unsigned short memory_latency;
43 /* Default RTX cost initializer, implemented in loongarch-def.cc. */
44 loongarch_rtx_cost_data ();
46 loongarch_rtx_cost_data fp_add_ (unsigned short _fp_add)
48 fp_add = _fp_add;
49 return *this;
52 loongarch_rtx_cost_data fp_mult_sf_ (unsigned short _fp_mult_sf)
54 fp_mult_sf = _fp_mult_sf;
55 return *this;
58 loongarch_rtx_cost_data fp_mult_df_ (unsigned short _fp_mult_df)
60 fp_mult_df = _fp_mult_df;
61 return *this;
64 loongarch_rtx_cost_data fp_div_sf_ (unsigned short _fp_div_sf)
66 fp_div_sf = _fp_div_sf;
67 return *this;
70 loongarch_rtx_cost_data fp_div_df_ (unsigned short _fp_div_df)
72 fp_div_df = _fp_div_df;
73 return *this;
76 loongarch_rtx_cost_data int_mult_si_ (unsigned short _int_mult_si)
78 int_mult_si = _int_mult_si;
79 return *this;
82 loongarch_rtx_cost_data int_mult_di_ (unsigned short _int_mult_di)
84 int_mult_di = _int_mult_di;
85 return *this;
88 loongarch_rtx_cost_data int_div_si_ (unsigned short _int_div_si)
90 int_div_si = _int_div_si;
91 return *this;
94 loongarch_rtx_cost_data int_div_di_ (unsigned short _int_div_di)
96 int_div_di = _int_div_di;
97 return *this;
100 loongarch_rtx_cost_data movcf2gr_ (unsigned short _movcf2gr)
102 movcf2gr = _movcf2gr;
103 return *this;
106 loongarch_rtx_cost_data movgr2cf_ (unsigned short _movgr2cf)
108 movgr2cf = _movgr2cf;
109 return *this;
112 loongarch_rtx_cost_data branch_cost_ (unsigned short _branch_cost)
114 branch_cost = _branch_cost;
115 return *this;
118 loongarch_rtx_cost_data memory_latency_ (unsigned short _memory_latency)
120 memory_latency = _memory_latency;
121 return *this;
125 /* Costs to use when optimizing for size. */
126 extern const struct loongarch_rtx_cost_data loongarch_rtx_cost_optimize_size;
128 /* Cache size record of known processor models. */
129 struct loongarch_cache {
130 int l1d_line_size; /* bytes */
131 int l1d_size; /* KiB */
132 int l2d_size; /* kiB */
133 int simultaneous_prefetches; /* number of parallel prefetch */
135 loongarch_cache () : l1d_line_size (0),
136 l1d_size (0),
137 l2d_size (0),
138 simultaneous_prefetches (0) {}
140 loongarch_cache l1d_line_size_ (int _l1d_line_size)
142 l1d_line_size = _l1d_line_size;
143 return *this;
146 loongarch_cache l1d_size_ (int _l1d_size)
148 l1d_size = _l1d_size;
149 return *this;
152 loongarch_cache l2d_size_ (int _l2d_size)
154 l2d_size = _l2d_size;
155 return *this;
158 loongarch_cache simultaneous_prefetches_ (int _simultaneous_prefetches)
160 simultaneous_prefetches = _simultaneous_prefetches;
161 return *this;
165 /* Alignment for functions loops and jumps for best performance. For new
166 uarchs the value should be measured via benchmarking. See the
167 documentation for -falign-functions, -falign-loops, and -falign-jumps in
168 invoke.texi for the format. */
169 struct loongarch_align {
170 const char *function; /* default value for -falign-functions */
171 const char *loop; /* default value for -falign-loops */
172 const char *jump; /* default value for -falign-jumps */
174 loongarch_align () : function (nullptr), loop (nullptr), jump (nullptr) {}
176 loongarch_align function_ (const char *_function)
178 function = _function;
179 return *this;
182 loongarch_align loop_ (const char *_loop)
184 loop = _loop;
185 return *this;
188 loongarch_align jump_ (const char *_jump)
190 jump = _jump;
191 return *this;
195 #endif /* LOONGARCH_TUNE_H */