|
|
1.1 root 1: /* Convert tree expression to rtl instructions, for GNU compiler.
1.1.1.2 root 2: Copyright (C) 1988 Free Software Foundation, Inc.
1.1 root 3:
4: This file is part of GNU CC.
5:
1.1.1.15 root 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 1, or (at your option)
9: any later version.
10:
1.1 root 11: GNU CC is distributed in the hope that it will be useful,
1.1.1.15 root 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.
15:
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, 675 Mass Ave, Cambridge, MA 02139, USA. */
1.1 root 19:
20:
21: #include "config.h"
22: #include "rtl.h"
23: #include "tree.h"
1.1.1.2 root 24: #include "flags.h"
1.1 root 25: #include "insn-flags.h"
26: #include "insn-codes.h"
27: #include "expr.h"
1.1.1.2 root 28: #include "insn-config.h"
29: #include "recog.h"
1.1.1.17 root 30: #include "gvarargs.h"
31: #include "typeclass.h"
1.1.1.2 root 32:
33: /* Decide whether a function's arguments should be processed
34: from first to last or from last to first. */
35:
36: #ifdef STACK_GROWS_DOWNWARD
37: #ifdef PUSH_ROUNDING
38: #define PUSH_ARGS_REVERSED /* If it's last to first */
39: #endif
40: #endif
41:
42: /* Like STACK_BOUNDARY but in units of bytes, not bits. */
43: #define STACK_BYTES (STACK_BOUNDARY / BITS_PER_UNIT)
1.1 root 44:
45: /* If this is nonzero, we do not bother generating VOLATILE
46: around volatile memory references, and we are willing to
47: output indirect addresses. If cse is to follow, we reject
48: indirect addresses so a useful potential cse is generated;
49: if it is used only once, instruction combination will produce
50: the same indirect address eventually. */
51: int cse_not_expected;
52:
53: /* Nonzero to generate code for all the subroutines within an
54: expression before generating the upper levels of the expression.
55: Nowadays this is never zero. */
56: int do_preexpand_calls = 1;
57:
58: /* Number of units that we should eventually pop off the stack.
59: These are the arguments to function calls that have already returned. */
60: int pending_stack_adjust;
61:
1.1.1.17 root 62: /* Nonzero means stack pops must not be deferred, and deferred stack
63: pops must not be output. It is nonzero inside a function call,
64: inside a conditional expression, inside a statement expression,
65: and in other cases as well. */
66: int inhibit_defer_pop;
1.1.1.6 root 67:
1.1.1.13 root 68: /* A list of all cleanups which belong to the arguments of
1.1.1.8 root 69: function calls being expanded by expand_call. */
70: static tree cleanups_of_this_call;
71:
1.1.1.17 root 72: /* Nonzero means current function may call alloca
73: as a subroutine. (__builtin_alloca does not count.) */
1.1.1.2 root 74: int may_call_alloca;
75:
76: rtx store_expr ();
77: static void store_constructor ();
78: static rtx store_field ();
1.1 root 79: static rtx expand_call ();
1.1.1.2 root 80: static void emit_call_1 ();
81: static rtx prepare_call_address ();
82: static rtx expand_builtin ();
1.1 root 83: static rtx compare ();
1.1.1.2 root 84: static rtx compare_constants ();
1.1 root 85: static rtx compare1 ();
86: static rtx do_store_flag ();
87: static void preexpand_calls ();
1.1.1.2 root 88: static rtx expand_increment ();
89: static void init_queue ();
90:
91: void do_pending_stack_adjust ();
1.1 root 92:
93: /* MOVE_RATIO is the number of move instructions that is better than
94: a block move. */
95:
1.1.1.10 root 96: #ifndef MOVE_RATIO
97: #if defined (HAVE_movstrqi) || defined (HAVE_movstrhi) || defined (HAVE_movstrsi)
1.1 root 98: #define MOVE_RATIO 2
99: #else
1.1.1.10 root 100: /* A value of around 6 would minimize code size; infinity would minimize
101: execution time. */
102: #define MOVE_RATIO 15
103: #endif
1.1 root 104: #endif
105:
106: /* Table indexed by tree code giving 1 if the code is for a
107: comparison operation, or anything that is most easily
108: computed with a conditional branch.
109:
110: We include tree.def to give it the proper length.
111: The contents thus created are irrelevant.
112: The real contents are initialized in init_comparisons. */
113:
1.1.1.2 root 114: #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) 0,
1.1 root 115:
116: static char comparison_code[] = {
117: #include "tree.def"
118: };
119: #undef DEFTREECODE
120:
1.1.1.2 root 121: /* This is run once per compilation. */
122:
123: void
1.1 root 124: init_comparisons ()
125: {
126: comparison_code[(int) EQ_EXPR] = 1;
127: comparison_code[(int) NE_EXPR] = 1;
128: comparison_code[(int) LT_EXPR] = 1;
129: comparison_code[(int) GT_EXPR] = 1;
130: comparison_code[(int) LE_EXPR] = 1;
131: comparison_code[(int) GE_EXPR] = 1;
132: }
1.1.1.2 root 133:
134: /* This is run at the start of compiling a function. */
135:
136: void
137: init_expr ()
138: {
139: init_queue ();
140: may_call_alloca = 0;
141: }
1.1 root 142:
143: /* Manage the queue of increment instructions to be output
144: for POSTINCREMENT_EXPR expressions, etc. */
145:
146: static rtx pending_chain;
147:
148: /* Queue up to increment (or change) VAR later. BODY says how:
149: BODY should be the same thing you would pass to emit_insn
150: to increment right away. It will go to emit_insn later on.
151:
152: The value is a QUEUED expression to be used in place of VAR
1.1.1.2 root 153: where you want to guarantee the pre-incrementation value of VAR. */
1.1 root 154:
155: static rtx
156: enqueue_insn (var, body)
157: rtx var, body;
158: {
159: pending_chain = gen_rtx (QUEUED, GET_MODE (var),
160: var, 0, 0, body, pending_chain);
161: return pending_chain;
162: }
163:
164: /* Use protect_from_queue to convert a QUEUED expression
165: into something that you can put immediately into an instruction.
166: If the queued incrementation has not happened yet,
167: protect_from_queue returns the variable itself.
168: If the incrementation has happened, protect_from_queue returns a temp
169: that contains a copy of the old value of the variable.
170:
171: Any time an rtx which might possibly be a QUEUED is to be put
172: into an instruction, it must be passed through protect_from_queue first.
173: QUEUED expressions are not meaningful in instructions.
174:
175: Do not pass a value through protect_from_queue and then hold
176: on to it for a while before putting it in an instruction!
177: If the queue is flushed in between, incorrect code will result. */
178:
179: rtx
180: protect_from_queue (x, modify)
181: register rtx x;
182: int modify;
183: {
184: register RTX_CODE code = GET_CODE (x);
185: if (code != QUEUED)
186: {
187: /* A special hack for read access to (MEM (QUEUED ...))
188: to facilitate use of autoincrement.
189: Make a copy of the contents of the memory location
190: rather than a copy of the address. */
191: if (code == MEM && GET_CODE (XEXP (x, 0)) == QUEUED && !modify)
192: {
193: register rtx y = XEXP (x, 0);
194: XEXP (x, 0) = QUEUED_VAR (y);
195: if (QUEUED_INSN (y))
196: {
197: register rtx temp = gen_reg_rtx (GET_MODE (x));
198: emit_insn_before (gen_move_insn (temp, x),
199: QUEUED_INSN (y));
200: return temp;
201: }
202: return x;
203: }
204: /* Otherwise, recursively protect the subexpressions of all
205: the kinds of rtx's that can contain a QUEUED. */
206: if (code == MEM)
207: XEXP (x, 0) = protect_from_queue (XEXP (x, 0), 0);
208: else if (code == PLUS || code == MULT)
209: {
210: XEXP (x, 0) = protect_from_queue (XEXP (x, 0), 0);
211: XEXP (x, 1) = protect_from_queue (XEXP (x, 1), 0);
212: }
213: return x;
214: }
215: /* If the increment has not happened, use the variable itself. */
216: if (QUEUED_INSN (x) == 0)
217: return QUEUED_VAR (x);
218: /* If the increment has happened and a pre-increment copy exists,
219: use that copy. */
220: if (QUEUED_COPY (x) != 0)
221: return QUEUED_COPY (x);
222: /* The increment has happened but we haven't set up a pre-increment copy.
223: Set one up now, and use it. */
224: QUEUED_COPY (x) = gen_reg_rtx (GET_MODE (QUEUED_VAR (x)));
225: emit_insn_before (gen_move_insn (QUEUED_COPY (x), QUEUED_VAR (x)),
226: QUEUED_INSN (x));
227: return QUEUED_COPY (x);
228: }
229:
1.1.1.2 root 230: /* Return nonzero if X contains a QUEUED expression:
1.1.1.15 root 231: if it contains anything that will be altered by a queued increment.
232: We handle only combinations of MEM, PLUS, MINUS and MULT operators
233: since memory addresses generally contain only those. */
1.1.1.2 root 234:
235: static int
236: queued_subexp_p (x)
237: rtx x;
238: {
239: register enum rtx_code code = GET_CODE (x);
240: switch (code)
241: {
242: case QUEUED:
243: return 1;
244: case MEM:
245: return queued_subexp_p (XEXP (x, 0));
246: case MULT:
247: case PLUS:
248: case MINUS:
249: return queued_subexp_p (XEXP (x, 0))
250: || queued_subexp_p (XEXP (x, 1));
251: }
252: return 0;
253: }
254:
255: /* Perform all the pending incrementations. */
1.1 root 256:
257: void
258: emit_queue ()
259: {
260: register rtx p;
261: while (p = pending_chain)
262: {
263: QUEUED_INSN (p) = emit_insn (QUEUED_BODY (p));
264: pending_chain = QUEUED_NEXT (p);
265: }
266: }
267:
1.1.1.2 root 268: static void
1.1 root 269: init_queue ()
270: {
271: if (pending_chain)
272: abort ();
273: }
274:
275: /* Copy data from FROM to TO, where the machine modes are not the same.
276: Both modes may be integer, or both may be floating.
277: UNSIGNEDP should be nonzero if FROM is an unsigned type.
278: This causes zero-extension instead of sign-extension. */
279:
280: void
281: convert_move (to, from, unsignedp)
282: register rtx to, from;
283: int unsignedp;
284: {
285: enum machine_mode to_mode = GET_MODE (to);
286: enum machine_mode from_mode = GET_MODE (from);
1.1.1.16 root 287: int to_real = GET_MODE_CLASS (to_mode) == MODE_FLOAT;
288: int from_real = GET_MODE_CLASS (from_mode) == MODE_FLOAT;
1.1 root 289: int extending = (int) to_mode > (int) from_mode;
290:
291: to = protect_from_queue (to, 1);
292: from = protect_from_queue (from, 0);
293:
294: if (to_real != from_real)
295: abort ();
296:
1.1.1.2 root 297: if (to_mode == from_mode
298: || (from_mode == VOIDmode && CONSTANT_P (from)))
1.1 root 299: {
300: emit_move_insn (to, from);
301: return;
302: }
303:
304: if (to_real)
305: {
306: #ifdef HAVE_extendsfdf2
307: if (HAVE_extendsfdf2 && extending)
308: {
1.1.1.2 root 309: emit_unop_insn (CODE_FOR_extendsfdf2, to, from, UNKNOWN);
1.1 root 310: return;
311: }
312: #endif
313: #ifdef HAVE_truncdfsf2
314: if (HAVE_truncdfsf2 && ! extending)
315: {
1.1.1.2 root 316: emit_unop_insn (CODE_FOR_truncdfsf2, to, from, UNKNOWN);
1.1 root 317: return;
318: }
319: #endif
320: emit_library_call (gen_rtx (SYMBOL_REF, Pmode, (extending
1.1.1.13 root 321: ? "__extendsfdf2"
1.1.1.17 root 322: : "__truncdfsf2")), 0,
1.1.1.2 root 323: GET_MODE (to), 1,
324: from, (extending ? SFmode : DFmode));
325: emit_move_insn (to, hard_libcall_value (GET_MODE (to)));
1.1 root 326: return;
327: }
328:
1.1.1.2 root 329: /* Now both modes are integers. */
330:
1.1 root 331: if (to_mode == DImode)
332: {
333: if (unsignedp)
334: {
1.1.1.14 root 335: #ifdef HAVE_zero_extendsidi2
336: if (HAVE_zero_extendsidi2 && from_mode == SImode)
337: emit_unop_insn (CODE_FOR_zero_extendsidi2, to, from, ZERO_EXTEND);
338: else
339: #endif
340: #ifdef HAVE_zero_extendhidi2
341: if (HAVE_zero_extendhidi2 && from_mode == HImode)
342: emit_unop_insn (CODE_FOR_zero_extendhidi2, to, from, ZERO_EXTEND);
343: else
344: #endif
345: #ifdef HAVE_zero_extendqidi2
346: if (HAVE_zero_extendqidi2 && from_mode == QImode)
347: emit_unop_insn (CODE_FOR_zero_extendqidi2, to, from, ZERO_EXTEND);
348: else
349: #endif
350: #ifdef HAVE_zero_extendsidi2
351: if (HAVE_zero_extendsidi2)
352: {
353: convert_move (gen_lowpart (SImode, to), from, unsignedp);
1.1.1.15 root 354: emit_unop_insn (CODE_FOR_zero_extendsidi2, to,
355: gen_lowpart (SImode, to), ZERO_EXTEND);
1.1.1.14 root 356: }
357: else
358: #endif
359: {
360: emit_insn (gen_rtx (CLOBBER, VOIDmode, to));
361: convert_move (gen_lowpart (SImode, to), from, unsignedp);
362: emit_clr_insn (gen_highpart (SImode, to));
363: }
1.1 root 364: }
1.1.1.5 root 365: #ifdef HAVE_extendsidi2
1.1.1.14 root 366: else if (HAVE_extendsidi2 && from_mode == SImode)
367: emit_unop_insn (CODE_FOR_extendsidi2, to, from, SIGN_EXTEND);
368: #endif
369: #ifdef HAVE_extendhidi2
370: else if (HAVE_extendhidi2 && from_mode == HImode)
371: emit_unop_insn (CODE_FOR_extendhidi2, to, from, SIGN_EXTEND);
372: #endif
373: #ifdef HAVE_extendqidi2
374: else if (HAVE_extendqidi2 && from_mode == QImode)
375: emit_unop_insn (CODE_FOR_extendqidi2, to, from, SIGN_EXTEND);
376: #endif
377: #ifdef HAVE_extendsidi2
1.1.1.5 root 378: else if (HAVE_extendsidi2)
1.1.1.14 root 379: {
380: convert_move (gen_lowpart (SImode, to), from, unsignedp);
1.1.1.16 root 381: emit_unop_insn (CODE_FOR_extendsidi2, to,
382: gen_lowpart (SImode, to), SIGN_EXTEND);
1.1.1.14 root 383: }
1.1.1.5 root 384: #endif
1.1.1.2 root 385: #ifdef HAVE_slt
386: else if (HAVE_slt && insn_operand_mode[(int) CODE_FOR_slt][0] == SImode)
1.1 root 387: {
1.1.1.5 root 388: emit_insn (gen_rtx (CLOBBER, VOIDmode, to));
1.1 root 389: convert_move (gen_lowpart (SImode, to), from, unsignedp);
1.1.1.2 root 390: emit_insn (gen_slt (gen_highpart (SImode, to)));
1.1 root 391: }
392: #endif
393: else
394: {
395: register rtx label = gen_label_rtx ();
396:
1.1.1.5 root 397: emit_insn (gen_rtx (CLOBBER, VOIDmode, to));
1.1 root 398: emit_clr_insn (gen_highpart (SImode, to));
399: convert_move (gen_lowpart (SImode, to), from, unsignedp);
400: emit_cmp_insn (gen_lowpart (SImode, to),
401: gen_rtx (CONST_INT, VOIDmode, 0),
1.1.1.14 root 402: 0, 0, 0);
1.1.1.6 root 403: NO_DEFER_POP;
1.1 root 404: emit_jump_insn (gen_bge (label));
405: expand_unop (SImode, one_cmpl_optab,
406: gen_highpart (SImode, to), gen_highpart (SImode, to),
407: 1);
408: emit_label (label);
1.1.1.6 root 409: OK_DEFER_POP;
1.1 root 410: }
411: return;
412: }
413:
414: if (from_mode == DImode)
415: {
416: convert_move (to, gen_lowpart (SImode, from), 0);
417: return;
418: }
419:
420: /* Now follow all the conversions between integers
421: no more than a word long. */
422:
1.1.1.2 root 423: /* For truncation, usually we can just refer to FROM in a narrower mode. */
424: if (GET_MODE_BITSIZE (to_mode) < GET_MODE_BITSIZE (from_mode)
425: && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (to_mode),
426: GET_MODE_BITSIZE (from_mode))
427: && ((GET_CODE (from) == MEM
1.1.1.16 root 428: && ! MEM_VOLATILE_P (from)
1.1.1.2 root 429: && ! mode_dependent_address_p (XEXP (from, 0)))
1.1.1.16 root 430: || GET_CODE (from) == REG
431: || GET_CODE (from) == SUBREG))
1.1.1.2 root 432: {
433: emit_move_insn (to, gen_lowpart (to_mode, from));
434: return;
435: }
436:
1.1 root 437: if (to_mode == SImode && from_mode == HImode)
438: {
439: if (unsignedp)
440: {
441: #ifdef HAVE_zero_extendhisi2
442: if (HAVE_zero_extendhisi2)
1.1.1.2 root 443: emit_unop_insn (CODE_FOR_zero_extendhisi2, to, from, ZERO_EXTEND);
1.1 root 444: else
445: #endif
446: abort ();
447: }
448: else
449: {
450: #ifdef HAVE_extendhisi2
451: if (HAVE_extendhisi2)
1.1.1.2 root 452: emit_unop_insn (CODE_FOR_extendhisi2, to, from, SIGN_EXTEND);
1.1 root 453: else
454: #endif
455: abort ();
456: }
457: return;
458: }
459:
460: if (to_mode == SImode && from_mode == QImode)
461: {
462: if (unsignedp)
463: {
464: #ifdef HAVE_zero_extendqisi2
465: if (HAVE_zero_extendqisi2)
466: {
1.1.1.2 root 467: emit_unop_insn (CODE_FOR_zero_extendqisi2, to, from, ZERO_EXTEND);
1.1 root 468: return;
469: }
470: #endif
471: #if defined (HAVE_zero_extendqihi2) && defined (HAVE_extendhisi2)
472: if (HAVE_zero_extendqihi2 && HAVE_extendhisi2)
473: {
474: register rtx temp = gen_reg_rtx (HImode);
1.1.1.2 root 475: emit_unop_insn (CODE_FOR_zero_extendqihi2, temp, from, ZERO_EXTEND);
476: emit_unop_insn (CODE_FOR_extendhisi2, to, temp, SIGN_EXTEND);
1.1 root 477: return;
478: }
479: #endif
480: }
481: else
482: {
483: #ifdef HAVE_extendqisi2
484: if (HAVE_extendqisi2)
485: {
1.1.1.2 root 486: emit_unop_insn (CODE_FOR_extendqisi2, to, from, SIGN_EXTEND);
1.1 root 487: return;
488: }
489: #endif
490: #if defined (HAVE_extendqihi2) && defined (HAVE_extendhisi2)
491: if (HAVE_extendqihi2 && HAVE_extendhisi2)
492: {
493: register rtx temp = gen_reg_rtx (HImode);
1.1.1.2 root 494: emit_unop_insn (CODE_FOR_extendqihi2, temp, from, SIGN_EXTEND);
495: emit_unop_insn (CODE_FOR_extendhisi2, to, temp, SIGN_EXTEND);
1.1 root 496: return;
497: }
498: #endif
499: }
500: abort ();
501: }
502:
503: if (to_mode == HImode && from_mode == QImode)
504: {
505: if (unsignedp)
506: {
507: #ifdef HAVE_zero_extendqihi2
508: if (HAVE_zero_extendqihi2)
509: {
1.1.1.2 root 510: emit_unop_insn (CODE_FOR_zero_extendqihi2, to, from, ZERO_EXTEND);
1.1 root 511: return;
512: }
513: #endif
514: }
515: else
516: {
517: #ifdef HAVE_extendqihi2
518: if (HAVE_extendqihi2)
519: {
1.1.1.2 root 520: emit_unop_insn (CODE_FOR_extendqihi2, to, from, SIGN_EXTEND);
1.1 root 521: return;
522: }
523: #endif
524: }
525: abort ();
526: }
527:
1.1.1.16 root 528: #if 0 /* This seems to be redundant with code 100 lines up. */
529:
1.1 root 530: /* Now we are truncating an integer to a smaller one.
531: If the result is a temporary, we might as well just copy it,
532: since only the low-order part of the result needs to be valid
533: and it is valid with no change. */
534:
535: if (GET_CODE (to) == REG)
536: {
537: if (GET_CODE (from) == REG)
538: {
539: emit_move_insn (to, gen_lowpart (GET_MODE (to), from));
540: return;
541: }
1.1.1.2 root 542: else if (GET_CODE (from) == SUBREG)
543: {
544: from = copy_rtx (from);
545: /* This is safe since FROM is not more than one word. */
546: PUT_MODE (from, GET_MODE (to));
547: emit_move_insn (to, from);
548: return;
549: }
1.1 root 550: #ifndef BYTES_BIG_ENDIAN
551: else if (GET_CODE (from) == MEM)
552: {
553: register rtx addr = XEXP (from, 0);
1.1.1.2 root 554: if (memory_address_p (GET_MODE (to), addr))
1.1 root 555: {
556: emit_move_insn (to, gen_rtx (MEM, GET_MODE (to), addr));
557: return;
558: }
559: }
560: #endif /* not BYTES_BIG_ENDIAN */
561: }
1.1.1.16 root 562: #endif /* 0 */
1.1 root 563:
564: if (from_mode == SImode && to_mode == HImode)
565: {
566: #ifdef HAVE_truncsihi2
567: if (HAVE_truncsihi2)
568: {
1.1.1.2 root 569: emit_unop_insn (CODE_FOR_truncsihi2, to, from, UNKNOWN);
1.1 root 570: return;
571: }
572: #endif
573: abort ();
574: }
575:
576: if (from_mode == SImode && to_mode == QImode)
577: {
578: #ifdef HAVE_truncsiqi2
579: if (HAVE_truncsiqi2)
580: {
1.1.1.2 root 581: emit_unop_insn (CODE_FOR_truncsiqi2, to, from, UNKNOWN);
1.1 root 582: return;
583: }
584: #endif
585: abort ();
586: }
587:
588: if (from_mode == HImode && to_mode == QImode)
589: {
590: #ifdef HAVE_trunchiqi2
591: if (HAVE_trunchiqi2)
592: {
1.1.1.2 root 593: emit_unop_insn (CODE_FOR_trunchiqi2, to, from, UNKNOWN);
1.1 root 594: return;
595: }
596: #endif
597: abort ();
598: }
1.1.1.2 root 599:
600: /* Mode combination is not recognized. */
601: abort ();
1.1 root 602: }
603:
604: /* Return an rtx for a value that would result
605: from converting X to mode MODE.
606: Both X and MODE may be floating, or both integer.
607: UNSIGNEDP is nonzero if X is an unsigned value.
608: This can be done by referring to a part of X in place
609: or by copying to a new temporary with conversion. */
610:
611: rtx
612: convert_to_mode (mode, x, unsignedp)
613: enum machine_mode mode;
614: rtx x;
615: int unsignedp;
616: {
617: register rtx temp;
618: if (mode == GET_MODE (x))
619: return x;
1.1.1.2 root 620: if (integer_mode_p (mode)
1.1.1.16 root 621: && GET_MODE_SIZE (mode) <= GET_MODE_SIZE (GET_MODE (x))
622: && ! (GET_CODE (x) == MEM && MEM_VOLATILE_P (x)))
1.1 root 623: return gen_lowpart (mode, x);
624: temp = gen_reg_rtx (mode);
625: convert_move (temp, x, unsignedp);
626: return temp;
627: }
1.1.1.2 root 628:
629: int
630: integer_mode_p (mode)
631: enum machine_mode mode;
632: {
633: return (int) mode > (int) VOIDmode && (int) mode <= (int) TImode;
634: }
1.1 root 635:
636: /* Generate several move instructions to copy LEN bytes
1.1.1.2 root 637: from block FROM to block TO. (These are MEM rtx's with BLKmode).
638: The caller must pass FROM and TO
1.1 root 639: through protect_from_queue before calling.
640: ALIGN (in bytes) is maximum alignment we can assume. */
641:
642: struct move_by_pieces
643: {
644: rtx to;
1.1.1.2 root 645: rtx to_addr;
1.1 root 646: int autinc_to;
647: int explicit_inc_to;
648: rtx from;
1.1.1.2 root 649: rtx from_addr;
1.1 root 650: int autinc_from;
651: int explicit_inc_from;
652: int len;
653: int offset;
654: int reverse;
655: };
656:
1.1.1.17 root 657: static void move_by_pieces_1 ();
658: static int move_by_pieces_ninsns ();
659:
1.1 root 660: static void
1.1.1.2 root 661: move_by_pieces (to, from, len, align)
1.1 root 662: rtx to, from;
663: int len, align;
664: {
665: struct move_by_pieces data;
1.1.1.2 root 666: rtx to_addr = XEXP (to, 0), from_addr = XEXP (from, 0);
1.1 root 667:
668: data.offset = 0;
1.1.1.2 root 669: data.to_addr = to_addr;
670: data.from_addr = from_addr;
1.1 root 671: data.to = to;
672: data.from = from;
1.1.1.2 root 673: data.autinc_to
674: = (GET_CODE (to_addr) == PRE_INC || GET_CODE (to_addr) == PRE_DEC
675: || GET_CODE (to_addr) == POST_INC || GET_CODE (to_addr) == POST_DEC);
676: data.autinc_from
677: = (GET_CODE (from_addr) == PRE_INC || GET_CODE (from_addr) == PRE_DEC
678: || GET_CODE (from_addr) == POST_INC
679: || GET_CODE (from_addr) == POST_DEC);
1.1 root 680:
681: data.explicit_inc_from = 0;
682: data.explicit_inc_to = 0;
1.1.1.2 root 683: data.reverse
684: = (GET_CODE (to_addr) == PRE_DEC || GET_CODE (to_addr) == POST_DEC);
1.1 root 685: if (data.reverse) data.offset = len;
686: data.len = len;
687:
688: /* If copying requires more than two move insns,
689: copy addresses to registers (to make displacements shorter)
690: and use post-increment if available. */
691: if (!(data.autinc_from && data.autinc_to)
692: && move_by_pieces_ninsns (len, align) > 2)
693: {
694: #ifdef HAVE_PRE_DECREMENT
695: if (data.reverse && ! data.autinc_from)
696: {
1.1.1.2 root 697: data.from_addr = copy_addr_to_reg (plus_constant (from_addr, len));
1.1 root 698: data.autinc_from = 1;
699: data.explicit_inc_from = -1;
700: }
701: #endif
702: #ifdef HAVE_POST_INCREMENT
703: if (! data.autinc_from)
704: {
1.1.1.2 root 705: data.from_addr = copy_addr_to_reg (from_addr);
1.1 root 706: data.autinc_from = 1;
707: data.explicit_inc_from = 1;
708: }
709: #endif
1.1.1.2 root 710: if (!data.autinc_from && CONSTANT_P (from_addr))
711: data.from_addr = copy_addr_to_reg (from_addr);
1.1 root 712: #ifdef HAVE_PRE_DECREMENT
713: if (data.reverse && ! data.autinc_to)
714: {
1.1.1.2 root 715: data.to_addr = copy_addr_to_reg (plus_constant (to_addr, len));
1.1 root 716: data.autinc_to = 1;
717: data.explicit_inc_to = -1;
718: }
719: #endif
720: #ifdef HAVE_POST_INCREMENT
721: if (! data.reverse && ! data.autinc_to)
722: {
1.1.1.2 root 723: data.to_addr = copy_addr_to_reg (to_addr);
1.1 root 724: data.autinc_to = 1;
725: data.explicit_inc_to = 1;
726: }
727: #endif
1.1.1.2 root 728: if (!data.autinc_to && CONSTANT_P (to_addr))
729: data.to_addr = copy_addr_to_reg (to_addr);
1.1 root 730: }
731:
732: #ifdef STRICT_ALIGNMENT
1.1.1.2 root 733: if (align > MOVE_MAX || align >= BIGGEST_ALIGNMENT / BITS_PER_UNIT)
1.1 root 734: align = MOVE_MAX;
735: #else
736: align = MOVE_MAX;
737: #endif
738:
739: #ifdef HAVE_movti
740: if (HAVE_movti && align >= GET_MODE_SIZE (TImode))
741: move_by_pieces_1 (gen_movti, TImode, &data);
742: #endif
743: #ifdef HAVE_movdi
744: if (HAVE_movdi && align >= GET_MODE_SIZE (DImode))
745: move_by_pieces_1 (gen_movdi, DImode, &data);
746: #endif
1.1.1.2 root 747: #ifdef HAVE_movsi
1.1 root 748: if (align >= GET_MODE_SIZE (SImode))
749: move_by_pieces_1 (gen_movsi, SImode, &data);
1.1.1.2 root 750: #endif
751: #ifdef HAVE_movhi
752: if (HAVE_movhi && align >= GET_MODE_SIZE (HImode))
1.1 root 753: move_by_pieces_1 (gen_movhi, HImode, &data);
1.1.1.2 root 754: #endif
755: #ifdef HAVE_movqi
1.1 root 756: move_by_pieces_1 (gen_movqi, QImode, &data);
1.1.1.2 root 757: #else
758: movqi instruction required in machine description
759: #endif
1.1 root 760: }
761:
762: /* Return number of insns required to move L bytes by pieces.
763: ALIGN (in bytes) is maximum alignment we can assume. */
764:
1.1.1.2 root 765: static int
1.1 root 766: move_by_pieces_ninsns (l, align)
767: unsigned int l;
768: int align;
769: {
770: register int n_insns = 0;
771:
772: #ifdef STRICT_ALIGNMENT
1.1.1.2 root 773: if (align > MOVE_MAX || align >= BIGGEST_ALIGNMENT / BITS_PER_UNIT)
1.1 root 774: align = MOVE_MAX;
775: #else
776: align = MOVE_MAX;
777: #endif
778:
779: #ifdef HAVE_movti
780: if (HAVE_movti && align >= GET_MODE_SIZE (TImode))
781: n_insns += l / GET_MODE_SIZE (TImode), l %= GET_MODE_SIZE (TImode);
782: #endif
783: #ifdef HAVE_movdi
784: if (HAVE_movdi && align >= GET_MODE_SIZE (DImode))
785: n_insns += l / GET_MODE_SIZE (DImode), l %= GET_MODE_SIZE (DImode);
786: #endif
1.1.1.2 root 787: #ifdef HAVE_movsi
1.1 root 788: if (HAVE_movsi && align >= GET_MODE_SIZE (SImode))
789: n_insns += l / GET_MODE_SIZE (SImode), l %= GET_MODE_SIZE (SImode);
1.1.1.2 root 790: #endif
791: #ifdef HAVE_movhi
1.1 root 792: if (HAVE_movhi && align >= GET_MODE_SIZE (HImode))
793: n_insns += l / GET_MODE_SIZE (HImode), l %= GET_MODE_SIZE (HImode);
1.1.1.2 root 794: #endif
1.1 root 795: n_insns += l;
796:
797: return n_insns;
798: }
799:
800: /* Subroutine of move_by_pieces. Move as many bytes as appropriate
801: with move instructions for mode MODE. GENFUN is the gen_... function
802: to make a move insn for that mode. DATA has all the other info. */
803:
1.1.1.2 root 804: static void
1.1 root 805: move_by_pieces_1 (genfun, mode, data)
806: rtx (*genfun) ();
807: enum machine_mode mode;
808: struct move_by_pieces *data;
809: {
810: register int size = GET_MODE_SIZE (mode);
811: register rtx to1, from1;
812:
813: while (data->len >= size)
814: {
1.1.1.2 root 815: if (data->reverse) data->offset -= size;
1.1 root 816:
1.1.1.13 root 817: to1 = (data->autinc_to
818: ? gen_rtx (MEM, mode, data->to_addr)
819: : change_address (data->to, mode,
820: plus_constant (data->to_addr, data->offset)));
821: from1 =
822: (data->autinc_from
823: ? gen_rtx (MEM, mode, data->from_addr)
824: : change_address (data->from, mode,
825: plus_constant (data->from_addr, data->offset)));
1.1 root 826:
827: #ifdef HAVE_PRE_DECREMENT
828: if (data->explicit_inc_to < 0)
1.1.1.2 root 829: emit_insn (gen_sub2_insn (data->to_addr,
1.1 root 830: gen_rtx (CONST_INT, VOIDmode, size)));
831: if (data->explicit_inc_from < 0)
1.1.1.2 root 832: emit_insn (gen_sub2_insn (data->from_addr,
1.1 root 833: gen_rtx (CONST_INT, VOIDmode, size)));
834: #endif
835:
1.1.1.5 root 836: emit_insn ((*genfun) (to1, from1));
1.1 root 837: #ifdef HAVE_POST_INCREMENT
838: if (data->explicit_inc_to > 0)
1.1.1.2 root 839: emit_insn (gen_add2_insn (data->to_addr,
1.1 root 840: gen_rtx (CONST_INT, VOIDmode, size)));
841: if (data->explicit_inc_from > 0)
1.1.1.2 root 842: emit_insn (gen_add2_insn (data->from_addr,
1.1 root 843: gen_rtx (CONST_INT, VOIDmode, size)));
844: #endif
845:
846: if (! data->reverse) data->offset += size;
1.1.1.2 root 847:
1.1 root 848: data->len -= size;
849: }
850: }
851:
852: /* Emit code to move a block Y to a block X.
853: This may be done with string-move instructions,
854: with multiple scalar move instructions, or with a library call.
855:
856: Both X and Y must be MEM rtx's (perhaps inside VOLATILE)
857: with mode BLKmode.
858: SIZE is an rtx that says how long they are.
859: ALIGN is the maximum alignment we can assume they have,
860: measured in bytes. */
861:
862: static void
863: emit_block_move (x, y, size, align)
864: rtx x, y;
865: rtx size;
866: int align;
867: {
868: if (GET_MODE (x) != BLKmode)
869: abort ();
870:
871: if (GET_MODE (y) != BLKmode)
872: abort ();
873:
874: x = protect_from_queue (x, 1);
875: y = protect_from_queue (y, 0);
876:
1.1.1.2 root 877: if (GET_CODE (x) != MEM)
1.1 root 878: abort ();
1.1.1.2 root 879: if (GET_CODE (y) != MEM)
1.1 root 880: abort ();
881: if (size == 0)
882: abort ();
883:
884: if (GET_CODE (size) == CONST_INT
885: && (move_by_pieces_ninsns ((unsigned) INTVAL (size), align)
886: < MOVE_RATIO))
1.1.1.2 root 887: move_by_pieces (x, y, INTVAL (size), align);
1.1 root 888: else
889: {
1.1.1.9 root 890: /* Try the most limited insn first, because there's no point
891: including more than one in the machine description unless
892: the more limited one has some advantage. */
893: #ifdef HAVE_movstrqi
894: if (HAVE_movstrqi
895: && GET_CODE (size) == CONST_INT
896: && ((unsigned) INTVAL (size)
897: < (1 << (GET_MODE_BITSIZE (QImode) - 1))))
1.1 root 898: {
1.1.1.14 root 899: emit_insn (gen_movstrqi (x, y, size,
900: gen_rtx (CONST_INT, VOIDmode, align)));
1.1 root 901: return;
902: }
903: #endif
904: #ifdef HAVE_movstrhi
905: if (HAVE_movstrhi
906: && GET_CODE (size) == CONST_INT
907: && ((unsigned) INTVAL (size)
1.1.1.5 root 908: < (1 << (GET_MODE_BITSIZE (HImode) - 1))))
1.1 root 909: {
1.1.1.14 root 910: emit_insn (gen_movstrhi (x, y, size,
911: gen_rtx (CONST_INT, VOIDmode, align)));
1.1 root 912: return;
913: }
914: #endif
1.1.1.9 root 915: #ifdef HAVE_movstrsi
916: if (HAVE_movstrsi)
1.1.1.5 root 917: {
1.1.1.14 root 918: emit_insn (gen_movstrsi (x, y, size,
919: gen_rtx (CONST_INT, VOIDmode, align)));
1.1.1.5 root 920: return;
921: }
922: #endif
1.1.1.2 root 923:
924: #ifdef TARGET_MEM_FUNCTIONS
1.1.1.17 root 925: emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "memcpy"), 0,
1.1.1.2 root 926: VOIDmode, 3, XEXP (x, 0), Pmode,
927: XEXP (y, 0), Pmode,
928: size, Pmode);
929: #else
1.1.1.17 root 930: emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "bcopy"), 0,
1.1.1.2 root 931: VOIDmode, 3, XEXP (y, 0), Pmode,
932: XEXP (x, 0), Pmode,
1.1 root 933: size, Pmode);
1.1.1.2 root 934: #endif
935: }
936: }
937:
938: /* Copy all or part of a BLKmode value X into registers starting at REGNO.
939: The number of registers to be filled is NREGS. */
940:
941: static void
942: move_block_to_reg (regno, x, nregs)
943: int regno;
944: rtx x;
945: int nregs;
946: {
947: int i;
948: if (GET_CODE (x) == CONST_DOUBLE && x != dconst0_rtx)
949: x = force_const_double_mem (x);
950: for (i = 0; i < nregs; i++)
951: {
952: if (GET_CODE (x) == REG)
953: emit_move_insn (gen_rtx (REG, SImode, regno + i),
954: gen_rtx (SUBREG, SImode, x, i));
955: else if (x == dconst0_rtx)
956: emit_move_insn (gen_rtx (REG, SImode, regno + i),
957: const0_rtx);
958: else
959: emit_move_insn (gen_rtx (REG, SImode, regno + i),
960: gen_rtx (MEM, SImode,
1.1.1.10 root 961: memory_address (SImode,
962: plus_constant (XEXP (x, 0),
963: i * GET_MODE_SIZE (SImode)))));
1.1.1.2 root 964: }
965: }
966:
967: /* Copy all or part of a BLKmode value X out of registers starting at REGNO.
968: The number of registers to be filled is NREGS. */
969:
970: void
971: move_block_from_reg (regno, x, nregs)
972: int regno;
973: rtx x;
974: int nregs;
975: {
976: int i;
977: for (i = 0; i < nregs; i++)
978: {
979: if (GET_CODE (x) == REG)
980: emit_move_insn (gen_rtx (SUBREG, SImode, x, i),
981: gen_rtx (REG, SImode, regno + i));
982: else
983: emit_move_insn (gen_rtx (MEM, SImode,
1.1.1.10 root 984: memory_address (SImode,
985: plus_constant (XEXP (x, 0),
986: i * GET_MODE_SIZE (SImode)))),
1.1.1.2 root 987: gen_rtx (REG, SImode, regno + i));
1.1 root 988: }
989: }
1.1.1.2 root 990:
991: /* Mark NREGS consecutive regs, starting at REGNO, as being live now. */
992:
993: static void
994: use_regs (regno, nregs)
995: int regno;
996: int nregs;
997: {
998: int i;
999: for (i = 0; i < nregs; i++)
1000: emit_insn (gen_rtx (USE, VOIDmode, gen_rtx (REG, SImode, regno + i)));
1001: }
1.1 root 1002:
1.1.1.2 root 1003: /* Write zeros through the storage of OBJECT.
1004: If OBJECT has BLKmode, SIZE is its length in bytes. */
1005:
1006: void
1007: clear_storage (object, size)
1008: rtx object;
1009: int size;
1010: {
1011: if (GET_MODE (object) == BLKmode)
1012: {
1013: #ifdef TARGET_MEM_FUNCTIONS
1.1.1.17 root 1014: emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "memset"), 0,
1.1.1.2 root 1015: VOIDmode, 3,
1016: XEXP (object, 0), Pmode, const0_rtx, Pmode,
1017: gen_rtx (CONST_INT, VOIDmode, size), Pmode);
1018: #else
1.1.1.17 root 1019: emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "bzero"), 0,
1.1.1.2 root 1020: VOIDmode, 2,
1021: XEXP (object, 0), Pmode,
1022: gen_rtx (CONST_INT, VOIDmode, size), Pmode);
1023: #endif
1024: }
1025: else
1.1.1.13 root 1026: emit_move_insn (object, const0_rtx);
1.1.1.2 root 1027: }
1028:
1.1 root 1029: /* Generate code to copy Y into X.
1030: Both Y and X must have the same mode, except that
1031: Y can be a constant with VOIDmode.
1.1.1.2 root 1032: This mode cannot be BLKmode; use emit_block_move for that.
1.1 root 1033:
1.1.1.2 root 1034: Return the last instruction emitted. */
1035:
1036: rtx
1.1 root 1037: emit_move_insn (x, y)
1038: rtx x, y;
1039: {
1040: enum machine_mode mode = GET_MODE (x);
1041: x = protect_from_queue (x, 1);
1042: y = protect_from_queue (y, 0);
1043:
1.1.1.3 root 1044: if ((CONSTANT_P (y) || GET_CODE (y) == CONST_DOUBLE)
1045: && ! LEGITIMATE_CONSTANT_P (y))
1.1.1.10 root 1046: {
1047: y = force_const_mem (mode, y);
1.1.1.18! root 1048: if (! memory_address_p (mode, XEXP (y, 0)))
1.1.1.10 root 1049: y = gen_rtx (MEM, mode, memory_address (mode, XEXP (y, 0)));
1050: }
1.1.1.2 root 1051:
1.1 root 1052: if (mode == BLKmode)
1053: abort ();
1.1.1.2 root 1054: if (mov_optab->handlers[(int) mode].insn_code != CODE_FOR_nothing)
1.1.1.6 root 1055: return
1.1.1.2 root 1056: emit_insn (GEN_FCN (mov_optab->handlers[(int) mode].insn_code) (x, y));
1057: #if 0
1058: /* It turns out you get much better optimization (in cse and flow)
1059: if you define movdi and movdf instruction patterns
1060: even if they must turn into multiple assembler instructions. */
1.1 root 1061: else if (GET_MODE_SIZE (mode) >= GET_MODE_SIZE (SImode))
1062: {
1063: register int count = GET_MODE_SIZE (mode) / GET_MODE_SIZE (SImode);
1064: register int i;
1.1.1.2 root 1065: if (GET_CODE (y) == CONST_DOUBLE && y != dconst0_rtx)
1066: y = force_const_double_mem (y);
1.1 root 1067: for (i = 0; i < count; i++)
1068: {
1069: rtx x1, y1;
1070: if (GET_CODE (x) == REG)
1071: x1 = gen_rtx (SUBREG, SImode, x, i);
1072: else
1073: x1 = gen_rtx (MEM, SImode,
1074: memory_address (SImode,
1075: plus_constant (XEXP (x, 0),
1076: i * GET_MODE_SIZE (SImode))));
1077: if (GET_CODE (y) == REG)
1078: y1 = gen_rtx (SUBREG, SImode, y, i);
1.1.1.2 root 1079: else if (y == dconst0_rtx)
1080: y1 = const0_rtx;
1.1 root 1081: else
1082: y1 = gen_rtx (MEM, SImode,
1083: memory_address (SImode,
1084: plus_constant (XEXP (y, 0),
1085: i * GET_MODE_SIZE (SImode))));
1086: emit_insn (gen_movsi (protect_from_queue (x1, 1), protect_from_queue (y1, 0)));
1087: }
1088: }
1.1.1.2 root 1089: #endif
1.1 root 1090: else
1091: abort ();
1092: }
1093:
1094: /* Pushing data onto the stack. */
1095:
1096: /* Push a block of length SIZE (perhaps variable)
1097: and return an rtx to address the beginning of the block.
1.1.1.4 root 1098: Note that it is not possible for the value returned to be a QUEUED.
1099: The value may be stack_pointer_rtx.
1100:
1.1.1.7 root 1101: The value we return does take account of STACK_POINTER_OFFSET. */
1.1 root 1102:
1.1.1.7 root 1103: rtx
1.1 root 1104: push_block (size)
1105: rtx size;
1106: {
1107: register rtx temp;
1.1.1.2 root 1108: if (CONSTANT_P (size) || GET_CODE (size) == REG)
1109: anti_adjust_stack (size);
1110: else
1111: anti_adjust_stack (copy_to_mode_reg (Pmode, size));
1.1.1.6 root 1112:
1.1 root 1113: #ifdef STACK_GROWS_DOWNWARD
1.1.1.2 root 1114: temp = stack_pointer_rtx;
1.1 root 1115: #else
1116: temp = gen_rtx (PLUS, Pmode,
1.1.1.2 root 1117: stack_pointer_rtx,
1.1.1.11 root 1118: negate_rtx (Pmode, size));
1.1 root 1119: if (GET_CODE (size) != CONST_INT)
1120: temp = force_operand (temp, 0);
1121: #endif
1.1.1.7 root 1122:
1123: #ifdef STACK_POINTER_OFFSET
1124: temp = plus_constant (temp, STACK_POINTER_OFFSET);
1125: #endif /* STACK_POINTER_OFFSET */
1126:
1.1 root 1127: return memory_address (QImode, temp);
1128: }
1129:
1130: static rtx
1131: gen_push_operand ()
1132: {
1133: return gen_rtx (
1134: #ifdef STACK_GROWS_DOWNWARD
1135: PRE_DEC,
1136: #else
1137: PRE_INC,
1138: #endif
1139: Pmode,
1.1.1.2 root 1140: stack_pointer_rtx);
1.1 root 1141: }
1142:
1143: /* Generate code to push X onto the stack, assuming it has mode MODE.
1144: MODE is redundant except when X is a CONST_INT (since they don't
1145: carry mode info).
1146: SIZE is an rtx for the size of data to be copied (in bytes),
1147: needed only if X is BLKmode.
1.1.1.13 root 1148:
1149:
1150:
1151:
1152:
1.1.1.2 root 1153: ALIGN (in bytes) is maximum alignment we can assume.
1154:
1155: If PARTIAL is nonzero, then copy that many of the first words
1156: of X into registers starting with REG, and push the rest of X.
1157: The amount of space pushed is decreased by PARTIAL words,
1158: rounded *down* to a multiple of PARM_BOUNDARY.
1159: REG must be a hard register in this case.
1160:
1161: EXTRA is the amount in bytes of extra space to leave next to this arg.
1162:
1163: On a machine that lacks real push insns, ARGS_ADDR is the address of
1164: the bottom of the argument block for this call. We use indexing off there
1165: to store the arg. On machines with push insns, ARGS_ADDR is 0.
1166:
1167: ARGS_SO_FAR is the size of args previously pushed for this call. */
1.1 root 1168:
1169: static void
1.1.1.2 root 1170: emit_push_insn (x, mode, size, align, partial, reg, extra, args_addr, args_so_far)
1.1 root 1171: register rtx x;
1172: enum machine_mode mode;
1173: rtx size;
1174: int align;
1.1.1.2 root 1175: int partial;
1176: rtx reg;
1177: int extra;
1178: rtx args_addr;
1179: rtx args_so_far;
1.1 root 1180: {
1181: rtx xinner;
1.1.1.6 root 1182: enum direction stack_direction
1183: #ifdef STACK_GROWS_DOWNWARD
1184: = downward;
1185: #else
1186: = upward;
1187: #endif
1188:
1189: /* Decide where to pad the argument: `downward' for below,
1190: `upward' for above, or `none' for don't pad it.
1191: Default is below for small data on big-endian machines; else above. */
1192: enum direction where_pad = FUNCTION_ARG_PADDING (mode, size);
1.1 root 1193:
1194: xinner = x = protect_from_queue (x, 0);
1195:
1.1.1.6 root 1196: if (extra)
1197: {
1198: if (args_addr == 0)
1199: {
1200: /* Push padding now if padding above and stack grows down,
1201: or if padding below and stack grows up. */
1202: if (where_pad != none && where_pad != stack_direction)
1203: anti_adjust_stack (gen_rtx (CONST_INT, VOIDmode, extra));
1204: }
1205: else
1206: {
1207: /* If space already allocated, just adjust the address we use. */
1208: if (where_pad == downward)
1209: args_so_far = plus_constant (args_so_far, extra);
1210: }
1211: }
1.1 root 1212:
1213: if (mode == BLKmode)
1214: {
1.1.1.17 root 1215: /* Copy a block into the stack, entirely or partially. */
1216:
1.1 root 1217: register rtx temp;
1.1.1.2 root 1218: int used = partial * UNITS_PER_WORD;
1219: int offset = used % (PARM_BOUNDARY / BITS_PER_UNIT);
1.1.1.17 root 1220: int skip;
1221:
1222: if (size == 0)
1223: abort ();
1.1.1.2 root 1224:
1.1.1.13 root 1225: used -= offset;
1.1.1.2 root 1226:
1.1.1.17 root 1227: /* USED is now the # of bytes we need not copy to the stack
1228: because registers will take care of them. */
1.1 root 1229:
1.1.1.2 root 1230: if (partial != 0)
1231: xinner = change_address (xinner, BLKmode,
1232: plus_constant (XEXP (xinner, 0), used));
1233:
1.1.1.17 root 1234: /* If the partial register-part of the arg counts in its stack size,
1235: skip the part of stack space corresponding to the registers.
1236: Otherwise, start copying to the beginning of the stack space,
1237: by setting SKIP to 0. */
1238: #ifndef FIRST_PARM_CALLER_OFFSET
1239: skip = 0;
1240: #else
1241: skip = used;
1242: #endif
1243:
1.1.1.2 root 1244: #ifdef PUSH_ROUNDING
1245: /* Do it with several push insns if that doesn't take lots of insns
1246: and if there is no difficulty with push insns that skip bytes
1247: on the stack for alignment purposes. */
1248: if (args_addr == 0
1249: && GET_CODE (size) == CONST_INT
1250: && args_addr == 0
1.1.1.17 root 1251: && skip == 0
1.1.1.2 root 1252: && (move_by_pieces_ninsns ((unsigned) INTVAL (size) - used, align)
1253: < MOVE_RATIO)
1254: && PUSH_ROUNDING (INTVAL (size)) == INTVAL (size))
1255: move_by_pieces (gen_rtx (MEM, BLKmode, gen_push_operand ()), xinner,
1256: INTVAL (size) - used, align);
1.1 root 1257: else
1.1.1.2 root 1258: #endif /* PUSH_ROUNDING */
1.1 root 1259: {
1.1.1.2 root 1260: /* Otherwise make space on the stack and copy the data
1261: to the address of that space. */
1262:
1.1.1.17 root 1263: /* Deduct words put into registers from the size we must copy. */
1.1.1.2 root 1264: if (partial != 0)
1265: {
1266: if (GET_CODE (size) == CONST_INT)
1267: size = gen_rtx (CONST_INT, VOIDmode, INTVAL (size) - used);
1268: else
1269: size = expand_binop (GET_MODE (size), sub_optab, size,
1270: gen_rtx (CONST_INT, VOIDmode, used),
1271: 0, 0, OPTAB_LIB_WIDEN);
1272: }
1273:
1274: /* Get the address of the stack space. */
1275: if (! args_addr)
1276: temp = push_block (size);
1277: else if (GET_CODE (args_so_far) == CONST_INT)
1278: temp = memory_address (BLKmode,
1279: plus_constant (args_addr,
1.1.1.17 root 1280: skip + INTVAL (args_so_far)));
1.1.1.2 root 1281: else
1282: temp = memory_address (BLKmode,
1283: plus_constant (gen_rtx (PLUS, Pmode,
1284: args_addr, args_so_far),
1.1.1.17 root 1285: skip));
1.1.1.2 root 1286:
1287: /* TEMP is the address of the block. Copy the data there. */
1288: if (GET_CODE (size) == CONST_INT
1289: && (move_by_pieces_ninsns ((unsigned) INTVAL (size), align)
1290: < MOVE_RATIO))
1291: {
1292: move_by_pieces (gen_rtx (MEM, BLKmode, temp), xinner,
1293: INTVAL (size), align);
1.1.1.16 root 1294: goto ret;
1.1.1.2 root 1295: }
1.1.1.13 root 1296: /* Try the most limited insn first, because there's no point
1297: including more than one in the machine description unless
1298: the more limited one has some advantage. */
1.1.1.9 root 1299: #ifdef HAVE_movstrqi
1300: if (HAVE_movstrqi
1301: && GET_CODE (size) == CONST_INT
1302: && ((unsigned) INTVAL (size)
1303: < (1 << (GET_MODE_BITSIZE (QImode) - 1))))
1.1 root 1304: {
1.1.1.9 root 1305: emit_insn (gen_movstrqi (gen_rtx (MEM, BLKmode, temp),
1.1.1.14 root 1306: xinner, size,
1307: gen_rtx (CONST_INT, VOIDmode, align)));
1.1.1.16 root 1308: goto ret;
1.1 root 1309: }
1310: #endif
1311: #ifdef HAVE_movstrhi
1312: if (HAVE_movstrhi
1313: && GET_CODE (size) == CONST_INT
1314: && ((unsigned) INTVAL (size)
1.1.1.5 root 1315: < (1 << (GET_MODE_BITSIZE (HImode) - 1))))
1.1 root 1316: {
1317: emit_insn (gen_movstrhi (gen_rtx (MEM, BLKmode, temp),
1.1.1.14 root 1318: xinner, size,
1319: gen_rtx (CONST_INT, VOIDmode, align)));
1.1.1.16 root 1320: goto ret;
1.1 root 1321: }
1322: #endif
1.1.1.9 root 1323: #ifdef HAVE_movstrsi
1324: if (HAVE_movstrsi)
1.1.1.5 root 1325: {
1.1.1.14 root 1326: emit_insn (gen_movstrsi (gen_rtx (MEM, BLKmode, temp),
1327: xinner, size,
1328: gen_rtx (CONST_INT, VOIDmode, align)));
1.1.1.16 root 1329: goto ret;
1.1.1.5 root 1330: }
1331: #endif
1.1.1.2 root 1332:
1333: if (reg_mentioned_p (stack_pointer_rtx, temp))
1334: {
1.1.1.15 root 1335: /* Now that emit_library_call does force_operand
1336: before pushing anything, preadjustment does not work. */
1337: temp = copy_to_reg (temp);
1338: #if 0
1.1.1.2 root 1339: /* Correct TEMP so it holds what will be a description of
1340: the address to copy to, valid after one arg is pushed. */
1.1.1.5 root 1341: int xsize = GET_MODE_SIZE (Pmode);
1342: #ifdef PUSH_ROUNDING
1343: xsize = PUSH_ROUNDING (xsize);
1344: #endif
1345: xsize = ((xsize + PARM_BOUNDARY / BITS_PER_UNIT - 1)
1346: / (PARM_BOUNDARY / BITS_PER_UNIT)
1347: * (PARM_BOUNDARY / BITS_PER_UNIT));
1.1.1.8 root 1348: #ifdef TARGET_MEM_FUNCTIONS
1349: /* If we are calling bcopy, we push one arg before TEMP.
1350: If calling memcpy, we push two. */
1351: xsize *= 2;
1352: #endif
1.1 root 1353: #ifdef STACK_GROWS_DOWNWARD
1.1.1.4 root 1354: temp = plus_constant (temp, xsize);
1.1 root 1355: #else
1.1.1.6 root 1356: temp = plus_constant (temp, -xsize);
1.1.1.15 root 1357: #endif /* not STACK_GROWS_DOWNWARD */
1358: #endif /* 0 */
1.1.1.2 root 1359: }
1360:
1.1.1.17 root 1361: /* Make inhibit_defer_pop nonzero around the library call
1.1.1.2 root 1362: to force it to pop the bcopy-arguments right away. */
1.1.1.9 root 1363: NO_DEFER_POP;
1.1.1.2 root 1364: #ifdef TARGET_MEM_FUNCTIONS
1.1.1.17 root 1365: emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "memcpy"), 0,
1.1.1.2 root 1366: VOIDmode, 3, temp, Pmode, XEXP (xinner, 0), Pmode,
1367: size, Pmode);
1368: #else
1.1.1.17 root 1369: emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "bcopy"), 0,
1.1.1.2 root 1370: VOIDmode, 3, XEXP (xinner, 0), Pmode, temp, Pmode,
1.1 root 1371: size, Pmode);
1.1.1.2 root 1372: #endif
1.1.1.9 root 1373: OK_DEFER_POP;
1.1 root 1374: }
1375: }
1.1.1.2 root 1376: else if (partial > 0)
1.1 root 1377: {
1.1.1.14 root 1378: /* Scalar partly in registers. */
1379:
1.1.1.2 root 1380: int size = GET_MODE_SIZE (mode) / UNITS_PER_WORD;
1381: int i;
1.1.1.13 root 1382: int not_stack;
1.1.1.6 root 1383: /* # words of start of argument
1.1.1.2 root 1384: that we must make space for but need not store. */
1.1.1.17 root 1385: int offset = partial % (PARM_BOUNDARY / BITS_PER_WORD);
1.1.1.2 root 1386: int args_offset = INTVAL (args_so_far);
1.1.1.17 root 1387: int skip;
1.1.1.2 root 1388:
1389: /* If we make space by pushing it, we might as well push
1.1.1.17 root 1390: the real data. Otherwise, we can leave OFFSET nonzero
1.1.1.2 root 1391: and leave the space uninitialized. */
1392: if (args_addr == 0)
1.1.1.17 root 1393: offset = 0;
1.1.1.2 root 1394:
1.1.1.17 root 1395: /* Now NOT_STACK gets the number of words that we don't need to
1.1.1.13 root 1396: allocate on the stack. */
1.1.1.17 root 1397: not_stack = partial - offset;
1398:
1399: /* If the partial register-part of the arg counts in its stack size,
1400: skip the part of stack space corresponding to the registers.
1401: Otherwise, start copying to the beginning of the stack space,
1402: by setting SKIP to 0. */
1403: #ifndef FIRST_PARM_CALLER_OFFSET
1404: skip = 0;
1405: #else
1406: skip = not_stack;
1407: #endif
1.1.1.2 root 1408:
1409: if (GET_CODE (x) == CONST_DOUBLE && x != dconst0_rtx)
1410: x = force_const_double_mem (x);
1411:
1.1.1.13 root 1412: /* Loop over all the words allocated on the stack for this arg. */
1.1.1.14 root 1413: /* We can do it by words, because any scalar bigger than a word
1414: has a size a multiple of a word. */
1.1.1.2 root 1415: #ifndef PUSH_ARGS_REVERSED
1.1.1.13 root 1416: for (i = not_stack; i < size; i++)
1.1.1.2 root 1417: #else
1.1.1.13 root 1418: for (i = size - 1; i >= not_stack; i--)
1.1.1.2 root 1419: #endif
1.1.1.17 root 1420: if (i >= not_stack + offset)
1.1.1.13 root 1421: {
1.1.1.14 root 1422: rtx wd;
1423: rtx addr;
1424: /* Get the next word of the value in WD. */
1.1.1.13 root 1425: if (GET_CODE (x) == MEM)
1.1.1.14 root 1426: {
1427: rtx addr = memory_address (SImode,
1428: plus_constant (XEXP (x, 0),
1429: i * UNITS_PER_WORD));
1430: /* Copy to a reg, since machine may lack
1431: memory-to-memory move insns. */
1432: wd = copy_to_reg (gen_rtx (MEM, SImode, addr));
1433: }
1.1.1.13 root 1434: else if (GET_CODE (x) == REG)
1.1.1.14 root 1435: wd = gen_rtx (SUBREG, SImode, x, i);
1.1.1.13 root 1436: else if (x == dconst0_rtx)
1.1.1.14 root 1437: wd = const0_rtx;
1.1.1.13 root 1438: else
1439: abort ();
1.1.1.14 root 1440:
1441: emit_push_insn (wd,
1442: SImode, 0, align, 0, 0, 0, args_addr,
1443: gen_rtx (CONST_INT, VOIDmode,
1.1.1.17 root 1444: args_offset + (i - not_stack + skip) * UNITS_PER_WORD));
1.1.1.13 root 1445: }
1.1 root 1446: }
1447: else
1.1.1.2 root 1448: {
1449: rtx addr;
1450: #ifdef PUSH_ROUNDING
1451: if (args_addr == 0)
1452: addr = gen_push_operand ();
1453: else
1454: #endif
1455: if (GET_CODE (args_so_far) == CONST_INT)
1456: addr
1457: = memory_address (mode,
1458: plus_constant (args_addr, INTVAL (args_so_far)));
1459: else
1460: addr = memory_address (mode, gen_rtx (PLUS, Pmode, args_addr,
1461: args_so_far));
1462:
1463: emit_move_insn (gen_rtx (MEM, mode, addr), x);
1464: }
1465:
1.1.1.16 root 1466: ret:
1.1.1.17 root 1467: /* If part should go in registers, copy that part
1468: into the appropriate registers. Do this now, at the end,
1469: since mem-to-mem copies above may do function calls. */
1470: if (partial > 0)
1471: move_block_to_reg (REGNO (reg), x, partial);
1472:
1.1.1.6 root 1473: if (extra && args_addr == 0 && where_pad == stack_direction)
1.1.1.2 root 1474: anti_adjust_stack (gen_rtx (CONST_INT, VOIDmode, extra));
1.1 root 1475: }
1476:
1477: /* Output a library call to function FUN (a SYMBOL_REF rtx)
1.1.1.17 root 1478: (emitting the queue unless NO_QUEUE is nonzero),
1479: for a value of mode OUTMODE,
1.1 root 1480: with NARGS different arguments, passed as alternating rtx values
1481: and machine_modes to convert them to.
1482: The rtx values should have been passed through protect_from_queue already. */
1483:
1484: void
1.1.1.2 root 1485: emit_library_call (va_alist)
1486: va_dcl
1.1 root 1487: {
1.1.1.2 root 1488: register va_list p;
1.1 root 1489: register int args_size = 0;
1490: register int argnum;
1.1.1.2 root 1491: enum machine_mode outmode;
1492: int nargs;
1493: rtx fun;
1494: rtx orgfun;
1495: int inc;
1496: int count;
1497: rtx *regvec;
1498: rtx argblock = 0;
1499: CUMULATIVE_ARGS args_so_far;
1500: struct arg { rtx value; enum machine_mode mode; };
1501: struct arg *argvec;
1.1.1.17 root 1502: int old_inhibit_defer_pop = inhibit_defer_pop;
1.1.1.15 root 1503: int stack_padding = 0;
1.1.1.17 root 1504: int no_queue = 0;
1.1.1.18! root 1505: rtx use_insns;
1.1.1.2 root 1506:
1507: va_start (p);
1508: orgfun = fun = va_arg (p, rtx);
1.1.1.17 root 1509: no_queue = va_arg (p, int);
1.1.1.2 root 1510: outmode = va_arg (p, enum machine_mode);
1511: nargs = va_arg (p, int);
1512:
1513: regvec = (rtx *) alloca (nargs * sizeof (rtx));
1514:
1515: /* Copy all the libcall-arguments out of the varargs data
1516: and into a vector ARGVEC. */
1517: argvec = (struct arg *) alloca (nargs * sizeof (struct arg));
1518: for (count = 0; count < nargs; count++)
1519: {
1.1.1.14 root 1520: rtx val = va_arg (p, rtx);
1521: enum machine_mode mode = va_arg (p, enum machine_mode);
1522:
1523: argvec[count].value = val;
1524:
1525: /* Convert the arg value to the mode the library wants.
1526: Also make sure it is a reasonable operand
1527: for a move or push insn. */
1528: /* ??? It is wrong to do it here; must do it earlier
1529: where we know the signedness of the arg. */
1530: if (GET_MODE (val) != mode && GET_MODE (val) != VOIDmode)
1531: {
1532: val = gen_reg_rtx (mode);
1.1.1.16 root 1533: convert_move (val, argvec[count].value, 0);
1.1.1.14 root 1534: }
1535: else if (GET_CODE (val) != REG && GET_CODE (val) != MEM
1536:
1537: && ! ((CONSTANT_P (val) || GET_CODE (val) == CONST_DOUBLE)
1538: && LEGITIMATE_CONSTANT_P (val)))
1539: val = force_operand (val, 0);
1540:
1541: argvec[count].value = val;
1542: argvec[count].mode = mode;
1.1.1.2 root 1543: }
1544: va_end (p);
1545:
1546: /* If we have no actual push instructions, make space for all the args
1547: right now. */
1548: #ifndef PUSH_ROUNDING
1549: INIT_CUMULATIVE_ARGS (args_so_far, (tree)0);
1550: for (count = 0; count < nargs; count++)
1551: {
1552: register enum machine_mode mode = argvec[count].mode;
1553: register rtx reg;
1554: register int partial;
1555:
1.1.1.17 root 1556: reg = FUNCTION_ARG (args_so_far, mode, (tree)0, 1);
1.1.1.2 root 1557: #ifdef FUNCTION_ARG_PARTIAL_NREGS
1.1.1.17 root 1558: partial = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, mode, (tree)0, 1);
1.1.1.2 root 1559: #else
1560: partial = 0;
1561: #endif
1562: if (reg == 0 || partial != 0)
1563: args_size += GET_MODE_SIZE (mode);
1564: if (partial != 0)
1565: args_size -= partial * GET_MODE_SIZE (SImode);
1.1.1.17 root 1566: FUNCTION_ARG_ADVANCE (args_so_far, mode, (tree)0, 1);
1.1.1.2 root 1567: }
1568:
1569: if (args_size != 0)
1.1.1.15 root 1570: {
1571: #ifdef STACK_ARGS_ADJUST
1.1.1.16 root 1572: struct args_size size;
1573: size.constant = args_size;
1574: size.var = 0;
1575: STACK_ARGS_ADJUST (size);
1576: args_size = size.constant;
1.1.1.2 root 1577: #endif
1.1.1.15 root 1578: argblock
1579: = push_block (round_push (gen_rtx (CONST_INT, VOIDmode, args_size)));
1580: }
1581: #endif /* no PUSH_ROUNDING */
1.1.1.2 root 1582:
1583: INIT_CUMULATIVE_ARGS (args_so_far, (tree)0);
1584:
1585: #ifdef PUSH_ARGS_REVERSED
1586: inc = -1;
1587: argnum = nargs - 1;
1.1 root 1588: #else
1.1.1.2 root 1589: inc = 1;
1590: argnum = 0;
1.1 root 1591: #endif
1.1.1.15 root 1592: args_size = stack_padding;
1.1.1.2 root 1593:
1594: for (count = 0; count < nargs; count++, argnum += inc)
1.1 root 1595: {
1.1.1.2 root 1596: register enum machine_mode mode = argvec[argnum].mode;
1597: register rtx val = argvec[argnum].value;
1598: rtx reg;
1599: int partial;
1600: int arg_size;
1601:
1.1.1.17 root 1602: reg = FUNCTION_ARG (args_so_far, mode, (tree)0, 1);
1.1.1.2 root 1603: regvec[argnum] = reg;
1604: #ifdef FUNCTION_ARG_PARTIAL_NREGS
1.1.1.17 root 1605: partial = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, mode, (tree)0, 1);
1.1.1.2 root 1606: #else
1607: partial = 0;
1608: #endif
1609:
1610: if (reg != 0 && partial == 0)
1611: emit_move_insn (reg, val);
1612: else
1613: emit_push_insn (val, mode, 0, 0, partial, reg, 0, argblock,
1614: gen_rtx (CONST_INT, VOIDmode, args_size));
1615:
1616: /* Compute size of stack space used by this argument. */
1617: if (reg == 0 || partial != 0)
1618: arg_size = GET_MODE_SIZE (mode);
1619: else
1620: arg_size = 0;
1621: if (partial != 0)
1622: arg_size
1623: -= ((partial * UNITS_PER_WORD)
1624: / (PARM_BOUNDARY / BITS_PER_UNIT)
1625: * (PARM_BOUNDARY / BITS_PER_UNIT));
1626:
1627: args_size += arg_size;
1.1.1.9 root 1628: NO_DEFER_POP;
1.1.1.17 root 1629: FUNCTION_ARG_ADVANCE (args_so_far, mode, (tree)0, 1);
1.1 root 1630: }
1631:
1.1.1.17 root 1632: /* For version 1.37, try deleting this entirely. */
1633: if (! no_queue)
1634: emit_queue ();
1.1.1.2 root 1635:
1636: fun = prepare_call_address (fun, 0);
1637:
1.1.1.18! root 1638: /* Any regs containing parms remain in use through the call. */
! 1639: start_sequence ();
1.1.1.2 root 1640: for (count = 0; count < nargs; count++)
1641: if (regvec[count] != 0)
1642: emit_insn (gen_rtx (USE, VOIDmode, regvec[count]));
1643:
1.1.1.18! root 1644: use_insns = gen_sequence ();
! 1645: end_sequence ();
! 1646:
1.1.1.2 root 1647: #ifdef STACK_BOUNDARY
1648: args_size = (args_size + STACK_BYTES - 1) / STACK_BYTES * STACK_BYTES;
1649: #endif
1650:
1.1.1.3 root 1651: /* Don't allow popping to be deferred, since then
1652: cse'ing of library calls could delete a call and leave the pop. */
1.1.1.9 root 1653: NO_DEFER_POP;
1.1.1.2 root 1654: emit_call_1 (fun, get_identifier (XSTR (orgfun, 0)), args_size,
1655: FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1),
1656: outmode != VOIDmode ? hard_libcall_value (outmode) : 0,
1.1.1.18! root 1657: old_inhibit_defer_pop + 1, use_insns);
1.1.1.9 root 1658: OK_DEFER_POP;
1.1 root 1659: }
1660:
1661: /* Expand an assignment that stores the value of FROM into TO.
1.1.1.2 root 1662: If WANT_VALUE is nonzero, return an rtx for the value of TO.
1663: (This may contain a QUEUED rtx.)
1664: Otherwise, the returned value is not meaningful.
1665:
1666: SUGGEST_REG is no longer actually used.
1667: It used to mean, copy the value through a register
1668: and return that register, if that is possible.
1669: But now we do this if WANT_VALUE.
1670:
1671: If the value stored is a constant, we return the constant. */
1.1 root 1672:
1673: rtx
1.1.1.2 root 1674: expand_assignment (to, from, want_value, suggest_reg)
1.1 root 1675: tree to, from;
1.1.1.2 root 1676: int want_value;
1677: int suggest_reg;
1.1 root 1678: {
1679: register rtx to_rtx = 0;
1680:
1681: /* Don't crash if the lhs of the assignment was erroneous. */
1682:
1683: if (TREE_CODE (to) == ERROR_MARK)
1684: return expand_expr (from, 0, VOIDmode, 0);
1685:
1686: /* Assignment of a structure component needs special treatment
1.1.1.2 root 1687: if the structure component's rtx is not simply a MEM.
1688: Assignment of an array element at a constant index
1689: has the same problem. */
1690:
1691: if (TREE_CODE (to) == COMPONENT_REF
1692: || (TREE_CODE (to) == ARRAY_REF
1693: && TREE_CODE (TREE_OPERAND (to, 1)) == INTEGER_CST
1694: && TREE_CODE (TYPE_SIZE (TREE_TYPE (to))) == INTEGER_CST))
1.1 root 1695: {
1.1.1.2 root 1696: register enum machine_mode mode1;
1697: int bitsize;
1.1 root 1698: int volstruct = 0;
1.1.1.2 root 1699: tree tem = to;
1700: int bitpos = 0;
1701: int unsignedp;
1.1 root 1702:
1.1.1.2 root 1703: if (TREE_CODE (to) == COMPONENT_REF)
1.1 root 1704: {
1705: tree field = TREE_OPERAND (to, 1);
1.1.1.2 root 1706: bitsize = TREE_INT_CST_LOW (DECL_SIZE (field)) * DECL_SIZE_UNIT (field);
1707: mode1 = DECL_MODE (TREE_OPERAND (to, 1));
1708: unsignedp = TREE_UNSIGNED (field);
1.1 root 1709: }
1.1.1.2 root 1710: else
1.1 root 1711: {
1.1.1.2 root 1712: mode1 = TYPE_MODE (TREE_TYPE (to));
1713: bitsize = GET_MODE_BITSIZE (mode1);
1714: unsignedp = TREE_UNSIGNED (TREE_TYPE (to));
1.1 root 1715: }
1716:
1.1.1.2 root 1717: /* Compute cumulative bit-offset for nested component-refs
1718: and array-refs, and find the ultimate containing object. */
1.1 root 1719:
1.1.1.2 root 1720: while (1)
1.1 root 1721: {
1.1.1.2 root 1722: if (TREE_CODE (tem) == COMPONENT_REF)
1723: {
1724: bitpos += DECL_OFFSET (TREE_OPERAND (tem, 1));
1725: if (TREE_THIS_VOLATILE (tem))
1726: volstruct = 1;
1727: }
1728: else if (TREE_CODE (tem) == ARRAY_REF
1729: && TREE_CODE (TREE_OPERAND (tem, 1)) == INTEGER_CST
1730: && TREE_CODE (TYPE_SIZE (TREE_TYPE (tem))) == INTEGER_CST)
1731: {
1732: bitpos += (TREE_INT_CST_LOW (TREE_OPERAND (tem, 1))
1733: * TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (tem)))
1734: * TYPE_SIZE_UNIT (TREE_TYPE (tem)));
1735: }
1736: else
1737: break;
1738: tem = TREE_OPERAND (tem, 0);
1.1 root 1739: }
1.1.1.17 root 1740: /* TEM is now the containing data object. */
1.1 root 1741:
1.1.1.2 root 1742: /* If we are going to use store_bit_field and extract_bit_field,
1743: make sure to_rtx will be safe for multiple use. */
1744: if (mode1 == BImode && want_value)
1745: tem = stabilize_reference (tem);
1.1 root 1746:
1.1.1.2 root 1747: to_rtx = expand_expr (tem, 0, VOIDmode, 0);
1748:
1749: return store_field (to_rtx, bitsize, bitpos, mode1, from,
1.1.1.10 root 1750: (want_value
1751: /* Spurious cast makes HPUX compiler happy. */
1752: ? (enum machine_mode) TYPE_MODE (TREE_TYPE (to))
1753: : VOIDmode),
1.1.1.14 root 1754: unsignedp,
1.1.1.17 root 1755: /* Required alignment of containing datum. */
1756: TYPE_ALIGN (TREE_TYPE (tem)) / BITS_PER_UNIT);
1.1 root 1757: }
1758:
1759: /* Ordinary treatment. Expand TO to get a REG or MEM rtx.
1760: Don't re-expand if it was expanded already (in COMPONENT_REF case). */
1761:
1762: if (to_rtx == 0)
1763: to_rtx = expand_expr (to, 0, VOIDmode, 0);
1764:
1765: /* Compute FROM and store the value in the rtx we got. */
1766:
1.1.1.2 root 1767: return store_expr (from, to_rtx, want_value);
1.1 root 1768: }
1769:
1770: /* Generate code for computing expression EXP,
1.1.1.2 root 1771: and storing the value into TARGET.
1772: Returns TARGET or an equivalent value.
1773: TARGET may contain a QUEUED rtx.
1.1 root 1774:
1.1.1.2 root 1775: If SUGGEST_REG is nonzero, copy the value through a register
1776: and return that register, if that is possible.
1777:
1778: If the value stored is a constant, we return the constant. */
1779:
1780: rtx
1781: store_expr (exp, target, suggest_reg)
1.1 root 1782: register tree exp;
1783: register rtx target;
1.1.1.2 root 1784: int suggest_reg;
1.1 root 1785: {
1.1.1.2 root 1786: register rtx temp;
1787: int dont_return_target = 0;
1788:
1789: /* Copying a non-constant CONSTRUCTOR needs special treatment. */
1790:
1791: if (TREE_CODE (exp) == CONSTRUCTOR && ! TREE_LITERAL (exp))
1792: {
1793: store_constructor (exp, target);
1794: return target;
1795: }
1796:
1797: if (suggest_reg && GET_CODE (target) == MEM && GET_MODE (target) != BLKmode)
1798: /* If target is in memory and caller wants value in a register instead,
1799: arrange that. Pass TARGET as target for expand_expr so that,
1800: if EXP is another assignment, SUGGEST_REG will be nonzero for it.
1801: We know expand_expr will not use the target in that case. */
1802: {
1803: temp = expand_expr (exp, cse_not_expected ? 0 : target,
1804: GET_MODE (target), 0);
1805: if (GET_MODE (temp) != BLKmode && GET_MODE (temp) != VOIDmode)
1806: temp = copy_to_reg (temp);
1807: dont_return_target = 1;
1808: }
1809: else if (queued_subexp_p (target))
1810: /* If target contains a postincrement, it is not safe
1811: to use as the returned value. It would access the wrong
1812: place by the time the queued increment gets output.
1813: So copy the value through a temporary and use that temp
1814: as the result. */
1815: {
1816: temp = expand_expr (exp, 0, GET_MODE (target), 0);
1817: if (GET_MODE (temp) != BLKmode && GET_MODE (temp) != VOIDmode)
1818: temp = copy_to_reg (temp);
1819: dont_return_target = 1;
1820: }
1821: else
1822: {
1823: temp = expand_expr (exp, target, GET_MODE (target), 0);
1824: /* DO return TARGET if it's a specified hardware register.
1825: expand_return relies on this. */
1826: if (!(target && GET_CODE (target) == REG
1827: && REGNO (target) < FIRST_PSEUDO_REGISTER)
1828: && (CONSTANT_P (temp) || GET_CODE (temp) == CONST_DOUBLE))
1829: dont_return_target = 1;
1830: }
1831:
1.1.1.12 root 1832: /* If value was not generated in the target, store it there.
1833: Convert the value to TARGET's type first if nec. */
1.1.1.2 root 1834:
1.1 root 1835: if (temp != target && TREE_CODE (exp) != ERROR_MARK)
1836: {
1837: target = protect_from_queue (target, 1);
1838: if (GET_MODE (temp) != GET_MODE (target)
1839: && GET_MODE (temp) != VOIDmode)
1.1.1.2 root 1840: {
1841: int unsignedp = TREE_UNSIGNED (TREE_TYPE (exp));
1842: if (dont_return_target)
1.1.1.12 root 1843: {
1844: /* In this case, we will return TEMP,
1845: so make sure it has the proper mode.
1846: But don't forget to store the value into TARGET. */
1847: temp = convert_to_mode (GET_MODE (target), temp, unsignedp);
1848: emit_move_insn (target, temp);
1849: }
1.1.1.2 root 1850: else
1851: convert_move (target, temp, unsignedp);
1852: }
1853:
1.1 root 1854: else if (GET_MODE (temp) == BLKmode)
1855: emit_block_move (target, temp, expr_size (exp),
1856: TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
1857: else
1858: emit_move_insn (target, temp);
1859: }
1.1.1.2 root 1860: if (dont_return_target)
1861: return temp;
1.1 root 1862: return target;
1863: }
1864:
1.1.1.2 root 1865: /* Store the value of constructor EXP into the rtx TARGET.
1866: TARGET is either a REG or a MEM. */
1.1 root 1867:
1.1.1.2 root 1868: static void
1869: store_constructor (exp, target)
1870: tree exp;
1871: rtx target;
1.1 root 1872: {
1.1.1.7 root 1873: /* Don't try copying piece by piece into a hard register
1874: since that is vulnerable to being clobbered by EXP.
1875: Instead, construct in a pseudo register and then copy it all. */
1876: if (GET_CODE (target) == REG && REGNO (target) < FIRST_PSEUDO_REGISTER)
1877: {
1878: rtx temp = gen_reg_rtx (GET_MODE (target));
1879: store_constructor (exp, temp);
1880: emit_move_insn (target, temp);
1881: return;
1882: }
1883:
1.1.1.2 root 1884: if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
1.1 root 1885: {
1.1.1.2 root 1886: register tree elt;
1.1 root 1887:
1.1.1.2 root 1888: /* If the constructor has fewer fields than the structure,
1889: clear the whole structure first. */
1.1 root 1890:
1.1.1.2 root 1891: if (list_length (CONSTRUCTOR_ELTS (exp))
1892: != list_length (TYPE_FIELDS (TREE_TYPE (exp))))
1893: clear_storage (target, int_size_in_bytes (TREE_TYPE (exp)));
1894: else
1895: /* Inform later passes that the old value is dead. */
1896: emit_insn (gen_rtx (CLOBBER, VOIDmode, target));
1897:
1898: /* Store each element of the constructor into
1899: the corresponding field of TARGET. */
1900:
1901: for (elt = CONSTRUCTOR_ELTS (exp); elt; elt = TREE_CHAIN (elt))
1902: {
1903: register tree field = TREE_PURPOSE (elt);
1904: register enum machine_mode mode;
1905: int bitsize;
1906: int bitpos;
1907: int unsignedp;
1908:
1909: bitsize = TREE_INT_CST_LOW (DECL_SIZE (field)) * DECL_SIZE_UNIT (field);
1910: mode = DECL_MODE (field);
1911: unsignedp = TREE_UNSIGNED (field);
1912:
1913: bitpos = DECL_OFFSET (field);
1914:
1915: store_field (target, bitsize, bitpos, mode, TREE_VALUE (elt),
1.1.1.15 root 1916: /* The alignment of TARGET is
1917: at least what its type requires. */
1.1.1.17 root 1918: VOIDmode, 0,
1919: TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
1.1.1.2 root 1920: }
1921: }
1922: else if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
1923: {
1924: register tree elt;
1925: register int i;
1926: tree domain = TYPE_DOMAIN (TREE_TYPE (exp));
1927: int minelt = TREE_INT_CST_LOW (TYPE_MIN_VALUE (domain));
1928: int maxelt = TREE_INT_CST_LOW (TYPE_MAX_VALUE (domain));
1929: tree elttype = TREE_TYPE (TREE_TYPE (exp));
1930:
1931: /* If the constructor has fewer fields than the structure,
1932: clear the whole structure first. */
1933:
1934: if (list_length (CONSTRUCTOR_ELTS (exp)) < maxelt - minelt + 1)
1935: clear_storage (target, maxelt - minelt + 1);
1936: else
1937: /* Inform later passes that the old value is dead. */
1938: emit_insn (gen_rtx (CLOBBER, VOIDmode, target));
1939:
1940: /* Store each element of the constructor into
1941: the corresponding element of TARGET, determined
1942: by counting the elements. */
1943: for (elt = CONSTRUCTOR_ELTS (exp), i = 0;
1944: elt;
1945: elt = TREE_CHAIN (elt), i++)
1946: {
1947: register enum machine_mode mode;
1948: int bitsize;
1949: int bitpos;
1950: int unsignedp;
1951:
1952: mode = TYPE_MODE (elttype);
1953: bitsize = GET_MODE_BITSIZE (mode);
1954: unsignedp = TREE_UNSIGNED (elttype);
1955:
1956: bitpos = (i * TREE_INT_CST_LOW (TYPE_SIZE (elttype))
1957: * TYPE_SIZE_UNIT (elttype));
1958:
1959: store_field (target, bitsize, bitpos, mode, TREE_VALUE (elt),
1.1.1.15 root 1960: /* The alignment of TARGET is
1961: at least what its type requires. */
1.1.1.17 root 1962: VOIDmode, 0,
1963: TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
1.1.1.2 root 1964: }
1965: }
1966: }
1967:
1968: /* Store the value of EXP (an expression tree)
1969: into a subfield of TARGET which has mode MODE and occupies
1970: BITSIZE bits, starting BITPOS bits from the start of TARGET.
1971:
1972: If VALUE_MODE is VOIDmode, return nothing in particular.
1973: UNSIGNEDP is not used in this case.
1974:
1975: Otherwise, return an rtx for the value stored. This rtx
1976: has mode VALUE_MODE if that is convenient to do.
1.1.1.14 root 1977: In this case, UNSIGNEDP must be nonzero if the value is an unsigned type.
1978:
1979: ALIGN is the alignment that TARGET is known to have, measured in bytes. */
1.1.1.2 root 1980:
1981: static rtx
1.1.1.14 root 1982: store_field (target, bitsize, bitpos, mode, exp, value_mode, unsignedp, align)
1.1.1.2 root 1983: rtx target;
1984: int bitsize, bitpos;
1985: enum machine_mode mode;
1986: tree exp;
1987: enum machine_mode value_mode;
1988: int unsignedp;
1.1.1.14 root 1989: int align;
1.1.1.2 root 1990: {
1991: /* If the structure is in a register or if the component
1992: is a bit field, we cannot use addressing to access it.
1993: Use bit-field techniques or SUBREG to store in it. */
1994:
1995: if (mode == BImode || GET_CODE (target) == REG
1996: || GET_CODE (target) == SUBREG)
1997: {
1998: store_bit_field (target, bitsize, bitpos,
1999: mode,
1.1.1.14 root 2000: expand_expr (exp, 0, VOIDmode, 0),
2001: align);
1.1.1.2 root 2002: if (value_mode != VOIDmode)
2003: return extract_bit_field (target, bitsize, bitpos, unsignedp,
1.1.1.14 root 2004: 0, value_mode, 0, align);
1.1.1.2 root 2005: return const0_rtx;
2006: }
2007: else
2008: {
2009: rtx addr = XEXP (target, 0);
2010: rtx to_rtx;
2011:
2012: /* If a value is wanted, it must be the lhs;
2013: so make the address stable for multiple use. */
2014:
2015: if (value_mode != VOIDmode && GET_CODE (addr) != REG
2016: && ! CONSTANT_ADDRESS_P (addr))
2017: addr = copy_to_reg (addr);
2018:
2019: /* Now build a reference to just the desired component. */
2020:
2021: to_rtx = change_address (target, mode,
2022: plus_constant (addr,
2023: (bitpos / BITS_PER_UNIT)));
1.1.1.10 root 2024: MEM_IN_STRUCT_P (to_rtx) = 1;
1.1.1.2 root 2025:
2026: return store_expr (exp, to_rtx, value_mode != VOIDmode);
2027: }
2028: }
2029:
2030: /* Given an rtx VALUE that may contain additions and multiplications,
2031: return an equivalent value that just refers to a register or memory.
2032: This is done by generating instructions to perform the arithmetic
2033: and returning a pseudo-register containing the value. */
2034:
2035: rtx
2036: force_operand (value, target)
2037: rtx value, target;
2038: {
2039: register optab binoptab = 0;
2040: register rtx op2;
2041: /* Use subtarget as the target for operand 0 of a binary operation. */
2042: register rtx subtarget = (target != 0 && GET_CODE (target) == REG ? target : 0);
2043:
2044: if (GET_CODE (value) == PLUS)
2045: binoptab = add_optab;
2046: else if (GET_CODE (value) == MINUS)
2047: binoptab = sub_optab;
2048: else if (GET_CODE (value) == MULT)
2049: {
2050: op2 = XEXP (value, 1);
2051: if (!CONSTANT_P (op2)
2052: && !(GET_CODE (op2) == REG && op2 != subtarget))
2053: subtarget = 0;
2054: return expand_mult (GET_MODE (value),
2055: force_operand (XEXP (value, 0), subtarget),
2056: force_operand (op2, 0),
2057: target, 0);
2058: }
2059:
2060: if (binoptab)
2061: {
2062: op2 = XEXP (value, 1);
2063: if (!CONSTANT_P (op2)
2064: && !(GET_CODE (op2) == REG && op2 != subtarget))
2065: subtarget = 0;
2066: if (binoptab == sub_optab
2067: && GET_CODE (op2) == CONST_INT && INTVAL (op2) < 0)
2068: {
2069: binoptab = add_optab;
2070: op2 = gen_rtx (CONST_INT, VOIDmode, - INTVAL (op2));
2071: }
2072: return expand_binop (GET_MODE (value), binoptab,
2073: force_operand (XEXP (value, 0), subtarget),
2074: force_operand (op2, 0),
2075: target, 0, OPTAB_LIB_WIDEN);
2076: /* We give UNSIGNEP = 0 to expand_binop
2077: because the only operations we are expanding here are signed ones. */
2078: }
2079: return value;
2080: }
2081:
2082: /* expand_expr: generate code for computing expression EXP.
1.1.1.14 root 2083: An rtx for the computed value is returned. The value is never null.
2084: In the case of a void EXP, const0_rtx is returned.
1.1.1.2 root 2085:
2086: The value may be stored in TARGET if TARGET is nonzero.
1.1 root 2087: TARGET is just a suggestion; callers must assume that
2088: the rtx returned may not be the same as TARGET.
2089:
1.1.1.2 root 2090: If TARGET is CONST0_RTX, it means that the value will be ignored.
2091:
1.1 root 2092: If TMODE is not VOIDmode, it suggests generating the
2093: result in mode TMODE. But this is done only when convenient.
2094: Otherwise, TMODE is ignored and the value generated in its natural mode.
2095: TMODE is just a suggestion; callers must assume that
2096: the rtx returned may not have mode TMODE.
2097:
1.1.1.2 root 2098: If MODIFIER is EXPAND_SUM then when EXP is an addition
1.1 root 2099: we can return an rtx of the form (MULT (REG ...) (CONST_INT ...))
2100: or a nest of (PLUS ...) and (MINUS ...) where the terms are
2101: products as above, or REG or MEM, or constant.
1.1.1.2 root 2102: Ordinarily in such cases we would output mul or add instructions
2103: and then return a pseudo reg containing the sum.
2104:
2105: If MODIFIER is EXPAND_CONST_ADDRESS then it is ok to return
2106: a MEM rtx whose address is a constant that isn't a legitimate address. */
1.1 root 2107:
2108: /* Subroutine of expand_expr:
1.1.1.13 root 2109: save the non-copied parts (LIST) of an expr (LHS), and return a list
2110: which can restore these values to their previous values,
2111: should something modify their storage. */
2112: static tree
2113: save_noncopied_parts (lhs, list)
2114: tree lhs;
2115: tree list;
2116: {
2117: tree tail;
2118: tree parts = 0;
2119:
2120: for (tail = list; tail; tail = TREE_CHAIN (tail))
2121: if (TREE_CODE (TREE_VALUE (tail)) == TREE_LIST)
2122: parts = chainon (parts, save_noncopied_parts (TREE_VALUE (tail)));
2123: else
2124: {
2125: tree part = TREE_VALUE (tail);
2126: tree part_type = TREE_TYPE (part);
2127: parts = tree_cons (save_expr (build_component_ref (lhs, part, parts, 0)),
2128: build_nt (RTL_EXPR, 0, (tree) assign_stack_local (TYPE_MODE (part_type), int_size_in_bytes (part_type))),
2129: parts);
2130: store_expr (TREE_PURPOSE (parts), RTL_EXPR_RTL (TREE_VALUE (parts)), 0);
2131: }
2132: return parts;
2133: }
2134:
2135: /* Subroutine of expand_expr:
1.1 root 2136: return the target to use when recursively expanding
2137: the first operand of an arithmetic operation. */
2138:
2139: static rtx
2140: validate_subtarget (subtarget, otherop)
2141: rtx subtarget;
2142: tree otherop;
2143: {
2144: if (TREE_LITERAL (otherop))
2145: return subtarget;
2146: if (TREE_CODE (otherop) == VAR_DECL
2147: && DECL_RTL (otherop) != subtarget)
2148: return subtarget;
2149: return 0;
2150: }
2151:
2152: rtx
1.1.1.2 root 2153: expand_expr (exp, target, tmode, modifier)
1.1 root 2154: register tree exp;
2155: rtx target;
2156: enum machine_mode tmode;
1.1.1.2 root 2157: enum expand_modifier modifier;
1.1 root 2158: {
2159: register rtx op0, op1, temp;
2160: tree type = TREE_TYPE (exp);
2161: register enum machine_mode mode = TYPE_MODE (type);
2162: register enum tree_code code = TREE_CODE (exp);
1.1.1.2 root 2163: optab this_optab;
1.1 root 2164: int negate_1;
2165: /* Use subtarget as the target for operand 0 of a binary operation. */
2166: rtx subtarget = (target != 0 && GET_CODE (target) == REG ? target : 0);
1.1.1.2 root 2167: rtx original_target = target;
2168: int ignore = target == const0_rtx;
2169:
1.1.1.7 root 2170: /* Don't use hard regs as subtargets, because the combiner
2171: can only handle pseudo regs. */
2172: if (subtarget && REGNO (subtarget) < FIRST_PSEUDO_REGISTER)
2173: subtarget = 0;
1.1.1.17 root 2174: /* Avoid subtargets inside loops,
2175: since they hide some invariant expressions. */
2176: if (optimize && inside_loop ())
2177: subtarget = 0;
1.1.1.7 root 2178:
1.1.1.2 root 2179: if (ignore) target = 0, original_target = 0;
1.1 root 2180:
2181: /* If will do cse, generate all results into registers
2182: since 1) that allows cse to find more things
2183: and 2) otherwise cse could produce an insn the machine
2184: cannot support. */
2185:
2186: if (! cse_not_expected && mode != BLKmode)
2187: target = subtarget;
2188:
1.1.1.2 root 2189: /* No sense saving up arithmetic to be done
2190: if it's all in the wrong mode to form part of an address.
2191: And force_operand won't know whether to sign-extend or zero-extend. */
2192:
2193: if (mode != Pmode && modifier == EXPAND_SUM)
1.1.1.6 root 2194: modifier = EXPAND_NORMAL;
1.1.1.2 root 2195:
1.1 root 2196: switch (code)
2197: {
1.1.1.4 root 2198: case PARM_DECL:
2199: if (DECL_RTL (exp) == 0)
2200: {
2201: error_with_decl (exp, "prior parameter's size depends on `%s'");
2202: return const0_rtx;
2203: }
2204:
1.1 root 2205: case FUNCTION_DECL:
2206: case VAR_DECL:
2207: case RESULT_DECL:
2208: if (DECL_RTL (exp) == 0)
2209: abort ();
1.1.1.14 root 2210: /* This is the case of an array whose size is to be determined
2211: from its initializer, while the initializer is still being parsed.
2212: See expand_decl. */
2213: if (GET_CODE (DECL_RTL (exp)) == MEM
2214: && GET_CODE (XEXP (DECL_RTL (exp), 0)) == REG)
1.1.1.16 root 2215: return change_address (DECL_RTL (exp), GET_MODE (DECL_RTL (exp)),
1.1.1.14 root 2216: XEXP (DECL_RTL (exp), 0));
1.1.1.2 root 2217: if (GET_CODE (DECL_RTL (exp)) == MEM
2218: && modifier != EXPAND_CONST_ADDRESS)
2219: {
2220: /* DECL_RTL probably contains a constant address.
2221: On RISC machines where a constant address isn't valid,
2222: make some insns to get that address into a register. */
1.1.1.7 root 2223: if (!memory_address_p (DECL_MODE (exp), XEXP (DECL_RTL (exp), 0))
2224: || (flag_force_addr
2225: && CONSTANT_ADDRESS_P (XEXP (DECL_RTL (exp), 0))))
1.1.1.2 root 2226: return change_address (DECL_RTL (exp), VOIDmode,
2227: copy_rtx (XEXP (DECL_RTL (exp), 0)));
2228: }
1.1 root 2229: return DECL_RTL (exp);
2230:
2231: case INTEGER_CST:
1.1.1.7 root 2232: if (GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_INT)
2233: return gen_rtx (CONST_INT, VOIDmode, TREE_INT_CST_LOW (exp));
1.1.1.8 root 2234: /* Generate immediate CONST_DOUBLE
1.1.1.7 root 2235: which will be turned into memory by reload if necessary. */
1.1.1.8 root 2236: return immed_double_const (TREE_INT_CST_LOW (exp),
2237: TREE_INT_CST_HIGH (exp),
2238: mode);
1.1 root 2239:
2240: case CONST_DECL:
2241: return expand_expr (DECL_INITIAL (exp), target, VOIDmode, 0);
2242:
2243: case REAL_CST:
1.1.1.7 root 2244: /* If optimized, generate immediate CONST_DOUBLE
2245: which will be turned into memory by reload if necessary. */
1.1 root 2246: if (!cse_not_expected)
2247: return immed_real_const (exp);
2248: case COMPLEX_CST:
2249: case STRING_CST:
1.1.1.8 root 2250: if (! TREE_CST_RTL (exp))
2251: output_constant_def (exp);
2252:
2253: /* TREE_CST_RTL probably contains a constant address.
2254: On RISC machines where a constant address isn't valid,
2255: make some insns to get that address into a register. */
2256: if (GET_CODE (TREE_CST_RTL (exp)) == MEM
2257: && modifier != EXPAND_CONST_ADDRESS
2258: && !memory_address_p (mode, XEXP (TREE_CST_RTL (exp), 0)))
2259: return change_address (TREE_CST_RTL (exp), VOIDmode,
2260: copy_rtx (XEXP (TREE_CST_RTL (exp), 0)));
1.1 root 2261: return TREE_CST_RTL (exp);
2262:
2263: case SAVE_EXPR:
2264: if (SAVE_EXPR_RTL (exp) == 0)
2265: {
1.1.1.5 root 2266: rtx reg = gen_reg_rtx (mode);
2267: SAVE_EXPR_RTL (exp) = reg;
2268: store_expr (TREE_OPERAND (exp, 0), reg, 0);
2269: if (!optimize)
2270: save_expr_regs = gen_rtx (EXPR_LIST, VOIDmode, reg,
2271: save_expr_regs);
1.1 root 2272: }
1.1.1.2 root 2273: /* Don't let the same rtl node appear in two places. */
1.1 root 2274: return SAVE_EXPR_RTL (exp);
2275:
1.1.1.17 root 2276: case LET_STMT:
2277: TREE_USED (exp) = 1;
2278: temp = expand_expr (STMT_BODY (exp), target, tmode, modifier);
2279: return temp;
2280:
1.1.1.2 root 2281: case RTL_EXPR:
1.1.1.10 root 2282: if (RTL_EXPR_SEQUENCE (exp) == const0_rtx)
2283: abort ();
2284: emit_insns (RTL_EXPR_SEQUENCE (exp));
2285: RTL_EXPR_SEQUENCE (exp) = const0_rtx;
1.1.1.2 root 2286: return RTL_EXPR_RTL (exp);
2287:
2288: case CONSTRUCTOR:
2289: /* All elts simple constants => refer to a constant in memory. */
2290: if (TREE_STATIC (exp))
2291: /* For aggregate types with non-BLKmode modes,
2292: this should ideally construct a CONST_INT. */
1.1.1.14 root 2293: {
2294: rtx constructor = output_constant_def (exp);
2295: if (! memory_address_p (GET_MODE (constructor),
2296: XEXP (constructor, 0)))
2297: constructor = change_address (constructor, VOIDmode,
2298: XEXP (constructor, 0));
2299: return constructor;
2300: }
1.1.1.2 root 2301:
2302: if (ignore)
2303: {
2304: tree elt;
2305: for (elt = CONSTRUCTOR_ELTS (exp); elt; elt = TREE_CHAIN (elt))
2306: expand_expr (TREE_VALUE (elt), const0_rtx, VOIDmode, 0);
2307: return const0_rtx;
2308: }
2309: else
2310: {
2311: if (target == 0)
2312: target = gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)),
2313: get_structure_value_addr (expr_size (exp)));
2314: store_expr (exp, target, 0);
2315: return target;
2316: }
2317:
1.1 root 2318: case INDIRECT_REF:
2319: {
2320: tree exp1 = TREE_OPERAND (exp, 0);
2321: tree exp2;
2322:
2323: /* A SAVE_EXPR as the address in an INDIRECT_EXPR is generated
2324: for *PTR += ANYTHING where PTR is put inside the SAVE_EXPR.
2325: This code has the same general effect as simply doing
2326: expand_expr on the save expr, except that the expression PTR
2327: is computed for use as a memory address. This means different
2328: code, suitable for indexing, may be generated. */
2329: if (TREE_CODE (exp1) == SAVE_EXPR
2330: && SAVE_EXPR_RTL (exp1) == 0
2331: && TREE_CODE (exp2 = TREE_OPERAND (exp1, 0)) != ERROR_MARK
2332: && TYPE_MODE (TREE_TYPE (exp1)) == Pmode
2333: && TYPE_MODE (TREE_TYPE (exp2)) == Pmode)
2334: {
1.1.1.2 root 2335: temp = expand_expr (TREE_OPERAND (exp1, 0), 0, VOIDmode, EXPAND_SUM);
1.1 root 2336: op0 = memory_address (mode, temp);
2337: op0 = copy_all_regs (op0);
2338: SAVE_EXPR_RTL (exp1) = op0;
2339: }
2340: else
2341: {
1.1.1.2 root 2342: op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, EXPAND_SUM);
1.1 root 2343: op0 = memory_address (mode, op0);
2344: }
2345: }
2346: temp = gen_rtx (MEM, mode, op0);
1.1.1.2 root 2347: /* If address was computed by addition,
2348: mark this as an element of an aggregate. */
2349: if (TREE_CODE (TREE_OPERAND (exp, 0)) == PLUS_EXPR
2350: || (TREE_CODE (TREE_OPERAND (exp, 0)) == SAVE_EXPR
2351: && TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) == PLUS_EXPR))
1.1.1.10 root 2352: MEM_IN_STRUCT_P (temp) = 1;
1.1.1.13 root 2353: MEM_VOLATILE_P (temp) = TREE_THIS_VOLATILE (exp) || flag_volatile;
1.1.1.10 root 2354: RTX_UNCHANGING_P (temp) = TREE_READONLY (exp);
1.1.1.2 root 2355: return temp;
2356:
2357: case ARRAY_REF:
2358: if (TREE_CODE (TREE_OPERAND (exp, 1)) != INTEGER_CST
2359: || TREE_CODE (TYPE_SIZE (TREE_TYPE (exp))) != INTEGER_CST)
2360: {
2361: /* Nonconstant array index or nonconstant element size.
2362: Generate the tree for *(&array+index) and expand that,
2363: except do it in a language-independent way
2364: and don't complain about non-lvalue arrays.
2365: `mark_addressable' should already have been called
2366: for any array for which this case will be reached. */
2367:
2368: tree array_adr = build (ADDR_EXPR, TYPE_POINTER_TO (type),
2369: TREE_OPERAND (exp, 0));
2370: tree index = TREE_OPERAND (exp, 1);
2371: tree elt;
2372:
2373: /* Convert the integer argument to a type the same size as a pointer
2374: so the multiply won't overflow spuriously. */
2375: if (TYPE_PRECISION (TREE_TYPE (index)) != POINTER_SIZE)
2376: index = convert (type_for_size (POINTER_SIZE, 0), index);
2377:
2378: /* The array address isn't volatile even if the array is. */
2379: TREE_VOLATILE (array_adr) = 0;
2380:
2381: elt = build (INDIRECT_REF, type,
2382: fold (build (PLUS_EXPR, TYPE_POINTER_TO (type),
2383: array_adr,
2384: fold (build (MULT_EXPR,
2385: TYPE_POINTER_TO (type),
2386: index, size_in_bytes (type))))));
2387:
2388: return expand_expr (elt, target, tmode, modifier);
2389: }
1.1.1.13 root 2390:
1.1.1.17 root 2391: /* Fold an expression like: "foo"[2].
2392: This is not done in fold so it won't happen inside &. */
2393: {
2394: int i;
2395: tree arg0 = TREE_OPERAND (exp, 0);
2396: tree arg1 = TREE_OPERAND (exp, 1);
2397:
2398: if (TREE_CODE (arg0) == STRING_CST
2399: && TREE_CODE (arg1) == INTEGER_CST
2400: && !TREE_INT_CST_HIGH (arg1)
2401: && (i = TREE_INT_CST_LOW (arg1)) < TREE_STRING_LENGTH (arg0))
2402: {
2403: if (TREE_TYPE (TREE_TYPE (arg0)) == integer_type_node)
2404: {
2405: exp = build_int_2 (((int *)TREE_STRING_POINTER (arg0))[i], 0);
2406: TREE_TYPE (exp) = integer_type_node;
2407: return expand_expr (exp, target, tmode, modifier);
2408: }
2409: if (TREE_TYPE (TREE_TYPE (arg0)) == char_type_node)
2410: {
2411: exp = build_int_2 (TREE_STRING_POINTER (arg0)[i], 0);
2412: TREE_TYPE (exp) = integer_type_node;
2413: return expand_expr (convert (TREE_TYPE (TREE_TYPE (arg0)), exp), target, tmode, modifier);
2414: }
2415: }
2416: }
2417:
1.1.1.13 root 2418: /* If this is a constant index into a constant array,
2419: just get the value from the array. */
2420: if (TREE_READONLY (TREE_OPERAND (exp, 0))
2421: && ! TREE_VOLATILE (TREE_OPERAND (exp, 0))
2422: && TREE_CODE (TREE_TYPE (TREE_OPERAND (exp, 0))) == ARRAY_TYPE
2423: && TREE_LITERAL (TREE_OPERAND (exp, 1))
2424: && TREE_CODE (TREE_OPERAND (exp, 0)) == VAR_DECL
1.1.1.15 root 2425: && DECL_INITIAL (TREE_OPERAND (exp, 0))
2426: && TREE_CODE (DECL_INITIAL (TREE_OPERAND (exp, 0))) != ERROR_MARK)
1.1.1.13 root 2427: {
2428: tree index = fold (TREE_OPERAND (exp, 1));
2429: if (TREE_CODE (index) == INTEGER_CST)
2430: {
2431: int i = TREE_INT_CST_LOW (index);
2432: tree init = CONSTRUCTOR_ELTS (DECL_INITIAL (TREE_OPERAND (exp, 0)));
2433:
2434: while (init && i--)
2435: init = TREE_CHAIN (init);
2436: if (init)
2437: return expand_expr (fold (TREE_VALUE (init)), target, tmode, modifier);
2438: }
2439: }
1.1.1.2 root 2440: /* Treat array-ref with constant index as a component-ref. */
1.1 root 2441:
2442: case COMPONENT_REF:
2443: {
1.1.1.2 root 2444: register enum machine_mode mode1;
1.1 root 2445: int volstruct = 0;
1.1.1.2 root 2446: int bitsize;
2447: tree tem = exp;
2448: int bitpos = 0;
2449: int unsignedp;
1.1 root 2450:
1.1.1.2 root 2451: if (TREE_CODE (exp) == COMPONENT_REF)
1.1 root 2452: {
2453: tree field = TREE_OPERAND (exp, 1);
1.1.1.2 root 2454: bitsize = TREE_INT_CST_LOW (DECL_SIZE (field)) * DECL_SIZE_UNIT (field);
2455: mode1 = DECL_MODE (TREE_OPERAND (exp, 1));
2456: unsignedp = TREE_UNSIGNED (field);
1.1 root 2457: }
1.1.1.2 root 2458: else
1.1 root 2459: {
1.1.1.2 root 2460: mode1 = TYPE_MODE (TREE_TYPE (exp));
2461: bitsize = GET_MODE_BITSIZE (mode1);
2462: unsignedp = TREE_UNSIGNED (TREE_TYPE (exp));
1.1 root 2463: }
2464:
1.1.1.2 root 2465: /* Compute cumulative bit-offset for nested component-refs
2466: and array-refs, and find the ultimate containing object. */
2467:
2468: while (1)
1.1 root 2469: {
1.1.1.2 root 2470: if (TREE_CODE (tem) == COMPONENT_REF)
2471: {
2472: bitpos += DECL_OFFSET (TREE_OPERAND (tem, 1));
2473: if (TREE_THIS_VOLATILE (tem))
2474: volstruct = 1;
2475: }
2476: else if (TREE_CODE (tem) == ARRAY_REF
2477: && TREE_CODE (TREE_OPERAND (tem, 1)) == INTEGER_CST
2478: && TREE_CODE (TYPE_SIZE (TREE_TYPE (tem))) == INTEGER_CST)
2479: {
2480: bitpos += (TREE_INT_CST_LOW (TREE_OPERAND (tem, 1))
2481: * TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (tem)))
2482: * TYPE_SIZE_UNIT (TREE_TYPE (tem)));
2483: }
2484: else
2485: break;
2486: tem = TREE_OPERAND (tem, 0);
1.1 root 2487: }
2488:
1.1.1.2 root 2489: op0 = expand_expr (tem, 0, VOIDmode,
2490: (modifier == EXPAND_CONST_ADDRESS
2491: ? modifier : EXPAND_NORMAL));
1.1 root 2492:
1.1.1.2 root 2493: if (mode1 == BImode || GET_CODE (op0) == REG
2494: || GET_CODE (op0) == SUBREG)
1.1.1.17 root 2495: return extract_bit_field (op0, bitsize, bitpos, unsignedp,
2496: target, mode, tmode,
2497: TYPE_ALIGN (TREE_TYPE (tem)) / BITS_PER_UNIT);
1.1.1.2 root 2498: /* Get a reference to just this component. */
2499: if (modifier == EXPAND_CONST_ADDRESS)
2500: op0 = gen_rtx (MEM, mode1, plus_constant (XEXP (op0, 0),
2501: (bitpos / BITS_PER_UNIT)));
2502: else
2503: op0 = change_address (op0, mode1,
2504: plus_constant (XEXP (op0, 0),
2505: (bitpos / BITS_PER_UNIT)));
1.1.1.10 root 2506: MEM_IN_STRUCT_P (op0) = 1;
1.1.1.15 root 2507: MEM_VOLATILE_P (op0) |= volstruct;
1.1.1.2 root 2508: /* If OP0 is in the shared structure-value stack slot,
2509: and it is not BLKmode, copy it into a register.
2510: The shared slot may be clobbered at any time by another call.
2511: BLKmode is safe because our caller will either copy the value away
2512: or take another component and come back here. */
2513: if (mode != BLKmode
2514: && TREE_CODE (TREE_OPERAND (exp, 0)) == CALL_EXPR
2515: && TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))) == BLKmode)
2516: op0 = copy_to_reg (op0);
2517: if (mode == mode1 || mode1 == BLKmode || mode1 == tmode)
2518: return op0;
2519: if (target == 0)
2520: target = gen_reg_rtx (tmode != VOIDmode ? tmode : mode);
2521: convert_move (target, op0, unsignedp);
2522: return target;
1.1 root 2523: }
2524:
2525: /* Intended for a reference to a buffer of a file-object in Pascal.
2526: But it's not certain that a special tree code will really be
2527: necessary for these. INDIRECT_REF might work for them. */
2528: case BUFFER_REF:
2529: abort ();
2530:
1.1.1.13 root 2531: case WITH_CLEANUP_EXPR:
2532: RTL_EXPR_RTL (TREE_OPERAND (exp, 1))
2533: = expand_expr (TREE_OPERAND (exp, 0), target, tmode, modifier);
2534: cleanups_of_this_call = tree_cons (0, TREE_OPERAND (exp, 2), cleanups_of_this_call);
2535: return RTL_EXPR_RTL (TREE_OPERAND (exp, 1));
2536:
1.1 root 2537: case CALL_EXPR:
1.1.1.2 root 2538: /* Check for a built-in function. */
2539: if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR
2540: && TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) == FUNCTION_DECL
1.1.1.5 root 2541: && (DECL_FUNCTION_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))
2542: != NOT_BUILT_IN))
1.1.1.17 root 2543: return expand_builtin (exp, target, subtarget, tmode, ignore);
1.1 root 2544: /* If this call was expanded already by preexpand_calls,
2545: just return the result we got. */
2546: if (CALL_EXPR_RTL (exp) != 0)
2547: return CALL_EXPR_RTL (exp);
1.1.1.2 root 2548: return expand_call (exp, target, ignore);
1.1 root 2549:
2550: case NOP_EXPR:
2551: case CONVERT_EXPR:
1.1.1.7 root 2552: case REFERENCE_EXPR:
1.1.1.2 root 2553: if (TREE_CODE (type) == VOID_TYPE || ignore)
1.1 root 2554: {
1.1.1.2 root 2555: expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, modifier);
1.1 root 2556: return const0_rtx;
2557: }
2558: if (mode == TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))
1.1.1.2 root 2559: return expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode, modifier);
1.1 root 2560: op0 = expand_expr (TREE_OPERAND (exp, 0), 0, mode, 0);
1.1.1.2 root 2561: if (GET_MODE (op0) == mode || GET_MODE (op0) == VOIDmode)
1.1 root 2562: return op0;
1.1.1.2 root 2563: if (flag_force_mem && GET_CODE (op0) == MEM)
2564: op0 = copy_to_reg (op0);
1.1.1.18! root 2565: if (GET_MODE (op0) == VOIDmode)
! 2566: /* Avoid problem in convert_move due to unknown mode of OP0. */
! 2567: op0 = copy_to_mode_reg (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))),
! 2568: op0);
1.1 root 2569: if (target == 0)
2570: target = gen_reg_rtx (mode);
1.1.1.2 root 2571: convert_move (target, op0, TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0))));
1.1 root 2572: return target;
2573:
2574: case PLUS_EXPR:
2575: preexpand_calls (exp);
1.1.1.2 root 2576: if (TREE_CODE (TREE_OPERAND (exp, 0)) == INTEGER_CST
2577: && modifier == EXPAND_SUM)
1.1 root 2578: {
1.1.1.2 root 2579: op1 = expand_expr (TREE_OPERAND (exp, 1), subtarget, VOIDmode, EXPAND_SUM);
1.1 root 2580: op1 = plus_constant (op1, TREE_INT_CST_LOW (TREE_OPERAND (exp, 0)));
1.1.1.2 root 2581: return op1;
1.1 root 2582: }
2583: negate_1 = 1;
2584: plus_minus:
1.1.1.2 root 2585: if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST
2586: && modifier == EXPAND_SUM)
1.1 root 2587: {
1.1.1.2 root 2588: op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, EXPAND_SUM);
1.1 root 2589: op0 = plus_constant (op0,
2590: negate_1 * TREE_INT_CST_LOW (TREE_OPERAND (exp, 1)));
1.1.1.2 root 2591: return op0;
1.1 root 2592: }
2593: this_optab = add_optab;
1.1.1.2 root 2594: if (modifier != EXPAND_SUM) goto binop;
1.1 root 2595: subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
1.1.1.2 root 2596: op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, EXPAND_SUM);
2597: op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, EXPAND_SUM);
1.1 root 2598: /* Put a sum last, to simplify what follows. */
2599: #ifdef OLD_INDEXING
2600: if (GET_CODE (op1) == MULT)
2601: {
2602: temp = op0;
2603: op0 = op1;
2604: op1 = temp;
2605: }
2606: #endif
2607: #ifndef OLD_INDEXING
2608: /* Make sure any term that's a sum with a constant comes last. */
2609: if (GET_CODE (op0) == PLUS
1.1.1.2 root 2610: && CONSTANT_P (XEXP (op0, 1)))
1.1 root 2611: {
2612: temp = op0;
2613: op0 = op1;
2614: op1 = temp;
2615: }
2616: /* If adding to a sum including a constant,
2617: associate it to put the constant outside. */
2618: if (GET_CODE (op1) == PLUS
1.1.1.2 root 2619: && CONSTANT_P (XEXP (op1, 1)))
1.1 root 2620: {
1.1.1.16 root 2621: rtx tem;
2622: int constant_term = 0;
2623:
1.1 root 2624: op0 = gen_rtx (PLUS, mode, XEXP (op1, 0), op0);
1.1.1.16 root 2625: /* Let's also eliminate constants from op0 if possible. */
2626: tem = eliminate_constant_term (op0, &constant_term);
1.1 root 2627: if (GET_CODE (XEXP (op1, 1)) == CONST_INT)
1.1.1.16 root 2628: {
2629: if (constant_term != 0)
2630: return plus_constant (tem, INTVAL (XEXP (op1, 1)) + constant_term);
2631: else
2632: return plus_constant (op0, INTVAL (XEXP (op1, 1)));
2633: }
1.1 root 2634: else
2635: return gen_rtx (PLUS, mode, op0, XEXP (op1, 1));
2636: }
2637: #endif
2638: return gen_rtx (PLUS, mode, op0, op1);
2639:
2640: case MINUS_EXPR:
2641: preexpand_calls (exp);
1.1.1.18! root 2642: if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST
! 2643: && GET_MODE_BITSIZE (TYPE_MODE (type)) <= HOST_BITS_PER_INT)
1.1 root 2644: {
1.1.1.10 root 2645: int negated;
1.1.1.2 root 2646: if (modifier == EXPAND_SUM)
2647: {
2648: negate_1 = -1;
2649: goto plus_minus;
2650: }
2651: subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
2652: op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
1.1.1.10 root 2653: negated = - TREE_INT_CST_LOW (TREE_OPERAND (exp, 1));
2654: if (GET_MODE_BITSIZE (mode) < HOST_BITS_PER_INT)
2655: negated &= (1 << GET_MODE_BITSIZE (mode)) - 1;
2656: op1 = gen_rtx (CONST_INT, VOIDmode, negated);
1.1.1.2 root 2657: this_optab = add_optab;
2658: goto binop2;
1.1 root 2659: }
2660: this_optab = sub_optab;
2661: goto binop;
2662:
2663: case MULT_EXPR:
2664: preexpand_calls (exp);
2665: /* If first operand is constant, swap them.
2666: Thus the following special case checks need only
2667: check the second operand. */
2668: if (TREE_CODE (TREE_OPERAND (exp, 0)) == INTEGER_CST)
2669: {
2670: register tree t1 = TREE_OPERAND (exp, 0);
2671: TREE_OPERAND (exp, 0) = TREE_OPERAND (exp, 1);
2672: TREE_OPERAND (exp, 1) = t1;
2673: }
2674:
2675: /* Attempt to return something suitable for generating an
2676: indexed address, for machines that support that. */
2677:
1.1.1.2 root 2678: if (modifier == EXPAND_SUM
1.1.1.6 root 2679: && TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST)
1.1 root 2680: {
1.1.1.2 root 2681: op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, EXPAND_SUM);
2682:
2683: /* Apply distributive law if OP0 is x+c. */
2684: if (GET_CODE (op0) == PLUS
2685: && GET_CODE (XEXP (op0, 1)) == CONST_INT)
2686: return gen_rtx (PLUS, mode,
2687: gen_rtx (MULT, mode, XEXP (op0, 0),
2688: gen_rtx (CONST_INT, VOIDmode,
2689: TREE_INT_CST_LOW (TREE_OPERAND (exp, 1)))),
2690: gen_rtx (CONST_INT, VOIDmode,
2691: (TREE_INT_CST_LOW (TREE_OPERAND (exp, 1))
2692: * INTVAL (XEXP (op0, 1)))));
2693:
1.1 root 2694: if (GET_CODE (op0) != REG)
1.1.1.2 root 2695: op0 = force_operand (op0, 0);
2696: if (GET_CODE (op0) != REG)
2697: op0 = copy_to_mode_reg (mode, op0);
2698:
1.1.1.6 root 2699: return gen_rtx (MULT, mode, op0,
1.1 root 2700: gen_rtx (CONST_INT, VOIDmode,
2701: TREE_INT_CST_LOW (TREE_OPERAND (exp, 1))));
2702: }
2703: subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
2704: /* Check for multiplying things that have been extended
2705: from a narrower type. If this machine supports multiplying
2706: in that narrower type with a result in the desired type,
2707: do it that way, and avoid the explicit type-conversion. */
2708: if (TREE_CODE (TREE_OPERAND (exp, 0)) == NOP_EXPR
2709: && TREE_CODE (TREE_TYPE (exp)) == INTEGER_TYPE
2710: && (TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))
2711: < TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (exp, 0))))
2712: && ((TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST
2713: && int_fits_type_p (TREE_OPERAND (exp, 1),
1.1.1.2 root 2714: TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))
2715: /* Don't use a widening multiply if a shift will do. */
2716: && exact_log2 (TREE_INT_CST_LOW (TREE_OPERAND (exp, 1))) < 0)
1.1 root 2717: ||
2718: (TREE_CODE (TREE_OPERAND (exp, 1)) == NOP_EXPR
2719: && (TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 1), 0)))
2720: ==
1.1.1.2 root 2721: TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))))
2722: /* If both operands are extended, they must either both
2723: be zero-extended or both be sign-extended. */
2724: && (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 1), 0)))
2725: ==
2726: TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))))))
1.1 root 2727: {
2728: enum machine_mode innermode
2729: = TYPE_MODE (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)));
1.1.1.2 root 2730: this_optab = (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))
1.1 root 2731: ? umul_widen_optab : smul_widen_optab);
1.1.1.17 root 2732: if (mode == GET_MODE_WIDER_MODE (innermode)
1.1.1.2 root 2733: && this_optab->handlers[(int) mode].insn_code != CODE_FOR_nothing)
1.1 root 2734: {
2735: op0 = expand_expr (TREE_OPERAND (TREE_OPERAND (exp, 0), 0),
2736: 0, VOIDmode, 0);
2737: if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST)
2738: op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
2739: else
2740: op1 = expand_expr (TREE_OPERAND (TREE_OPERAND (exp, 1), 0),
2741: 0, VOIDmode, 0);
2742: goto binop2;
2743: }
2744: }
2745: op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
2746: op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
1.1.1.2 root 2747: return expand_mult (mode, op0, op1, target, TREE_UNSIGNED (type));
1.1 root 2748:
2749: case TRUNC_DIV_EXPR:
2750: case FLOOR_DIV_EXPR:
2751: case CEIL_DIV_EXPR:
2752: case ROUND_DIV_EXPR:
1.1.1.17 root 2753: case EXACT_DIV_EXPR:
1.1 root 2754: preexpand_calls (exp);
2755: subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
1.1.1.2 root 2756: /* Possible optimization: compute the dividend with EXPAND_SUM
1.1 root 2757: then if the divisor is constant can optimize the case
2758: where some terms of the dividend have coeffs divisible by it. */
2759: op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
2760: op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
2761: return expand_divmod (0, code, mode, op0, op1, target,
1.1.1.2 root 2762: TREE_UNSIGNED (type));
1.1 root 2763:
2764: case RDIV_EXPR:
2765: preexpand_calls (exp);
2766: this_optab = flodiv_optab;
2767: goto binop;
2768:
2769: case TRUNC_MOD_EXPR:
2770: case FLOOR_MOD_EXPR:
2771: case CEIL_MOD_EXPR:
2772: case ROUND_MOD_EXPR:
2773: preexpand_calls (exp);
2774: subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
2775: op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
2776: op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
2777: return expand_divmod (1, code, mode, op0, op1, target,
1.1.1.2 root 2778: TREE_UNSIGNED (type));
1.1 root 2779: #if 0
2780: #ifdef HAVE_divmoddisi4
2781: if (GET_MODE (op0) != DImode)
2782: {
2783: temp = gen_reg_rtx (DImode);
2784: convert_move (temp, op0, 0);
2785: op0 = temp;
2786: if (GET_MODE (op1) != SImode && GET_CODE (op1) != CONST_INT)
2787: {
2788: temp = gen_reg_rtx (SImode);
2789: convert_move (temp, op1, 0);
2790: op1 = temp;
2791: }
2792: temp = gen_reg_rtx (SImode);
2793: if (target == 0)
2794: target = gen_reg_rtx (SImode);
2795: emit_insn (gen_divmoddisi4 (temp, protect_from_queue (op0, 0),
2796: protect_from_queue (op1, 0),
2797: protect_from_queue (target, 1)));
2798: return target;
2799: }
2800: #endif
2801: #endif
2802:
2803: case FIX_ROUND_EXPR:
2804: case FIX_FLOOR_EXPR:
2805: case FIX_CEIL_EXPR:
2806: abort (); /* Not used for C. */
2807:
2808: case FIX_TRUNC_EXPR:
2809: op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0);
2810: if (target == 0)
2811: target = gen_reg_rtx (mode);
1.1.1.2 root 2812: {
2813: int unsignedp = TREE_UNSIGNED (TREE_TYPE (exp));
2814: if (mode == HImode || mode == QImode)
2815: {
2816: register rtx temp = gen_reg_rtx (SImode);
1.1.1.6 root 2817: expand_fix (temp, op0, 0);
2818: convert_move (target, temp, 0);
1.1.1.2 root 2819: }
2820: else
2821: expand_fix (target, op0, unsignedp);
2822: }
1.1 root 2823: return target;
2824:
2825: case FLOAT_EXPR:
2826: op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0);
2827: if (target == 0)
2828: target = gen_reg_rtx (mode);
1.1.1.18! root 2829: if (GET_MODE (op0) == VOIDmode)
! 2830: /* Avoid problem in convert_move due to unknown mode of OP0. */
! 2831: op0 = copy_to_mode_reg (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))),
! 2832: op0);
1.1.1.2 root 2833: {
2834: int unsignedp = TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0)));
2835: if (GET_MODE (op0) == HImode
2836: || GET_MODE (op0) == QImode)
2837: {
2838: register rtx temp = gen_reg_rtx (SImode);
2839: convert_move (temp, op0, unsignedp);
2840: expand_float (target, temp, 0);
2841: }
2842: else
2843: expand_float (target, op0, unsignedp);
2844: }
1.1 root 2845: return target;
2846:
2847: case NEGATE_EXPR:
2848: op0 = expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode, 0);
2849: temp = expand_unop (mode, neg_optab, op0, target, 0);
2850: if (temp == 0)
2851: abort ();
2852: return temp;
2853:
2854: case ABS_EXPR:
2855: /* First try to do it with a special abs instruction.
2856: If that does not win, use conditional jump and negate. */
1.1.1.2 root 2857: op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
1.1 root 2858: temp = expand_unop (mode, abs_optab, op0, target, 0);
2859: if (temp != 0)
2860: return temp;
2861: temp = gen_label_rtx ();
2862: if (target == 0 || GET_CODE (target) != REG)
1.1.1.2 root 2863: target = gen_reg_rtx (mode);
1.1 root 2864: emit_move_insn (target, op0);
1.1.1.2 root 2865: emit_cmp_insn (target,
2866: expand_expr (convert (TREE_TYPE (exp), integer_zero_node),
2867: 0, VOIDmode, 0),
1.1.1.14 root 2868: 0, 0, 0);
1.1.1.6 root 2869: NO_DEFER_POP;
1.1 root 2870: emit_jump_insn (gen_bge (temp));
2871: op0 = expand_unop (mode, neg_optab, target, target, 0);
2872: if (op0 != target)
2873: emit_move_insn (target, op0);
2874: emit_label (temp);
1.1.1.6 root 2875: OK_DEFER_POP;
1.1 root 2876: return target;
2877:
2878: case MAX_EXPR:
2879: case MIN_EXPR:
1.1.1.8 root 2880: mode = TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 1)));
1.1 root 2881: op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
2882: if (target == 0 || GET_CODE (target) != REG || target == op1)
1.1.1.2 root 2883: target = gen_reg_rtx (mode);
1.1 root 2884: op0 = expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode, 0);
2885: if (target != op0)
2886: emit_move_insn (target, op0);
2887: op0 = gen_label_rtx ();
2888: if (code == MAX_EXPR)
1.1.1.2 root 2889: temp = (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 1)))
2890: ? compare1 (target, op1, GEU, LEU, 1, mode)
2891: : compare1 (target, op1, GE, LE, 0, mode));
2892: else
2893: temp = (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 1)))
2894: ? compare1 (target, op1, LEU, GEU, 1, mode)
2895: : compare1 (target, op1, LE, GE, 0, mode));
2896: if (temp == const0_rtx)
2897: emit_move_insn (target, op1);
2898: else if (temp != const1_rtx)
2899: {
1.1.1.13 root 2900: if (bcc_gen_fctn[(int) GET_CODE (temp)] != 0)
2901: emit_jump_insn ((*bcc_gen_fctn[(int) GET_CODE (temp)]) (op0));
2902: else
2903: abort ();
1.1.1.2 root 2904: emit_move_insn (target, op1);
2905: }
2906: emit_label (op0);
1.1 root 2907: return target;
2908:
2909: /* ??? Can optimize when the operand of this is a bitwise operation,
2910: by using a different bitwise operation. */
2911: case BIT_NOT_EXPR:
2912: op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
2913: temp = expand_unop (mode, one_cmpl_optab, op0, target, 1);
2914: if (temp == 0)
2915: abort ();
2916: return temp;
2917:
1.1.1.2 root 2918: case FFS_EXPR:
2919: op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
2920: temp = expand_unop (mode, ffs_optab, op0, target, 1);
2921: if (temp == 0)
2922: abort ();
2923: return temp;
2924:
1.1 root 2925: /* ??? Can optimize bitwise operations with one arg constant.
2926: Pastel optimizes (a bitwise1 n) bitwise2 (a bitwise3 b)
2927: and (a bitwise1 b) bitwise2 b (etc)
2928: but that is probably not worth while. */
2929:
1.1.1.2 root 2930: /* BIT_AND_EXPR is for bitwise anding.
1.1 root 2931: TRUTH_AND_EXPR is for anding two boolean values
2932: when we want in all cases to compute both of them.
2933: In general it is fastest to do TRUTH_AND_EXPR by
2934: computing both operands as actual zero-or-1 values
2935: and then bitwise anding. In cases where there cannot
2936: be any side effects, better code would be made by
2937: treating TRUTH_AND_EXPR like TRUTH_ANDIF_EXPR;
2938: but the question is how to recognize those cases. */
2939:
2940: case TRUTH_AND_EXPR:
2941: case BIT_AND_EXPR:
2942: preexpand_calls (exp);
2943: subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
2944: op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
2945: op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
2946: return expand_bit_and (mode, op0, op1, target);
2947:
2948: /* See comment above about TRUTH_AND_EXPR; it applies here too. */
2949: case TRUTH_OR_EXPR:
2950: case BIT_IOR_EXPR:
2951: preexpand_calls (exp);
2952: this_optab = ior_optab;
2953: goto binop;
2954:
2955: case BIT_XOR_EXPR:
2956: preexpand_calls (exp);
2957: this_optab = xor_optab;
2958: goto binop;
2959:
2960: case LSHIFT_EXPR:
2961: case RSHIFT_EXPR:
2962: case LROTATE_EXPR:
2963: case RROTATE_EXPR:
2964: preexpand_calls (exp);
2965: subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
2966: op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
2967: return expand_shift (code, mode, op0, TREE_OPERAND (exp, 1), target,
1.1.1.2 root 2968: TREE_UNSIGNED (type));
1.1 root 2969:
2970: /* ??? cv's were used to effect here to combine additive constants
2971: and to determine the answer when only additive constants differ.
2972: Also, the addition of one can be handled by changing the condition. */
2973: case LT_EXPR:
2974: case LE_EXPR:
2975: case GT_EXPR:
2976: case GE_EXPR:
2977: case EQ_EXPR:
2978: case NE_EXPR:
2979: preexpand_calls (exp);
1.1.1.2 root 2980: temp = do_store_flag (exp, target, mode);
1.1 root 2981: if (temp != 0)
2982: return temp;
1.1.1.2 root 2983: /* For foo != 0, load foo, and if it is nonzero load 1 instead. */
2984: if (code == NE_EXPR && integer_zerop (TREE_OPERAND (exp, 1))
2985: && subtarget
2986: && (GET_MODE (subtarget)
2987: == TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))))
1.1 root 2988: {
2989: temp = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
2990: if (temp != subtarget)
2991: temp = copy_to_reg (temp);
2992: op1 = gen_label_rtx ();
1.1.1.14 root 2993: emit_cmp_insn (temp, const0_rtx, 0, TREE_UNSIGNED (type), 0);
1.1 root 2994: emit_jump_insn (gen_beq (op1));
2995: emit_move_insn (temp, const1_rtx);
2996: emit_label (op1);
2997: return temp;
2998: }
2999: /* If no set-flag instruction, must generate a conditional
3000: store into a temporary variable. Drop through
3001: and handle this like && and ||. */
3002:
3003: case TRUTH_ANDIF_EXPR:
3004: case TRUTH_ORIF_EXPR:
3005: temp = gen_reg_rtx (mode);
3006: emit_clr_insn (temp);
3007: op1 = gen_label_rtx ();
3008: jumpifnot (exp, op1);
3009: emit_0_to_1_insn (temp);
3010: emit_label (op1);
3011: return temp;
3012:
3013: case TRUTH_NOT_EXPR:
3014: op0 = expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode, 0);
3015: /* The parser is careful to generate TRUTH_NOT_EXPR
3016: only with operands that are always zero or one. */
3017: temp = expand_binop (mode, xor_optab, op0,
3018: gen_rtx (CONST_INT, mode, 1),
3019: target, 1, OPTAB_LIB_WIDEN);
3020: if (temp == 0)
3021: abort ();
3022: return temp;
3023:
3024: case COMPOUND_EXPR:
1.1.1.2 root 3025: expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0);
1.1 root 3026: emit_queue ();
3027: return expand_expr (TREE_OPERAND (exp, 1), target, VOIDmode, 0);
3028:
3029: case COND_EXPR:
3030: /* Note that COND_EXPRs whose type is a structure or union
3031: are required to be constructed to contain assignments of
3032: a temporary variable, so that we can evaluate them here
3033: for side effect only. If type is void, we must do likewise. */
3034: op0 = gen_label_rtx ();
3035: op1 = gen_label_rtx ();
3036:
1.1.1.2 root 3037: if (mode == VOIDmode || ignore)
1.1 root 3038: temp = 0;
3039: else if (target)
3040: temp = target;
1.1.1.2 root 3041: else if (mode == BLKmode)
3042: {
3043: if (TYPE_SIZE (type) == 0 || ! TREE_LITERAL (TYPE_SIZE (type)))
3044: abort ();
3045: temp = assign_stack_local (BLKmode,
3046: (TREE_INT_CST_LOW (TYPE_SIZE (type))
3047: * TYPE_SIZE_UNIT (type)
3048: + BITS_PER_UNIT - 1)
3049: / BITS_PER_UNIT);
3050: }
1.1 root 3051: else
3052: temp = gen_reg_rtx (mode);
3053:
3054: jumpifnot (TREE_OPERAND (exp, 0), op0);
1.1.1.6 root 3055: NO_DEFER_POP;
1.1 root 3056: if (temp != 0)
1.1.1.2 root 3057: store_expr (TREE_OPERAND (exp, 1), temp, 0);
1.1 root 3058: else
1.1.1.2 root 3059: expand_expr (TREE_OPERAND (exp, 1), ignore ? const0_rtx : 0,
3060: VOIDmode, 0);
1.1 root 3061: emit_queue ();
3062: emit_jump_insn (gen_jump (op1));
3063: emit_barrier ();
3064: emit_label (op0);
3065: if (temp != 0)
1.1.1.2 root 3066: store_expr (TREE_OPERAND (exp, 2), temp, 0);
1.1 root 3067: else
1.1.1.2 root 3068: expand_expr (TREE_OPERAND (exp, 2), ignore ? const0_rtx : 0,
3069: VOIDmode, 0);
1.1 root 3070: emit_queue ();
3071: emit_label (op1);
1.1.1.6 root 3072: OK_DEFER_POP;
1.1 root 3073: return temp;
3074:
3075: case MODIFY_EXPR:
1.1.1.7 root 3076: {
3077: /* If lhs is complex, expand calls in rhs before computing it.
3078: That's so we don't compute a pointer and save it over a call.
3079: If lhs is simple, compute it first so we can give it as a
3080: target if the rhs is just a call. This avoids an extra temp and copy
3081: and that prevents a partial-subsumption which makes bad code.
3082: Actually we could treat component_ref's of vars like vars. */
3083:
3084: tree lhs = TREE_OPERAND (exp, 0);
3085: tree rhs = TREE_OPERAND (exp, 1);
1.1.1.13 root 3086: tree noncopied_parts;
1.1.1.7 root 3087:
3088: if (TREE_CODE (lhs) != VAR_DECL
3089: && TREE_CODE (lhs) != RESULT_DECL
3090: && TREE_CODE (lhs) != PARM_DECL)
3091: preexpand_calls (exp);
3092:
1.1.1.13 root 3093: noncopied_parts = save_noncopied_parts (lhs, TYPE_NONCOPIED_PARTS (TREE_TYPE (lhs)));
3094: temp = expand_assignment (lhs, rhs, ! ignore, original_target != 0);
3095: while (noncopied_parts != 0)
1.1.1.7 root 3096: {
1.1.1.13 root 3097: store_expr (TREE_VALUE (noncopied_parts),
3098: SAVE_EXPR_RTL (TREE_PURPOSE (noncopied_parts)), 0);
3099: noncopied_parts = TREE_CHAIN (noncopied_parts);
1.1.1.7 root 3100: }
1.1.1.13 root 3101: return temp;
3102: }
1.1 root 3103:
3104: case PREINCREMENT_EXPR:
3105: case PREDECREMENT_EXPR:
1.1.1.2 root 3106: return expand_increment (exp, 0);
1.1 root 3107:
3108: case POSTINCREMENT_EXPR:
3109: case POSTDECREMENT_EXPR:
1.1.1.2 root 3110: return expand_increment (exp, 1);
1.1 root 3111:
3112: case ADDR_EXPR:
1.1.1.2 root 3113: op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode,
3114: EXPAND_CONST_ADDRESS);
1.1 root 3115: if (GET_CODE (op0) != MEM)
3116: abort ();
1.1.1.2 root 3117: if (modifier == EXPAND_SUM)
1.1 root 3118: return XEXP (op0, 0);
1.1.1.2 root 3119: op0 = force_operand (XEXP (op0, 0), target);
3120: if (flag_force_addr && GET_CODE (op0) != REG)
3121: return force_reg (Pmode, op0);
3122: return op0;
1.1 root 3123:
3124: case ENTRY_VALUE_EXPR:
3125: abort ();
3126:
3127: case ERROR_MARK:
1.1.1.2 root 3128: return const0_rtx;
1.1 root 3129:
3130: default:
3131: abort ();
3132: }
3133:
3134: /* Here to do an ordinary binary operator, generating an instruction
3135: from the optab already placed in `this_optab'. */
3136: binop:
3137: /* Detect things like x = y | (a == b)
3138: and do them as (x = y), (a == b ? x |= 1 : 0), x. */
3139: /* First, get the comparison or conditional into the second arg. */
3140: if (comparison_code[(int) TREE_CODE (TREE_OPERAND (exp, 0))]
3141: || (TREE_CODE (TREE_OPERAND (exp, 0)) == COND_EXPR
3142: && (integer_zerop (TREE_OPERAND (TREE_OPERAND (exp, 0), 1))
3143: || integer_zerop (TREE_OPERAND (TREE_OPERAND (exp, 0), 2)))))
3144: {
3145: if (this_optab == ior_optab || this_optab == add_optab
3146: || this_optab == xor_optab)
3147: {
3148: tree exch = TREE_OPERAND (exp, 1);
3149: TREE_OPERAND (exp, 1) = TREE_OPERAND (exp, 0);
3150: TREE_OPERAND (exp, 0) = exch;
3151: }
3152: }
1.1.1.3 root 3153: /* Optimize X + (Y ? Z : 0) by computing X and maybe adding Z. */
1.1 root 3154: if (comparison_code[(int) TREE_CODE (TREE_OPERAND (exp, 1))]
3155: || (TREE_CODE (TREE_OPERAND (exp, 1)) == COND_EXPR
3156: && (integer_zerop (TREE_OPERAND (TREE_OPERAND (exp, 1), 1))
3157: || integer_zerop (TREE_OPERAND (TREE_OPERAND (exp, 1), 2)))))
3158: {
3159: if (this_optab == ior_optab || this_optab == add_optab
3160: || this_optab == xor_optab || this_optab == sub_optab
3161: || this_optab == lshl_optab || this_optab == ashl_optab
3162: || this_optab == lshr_optab || this_optab == ashr_optab
3163: || this_optab == rotl_optab || this_optab == rotr_optab)
3164: {
1.1.1.2 root 3165: tree thenexp;
1.1 root 3166: rtx thenv = 0;
3167:
1.1.1.8 root 3168: /* TARGET gets a reg in which we can perform the computation.
3169: Use the specified target if it's a pseudo reg and safe. */
3170: target = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
1.1 root 3171: if (target == 0) target = gen_reg_rtx (mode);
1.1.1.3 root 3172:
3173: /* Compute X into the target. */
1.1.1.2 root 3174: store_expr (TREE_OPERAND (exp, 0), target, 0);
1.1 root 3175: op0 = gen_label_rtx ();
3176:
1.1.1.3 root 3177: /* If other operand is a comparison COMP, treat it as COMP ? 1 : 0 */
1.1 root 3178: if (TREE_CODE (TREE_OPERAND (exp, 1)) != COND_EXPR)
3179: {
3180: do_jump (TREE_OPERAND (exp, 1), op0, 0);
3181: thenv = const1_rtx;
3182: }
3183: else if (integer_zerop (TREE_OPERAND (TREE_OPERAND (exp, 1), 2)))
3184: {
3185: do_jump (TREE_OPERAND (TREE_OPERAND (exp, 1), 0), op0, 0);
3186: thenexp = TREE_OPERAND (TREE_OPERAND (exp, 1), 1);
3187: }
3188: else
3189: {
3190: do_jump (TREE_OPERAND (TREE_OPERAND (exp, 1), 0), 0, op0);
3191: thenexp = TREE_OPERAND (TREE_OPERAND (exp, 1), 2);
3192: }
3193:
3194: if (thenv == 0)
3195: thenv = expand_expr (thenexp, 0, VOIDmode, 0);
3196:
1.1.1.3 root 3197: /* THENV is now Z, the value to operate on, as an rtx.
3198: We have already tested that Y isn't zero, so do the operation. */
3199:
1.1 root 3200: if (this_optab == rotl_optab || this_optab == rotr_optab)
3201: temp = expand_binop (mode, this_optab, target, thenv, target,
3202: -1, OPTAB_LIB);
3203: else if (this_optab == lshl_optab || this_optab == lshr_optab)
3204: temp = expand_binop (mode, this_optab, target, thenv, target,
3205: 1, OPTAB_LIB_WIDEN);
3206: else
3207: temp = expand_binop (mode, this_optab, target, thenv, target,
3208: 0, OPTAB_LIB_WIDEN);
3209: if (target != temp)
3210: emit_move_insn (target, temp);
3211:
1.1.1.17 root 3212: emit_queue ();
1.1.1.6 root 3213: do_pending_stack_adjust ();
1.1 root 3214: emit_label (op0);
3215: return target;
3216: }
3217: }
3218: subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
3219: op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
3220: op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
3221: binop2:
3222: temp = expand_binop (mode, this_optab, op0, op1, target,
1.1.1.2 root 3223: TREE_UNSIGNED (TREE_TYPE (exp)), OPTAB_LIB_WIDEN);
1.1 root 3224: if (temp == 0)
3225: abort ();
3226: return temp;
3227: }
3228:
1.1.1.2 root 3229: /* Expand an expression EXP that calls a built-in function,
3230: with result going to TARGET if that's convenient
3231: (and in mode MODE if that's convenient).
1.1.1.17 root 3232: SUBTARGET may be used as the target for computing one of EXP's operands.
3233: IGNORE is nonzero if the value is to be ignored. */
1.1.1.2 root 3234:
3235: static rtx
1.1.1.17 root 3236: expand_builtin (exp, target, subtarget, mode, ignore)
1.1.1.2 root 3237: tree exp;
3238: rtx target;
3239: rtx subtarget;
3240: enum machine_mode mode;
1.1.1.17 root 3241: int ignore;
1.1.1.2 root 3242: {
3243: tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
3244: tree arglist = TREE_OPERAND (exp, 1);
3245: rtx op0;
3246:
3247: switch (DECL_FUNCTION_CODE (fndecl))
3248: {
3249: case BUILT_IN_ABS:
3250: case BUILT_IN_LABS:
3251: case BUILT_IN_FABS:
3252: /* build_function_call changes these into ABS_EXPR. */
3253: abort ();
3254:
1.1.1.14 root 3255: case BUILT_IN_SAVEREGS:
3256: {
3257: /* When this function is called, it means that registers must be
3258: saved on entry to this function. So we migrate the
3259: call to the first insn of this function. */
3260: rtx last = get_last_insn ();
3261: /* Now really call the function. `expand_call' does not call
3262: expand_builtin, so there is no danger of infinite recursion here. */
1.1.1.17 root 3263: rtx temp = expand_call (exp, target, ignore);
3264: reorder_insns (NEXT_INSN (last), get_last_insn (), get_insns ());
3265: return temp;
1.1.1.14 root 3266: }
1.1.1.17 root 3267:
3268: case BUILT_IN_CLASSIFY_TYPE:
3269: if (arglist != 0)
3270: {
3271: tree type = TREE_TYPE (TREE_VALUE (arglist));
3272: enum tree_code code = TREE_CODE (type);
3273: if (code == VOID_TYPE)
3274: return gen_rtx (CONST_INT, VOIDmode, void_type_class);
3275: if (code == INTEGER_TYPE)
3276: return gen_rtx (CONST_INT, VOIDmode, integer_type_class);
3277: if (code == CHAR_TYPE)
3278: return gen_rtx (CONST_INT, VOIDmode, char_type_class);
3279: if (code == ENUMERAL_TYPE)
3280: return gen_rtx (CONST_INT, VOIDmode, enumeral_type_class);
3281: if (code == BOOLEAN_TYPE)
3282: return gen_rtx (CONST_INT, VOIDmode, boolean_type_class);
3283: if (code == POINTER_TYPE)
3284: return gen_rtx (CONST_INT, VOIDmode, pointer_type_class);
3285: if (code == REFERENCE_TYPE)
3286: return gen_rtx (CONST_INT, VOIDmode, reference_type_class);
3287: if (code == OFFSET_TYPE)
3288: return gen_rtx (CONST_INT, VOIDmode, offset_type_class);
3289: if (code == REAL_TYPE)
3290: return gen_rtx (CONST_INT, VOIDmode, real_type_class);
3291: if (code == COMPLEX_TYPE)
3292: return gen_rtx (CONST_INT, VOIDmode, complex_type_class);
3293: if (code == FUNCTION_TYPE)
3294: return gen_rtx (CONST_INT, VOIDmode, function_type_class);
3295: if (code == METHOD_TYPE)
3296: return gen_rtx (CONST_INT, VOIDmode, method_type_class);
3297: if (code == RECORD_TYPE)
3298: return gen_rtx (CONST_INT, VOIDmode, record_type_class);
3299: if (code == UNION_TYPE)
3300: return gen_rtx (CONST_INT, VOIDmode, union_type_class);
3301: if (code == ARRAY_TYPE)
3302: return gen_rtx (CONST_INT, VOIDmode, array_type_class);
3303: if (code == STRING_TYPE)
3304: return gen_rtx (CONST_INT, VOIDmode, string_type_class);
3305: if (code == SET_TYPE)
3306: return gen_rtx (CONST_INT, VOIDmode, set_type_class);
3307: if (code == FILE_TYPE)
3308: return gen_rtx (CONST_INT, VOIDmode, file_type_class);
3309: if (code == LANG_TYPE)
3310: return gen_rtx (CONST_INT, VOIDmode, lang_type_class);
3311: }
3312: return gen_rtx (CONST_INT, VOIDmode, no_type_class);
3313:
1.1.1.2 root 3314: case BUILT_IN_ALLOCA:
1.1.1.10 root 3315: if (arglist == 0
3316: /* Arg could be non-integer if user redeclared this fcn wrong. */
3317: || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != INTEGER_TYPE)
1.1.1.2 root 3318: return const0_rtx;
3319: frame_pointer_needed = 1;
1.1.1.17 root 3320: current_function_calls_alloca = 1;
1.1.1.2 root 3321: /* Compute the argument. */
3322: op0 = expand_expr (TREE_VALUE (arglist), 0, VOIDmode, 0);
3323: if (! CONSTANT_P (op0))
3324: {
3325: op0 = force_reg (GET_MODE (op0), op0);
3326: if (GET_MODE (op0) != Pmode)
1.1.1.12 root 3327: op0 = convert_to_mode (Pmode, op0, 1);
1.1.1.2 root 3328: }
3329: /* Push that much space (rounding it up). */
1.1.1.3 root 3330: do_pending_stack_adjust ();
1.1.1.8 root 3331:
3332: #ifdef STACK_POINTER_OFFSET
1.1.1.9 root 3333: /* If we will have to round the result down (which is up
3334: if stack grows down), make sure we have extra space so the
3335: user still gets at least as much space as he asked for. */
1.1.1.8 root 3336: if ((STACK_POINTER_OFFSET + STACK_BYTES - 1) / STACK_BYTES
3337: != STACK_POINTER_OFFSET / STACK_BYTES)
3338: op0 = plus_constant (op0, STACK_BYTES);
3339: #endif
3340:
1.1.1.4 root 3341: #ifdef STACK_GROWS_DOWNWARD
1.1.1.2 root 3342: anti_adjust_stack (round_push (op0));
1.1.1.4 root 3343: #endif
1.1.1.2 root 3344: /* Return a copy of current stack ptr, in TARGET if possible. */
3345: if (target)
3346: emit_move_insn (target, stack_pointer_rtx);
3347: else
3348: target = copy_to_reg (stack_pointer_rtx);
1.1.1.4 root 3349: #ifdef STACK_POINTER_OFFSET
3350: /* If the contents of the stack pointer reg are offset from the
3351: actual top-of-stack address, add the offset here. */
1.1.1.6 root 3352: if (GET_CODE (target) == REG)
1.1.1.8 root 3353: emit_insn (gen_add2_insn (target,
3354: gen_rtx (CONST_INT, VOIDmode,
3355: (STACK_POINTER_OFFSET + STACK_BYTES - 1) / STACK_BYTES * STACK_BYTES)));
1.1.1.6 root 3356: else
3357: {
3358: rtx temp =
3359: expand_binop (GET_MODE (target), add_optab, target,
1.1.1.8 root 3360: gen_rtx (CONST_INT, VOIDmode,
3361: (STACK_POINTER_OFFSET + STACK_BYTES - 1) / STACK_BYTES * STACK_BYTES),
1.1.1.6 root 3362: target,
3363: 1, OPTAB_DIRECT);
3364: if (temp == 0) abort ();
3365: if (temp != target)
3366: emit_move_insn (target, temp);
3367: }
1.1.1.4 root 3368: #endif
3369: #ifndef STACK_GROWS_DOWNWARD
3370: anti_adjust_stack (round_push (op0));
3371: #endif
1.1.1.17 root 3372: /* Some systems require a particular insn to refer to the stack
3373: to make the pages exist. */
3374: #ifdef HAVE_probe
3375: if (HAVE_probe)
3376: emit_insn (gen_probe ());
3377: #endif
1.1.1.2 root 3378: return target;
3379:
3380: case BUILT_IN_FFS:
1.1.1.10 root 3381: if (arglist == 0
3382: /* Arg could be non-integer if user redeclared this fcn wrong. */
3383: || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != INTEGER_TYPE)
1.1.1.2 root 3384: return const0_rtx;
3385:
3386: /* Compute the argument. */
3387: op0 = expand_expr (TREE_VALUE (arglist), subtarget, VOIDmode, 0);
3388: /* Compute ffs, into TARGET if possible.
3389: Set TARGET to wherever the result comes back. */
3390: target = expand_unop (mode, ffs_optab, op0, target, 1);
3391: if (target == 0)
3392: abort ();
3393: return target;
3394:
3395: default:
3396: abort ();
3397: }
3398: }
3399:
3400: /* Expand code for a post- or pre- increment or decrement
3401: and return the RTX for the result.
3402: POST is 1 for postinc/decrements and 0 for preinc/decrements. */
3403:
3404: static rtx
3405: expand_increment (exp, post)
3406: register tree exp;
3407: int post;
3408: {
3409: register rtx op0, op1;
3410: register rtx temp;
3411: register tree incremented = TREE_OPERAND (exp, 0);
3412: optab this_optab = add_optab;
3413: int icode;
3414: enum machine_mode mode = TYPE_MODE (TREE_TYPE (exp));
3415: int op0_is_copy = 0;
3416:
3417: /* Stabilize any component ref that might need to be
3418: evaluated more than once below. */
3419: if (TREE_CODE (incremented) == COMPONENT_REF
3420: && (TREE_CODE (TREE_OPERAND (incremented, 0)) != INDIRECT_REF
1.1.1.17 root 3421: || DECL_MODE (TREE_OPERAND (incremented, 1)) == BImode))
1.1.1.2 root 3422: incremented = stabilize_reference (incremented);
3423:
3424: /* Compute the operands as RTX.
3425: Note whether OP0 is the actual lvalue or a copy of it:
3426: I believe it is a copy iff it is a register and insns were
3427: generated in computing it. */
3428: temp = get_last_insn ();
3429: op0 = expand_expr (incremented, 0, VOIDmode, 0);
3430: if (temp != get_last_insn ())
3431: op0_is_copy = (GET_CODE (op0) == REG || GET_CODE (op0) == SUBREG);
3432: op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
3433:
3434: /* Decide whether incrementing or decrementing. */
3435: if (TREE_CODE (exp) == POSTDECREMENT_EXPR
3436: || TREE_CODE (exp) == PREDECREMENT_EXPR)
3437: this_optab = sub_optab;
3438:
3439: /* If OP0 is not the actual lvalue, but rather a copy in a register,
3440: then we cannot just increment OP0. We must
3441: therefore contrive to increment the original value.
3442: Then we can return OP0 since it is a copy of the old value. */
3443: if (op0_is_copy)
3444: {
3445: /* This is the easiest way to increment the value wherever it is.
3446: Problems with multiple evaluation of INCREMENTED
3447: are prevented because either (1) it is a component_ref,
3448: in which case it was stabilized above, or (2) it is an array_ref
3449: with constant index in an array in a register, which is
3450: safe to reevaluate. */
3451: tree newexp = build ((this_optab == add_optab
3452: ? PLUS_EXPR : MINUS_EXPR),
3453: TREE_TYPE (exp),
3454: incremented,
3455: TREE_OPERAND (exp, 1));
3456: temp = expand_assignment (incremented, newexp, ! post, 0);
3457: return post ? op0 : temp;
3458: }
3459:
3460: /* Convert decrement by a constant into a negative increment. */
3461: if (this_optab == sub_optab
3462: && GET_CODE (op1) == CONST_INT)
3463: {
3464: op1 = gen_rtx (CONST_INT, VOIDmode, - INTVAL (op1));
3465: this_optab = add_optab;
3466: }
3467:
3468: if (post)
3469: {
3470: /* We have a true reference to the value in OP0.
3471: If there is an insn to add or subtract in this mode, queue it. */
3472:
3473: /* I'm not sure this is still necessary. */
3474: op0 = stabilize (op0);
3475:
3476: icode = (int) this_optab->handlers[(int) mode].insn_code;
3477: if (icode != (int) CODE_FOR_nothing
3478: /* Make sure that OP0 is valid for operands 0 and 1
3479: of the insn we want to queue. */
3480: && (*insn_operand_predicate[icode][0]) (op0, mode)
3481: && (*insn_operand_predicate[icode][1]) (op0, mode))
3482: {
3483: if (! (*insn_operand_predicate[icode][2]) (op1, mode))
3484: op1 = force_reg (mode, op1);
3485:
3486: return enqueue_insn (op0, GEN_FCN (icode) (op0, op0, op1));
3487: }
3488: }
3489:
3490: /* Preincrement, or we can't increment with one simple insn. */
3491: if (post)
3492: /* Save a copy of the value before inc or dec, to return it later. */
3493: temp = copy_to_reg (op0);
3494: else
3495: /* Arrange to return the incremented value. */
1.1.1.18! root 3496: /* Copy the rtx because expand_binop will protect from the queue,
! 3497: and the results of that would be invalid for us to return
! 3498: if our caller does emit_queue before using our result. */
! 3499: temp = copy_rtx (op0);
1.1.1.2 root 3500:
3501: /* Increment however we can. */
3502: op1 = expand_binop (mode, this_optab, op0, op1, op0,
1.1.1.17 root 3503: TREE_UNSIGNED (TREE_TYPE (exp)), OPTAB_LIB_WIDEN);
1.1.1.2 root 3504: /* Make sure the value is stored into OP0. */
3505: if (op1 != op0)
3506: emit_move_insn (op0, op1);
3507:
3508: return temp;
3509: }
3510:
1.1 root 3511: /* Expand all function calls contained within EXP, innermost ones first.
3512: But don't look within expressions that have sequence points.
3513: For each CALL_EXPR, record the rtx for its value
1.1.1.2 root 3514: in the CALL_EXPR_RTL field.
3515:
3516: Calls that return large structures for which a structure return
3517: stack slot is needed are not preexpanded. Preexpanding them loses
3518: because if more than one were preexpanded they would try to use the
3519: same stack slot. */
1.1 root 3520:
3521: static void
3522: preexpand_calls (exp)
3523: tree exp;
3524: {
3525: register int nops, i;
3526:
3527: if (! do_preexpand_calls)
3528: return;
3529:
1.1.1.2 root 3530: /* Only expressions and references can contain calls. */
3531:
3532: if (tree_code_type[(int) TREE_CODE (exp)][0] != 'e'
3533: && tree_code_type[(int) TREE_CODE (exp)][0] != 'r')
3534: return;
3535:
1.1 root 3536: switch (TREE_CODE (exp))
3537: {
3538: case CALL_EXPR:
1.1.1.2 root 3539: /* Do nothing to built-in functions. */
3540: if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR
3541: && TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) == FUNCTION_DECL
1.1.1.5 root 3542: && (DECL_FUNCTION_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))
3543: != NOT_BUILT_IN))
1.1.1.2 root 3544: return;
1.1.1.16 root 3545: /* Precompute calls that don't return values in memory. */
1.1.1.2 root 3546: if (CALL_EXPR_RTL (exp) == 0
1.1.1.16 root 3547: && TYPE_MODE (TREE_TYPE (exp)) != BLKmode
3548: && ! RETURN_IN_MEMORY (TREE_TYPE (exp)))
1.1.1.2 root 3549: CALL_EXPR_RTL (exp) = expand_call (exp, 0, 0);
1.1 root 3550: return;
3551:
3552: case COMPOUND_EXPR:
3553: case COND_EXPR:
3554: case TRUTH_ANDIF_EXPR:
3555: case TRUTH_ORIF_EXPR:
3556: /* If we find one of these, then we can be sure
3557: the adjust will be done for it (since it makes jumps).
3558: Do it now, so that if this is inside an argument
3559: of a function, we don't get the stack adjustment
3560: after some other args have already been pushed. */
3561: do_pending_stack_adjust ();
3562: return;
3563:
1.1.1.2 root 3564: case RTL_EXPR:
3565: return;
3566:
1.1 root 3567: case SAVE_EXPR:
3568: if (SAVE_EXPR_RTL (exp) != 0)
3569: return;
3570: }
3571:
3572: nops = tree_code_length[(int) TREE_CODE (exp)];
3573: for (i = 0; i < nops; i++)
3574: if (TREE_OPERAND (exp, i) != 0)
3575: {
3576: register int type = *tree_code_type[(int) TREE_CODE (TREE_OPERAND (exp, i))];
3577: if (type == 'e' || type == 'r')
3578: preexpand_calls (TREE_OPERAND (exp, i));
3579: }
3580: }
3581:
1.1.1.2 root 3582: /* Force FUNEXP into a form suitable for the address of a CALL,
3583: and return that as an rtx. Also load the static chain register
3584: from either FUNEXP or CONTEXT. */
1.1 root 3585:
1.1.1.2 root 3586: static rtx
3587: prepare_call_address (funexp, context)
1.1 root 3588: rtx funexp;
3589: rtx context;
3590: {
3591: funexp = protect_from_queue (funexp, 0);
1.1.1.2 root 3592: if (context != 0)
1.1 root 3593: context = protect_from_queue (context, 0);
3594:
3595: /* Function variable in language with nested functions. */
3596: if (GET_MODE (funexp) == EPmode)
3597: {
1.1.1.2 root 3598: emit_move_insn (static_chain_rtx, gen_highpart (Pmode, funexp));
3599: funexp = memory_address (FUNCTION_MODE, gen_lowpart (Pmode, funexp));
3600: emit_insn (gen_rtx (USE, VOIDmode, static_chain_rtx));
1.1 root 3601: }
3602: else
3603: {
3604: if (context != 0)
1.1.1.2 root 3605: /* Unless function variable in C, or top level function constant */
3606: emit_move_insn (static_chain_rtx, lookup_static_chain (context));
3607:
3608: /* Make a valid memory address and copy constants thru pseudo-regs,
3609: but not for a constant address if -fno-function-cse. */
3610: if (GET_CODE (funexp) != SYMBOL_REF)
3611: funexp = memory_address (FUNCTION_MODE, funexp);
3612: else
1.1 root 3613: {
1.1.1.2 root 3614: #ifndef NO_FUNCTION_CSE
1.1.1.6 root 3615: if (optimize && ! flag_no_function_cse)
3616: funexp = force_reg (Pmode, funexp);
1.1.1.2 root 3617: #endif
3618: }
3619:
3620: if (context != 0)
3621: emit_insn (gen_rtx (USE, VOIDmode, static_chain_rtx));
1.1 root 3622: }
1.1.1.2 root 3623: return funexp;
3624: }
3625:
3626: /* Generate instructions to call function FUNEXP,
3627: and optionally pop the results.
3628: The CALL_INSN is the first insn generated.
3629:
3630: FUNTYPE is the data type of the function, or, for a library call,
3631: the identifier for the name of the call. This is given to the
3632: macro RETURN_POPS_ARGS to determine whether this function pops its own args.
3633:
1.1.1.6 root 3634: STACK_SIZE is the number of bytes of arguments on the stack,
1.1.1.2 root 3635: rounded up to STACK_BOUNDARY; zero if the size is variable.
3636: This is both to put into the call insn and
3637: to generate explicit popping code if necessary.
3638:
3639: NEXT_ARG_REG is the rtx that results from executing
3640: FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1)
3641: just after all the args have had their registers assigned.
3642: This could be whatever you like, but normally it is the first
3643: arg-register beyond those used for args in this call,
3644: or 0 if all the arg-registers are used in this call.
3645: It is passed on to `gen_call' so you can put this info in the call insn.
3646:
3647: VALREG is a hard register in which a value is returned,
3648: or 0 if the call does not return a value.
3649:
1.1.1.17 root 3650: OLD_INHIBIT_DEFER_POP is the value that `inhibit_defer_pop' had before
1.1.1.2 root 3651: the args to this call were processed.
1.1.1.18! root 3652: We restore `inhibit_defer_pop' to that value.
! 3653:
! 3654: USE_INSNS is a SEQUENCE of USE insns to be emitted immediately before
! 3655: the actual CALL insn. */
1.1.1.2 root 3656:
3657: static void
1.1.1.18! root 3658: emit_call_1 (funexp, funtype, stack_size, next_arg_reg, valreg, old_inhibit_defer_pop, use_insns)
1.1.1.2 root 3659: rtx funexp;
3660: tree funtype;
3661: int stack_size;
3662: rtx next_arg_reg;
3663: rtx valreg;
1.1.1.17 root 3664: int old_inhibit_defer_pop;
1.1.1.18! root 3665: rtx use_insns;
1.1.1.2 root 3666: {
3667: rtx stack_size_rtx = gen_rtx (CONST_INT, VOIDmode, stack_size);
1.1.1.18! root 3668: rtx call_insn;
1.1.1.2 root 3669:
3670: if (valreg)
3671: emit_call_insn (gen_call_value (valreg,
3672: gen_rtx (MEM, FUNCTION_MODE, funexp),
3673: stack_size_rtx, next_arg_reg));
3674: else
3675: emit_call_insn (gen_call (gen_rtx (MEM, FUNCTION_MODE, funexp),
3676: stack_size_rtx, next_arg_reg));
3677:
1.1.1.18! root 3678: /* Find the CALL insn we just emitted and write the USE insns before it. */
! 3679: for (call_insn = get_last_insn();
! 3680: call_insn && GET_CODE (call_insn) != CALL_INSN;
! 3681: call_insn = PREV_INSN (call_insn))
! 3682: ;
! 3683:
! 3684: if (! call_insn)
! 3685: abort ();
! 3686:
! 3687: /* Put the USE insns before the CALL. */
! 3688: emit_insn_before (use_insns, call_insn);
! 3689:
1.1.1.17 root 3690: inhibit_defer_pop = old_inhibit_defer_pop;
1.1.1.2 root 3691:
1.1 root 3692: /* If returning from the subroutine does not automatically pop the args,
3693: we need an instruction to pop them sooner or later.
3694: Perhaps do it now; perhaps just record how much space to pop later. */
1.1.1.2 root 3695:
3696: if (! RETURN_POPS_ARGS (TREE_TYPE (funtype))
3697: && stack_size != 0)
1.1 root 3698: {
1.1.1.17 root 3699: if (flag_defer_pop && inhibit_defer_pop == 0)
1.1.1.2 root 3700: pending_stack_adjust += stack_size;
1.1 root 3701: else
1.1.1.3 root 3702: adjust_stack (stack_size_rtx);
1.1 root 3703: }
3704: }
3705:
3706: /* At the start of a function, record that we have no previously-pushed
3707: arguments waiting to be popped. */
3708:
1.1.1.2 root 3709: void
3710: init_pending_stack_adjust ()
1.1 root 3711: {
3712: pending_stack_adjust = 0;
3713: }
3714:
1.1.1.2 root 3715: /* When exiting from function, if safe, clear out any pending stack adjust
3716: so the adjustment won't get done. */
3717:
3718: void
3719: clear_pending_stack_adjust ()
3720: {
3721: #ifdef EXIT_IGNORE_STACK
1.1.1.4 root 3722: if (!flag_omit_frame_pointer && EXIT_IGNORE_STACK
1.1.1.10 root 3723: && ! TREE_INLINE (current_function_decl)
3724: && ! flag_inline_functions)
1.1.1.2 root 3725: pending_stack_adjust = 0;
3726: #endif
3727: }
3728:
1.1 root 3729: /* Pop any previously-pushed arguments that have not been popped yet. */
3730:
1.1.1.2 root 3731: void
1.1 root 3732: do_pending_stack_adjust ()
3733: {
1.1.1.17 root 3734: if (inhibit_defer_pop == 0)
1.1 root 3735: {
3736: if (pending_stack_adjust != 0)
3737: adjust_stack (gen_rtx (CONST_INT, VOIDmode, pending_stack_adjust));
3738: pending_stack_adjust = 0;
3739: }
3740: }
3741:
1.1.1.17 root 3742: /* Data structure and subroutines used within expand_call. */
1.1 root 3743:
1.1.1.9 root 3744: struct arg_data
3745: {
3746: /* Tree node for this argument. */
3747: tree tree_value;
3748: /* Precomputed RTL value, or 0 if it isn't precomputed. */
3749: rtx value;
3750: /* Register to pass this argument in, or 0 if passed on stack. */
3751: rtx reg;
3752: /* Number of registers to use. 0 means put the whole arg in registers.
3753: Also 0 if not passed in registers. */
3754: int partial;
3755: /* Offset of this argument from beginning of stack-args. */
3756: struct args_size offset;
3757: /* Size of this argument on the stack, rounded up for any padding it gets,
3758: parts of the argument passed in registers do not count.
3759: If the FIRST_PARM_CALLER_OFFSET is negative, then register parms
3760: are counted here as well. */
3761: struct args_size size;
3762: /* Nonzero if this arg has already been stored. */
3763: int stored;
3764: /* const0_rtx means should preallocate stack space for this arg.
3765: Other non0 value is the stack slot, preallocated.
3766: Used only for BLKmode. */
3767: rtx stack;
3768: };
3769:
1.1.1.17 root 3770: static void store_one_arg ();
3771: static rtx target_for_arg ();
3772:
3773: /* Generate all the code for a function call
3774: and return an rtx for its value.
3775: Store the value in TARGET (specified as an rtx) if convenient.
3776: If the value is stored in TARGET then TARGET is returned.
3777: If IGNORE is nonzero, then we ignore the value of the function call. */
3778:
1.1 root 3779: static rtx
1.1.1.2 root 3780: expand_call (exp, target, ignore)
1.1 root 3781: tree exp;
3782: rtx target;
1.1.1.2 root 3783: int ignore;
1.1 root 3784: {
1.1.1.8 root 3785: /* List of actual parameters. */
1.1 root 3786: tree actparms = TREE_OPERAND (exp, 1);
1.1.1.8 root 3787: /* RTX for the function to be called. */
1.1.1.2 root 3788: rtx funexp;
1.1.1.8 root 3789: /* Data type of the function. */
3790: tree funtype;
3791: /* Declaration of the function being called,
3792: or 0 if the function is computed (not known by name). */
3793: tree fndecl = 0;
3794:
3795: /* Register in which non-BLKmode value will be returned,
3796: or 0 if no value or if value is BLKmode. */
3797: rtx valreg;
3798: /* Address where we should return a BLKmode value;
3799: 0 if value not BLKmode. */
3800: rtx structure_value_addr = 0;
3801: /* Nonzero if that address is being passed by treating it as
3802: an extra, implicit first parameter. Otherwise,
3803: it is passed by being copied directly into struct_value_rtx. */
3804: int structure_value_addr_parm = 0;
1.1.1.15 root 3805: /* Nonzero if called function returns an aggregate in memory PCC style,
3806: by returning the address of where to find it. */
3807: int pcc_struct_value = 0;
1.1.1.8 root 3808:
3809: /* Number of actual parameters in this call, including struct value addr. */
3810: int num_actuals;
3811: /* Number of named args. Args after this are anonymous ones
3812: and they must all go on the stack. */
3813: int n_named_args;
3814:
1.1.1.9 root 3815: /* Vector of information about each argument.
3816: Arguments are numbered in the order they will be pushed,
1.1.1.8 root 3817: not the order they are written. */
1.1.1.9 root 3818: struct arg_data *args;
1.1.1.8 root 3819:
3820: /* Total size in bytes of all the stack-parms scanned so far. */
3821: struct args_size args_size;
1.1.1.9 root 3822: /* Remember initial value of args_size.constant. */
3823: int starting_args_size;
3824: /* Nonzero means count reg-parms' size in ARGS_SIZE. */
3825: int stack_count_regparms = 0;
1.1.1.8 root 3826: /* Data on reg parms scanned so far. */
3827: CUMULATIVE_ARGS args_so_far;
3828: /* Nonzero if a reg parm has been scanned. */
1.1.1.9 root 3829: int reg_parm_seen;
3830: /* Nonzero if we must avoid push-insns in the args for this call. */
3831: int must_preallocate;
1.1.1.8 root 3832: /* 1 if scanning parms front to back, -1 if scanning back to front. */
1.1.1.2 root 3833: int inc;
1.1.1.8 root 3834: /* Address of space preallocated for stack parms
3835: (on machines that lack push insns), or 0 if space not preallocated. */
3836: rtx argblock = 0;
3837:
3838: /* Nonzero if it is plausible that this is a call to alloca. */
3839: int may_be_alloca;
3840: /* Nonzero if this is a call to setjmp or a related function. */
1.1.1.2 root 3841: int is_setjmp;
1.1.1.8 root 3842: /* Nonzero if this is a call to an inline function. */
1.1.1.2 root 3843: int is_integrable = 0;
1.1.1.8 root 3844: /* Nonzero if this is a call to __builtin_new. */
3845: int is_builtin_new;
1.1.1.14 root 3846: /* Nonzero if this is a call to a `const' function. */
3847: int is_const = 0;
1.1.1.8 root 3848:
1.1.1.9 root 3849: /* Nonzero if there are BLKmode args whose data types require them
3850: to be passed in memory, not (even partially) in registers. */
3851: int BLKmode_parms_forced = 0;
3852: /* The offset of the first BLKmode parameter which
3853: *must* be passed in memory. */
3854: int BLKmode_parms_first_offset = 0;
3855: /* Total size of BLKmode parms which could usefully be preallocated. */
3856: int BLKmode_parms_sizes = 0;
3857:
3858: /* Amount stack was adjusted to protect BLKmode parameters
3859: which are below the nominal "stack address" value. */
3860: rtx protected_stack = 0;
3861:
1.1.1.14 root 3862: /* The last insn before the things that are intrinsically part of the call.
3863: The beginning reg-note goes on the insn after this one. */
3864: rtx insn_before;
3865:
1.1.1.9 root 3866: rtx old_stack_level = 0;
1.1.1.2 root 3867: int old_pending_adj;
1.1.1.17 root 3868: int old_inhibit_defer_pop = inhibit_defer_pop;
1.1.1.8 root 3869: tree old_cleanups = cleanups_of_this_call;
1.1.1.18! root 3870: rtx use_insns;
1.1.1.2 root 3871:
1.1.1.8 root 3872: register tree p;
3873: register int i;
1.1.1.2 root 3874:
3875: /* See if we can find a DECL-node for the actual function.
3876: As a result, decide whether this is a call to an integrable function. */
3877:
1.1.1.8 root 3878: p = TREE_OPERAND (exp, 0);
1.1.1.2 root 3879: if (TREE_CODE (p) == ADDR_EXPR)
3880: {
3881: fndecl = TREE_OPERAND (p, 0);
3882: if (TREE_CODE (fndecl) != FUNCTION_DECL)
3883: fndecl = 0;
3884: else
3885: {
3886: extern tree current_function_decl;
1.1 root 3887:
1.1.1.2 root 3888: if (fndecl != current_function_decl
3889: && DECL_SAVED_INSNS (fndecl))
3890: is_integrable = 1;
3891: else
1.1.1.4 root 3892: {
3893: /* In case this function later becomes inlineable,
3894: record that there was already a non-inline call to it. */
1.1.1.17 root 3895: mark_addressable (fndecl);
1.1.1.4 root 3896: }
1.1.1.14 root 3897:
3898: if (TREE_READONLY (fndecl) && ! TREE_THIS_VOLATILE (fndecl))
3899: is_const = 1;
1.1.1.2 root 3900: }
3901: }
1.1 root 3902:
1.1.1.17 root 3903: /* When calling a const function, we must pop the stack args right away,
3904: so that the pop is deleted or moved with the call. */
3905: if (is_const)
3906: NO_DEFER_POP;
3907:
1.1.1.2 root 3908: /* Set up a place to return a structure. */
1.1 root 3909:
1.1.1.17 root 3910: /* Cater to broken compilers. */
3911: if (aggregate_value_p (exp))
1.1 root 3912: {
3913: /* This call returns a big structure. */
1.1.1.15 root 3914: #ifdef PCC_STATIC_STRUCT_RETURN
3915: if (flag_pcc_struct_return)
1.1.1.9 root 3916: {
1.1.1.15 root 3917: pcc_struct_value = 1;
3918: is_integrable = 0; /* Easier than making that case work right. */
1.1.1.9 root 3919: }
1.1 root 3920: else
1.1.1.15 root 3921: #endif
3922: {
1.1.1.16 root 3923: if (target && GET_CODE (target) == MEM)
1.1.1.15 root 3924: {
3925: structure_value_addr = XEXP (target, 0);
3926: if (reg_mentioned_p (stack_pointer_rtx, structure_value_addr))
3927: structure_value_addr = copy_to_reg (structure_value_addr);
3928: }
3929: else
1.1.1.17 root 3930: {
3931: /* Make room on the stack to hold the value. */
3932: structure_value_addr
3933: = get_structure_value_addr (expr_size (exp));
3934: target = 0;
3935: }
1.1.1.15 root 3936: }
1.1 root 3937: }
3938:
1.1.1.15 root 3939: /* If called function is inline, try to integrate it. */
3940:
1.1.1.2 root 3941: if (is_integrable)
3942: {
3943: extern rtx expand_inline_function ();
3944: rtx temp;
3945:
3946: temp = expand_inline_function (fndecl, actparms, target,
3947: ignore, TREE_TYPE (exp),
3948: structure_value_addr);
3949:
1.1.1.8 root 3950: /* If inlining succeeded, return. */
3951: if ((int) temp != -1)
1.1.1.2 root 3952: return temp;
1.1.1.8 root 3953:
3954: /* If inlining failed, mark FNDECL as needing to be compiled
3955: separately after all. */
3956: TREE_ADDRESSABLE (fndecl) = 1;
3957: TREE_ADDRESSABLE (DECL_NAME (fndecl)) = 1;
1.1.1.2 root 3958: }
3959:
3960: #if 0
3961: /* Unless it's a call to a specific function that isn't alloca,
3962: if it has one argument, we must assume it might be alloca. */
3963:
3964: may_be_alloca =
3965: (!(fndecl != 0
3966: && strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)),
3967: "alloca"))
3968: && actparms != 0
3969: && TREE_CHAIN (actparms) == 0);
3970: #else
3971: /* We assume that alloca will always be called by name. It
3972: makes no sense to pass it as a pointer-to-function to
3973: anything that does not understand its behavior. */
3974: may_be_alloca =
1.1.1.9 root 3975: (fndecl && (! strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "alloca")
3976: || ! strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)),
3977: "__builtin_alloca")));
1.1.1.2 root 3978: #endif
3979:
3980: /* See if this is a call to a function that can return more than once. */
3981:
3982: is_setjmp
3983: = (fndecl != 0
3984: && (!strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "setjmp")
3985: || !strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "_setjmp")));
3986:
1.1.1.8 root 3987: is_builtin_new
3988: = (fndecl != 0
3989: && (!strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "__builtin_new")));
3990:
1.1.1.2 root 3991: if (may_be_alloca)
3992: {
3993: frame_pointer_needed = 1;
3994: may_call_alloca = 1;
1.1.1.17 root 3995: current_function_calls_alloca = 1;
1.1.1.2 root 3996: }
3997:
3998: /* Don't let pending stack adjusts add up to too much.
3999: Also, do all pending adjustments now
4000: if there is any chance this might be a call to alloca. */
4001:
4002: if (pending_stack_adjust >= 32
4003: || (pending_stack_adjust > 0 && may_be_alloca))
4004: do_pending_stack_adjust ();
4005:
4006: /* Operand 0 is a pointer-to-function; get the type of the function. */
4007: funtype = TREE_TYPE (TREE_OPERAND (exp, 0));
4008: if (TREE_CODE (funtype) != POINTER_TYPE)
4009: abort ();
4010: funtype = TREE_TYPE (funtype);
4011:
1.1.1.17 root 4012: /* If struct_value_rtx is 0, it means pass the address
4013: as if it were an extra parameter. */
4014: if (structure_value_addr && struct_value_rtx == 0)
1.1.1.8 root 4015: {
4016: rtx tem;
4017:
4018: INIT_CUMULATIVE_ARGS (args_so_far, funtype);
4019: tem = FUNCTION_ARG (args_so_far, Pmode,
4020: build_pointer_type (TREE_TYPE (funtype)), 1);
1.1.1.16 root 4021: if (tem == 0)
1.1.1.8 root 4022: {
4023: actparms = tree_cons (error_mark_node,
4024: build (SAVE_EXPR,
4025: type_for_size (GET_MODE_BITSIZE (Pmode), 0),
4026: 0,
4027: force_reg (Pmode, structure_value_addr)),
4028: actparms);
4029: structure_value_addr_parm = 1;
4030: }
4031: }
1.1.1.6 root 4032:
1.1.1.2 root 4033: /* Count the arguments and set NUM_ACTUALS. */
1.1 root 4034: for (p = actparms, i = 0; p; p = TREE_CHAIN (p)) i++;
4035: num_actuals = i;
1.1.1.2 root 4036:
4037: /* Compute number of named args.
1.1.1.17 root 4038: Don't include the last named arg if anonymous args follow.
4039: (If no anonymous args follow, the result of list_length
4040: is actually one too large.) */
1.1.1.2 root 4041: if (TYPE_ARG_TYPES (funtype) != 0)
1.1.1.17 root 4042: n_named_args = list_length (TYPE_ARG_TYPES (funtype)) - 1;
1.1.1.2 root 4043: else
4044: /* If we know nothing, treat all args as named. */
4045: n_named_args = num_actuals;
4046:
1.1.1.9 root 4047: /* Make a vector to hold all the information about each arg. */
4048: args = (struct arg_data *) alloca (num_actuals * sizeof (struct arg_data));
4049: bzero (args, num_actuals * sizeof (struct arg_data));
4050:
4051: args_size.constant = 0;
4052: args_size.var = 0;
4053: #ifdef FIRST_PARM_CALLER_OFFSET
1.1.1.17 root 4054: args_size.constant = FIRST_PARM_CALLER_OFFSET (funtype);
1.1.1.9 root 4055: stack_count_regparms = 1;
4056: #endif
4057: starting_args_size = args_size.constant;
1.1.1.2 root 4058:
4059: /* In this loop, we consider args in the order they are written.
1.1.1.9 root 4060: We fill up ARGS from the front of from the back if necessary
4061: so that in any case the first arg to be pushed ends up at the front. */
1.1 root 4062:
1.1.1.2 root 4063: #ifdef PUSH_ARGS_REVERSED
4064: i = num_actuals - 1, inc = -1;
1.1 root 4065: /* In this case, must reverse order of args
1.1.1.2 root 4066: so that we compute and push the last arg first. */
1.1 root 4067: #else
1.1.1.2 root 4068: i = 0, inc = 1;
4069: #endif
4070:
4071: INIT_CUMULATIVE_ARGS (args_so_far, funtype);
4072:
4073: for (p = actparms; p; p = TREE_CHAIN (p), i += inc)
4074: {
4075: tree type = TREE_TYPE (TREE_VALUE (p));
1.1.1.9 root 4076: args[i].tree_value = TREE_VALUE (p);
4077: args[i].offset = args_size;
1.1.1.2 root 4078:
1.1.1.15 root 4079: if (type == error_mark_node
4080: || TYPE_SIZE (type) == 0)
1.1.1.2 root 4081: continue;
4082:
4083: /* Decide where to pass this arg. */
1.1.1.9 root 4084: /* args[i].reg is nonzero if all or part is passed in registers.
4085: args[i].partial is nonzero if part but not all is passed in registers,
1.1.1.2 root 4086: and the exact value says how many words are passed in registers. */
4087:
4088: if (TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
1.1.1.6 root 4089: && args_size.var == 0
4090: /* error_mark_node here is a flag for the fake argument
4091: for a structure value address. */
4092: && TREE_PURPOSE (p) != error_mark_node)
1.1.1.2 root 4093: {
1.1.1.9 root 4094: args[i].reg = FUNCTION_ARG (args_so_far, TYPE_MODE (type), type,
4095: i < n_named_args);
1.1.1.16 root 4096: /* If this argument needs more than the usual parm alignment, do
4097: extrinsic padding to reach that alignment. */
4098:
4099: #ifdef MAX_PARM_BOUNDARY
4100: /* If MAX_PARM_BOUNDARY is not defined, it means that the usual
4101: alignment requirements are relaxed for parms, and that no parm
4102: needs more than PARM_BOUNDARY, regardless of data type. */
4103:
4104: if (PARM_BOUNDARY < TYPE_ALIGN (type))
4105: {
4106: int boundary = PARM_BOUNDARY;
4107:
4108: /* Determine the boundary to pad up to. */
4109: if (TYPE_ALIGN (type) > boundary)
4110: boundary = TYPE_ALIGN (type);
4111: if (boundary > MAX_PARM_BOUNDARY)
4112: boundary = MAX_PARM_BOUNDARY;
4113:
4114: /* If the previous args don't reach such a boundary,
4115: advance to the next one. */
1.1.1.17 root 4116: boundary /= BITS_PER_UNIT;
1.1.1.16 root 4117: args[i].offset.constant += boundary - 1;
1.1.1.17 root 4118: args[i].offset.constant &= ~(boundary - 1);
1.1.1.16 root 4119: args_size.constant += boundary - 1;
1.1.1.17 root 4120: args_size.constant &= ~(boundary - 1);
1.1.1.16 root 4121:
4122: if (args_size.var != 0)
4123: abort (); /* This case not implemented yet */
4124: }
4125: #endif /* MAX_PARM_BOUNDARY */
4126:
1.1.1.2 root 4127: #ifdef FUNCTION_ARG_PARTIAL_NREGS
1.1.1.9 root 4128: args[i].partial
4129: = FUNCTION_ARG_PARTIAL_NREGS (args_so_far,
4130: TYPE_MODE (type), type,
4131: i < n_named_args);
1.1.1.2 root 4132: #endif
4133: }
4134:
1.1.1.9 root 4135: /* Compute the stack-size of this argument. */
1.1.1.2 root 4136:
1.1.1.9 root 4137: if (args[i].reg != 0 && args[i].partial == 0
4138: && ! stack_count_regparms)
4139: /* On most machines, don't count stack space for a register arg. */
1.1.1.2 root 4140: ;
4141: else if (TYPE_MODE (type) != BLKmode)
4142: {
4143: register int size;
4144:
4145: size = GET_MODE_SIZE (TYPE_MODE (type));
4146: /* Compute how much space the push instruction will push.
4147: On many machines, pushing a byte will advance the stack
4148: pointer by a halfword. */
4149: #ifdef PUSH_ROUNDING
4150: size = PUSH_ROUNDING (size);
1.1 root 4151: #endif
1.1.1.2 root 4152: /* Compute how much space the argument should get:
1.1.1.6 root 4153: maybe pad to a multiple of the alignment for arguments. */
1.1.1.16 root 4154: if (none == FUNCTION_ARG_PADDING (TYPE_MODE (type), const0_rtx))
1.1.1.9 root 4155: args[i].size.constant = size;
1.1.1.6 root 4156: else
1.1.1.9 root 4157: args[i].size.constant
1.1.1.6 root 4158: = (((size + PARM_BOUNDARY / BITS_PER_UNIT - 1)
4159: / (PARM_BOUNDARY / BITS_PER_UNIT))
4160: * (PARM_BOUNDARY / BITS_PER_UNIT));
1.1.1.2 root 4161: }
4162: else
4163: {
4164: register tree size = size_in_bytes (type);
4165:
4166: /* A nonscalar. Round its size up to a multiple
1.1.1.9 root 4167: of PARM_BOUNDARY bits, unless it is not supposed to be padded. */
1.1.1.6 root 4168: if (none
4169: != FUNCTION_ARG_PADDING (TYPE_MODE (type),
4170: expand_expr (size, 0, VOIDmode, 0)))
4171: size = convert_units (convert_units (size, BITS_PER_UNIT,
4172: PARM_BOUNDARY),
4173: PARM_BOUNDARY, BITS_PER_UNIT);
1.1.1.9 root 4174: ADD_PARM_SIZE (args[i].size, size);
4175:
4176: /* Certain data types may not be passed in registers
4177: (eg C++ classes with constructors).
4178: Also, BLKmode parameters initialized from CALL_EXPRs
4179: are treated specially, if it is a win to do so. */
4180: if (TREE_CODE (TREE_VALUE (p)) == CALL_EXPR
1.1.1.13 root 4181: || TREE_ADDRESSABLE (type))
1.1.1.9 root 4182: {
1.1.1.13 root 4183: if (TREE_ADDRESSABLE (type))
1.1.1.9 root 4184: BLKmode_parms_forced = 1;
4185: /* This is a marker for such a parameter. */
4186: args[i].stack = const0_rtx;
4187: BLKmode_parms_sizes += TREE_INT_CST_LOW (size);
4188:
4189: /* If this parm's location is "below" the nominal stack pointer,
4190: note to decrement the stack pointer while it is computed. */
4191: #ifdef FIRST_PARM_CALLER_OFFSET
4192: if (BLKmode_parms_first_offset == 0)
4193: BLKmode_parms_first_offset
4194: /* If parameter's offset is variable, assume the worst. */
4195: = (args[i].offset.var
1.1.1.17 root 4196: ? FIRST_PARM_CALLER_OFFSET (funtype)
1.1.1.9 root 4197: : args[i].offset.constant);
4198: #endif
4199: }
1.1.1.2 root 4200: }
1.1.1.9 root 4201:
1.1.1.2 root 4202: /* If a part of the arg was put into registers,
4203: don't include that part in the amount pushed. */
1.1.1.9 root 4204: if (! stack_count_regparms)
4205: args[i].size.constant
4206: -= ((args[i].partial * UNITS_PER_WORD)
4207: / (PARM_BOUNDARY / BITS_PER_UNIT)
4208: * (PARM_BOUNDARY / BITS_PER_UNIT));
1.1.1.2 root 4209:
1.1.1.9 root 4210: /* Update ARGS_SIZE, the total stack space for args so far. */
1.1.1.2 root 4211:
1.1.1.9 root 4212: args_size.constant += args[i].size.constant;
4213: if (args[i].size.var)
1.1.1.2 root 4214: {
1.1.1.9 root 4215: ADD_PARM_SIZE (args_size, args[i].size.var);
1.1.1.2 root 4216: }
1.1.1.9 root 4217:
4218: /* Increment ARGS_SO_FAR, which has info about which arg-registers
4219: have been used, etc. */
4220:
4221: FUNCTION_ARG_ADVANCE (args_so_far, TYPE_MODE (type), type,
4222: i < n_named_args);
1.1.1.2 root 4223: }
4224:
1.1.1.9 root 4225: /* If we would have to push a partially-in-regs parm
4226: before other stack parms, preallocate stack space instead. */
4227: must_preallocate = 0;
4228: {
4229: int partial_seen = 0;
4230: for (i = 0; i < num_actuals; i++)
4231: {
4232: if (args[i].partial > 0)
4233: partial_seen = 1;
4234: else if (partial_seen && args[i].reg == 0)
4235: must_preallocate = 1;
4236: }
4237: }
4238:
1.1.1.14 root 4239: /* Precompute all register parameters. It isn't safe to compute anything
4240: once we have started filling any specific hard regs.
4241: If this function call is cse'able, precompute all the parameters. */
4242:
4243: reg_parm_seen = 0;
4244: for (i = 0; i < num_actuals; i++)
4245: if (args[i].reg != 0 || is_const)
4246: {
1.1.1.15 root 4247: int j;
4248: int struct_value_lossage = 0;
4249:
4250: /* First, see if this is a precomputed struct-returning function call
4251: and other subsequent parms are also such. */
1.1.1.16 root 4252: if ((TYPE_MODE (TREE_TYPE (args[i].tree_value)) == BLKmode
4253: || RETURN_IN_MEMORY (TREE_TYPE (args[i].tree_value)))
1.1.1.15 root 4254: && TREE_CODE (args[i].tree_value) == CALL_EXPR)
4255: for (j = i + 1; j < num_actuals; j++)
1.1.1.16 root 4256: if ((TYPE_MODE (TREE_TYPE (args[j].tree_value)) == BLKmode
4257: || RETURN_IN_MEMORY (TREE_TYPE (args[j].tree_value)))
1.1.1.15 root 4258: && TREE_CODE (args[j].tree_value) == CALL_EXPR
4259: && args[j].reg != 0 || is_const)
4260: {
4261: /* We have two precomputed structure-values call expressions
4262: in our parm list. Both of them would normally use
4263: the structure-value block. To avoid the conflict,
4264: compute this parm with a different temporary block. */
4265: int size = int_size_in_bytes (TREE_TYPE (args[i].tree_value));
4266: rtx structval = assign_stack_local (BLKmode, size);
4267: args[i].value = expand_expr (args[i].tree_value, structval,
4268: VOIDmode, 0);
4269: struct_value_lossage = 1;
4270: break;
4271: }
4272: if (!struct_value_lossage)
4273: args[i].value = expand_expr (args[i].tree_value, 0, VOIDmode, 0);
4274:
1.1.1.14 root 4275: if (args[i].reg != 0)
4276: reg_parm_seen = 1;
1.1.1.15 root 4277:
1.1.1.14 root 4278: if (GET_CODE (args[i].value) != MEM
4279: && ! CONSTANT_P (args[i].value)
4280: && GET_CODE (args[i].value) != CONST_DOUBLE)
4281: args[i].value
4282: = force_reg (TYPE_MODE (TREE_TYPE (args[i].tree_value)),
4283: args[i].value);
4284: /* ANSI doesn't require a sequence point here,
4285: but PCC has one, so this will avoid some problems. */
4286: emit_queue ();
4287: }
4288:
4289: /* Get the function to call, in the form of RTL, if it is a constant. */
4290: if (fndecl && is_const)
4291: {
4292: /* Get a SYMBOL_REF rtx for the function address. */
4293: funexp = XEXP (DECL_RTL (fndecl), 0);
4294:
4295: #ifndef NO_FUNCTION_CSE
4296: /* Pass the address through a pseudoreg, if desired,
4297: before the "beginning" of the library call.
4298: So this insn isn't "part of" the library call, in case that
4299: is deleted, or cse'd. */
4300: if (! flag_no_function_cse)
4301: funexp = copy_to_mode_reg (Pmode, funexp);
4302: #endif
4303: }
4304:
4305: /* Now we are about to start emitting insns that can be deleted
4306: if the libcall is deleted. */
4307: insn_before = get_last_insn ();
4308:
1.1.1.16 root 4309: /* Maybe do additional rounding on the size of the arguments. */
4310: #ifdef STACK_ARGS_ADJUST
4311: STACK_ARGS_ADJUST (args_size);
4312: #endif
4313:
1.1.1.9 root 4314: /* If we have no actual push instructions, or shouldn't use them,
4315: or we need a variable amount of space, make space for all args right now.
4316: Round the needed size up to multiple of STACK_BOUNDARY. */
1.1.1.2 root 4317:
4318: if (args_size.var != 0)
4319: {
4320: old_stack_level = copy_to_mode_reg (Pmode, stack_pointer_rtx);
4321: old_pending_adj = pending_stack_adjust;
4322: argblock = push_block (round_push (ARGS_SIZE_RTX (args_size)));
4323: }
1.1.1.9 root 4324: else if (args_size.constant > 0)
1.1.1.2 root 4325: {
4326: int needed = args_size.constant;
4327:
4328: #ifdef STACK_BOUNDARY
4329: needed = (needed + STACK_BYTES - 1) / STACK_BYTES * STACK_BYTES;
4330: #endif
1.1.1.15 root 4331: args_size.constant = needed;
1.1.1.2 root 4332:
1.1.1.9 root 4333: if (
1.1.1.2 root 4334: #ifndef PUSH_ROUNDING
1.1.1.9 root 4335: 1 /* Always preallocate if no push insns. */
4336: #else
4337: must_preallocate || BLKmode_parms_forced
4338: || BLKmode_parms_sizes > (args_size.constant >> 1)
4339: #endif
4340: )
1.1.1.2 root 4341: {
1.1.1.9 root 4342: /* Try to reuse some or all of the pending_stack_adjust
4343: to get this space. Maybe we can avoid any pushing. */
4344: if (needed > pending_stack_adjust)
4345: {
4346: needed -= pending_stack_adjust;
4347: pending_stack_adjust = 0;
4348: }
4349: else
4350: {
4351: pending_stack_adjust -= needed;
4352: needed = 0;
4353: }
4354: argblock = push_block (gen_rtx (CONST_INT, VOIDmode, needed));
1.1.1.2 root 4355: }
4356: }
1.1.1.13 root 4357: #ifndef PUSH_ROUNDING
4358: else if (BLKmode_parms_forced)
4359: {
4360: /* If we have reg-parms that need to be temporarily on the stack,
4361: set up an arg block address even though there is no space
4362: to be allocated for it. */
4363: argblock = push_block (const0_rtx);
4364: }
4365: #endif
1.1.1.2 root 4366:
1.1.1.16 root 4367: #if 0
1.1.1.15 root 4368: /* If stack needs padding below the args, increase all arg offsets
4369: so the args are stored above the padding. */
4370: if (stack_padding)
4371: for (i = 0; i < num_actuals; i++)
4372: args[i].offset.constant += stack_padding;
4373: #endif
4374:
1.1.1.9 root 4375: /* Don't try to defer pops if preallocating, not even from the first arg,
4376: since ARGBLOCK probably refers to the SP. */
4377: if (argblock)
4378: NO_DEFER_POP;
4379:
4380: #ifdef STACK_GROWS_DOWNWARD
4381: /* If any BLKmode parms need to be preallocated in space
4382: below the nominal stack-pointer address, we need to adjust the
4383: stack pointer so that this location is temporarily above it.
4384: This ensures that computation won't clobber that space. */
4385: if (BLKmode_parms_first_offset < 0 && argblock != 0)
4386: {
4387: int needed = -BLKmode_parms_first_offset;
4388: argblock = copy_to_reg (argblock);
4389:
4390: #ifdef STACK_BOUNDARY
4391: needed = (needed + STACK_BYTES - 1) / STACK_BYTES * STACK_BYTES;
4392: #endif
4393: protected_stack = gen_rtx (CONST_INT, VOIDmode, needed);
4394: anti_adjust_stack (protected_stack);
4395: }
4396: #endif /* STACK_GROWS_DOWNWARD */
4397:
1.1.1.2 root 4398: /* Get the function to call, in the form of RTL. */
4399: if (fndecl)
4400: /* Get a SYMBOL_REF rtx for the function address. */
4401: funexp = XEXP (DECL_RTL (fndecl), 0);
4402: else
4403: /* Generate an rtx (probably a pseudo-register) for the address. */
1.1.1.4 root 4404: {
4405: funexp = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0);
4406: emit_queue ();
4407: }
1.1.1.2 root 4408:
1.1.1.9 root 4409: /* Now compute and store all non-register parms.
4410: These come before register parms, since they can require block-moves,
4411: which could clobber the registers used for register parms.
4412: Parms which have partial registers are not stored here,
4413: but we do preallocate space here if they want that. */
1.1.1.2 root 4414:
1.1 root 4415: for (i = 0; i < num_actuals; i++)
4416: {
1.1.1.9 root 4417: /* Preallocate the stack space for a parm if appropriate
4418: so it can be computed directly in the stack space. */
4419: if (args[i].stack != 0 && argblock != 0)
4420: args[i].stack = target_for_arg (TREE_TYPE (args[i].tree_value),
4421: ARGS_SIZE_RTX (args[i].size),
4422: argblock, args[i].offset);
1.1 root 4423: else
1.1.1.9 root 4424: args[i].stack = 0;
1.1 root 4425:
1.1.1.15 root 4426: if (args[i].reg == 0
4427: && TYPE_SIZE (TREE_TYPE (args[i].tree_value)) != 0)
1.1.1.9 root 4428: store_one_arg (&args[i], argblock, may_be_alloca);
4429: }
1.1 root 4430:
1.1.1.9 root 4431: /* Now store any partially-in-registers parm.
4432: This is the last place a block-move can happen. */
4433: if (reg_parm_seen)
4434: for (i = 0; i < num_actuals; i++)
4435: if (args[i].partial != 0)
4436: store_one_arg (&args[i], argblock, may_be_alloca);
1.1 root 4437:
1.1.1.9 root 4438: if (protected_stack != 0)
4439: adjust_stack (protected_stack);
1.1 root 4440:
1.1.1.9 root 4441: /* Pass the function the address in which to return a structure value. */
4442: if (structure_value_addr && ! structure_value_addr_parm)
1.1.1.17 root 4443: emit_move_insn (struct_value_rtx,
4444: force_reg (Pmode, force_operand (structure_value_addr, 0)));
1.1 root 4445:
1.1.1.9 root 4446: /* Now set up any wholly-register parms. They were computed already. */
4447: if (reg_parm_seen)
4448: for (i = 0; i < num_actuals; i++)
4449: if (args[i].reg != 0 && args[i].partial == 0)
4450: store_one_arg (&args[i], argblock, may_be_alloca);
1.1 root 4451:
4452: /* Perform postincrements before actually calling the function. */
4453: emit_queue ();
4454:
1.1.1.2 root 4455: /* All arguments and registers used for the call must be set up by now! */
1.1 root 4456:
1.1.1.2 root 4457: /* ??? Other languages need a nontrivial second argument (static chain). */
4458: funexp = prepare_call_address (funexp, 0);
4459:
1.1.1.18! root 4460: /* Mark all register-parms as living through the call. */
! 4461: start_sequence ();
1.1.1.2 root 4462: for (i = 0; i < num_actuals; i++)
1.1.1.9 root 4463: if (args[i].reg != 0)
1.1.1.2 root 4464: {
1.1.1.9 root 4465: if (args[i].partial > 0)
4466: use_regs (REGNO (args[i].reg), args[i].partial);
4467: else if (GET_MODE (args[i].reg) == BLKmode)
4468: use_regs (REGNO (args[i].reg),
1.1.1.18! root 4469: ((int_size_in_bytes (TREE_TYPE (args[i].tree_value))
! 4470: + UNITS_PER_WORD - 1)
1.1.1.2 root 4471: / UNITS_PER_WORD));
4472: else
1.1.1.9 root 4473: emit_insn (gen_rtx (USE, VOIDmode, args[i].reg));
1.1.1.2 root 4474: }
4475:
1.1.1.17 root 4476: if (structure_value_addr && ! structure_value_addr_parm
4477: && GET_CODE (struct_value_rtx) == REG)
1.1.1.2 root 4478: emit_insn (gen_rtx (USE, VOIDmode, struct_value_rtx));
4479:
1.1.1.18! root 4480: use_insns = gen_sequence ();
! 4481: end_sequence ();
! 4482:
1.1.1.2 root 4483: /* Figure out the register where the value, if any, will come back. */
4484: valreg = 0;
4485: if (TYPE_MODE (TREE_TYPE (exp)) != VOIDmode
1.1.1.18! root 4486: && ! structure_value_addr)
! 4487: {
! 4488: if (pcc_struct_value)
! 4489: valreg = hard_libcall_value (Pmode);
! 4490: else
! 4491: valreg = hard_function_value (TREE_TYPE (exp), fndecl);
! 4492: }
1.1.1.2 root 4493:
4494: /* Generate the actual call instruction. */
1.1.1.18! root 4495: /* This also has the effect of turning off any pop-inhibition
! 4496: done in expand_call. */
1.1.1.9 root 4497: if (args_size.constant < 0)
4498: args_size.constant = 0;
1.1.1.2 root 4499: emit_call_1 (funexp, funtype, args_size.constant,
4500: FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1),
1.1.1.18! root 4501: valreg, old_inhibit_defer_pop, use_insns);
1.1 root 4502:
4503: /* ??? Nothing has been done here to record control flow
4504: when contained functions can do nonlocal gotos. */
4505:
1.1.1.2 root 4506: /* For calls to `setjmp', etc., inform flow.c it should complain
4507: if nonvolatile values are live. */
4508:
4509: if (is_setjmp)
1.1.1.11 root 4510: {
4511: emit_note (IDENTIFIER_POINTER (DECL_NAME (fndecl)), NOTE_INSN_SETJMP);
4512: current_function_calls_setjmp = 1;
4513: }
1.1.1.2 root 4514:
1.1.1.14 root 4515: /* Notice functions that cannot return.
4516: If optimizing, insns emitted below will be dead.
4517: If not optimizing, they will exist, which is useful
4518: if the user uses the `return' command in the debugger. */
4519:
4520: if (fndecl && TREE_THIS_VOLATILE (fndecl))
4521: emit_barrier ();
4522:
1.1.1.8 root 4523: /* For calls to __builtin_new, note that it can never return 0.
4524: This is because a new handler will be called, and 0 it not
4525: among the numbers it is supposed to return. */
4526: #if 0
4527: if (is_builtin_new)
4528: emit_note (IDENTIFIER_POINTER (DECL_NAME (fndecl)), NOTE_INSN_BUILTIN_NEW);
4529: #endif
1.1.1.2 root 4530:
1.1 root 4531: /* If value type not void, return an rtx for the value. */
4532:
1.1.1.13 root 4533: /* If there are cleanups to be called, don't use a hard reg as target. */
4534: if (cleanups_of_this_call != old_cleanups
4535: && target && REG_P (target)
4536: && REGNO (target) < FIRST_PSEUDO_REGISTER)
4537: target = 0;
4538:
1.1.1.2 root 4539: if (TYPE_MODE (TREE_TYPE (exp)) == VOIDmode
4540: || ignore)
1.1 root 4541: {
1.1.1.14 root 4542: target = const0_rtx;
1.1 root 4543: }
1.1.1.8 root 4544: else if (structure_value_addr)
4545: {
1.1.1.16 root 4546: if (target == 0 || GET_CODE (target) != MEM)
4547: target = gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)),
1.1.1.8 root 4548: memory_address (BLKmode, structure_value_addr));
4549: }
1.1.1.15 root 4550: else if (pcc_struct_value)
4551: {
1.1.1.16 root 4552: valreg = hard_function_value (build_pointer_type (TREE_TYPE (exp)),
4553: fndecl);
4554: if (target == 0)
4555: target = gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)),
4556: copy_to_reg (valreg));
1.1.1.15 root 4557: else if (TYPE_MODE (TREE_TYPE (exp)) != BLKmode)
4558: emit_move_insn (target, gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)),
4559: copy_to_reg (valreg)));
4560: else
4561: emit_block_move (target, gen_rtx (MEM, BLKmode, copy_to_reg (valreg)),
4562: expr_size (exp),
4563: TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
4564: }
1.1.1.8 root 4565: else if (target && GET_MODE (target) == TYPE_MODE (TREE_TYPE (exp)))
1.1 root 4566: {
1.1.1.2 root 4567: if (!rtx_equal_p (target, valreg))
4568: emit_move_insn (target, valreg);
4569: else
4570: /* This tells expand_inline_function to copy valreg to its target. */
4571: emit_insn (gen_rtx (USE, VOIDmode, valreg));
1.1 root 4572: }
1.1.1.8 root 4573: else
4574: target = copy_to_reg (valreg);
4575:
1.1.1.9 root 4576: /* Perform all cleanups needed for the arguments of this call
4577: (i.e. destructors in C++). */
4578: while (cleanups_of_this_call != old_cleanups)
4579: {
4580: expand_expr (TREE_VALUE (cleanups_of_this_call), 0, VOIDmode, 0);
4581: cleanups_of_this_call = TREE_CHAIN (cleanups_of_this_call);
4582: }
4583:
1.1.1.8 root 4584: /* If size of args is variable, restore saved stack-pointer value. */
4585:
1.1.1.9 root 4586: if (old_stack_level)
1.1.1.8 root 4587: {
4588: emit_move_insn (stack_pointer_rtx, old_stack_level);
4589: pending_stack_adjust = old_pending_adj;
4590: }
4591:
1.1.1.14 root 4592: /* If call is cse'able, make appropriate pair of reg-notes around it. */
4593: if (is_const)
4594: {
4595: rtx insn_first = NEXT_INSN (insn_before);
4596: rtx insn_last = get_last_insn ();
4597: rtx note = 0;
4598:
1.1.1.18! root 4599: /* Don't put the notes on if we don't have insns that can hold them. */
! 4600: if ((GET_CODE (insn_first) == INSN
! 4601: || GET_CODE (insn_first) == CALL_INSN
! 4602: || GET_CODE (insn_first) == JUMP_INSN)
! 4603: && (GET_CODE (insn_last) == INSN
! 4604: || GET_CODE (insn_last) == CALL_INSN
! 4605: || GET_CODE (insn_last) == JUMP_INSN))
! 4606: {
! 4607: /* Construct an "equal form" for the value
! 4608: which mentions all the arguments in order
! 4609: as well as the function name. */
! 4610: for (i = 0; i < num_actuals; i++)
! 4611: if (args[i].reg != 0 || is_const)
! 4612: note = gen_rtx (EXPR_LIST, VOIDmode, args[i].value, note);
! 4613: note = gen_rtx (EXPR_LIST, VOIDmode,
! 4614: XEXP (DECL_RTL (fndecl), 0), note);
! 4615:
! 4616: REG_NOTES (insn_last)
! 4617: = gen_rtx (EXPR_LIST, REG_EQUAL, note,
! 4618: gen_rtx (INSN_LIST, REG_RETVAL, insn_first,
! 4619: REG_NOTES (insn_last)));
! 4620: REG_NOTES (insn_first)
! 4621: = gen_rtx (INSN_LIST, REG_LIBCALL, insn_last,
! 4622: REG_NOTES (insn_first));
! 4623: }
1.1.1.14 root 4624: }
4625:
1.1.1.9 root 4626: return target;
4627: }
4628:
4629: /* Return an rtx which represents a suitable home on the stack
4630: given TYPE, the type of the argument looking for a home.
4631: This is called only for BLKmode arguments.
4632:
4633: SIZE is the size needed for this target.
4634: ARGS_ADDR is the address of the bottom of the argument block for this call.
4635: OFFSET describes this parameter's offset into ARGS_ADDR. It is meaningless
4636: if this machine uses push insns. */
4637:
4638: static rtx
4639: target_for_arg (type, size, args_addr, offset)
4640: tree type;
4641: rtx size;
4642: rtx args_addr;
4643: struct args_size offset;
4644: {
4645: rtx target;
4646: rtx offset_rtx = ARGS_SIZE_RTX (offset);
4647:
4648: /* We do not call memory_address if possible,
4649: because we want to address as close to the stack
4650: as possible. For non-variable sized arguments,
4651: this will be stack-pointer relative addressing. */
4652: if (GET_CODE (offset_rtx) == CONST_INT)
4653: target = plus_constant (args_addr, INTVAL (offset_rtx));
4654: else
1.1.1.8 root 4655: {
1.1.1.9 root 4656: /* I have no idea how to guarantee that this
4657: will work in the presence of register parameters. */
4658: target = gen_rtx (PLUS, Pmode, args_addr, offset_rtx);
4659: target = memory_address (QImode, target);
1.1.1.8 root 4660: }
1.1.1.9 root 4661:
4662: return gen_rtx (MEM, BLKmode, target);
4663: }
4664:
4665: /* Store a single argument for a function call
4666: into the register or memory area where it must be passed.
4667: *ARG describes the argument value and where to pass it.
4668: ARGBLOCK is the address of the stack-block for all the arguments,
4669: or 0 on a machine where arguemnts are pushed individually.
4670: MAY_BE_ALLOCA nonzero says this could be a call to `alloca'
4671: so must be careful about how the stack is used. */
4672:
4673: static void
4674: store_one_arg (arg, argblock, may_be_alloca)
4675: struct arg_data *arg;
4676: rtx argblock;
4677: int may_be_alloca;
4678: {
4679: register tree pval = arg->tree_value;
4680: int used = 0;
4681:
4682: if (TREE_CODE (pval) == ERROR_MARK)
4683: return;
4684:
4685: if (arg->reg != 0 && arg->partial == 0)
4686: {
4687: /* Being passed entirely in a register. */
4688: if (arg->value != 0)
4689: {
4690: if (GET_MODE (arg->value) == BLKmode)
4691: move_block_to_reg (REGNO (arg->reg), arg->value,
1.1.1.18! root 4692: ((int_size_in_bytes (TREE_TYPE (pval))
! 4693: + UNITS_PER_WORD - 1)
1.1.1.9 root 4694: / UNITS_PER_WORD));
4695: else
4696: emit_move_insn (arg->reg, arg->value);
4697: }
4698: else
4699: store_expr (pval, arg->reg, 0);
4700:
4701: /* Don't allow anything left on stack from computation
4702: of argument to alloca. */
4703: if (may_be_alloca)
4704: do_pending_stack_adjust ();
4705: }
4706: else if (TYPE_MODE (TREE_TYPE (pval)) != BLKmode)
4707: {
4708: register int size;
4709: rtx tem;
4710:
4711: /* Argument is a scalar, not entirely passed in registers.
4712: (If part is passed in registers, arg->partial says how much
4713: and emit_push_insn will take care of putting it there.)
4714:
4715: Push it, and if its size is less than the
4716: amount of space allocated to it,
4717: also bump stack pointer by the additional space.
4718: Note that in C the default argument promotions
4719: will prevent such mismatches. */
4720:
4721: used = size = GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (pval)));
4722: /* Compute how much space the push instruction will push.
4723: On many machines, pushing a byte will advance the stack
4724: pointer by a halfword. */
4725: #ifdef PUSH_ROUNDING
4726: size = PUSH_ROUNDING (size);
4727: #endif
4728: /* Compute how much space the argument should get:
4729: round up to a multiple of the alignment for arguments. */
1.1.1.16 root 4730: if (none != FUNCTION_ARG_PADDING (TYPE_MODE (TREE_TYPE (pval)), const0_rtx))
1.1.1.9 root 4731: used = (((size + PARM_BOUNDARY / BITS_PER_UNIT - 1)
4732: / (PARM_BOUNDARY / BITS_PER_UNIT))
4733: * (PARM_BOUNDARY / BITS_PER_UNIT));
4734:
4735: tem = arg->value;
4736: if (tem == 0)
4737: {
4738: tem = expand_expr (pval, 0, VOIDmode, 0);
4739: /* ANSI doesn't require a sequence point here,
4740: but PCC has one, so this will avoid some problems. */
4741: emit_queue ();
4742: }
4743:
4744: /* Don't allow anything left on stack from computation
4745: of argument to alloca. */
4746: if (may_be_alloca)
4747: do_pending_stack_adjust ();
4748:
4749: emit_push_insn (tem, TYPE_MODE (TREE_TYPE (pval)), 0, 0,
4750: arg->partial, arg->reg, used - size,
4751: argblock, ARGS_SIZE_RTX (arg->offset));
4752: }
4753: else if (arg->stack != 0)
4754: {
1.1.1.14 root 4755: /* BLKmode parm, not entirely passed in registers,
4756: and with space already allocated. */
4757:
4758: tree sizetree = size_in_bytes (TREE_TYPE (pval));
4759: /* Round the size up to multiple of PARM_BOUNDARY bits. */
4760: tree s1 = convert_units (sizetree, BITS_PER_UNIT, PARM_BOUNDARY);
4761: tree s2 = convert_units (s1, PARM_BOUNDARY, BITS_PER_UNIT);
4762:
4763: /* Find out if the parm needs padding, and whether above or below. */
4764: enum direction where_pad
4765: = FUNCTION_ARG_PADDING (TYPE_MODE (TREE_TYPE (pval)),
4766: expand_expr (sizetree, 0, VOIDmode, 0));
4767:
4768: /* If it is padded below, adjust the stack address
4769: upward over the padding. */
4770:
4771: if (where_pad == downward)
4772: {
4773: rtx offset_rtx;
4774: rtx address = XEXP (arg->stack, 0);
4775: struct args_size stack_offset;
4776:
4777: stack_offset.constant = 0;
4778: stack_offset.var = 0;
4779:
4780: /* Compute amount of padding. */
4781: ADD_PARM_SIZE (stack_offset, s2);
4782: SUB_PARM_SIZE (stack_offset, sizetree);
4783: offset_rtx = ARGS_SIZE_RTX (stack_offset);
4784:
4785: /* Adjust the address to store at. */
4786: if (GET_CODE (offset_rtx) == CONST_INT)
4787: address = plus_constant (address, INTVAL (offset_rtx));
4788: else
4789: {
4790: address = gen_rtx (PLUS, Pmode, address, offset_rtx);
4791: address = memory_address (QImode, address);
4792: }
4793: arg->stack = change_address (arg->stack, VOIDmode, address);
4794: }
4795:
1.1.1.12 root 4796: /* ARG->stack probably refers to the stack-pointer. If so,
4797: stabilize it, in case stack-pointer changes during evaluation. */
4798: if (reg_mentioned_p (stack_pointer_rtx, arg->stack))
4799: arg->stack = change_address (arg->stack, VOIDmode,
4800: copy_to_reg (XEXP (arg->stack, 0)));
1.1.1.9 root 4801: /* BLKmode argument that should go in a prespecified stack location. */
4802: if (arg->value == 0)
4803: /* Not yet computed => compute it there. */
4804: /* ??? This should be changed to tell expand_expr
4805: that it can store directly in the target. */
4806: arg->value = store_expr (arg->tree_value, arg->stack, 0);
4807: else if (arg->value != arg->stack)
4808: /* It was computed somewhere, but not where we wanted.
4809: For example, the value may have come from an official
4810: local variable or parameter. In that case, expand_expr
4811: does not fill our suggested target. */
4812: emit_block_move (arg->stack, arg->value, ARGS_SIZE_RTX (arg->size),
1.1.1.10 root 4813: TYPE_ALIGN (TREE_TYPE (pval)) / BITS_PER_UNIT);
1.1.1.9 root 4814:
4815: /* Now, if this value wanted to be partly in registers,
4816: move the value from the stack to the registers
4817: that are supposed to hold the values. */
4818: if (arg->partial > 0)
4819: move_block_to_reg (REGNO (arg->reg), arg->stack, arg->partial);
4820: }
4821: else
4822: {
1.1.1.14 root 4823: /* BLKmode, at least partly to be pushed. */
4824:
1.1.1.9 root 4825: register rtx tem
4826: = arg->value ? arg->value : expand_expr (pval, 0, VOIDmode, 0);
4827: register int excess;
4828: rtx size_rtx;
4829:
4830: /* Pushing a nonscalar.
4831: If part is passed in registers, arg->partial says how much
4832: and emit_push_insn will take care of putting it there. */
4833:
4834: /* Round its size up to a multiple
4835: of the allocation unit for arguments. */
4836:
4837: if (arg->size.var != 0)
4838: {
4839: excess = 0;
4840: size_rtx = ARGS_SIZE_RTX (arg->size);
4841: }
4842: else
4843: {
4844: register tree size = size_in_bytes (TREE_TYPE (pval));
4845: /* PUSH_ROUNDING has no effect on us, because
4846: emit_push_insn for BLKmode is careful to avoid it. */
1.1.1.17 root 4847: excess = (arg->size.constant - TREE_INT_CST_LOW (size)
4848: + arg->partial * UNITS_PER_WORD);
1.1.1.9 root 4849: size_rtx = expand_expr (size, 0, VOIDmode, 0);
4850: }
4851:
4852: if (arg->stack)
4853: abort ();
4854:
4855: emit_push_insn (tem, TYPE_MODE (TREE_TYPE (pval)), size_rtx,
4856: TYPE_ALIGN (TREE_TYPE (pval)) / BITS_PER_UNIT,
4857: arg->partial, arg->reg, excess, argblock,
4858: ARGS_SIZE_RTX (arg->offset));
4859: }
4860:
4861: /* Once we have pushed something, pops can't safely
4862: be deferred during the rest of the arguments. */
4863: NO_DEFER_POP;
1.1 root 4864: }
4865:
4866: /* Expand conditional expressions. */
4867:
4868: /* Generate code to evaluate EXP and jump to LABEL if the value is zero.
4869: LABEL is an rtx of code CODE_LABEL, in this function and all the
4870: functions here. */
4871:
1.1.1.2 root 4872: void
1.1 root 4873: jumpifnot (exp, label)
4874: tree exp;
4875: rtx label;
4876: {
4877: do_jump (exp, label, 0);
4878: }
4879:
4880: /* Generate code to evaluate EXP and jump to LABEL if the value is nonzero. */
4881:
1.1.1.2 root 4882: void
1.1 root 4883: jumpif (exp, label)
4884: tree exp;
4885: rtx label;
4886: {
4887: do_jump (exp, 0, label);
4888: }
4889:
4890: /* Generate code to evaluate EXP and jump to IF_FALSE_LABEL if
4891: the result is zero, or IF_TRUE_LABEL if the result is one.
4892: Either of IF_FALSE_LABEL and IF_TRUE_LABEL may be zero,
4893: meaning fall through in that case.
4894:
4895: This function is responsible for optimizing cases such as
4896: &&, || and comparison operators in EXP. */
4897:
1.1.1.2 root 4898: void
1.1 root 4899: do_jump (exp, if_false_label, if_true_label)
4900: tree exp;
4901: rtx if_false_label, if_true_label;
4902: {
4903: register enum tree_code code = TREE_CODE (exp);
4904: /* Some cases need to create a label to jump to
4905: in order to properly fall through.
4906: These cases set DROP_THROUGH_LABEL nonzero. */
4907: rtx drop_through_label = 0;
4908: rtx temp;
4909: rtx comparison = 0;
4910:
4911: emit_queue ();
4912:
4913: switch (code)
4914: {
4915: case ERROR_MARK:
4916: break;
4917:
4918: case INTEGER_CST:
4919: temp = integer_zerop (exp) ? if_false_label : if_true_label;
4920: if (temp)
4921: emit_jump (temp);
4922: break;
4923:
4924: case ADDR_EXPR:
4925: /* The address of something can never be zero. */
4926: if (if_true_label)
4927: emit_jump (if_true_label);
4928: break;
1.1.1.6 root 4929:
1.1 root 4930: case NOP_EXPR:
4931: do_jump (TREE_OPERAND (exp, 0), if_false_label, if_true_label);
4932: break;
4933:
4934: case TRUTH_NOT_EXPR:
4935: do_jump (TREE_OPERAND (exp, 0), if_true_label, if_false_label);
4936: break;
4937:
4938: case TRUTH_ANDIF_EXPR:
4939: if (if_false_label == 0)
4940: if_false_label = drop_through_label = gen_label_rtx ();
4941: do_jump (TREE_OPERAND (exp, 0), if_false_label, 0);
4942: do_jump (TREE_OPERAND (exp, 1), if_false_label, if_true_label);
4943: break;
4944:
4945: case TRUTH_ORIF_EXPR:
4946: if (if_true_label == 0)
4947: if_true_label = drop_through_label = gen_label_rtx ();
4948: do_jump (TREE_OPERAND (exp, 0), 0, if_true_label);
4949: do_jump (TREE_OPERAND (exp, 1), if_false_label, if_true_label);
4950: break;
4951:
4952: case COMPOUND_EXPR:
1.1.1.2 root 4953: expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0);
1.1 root 4954: emit_queue ();
4955: do_jump (TREE_OPERAND (exp, 1), if_false_label, if_true_label);
4956: break;
4957:
4958: case COND_EXPR:
4959: {
4960: register rtx label1 = gen_label_rtx ();
4961: drop_through_label = gen_label_rtx ();
4962: do_jump (TREE_OPERAND (exp, 0), label1, 0);
4963: /* Now the THEN-expression. */
4964: do_jump (TREE_OPERAND (exp, 1),
4965: if_false_label ? if_false_label : drop_through_label,
4966: if_true_label ? if_true_label : drop_through_label);
4967: emit_label (label1);
4968: /* Now the ELSE-expression. */
4969: do_jump (TREE_OPERAND (exp, 2),
4970: if_false_label ? if_false_label : drop_through_label,
4971: if_true_label ? if_true_label : drop_through_label);
4972: }
4973: break;
4974:
4975: case EQ_EXPR:
4976: comparison = compare (exp, EQ, EQ, EQ, EQ);
4977: break;
4978:
4979: case NE_EXPR:
4980: comparison = compare (exp, NE, NE, NE, NE);
4981: break;
4982:
4983: case LT_EXPR:
4984: comparison = compare (exp, LT, LTU, GT, GTU);
4985: break;
4986:
4987: case LE_EXPR:
4988: comparison = compare (exp, LE, LEU, GE, GEU);
4989: break;
4990:
4991: case GT_EXPR:
4992: comparison = compare (exp, GT, GTU, LT, LTU);
4993: break;
4994:
4995: case GE_EXPR:
4996: comparison = compare (exp, GE, GEU, LE, LEU);
4997: break;
4998:
4999: default:
5000: temp = expand_expr (exp, 0, VOIDmode, 0);
1.1.1.2 root 5001: /* Copy to register to avoid generating bad insns by cse
5002: from (set (mem ...) (arithop)) (set (cc0) (mem ...)). */
5003: if (!cse_not_expected && GET_CODE (temp) == MEM)
5004: temp = copy_to_reg (temp);
1.1 root 5005: do_pending_stack_adjust ();
1.1.1.2 root 5006: {
1.1.1.16 root 5007: rtx zero = CONST0_RTX (GET_MODE (temp));
1.1 root 5008:
1.1.1.2 root 5009: if (GET_CODE (temp) == CONST_INT)
5010: comparison = compare_constants (NE, 0,
5011: INTVAL (temp), 0, BITS_PER_WORD);
5012: else if (GET_MODE (temp) != VOIDmode)
5013: comparison = compare1 (temp, zero, NE, NE, 0, GET_MODE (temp));
5014: else
5015: abort ();
5016: }
1.1 root 5017: }
5018:
1.1.1.2 root 5019: /* Do any postincrements in the expression that was tested. */
5020: emit_queue ();
5021:
1.1 root 5022: /* If COMPARISON is nonzero here, it is an rtx that can be substituted
5023: straight into a conditional jump instruction as the jump condition.
5024: Otherwise, all the work has been done already. */
5025:
1.1.1.2 root 5026: if (comparison == const1_rtx)
5027: {
5028: if (if_true_label)
5029: emit_jump (if_true_label);
5030: }
5031: else if (comparison == const0_rtx)
5032: {
5033: if (if_false_label)
5034: emit_jump (if_false_label);
5035: }
5036: else if (comparison)
5037: {
5038: if (if_true_label)
5039: {
1.1.1.13 root 5040: if (bcc_gen_fctn[(int) GET_CODE (comparison)] != 0)
5041: emit_jump_insn ((*bcc_gen_fctn[(int) GET_CODE (comparison)]) (if_true_label));
5042: else
5043: abort ();
5044:
1.1.1.2 root 5045: if (if_false_label)
5046: emit_jump (if_false_label);
5047: }
5048: else if (if_false_label)
5049: {
1.1.1.13 root 5050: rtx pat;
5051:
5052: if (bcc_gen_fctn[(int) GET_CODE (comparison)] == 0)
5053: abort ();
5054:
5055: pat = (*bcc_gen_fctn[(int) GET_CODE (comparison)]) (if_false_label);
5056: /* Now invert the sense of the jump by exchanging the two arms
5057: of each IF_THEN_ELSE. Note that inverting the condition
5058: would be incorrect for IEEE floating point with nans! */
1.1.1.14 root 5059: if (GET_CODE (pat) == SEQUENCE)
5060: {
5061: int i;
5062: /* We can invert a sequence if the only jump is at the end. */
1.1.1.18! root 5063: for (i = 0; i < (int) (XVECLEN (pat, 0) - 1); i++)
1.1.1.14 root 5064: if (GET_CODE (XVECEXP (pat, 0, i)) == JUMP_INSN)
5065: abort ();
1.1.1.16 root 5066: invert_exp (PATTERN (XVECEXP (pat, 0, XVECLEN (pat, 0) - 1)),
5067: 0, 0);
1.1.1.14 root 5068: }
5069: else
5070: invert_exp (pat, 0, 0);
5071:
1.1.1.13 root 5072: emit_jump_insn (pat);
1.1.1.2 root 5073: }
5074: }
1.1 root 5075:
5076: if (drop_through_label)
5077: emit_label (drop_through_label);
5078: }
5079:
1.1.1.2 root 5080: /* Compare two integer constant rtx's, OP0 and OP1.
5081: The comparison operation is OPERATION.
5082: Return an rtx representing the value 1 or 0.
5083: WIDTH is the width in bits that is significant. */
5084:
5085: static rtx
5086: compare_constants (operation, unsignedp, op0, op1, width)
5087: enum rtx_code operation;
5088: int unsignedp;
5089: int op0, op1;
5090: int width;
5091: {
5092: int val;
5093:
5094: /* Sign-extend or zero-extend the operands to a full word
5095: from an initial width of WIDTH bits. */
5096: if (width < HOST_BITS_PER_INT)
5097: {
5098: op0 &= (1 << width) - 1;
5099: op1 &= (1 << width) - 1;
5100:
5101: if (! unsignedp)
5102: {
5103: if (op0 & (1 << (width - 1)))
5104: op0 |= ((-1) << width);
5105: if (op1 & (1 << (width - 1)))
5106: op1 |= ((-1) << width);
5107: }
5108: }
5109:
5110: switch (operation)
5111: {
5112: case EQ:
5113: val = op0 == op1;
5114: break;
5115:
5116: case NE:
5117: val = op0 != op1;
5118: break;
5119:
5120: case GT:
5121: case GTU:
5122: val = op0 > op1;
5123: break;
5124:
5125: case LT:
5126: case LTU:
5127: val = op0 < op1;
5128: break;
5129:
5130: case GE:
5131: case GEU:
5132: val = op0 >= op1;
5133: break;
5134:
5135: case LE:
5136: case LEU:
5137: val = op0 <= op1;
5138: }
5139:
5140: return val ? const1_rtx : const0_rtx;
5141: }
5142:
1.1 root 5143: /* Generate code for a comparison expression EXP
5144: (including code to compute the values to be compared)
5145: and set (CC0) according to the result.
5146: SIGNED_FORWARD should be the rtx operation for this comparison for
5147: signed data; UNSIGNED_FORWARD, likewise for use if data is unsigned.
5148: SIGNED_REVERSE and UNSIGNED_REVERSE are used if it is desirable
5149: to interchange the operands for the compare instruction.
5150:
5151: We force a stack adjustment unless there are currently
5152: things pushed on the stack that aren't yet used. */
5153:
5154: static rtx
5155: compare (exp, signed_forward, unsigned_forward,
5156: signed_reverse, unsigned_reverse)
5157: register tree exp;
5158: enum rtx_code signed_forward, unsigned_forward;
5159: enum rtx_code signed_reverse, unsigned_reverse;
5160: {
1.1.1.2 root 5161:
1.1 root 5162: register rtx op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0);
5163: register rtx op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
5164: register enum machine_mode mode = GET_MODE (op0);
5165: int unsignedp;
5166:
5167: /* If one operand is 0, make it the second one. */
5168:
1.1.1.16 root 5169: if (op0 == const0_rtx
5170: || (GET_MODE_CLASS (mode) == MODE_FLOAT && op0 == CONST0_RTX (mode)))
1.1 root 5171: {
5172: rtx tem = op0;
5173: op0 = op1;
5174: op1 = tem;
5175: signed_forward = signed_reverse;
5176: unsigned_forward = unsigned_reverse;
5177: }
5178:
1.1.1.2 root 5179: if (flag_force_mem)
1.1 root 5180: {
5181: op0 = force_not_mem (op0);
5182: op1 = force_not_mem (op1);
5183: }
5184:
5185: do_pending_stack_adjust ();
5186:
1.1.1.2 root 5187: unsignedp = (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0)))
5188: || TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 1))));
5189:
5190: if (GET_CODE (op0) == CONST_INT && GET_CODE (op1) == CONST_INT)
5191: return compare_constants (signed_forward, unsignedp,
5192: INTVAL (op0), INTVAL (op1),
5193: GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))));
1.1 root 5194:
5195: emit_cmp_insn (op0, op1,
5196: (mode == BLKmode) ? expr_size (TREE_OPERAND (exp, 0)) : 0,
1.1.1.14 root 5197: unsignedp,
5198: TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
1.1 root 5199:
5200: return gen_rtx ((unsignedp ? unsigned_forward : signed_forward),
5201: VOIDmode, cc0_rtx, const0_rtx);
5202: }
5203:
5204: /* Like compare but expects the values to compare as two rtx's.
5205: The decision as to signed or unsigned comparison must be made by the caller.
5206: BLKmode is not allowed. */
5207:
5208: static rtx
1.1.1.2 root 5209: compare1 (op0, op1, forward_op, reverse_op, unsignedp, mode)
1.1 root 5210: register rtx op0, op1;
5211: enum rtx_code forward_op, reverse_op;
5212: int unsignedp;
1.1.1.2 root 5213: enum machine_mode mode;
1.1 root 5214: {
5215: /* If one operand is 0, make it the second one. */
5216:
1.1.1.16 root 5217: if (op0 == const0_rtx
5218: || (GET_MODE_CLASS (mode) == MODE_FLOAT && op0 == CONST0_RTX (mode)))
1.1 root 5219: {
5220: rtx tem = op0;
5221: op0 = op1;
5222: op1 = tem;
5223: forward_op = reverse_op;
5224: }
5225:
1.1.1.2 root 5226: if (flag_force_mem)
1.1 root 5227: {
5228: op0 = force_not_mem (op0);
5229: op1 = force_not_mem (op1);
5230: }
5231:
5232: do_pending_stack_adjust ();
5233:
1.1.1.2 root 5234: if (GET_CODE (op0) == CONST_INT && GET_CODE (op1) == CONST_INT)
5235: return compare_constants (forward_op, unsignedp,
5236: INTVAL (op0), INTVAL (op1),
5237: GET_MODE_BITSIZE (mode));
5238:
1.1.1.14 root 5239: emit_cmp_insn (op0, op1, 0, unsignedp, 0);
1.1 root 5240:
5241: return gen_rtx (forward_op, VOIDmode, cc0_rtx, const0_rtx);
5242: }
5243:
5244: /* Generate code to calculate EXP using a store-flag instruction
5245: and return an rtx for the result.
5246: If TARGET is nonzero, store the result there if convenient.
5247:
5248: Return zero if there is no suitable set-flag instruction
5249: available on this machine. */
5250:
5251: static rtx
1.1.1.2 root 5252: do_store_flag (exp, target, mode)
1.1 root 5253: tree exp;
5254: rtx target;
1.1.1.2 root 5255: enum machine_mode mode;
1.1 root 5256: {
5257: register enum tree_code code = TREE_CODE (exp);
5258: register rtx comparison = 0;
1.1.1.2 root 5259: enum machine_mode compare_mode;
1.1.1.17 root 5260: rtx prev_insn = get_last_insn ();
5261: enum insn_code icode;
1.1 root 5262:
5263: switch (code)
5264: {
1.1.1.2 root 5265: #ifdef HAVE_seq
1.1 root 5266: case EQ_EXPR:
1.1.1.2 root 5267: if (HAVE_seq)
5268: {
5269: comparison = compare (exp, EQ, EQ, EQ, EQ);
1.1.1.17 root 5270: icode = CODE_FOR_seq;
1.1.1.2 root 5271: compare_mode = insn_operand_mode[(int) CODE_FOR_seq][0];
5272: }
1.1 root 5273: break;
5274: #endif
5275:
1.1.1.2 root 5276: #ifdef HAVE_sne
1.1 root 5277: case NE_EXPR:
1.1.1.2 root 5278: if (HAVE_sne)
5279: {
5280: comparison = compare (exp, NE, NE, NE, NE);
1.1.1.17 root 5281: icode = CODE_FOR_sne;
1.1.1.2 root 5282: compare_mode = insn_operand_mode[(int) CODE_FOR_sne][0];
5283: }
1.1 root 5284: break;
5285: #endif
5286:
1.1.1.2 root 5287: #if defined (HAVE_slt) && defined (HAVE_sltu) && defined (HAVE_sgt) && defined (HAVE_sgtu)
1.1 root 5288: case LT_EXPR:
1.1.1.2 root 5289: if (HAVE_slt && HAVE_sltu && HAVE_sgt && HAVE_sgtu)
5290: {
5291: comparison = compare (exp, LT, LTU, GT, GTU);
1.1.1.17 root 5292: icode = CODE_FOR_slt;
1.1.1.2 root 5293: compare_mode = insn_operand_mode[(int) CODE_FOR_slt][0];
5294: }
1.1 root 5295: break;
5296:
5297: case GT_EXPR:
1.1.1.2 root 5298: if (HAVE_slt && HAVE_sltu && HAVE_sgt && HAVE_sgtu)
5299: {
5300: comparison = compare (exp, GT, GTU, LT, LTU);
1.1.1.17 root 5301: icode = CODE_FOR_slt;
1.1.1.2 root 5302: compare_mode = insn_operand_mode[(int) CODE_FOR_slt][0];
5303: }
1.1 root 5304: break;
5305: #endif
5306:
1.1.1.2 root 5307: #if defined (HAVE_sle) && defined (HAVE_sleu) && defined (HAVE_sge) && defined (HAVE_sgeu)
1.1 root 5308: case LE_EXPR:
1.1.1.2 root 5309: if (HAVE_sle && HAVE_sleu && HAVE_sge && HAVE_sgeu)
5310: {
5311: comparison = compare (exp, LE, LEU, GE, GEU);
1.1.1.17 root 5312: icode = CODE_FOR_sle;
1.1.1.2 root 5313: compare_mode = insn_operand_mode[(int) CODE_FOR_sle][0];
5314: }
1.1 root 5315: break;
5316:
5317: case GE_EXPR:
1.1.1.2 root 5318: if (HAVE_sle && HAVE_sleu && HAVE_sge && HAVE_sgeu)
5319: {
5320: comparison = compare (exp, GE, GEU, LE, LEU);
1.1.1.17 root 5321: icode = CODE_FOR_sle;
1.1.1.2 root 5322: compare_mode = insn_operand_mode[(int) CODE_FOR_sle][0];
5323: }
1.1 root 5324: break;
5325: #endif
5326: }
5327: if (comparison == 0)
5328: return 0;
5329:
1.1.1.2 root 5330: if (target == 0 || GET_MODE (target) != mode
1.1.1.17 root 5331: /* Don't use specified target unless the insn can handle it. */
5332: || ! (*insn_operand_predicate[(int) icode][0]) (target, mode)
5333: /* When modes don't match, don't use specified target,
5334: because it might be the same as an operand,
5335: and then the CLOBBER output below would screw up. */
5336: || (mode != compare_mode && GET_CODE (comparison) != CONST_INT))
1.1.1.2 root 5337: target = gen_reg_rtx (mode);
5338:
5339: /* Store the comparison in its proper mode. */
1.1.1.13 root 5340: if (GET_CODE (comparison) == CONST_INT)
5341: emit_move_insn (target, comparison);
5342: else if (GET_MODE (target) != compare_mode)
1.1.1.17 root 5343: {
5344: /* We want a different mode: store result in its natural mode.
5345: Combine the mode conversion with the truncation we must do anyway. */
5346: /* Put a CLOBBER before the compare, so we don't come between
5347: the compare and the insn that uses the result. */
5348: emit_insn_after (gen_rtx (CLOBBER, VOIDmode, target), prev_insn);
5349: emit_insn ((*setcc_gen_fctn[(int) GET_CODE (comparison)])
5350: (gen_rtx (SUBREG, compare_mode, target, 0)));
5351: /* If the desired mode is wider than what we got,
5352: use an AND to convert it, but not if we will do one anyway. */
5353: #if STORE_FLAG_VALUE == 1
5354: if (GET_MODE_SIZE (mode) > GET_MODE_SIZE (compare_mode))
5355: expand_bit_and (mode, target, const1_rtx, target);
5356: #endif
5357: }
1.1.1.2 root 5358: else
1.1.1.13 root 5359: emit_insn ((*setcc_gen_fctn[(int) GET_CODE (comparison)]) (target));
1.1.1.2 root 5360:
5361: #if STORE_FLAG_VALUE != 1
1.1.1.17 root 5362: #if STORE_FLAG_VALUE & 1
1.1.1.2 root 5363: expand_bit_and (mode, target, const1_rtx, target);
1.1.1.17 root 5364: #else
5365: expand_shift (RSHIFT_EXPR, mode, target,
5366: build_int_2 (GET_MODE_BITSIZE (mode) - 1, 0),
5367: target, TRUE);
5368: #endif
1.1.1.2 root 5369: #endif
1.1 root 5370: return target;
5371: }
5372:
5373: /* Generate a tablejump instruction (used for switch statements). */
5374:
5375: #ifdef HAVE_tablejump
5376:
5377: /* INDEX is the value being switched on, with the lowest value
5378: in the table already subtracted.
5379: RANGE is the length of the jump table.
5380: TABLE_LABEL is a CODE_LABEL rtx for the table itself.
1.1.1.2 root 5381:
1.1 root 5382: DEFAULT_LABEL is a CODE_LABEL rtx to jump to if the
5383: index value is out of range. */
5384:
5385: void
5386: do_tablejump (index, range, table_label, default_label)
5387: rtx index, range, table_label, default_label;
5388: {
5389: register rtx temp;
5390:
1.1.1.14 root 5391: emit_cmp_insn (range, index, 0, 0, 0);
1.1.1.2 root 5392: emit_jump_insn (gen_bltu (default_label));
1.1.1.4 root 5393: /* If flag_force_addr were to affect this address
5394: it could interfere with the tricky assumptions made
5395: about addresses that contain label-refs,
5396: which may be valid only very near the tablejump itself. */
5397: index = memory_address_noforce
5398: (CASE_VECTOR_MODE,
5399: gen_rtx (PLUS, Pmode,
5400: gen_rtx (MULT, Pmode, index,
5401: gen_rtx (CONST_INT, VOIDmode,
5402: GET_MODE_SIZE (CASE_VECTOR_MODE))),
5403: gen_rtx (LABEL_REF, VOIDmode, table_label)));
1.1 root 5404: temp = gen_reg_rtx (CASE_VECTOR_MODE);
5405: convert_move (temp, gen_rtx (MEM, CASE_VECTOR_MODE, index), 0);
5406:
1.1.1.2 root 5407: emit_jump_insn (gen_tablejump (temp, table_label));
1.1 root 5408: }
5409:
1.1.1.2 root 5410: #endif /* HAVE_tablejump */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.