annotate gcc/expmed.h @ 158:494b0b89df80 default tip

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