Line data Source code
1 : /* Target-dependent costs for expmed.cc.
2 : Copyright (C) 1987-2026 Free Software Foundation, Inc.
3 :
4 : This file is part of GCC.
5 :
6 : GCC is free software; you can redistribute it and/or modify it under
7 : the terms of the GNU General Public License as published by the Free
8 : Software Foundation; either version 3, or (at your option) any later
9 : version.
10 :
11 : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 : WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 : FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 : for more details.
15 :
16 : You should have received a copy of the GNU General Public License
17 : along with GCC; see the file COPYING3. If not see
18 : <http://www.gnu.org/licenses/>. */
19 :
20 : #ifndef EXPMED_H
21 : #define EXPMED_H 1
22 :
23 : #include "insn-codes.h"
24 :
25 : enum alg_code {
26 : alg_unknown,
27 : alg_zero,
28 : alg_m, alg_shift,
29 : alg_add_t_m2,
30 : alg_sub_t_m2,
31 : alg_add_factor,
32 : alg_sub_factor,
33 : alg_add_t2_m,
34 : alg_sub_t2_m,
35 : alg_impossible
36 : };
37 :
38 : /* Indicates the type of fixup needed after a constant multiplication.
39 : BASIC_VARIANT means no fixup is needed, NEGATE_VARIANT means that
40 : the result should be negated, and ADD_VARIANT means that the
41 : multiplicand should be added to the result. */
42 : enum mult_variant {basic_variant, negate_variant, add_variant};
43 :
44 : bool choose_mult_variant (machine_mode, HOST_WIDE_INT,
45 : struct algorithm *, enum mult_variant *, int);
46 :
47 : /* This structure holds the "cost" of a multiply sequence. The
48 : "cost" field holds the total rtx_cost of every operator in the
49 : synthetic multiplication sequence, hence cost(a op b) is defined
50 : as rtx_cost(op) + cost(a) + cost(b), where cost(leaf) is zero.
51 : The "latency" field holds the minimum possible latency of the
52 : synthetic multiply, on a hypothetical infinitely parallel CPU.
53 : This is the critical path, or the maximum height, of the expression
54 : tree which is the sum of rtx_costs on the most expensive path from
55 : any leaf to the root. Hence latency(a op b) is defined as zero for
56 : leaves and rtx_cost(op) + max(latency(a), latency(b)) otherwise. */
57 :
58 : struct mult_cost {
59 : short cost; /* Total rtx_cost of the multiplication sequence. */
60 : short latency; /* The latency of the multiplication sequence. */
61 : };
62 :
63 : /* This macro is used to compare a pointer to a mult_cost against an
64 : single integer "rtx_cost" value. This is equivalent to the macro
65 : CHEAPER_MULT_COST(X,Z) where Z = {Y,Y}. */
66 : #define MULT_COST_LESS(X,Y) ((X)->cost < (Y) \
67 : || ((X)->cost == (Y) && (X)->latency < (Y)))
68 :
69 : /* This macro is used to compare two pointers to mult_costs against
70 : each other. The macro returns true if X is cheaper than Y.
71 : Currently, the cheaper of two mult_costs is the one with the
72 : lower "cost". If "cost"s are tied, the lower latency is cheaper. */
73 : #define CHEAPER_MULT_COST(X,Y) ((X)->cost < (Y)->cost \
74 : || ((X)->cost == (Y)->cost \
75 : && (X)->latency < (Y)->latency))
76 :
77 : /* This structure records a sequence of operations.
78 : `ops' is the number of operations recorded.
79 : `cost' is their total cost.
80 : The operations are stored in `op' and the corresponding
81 : logarithms of the integer coefficients in `log'.
82 :
83 : These are the operations:
84 : alg_zero total := 0;
85 : alg_m total := multiplicand;
86 : alg_shift total := total * coeff
87 : alg_add_t_m2 total := total + multiplicand * coeff;
88 : alg_sub_t_m2 total := total - multiplicand * coeff;
89 : alg_add_factor total := total * coeff + total;
90 : alg_sub_factor total := total * coeff - total;
91 : alg_add_t2_m total := total * coeff + multiplicand;
92 : alg_sub_t2_m total := total * coeff - multiplicand;
93 :
94 : The first operand must be either alg_zero or alg_m. */
95 :
96 : struct algorithm
97 : {
98 : struct mult_cost cost;
99 : short ops;
100 : /* The size of the OP and LOG fields are not directly related to the
101 : word size, but the worst-case algorithms will be if we have few
102 : consecutive ones or zeros, i.e., a multiplicand like 10101010101...
103 : In that case we will generate shift-by-2, add, shift-by-2, add,...,
104 : in total wordsize operations. One extra slot: synth_mult extends
105 : a sub-algorithm of up to MAX_BITS_PER_WORD operations by one
106 : before its length check discards the result. */
107 : enum alg_code op[MAX_BITS_PER_WORD + 1];
108 : char log[MAX_BITS_PER_WORD + 1];
109 : };
110 :
111 : /* The entry for our multiplication cache/hash table. */
112 : struct alg_hash_entry {
113 : /* The number we are multiplying by. */
114 : unsigned HOST_WIDE_INT t;
115 :
116 : /* The mode in which we are multiplying something by T. */
117 : machine_mode mode;
118 :
119 : /* The best multiplication algorithm for t. */
120 : enum alg_code alg;
121 :
122 : /* The cost of multiplication if ALG_CODE is not alg_impossible.
123 : Otherwise, the cost within which multiplication by T is
124 : impossible. */
125 : struct mult_cost cost;
126 :
127 : /* Optimized for speed? */
128 : bool speed;
129 : };
130 :
131 : /* The number of cache/hash entries. */
132 : #if HOST_BITS_PER_WIDE_INT == 64
133 : #define NUM_ALG_HASH_ENTRIES 1031
134 : #else
135 : #define NUM_ALG_HASH_ENTRIES 307
136 : #endif
137 :
138 : #define NUM_MODE_IP_INT (NUM_MODE_INT + NUM_MODE_PARTIAL_INT)
139 : #define NUM_MODE_IPV_INT (NUM_MODE_IP_INT + NUM_MODE_VECTOR_INT)
140 :
141 : struct expmed_op_cheap {
142 : bool cheap[2][NUM_MODE_IPV_INT];
143 : };
144 :
145 : struct expmed_op_costs {
146 : int cost[2][NUM_MODE_IPV_INT];
147 : };
148 :
149 : /* Target-dependent globals. */
150 : struct target_expmed {
151 : /* Each entry of ALG_HASH caches alg_code for some integer. This is
152 : actually a hash table. If we have a collision, that the older
153 : entry is kicked out. */
154 : struct alg_hash_entry x_alg_hash[NUM_ALG_HASH_ENTRIES];
155 :
156 : /* True if x_alg_hash might already have been used. */
157 : bool x_alg_hash_used_p;
158 :
159 : /* Nonzero means divides or modulus operations are relatively cheap for
160 : powers of two, so don't use branches; emit the operation instead.
161 : Usually, this will mean that the MD file will emit non-branch
162 : sequences. */
163 : struct expmed_op_cheap x_sdiv_pow2_cheap;
164 : struct expmed_op_cheap x_smod_pow2_cheap;
165 :
166 : /* Cost of various pieces of RTL. */
167 : int x_zero_cost[2];
168 : struct expmed_op_costs x_add_cost;
169 : struct expmed_op_costs x_neg_cost;
170 : int x_shift_cost[2][NUM_MODE_IPV_INT][MAX_BITS_PER_WORD];
171 : int x_shiftadd_cost[2][NUM_MODE_IPV_INT][MAX_BITS_PER_WORD];
172 : int x_shiftsub0_cost[2][NUM_MODE_IPV_INT][MAX_BITS_PER_WORD];
173 : int x_shiftsub1_cost[2][NUM_MODE_IPV_INT][MAX_BITS_PER_WORD];
174 : struct expmed_op_costs x_mul_cost;
175 : struct expmed_op_costs x_sdiv_cost;
176 : struct expmed_op_costs x_udiv_cost;
177 : int x_mul_widen_cost[2][NUM_MODE_INT];
178 : int x_mul_highpart_cost[2][NUM_MODE_INT];
179 :
180 : /* Conversion costs are only defined between two scalar integer modes
181 : of different sizes. The first machine mode is the destination mode,
182 : and the second is the source mode. */
183 : int x_convert_cost[2][NUM_MODE_IP_INT][NUM_MODE_IP_INT];
184 : };
185 :
186 : extern struct target_expmed default_target_expmed;
187 : #if SWITCHABLE_TARGET
188 : extern struct target_expmed *this_target_expmed;
189 : #else
190 : #define this_target_expmed (&default_target_expmed)
191 : #endif
192 :
193 : /* Return a pointer to the alg_hash_entry at IDX. */
194 :
195 : inline struct alg_hash_entry *
196 19370649 : alg_hash_entry_ptr (int idx)
197 : {
198 19370649 : return &this_target_expmed->x_alg_hash[idx];
199 : }
200 :
201 : /* Return true if the x_alg_hash field might have been used. */
202 :
203 : inline bool
204 220100 : alg_hash_used_p (void)
205 : {
206 220100 : return this_target_expmed->x_alg_hash_used_p;
207 : }
208 :
209 : /* Set whether the x_alg_hash field might have been used. */
210 :
211 : inline void
212 219043 : set_alg_hash_used_p (bool usedp)
213 : {
214 219043 : this_target_expmed->x_alg_hash_used_p = usedp;
215 : }
216 :
217 : /* Compute an index into the cost arrays by mode class. */
218 :
219 : inline int
220 2672744801 : expmed_mode_index (machine_mode mode)
221 : {
222 2672744801 : switch (GET_MODE_CLASS (mode))
223 : {
224 675160928 : case MODE_INT:
225 675160928 : return mode - MIN_MODE_INT;
226 215698000 : case MODE_PARTIAL_INT:
227 : /* If there are no partial integer modes, help the compiler
228 : to figure out this will never happen. See PR59934. */
229 215698000 : if (MIN_MODE_PARTIAL_INT != VOIDmode)
230 215698000 : return mode - MIN_MODE_PARTIAL_INT + NUM_MODE_INT;
231 : break;
232 1781885873 : case MODE_VECTOR_INT:
233 : /* If there are no vector integer modes, help the compiler
234 : to figure out this will never happen. See PR59934. */
235 1781885873 : if (MIN_MODE_VECTOR_INT != VOIDmode)
236 1781885873 : return mode - MIN_MODE_VECTOR_INT + NUM_MODE_IP_INT;
237 : break;
238 0 : default:
239 0 : break;
240 : }
241 0 : gcc_unreachable ();
242 : }
243 :
244 : /* Return a pointer to a boolean contained in EOC indicating whether
245 : a particular operation performed in MODE is cheap when optimizing
246 : for SPEED. */
247 :
248 : inline bool *
249 36119674 : expmed_op_cheap_ptr (struct expmed_op_cheap *eoc, bool speed,
250 : machine_mode mode)
251 : {
252 36142948 : int idx = expmed_mode_index (mode);
253 36119674 : return &eoc->cheap[speed][idx];
254 : }
255 :
256 : /* Return a pointer to a cost contained in COSTS when a particular
257 : operation is performed in MODE when optimizing for SPEED. */
258 :
259 : inline int *
260 194607398 : expmed_op_cost_ptr (struct expmed_op_costs *costs, bool speed,
261 : machine_mode mode)
262 : {
263 237139524 : int idx = expmed_mode_index (mode);
264 194542300 : return &costs->cost[speed][idx];
265 : }
266 :
267 : /* Subroutine of {set_,}sdiv_pow2_cheap. Not to be used otherwise. */
268 :
269 : inline bool *
270 18068848 : sdiv_pow2_cheap_ptr (bool speed, machine_mode mode)
271 : {
272 18089496 : return expmed_op_cheap_ptr (&this_target_expmed->x_sdiv_pow2_cheap,
273 : speed, mode);
274 : }
275 :
276 : /* Set whether a signed division by a power of 2 is cheap in MODE
277 : when optimizing for SPEED. */
278 :
279 : inline void
280 18048200 : set_sdiv_pow2_cheap (bool speed, machine_mode mode, bool cheap_p)
281 : {
282 18048200 : *sdiv_pow2_cheap_ptr (speed, mode) = cheap_p;
283 : }
284 :
285 : /* Return whether a signed division by a power of 2 is cheap in MODE
286 : when optimizing for SPEED. */
287 :
288 : inline bool
289 20648 : sdiv_pow2_cheap (bool speed, machine_mode mode)
290 : {
291 20648 : return *sdiv_pow2_cheap_ptr (speed, mode);
292 : }
293 :
294 : /* Subroutine of {set_,}smod_pow2_cheap. Not to be used otherwise. */
295 :
296 : inline bool *
297 18050826 : smod_pow2_cheap_ptr (bool speed, machine_mode mode)
298 : {
299 18053452 : return expmed_op_cheap_ptr (&this_target_expmed->x_smod_pow2_cheap,
300 : speed, mode);
301 : }
302 :
303 : /* Set whether a signed modulo by a power of 2 is CHEAP in MODE when
304 : optimizing for SPEED. */
305 :
306 : inline void
307 18048200 : set_smod_pow2_cheap (bool speed, machine_mode mode, bool cheap)
308 : {
309 18048200 : *smod_pow2_cheap_ptr (speed, mode) = cheap;
310 : }
311 :
312 : /* Return whether a signed modulo by a power of 2 is cheap in MODE
313 : when optimizing for SPEED. */
314 :
315 : inline bool
316 2626 : smod_pow2_cheap (bool speed, machine_mode mode)
317 : {
318 2626 : return *smod_pow2_cheap_ptr (speed, mode);
319 : }
320 :
321 : /* Subroutine of {set_,}zero_cost. Not to be used otherwise. */
322 :
323 : inline int *
324 976815 : zero_cost_ptr (bool speed)
325 : {
326 976815 : return &this_target_expmed->x_zero_cost[speed];
327 : }
328 :
329 : /* Set the COST of loading zero when optimizing for SPEED. */
330 :
331 : inline void
332 440200 : set_zero_cost (bool speed, int cost)
333 : {
334 440200 : *zero_cost_ptr (speed) = cost;
335 : }
336 :
337 : /* Return the COST of loading zero when optimizing for SPEED. */
338 :
339 : inline int
340 536615 : zero_cost (bool speed)
341 : {
342 536615 : return *zero_cost_ptr (speed);
343 : }
344 :
345 : /* Subroutine of {set_,}add_cost. Not to be used otherwise. */
346 :
347 : inline int *
348 119386040 : add_cost_ptr (bool speed, machine_mode mode)
349 : {
350 238541337 : return expmed_op_cost_ptr (&this_target_expmed->x_add_cost, speed, mode);
351 : }
352 :
353 : /* Set the COST of computing an add in MODE when optimizing for SPEED. */
354 :
355 : inline void
356 18048200 : set_add_cost (bool speed, machine_mode mode, int cost)
357 : {
358 18048200 : *add_cost_ptr (speed, mode) = cost;
359 : }
360 :
361 : /* Return the cost of computing an add in MODE when optimizing for SPEED. */
362 :
363 : inline int
364 101337840 : add_cost (bool speed, machine_mode mode)
365 : {
366 65241440 : return *add_cost_ptr (speed, mode);
367 : }
368 :
369 : /* Subroutine of {set_,}neg_cost. Not to be used otherwise. */
370 :
371 : inline int *
372 20680077 : neg_cost_ptr (bool speed, machine_mode mode)
373 : {
374 41356979 : return expmed_op_cost_ptr (&this_target_expmed->x_neg_cost, speed, mode);
375 : }
376 :
377 : /* Set the COST of computing a negation in MODE when optimizing for SPEED. */
378 :
379 : inline void
380 18048200 : set_neg_cost (bool speed, machine_mode mode, int cost)
381 : {
382 18048200 : *neg_cost_ptr (speed, mode) = cost;
383 : }
384 :
385 : /* Return the cost of computing a negation in MODE when optimizing for
386 : SPEED. */
387 :
388 : inline int
389 2631877 : neg_cost (bool speed, machine_mode mode)
390 : {
391 2631877 : return *neg_cost_ptr (speed, mode);
392 : }
393 :
394 : /* Subroutine of {set_,}shift_cost. Not to be used otherwise. */
395 :
396 : inline int *
397 619011276 : shift_cost_ptr (bool speed, machine_mode mode, int bits)
398 : {
399 1207576178 : int midx = expmed_mode_index (mode);
400 618965592 : return &this_target_expmed->x_shift_cost[speed][midx][bits];
401 : }
402 :
403 : /* Set the COST of doing a shift in MODE by BITS when optimizing for SPEED. */
404 :
405 : inline void
406 605715200 : set_shift_cost (bool speed, machine_mode mode, int bits, int cost)
407 : {
408 605715200 : *shift_cost_ptr (speed, mode, bits) = cost;
409 : }
410 :
411 : /* Return the cost of doing a shift in MODE by BITS when optimizing for
412 : SPEED. */
413 :
414 : inline int
415 995853 : shift_cost (bool speed, machine_mode mode, int bits)
416 : {
417 13250392 : return *shift_cost_ptr (speed, mode, bits);
418 : }
419 :
420 : /* Subroutine of {set_,}shiftadd_cost. Not to be used otherwise. */
421 :
422 : inline int *
423 611623433 : shiftadd_cost_ptr (bool speed, machine_mode mode, int bits)
424 : {
425 1203107976 : int midx = expmed_mode_index (mode);
426 611623433 : return &this_target_expmed->x_shiftadd_cost[speed][midx][bits];
427 : }
428 :
429 : /* Set the COST of doing a shift in MODE by BITS followed by an add when
430 : optimizing for SPEED. */
431 :
432 : inline void
433 605715200 : set_shiftadd_cost (bool speed, machine_mode mode, int bits, int cost)
434 : {
435 605715200 : *shiftadd_cost_ptr (speed, mode, bits) = cost;
436 : }
437 :
438 : /* Return the cost of doing a shift in MODE by BITS followed by an add
439 : when optimizing for SPEED. */
440 :
441 : inline int
442 5908233 : shiftadd_cost (bool speed, machine_mode mode, int bits)
443 : {
444 5908233 : return *shiftadd_cost_ptr (speed, mode, bits);
445 : }
446 :
447 : /* Subroutine of {set_,}shiftsub0_cost. Not to be used otherwise. */
448 :
449 : inline int *
450 609668883 : shiftsub0_cost_ptr (bool speed, machine_mode mode, int bits)
451 : {
452 1199817904 : int midx = expmed_mode_index (mode);
453 609668883 : return &this_target_expmed->x_shiftsub0_cost[speed][midx][bits];
454 : }
455 :
456 : /* Set the COST of doing a shift in MODE by BITS and then subtracting a
457 : value when optimizing for SPEED. */
458 :
459 : inline void
460 605715200 : set_shiftsub0_cost (bool speed, machine_mode mode, int bits, int cost)
461 : {
462 605715200 : *shiftsub0_cost_ptr (speed, mode, bits) = cost;
463 : }
464 :
465 : /* Return the cost of doing a shift in MODE by BITS and then subtracting
466 : a value when optimizing for SPEED. */
467 :
468 : inline int
469 3953683 : shiftsub0_cost (bool speed, machine_mode mode, int bits)
470 : {
471 3953683 : return *shiftsub0_cost_ptr (speed, mode, bits);
472 : }
473 :
474 : /* Subroutine of {set_,}shiftsub1_cost. Not to be used otherwise. */
475 :
476 : inline int *
477 606559571 : shiftsub1_cost_ptr (bool speed, machine_mode mode, int bits)
478 : {
479 1194226571 : int midx = expmed_mode_index (mode);
480 606559571 : return &this_target_expmed->x_shiftsub1_cost[speed][midx][bits];
481 : }
482 :
483 : /* Set the COST of subtracting a shift in MODE by BITS from a value when
484 : optimizing for SPEED. */
485 :
486 : inline void
487 605715200 : set_shiftsub1_cost (bool speed, machine_mode mode, int bits, int cost)
488 : {
489 605715200 : *shiftsub1_cost_ptr (speed, mode, bits) = cost;
490 : }
491 :
492 : /* Return the cost of subtracting a shift in MODE by BITS from a value
493 : when optimizing for SPEED. */
494 :
495 : inline int
496 844371 : shiftsub1_cost (bool speed, machine_mode mode, int bits)
497 : {
498 844371 : return *shiftsub1_cost_ptr (speed, mode, bits);
499 : }
500 :
501 : /* Subroutine of {set_,}mul_cost. Not to be used otherwise. */
502 :
503 : inline int *
504 18204672 : mul_cost_ptr (bool speed, machine_mode mode)
505 : {
506 36408748 : return expmed_op_cost_ptr (&this_target_expmed->x_mul_cost, speed, mode);
507 : }
508 :
509 : /* Set the COST of doing a multiplication in MODE when optimizing for
510 : SPEED. */
511 :
512 : inline void
513 18048200 : set_mul_cost (bool speed, machine_mode mode, int cost)
514 : {
515 18048200 : *mul_cost_ptr (speed, mode) = cost;
516 : }
517 :
518 : /* Return the cost of doing a multiplication in MODE when optimizing
519 : for SPEED. */
520 :
521 : inline int
522 156472 : mul_cost (bool speed, machine_mode mode)
523 : {
524 156472 : return *mul_cost_ptr (speed, mode);
525 : }
526 :
527 : /* Subroutine of {set_,}sdiv_cost. Not to be used otherwise. */
528 :
529 : inline int *
530 18182651 : sdiv_cost_ptr (bool speed, machine_mode mode)
531 : {
532 36365302 : return expmed_op_cost_ptr (&this_target_expmed->x_sdiv_cost, speed, mode);
533 : }
534 :
535 : /* Set the COST of doing a signed division in MODE when optimizing
536 : for SPEED. */
537 :
538 : inline void
539 18048200 : set_sdiv_cost (bool speed, machine_mode mode, int cost)
540 : {
541 18048200 : *sdiv_cost_ptr (speed, mode) = cost;
542 : }
543 :
544 : /* Return the cost of doing a signed division in MODE when optimizing
545 : for SPEED. */
546 :
547 : inline int
548 134451 : sdiv_cost (bool speed, machine_mode mode)
549 : {
550 134451 : return *sdiv_cost_ptr (speed, mode);
551 : }
552 :
553 : /* Subroutine of {set_,}udiv_cost. Not to be used otherwise. */
554 :
555 : inline int *
556 18153958 : udiv_cost_ptr (bool speed, machine_mode mode)
557 : {
558 36307916 : return expmed_op_cost_ptr (&this_target_expmed->x_udiv_cost, speed, mode);
559 : }
560 :
561 : /* Set the COST of doing an unsigned division in MODE when optimizing
562 : for SPEED. */
563 :
564 : inline void
565 18048200 : set_udiv_cost (bool speed, machine_mode mode, int cost)
566 : {
567 18048200 : *udiv_cost_ptr (speed, mode) = cost;
568 : }
569 :
570 : /* Return the cost of doing an unsigned division in MODE when
571 : optimizing for SPEED. */
572 :
573 : inline int
574 105758 : udiv_cost (bool speed, machine_mode mode)
575 : {
576 105758 : return *udiv_cost_ptr (speed, mode);
577 : }
578 :
579 : /* Subroutine of {set_,}mul_widen_cost. Not to be used otherwise. */
580 :
581 : inline int *
582 2646141 : mul_widen_cost_ptr (bool speed, machine_mode mode)
583 : {
584 2646141 : gcc_assert (GET_MODE_CLASS (mode) == MODE_INT);
585 :
586 2646141 : return &this_target_expmed->x_mul_widen_cost[speed][mode - MIN_MODE_INT];
587 : }
588 :
589 : /* Set the COST for computing a widening multiplication in MODE when
590 : optimizing for SPEED. */
591 :
592 : inline void
593 2641200 : set_mul_widen_cost (bool speed, machine_mode mode, int cost)
594 : {
595 2641200 : *mul_widen_cost_ptr (speed, mode) = cost;
596 : }
597 :
598 : /* Return the cost for computing a widening multiplication in MODE when
599 : optimizing for SPEED. */
600 :
601 : inline int
602 4941 : mul_widen_cost (bool speed, machine_mode mode)
603 : {
604 4941 : return *mul_widen_cost_ptr (speed, mode);
605 : }
606 :
607 : /* Subroutine of {set_,}mul_highpart_cost. Not to be used otherwise. */
608 :
609 : inline int *
610 2709315 : mul_highpart_cost_ptr (bool speed, machine_mode mode)
611 : {
612 2709315 : gcc_assert (GET_MODE_CLASS (mode) == MODE_INT);
613 2709315 : int m = mode - MIN_MODE_INT;
614 2709315 : gcc_assert (m < NUM_MODE_INT);
615 :
616 2709315 : return &this_target_expmed->x_mul_highpart_cost[speed][m];
617 : }
618 :
619 : /* Set the COST for computing the high part of a multiplication in MODE
620 : when optimizing for SPEED. */
621 :
622 : inline void
623 2641200 : set_mul_highpart_cost (bool speed, machine_mode mode, int cost)
624 : {
625 2641200 : *mul_highpart_cost_ptr (speed, mode) = cost;
626 : }
627 :
628 : /* Return the cost for computing the high part of a multiplication in MODE
629 : when optimizing for SPEED. */
630 :
631 : inline int
632 68115 : mul_highpart_cost (bool speed, machine_mode mode)
633 : {
634 68115 : return *mul_highpart_cost_ptr (speed, mode);
635 : }
636 :
637 : /* Subroutine of {set_,}convert_cost. Not to be used otherwise. */
638 :
639 : inline int *
640 33502617 : convert_cost_ptr (machine_mode to_mode, machine_mode from_mode,
641 : bool speed)
642 : {
643 33502617 : int to_idx = expmed_mode_index (to_mode);
644 33502617 : int from_idx = expmed_mode_index (from_mode);
645 :
646 33502617 : gcc_assert (IN_RANGE (to_idx, 0, NUM_MODE_IP_INT - 1));
647 33502617 : gcc_assert (IN_RANGE (from_idx, 0, NUM_MODE_IP_INT - 1));
648 :
649 33502617 : return &this_target_expmed->x_convert_cost[speed][to_idx][from_idx];
650 : }
651 :
652 : /* Set the COST for converting from FROM_MODE to TO_MODE when optimizing
653 : for SPEED. */
654 :
655 : inline void
656 30814000 : set_convert_cost (machine_mode to_mode, machine_mode from_mode,
657 : bool speed, int cost)
658 : {
659 30814000 : *convert_cost_ptr (to_mode, from_mode, speed) = cost;
660 : }
661 :
662 : /* Return the cost for converting from FROM_MODE to TO_MODE when optimizing
663 : for SPEED. */
664 :
665 : inline int
666 2688617 : convert_cost (machine_mode to_mode, machine_mode from_mode,
667 : bool speed)
668 : {
669 2688617 : return *convert_cost_ptr (to_mode, from_mode, speed);
670 : }
671 :
672 : extern int mult_by_coeff_cost (HOST_WIDE_INT, machine_mode, bool);
673 : extern rtx emit_cstore (rtx target, enum insn_code icode, enum rtx_code code,
674 : machine_mode mode, machine_mode compare_mode,
675 : int unsignedp, rtx x, rtx y, int normalizep,
676 : machine_mode target_mode);
677 :
678 : /* Arguments MODE, RTX: return an rtx for the negation of that value.
679 : May emit insns. */
680 : extern rtx negate_rtx (machine_mode, rtx);
681 :
682 : /* Arguments MODE, RTX: return an rtx for the flipping of that value.
683 : May emit insns. */
684 : extern rtx flip_storage_order (machine_mode, rtx);
685 :
686 : /* Expand a logical AND operation. */
687 : extern rtx expand_and (machine_mode, rtx, rtx, rtx);
688 :
689 : /* Emit a store-flag operation. */
690 : extern rtx emit_store_flag (rtx, enum rtx_code, rtx, rtx, machine_mode,
691 : int, int);
692 :
693 : /* Like emit_store_flag, but always succeeds. */
694 : extern rtx emit_store_flag_force (rtx, enum rtx_code, rtx, rtx,
695 : machine_mode, int, int);
696 :
697 : extern void canonicalize_comparison (machine_mode, enum rtx_code *, rtx *);
698 :
699 : /* Choose a minimal N + 1 bit approximation to 2**K / D that can be used to
700 : replace division by D, put the least significant N bits of the result in
701 : *MULTIPLIER_PTR, the value K - N in *POST_SHIFT_PTR, and return the most
702 : significant bit. */
703 : extern unsigned HOST_WIDE_INT choose_multiplier (unsigned HOST_WIDE_INT, int,
704 : int, unsigned HOST_WIDE_INT *,
705 : int *);
706 :
707 : #ifdef TREE_CODE
708 : extern rtx expand_variable_shift (enum tree_code, machine_mode,
709 : rtx, tree, rtx, int);
710 : extern rtx expand_shift (enum tree_code, machine_mode, rtx, poly_int64, rtx,
711 : int);
712 : extern rtx maybe_expand_shift (enum tree_code, machine_mode, rtx, int, rtx,
713 : int);
714 : #ifdef GCC_OPTABS_H
715 : extern rtx expand_divmod (int, enum tree_code, machine_mode, rtx, rtx,
716 : rtx, int, enum optab_methods = OPTAB_LIB_WIDEN);
717 : #endif
718 : #endif
719 :
720 : extern void store_bit_field (rtx, poly_uint64, poly_uint64,
721 : poly_uint64, poly_uint64,
722 : machine_mode, rtx, bool, bool);
723 : extern rtx extract_bit_field (rtx, poly_uint64, poly_uint64, int, rtx,
724 : machine_mode, machine_mode, bool, rtx *);
725 : extern rtx extract_low_bits (machine_mode, machine_mode, rtx);
726 : extern rtx expand_mult (machine_mode, rtx, rtx, rtx, int, bool = false);
727 : extern rtx expand_mult_highpart_adjust (scalar_int_mode, rtx, rtx, rtx,
728 : rtx, int);
729 : extern rtx expmed_mult_highpart_optab (scalar_int_mode, rtx, rtx, rtx,
730 : int, int);
731 : extern rtx expand_rotate_as_vec_perm (machine_mode, rtx, rtx, rtx);
732 :
733 : /* The constant divisor of the last division expanded, reset per function
734 : by prepare_function_start. */
735 : extern HOST_WIDE_INT last_div_const;
736 :
737 : #endif // EXPMED_H
|