]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/genopinit.c
trans-array.c (gfc_conv_descriptor_data_get): Rename from gfc_conv_descriptor_data.
[thirdparty/gcc.git] / gcc / genopinit.c
CommitLineData
af9e4a0c 1/* Generate code to initialize optabs from machine description.
b5e01d4b 2 Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
7ae4d8d4 3 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
af9e4a0c 4
1322177d 5This file is part of GCC.
af9e4a0c 6
1322177d
LB
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
9Software Foundation; either version 2, or (at your option) any later
10version.
af9e4a0c 11
1322177d
LB
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15for more details.
af9e4a0c
RK
16
17You should have received a copy of the GNU General Public License
1322177d
LB
18along with GCC; see the file COPYING. If not, write to the Free
19Software Foundation, 59 Temple Place - Suite 330, Boston, MA
2002111-1307, USA. */
af9e4a0c
RK
21
22
4977bab6 23#include "bconfig.h"
0b93b64e 24#include "system.h"
4977bab6
ZW
25#include "coretypes.h"
26#include "tm.h"
af9e4a0c 27#include "rtl.h"
f8b6598e 28#include "errors.h"
c88c0d42 29#include "gensupport.h"
ccd043a9 30
af9e4a0c 31
af9e4a0c
RK
32/* Many parts of GCC use arrays that are indexed by machine mode and
33 contain the insn codes for pattern in the MD file that perform a given
34 operation on operands of that mode.
35
36 These patterns are present in the MD file with names that contain
37 the mode(s) used and the name of the operation. This program
38 writes a function `init_all_optabs' that initializes the optabs with
39 all the insn codes of the relevant patterns present in the MD file.
40
41 This array contains a list of optabs that need to be initialized. Within
42 each string, the name of the pattern to be matched against is delimited
1b3459d2 43 with $( and $). In the string, $a and $b are used to match a short mode
af9e4a0c
RK
44 name (the part of the mode name not including `mode' and converted to
45 lower-case). When writing out the initializer, the entire string is
1b3459d2 46 used. $A and $B are replaced with the full name of the mode; $a and $b
af9e4a0c
RK
47 are replaced with the short form of the name, as above.
48
1b3459d2
ZW
49 If $N is present in the pattern, it means the two modes must be consecutive
50 widths in the same mode class (e.g, QImode and HImode). $I means that
91ce572a
CC
51 only full integer modes should be considered for the next mode, and $F
52 means that only float modes should be considered.
53 $P means that both full and partial integer modes should be considered.
54
55 $V means to emit 'v' if the first mode is a MODE_FLOAT mode.
af9e4a0c
RK
56
57 For some optabs, we store the operation by RTL codes. These are only
1b3459d2 58 used for comparisons. In that case, $c and $C are the lower-case and
af9e4a0c
RK
59 upper-case forms of the comparison, respectively. */
60
83182544 61static const char * const optabs[] =
85363ca0
ZW
62{ "sext_optab->handlers[$B][$A].insn_code = CODE_FOR_$(extend$a$b2$)",
63 "zext_optab->handlers[$B][$A].insn_code = CODE_FOR_$(zero_extend$a$b2$)",
64 "sfix_optab->handlers[$B][$A].insn_code = CODE_FOR_$(fix$F$a$I$b2$)",
65 "ufix_optab->handlers[$B][$A].insn_code = CODE_FOR_$(fixuns$F$a$b2$)",
66 "sfixtrunc_optab->handlers[$B][$A].insn_code = CODE_FOR_$(fix_trunc$F$a$I$b2$)",
67 "ufixtrunc_optab->handlers[$B][$A].insn_code = CODE_FOR_$(fixuns_trunc$F$a$I$b2$)",
68 "sfloat_optab->handlers[$B][$A].insn_code = CODE_FOR_$(float$I$a$F$b2$)",
69 "ufloat_optab->handlers[$B][$A].insn_code = CODE_FOR_$(floatuns$I$a$F$b2$)",
70 "trunc_optab->handlers[$B][$A].insn_code = CODE_FOR_$(trunc$a$b2$)",
91ce572a 71 "add_optab->handlers[$A].insn_code = CODE_FOR_$(add$P$a3$)",
85363ca0
ZW
72 "addv_optab->handlers[$A].insn_code =\n\
73 add_optab->handlers[$A].insn_code = CODE_FOR_$(add$F$a3$)",
74 "addv_optab->handlers[$A].insn_code = CODE_FOR_$(addv$I$a3$)",
91ce572a 75 "sub_optab->handlers[$A].insn_code = CODE_FOR_$(sub$P$a3$)",
85363ca0
ZW
76 "subv_optab->handlers[$A].insn_code =\n\
77 sub_optab->handlers[$A].insn_code = CODE_FOR_$(sub$F$a3$)",
78 "subv_optab->handlers[$A].insn_code = CODE_FOR_$(subv$I$a3$)",
91ce572a 79 "smul_optab->handlers[$A].insn_code = CODE_FOR_$(mul$P$a3$)",
85363ca0
ZW
80 "smulv_optab->handlers[$A].insn_code =\n\
81 smul_optab->handlers[$A].insn_code = CODE_FOR_$(mul$F$a3$)",
82 "smulv_optab->handlers[$A].insn_code = CODE_FOR_$(mulv$I$a3$)",
1b3459d2
ZW
83 "umul_highpart_optab->handlers[$A].insn_code = CODE_FOR_$(umul$a3_highpart$)",
84 "smul_highpart_optab->handlers[$A].insn_code = CODE_FOR_$(smul$a3_highpart$)",
85 "smul_widen_optab->handlers[$B].insn_code = CODE_FOR_$(mul$a$b3$)$N",
86 "umul_widen_optab->handlers[$B].insn_code = CODE_FOR_$(umul$a$b3$)$N",
ef89d648 87 "sdiv_optab->handlers[$A].insn_code = CODE_FOR_$(div$a3$)",
85363ca0 88 "sdivv_optab->handlers[$A].insn_code = CODE_FOR_$(div$V$I$a3$)",
1b3459d2
ZW
89 "udiv_optab->handlers[$A].insn_code = CODE_FOR_$(udiv$I$a3$)",
90 "sdivmod_optab->handlers[$A].insn_code = CODE_FOR_$(divmod$a4$)",
91 "udivmod_optab->handlers[$A].insn_code = CODE_FOR_$(udivmod$a4$)",
92 "smod_optab->handlers[$A].insn_code = CODE_FOR_$(mod$a3$)",
93 "umod_optab->handlers[$A].insn_code = CODE_FOR_$(umod$a3$)",
5ae27cfa
UB
94 "fmod_optab->handlers[$A].insn_code = CODE_FOR_$(fmod$a3$)",
95 "drem_optab->handlers[$A].insn_code = CODE_FOR_$(drem$a3$)",
1b3459d2
ZW
96 "ftrunc_optab->handlers[$A].insn_code = CODE_FOR_$(ftrunc$F$a2$)",
97 "and_optab->handlers[$A].insn_code = CODE_FOR_$(and$a3$)",
98 "ior_optab->handlers[$A].insn_code = CODE_FOR_$(ior$a3$)",
99 "xor_optab->handlers[$A].insn_code = CODE_FOR_$(xor$a3$)",
100 "ashl_optab->handlers[$A].insn_code = CODE_FOR_$(ashl$a3$)",
101 "ashr_optab->handlers[$A].insn_code = CODE_FOR_$(ashr$a3$)",
102 "lshr_optab->handlers[$A].insn_code = CODE_FOR_$(lshr$a3$)",
103 "rotl_optab->handlers[$A].insn_code = CODE_FOR_$(rotl$a3$)",
104 "rotr_optab->handlers[$A].insn_code = CODE_FOR_$(rotr$a3$)",
7ae4d8d4
RH
105 "smin_optab->handlers[$A].insn_code = CODE_FOR_$(smin$a3$)",
106 "smax_optab->handlers[$A].insn_code = CODE_FOR_$(smax$a3$)",
1b3459d2
ZW
107 "umin_optab->handlers[$A].insn_code = CODE_FOR_$(umin$I$a3$)",
108 "umax_optab->handlers[$A].insn_code = CODE_FOR_$(umax$I$a3$)",
b5e01d4b
RS
109 "pow_optab->handlers[$A].insn_code = CODE_FOR_$(pow$a3$)",
110 "atan2_optab->handlers[$A].insn_code = CODE_FOR_$(atan2$a3$)",
91ce572a 111 "neg_optab->handlers[$A].insn_code = CODE_FOR_$(neg$P$a2$)",
85363ca0
ZW
112 "negv_optab->handlers[$A].insn_code =\n\
113 neg_optab->handlers[$A].insn_code = CODE_FOR_$(neg$F$a2$)",
114 "negv_optab->handlers[$A].insn_code = CODE_FOR_$(negv$I$a2$)",
91ce572a 115 "abs_optab->handlers[$A].insn_code = CODE_FOR_$(abs$P$a2$)",
85363ca0
ZW
116 "absv_optab->handlers[$A].insn_code =\n\
117 abs_optab->handlers[$A].insn_code = CODE_FOR_$(abs$F$a2$)",
118 "absv_optab->handlers[$A].insn_code = CODE_FOR_$(absv$I$a2$)",
046625fa 119 "copysign_optab->handlers[$A].insn_code = CODE_FOR_$(copysign$F$a3$)",
1b3459d2 120 "sqrt_optab->handlers[$A].insn_code = CODE_FOR_$(sqrt$a2$)",
4977bab6 121 "floor_optab->handlers[$A].insn_code = CODE_FOR_$(floor$a2$)",
d8b42d06 122 "lfloor_optab->handlers[$A].insn_code = CODE_FOR_$(lfloor$a2$)",
4977bab6 123 "ceil_optab->handlers[$A].insn_code = CODE_FOR_$(ceil$a2$)",
f94b1661 124 "lceil_optab->handlers[$A].insn_code = CODE_FOR_$(lceil$a2$)",
4977bab6 125 "round_optab->handlers[$A].insn_code = CODE_FOR_$(round$a2$)",
edeacc14 126 "btrunc_optab->handlers[$A].insn_code = CODE_FOR_$(btrunc$a2$)",
4977bab6 127 "nearbyint_optab->handlers[$A].insn_code = CODE_FOR_$(nearbyint$a2$)",
edeacc14 128 "rint_optab->handlers[$A].insn_code = CODE_FOR_$(rint$a2$)",
21e01bf1 129 "lrint_optab->handlers[$A].insn_code = CODE_FOR_$(lrint$a2$)",
6c7cf1f0 130 "sincos_optab->handlers[$A].insn_code = CODE_FOR_$(sincos$a3$)",
1b3459d2 131 "sin_optab->handlers[$A].insn_code = CODE_FOR_$(sin$a2$)",
c56122d8 132 "asin_optab->handlers[$A].insn_code = CODE_FOR_$(asin$a2$)",
1b3459d2 133 "cos_optab->handlers[$A].insn_code = CODE_FOR_$(cos$a2$)",
c56122d8 134 "acos_optab->handlers[$A].insn_code = CODE_FOR_$(acos$a2$)",
e7b489c8 135 "exp_optab->handlers[$A].insn_code = CODE_FOR_$(exp$a2$)",
a251102e
UB
136 "exp10_optab->handlers[$A].insn_code = CODE_FOR_$(exp10$a2$)",
137 "exp2_optab->handlers[$A].insn_code = CODE_FOR_$(exp2$a2$)",
7a8e07c7 138 "expm1_optab->handlers[$A].insn_code = CODE_FOR_$(expm1$a2$)",
c94a75af 139 "ldexp_optab->handlers[$A].insn_code = CODE_FOR_$(ldexp$a3$)",
88b28a31
UB
140 "logb_optab->handlers[$A].insn_code = CODE_FOR_$(logb$a2$)",
141 "ilogb_optab->handlers[$A].insn_code = CODE_FOR_$(ilogb$a2$)",
e7b489c8 142 "log_optab->handlers[$A].insn_code = CODE_FOR_$(log$a2$)",
3b8e0c91
UB
143 "log10_optab->handlers[$A].insn_code = CODE_FOR_$(log10$a2$)",
144 "log2_optab->handlers[$A].insn_code = CODE_FOR_$(log2$a2$)",
c2fcfa4f 145 "log1p_optab->handlers[$A].insn_code = CODE_FOR_$(log1p$a2$)",
82d397c7
RS
146 "tan_optab->handlers[$A].insn_code = CODE_FOR_$(tan$a2$)",
147 "atan_optab->handlers[$A].insn_code = CODE_FOR_$(atan$a2$)",
1b3459d2
ZW
148 "strlen_optab->handlers[$A].insn_code = CODE_FOR_$(strlen$a$)",
149 "one_cmpl_optab->handlers[$A].insn_code = CODE_FOR_$(one_cmpl$a2$)",
150 "ffs_optab->handlers[$A].insn_code = CODE_FOR_$(ffs$a2$)",
2928cd7a
RH
151 "clz_optab->handlers[$A].insn_code = CODE_FOR_$(clz$a2$)",
152 "ctz_optab->handlers[$A].insn_code = CODE_FOR_$(ctz$a2$)",
153 "popcount_optab->handlers[$A].insn_code = CODE_FOR_$(popcount$a2$)",
154 "parity_optab->handlers[$A].insn_code = CODE_FOR_$(parity$a2$)",
1b3459d2
ZW
155 "mov_optab->handlers[$A].insn_code = CODE_FOR_$(mov$a$)",
156 "movstrict_optab->handlers[$A].insn_code = CODE_FOR_$(movstrict$a$)",
1e0598e2 157 "movmisalign_optab->handlers[$A].insn_code = CODE_FOR_$(movmisalign$a$)",
1b3459d2
ZW
158 "cmp_optab->handlers[$A].insn_code = CODE_FOR_$(cmp$a$)",
159 "tst_optab->handlers[$A].insn_code = CODE_FOR_$(tst$a$)",
068f5dea 160 "addcc_optab->handlers[$A].insn_code = CODE_FOR_$(add$acc$)",
1b3459d2
ZW
161 "bcc_gen_fctn[$C] = gen_$(b$c$)",
162 "setcc_gen_code[$C] = CODE_FOR_$(s$c$)",
163 "movcc_gen_code[$A] = CODE_FOR_$(mov$acc$)",
164 "cbranch_optab->handlers[$A].insn_code = CODE_FOR_$(cbranch$a4$)",
165 "cmov_optab->handlers[$A].insn_code = CODE_FOR_$(cmov$a6$)",
166 "cstore_optab->handlers[$A].insn_code = CODE_FOR_$(cstore$a4$)",
371b8fc0 167 "push_optab->handlers[$A].insn_code = CODE_FOR_$(push$a1$)",
1b3459d2
ZW
168 "reload_in_optab[$A] = CODE_FOR_$(reload_in$a$)",
169 "reload_out_optab[$A] = CODE_FOR_$(reload_out$a$)",
70128ad9
AO
170 "movmem_optab[$A] = CODE_FOR_$(movmem$a$)",
171 "clrmem_optab[$A] = CODE_FOR_$(clrmem$a$)",
118355a0 172 "cmpstr_optab[$A] = CODE_FOR_$(cmpstr$a$)",
997404de 173 "cmpmem_optab[$A] = CODE_FOR_$(cmpmem$a$)",
48ae6c13
RH
174 "sync_add_optab[$A] = CODE_FOR_$(sync_add$I$a$)",
175 "sync_sub_optab[$A] = CODE_FOR_$(sync_sub$I$a$)",
176 "sync_ior_optab[$A] = CODE_FOR_$(sync_ior$I$a$)",
177 "sync_and_optab[$A] = CODE_FOR_$(sync_and$I$a$)",
178 "sync_xor_optab[$A] = CODE_FOR_$(sync_xor$I$a$)",
179 "sync_nand_optab[$A] = CODE_FOR_$(sync_nand$I$a$)",
180 "sync_old_add_optab[$A] = CODE_FOR_$(sync_old_add$I$a$)",
181 "sync_old_sub_optab[$A] = CODE_FOR_$(sync_old_sub$I$a$)",
182 "sync_old_ior_optab[$A] = CODE_FOR_$(sync_old_ior$I$a$)",
183 "sync_old_and_optab[$A] = CODE_FOR_$(sync_old_and$I$a$)",
184 "sync_old_xor_optab[$A] = CODE_FOR_$(sync_old_xor$I$a$)",
185 "sync_old_nand_optab[$A] = CODE_FOR_$(sync_old_nand$I$a$)",
186 "sync_new_add_optab[$A] = CODE_FOR_$(sync_new_add$I$a$)",
187 "sync_new_sub_optab[$A] = CODE_FOR_$(sync_new_sub$I$a$)",
188 "sync_new_ior_optab[$A] = CODE_FOR_$(sync_new_ior$I$a$)",
189 "sync_new_and_optab[$A] = CODE_FOR_$(sync_new_and$I$a$)",
190 "sync_new_xor_optab[$A] = CODE_FOR_$(sync_new_xor$I$a$)",
191 "sync_new_nand_optab[$A] = CODE_FOR_$(sync_new_nand$I$a$)",
192 "sync_compare_and_swap[$A] = CODE_FOR_$(sync_compare_and_swap$I$a$)",
193 "sync_compare_and_swap_cc[$A] = CODE_FOR_$(sync_compare_and_swap_cc$I$a$)",
194 "sync_lock_test_and_set[$A] = CODE_FOR_$(sync_lock_test_and_set$I$a$)",
195 "sync_lock_release[$A] = CODE_FOR_$(sync_lock_release$I$a$)",
997404de
JH
196 "vec_set_optab->handlers[$A].insn_code = CODE_FOR_$(vec_set$a$)",
197 "vec_extract_optab->handlers[$A].insn_code = CODE_FOR_$(vec_extract$a$)",
7ccf35ed 198 "vec_init_optab->handlers[$A].insn_code = CODE_FOR_$(vec_init$a$)",
7ce67fbe
DP
199 "vec_realign_load_optab->handlers[$A].insn_code = CODE_FOR_$(vec_realign_load_$a$)",
200 "vcond_gen_code[$A] = CODE_FOR_$(vcond$a$)",
48ae6c13
RH
201 "vcondu_gen_code[$A] = CODE_FOR_$(vcondu$a$)"
202};
af9e4a0c 203
3d7aafde 204static void gen_insn (rtx);
56c0e996 205
af9e4a0c 206static void
3d7aafde 207gen_insn (rtx insn)
af9e4a0c 208{
3cce094d 209 const char *name = XSTR (insn, 0);
a544cfd2 210 int m1 = 0, m2 = 0, op = 0;
5ae9a7e9 211 size_t pindex;
af9e4a0c 212 int i;
85fda1eb 213 const char *np, *pp, *p, *q;
af9e4a0c
RK
214
215 /* Don't mention instructions whose names are the null string.
216 They are in the machine description just to be recognized. */
217 if (*name == 0)
218 return;
219
220 /* See if NAME matches one of the patterns we have for the optabs we know
221 about. */
222
b6a1cbae 223 for (pindex = 0; pindex < ARRAY_SIZE (optabs); pindex++)
af9e4a0c 224 {
91ce572a 225 int force_float = 0, force_int = 0, force_partial_int = 0;
af9e4a0c
RK
226 int force_consec = 0;
227 int matches = 1;
228
1b3459d2 229 for (pp = optabs[pindex]; pp[0] != '$' || pp[1] != '('; pp++)
af9e4a0c
RK
230 ;
231
1b3459d2 232 for (pp += 2, np = name; matches && ! (pp[0] == '$' && pp[1] == ')');
af9e4a0c
RK
233 pp++)
234 {
1b3459d2 235 if (*pp != '$')
af9e4a0c
RK
236 {
237 if (*pp != *np++)
238 break;
239 }
240 else
241 switch (*++pp)
242 {
243 case 'N':
244 force_consec = 1;
245 break;
246 case 'I':
247 force_int = 1;
248 break;
91ce572a
CC
249 case 'P':
250 force_partial_int = 1;
251 break;
af9e4a0c
RK
252 case 'F':
253 force_float = 1;
254 break;
91ce572a
CC
255 case 'V':
256 break;
af9e4a0c
RK
257 case 'c':
258 for (op = 0; op < NUM_RTX_CODE; op++)
259 {
5f06c983 260 for (p = GET_RTX_NAME(op), q = np; *p; p++, q++)
af9e4a0c
RK
261 if (*p != *q)
262 break;
263
264 /* We have to be concerned about matching "gt" and
265 missing "gtu", e.g., so verify we have reached the
4639555c 266 end of thing we are to match. */
ec8e098d
PB
267 if (*p == 0 && *q == 0
268 && (GET_RTX_CLASS (op) == RTX_COMPARE
269 || GET_RTX_CLASS (op) == RTX_COMM_COMPARE))
af9e4a0c
RK
270 break;
271 }
272
273 if (op == NUM_RTX_CODE)
274 matches = 0;
275 else
5f06c983 276 np += strlen (GET_RTX_NAME(op));
af9e4a0c
RK
277 break;
278 case 'a':
279 case 'b':
4639555c
ILT
280 /* This loop will stop at the first prefix match, so
281 look through the modes in reverse order, in case
94134f42 282 there are extra CC modes and CC is a prefix of the
4639555c 283 CC modes (as it should be). */
85363ca0 284 for (i = (MAX_MACHINE_MODE) - 1; i >= 0; i--)
af9e4a0c 285 {
a4ec8d12 286 for (p = GET_MODE_NAME(i), q = np; *p; p++, q++)
92a438d1 287 if (TOLOWER (*p) != *q)
af9e4a0c
RK
288 break;
289
290 if (*p == 0
7d9e680f
DB
291 && (! force_int || mode_class[i] == MODE_INT
292 || mode_class[i] == MODE_VECTOR_INT)
91ce572a
CC
293 && (! force_partial_int
294 || mode_class[i] == MODE_INT
7d9e680f
DB
295 || mode_class[i] == MODE_PARTIAL_INT
296 || mode_class[i] == MODE_VECTOR_INT)
297 && (! force_float || mode_class[i] == MODE_FLOAT
6041dc3c 298 || mode_class[i] == MODE_COMPLEX_FLOAT
7d9e680f 299 || mode_class[i] == MODE_VECTOR_FLOAT))
af9e4a0c
RK
300 break;
301 }
302
4639555c 303 if (i < 0)
af9e4a0c
RK
304 matches = 0;
305 else if (*pp == 'a')
a4ec8d12 306 m1 = i, np += strlen (GET_MODE_NAME(i));
af9e4a0c 307 else
a4ec8d12 308 m2 = i, np += strlen (GET_MODE_NAME(i));
af9e4a0c 309
91ce572a 310 force_int = force_partial_int = force_float = 0;
af9e4a0c
RK
311 break;
312
313 default:
b2d59f6f 314 gcc_unreachable ();
af9e4a0c
RK
315 }
316 }
317
1b3459d2 318 if (matches && pp[0] == '$' && pp[1] == ')'
af9e4a0c 319 && *np == 0
88a5e9da 320 && (! force_consec || (int) GET_MODE_WIDER_MODE(m1) == m2))
af9e4a0c
RK
321 break;
322 }
323
b6a1cbae 324 if (pindex == ARRAY_SIZE (optabs))
af9e4a0c
RK
325 return;
326
327 /* We found a match. If this pattern is only conditionally present,
328 write out the "if" and two extra blanks. */
329
330 if (*XSTR (insn, 2) != 0)
331 printf (" if (HAVE_%s)\n ", name);
332
333 printf (" ");
334
335 /* Now write out the initialization, making all required substitutions. */
336 for (pp = optabs[pindex]; *pp; pp++)
337 {
1b3459d2
ZW
338 if (*pp != '$')
339 putchar (*pp);
af9e4a0c
RK
340 else
341 switch (*++pp)
342 {
343 case '(': case ')':
344 case 'I': case 'F': case 'N':
345 break;
91ce572a
CC
346 case 'V':
347 if (GET_MODE_CLASS (m1) == MODE_FLOAT)
348 printf ("v");
349 break;
af9e4a0c 350 case 'a':
a4ec8d12 351 for (np = GET_MODE_NAME(m1); *np; np++)
92a438d1 352 putchar (TOLOWER (*np));
af9e4a0c
RK
353 break;
354 case 'b':
a4ec8d12 355 for (np = GET_MODE_NAME(m2); *np; np++)
92a438d1 356 putchar (TOLOWER (*np));
af9e4a0c
RK
357 break;
358 case 'A':
85363ca0 359 printf ("%smode", GET_MODE_NAME(m1));
af9e4a0c
RK
360 break;
361 case 'B':
85363ca0 362 printf ("%smode", GET_MODE_NAME(m2));
af9e4a0c
RK
363 break;
364 case 'c':
5f06c983 365 printf ("%s", GET_RTX_NAME(op));
af9e4a0c
RK
366 break;
367 case 'C':
5f06c983 368 for (np = GET_RTX_NAME(op); *np; np++)
92a438d1 369 putchar (TOUPPER (*np));
af9e4a0c
RK
370 break;
371 }
372 }
373
374 printf (";\n");
375}
af9e4a0c 376
3d7aafde 377extern int main (int, char **);
c1b59dce 378
af9e4a0c 379int
3d7aafde 380main (int argc, char **argv)
af9e4a0c
RK
381{
382 rtx desc;
af9e4a0c 383
f8b6598e 384 progname = "genopinit";
af9e4a0c 385
04d8aa70 386 if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE)
c88c0d42 387 return (FATAL_EXIT_CODE);
af9e4a0c 388
af9e4a0c
RK
389 printf ("/* Generated automatically by the program `genopinit'\n\
390from the machine description file `md'. */\n\n");
391
392 printf ("#include \"config.h\"\n");
729da3f5 393 printf ("#include \"system.h\"\n");
4977bab6
ZW
394 printf ("#include \"coretypes.h\"\n");
395 printf ("#include \"tm.h\"\n");
af9e4a0c
RK
396 printf ("#include \"rtl.h\"\n");
397 printf ("#include \"flags.h\"\n");
af9e4a0c
RK
398 printf ("#include \"insn-config.h\"\n");
399 printf ("#include \"recog.h\"\n");
400 printf ("#include \"expr.h\"\n");
e78d8e51 401 printf ("#include \"optabs.h\"\n");
af9e4a0c
RK
402 printf ("#include \"reload.h\"\n\n");
403
6906ba40 404 printf ("void\ninit_all_optabs (void)\n{\n");
af9e4a0c 405
dcc3fcf2
KH
406 puts ("\
407#ifdef FIXUNS_TRUNC_LIKE_FIX_TRUNC\n\
408 int i, j;\n\
409#endif\n");
410
af9e4a0c
RK
411 /* Read the machine description. */
412
413 while (1)
414 {
c88c0d42
CP
415 int line_no, insn_code_number = 0;
416
417 desc = read_md_rtx (&line_no, &insn_code_number);
418 if (desc == NULL)
af9e4a0c 419 break;
af9e4a0c 420
af9e4a0c
RK
421 if (GET_CODE (desc) == DEFINE_INSN || GET_CODE (desc) == DEFINE_EXPAND)
422 gen_insn (desc);
423 }
424
85363ca0
ZW
425 puts ("\
426\n\
427#ifdef FIXUNS_TRUNC_LIKE_FIX_TRUNC\n\
428 /* This flag says the same insns that convert to a signed fixnum\n\
429 also convert validly to an unsigned one. */\n\
430 for (i = 0; i < NUM_MACHINE_MODES; i++)\n\
431 for (j = 0; j < NUM_MACHINE_MODES; j++)\n\
432 ufixtrunc_optab->handlers[i][j].insn_code\n\
433 = sfixtrunc_optab->handlers[i][j].insn_code;\n\
434#endif\n\
435}");
af9e4a0c
RK
436
437 fflush (stdout);
c1b59dce 438 return (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);
af9e4a0c 439}
a995e389
RH
440
441/* Define this so we can link with print-rtl.o to get debug_rtx function. */
442const char *
3d7aafde 443get_insn_name (int code ATTRIBUTE_UNUSED)
a995e389
RH
444{
445 return NULL;
446}