]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/loongarch/loongarch-tune.h
Update copyright years.
[thirdparty/gcc.git] / gcc / config / loongarch / loongarch-tune.h
1 /* Definitions for microarchitecture-related data structures.
2 Copyright (C) 2021-2024 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 #ifndef LOONGARCH_TUNE_H
22 #define LOONGARCH_TUNE_H
23
24 #include "loongarch-def-array.h"
25
26 /* RTX costs of various operations on the different architectures. */
27 struct loongarch_rtx_cost_data
28 {
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;
42
43 /* Default RTX cost initializer, implemented in loongarch-def.cc. */
44 loongarch_rtx_cost_data ();
45
46 loongarch_rtx_cost_data fp_add_ (unsigned short _fp_add)
47 {
48 fp_add = _fp_add;
49 return *this;
50 }
51
52 loongarch_rtx_cost_data fp_mult_sf_ (unsigned short _fp_mult_sf)
53 {
54 fp_mult_sf = _fp_mult_sf;
55 return *this;
56 }
57
58 loongarch_rtx_cost_data fp_mult_df_ (unsigned short _fp_mult_df)
59 {
60 fp_mult_df = _fp_mult_df;
61 return *this;
62 }
63
64 loongarch_rtx_cost_data fp_div_sf_ (unsigned short _fp_div_sf)
65 {
66 fp_div_sf = _fp_div_sf;
67 return *this;
68 }
69
70 loongarch_rtx_cost_data fp_div_df_ (unsigned short _fp_div_df)
71 {
72 fp_div_df = _fp_div_df;
73 return *this;
74 }
75
76 loongarch_rtx_cost_data int_mult_si_ (unsigned short _int_mult_si)
77 {
78 int_mult_si = _int_mult_si;
79 return *this;
80 }
81
82 loongarch_rtx_cost_data int_mult_di_ (unsigned short _int_mult_di)
83 {
84 int_mult_di = _int_mult_di;
85 return *this;
86 }
87
88 loongarch_rtx_cost_data int_div_si_ (unsigned short _int_div_si)
89 {
90 int_div_si = _int_div_si;
91 return *this;
92 }
93
94 loongarch_rtx_cost_data int_div_di_ (unsigned short _int_div_di)
95 {
96 int_div_di = _int_div_di;
97 return *this;
98 }
99
100 loongarch_rtx_cost_data movcf2gr_ (unsigned short _movcf2gr)
101 {
102 movcf2gr = _movcf2gr;
103 return *this;
104 }
105
106 loongarch_rtx_cost_data movgr2cf_ (unsigned short _movgr2cf)
107 {
108 movgr2cf = _movgr2cf;
109 return *this;
110 }
111
112 loongarch_rtx_cost_data branch_cost_ (unsigned short _branch_cost)
113 {
114 branch_cost = _branch_cost;
115 return *this;
116 }
117
118 loongarch_rtx_cost_data memory_latency_ (unsigned short _memory_latency)
119 {
120 memory_latency = _memory_latency;
121 return *this;
122 }
123 };
124
125 /* Costs to use when optimizing for size. */
126 extern const struct loongarch_rtx_cost_data loongarch_rtx_cost_optimize_size;
127
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 */
134
135 loongarch_cache () : l1d_line_size (0),
136 l1d_size (0),
137 l2d_size (0),
138 simultaneous_prefetches (0) {}
139
140 loongarch_cache l1d_line_size_ (int _l1d_line_size)
141 {
142 l1d_line_size = _l1d_line_size;
143 return *this;
144 }
145
146 loongarch_cache l1d_size_ (int _l1d_size)
147 {
148 l1d_size = _l1d_size;
149 return *this;
150 }
151
152 loongarch_cache l2d_size_ (int _l2d_size)
153 {
154 l2d_size = _l2d_size;
155 return *this;
156 }
157
158 loongarch_cache simultaneous_prefetches_ (int _simultaneous_prefetches)
159 {
160 simultaneous_prefetches = _simultaneous_prefetches;
161 return *this;
162 }
163 };
164
165 /* Alignment for functions and labels for best performance. For new uarchs
166 the value should be measured via benchmarking. See the documentation for
167 -falign-functions and -falign-labels in invoke.texi for the format. */
168 struct loongarch_align {
169 const char *function; /* default value for -falign-functions */
170 const char *label; /* default value for -falign-labels */
171
172 loongarch_align () : function (nullptr), label (nullptr) {}
173
174 loongarch_align function_ (const char *_function)
175 {
176 function = _function;
177 return *this;
178 }
179
180 loongarch_align label_ (const char *_label)
181 {
182 label = _label;
183 return *this;
184 }
185 };
186
187 #endif /* LOONGARCH_TUNE_H */