1 /* Bytecode conversion definitions for GNU C-compiler.
2 Copyright (C) 1993, 1994 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
28 #include "bc-typecd.h"
29 #include "bc-opcode.h"
36 #ifdef NEED_DECLARATION_FREE
37 extern void free PROTO((void *));
40 #define obstack_chunk_alloc xmalloc
41 #define obstack_chunk_free free
43 extern char *xmalloc ();
45 /* Table relating interpreter typecodes to machine modes. */
46 #define GET_TYPECODE_MODE(CODE) (typecode_mode[((int) CODE)])
47 enum machine_mode typecode_mode[] = {
48 #define DEFTYPECODE(CODE, NAME, MODE, TYPE) MODE,
49 #include "bc-typecd.def"
53 /* Machine mode to type code map */
54 static enum typecode signed_mode_to_code_map[MAX_MACHINE_MODE+1];
55 static enum typecode unsigned_mode_to_code_map[MAX_MACHINE_MODE+1];
57 #define GET_TYPECODE_SIZE(CODE) GET_MODE_SIZE (GET_TYPECODE_MODE (CODE))
59 #define BIG_ARBITRARY_NUMBER 100000
61 /* Table of recipes for conversions among scalar types, to be filled
62 in as needed at run time. */
63 static struct conversion_recipe
65 unsigned char *opcodes; /* Bytecodes to emit in order. */
66 int nopcodes; /* Count of bytecodes. */
67 int cost; /* A rather arbitrary cost function. */
68 } conversion_recipe[NUM_TYPECODES][NUM_TYPECODES];
70 /* Binary operator tables. */
71 struct binary_operator optab_plus_expr[] = {
72 { addSI, SIcode, SIcode, SIcode },
73 { addDI, DIcode, DIcode, DIcode },
74 { addSF, SFcode, SFcode, SFcode },
75 { addDF, DFcode, DFcode, DFcode },
76 { addXF, XFcode, XFcode, XFcode },
77 { addPSI, Pcode, Pcode, SIcode },
81 struct binary_operator optab_minus_expr[] = {
82 { subSI, SIcode, SIcode, SIcode },
83 { subDI, DIcode, DIcode, DIcode },
84 { subSF, SFcode, SFcode, SFcode },
85 { subDF, DFcode, DFcode, DFcode },
86 { subXF, XFcode, XFcode, XFcode },
87 { subPP, SIcode, Pcode, Pcode },
91 /* The ordering of the tables for multiplicative operators
92 is such that unsigned operations will be preferred to signed
93 operations when one argument is unsigned. */
95 struct binary_operator optab_mult_expr[] = {
96 { mulSU, SUcode, SUcode, SUcode },
97 { mulDU, DUcode, DUcode, DUcode },
98 { mulSI, SIcode, SIcode, SIcode },
99 { mulDI, DIcode, DIcode, DIcode },
100 { mulSF, SFcode, SFcode, SFcode },
101 { mulDF, DFcode, DFcode, DFcode },
102 { mulXF, XFcode, XFcode, XFcode },
106 struct binary_operator optab_trunc_div_expr[] = {
107 { divSU, SUcode, SUcode, SUcode },
108 { divDU, DUcode, DUcode, DUcode },
109 { divSI, SIcode, SIcode, SIcode },
110 { divDI, DIcode, DIcode, DIcode },
114 struct binary_operator optab_trunc_mod_expr[] = {
115 { modSU, SUcode, SUcode, SUcode },
116 { modDU, DUcode, DUcode, DUcode },
117 { modSI, SIcode, SIcode, SIcode },
118 { modDI, DIcode, DIcode, DIcode },
122 struct binary_operator optab_rdiv_expr[] = {
123 { divSF, SFcode, SFcode, SFcode },
124 { divDF, DFcode, DFcode, DFcode },
125 { divXF, XFcode, XFcode, XFcode },
129 struct binary_operator optab_bit_and_expr[] = {
130 { andSI, SIcode, SIcode, SIcode },
131 { andDI, DIcode, DIcode, DIcode },
135 struct binary_operator optab_bit_ior_expr[] = {
136 { iorSI, SIcode, SIcode, SIcode },
137 { iorDI, DIcode, DIcode, DIcode },
141 struct binary_operator optab_bit_xor_expr[] = {
142 { xorSI, SIcode, SIcode, SIcode },
143 { xorDI, DIcode, DIcode, DIcode },
147 struct binary_operator optab_lshift_expr[] = {
148 { lshiftSI, SIcode, SIcode, SIcode },
149 { lshiftSU, SUcode, SUcode, SIcode },
150 { lshiftDI, DIcode, DIcode, SIcode },
151 { lshiftDU, DUcode, DUcode, SIcode },
155 struct binary_operator optab_rshift_expr[] = {
156 { rshiftSI, SIcode, SIcode, SIcode },
157 { rshiftSU, SUcode, SUcode, SIcode },
158 { rshiftDI, DIcode, DIcode, SIcode },
159 { rshiftDU, DUcode, DUcode, SIcode },
163 struct binary_operator optab_truth_and_expr[] = {
164 { andSI, SIcode, Tcode, Tcode },
168 struct binary_operator optab_truth_or_expr[] = {
169 { iorSI, SIcode, Tcode, Tcode },
173 struct binary_operator optab_lt_expr[] = {
174 { ltSI, Tcode, SIcode, SIcode },
175 { ltSU, Tcode, SUcode, SUcode },
176 { ltDI, Tcode, DIcode, DIcode },
177 { ltDU, Tcode, DUcode, DUcode },
178 { ltSF, Tcode, SFcode, SFcode },
179 { ltDF, Tcode, DFcode, DFcode },
180 { ltXF, Tcode, XFcode, XFcode },
181 { ltP, Tcode, Pcode, Pcode },
185 struct binary_operator optab_le_expr[] = {
186 { leSI, Tcode, SIcode, SIcode },
187 { leSU, Tcode, SUcode, SUcode },
188 { leDI, Tcode, DIcode, DIcode },
189 { leDU, Tcode, DUcode, DUcode },
190 { leSF, Tcode, SFcode, SFcode },
191 { leDF, Tcode, DFcode, DFcode },
192 { leXF, Tcode, XFcode, XFcode },
193 { leP, Tcode, Pcode, Pcode },
197 struct binary_operator optab_ge_expr[] = {
198 { geSI, Tcode, SIcode, SIcode },
199 { geSU, Tcode, SUcode, SUcode },
200 { geDI, Tcode, DIcode, DIcode },
201 { geDU, Tcode, DUcode, DUcode },
202 { geSF, Tcode, SFcode, SFcode },
203 { geDF, Tcode, DFcode, DFcode },
204 { geXF, Tcode, XFcode, XFcode },
205 { geP, Tcode, Pcode, Pcode },
209 struct binary_operator optab_gt_expr[] = {
210 { gtSI, Tcode, SIcode, SIcode },
211 { gtSU, Tcode, SUcode, SUcode },
212 { gtDI, Tcode, DIcode, DIcode },
213 { gtDU, Tcode, DUcode, DUcode },
214 { gtSF, Tcode, SFcode, SFcode },
215 { gtDF, Tcode, DFcode, DFcode },
216 { gtXF, Tcode, XFcode, XFcode },
217 { gtP, Tcode, Pcode, Pcode },
221 struct binary_operator optab_eq_expr[] = {
222 { eqSI, Tcode, SIcode, SIcode },
223 { eqDI, Tcode, DIcode, DIcode },
224 { eqSF, Tcode, SFcode, SFcode },
225 { eqDF, Tcode, DFcode, DFcode },
226 { eqXF, Tcode, XFcode, XFcode },
227 { eqP, Tcode, Pcode, Pcode },
231 struct binary_operator optab_ne_expr[] = {
232 { neSI, Tcode, SIcode, SIcode },
233 { neDI, Tcode, DIcode, DIcode },
234 { neSF, Tcode, SFcode, SFcode },
235 { neDF, Tcode, DFcode, DFcode },
236 { neXF, Tcode, XFcode, XFcode },
237 { neP, Tcode, Pcode, Pcode },
241 /* Unary operator tables. */
242 struct unary_operator optab_negate_expr[] = {
243 { negSI, SIcode, SIcode },
244 { negDI, DIcode, DIcode },
245 { negSF, SFcode, SFcode },
246 { negDF, DFcode, DFcode },
247 { negXF, XFcode, XFcode },
251 struct unary_operator optab_bit_not_expr[] = {
252 { notSI, SIcode, SIcode },
253 { notDI, DIcode, DIcode },
257 struct unary_operator optab_truth_not_expr[] = {
258 { notT, SIcode, SIcode },
262 /* Increment operator tables. */
263 struct increment_operator optab_predecrement_expr[] = {
264 { predecQI, QIcode },
265 { predecQI, QUcode },
266 { predecHI, HIcode },
267 { predecHI, HUcode },
268 { predecSI, SIcode },
269 { predecSI, SUcode },
270 { predecDI, DIcode },
271 { predecDI, DUcode },
273 { predecSF, SFcode },
274 { predecDF, DFcode },
275 { predecXF, XFcode },
279 struct increment_operator optab_preincrement_expr[] = {
280 { preincQI, QIcode },
281 { preincQI, QUcode },
282 { preincHI, HIcode },
283 { preincHI, HUcode },
284 { preincSI, SIcode },
285 { preincSI, SUcode },
286 { preincDI, DIcode },
287 { preincDI, DUcode },
289 { preincSF, SFcode },
290 { preincDF, DFcode },
291 { preincXF, XFcode },
295 struct increment_operator optab_postdecrement_expr[] = {
296 { postdecQI, QIcode },
297 { postdecQI, QUcode },
298 { postdecHI, HIcode },
299 { postdecHI, HUcode },
300 { postdecSI, SIcode },
301 { postdecSI, SUcode },
302 { postdecDI, DIcode },
303 { postdecDI, DUcode },
305 { postdecSF, SFcode },
306 { postdecDF, DFcode },
307 { postdecXF, XFcode },
311 struct increment_operator optab_postincrement_expr[] = {
312 { postincQI, QIcode },
313 { postincQI, QUcode },
314 { postincHI, HIcode },
315 { postincHI, HUcode },
316 { postincSI, SIcode },
317 { postincSI, SUcode },
318 { postincDI, DIcode },
319 { postincDI, DUcode },
321 { postincSF, SFcode },
322 { postincDF, DFcode },
323 { postincXF, XFcode },
327 /* Table of conversions supported by the interpreter. */
328 static struct conversion_info
330 enum bytecode_opcode opcode; /* here indicates the conversion needs no opcode. */
333 int cost; /* 1 for no-op conversions, 2 for widening conversions,
334 4 for int/float conversions, 8 for narrowing conversions. */
335 } conversion_info[] = {
336 { -1, QIcode, QUcode, 1 },
337 { -1, HIcode, HUcode, 1 },
338 { -1, SIcode, SUcode, 1 },
339 { -1, DIcode, DUcode, 1 },
340 { -1, QUcode, QIcode, 1 },
341 { -1, HUcode, HIcode, 1 },
342 { -1, SUcode, SIcode, 1 },
343 { -1, DUcode, DIcode, 1 },
344 { -1, Tcode, SIcode, 1 },
345 { convertQIHI, QIcode, HIcode, 2 },
346 { convertQUHU, QUcode, HUcode, 2 },
347 { convertQUSU, QUcode, SUcode, 2 },
348 { convertHISI, HIcode, SIcode, 2 },
349 { convertHUSU, HUcode, SUcode, 2 },
350 { convertSIDI, SIcode, DIcode, 2 },
351 { convertSUDU, SUcode, DUcode, 2 },
352 { convertSFDF, SFcode, DFcode, 2 },
353 { convertDFXF, DFcode, XFcode, 2 },
354 { convertHIQI, HIcode, QIcode, 8 },
355 { convertSIQI, SIcode, QIcode, 8 },
356 { convertSIHI, SIcode, HIcode, 8 },
357 { convertSUQU, SUcode, QUcode, 8 },
358 { convertDISI, DIcode, SIcode, 8 },
359 { convertDFSF, DFcode, SFcode, 8 },
360 { convertXFDF, XFcode, DFcode, 8 },
361 { convertPSI, Pcode, SIcode, 2 },
362 { convertSIP, SIcode, Pcode, 2 },
363 { convertSIT, SIcode, Tcode, 2 },
364 { convertDIT, DIcode, Tcode, 2 },
365 { convertSFT, SFcode, Tcode, 2 },
366 { convertDFT, DFcode, Tcode, 2 },
367 { convertXFT, XFcode, Tcode, 2 },
368 { convertQISI, QIcode, SIcode, 2 },
369 { convertPT, Pcode, Tcode, 2 },
370 { convertSISF, SIcode, SFcode, 4 },
371 { convertSIDF, SIcode, DFcode, 4 },
372 { convertSIXF, SIcode, XFcode, 4 },
373 { convertSUSF, SUcode, SFcode, 4 },
374 { convertSUDF, SUcode, DFcode, 4 },
375 { convertSUXF, SUcode, XFcode, 4 },
376 { convertDISF, DIcode, SFcode, 4 },
377 { convertDIDF, DIcode, DFcode, 4 },
378 { convertDIXF, DIcode, XFcode, 4 },
379 { convertDUSF, DUcode, SFcode, 4 },
380 { convertDUDF, DUcode, DFcode, 4 },
381 { convertDUXF, DUcode, XFcode, 4 },
382 { convertSFSI, SFcode, SIcode, 4 },
383 { convertDFSI, DFcode, SIcode, 4 },
384 { convertXFSI, XFcode, SIcode, 4 },
385 { convertSFSU, SFcode, SUcode, 4 },
386 { convertDFSU, DFcode, SUcode, 4 },
387 { convertXFSU, XFcode, SUcode, 4 },
388 { convertSFDI, SFcode, DIcode, 4 },
389 { convertDFDI, DFcode, DIcode, 4 },
390 { convertXFDI, XFcode, DIcode, 4 },
391 { convertSFDU, SFcode, DUcode, 4 },
392 { convertDFDU, DFcode, DUcode, 4 },
393 { convertXFDU, XFcode, DUcode, 4 },
394 { convertSIQI, SIcode, QIcode, 8 },
397 #define NUM_CONVERSIONS (sizeof conversion_info / sizeof (struct conversion_info))
399 /* List form of a conversion recipe. */
400 struct conversion_list
402 enum bytecode_opcode opcode;
405 struct conversion_list *prev;
408 /* Determine if it is "reasonable" to add a given conversion to
409 a given list of conversions. The following criteria define
410 "reasonable" conversion lists:
411 * No typecode appears more than once in the sequence (no loops).
412 * At most one conversion from integer to float or vice versa is present.
413 * Either sign extensions or zero extensions may be present, but not both.
414 * No widening conversions occur after a signed/unsigned conversion.
415 * The sequence of sizes must be strict nonincreasing or nondecreasing. */
418 conversion_reasonable_p (conversion, list)
419 struct conversion_info *conversion;
420 struct conversion_list *list;
422 struct conversion_list *curr;
423 int curr_size, prev_size;
424 int has_int_float, has_float_int;
425 int has_sign_extend, has_zero_extend;
426 int has_signed_unsigned, has_unsigned_signed;
432 has_signed_unsigned = 0;
433 has_unsigned_signed = 0;
435 /* Make sure the destination typecode doesn't already appear in
437 for (curr = list; curr; curr = curr->prev)
438 if (conversion->to == curr->to)
441 /* Check for certain kinds of conversions. */
442 if (TYPECODE_INTEGER_P (conversion->from)
443 && TYPECODE_FLOAT_P (conversion->to))
445 if (TYPECODE_FLOAT_P (conversion->from)
446 && TYPECODE_INTEGER_P (conversion->to))
448 if (TYPECODE_SIGNED_P (conversion->from)
449 && TYPECODE_SIGNED_P (conversion->to)
450 && GET_TYPECODE_SIZE (conversion->from)
451 < GET_TYPECODE_SIZE (conversion->to))
453 if (TYPECODE_UNSIGNED_P (conversion->from)
454 && TYPECODE_UNSIGNED_P (conversion->to)
455 && GET_TYPECODE_SIZE (conversion->from)
456 < GET_TYPECODE_SIZE (conversion->to))
459 for (curr = list; curr && curr->prev; curr = curr->prev)
461 if (TYPECODE_INTEGER_P (curr->prev->to)
462 && TYPECODE_FLOAT_P (curr->to))
464 if (TYPECODE_FLOAT_P (curr->prev->to)
465 && TYPECODE_INTEGER_P (curr->to))
467 if (TYPECODE_SIGNED_P (curr->prev->to)
468 && TYPECODE_SIGNED_P (curr->to)
469 && GET_TYPECODE_SIZE (curr->prev->to)
470 < GET_TYPECODE_SIZE (curr->to))
472 if (TYPECODE_UNSIGNED_P (curr->prev->to)
473 && TYPECODE_UNSIGNED_P (curr->to)
474 && GET_TYPECODE_SIZE (curr->prev->to)
475 < GET_TYPECODE_SIZE (curr->to))
477 if (TYPECODE_SIGNED_P (curr->prev->to)
478 && TYPECODE_UNSIGNED_P (curr->to))
479 has_signed_unsigned = 1;
480 if (TYPECODE_UNSIGNED_P (curr->prev->to)
481 && TYPECODE_SIGNED_P (curr->to))
482 has_unsigned_signed = 1;
485 if (TYPECODE_INTEGER_P (conversion->from)
486 && TYPECODE_INTEGER_P (conversion->to)
487 && GET_TYPECODE_SIZE (conversion->to)
488 > GET_TYPECODE_SIZE (conversion->from)
489 && (has_signed_unsigned || has_unsigned_signed))
492 if (has_float_int && has_int_float || has_sign_extend && has_zero_extend)
495 /* Make sure the sequence of destination typecode sizes is
496 strictly nondecreasing or strictly nonincreasing. */
497 prev_size = GET_TYPECODE_SIZE (conversion->to);
498 for (curr = list; curr; curr = curr->prev)
500 curr_size = GET_TYPECODE_SIZE (curr->to);
501 if (curr_size != prev_size)
507 if (curr_size < prev_size)
508 for (prev_size = curr_size; curr; curr = curr->prev)
510 curr_size = GET_TYPECODE_SIZE (curr->to);
511 if (curr_size > prev_size)
513 prev_size = curr_size;
516 for (prev_size = curr_size; curr; curr = curr->prev)
518 curr_size = GET_TYPECODE_SIZE (curr->to);
519 if (curr_size < prev_size)
521 prev_size = curr_size;
527 /* Exhaustively search all reasonable conversions to find one to
528 convert the given types. */
530 static struct conversion_recipe
531 deduce_conversion (from, to)
532 enum typecode from, to;
536 struct conversion_list *list;
538 } *prev, curr, *good, *temp;
539 struct conversion_list *conv, *best;
540 int i, cost, bestcost;
541 struct conversion_recipe result;
542 struct obstack recipe_obstack;
545 obstack_init (&recipe_obstack);
546 curr.next = (struct rl *) obstack_alloc (&recipe_obstack, sizeof (struct rl));
548 = (struct conversion_list *) obstack_alloc (&recipe_obstack,
549 sizeof (struct conversion_list));
550 curr.next->list->opcode = -1;
551 curr.next->list->to = from;
552 curr.next->list->cost = 0;
553 curr.next->list->prev = 0;
559 /* Remove successful conversions from further consideration. */
560 for (prev = &curr; prev; prev = prev->next)
561 if (prev->next && prev->next->list->to == to)
563 temp = prev->next->next;
564 prev->next->next = good;
569 /* Go through each of the pending conversion chains, trying
570 all possible candidate conversions on them. */
571 for (prev = curr.next, curr.next = 0; prev; prev = prev->next)
572 for (i = 0; i < NUM_CONVERSIONS; ++i)
573 if (conversion_info[i].from == prev->list->to
574 && conversion_reasonable_p (&conversion_info[i], prev->list))
576 temp = (struct rl *) obstack_alloc (&recipe_obstack,
578 temp->list = (struct conversion_list *)
579 obstack_alloc (&recipe_obstack,
580 sizeof (struct conversion_list));
581 temp->list->opcode = conversion_info[i].opcode;
582 temp->list->to = conversion_info[i].to;
583 temp->list->cost = conversion_info[i].cost;
584 temp->list->prev = prev->list;
585 temp->next = curr.next;
590 bestcost = BIG_ARBITRARY_NUMBER;
592 for (temp = good; temp; temp = temp->next)
594 for (conv = temp->list, cost = 0; conv; conv = conv->prev)
606 for (i = 0, conv = best; conv; conv = conv->prev)
607 if (conv->opcode != -1)
610 result.opcodes = (unsigned char *) xmalloc (i);
612 for (conv = best; conv; conv = conv->prev)
613 if (conv->opcode != -1)
614 result.opcodes[--i] = conv->opcode;
615 result.cost = bestcost;
616 obstack_free (&recipe_obstack, 0);
620 #define DEDUCE_CONVERSION(FROM, TO) \
621 (conversion_recipe[(int) FROM][(int) TO].opcodes ? 0 \
622 : (conversion_recipe[(int) FROM][(int) TO] \
623 = deduce_conversion (FROM, TO), 0))
626 /* Emit a conversion between the given scalar types. */
629 emit_typecode_conversion (from, to)
630 enum typecode from, to;
634 DEDUCE_CONVERSION (from, to);
635 for (i = 0; i < conversion_recipe[(int) from][(int) to].nopcodes; ++i)
636 bc_emit_instruction (conversion_recipe[(int) from][(int) to].opcodes[i]);
640 /* Initialize mode_to_code_map[] */
643 bc_init_mode_to_code_map ()
647 for (mode = 0; mode < MAX_MACHINE_MODE + 1; mode++)
649 signed_mode_to_code_map[mode]
650 = unsigned_mode_to_code_map[mode]
651 = LAST_AND_UNUSED_TYPECODE;
654 #define DEF_MODEMAP(SYM, CODE, UCODE, CONST, LOAD, STORE) \
655 { signed_mode_to_code_map[(int) SYM] = CODE; \
656 unsigned_mode_to_code_map[(int) SYM] = UCODE; }
657 #include "modemap.def"
660 /* Initialize opcode maps for const, load, and store */
661 bc_init_mode_to_opcode_maps ();
664 /* Given a machine mode return the preferred typecode. */
667 preferred_typecode (mode, unsignedp)
668 enum machine_mode mode;
671 enum typecode code = (unsignedp
672 ? unsigned_mode_to_code_map
673 : signed_mode_to_code_map) [MIN ((int) mode,
674 (int) MAX_MACHINE_MODE)];
676 if (code == LAST_AND_UNUSED_TYPECODE)
683 /* Expand a conversion between the given types. */
686 bc_expand_conversion (from, to)
689 enum typecode fcode, tcode;
691 fcode = preferred_typecode (TYPE_MODE (from), TREE_UNSIGNED (from));
692 tcode = preferred_typecode (TYPE_MODE (to), TREE_UNSIGNED (to));
694 emit_typecode_conversion (fcode, tcode);
697 /* Expand a conversion of the given type to a truth value. */
700 bc_expand_truth_conversion (from)
705 fcode = preferred_typecode (TYPE_MODE (from), TREE_UNSIGNED (from));
706 emit_typecode_conversion (fcode, Tcode);
709 /* Emit an appropriate binary operation. */
712 bc_expand_binary_operation (optab, resulttype, arg0, arg1)
713 struct binary_operator optab[];
714 tree resulttype, arg0, arg1;
716 int i, besti, cost, bestcost;
717 enum typecode resultcode, arg0code, arg1code;
719 resultcode = preferred_typecode (TYPE_MODE (resulttype), TREE_UNSIGNED (resulttype));
720 arg0code = preferred_typecode (TYPE_MODE (TREE_TYPE (arg0)), TREE_UNSIGNED (resulttype));
721 arg1code = preferred_typecode (TYPE_MODE (TREE_TYPE (arg1)), TREE_UNSIGNED (resulttype));
724 bestcost = BIG_ARBITRARY_NUMBER;
726 for (i = 0; optab[i].opcode != -1; ++i)
729 DEDUCE_CONVERSION (arg0code, optab[i].arg0);
730 cost += conversion_recipe[(int) arg0code][(int) optab[i].arg0].cost;
731 DEDUCE_CONVERSION (arg1code, optab[i].arg1);
732 cost += conversion_recipe[(int) arg1code][(int) optab[i].arg1].cost;
743 expand_expr (arg1, 0, VOIDmode, 0);
744 emit_typecode_conversion (arg1code, optab[besti].arg1);
745 expand_expr (arg0, 0, VOIDmode, 0);
746 emit_typecode_conversion (arg0code, optab[besti].arg0);
747 bc_emit_instruction (optab[besti].opcode);
748 emit_typecode_conversion (optab[besti].result, resultcode);
751 /* Emit an appropriate unary operation. */
754 bc_expand_unary_operation (optab, resulttype, arg0)
755 struct unary_operator optab[];
756 tree resulttype, arg0;
758 int i, besti, cost, bestcost;
759 enum typecode resultcode, arg0code;
761 resultcode = preferred_typecode (TYPE_MODE (resulttype), TREE_UNSIGNED (resulttype));
762 arg0code = preferred_typecode (TYPE_MODE (TREE_TYPE (arg0)), TREE_UNSIGNED (TREE_TYPE (arg0)));
765 bestcost = BIG_ARBITRARY_NUMBER;
767 for (i = 0; optab[i].opcode != -1; ++i)
769 DEDUCE_CONVERSION (arg0code, optab[i].arg0);
770 cost = conversion_recipe[(int) arg0code][(int) optab[i].arg0].cost;
781 expand_expr (arg0, 0, VOIDmode, 0);
782 emit_typecode_conversion (arg0code, optab[besti].arg0);
783 bc_emit_instruction (optab[besti].opcode);
784 emit_typecode_conversion (optab[besti].result, resultcode);
788 /* Emit an appropriate increment. */
791 bc_expand_increment (optab, type)
792 struct increment_operator optab[];
798 code = preferred_typecode (TYPE_MODE (type), TREE_UNSIGNED (type));
799 for (i = 0; (int) optab[i].opcode >= 0; ++i)
800 if (code == optab[i].arg)
802 bc_emit_instruction (optab[i].opcode);